[vlc-devel] [PATCH] decoder: initialize the CC state earlier

Alexandre Janniaux ajanni at videolabs.io
Thu Feb 18 08:49:17 UTC 2021


The decoder owner can be returned earlier in the CreateDecoder function,
leaving the owner.cc state uninitialized.

Except b_supported, no functional changes in most cases since it was
allocated by calloc anyway.
---
 src/input/decoder.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index be04818859..41c7f88d2a 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1876,6 +1876,16 @@ CreateDecoder( vlc_object_t *p_parent,
         }
     }
 
+    /* */
+    p_owner->cc.b_supported = ( p_sout == NULL );
+
+    p_owner->cc.desc.i_608_channels = 0;
+    p_owner->cc.desc.i_708_channels = 0;
+    for( unsigned i = 0; i < MAX_CC_DECODERS; i++ )
+        p_owner->cc.pp_decoder[i] = NULL;
+    p_owner->cc.p_sout_input = NULL;
+    p_owner->cc.b_sout_created = false;
+
     switch( fmt->i_cat )
     {
         case VIDEO_ES:
@@ -1918,16 +1928,6 @@ CreateDecoder( vlc_object_t *p_parent,
             }
         }
     }
-
-    /* */
-    p_owner->cc.b_supported = ( p_sout == NULL );
-
-    p_owner->cc.desc.i_608_channels = 0;
-    p_owner->cc.desc.i_708_channels = 0;
-    for( unsigned i = 0; i < MAX_CC_DECODERS; i++ )
-        p_owner->cc.pp_decoder[i] = NULL;
-    p_owner->cc.p_sout_input = NULL;
-    p_owner->cc.b_sout_created = false;
     return p_owner;
 }
 
-- 
2.30.1



More information about the vlc-devel mailing list