diff --git a/src/ExtLib/ffmpeg/libavcodec/ffv1.h b/src/ExtLib/ffmpeg/libavcodec/ffv1.h index acec22e83e..39eef8087c 100644 --- a/src/ExtLib/ffmpeg/libavcodec/ffv1.h +++ b/src/ExtLib/ffmpeg/libavcodec/ffv1.h @@ -181,4 +181,8 @@ static inline void update_vlc_state(VlcState *const state, const int v) state->count = count; } +// ==> Start patch MPC +int ff_ffv1_parse_extra_data(AVCodecContext* avctx); +// ==> End patch MPC + #endif /* AVCODEC_FFV1_H */ diff --git a/src/ExtLib/ffmpeg/libavcodec/ffv1dec.c b/src/ExtLib/ffmpeg/libavcodec/ffv1dec.c index 7a0d1909aa..32d2d58ca4 100644 --- a/src/ExtLib/ffmpeg/libavcodec/ffv1dec.c +++ b/src/ExtLib/ffmpeg/libavcodec/ffv1dec.c @@ -1118,3 +1118,19 @@ const FFCodec ff_ffv1_decoder = { .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_USES_PROGRESSFRAMES, }; + +// ==> Start patch MPC +int ff_ffv1_parse_extra_data(AVCodecContext* avctx) +{ + FFV1Context* f = avctx->priv_data; + int ret; + + if ((ret = ff_ffv1_common_init(avctx)) < 0) + return ret; + + if (avctx->extradata_size > 0 && (ret = read_extra_header(f)) < 0) + return ret; + + return 0; +} +// ==> End patch MPC diff --git a/src/filters/transform/MPCVideoDec/ffmpegContext.cpp b/src/filters/transform/MPCVideoDec/ffmpegContext.cpp index df8621ae2f..8ba33dfa32 100644 --- a/src/filters/transform/MPCVideoDec/ffmpegContext.cpp +++ b/src/filters/transform/MPCVideoDec/ffmpegContext.cpp @@ -269,11 +269,18 @@ void FillAVCodecProps(struct AVCodecContext* pAVCtx, BITMAPINFOHEADER* pBMI) break; case AV_CODEC_ID_FFV1: if (pAVCtx->priv_data) { - const FFV1Context* h = (FFV1Context*)pAVCtx->priv_data; - if (h->version > 0) { // extra data has been parse - if (h->colorspace == 0) { + auto f = static_cast(pAVCtx->priv_data); + if (!f->version) { + if (ff_ffv1_parse_extra_data(pAVCtx) < 0) { + break; + } + } + if (f->version > 0) { // extra data has been parse + if (f->colorspace == 0) { + auto chorma_shift = 16 * f->chroma_h_shift + f->chroma_v_shift; + if (pAVCtx->bits_per_raw_sample <= 8) { // <=8 bit and transparency - switch (16 * h->chroma_h_shift + h->chroma_v_shift) { + switch (chorma_shift) { case 0x00: pAVCtx->pix_fmt = AV_PIX_FMT_YUV444P; break; case 0x01: pAVCtx->pix_fmt = AV_PIX_FMT_YUV440P; break; case 0x10: pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P; break; @@ -283,21 +290,21 @@ void FillAVCodecProps(struct AVCodecContext* pAVCtx, BITMAPINFOHEADER* pBMI) } } else if (pAVCtx->bits_per_raw_sample <= 10) { // 9, 10 bit and transparency - switch (16 * h->chroma_h_shift + h->chroma_v_shift) { + switch (chorma_shift) { case 0x00: pAVCtx->pix_fmt = AV_PIX_FMT_YUV444P10; break; case 0x10: pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P10; break; case 0x11: pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P10; break; } } else if (pAVCtx->bits_per_raw_sample <= 16) { // 12, 14, 16 bit and transparency - switch (16 * h->chroma_h_shift + h->chroma_v_shift) { + switch (chorma_shift) { case 0x00: pAVCtx->pix_fmt = AV_PIX_FMT_YUV444P16; break; case 0x10: pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P16; break; case 0x11: pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P16; break; } } } - else if (h->colorspace == 1) { + else if (f->colorspace == 1) { pAVCtx->pix_fmt = AV_PIX_FMT_RGBA; // and other RGB formats, but it is not important here } } @@ -318,7 +325,7 @@ void FillAVCodecProps(struct AVCodecContext* pAVCtx, BITMAPINFOHEADER* pBMI) case AV_CODEC_ID_DXTORY: pAVCtx->pix_fmt = AV_PIX_FMT_RGB24; // and other RGB formats, but it is not important here break; - /* + /* case AV_CODEC_ID_VVC: { auto s = reinterpret_cast(pAVCtx->priv_data); @@ -370,7 +377,7 @@ void FillAVCodecProps(struct AVCodecContext* pAVCtx, BITMAPINFOHEADER* pBMI) } } break; - */ + */ } if (pAVCtx->pix_fmt == AV_PIX_FMT_NONE) {