[vlc-devel] [PATCH] mediacodec: detect size changed by comparing visible size

Zhao Zhili quinkblack at foxmail.com
Thu Aug 9 03:52:28 CEST 2018


Input size may not aligned to the requirement of codec. For H.264 We can
divide the size by macroblock size before comparing, but it doesn't work
with HEVC.
---
 modules/codec/omxil/mediacodec.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 9ee2cf6..40bc5d7 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -112,7 +112,7 @@ typedef struct
         {
             void *p_surface, *p_jsurface;
             unsigned i_angle;
-            unsigned i_input_width, i_input_height;
+            unsigned i_input_visible_width, i_input_visible_height;
             unsigned int i_stride, i_slice_height;
             int i_pixel_format;
             struct hxxx_helper hh;
@@ -259,10 +259,10 @@ static void HXXXInitSize(decoder_t *p_dec, bool *p_size_changed)
         unsigned i_w, i_h, i_vw, i_vh;
         hxxx_helper_get_current_picture_size(hh, &i_w, &i_h, &i_vw, &i_vh);
 
-        *p_size_changed = (i_w != p_sys->video.i_input_width
-                        || i_h != p_sys->video.i_input_height);
-        p_sys->video.i_input_width = i_w;
-        p_sys->video.i_input_height = i_h;
+        *p_size_changed = (i_vw != p_sys->video.i_input_visible_width
+                        || i_vh != p_sys->video.i_input_visible_height);
+        p_sys->video.i_input_visible_width = i_vw;
+        p_sys->video.i_input_visible_height = i_vh;
         /* fmt_out video size will be updated by mediacodec output callback */
     }
 }
@@ -731,9 +731,9 @@ static int OpenDecoder(vlc_object_t *p_this, pf_MediaCodecApi_init pf_init)
                 p_dec->fmt_out.video.i_sar_den = 1;
             }
 
-            p_sys->video.i_input_width =
+            p_sys->video.i_input_visible_width = p_dec->fmt_in.video.i_visible_width;
+            p_sys->video.i_input_visible_height = p_dec->fmt_in.video.i_visible_height;
             p_dec->fmt_out.video.i_visible_width = p_dec->fmt_out.video.i_width;
-            p_sys->video.i_input_height =
             p_dec->fmt_out.video.i_visible_height = p_dec->fmt_out.video.i_height;
 
             if (UpdateVout(p_dec) != VLC_SUCCESS)
-- 
2.9.5





More information about the vlc-devel mailing list