From d04ffe94eb03562a58083e9af687ec0cdf9b6ab7 Mon Sep 17 00:00:00 2001 From: Vignesh Venkat Date: Tue, 19 Nov 2024 11:39:28 -0800 Subject: [PATCH] mediacodec: Always use YUV420Flexible for 8-bit There is no reason to request P010 for 8-bit images. PiperOrigin-RevId: 698091037 --- src/codecs/android_mediacodec.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/codecs/android_mediacodec.rs b/src/codecs/android_mediacodec.rs index 33f5fa3..10c5b47 100644 --- a/src/codecs/android_mediacodec.rs +++ b/src/codecs/android_mediacodec.rs @@ -326,7 +326,12 @@ impl Decoder for MediaCodec { AMediaFormat_setInt32( format, AMEDIAFORMAT_KEY_COLOR_FORMAT, - config.android_mediacodec_output_color_format as i32, + if config.depth == 8 { + // Always use Yuv420Flexible for 8-bit images. + AndroidMediaCodecOutputColorFormat::Yuv420Flexible + } else { + config.android_mediacodec_output_color_format + } as i32, ); // low-latency is documented but isn't exposed as a constant in the NDK: // https://developer.android.com/reference/android/media/MediaFormat#KEY_LOW_LATENCY