[FFmpeg-cvslog] avcodec/mediacodecdec_common: Workaround MTK broken crop implementation

Zhao Zhili git at videolan.org
Sun Oct 27 06:07:15 EET 2024


ffmpeg | branch: master | Zhao Zhili <zhilizhao at tencent.com> | Fri Oct 11 15:49:44 2024 +0800| [7fe9d12f2571265b2a7b5c763d62ee80f9a9e2e2] | committer: Zhao Zhili

avcodec/mediacodecdec_common: Workaround MTK broken crop implementation

MediaTek SOC return broken crop info, e.g.,
width: int32(3840) height: int32(2160) crop: Rect(0, 0, 318, 238)

It will notify the right crop info with infoOutputFormatChanged, but
too late.

Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7fe9d12f2571265b2a7b5c763d62ee80f9a9e2e2
---

 libavcodec/mediacodecdec_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index b1ee8b609a..84c34ac270 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -593,7 +593,8 @@ static int mediacodec_dec_parse_video_format(AVCodecContext *avctx, MediaCodecDe
     AMEDIAFORMAT_GET_INT32(s->crop_right,  "crop-right",  0);
 
     // Try "crop" for NDK
-    if (!(s->crop_right && s->crop_bottom) && s->use_ndk_codec)
+    // MediaTek SOC return some default value like Rect(0, 0, 318, 238)
+    if (!(s->crop_right && s->crop_bottom) && s->use_ndk_codec && !strstr(s->codec_name, ".mtk."))
         ff_AMediaFormat_getRect(s->format, "crop", &s->crop_left, &s->crop_top, &s->crop_right, &s->crop_bottom);
 
     if (s->crop_right && s->crop_bottom) {



More information about the ffmpeg-cvslog mailing list