diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2024-05-23 15:08:55 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2024-06-07 13:14:46 +0800 |
commit | 2a68b2d643f7b725defa9bec5174853a00411b98 (patch) | |
tree | 87cc1a312d8ca3250a61c32a5762a8046d4aa9d2 | |
parent | 680b3cee1f481976cae9787e16f181c1d0e989bd (diff) | |
download | ffmpeg-2a68b2d643f7b725defa9bec5174853a00411b98.tar.gz |
avcodec/mediacodecenc: workaround the alignment requirement only for H.264
There is no bsf for other codecs to modify crop info except H.265.
For H.265, the assumption that FFALIGN(width, 16)xFFALIGN(height, 16)
is the video resolution can be wrong, since the encoder can use CTU
larger than 16x16. In that case, use FFALIGN(width, 16) - width
as crop_right is incorrect. So disable the workaround for H.265 now.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
-rw-r--r-- | libavcodec/mediacodecenc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c index bbf570e7be..bfff149039 100644 --- a/libavcodec/mediacodecenc.c +++ b/libavcodec/mediacodecenc.c @@ -234,7 +234,8 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) ff_AMediaFormat_setString(format, "mime", codec_mime); // Workaround the alignment requirement of mediacodec. We can't do it // silently for AV_PIX_FMT_MEDIACODEC. - if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC) { + if (avctx->pix_fmt != AV_PIX_FMT_MEDIACODEC && + avctx->codec_id == AV_CODEC_ID_H264) { s->width = FFALIGN(avctx->width, 16); s->height = FFALIGN(avctx->height, 16); } else { |