Commit 2bb4d93d authored by Gildas Bazin's avatar Gildas Bazin

* src/libvlc.h, src/video_output/vout_intf.c: added crop config option +...

* src/libvlc.h, src/video_output/vout_intf.c: added crop config option + changed --monitor-aspect-ratio into --monitor-par (pixel aspect ratio). It makes a lot more sense since lots of widescreens still have square pixels.
parent 5e15330d
...@@ -279,6 +279,12 @@ static char *ppsz_align_descriptions[] = ...@@ -279,6 +279,12 @@ static char *ppsz_align_descriptions[] =
"Allows you to specify the image format in which the video snapshots will " \ "Allows you to specify the image format in which the video snapshots will " \
"be stored.") "be stored.")
#define CROP_TEXT N_("Video cropping")
#define CROP_LONGTEXT N_( \
"This will force the cropping of the source video. " \
"Accepted formats are x:y (4:3, 16:9, etc.) expressing the global image " \
"aspect.")
#define ASPECT_RATIO_TEXT N_("Source aspect ratio") #define ASPECT_RATIO_TEXT N_("Source aspect ratio")
#define ASPECT_RATIO_LONGTEXT N_( \ #define ASPECT_RATIO_LONGTEXT N_( \
"This will force the source aspect ratio. For instance, some DVDs claim " \ "This will force the source aspect ratio. For instance, some DVDs claim " \
...@@ -295,11 +301,11 @@ static char *ppsz_align_descriptions[] = ...@@ -295,11 +301,11 @@ static char *ppsz_align_descriptions[] =
"Disable this option only if your video has non-standard format " \ "Disable this option only if your video has non-standard format " \
"requiring all 1088 lines.") "requiring all 1088 lines.")
#define MASPECT_RATIO_TEXT N_("Monitor aspect ratio") #define MASPECT_RATIO_TEXT N_("Monitor pixel aspect ratio")
#define MASPECT_RATIO_LONGTEXT N_( \ #define MASPECT_RATIO_LONGTEXT N_( \
"This will force the monitor aspect ratio. Most monitors have a 4:3." \ "This will force the monitor aspect ratio. Most monitors have square " \
"If you have a 16:9 screen, you will need to change this to 16:9 in" \ "pixels (1:1). If you have a 16:9 screen, you might need to change this " \
"order to keep proportions.") "to 4:3 in order to keep proportions.")
#define SKIP_FRAMES_TEXT N_("Skip frames") #define SKIP_FRAMES_TEXT N_("Skip frames")
#define SKIP_FRAMES_LONGTEXT N_( \ #define SKIP_FRAMES_LONGTEXT N_( \
...@@ -1022,10 +1028,11 @@ vlc_module_begin(); ...@@ -1022,10 +1028,11 @@ vlc_module_begin();
add_integer( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE ); add_integer( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
add_integer( "video-x", -1, NULL, VIDEOX_TEXT, VIDEOX_LONGTEXT, VLC_TRUE ); add_integer( "video-x", -1, NULL, VIDEOX_TEXT, VIDEOX_LONGTEXT, VLC_TRUE );
add_integer( "video-y", -1, NULL, VIDEOY_TEXT, VIDEOY_LONGTEXT, VLC_TRUE ); add_integer( "video-y", -1, NULL, VIDEOY_TEXT, VIDEOY_LONGTEXT, VLC_TRUE );
add_string( "aspect-ratio", "", NULL, add_string( "crop", NULL, NULL, CROP_TEXT, CROP_LONGTEXT, VLC_FALSE );
ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, VLC_FALSE ); add_string( "aspect-ratio", NULL, NULL,
add_string( "monitor-aspect-ratio", "4:3", NULL, ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, VLC_FALSE );
MASPECT_RATIO_TEXT, MASPECT_RATIO_LONGTEXT, VLC_FALSE ); add_string( "monitor-par", NULL, NULL,
MASPECT_RATIO_TEXT, MASPECT_RATIO_LONGTEXT, VLC_TRUE );
add_bool( "hdtv-fix", 1, NULL, HDTV_FIX_TEXT, HDTV_FIX_LONGTEXT, VLC_TRUE ); add_bool( "hdtv-fix", 1, NULL, HDTV_FIX_TEXT, HDTV_FIX_LONGTEXT, VLC_TRUE );
add_bool( "video-deco", 1, NULL, VIDEO_DECO_TEXT, add_bool( "video-deco", 1, NULL, VIDEO_DECO_TEXT,
VIDEO_DECO_LONGTEXT, VLC_TRUE ); VIDEO_DECO_LONGTEXT, VLC_TRUE );
......
...@@ -176,6 +176,7 @@ int vout_ControlWindow( vout_thread_t *p_vout, void *p_window, ...@@ -176,6 +176,7 @@ int vout_ControlWindow( vout_thread_t *p_vout, void *p_window,
void vout_IntfInit( vout_thread_t *p_vout ) void vout_IntfInit( vout_thread_t *p_vout )
{ {
vlc_value_t val, text, old_val; vlc_value_t val, text, old_val;
vlc_bool_t b_force_par = VLC_FALSE;
/* Create a few object variables we'll need later on */ /* Create a few object variables we'll need later on */
var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
...@@ -242,10 +243,9 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -242,10 +243,9 @@ void vout_IntfInit( vout_thread_t *p_vout )
if( old_val.psz_string ) free( old_val.psz_string ); if( old_val.psz_string ) free( old_val.psz_string );
/* Monitor pixel aspect-ratio */ /* Monitor pixel aspect-ratio */
var_Create( p_vout, "monitor-aspect-ratio", var_Create( p_vout, "monitor-par", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Get( p_vout, "monitor-par", &val );
var_Get( p_vout, "monitor-aspect-ratio", &val ); if( val.psz_string && *val.psz_string )
if( val.psz_string )
{ {
char *psz_parser = strchr( val.psz_string, ':' ); char *psz_parser = strchr( val.psz_string, ':' );
unsigned int i_aspect_num = 0, i_aspect_den = 0; unsigned int i_aspect_num = 0, i_aspect_den = 0;
...@@ -262,16 +262,17 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -262,16 +262,17 @@ void vout_IntfInit( vout_thread_t *p_vout )
i_aspect *VOUT_ASPECT_FACTOR, VOUT_ASPECT_FACTOR, 0 ); i_aspect *VOUT_ASPECT_FACTOR, VOUT_ASPECT_FACTOR, 0 );
} }
free( val.psz_string ); free( val.psz_string );
if( !i_aspect_num || !i_aspect_den ) if( !i_aspect_num || !i_aspect_den ) i_aspect_num = i_aspect_den = 1;
{
i_aspect_num = 4; p_vout->i_par_num = i_aspect_num;
i_aspect_den = 3;
}
p_vout->i_par_num = i_aspect_num * 3 * 4;
p_vout->i_par_den = i_aspect_den; p_vout->i_par_den = i_aspect_den;
vlc_ureduce( &p_vout->i_par_num, &p_vout->i_par_den, vlc_ureduce( &p_vout->i_par_num, &p_vout->i_par_den,
p_vout->i_par_num, p_vout->i_par_den, 0 ); p_vout->i_par_num, p_vout->i_par_den, 0 );
msg_Dbg( p_vout, "monitor pixel aspect-ratio overriding: %i:%i",
p_vout->i_par_num, p_vout->i_par_den );
b_force_par = VLC_TRUE;
} }
/* Aspect-ratio object var */ /* Aspect-ratio object var */
...@@ -296,7 +297,7 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -296,7 +297,7 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_AddCallback( p_vout, "aspect-ratio", AspectCallback, NULL ); var_AddCallback( p_vout, "aspect-ratio", AspectCallback, NULL );
var_Get( p_vout, "aspect-ratio", &old_val ); var_Get( p_vout, "aspect-ratio", &old_val );
if( old_val.psz_string && *old_val.psz_string ) if( (old_val.psz_string && *old_val.psz_string) || b_force_par )
var_Change( p_vout, "aspect-ratio", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 ); var_Change( p_vout, "aspect-ratio", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 );
if( old_val.psz_string ) free( old_val.psz_string ); if( old_val.psz_string ) free( old_val.psz_string );
...@@ -619,6 +620,15 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -619,6 +620,15 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
p_vout->render.i_aspect = p_vout->fmt_in.i_aspect; p_vout->render.i_aspect = p_vout->fmt_in.i_aspect;
aspect_end: aspect_end:
if( p_vout->i_par_num && p_vout->i_par_den )
{
p_vout->fmt_in.i_sar_num *= p_vout->i_par_den;
p_vout->fmt_in.i_sar_den *= p_vout->i_par_num;
p_vout->fmt_in.i_aspect = p_vout->fmt_in.i_aspect *
p_vout->i_par_den / p_vout->i_par_num;
p_vout->render.i_aspect = p_vout->fmt_in.i_aspect;
}
p_vout->i_changes |= VOUT_ASPECT_CHANGE; p_vout->i_changes |= VOUT_ASPECT_CHANGE;
vlc_ureduce( &i_aspect_num, &i_aspect_den, vlc_ureduce( &i_aspect_num, &i_aspect_den,
......
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