From f8946f2e94518d231fc220c110d763cfa2284c59 Mon Sep 17 00:00:00 2001 From: Steinar Gunderson Date: Sat, 25 Sep 2010 00:04:14 +0200 Subject: [PATCH] Change SDI default aspect ratio to square pixels, and add a --sdi-aspect-ratio flag to override it. --- modules/access/sdi.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 ); -- 2.39.2