[vlc-devel] [PATCH 2/3] mediacodec: fix AMediaCodec.configure failed on some devices

Zhao Zhili quinkblack at foxmail.com
Wed Feb 3 12:53:07 UTC 2021


fmt_out.video.i_width/i_height are used in MediaCodec configure.
They are not set in --no-mediacodec-dr. Some devices require video
size to be non-zero. For example, Huawei P20 failed with the
following log:

I ACodec  : In onAllocateComponent create compenent, codec name: OMX.hisi.video.decoder.avc
E ACodec  : Wrong cropped rect (0, 0, 0, 0) vs. frame (0, 0)
E ACodec  : [OMX.hisi.video.decoder.avc] configureCodec returning error -22

E NdkMediaCodec: configure: err(-22), failed with format: AMessage(what = 'conf', target = 1) = {
E NdkMediaCodec:   int32_t encoder = 0
E NdkMediaCodec:   string mime = "video/avc"
E NdkMediaCodec:   int32_t max-input-size = 0
E NdkMediaCodec:   int32_t width = 0
E NdkMediaCodec:   int32_t height = 0
E NdkMediaCodec:   int32_t rotation-degrees = 0
E NdkMediaCodec: }
---
 modules/codec/omxil/mediacodec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 2788b049d0..f8435f342c 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -946,6 +946,11 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
             }
 
         }
+        else
+        {
+            p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width;
+            p_dec->fmt_out.video.i_height = p_dec->fmt_in.video.i_height;
+        }
         p_sys->cat = VIDEO_ES;
     }
     else
-- 
2.28.0



More information about the vlc-devel mailing list