[FFmpeg-devel] [PATCH] avcodec/mediacodecdec_common: Workaround MTK broken crop implementation
Zhao Zhili
quinkblack at foxmail.com
Fri Oct 11 10:49:44 EEST 2024
From: Zhao Zhili <zhilizhao at tencent.com>
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.
---
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) {
--
2.46.0
More information about the ffmpeg-devel
mailing list