From 75add792ab402be13bef5f5b66a86342ea1f4915 Mon Sep 17 00:00:00 2001 From: Rajy Rawther Date: Wed, 8 Jan 2025 13:26:08 -0800 Subject: [PATCH] fix for build errors with FFMpeg version 6 (#489) * fix for build errors with FFMpeg version 6 * set initialize for reconfigure [ROCm/rocdecode commit: f02751900dfe7f9f9cf02d2713bc4c54b06f9ab9] --- .../rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.cpp | 5 +++-- .../rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.h | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.cpp b/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.cpp index 54b7e58f78..0d0caaf626 100644 --- a/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.cpp +++ b/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.cpp @@ -246,7 +246,7 @@ int FFMpegVideoDecoder::HandleVideoSequence(RocdecVideoFormat *p_video_format) { if (coded_width_ && coded_height_) { end_of_stream_ = false; - // rocdecCreateDecoder() has been called before, and now there's possible config change + b_decoder_initialized = false; // reinitialize for reconfigure return ReconfigureDecoder(p_video_format); } // e_codec has been set in the constructor (for parser). Here it's set again for potential correction @@ -798,8 +798,9 @@ int FFMpegVideoDecoder::DecodeAvFrame(AVPacket *av_pkt, AVFrame *p_frame) { return 0; } // for the first frame, initialize OutputsurfaceInfo - if (dec_context_->frame_number == 1) { + if (!b_decoder_initialized) { InitOutputFrameInfo(p_frame); + b_decoder_initialized = true; } decoded_pic_cnt_++; if (no_multithreading_) diff --git a/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.h b/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.h index dfee5cb446..53b48060d1 100644 --- a/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.h +++ b/projects/rocdecode/utils/ffmpegvideodecode/ffmpeg_video_dec.h @@ -214,6 +214,7 @@ class FFMpegVideoDecoder: public RocVideoDecoder { typedef enum { STATUS_SUCCESS = 0, STATUS_FAILURE = -1 } StatusType; bool no_multithreading_ = false; + bool b_decoder_initialized = false; uint32_t av_frame_cnt_ = 0; uint32_t av_pkt_cnt_ = 0; RocdecSourceDataPacket last_packet_; @@ -230,7 +231,11 @@ class FFMpegVideoDecoder: public RocVideoDecoder { // Variables for FFMpeg decoding AVCodecContext * dec_context_ = nullptr; AVPixelFormat decoder_pixel_format_; +#if USE_AVCODEC_GREATER_THAN_58_134 + const AVCodec *_decoder = nullptr; +#else AVCodec *decoder_ = nullptr; +#endif AVFormatContext * formatContext = nullptr; AVInputFormat * inputFormat = nullptr; AVStream *video = nullptr;