Commit 7b84cea4 authored by Joseph Tulou's avatar Joseph Tulou Committed by Jean-Baptiste Kempf

Enabling scaling activation/deactivation

this patch adds a parameter ( --[no]-scaling) and a toggle hotkey ('o')
At fullscreen, it allows displaying a video at original size surrounded by a black screen.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent d16c3267
......@@ -309,6 +309,7 @@ typedef enum vlc_key {
ACTIONID_DISC_MENU,
ACTIONID_ASPECT_RATIO,
ACTIONID_CROP,
ACTIONID_TOGGLE_SCALING,
ACTIONID_DEINTERLACE,
ACTIONID_ZOOM,
ACTIONID_UNZOOM,
......
......@@ -609,6 +609,11 @@ static void Run( intf_thread_t *p_intf )
}
free( val.psz_string );
}
else if( i_action == ACTIONID_TOGGLE_SCALING && p_vout )
{
bool b_scaling = var_GetBool( p_vout, "scaling" );
var_SetBool( p_vout, "scaling", !b_scaling );
}
else if( i_action == ACTIONID_DEINTERLACE && p_vout )
{
vlc_value_t val={0}, val_list, text_list;
......
......@@ -510,6 +510,10 @@ static const char *const ppsz_pos_descriptions[] =
"aspect, or a float value (1.25, 1.3333, etc.) expressing pixel " \
"squareness.")
#define SCALING_TEXT N_("Video scaling")
#define SCALING_LONGTEXT N_( \
"This enables upscaling a video in a given window.")
#define CUSTOM_CROP_RATIOS_TEXT N_("Custom crop ratios list")
#define CUSTOM_CROP_RATIOS_LONGTEXT N_( \
"Comma seperated list of crop ratios which will be added in the " \
......@@ -1344,6 +1348,8 @@ static const char *const ppsz_albumart_descriptions[] =
#define ASPECT_RATIO_KEY_LONGTEXT N_("Cycle through a predefined list of source aspect ratios.")
#define CROP_KEY_TEXT N_("Cycle video crop")
#define CROP_KEY_LONGTEXT N_("Cycle through a predefined list of crop formats.")
#define TOGGLE_SCALING_KEY_TEXT N_("Toggle upscaling")
#define TOGGLE_SCALING_KEY_LONGTEXT N_("Activate or deactivate upscaling.")
#define DEINTERLACE_KEY_TEXT N_("Cycle deinterlace modes")
#define DEINTERLACE_KEY_LONGTEXT N_("Cycle through deinterlace modes.")
#define INTF_SHOW_KEY_TEXT N_("Show interface")
......@@ -1598,6 +1604,8 @@ vlc_module_begin ()
add_string( "aspect-ratio", NULL, NULL,
ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, false );
change_safe ()
add_bool( "scaling", true, NULL, SCALING_TEXT, SCALING_LONGTEXT, false )
change_safe ()
add_string( "monitor-par", NULL, NULL,
MASPECT_RATIO_TEXT, MASPECT_RATIO_LONGTEXT, true );
add_string( "custom-aspect-ratios", NULL, NULL, CUSTOM_ASPECT_RATIOS_TEXT,
......@@ -2125,6 +2133,7 @@ vlc_module_begin ()
# define KEY_SUBTITLE_TRACK 's'
# define KEY_ASPECT_RATIO 'a'
# define KEY_CROP 'c'
# define KEY_TOGGLE_SCALING 'o'
# define KEY_DEINTERLACE 'd'
# define KEY_INTF_SHOW 'i'
# define KEY_INTF_HIDE KEY_MODIFIER_SHIFT|'i'
......@@ -2236,6 +2245,7 @@ vlc_module_begin ()
# define KEY_SUBTITLE_TRACK 'v'
# define KEY_ASPECT_RATIO 'a'
# define KEY_CROP 'c'
# define KEY_TOGGLE_SCALING 'o'
# define KEY_DEINTERLACE 'd'
# define KEY_INTF_SHOW 'i'
# define KEY_INTF_HIDE KEY_MODIFIER_SHIFT|'i'
......@@ -2393,6 +2403,8 @@ vlc_module_begin ()
ASPECT_RATIO_KEY_TEXT, ASPECT_RATIO_KEY_LONGTEXT, false );
add_key( "key-crop", KEY_CROP, NULL,
CROP_KEY_TEXT, CROP_KEY_LONGTEXT, false );
add_key( "key-toggle-scaling", KEY_TOGGLE_SCALING, NULL,
TOGGLE_SCALING_KEY_TEXT, TOGGLE_SCALING_KEY_LONGTEXT, false );
add_key( "key-deinterlace", KEY_DEINTERLACE, NULL,
DEINTERLACE_KEY_TEXT, DEINTERLACE_KEY_LONGTEXT, false );
add_key( "key-intf-show", KEY_INTF_SHOW, NULL,
......@@ -2669,6 +2681,7 @@ const struct hotkey libvlc_hotkeys[] =
{ "key-subtitle-track", ACTIONID_SUBTITLE_TRACK, 0, },
{ "key-aspect-ratio", ACTIONID_ASPECT_RATIO, 0, },
{ "key-crop", ACTIONID_CROP, 0, },
{ "key-toggle-scaling", ACTIONID_TOGGLE_SCALING, 0, },
{ "key-deinterlace", ACTIONID_DEINTERLACE, 0, },
{ "key-intf-show", ACTIONID_INTF_SHOW, 0, },
{ "key-intf-hide", ACTIONID_INTF_HIDE, 0, },
......
......@@ -65,6 +65,8 @@ static int CropCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int AspectCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int ScalingCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int OnTopCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int FullscreenCallback( vlc_object_t *, char const *,
......@@ -397,6 +399,15 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_TriggerCallback( p_vout, "aspect-ratio" );
free( old_val.psz_string );
/* Add a variable to indicate if scaling video is activated or not */
var_Create( p_vout, "scaling", VLC_VAR_BOOL | VLC_VAR_DOINHERIT
| VLC_VAR_ISCOMMAND );
text.psz_string = _("Scaling video");
var_Change( p_vout, "scaling", VLC_VAR_SETTEXT, &text, NULL );
var_AddCallback( p_vout, "scaling", ScalingCallback, NULL );
var_Get( p_vout, "scaling", &val );
p_vout->b_scale = val.b_bool;
/* Initialize the dimensions of the video window */
InitWindowSize( p_vout, &p_vout->i_window_width,
&p_vout->i_window_height );
......@@ -1199,6 +1210,19 @@ static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
return i_ret;
}
static int ScalingCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
vlc_mutex_lock( &p_vout->change_lock );
p_vout->b_scale = newval.b_bool;
p_vout->i_changes |= VOUT_SIZE_CHANGE;
vlc_mutex_unlock( &p_vout->change_lock );
}
static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
......
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