]> git.sesse.net Git - vlc/commitdiff
* modules/stream_out/switcher.c: Added --sout-switcher-aspect-ratio option.
authorChristophe Massiot <massiot@videolan.org>
Tue, 15 Mar 2005 18:55:17 +0000 (18:55 +0000)
committerChristophe Massiot <massiot@videolan.org>
Tue, 15 Mar 2005 18:55:17 +0000 (18:55 +0000)
modules/stream_out/switcher.c

index 7c1b491fa6cae9524d7cab814f7e438e821a21c1..0832008b72c8ae9b7aba1d334f5257fe01e178b1 100644 (file)
@@ -84,6 +84,9 @@ static block_t *AudioGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
 #define SIZES_TEXT N_("Sizes")
 #define SIZES_LONGTEXT N_( \
     "List of sizes separated by colons (720x576:480x576)." )
+#define RATIO_TEXT N_("Aspect ratio")
+#define RATIO_LONGTEXT N_( \
+    "Aspect ratio (4:3, 16:9)." )
 #define PORT_TEXT N_("Command UDP port")
 #define PORT_LONGTEXT N_( \
     "UDP port to listen to for commands." )
@@ -95,7 +98,7 @@ static block_t *AudioGetBuffer( sout_stream_t *p_stream, sout_stream_id_t *id,
     "Number of P frames between two I frames." )
 #define QSCALE_TEXT N_("Quantizer scale")
 #define QSCALE_LONGTEXT N_( \
-    "Quantizer scale." )
+    "Fixed quantizer scale to use." )
 
 vlc_module_begin();
     set_description( _("MPEG2 video switcher stream output") );
@@ -107,6 +110,8 @@ vlc_module_begin();
                 FILES_LONGTEXT, VLC_FALSE );
     add_string( SOUT_CFG_PREFIX "sizes", "", NULL, SIZES_TEXT,
                 SIZES_LONGTEXT, VLC_FALSE );
+    add_string( SOUT_CFG_PREFIX "aspect-ratio", "4:3", NULL, RATIO_TEXT,
+                RATIO_LONGTEXT, VLC_FALSE );
     add_integer( SOUT_CFG_PREFIX "port", 5001, NULL,
                  PORT_TEXT, PORT_LONGTEXT, VLC_TRUE );
     add_integer( SOUT_CFG_PREFIX "command", 0, NULL,
@@ -118,7 +123,7 @@ vlc_module_begin();
 vlc_module_end();
 
 static const char *ppsz_sout_options[] = {
-    "files", "sizes", "port", "command", "gop", "qscale", NULL
+    "files", "sizes", "aspect-ratio", "port", "command", "gop", "qscale", NULL
 };
 
 struct sout_stream_sys_t
@@ -126,6 +131,7 @@ struct sout_stream_sys_t
     sout_stream_t   *p_out;
     int             i_gop;
     int             i_qscale;
+    AVRational      sample_aspect_ratio;
     sout_stream_id_t *pp_audio_ids[MAX_AUDIO];
 
     /* Pictures */
@@ -219,6 +225,32 @@ static int Open( vlc_object_t *p_this )
         p_sys->i_nb_pictures++;
     }
 
+    var_Get( p_stream, SOUT_CFG_PREFIX "aspect-ratio", &val );
+    if ( val.psz_string )
+    {
+        char *psz_parser = strchr( val.psz_string, ':' );
+
+        if( psz_parser )
+        {
+            *psz_parser++ = '\0';
+            p_sys->sample_aspect_ratio.num = atoi( val.psz_string );
+            p_sys->sample_aspect_ratio.den = atoi( psz_parser );
+        }
+        else
+        {
+            msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string );
+            p_sys->sample_aspect_ratio.num = 4;
+            p_sys->sample_aspect_ratio.den = 3;
+        }
+
+        free( val.psz_string );
+    }
+    else
+    {
+        p_sys->sample_aspect_ratio.num = 4;
+        p_sys->sample_aspect_ratio.den = 3;
+    }
+
     var_Get( p_stream, SOUT_CFG_PREFIX "port", &val );
     p_sys->i_fd = net_OpenUDP( p_stream, NULL, val.i_int, NULL, 0 );
     if ( p_sys->i_fd < 0 )
@@ -703,6 +735,8 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
 
         id->ff_enc_c->frame_rate    = 25; /* FIXME */
         id->ff_enc_c->frame_rate_base = 1;
+        memcpy( &id->ff_enc_c->sample_aspect_ratio, &p_sys->sample_aspect_ratio,
+                sizeof(AVRational) );
 
         id->ff_enc_c->gop_size = 200;
         id->ff_enc_c->max_b_frames = 0;