Commit f42f818e authored by dionoea's avatar dionoea
Browse files

Add aspect ratio option to canvas (like what transcode used to have). Please...

Add aspect ratio option to canvas (like what transcode used to have). Please confirm that i'm not using the aspect ratio the wrong way :) (aspect instead of 1/aspect or something)
parent d29ca07c
......@@ -50,6 +50,9 @@ static int alloc_init( filter_t *, void * );
#define HEIGHT_TEXT N_( "Image height" )
#define HEIGHT_LONGTEXT N_( \
"Image height" )
#define ASPECT_TEXT N_( "Aspect ratio" )
#define ASPECT_LONGTEXT N_( \
"Set aspect (like 4:3) of the video canvas" )
#define CFG_PREFIX "canvas-"
......@@ -65,10 +68,13 @@ vlc_module_begin();
WIDTH_TEXT, WIDTH_LONGTEXT, false );
add_integer_with_range( CFG_PREFIX "height", 0, 0, INT_MAX, NULL,
HEIGHT_TEXT, HEIGHT_LONGTEXT, false );
add_string( CFG_PREFIX "aspect", "4:3", NULL,
ASPECT_TEXT, ASPECT_LONGTEXT, false );
vlc_module_end();
static const char *const ppsz_filter_options[] = {
"width", "height", NULL
"width", "height", "aspect", NULL
};
struct filter_sys_t
......@@ -86,6 +92,8 @@ static int Activate( vlc_object_t *p_this )
es_format_t fmt;
char psz_croppadd[100];
int i_padd;
char *psz_aspect, *psz_parser;
int i_aspect;
if( !p_filter->b_allow_fmt_out_change )
{
......@@ -117,6 +125,26 @@ static int Activate( vlc_object_t *p_this )
return VLC_EGENERIC;
}
psz_aspect = var_CreateGetNonEmptyString( p_filter, CFG_PREFIX "aspect" );
if( !psz_aspect )
{
msg_Err( p_filter, "Aspect ratio must be set" );
return VLC_EGENERIC;
}
psz_parser = strchr( psz_aspect, ':' );
if( psz_parser ) psz_parser++;
if( psz_parser && atoi( psz_parser ) > 0 )
i_aspect = atoi( psz_aspect ) * VOUT_ASPECT_FACTOR / atoi( psz_parser );
else
i_aspect = atof( psz_aspect ) * VOUT_ASPECT_FACTOR;
free( psz_aspect );
if( i_aspect <= 0 )
{
msg_Err( p_filter, "Aspect ratio must be strictly positive" );
return VLC_EGENERIC;
}
filter_sys_t *p_sys = (filter_sys_t *)malloc( sizeof( filter_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
......@@ -168,6 +196,8 @@ static int Activate( vlc_object_t *p_this )
fmt = *filter_chain_GetFmtOut( p_sys->p_chain );
es_format_Copy( &p_filter->fmt_out, &fmt );
p_filter->fmt_out.video.i_aspect = i_aspect * i_width / i_height;
if( p_filter->fmt_out.video.i_width != i_width
|| p_filter->fmt_out.video.i_height != 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