]> git.sesse.net Git - vlc/commitdiff
* ts: fix segfault with old dvbpsi, fix uninitialized variables
authorLaurent Aimar <fenrir@videolan.org>
Sun, 9 Oct 2005 17:01:08 +0000 (17:01 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 9 Oct 2005 17:01:08 +0000 (17:01 +0000)
 * pes: memset header before using bits_* in DEBUG mode (to please valgrind)
 * bits: cosmetics.

modules/mux/mpeg/bits.h
modules/mux/mpeg/pes.c
modules/mux/mpeg/ts.c

index abe1b905ece4b41822f4e96fe0c8454486db17cd..5d5c26a8eecdca7441f0af97070c738564820046 100644 (file)
@@ -43,18 +43,9 @@ static inline int bits_initwrite( bits_buffer_t *p_buffer,
     if( !p_buffer->p_data )
     {
         if( !( p_buffer->p_data = malloc( i_size ) ) )
-        {
-            return( -1 );
-        }
-        else
-        {
-            return( 0 );
-        }
-    }
-    else
-    {
-        return( 0 );
+            return -1;
     }
+    return 0;
 }
 
 static inline void bits_align( bits_buffer_t *p_buffer )
index e983ec2f110bb8a1cdfe6ae1415baaf8bf4d9531..11bf44117d04f9376c0c031fb5f44c0130926abe 100644 (file)
@@ -65,7 +65,6 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
         }
     }
 
-
     bits_initwrite( &bits, 50, p_hdr );
 
     /* add start code */
@@ -272,6 +271,10 @@ int E_( EStoPES )( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
 
     *pp_pes = p_pes = NULL;
 
+#ifdef DEBUG
+    memset( header, 0, 50 );
+#endif
+
     do
     {
         i_pes_payload = __MIN( i_size, (i_max_pes_size ?
index e6c3094cc3e8d64602c7ce5faa1e9769ddb312af..17ff3873d47a9c3a3eb8c35ae350e745ea8e296f 100644 (file)
@@ -544,28 +544,38 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_pat_version_number = rand() % 32;
     p_sys->pat.i_pid = 0;
     p_sys->pat.i_continuity_counter = 0;
+    p_sys->pat.b_discontinuity = VLC_FALSE;
 
     var_Get( p_mux, SOUT_CFG_PREFIX "tsid", &val );
     if ( val.i_int )
         p_sys->i_tsid = val.i_int;
     else
         p_sys->i_tsid = rand() % 65536;
+
+    p_sys->i_netid = rand() % 65536;
+#ifdef HAVE_DVBPSI_SDT
     var_Get( p_mux, SOUT_CFG_PREFIX "netid", &val );
     if ( val.i_int )
         p_sys->i_netid = val.i_int;
-    else
-        p_sys->i_netid = rand() % 65536;
-    p_sys->i_pmt_version_number = rand() % 32;
-    p_sys->sdt.i_continuity_counter = 0;
+#endif
 
+    p_sys->i_pmt_version_number = rand() % 32;
     for( i = 0; i < p_sys->i_num_pmt; i++ )
+    {
         p_sys->pmt[i].i_continuity_counter = 0;
+        p_sys->pmt[i].b_discontinuity = VLC_FALSE;
+    }
+
+    p_sys->sdt.i_pid = 0x11;
+    p_sys->sdt.i_continuity_counter = 0;
+    p_sys->sdt.b_discontinuity = VLC_FALSE;
 
+#ifdef HAVE_DVBPSI_SDT
     var_Get( p_mux, SOUT_CFG_PREFIX "sdtdesc", &val );
     p_sys->b_sdt = val.psz_string && *val.psz_string ? VLC_TRUE : VLC_FALSE;
 
     /* Syntax is provider_sdt1,service_name_sdt1,provider_sdt2,service_name_sdt2... */
-    if( val.psz_string != NULL && *val.psz_string )
+    if( p_sys->b_sdt )
     {
 
         char *psz = val.psz_string;
@@ -595,6 +605,9 @@ static int Open( vlc_object_t *p_this )
         }
     }
     if( val.psz_string != NULL ) free( val.psz_string );
+#else
+    p_sys->b_sdt = VLC_FALSE;
+#endif
 
     var_Get( p_mux, SOUT_CFG_PREFIX "program-pmt", &val );
     if( val.psz_string && *val.psz_string )
@@ -2475,7 +2488,6 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
     {
         p_section2 = dvbpsi_GenSDTSections( &sdt );
         p_sdt = WritePSISection( p_mux->p_sout, p_section2 );
-        p_sys->sdt.i_pid = 0x11;
         PEStoTS( p_mux->p_sout, c, p_sdt, &p_sys->sdt );
         dvbpsi_DeletePSISections( p_section2 );
         dvbpsi_EmptySDT( &sdt );