[vlc-commits] demux: ts: split OD/IODInit

Francois Cartegnie git at videolan.org
Tue Mar 31 21:22:40 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Mar 28 23:27:37 2015 +0100| [05c045e40907713a5149d0513a0761d7afb12093] | committer: Francois Cartegnie

demux: ts: split OD/IODInit

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

 modules/demux/mpeg4_iod.c |   38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/modules/demux/mpeg4_iod.c b/modules/demux/mpeg4_iod.c
index c0e8536..1210042 100644
--- a/modules/demux/mpeg4_iod.c
+++ b/modules/demux/mpeg4_iod.c
@@ -438,6 +438,26 @@ static uint8_t IOD_Desc_Read( vlc_object_t *p_object, unsigned *pi_data, const u
     return i_read_count;
 }
 
+static iod_descriptor_t *ODInit( vlc_object_t *p_object, unsigned i_data, const uint8_t *p_data,
+                                 uint8_t i_start_tag, uint8_t i_min, uint8_t i_max )
+{
+    /* Initial Object Descriptor must follow */
+    iod_descriptor_t *p_iod = calloc( 1, sizeof( iod_descriptor_t ) );
+    if( !p_iod )
+        return NULL;
+
+    iod_read_params_t params;
+    params.p_iod = p_iod;
+    if ( IOD_Desc_Read( p_object, &i_data, &p_data, i_start_tag, i_max, params ) < i_min )
+    {
+        iod_debug( p_object, "   cannot read first tag 0x%"PRIx8, i_start_tag );
+        free( p_iod );
+        return NULL;
+    }
+
+    return p_iod;
+}
+
 iod_descriptor_t *IODNew( vlc_object_t *p_object, unsigned i_data, const uint8_t *p_data )
 {
     if( i_data < 4 )
@@ -461,23 +481,7 @@ iod_descriptor_t *IODNew( vlc_object_t *p_object, unsigned i_data, const uint8_t
         return NULL;
     }
 
-    /* Initial Object Descriptor must follow */
-    iod_descriptor_t *p_iod = calloc( 1, sizeof( iod_descriptor_t ) );
-    if( !p_iod )
-        return NULL;
-
-    /* IOD_InitialObjectDescrTag Parsing */
-    iod_read_params_t params;
-    params.p_iod = p_iod;
-    if ( 1 != IOD_Desc_Read( p_object, &i_data, &p_data,
-                             IODTag_InitialObjectDescr, 1, params ) )
-    {
-        iod_debug( p_object, "   cannot read InitialObjectDescr" );
-        free( p_iod );
-        return NULL;
-    }
-
-    return p_iod;
+    return ODInit( p_object, i_data, p_data, IODTag_InitialObjectDescr, 1, 1 );
 }
 
 void IODFree( iod_descriptor_t *p_iod )



More information about the vlc-commits mailing list