[vlc-devel] [PATCH 19/31] decoder: split the creation of the vout/decoder device and the display module

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 5 16:19:58 CEST 2019


First handle the resources needed by the get_device() call, then the
format_update() which creates the display.
---
 src/input/decoder.c | 86 +++++++++++++++++++++++++++------------------
 1 file changed, 52 insertions(+), 34 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index ea0b4a38cb..d3d8ea4108 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -441,7 +441,7 @@ static void FixDisplayFormat(decoder_t *p_dec, video_format_t *fmt)
     video_format_AdjustColorSpace( fmt );
 }
 
-static int vout_update_format( decoder_t *p_dec )
+static int vout_get_device( decoder_t *p_dec )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
     bool need_vout = false;
@@ -529,47 +529,14 @@ static int vout_update_format( decoder_t *p_dec )
         p_owner->p_dec_dev = NULL;
         vlc_mutex_unlock( &p_owner->lock );
 
-        unsigned dpb_size;
-        switch( p_dec->fmt_in.i_codec )
-        {
-        case VLC_CODEC_HEVC:
-        case VLC_CODEC_H264:
-        case VLC_CODEC_DIRAC: /* FIXME valid ? */
-            dpb_size = 18;
-            break;
-        case VLC_CODEC_AV1:
-            dpb_size = 10;
-            break;
-        case VLC_CODEC_VP5:
-        case VLC_CODEC_VP6:
-        case VLC_CODEC_VP6F:
-        case VLC_CODEC_VP8:
-            dpb_size = 3;
-            break;
-        default:
-            dpb_size = 2;
-            break;
-        }
         enum vlc_vout_order order;
         vlc_decoder_device *dec_dev;
         vout_configuration_t cfg = {
             .vout = p_vout, .clock = p_owner->p_clock, .fmt = &fmt,
-            .dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
             .mouse_event = MouseEvent, .mouse_opaque = p_dec,
             .dec_devive = p_dec_dev,
         };
         p_vout = input_resource_GetVout( p_owner->p_resource, &cfg, &order, &dec_dev );
-        if (p_vout)
-        {
-            cfg.vout = p_vout;
-            if (input_resource_GetDisplay( p_owner->p_resource, &cfg) != 0)
-            {
-                p_vout = NULL;
-            }
-        }
-
-        if (p_vout)
-            decoder_Notify(p_owner, on_vout_added, p_vout, order);
 
         vlc_mutex_lock( &p_owner->lock );
         p_owner->p_vout = p_vout;
@@ -600,6 +567,56 @@ static int vout_update_format( decoder_t *p_dec )
     return 0;
 }
 
+static int vout_update_format( decoder_t *p_dec )
+{
+    struct decoder_owner *p_owner = dec_get_owner( p_dec );
+
+    video_format_t fmt;
+    FixDisplayFormat( p_dec, &fmt );
+
+    vlc_mutex_lock( &p_owner->lock );
+
+    vout_thread_t *p_vout = p_owner->p_vout;
+    vlc_mutex_unlock( &p_owner->lock );
+
+    unsigned dpb_size;
+    switch( p_dec->fmt_in.i_codec )
+    {
+    case VLC_CODEC_HEVC:
+    case VLC_CODEC_H264:
+    case VLC_CODEC_DIRAC: /* FIXME valid ? */
+        dpb_size = 18;
+        break;
+    case VLC_CODEC_AV1:
+        dpb_size = 10;
+        break;
+    case VLC_CODEC_VP5:
+    case VLC_CODEC_VP6:
+    case VLC_CODEC_VP6F:
+    case VLC_CODEC_VP8:
+        dpb_size = 3;
+        break;
+    default:
+        dpb_size = 2;
+        break;
+    }
+    vout_configuration_t cfg = {
+        .vout = p_vout, .clock = p_owner->p_clock, .fmt = &fmt,
+        .dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1,
+        .mouse_event = MouseEvent, .mouse_opaque = p_dec,
+    };
+    int res = input_resource_GetDisplay( p_owner->p_resource, &cfg);
+
+    vlc_mutex_lock( &p_owner->lock );
+    p_owner->fmt.video.i_chroma = p_dec->fmt_out.i_codec;
+    vlc_mutex_unlock( &p_owner->lock );
+
+    vlc_fifo_Lock( p_owner->p_fifo );
+    p_owner->reset_out_state = true;
+    vlc_fifo_Unlock( p_owner->p_fifo );
+    return res;
+}
+
 static picture_t *vout_new_buffer( decoder_t *p_dec )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
@@ -1743,6 +1760,7 @@ static void *DecoderThread( void *p_data )
 static const struct decoder_owner_callbacks dec_video_cbs =
 {
     .video = {
+        .get_device = vout_get_device,
         .format_update = vout_update_format,
         .buffer_new = vout_new_buffer,
         .queue = DecoderQueueVideo,
-- 
2.17.1



More information about the vlc-devel mailing list