Remove 16px resolution alignment from MediaCodec

More details: https://trac.ffmpeg.org/ticket/11010
This commit is contained in:
Anton Liaposhchenko 2024-05-18 17:43:01 +03:00
parent 0159ba572b
commit 5d504f1267
2 changed files with 36 additions and 0 deletions

View File

@ -478,6 +478,10 @@ if [[ $? -ne 0 ]]; then
exit 1 exit 1
fi fi
patch "${BASEDIR}"/src/ffmpeg/libavcodec/mediacodecenc.c \
"${BASEDIR}"/tools/patch/cpp/ffmpeg/mediacodecenc.c.patch \
-N -r /dev/null || true 1>> build.log 2>&1
if [[ -z ${NO_OUTPUT_REDIRECTION} ]]; then if [[ -z ${NO_OUTPUT_REDIRECTION} ]]; then
make -j$(get_cpu_count) 1>>"${BASEDIR}"/build.log 2>&1 make -j$(get_cpu_count) 1>>"${BASEDIR}"/build.log 2>&1

View File

@ -0,0 +1,32 @@
diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
index 984014f..f2e5ab1 100644
--- a/libavcodec/mediacodecenc.c
+++ b/libavcodec/mediacodecenc.c
@@ -198,19 +198,14 @@ 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) {
- s->width = FFALIGN(avctx->width, 16);
- s->height = FFALIGN(avctx->height, 16);
- } else {
- s->width = avctx->width;
- s->height = avctx->height;
- if (s->width % 16 || s->height % 16)
- av_log(avctx, AV_LOG_WARNING,
- "Video size %dx%d isn't align to 16, it may have device compatibility issue\n",
- s->width, s->height);
- }
+
+ s->width = avctx->width;
+ s->height = avctx->height;
+ if (s->width % 16 || s->height % 16)
+ av_log(avctx, AV_LOG_WARNING,
+ "Video size %dx%d isn't align to 16, it may have device compatibility issue\n",
+ s->width, s->height);
+
ff_AMediaFormat_setInt32(format, "width", s->width);
ff_AMediaFormat_setInt32(format, "height", s->height);