From 7fe9d12f2571265b2a7b5c763d62ee80f9a9e2e2 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Fri, 11 Oct 2024 15:49:44 +0800 Subject: [PATCH] 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 --- 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) {