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@tencent.com>
This commit is contained in:
Zhao Zhili 2024-10-11 15:49:44 +08:00
parent 0ee18ff23d
commit 7fe9d12f25
1 changed files with 2 additions and 1 deletions

View File

@ -593,7 +593,8 @@ static int mediacodec_dec_parse_video_format(AVCodecContext *avctx, MediaCodecDe
AMEDIAFORMAT_GET_INT32(s->crop_right, "crop-right", 0); AMEDIAFORMAT_GET_INT32(s->crop_right, "crop-right", 0);
// Try "crop" for NDK // 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); 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) { if (s->crop_right && s->crop_bottom) {