From: Steinar Gunderson Date: Fri, 24 Sep 2010 22:04:14 +0000 (+0200) Subject: Change SDI default aspect ratio to square pixels, and add a --sdi-aspect-ratio flag... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f8946f2e94518d231fc220c110d763cfa2284c59;p=vlc Change SDI default aspect ratio to square pixels, and add a --sdi-aspect-ratio flag to override it. --- diff --git a/modules/access/sdi.cpp b/modules/access/sdi.cpp index fa286ca89d..4ae22c5488 100644 --- a/modules/access/sdi.cpp +++ b/modules/access/sdi.cpp @@ -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 );