]> git.sesse.net Git - vlc/blobdiff - modules/mux/asf.c
ASF mux: reduce variable scope
[vlc] / modules / mux / asf.c
index 2eacd0a736f562d9db25257534b3baef94d467f6..3ecd0de7ea5c8b39e0aef5ad8982d4bc1f3d1bcf 100644 (file)
@@ -76,8 +76,7 @@ vlc_module_begin ()
     set_shortname( "ASF" )
 
     set_capability( "sout mux", 5 )
-    add_shortcut( "asf" )
-    add_shortcut( "asfh" )
+    add_shortcut( "asf", "asfh" )
     set_callbacks( Open, Close )
 
     add_string( SOUT_CFG_PREFIX "title", "", NULL, TITLE_TEXT, TITLE_LONGTEXT,
@@ -191,7 +190,6 @@ static int Open( vlc_object_t *p_this )
 {
     sout_mux_t     *p_mux = (sout_mux_t*)p_this;
     sout_mux_sys_t *p_sys;
-    int i;
 
     msg_Dbg( p_mux, "asf muxer opened" );
     config_ChainParse( p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg );
@@ -257,7 +255,6 @@ static void Close( vlc_object_t * p_this )
     sout_mux_t     *p_mux = (sout_mux_t*)p_this;
     sout_mux_sys_t *p_sys = p_mux->p_sys;
     block_t  *out;
-    int i;
 
     msg_Dbg( p_mux, "Asf muxer closed" );
 
@@ -280,7 +277,7 @@ static void Close( vlc_object_t * p_this )
     }
 
 
-    for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
+    for( int i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
     {
         asf_track_t *track = (asf_track_t *)vlc_array_item_at_index( p_sys->p_tracks, i );
         free( track->p_extra );
@@ -539,6 +536,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             {
                 tk->psz_name = "Windows Media Video 9";
                 tk->i_fourcc = VLC_FOURCC( 'W', 'M', 'V', '3' );
+                tk->b_extended = true;
             }
             else if( p_input->p_fmt->i_codec == VLC_CODEC_VC1 )
             {
@@ -629,7 +627,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
     tk->i_id = vlc_array_index_of_item( p_sys->p_tracks, tk ) + 1;
 
 
-    p_sys->b_write_header = true;
+    if( p_sys->b_asf_http )
+        p_sys->b_write_header = true;
 
     return VLC_SUCCESS;
 }
@@ -662,10 +661,11 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
         }
     }
 
-    vlc_array_remove( p_sys->p_tracks, vlc_array_index_of_item( p_sys->p_tracks, (void *)tk ) );
-
-
-    p_sys->b_write_header = true;
+    if( p_sys->b_asf_http )
+    {
+        vlc_array_remove( p_sys->p_tracks, vlc_array_index_of_item( p_sys->p_tracks, (void *)tk ) );
+        p_sys->b_write_header = true;
+    }
     return VLC_SUCCESS;
 }
 
@@ -816,11 +816,10 @@ static void bo_addle_str16_nosize( bo_t *bo, const char *str )
  ****************************************************************************/
 static void bo_add_guid( bo_t *p_bo, const guid_t *id )
 {
-    int i;
     bo_addle_u32( p_bo, id->Data1 );
     bo_addle_u16( p_bo, id->Data2 );
     bo_addle_u16( p_bo, id->Data3 );
-    for( i = 0; i < 8; i++ )
+    for( int i = 0; i < 8; i++ )
     {
         bo_add_u8( p_bo, id->Data4[i] );
     }
@@ -933,7 +932,6 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
             p_track->fmt.video.i_sar_den != 0 )
         {
             i_cm_size = 26 + 2 * (16 + 2 * sizeof("AspectRatio?"));
-            break;
         }
         if( p_track->b_extended )
             i_header_ext_size += 88;
@@ -1027,13 +1025,15 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
     if( i_cm_size )
     {
         unsigned int i_dst_num, i_dst_den;
-        asf_track_t *tk;
-        tk=NULL;
 
+        asf_track_t *tk = NULL;
         for( i = 0; i < vlc_array_count( p_sys->p_tracks ); i++ )
         {
             tk = vlc_array_item_at_index( p_sys->p_tracks, i );
-            if( tk->i_cat == VIDEO_ES ) break;
+            if( tk->i_cat == VIDEO_ES &&
+                tk->fmt.video.i_sar_num != 0 &&
+                tk->fmt.video.i_sar_den != 0 )
+                break;
         }
         assert( tk != NULL );