[vlc-devel] [PATCH 13/30] decoder: move the display creation in a separate function

Steve Lhomme robux4 at ycbcr.xyz
Wed Sep 25 15:31:02 CEST 2019


To create the vout and decoder device we don't need to know the DPB.

For now the display still holds the picture pool so the display still needs the
DBP size.
---
 src/input/decoder.c | 71 ++++++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 30 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 4663e93bb94..bd0e9d03225 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -460,6 +460,45 @@ static void FixDisplayFormat(decoder_t *p_dec, video_format_t *fmt)
     video_format_AdjustColorSpace( fmt );
 }
 
+static int CreateDisplay(struct decoder_owner *p_owner, vout_thread_t *p_vout)
+{
+    if (!p_vout)
+        return -1;
+
+    decoder_t *p_dec = &p_owner->dec;
+
+    video_format_t fmt;
+    FixDisplayFormat( p_dec, &fmt );
+
+    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,
+    };
+    return input_resource_GetDisplay( p_owner->p_resource, &cfg);
+}
+
 static int CreateVoutIfNeeded(struct decoder_owner *p_owner)
 {
     decoder_t *p_dec = &p_owner->dec;
@@ -535,36 +574,8 @@ static int CreateVoutIfNeeded(struct decoder_owner *p_owner)
     vlc_decoder_device *dec_dev = NULL;
     p_vout = input_resource_GetVoutHoldDevice( p_owner->p_resource,
                                     &cfg, &order, &dec_dev );
-    if (p_vout)
-    {
-        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;
-        }
-        cfg.dpb_size = dpb_size + p_dec->i_extra_picture_buffers + 1;
-        cfg.vout = p_vout;
-        if (input_resource_GetDisplay( p_owner->p_resource, dec_dev, &cfg) != 0)
-        {
-            p_vout = NULL;
-        }
-    }
+    if (CreateDisplay( p_owner, p_vout ) != 0)
+        p_vout = NULL;
     if (p_vout)
         decoder_Notify(p_owner, on_vout_added, p_vout, order);
 
-- 
2.17.1



More information about the vlc-devel mailing list