[vlc-commits] codec/mediacodec: update the surface when a new vout is requested

Thomas Guillem git at videolan.org
Tue Dec 13 17:11:05 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Dec 13 15:41:46 2016 +0100| [3aff6aace986c1d9d94c919c2dc4b17cdcb78332] | committer: Thomas Guillem

codec/mediacodec: update the surface when a new vout is requested

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3aff6aace986c1d9d94c919c2dc4b17cdcb78332
---

 modules/codec/omxil/mediacodec.c | 48 +++++++++++++++++++++++++++++++---------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index 4db66be..3f247b7 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -1044,17 +1044,23 @@ static int Video_ProcessOutput(decoder_t *p_dec, mc_api_out *p_out,
                 p_out->conf.video.crop_left, p_out->conf.video.crop_top,
                 p_out->conf.video.crop_right, p_out->conf.video.crop_bottom);
 
-        p_dec->fmt_out.video.i_width  = p_out->conf.video.crop_right + 1
-                                      - p_out->conf.video.crop_left;
-        p_dec->fmt_out.video.i_height = p_out->conf.video.crop_bottom + 1
-                                      - p_out->conf.video.crop_top;
-        if (p_dec->fmt_out.video.i_width <= 1
-            || p_dec->fmt_out.video.i_height <= 1) {
-            p_dec->fmt_out.video.i_width = p_out->conf.video.width;
-            p_dec->fmt_out.video.i_height = p_out->conf.video.height;
+        int i_width  = p_out->conf.video.crop_right + 1
+                     - p_out->conf.video.crop_left;
+        int i_height = p_out->conf.video.crop_bottom + 1
+                     - p_out->conf.video.crop_top;
+        if (i_width <= 1 || i_height <= 1)
+        {
+            i_width = p_out->conf.video.width;
+            i_height = p_out->conf.video.height;
         }
-        p_dec->fmt_out.video.i_visible_width = p_dec->fmt_out.video.i_width;
-        p_dec->fmt_out.video.i_visible_height = p_dec->fmt_out.video.i_height;
+        bool b_video_changed =
+            (unsigned) i_width != p_dec->fmt_out.video.i_width ||
+            (unsigned) i_height != p_dec->fmt_out.video.i_height;
+
+        p_dec->fmt_out.video.i_visible_width =
+        p_dec->fmt_out.video.i_width = i_width;
+        p_dec->fmt_out.video.i_visible_height =
+        p_dec->fmt_out.video.i_height = i_height;
 
         p_sys->video.i_stride = p_out->conf.video.stride;
         p_sys->video.i_slice_height = p_out->conf.video.slice_height;
@@ -1071,7 +1077,27 @@ static int Video_ProcessOutput(decoder_t *p_dec, mc_api_out *p_out,
             p_sys->video.i_stride = p_dec->fmt_out.video.i_width;
         }
 
-        if (decoder_UpdateVideoFormat(p_dec) != 0)
+        if (p_sys->api->b_direct_rendering)
+        {
+            if (b_video_changed)
+            {
+                /* p_surface/p_jsurface can change when the vout is updated */
+                if (UpdateOpaqueVout(p_dec) != VLC_SUCCESS)
+                    return -1;
+
+                if (p_sys->api->set_output_surface(p_sys->api,
+                        p_sys->video.p_surface, p_sys->video.p_jsurface) != 0)
+                {
+                    /* Corner case: not able to update directly the new surface
+                     * to MediaCodec: ask for a restart */
+                    msg_Warn(p_dec, "The vout changed and the output surface "
+                             "could not be updated: restarting MediaCodec");
+                    p_sys->i_decode_flags |= DECODE_FLAG_RESTART;
+                    return 0;
+                }
+            }
+        }
+        else if (decoder_UpdateVideoFormat(p_dec) != 0)
         {
             msg_Err(p_dec, "decoder_UpdateVideoFormat failed");
             return -1;



More information about the vlc-commits mailing list