]> git.sesse.net Git - vlc/commitdiff
Change SDI default aspect ratio to square pixels, and add a --sdi-aspect-ratio flag...
authorSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 22:04:14 +0000 (00:04 +0200)
committerSteinar Gunderson <sgunderson@bigfoot.com>
Fri, 24 Sep 2010 22:04:14 +0000 (00:04 +0200)
modules/access/sdi.cpp

index fa286ca89d8f9ce88d0c24b2798e170102a4bab0..4ae22c5488f7b1a601fd42a8054d48a7cecda109 100644 (file)
@@ -46,6 +46,10 @@ static void Close( vlc_object_t * );
     "Number of input audio channels for SDI captures. " \
     "Must be 2, 8 or 16. 0 disables audio input." )
 
+#define ASPECT_RATIO_TEXT N_("Aspect ratio")
+#define ASPECT_RATIO_LONGTEXT N_( \
+    "Aspect ratio (4:3, 16:9). Default assumes square pixels." )
+
 vlc_module_begin ()
     set_shortname( N_("SDI") )
     set_description( N_("BlackMagic SDI input") )
@@ -60,6 +64,8 @@ vlc_module_begin ()
                  RATE_TEXT, RATE_LONGTEXT, true )
     add_integer( "sdi-audio-channels", 2, NULL,
                  CHANNELS_TEXT, CHANNELS_LONGTEXT, true )
+    add_string( "sdi-aspect-ratio", NULL, NULL,
+                ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, true )
 
     add_shortcut( "sdi" )
     set_capability( "access_demux", 10 )
@@ -380,11 +386,24 @@ static int Open( vlc_object_t *p_this )
     es_format_Init( &video_fmt, VIDEO_ES, VLC_CODEC_UYVY );
     video_fmt.video.i_width = p_sys->i_width;
     video_fmt.video.i_height = p_sys->i_height;
-    video_fmt.video.i_sar_num = 16 * video_fmt.video.i_height;
-    video_fmt.video.i_sar_den = 9 * video_fmt.video.i_width;
+    video_fmt.video.i_sar_num = 1;
+    video_fmt.video.i_sar_den = 1;
     video_fmt.video.i_frame_rate = p_sys->i_fps_num;
     video_fmt.video.i_frame_rate_base = p_sys->i_fps_den;
     video_fmt.i_bitrate = video_fmt.video.i_width * video_fmt.video.i_height * video_fmt.video.i_frame_rate * 2;
+    
+    char *psz_tmp = var_CreateGetNonEmptyString( p_demux, "sdi-aspect-ratio" );
+    if( psz_tmp )
+    {
+        char *psz_denominator = strchr( psz_tmp, ':' );
+        if( psz_denominator )
+        {
+            *psz_denominator++ = '\0';
+            video_fmt.video.i_sar_num = atoi( psz_tmp )         * video_fmt.video.i_height;
+            video_fmt.video.i_sar_den = atoi( psz_denominator ) * video_fmt.video.i_width;
+        }
+        free( psz_tmp );
+    }
 
     msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
              (char*)&video_fmt.i_codec, video_fmt.video.i_width, video_fmt.video.i_height );