Commit 44481f31 authored by Christophe Massiot's avatar Christophe Massiot

* modules/stream_out/mosaic_bridge.c: Added a --sout-mosaic-bridge-sar

   parameter to specify the sample aspect ratio of the destination
   background. In this case, one of {width, height} can be omitted (set
   to 0) and it will be calculated based on the PAR of the source and
   the SAR of the background.
parent 6881b72f
......@@ -48,6 +48,7 @@ struct sout_stream_sys_t
decoder_t *p_decoder;
image_handler_t *p_image; /* filter for resizing */
int i_height, i_width;
int i_sar_num, i_sar_den;
char *psz_id;
vlc_bool_t b_inited;
};
......@@ -106,6 +107,9 @@ static void video_unlink_picture_decoder( decoder_t *, picture_t * );
#define HEIGHT_TEXT N_("Video height")
#define HEIGHT_LONGTEXT N_( \
"Allows you to specify the output video height." )
#define RATIO_TEXT N_("Sample aspect ratio")
#define RATIO_LONGTEXT N_( \
"Sample aspect ratio of the destination (1:1, 3:4, 2:3)." )
#define SOUT_CFG_PREFIX "sout-mosaic-bridge-"
......@@ -121,6 +125,8 @@ vlc_module_begin();
WIDTH_LONGTEXT, VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "height", 0, NULL, HEIGHT_TEXT,
HEIGHT_LONGTEXT, VLC_TRUE );
add_string( SOUT_CFG_PREFIX "sar", "1:1", NULL, RATIO_TEXT,
RATIO_LONGTEXT, VLC_FALSE );
set_callbacks( Open, Close );
......@@ -128,7 +134,7 @@ vlc_module_begin();
vlc_module_end();
static const char *ppsz_sout_options[] = {
"id", "width", "height", NULL
"id", "width", "height", "sar", NULL
};
/*****************************************************************************
......@@ -160,6 +166,32 @@ static int Open( vlc_object_t *p_this )
var_Get( p_stream, SOUT_CFG_PREFIX "width", &val );
p_sys->i_width = val.i_int;
var_Get( p_stream, SOUT_CFG_PREFIX "sar", &val );
if ( val.psz_string )
{
char *psz_parser = strchr( val.psz_string, ':' );
if( psz_parser )
{
*psz_parser++ = '\0';
p_sys->i_sar_num = atoi( val.psz_string );
p_sys->i_sar_den = atoi( psz_parser );
vlc_reduce( &p_sys->i_sar_num, &p_sys->i_sar_den,
p_sys->i_sar_num, p_sys->i_sar_den, 0 );
}
else
{
msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string );
p_sys->i_sar_num = p_sys->i_sar_den = 1;
}
free( val.psz_string );
}
else
{
p_sys->i_sar_num = p_sys->i_sar_den = 1;
}
if ( p_sys->i_height || p_sys->i_width )
{
p_sys->p_image = image_HandlerCreate( p_stream );
......@@ -386,8 +418,26 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
fmt_in = p_sys->p_decoder->fmt_out.video;
fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
if ( !p_sys->i_height )
{
fmt_out.i_width = p_sys->i_width;
fmt_out.i_height = (p_sys->i_width * VOUT_ASPECT_FACTOR
* p_sys->i_sar_num / p_sys->i_sar_den / fmt_in.i_aspect)
& ~0x1;
}
else if ( !p_sys->i_width )
{
fmt_out.i_height = p_sys->i_height;
fmt_out.i_width = (p_sys->i_height * fmt_in.i_aspect
* p_sys->i_sar_den / p_sys->i_sar_num / VOUT_ASPECT_FACTOR)
& ~0x1;
}
else
{
fmt_out.i_width = p_sys->i_width;
fmt_out.i_height = p_sys->i_height;
}
fmt_out.i_visible_width = fmt_out.i_width;
fmt_out.i_visible_height = fmt_out.i_height;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment