[vlc-devel] [RFC PATCH 4/9] decoder: factor extra packetizer creation

Thomas Guillem thomas at gllm.fr
Sat Jul 9 12:20:12 CEST 2016


---
 src/input/decoder.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 066aba8..8608976 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -189,6 +189,26 @@ static void UnloadDecoder( decoder_t *p_dec )
     p_dec->b_error = false;
 }
 
+static decoder_t *CreateExtraPacketizer( decoder_t *p_dec, const es_format_t *fmt,
+                                         const char *psz_name )
+{
+    decoder_t *p_packetizer =
+        vlc_custom_create( p_dec, sizeof( decoder_t ), "packetizer" );
+    if( !p_packetizer )
+        return NULL;
+
+    if( LoadDecoder( p_packetizer, "packetizer", psz_name, fmt ) )
+    {
+        vlc_object_release( p_packetizer );
+        return NULL;
+    }
+    else
+    {
+        p_packetizer->fmt_out.b_packetized = true;
+        return p_packetizer;
+    }
+}
+
 static void DecoderUpdateFormatLocked( decoder_t *p_dec )
 {
     decoder_owner_sys_t *p_owner = p_dec->p_owner;
@@ -1609,21 +1629,9 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     /* Load a packetizer module if the input is not already packetized */
     if( p_sout == NULL && !fmt->b_packetized )
     {
-        p_owner->p_packetizer =
-            vlc_custom_create( p_parent, sizeof( decoder_t ), "packetizer" );
-        if( p_owner->p_packetizer )
-        {
-            if( LoadDecoder( p_owner->p_packetizer, "packetizer", NULL, fmt ) )
-            {
-                vlc_object_release( p_owner->p_packetizer );
-                p_owner->p_packetizer = NULL;
-            }
-            else
-            {
-                p_owner->p_packetizer->fmt_out.b_packetized = true;
-                fmt = &p_owner->p_packetizer->fmt_out;
-            }
-        }
+        p_owner->p_packetizer = CreateExtraPacketizer( p_dec, fmt, NULL );
+        if( p_owner->p_packetizer != NULL )
+            fmt = &p_owner->p_packetizer->fmt_out;
     }
 
     /* Find a suitable decoder/packetizer module */
-- 
2.8.1



More information about the vlc-devel mailing list