Commit 8d19624e authored by Antoine Cellerier's avatar Antoine Cellerier

Allow on the fly cropping size change with top, left, right and bottom offsets.

alt+i -> crop one more pixel from the top
alt+j -> crop one more from the left
alt+k -> crop one more from the bottom
alt+l -> crop one more from the right
alt+shift+<the letter> -> crop one less
parent f4f98d5c
......@@ -258,3 +258,11 @@ static inline int StringToKey( char *psz_key )
#define ACTIONID_DEINTERLACE 69
#define ACTIONID_ZOOM 70
#define ACTIONID_UNZOOM 71
#define ACTIONID_CROP_TOP 72
#define ACTIONID_UNCROP_TOP 73
#define ACTIONID_CROP_LEFT 74
#define ACTIONID_UNCROP_LEFT 75
#define ACTIONID_CROP_BOTTOM 76
#define ACTIONID_UNCROP_BOTTOM 77
#define ACTIONID_CROP_RIGHT 78
#define ACTIONID_UNCROP_RIGHT 79
......@@ -618,6 +618,50 @@ static void Run( intf_thread_t *p_intf )
text_list.p_list->p_values[i].var.psz_name );
}
}
else if( i_action == ACTIONID_CROP_TOP && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-top" );
var_SetInteger( p_vout, "crop-top", i_val+1 );
}
else if( i_action == ACTIONID_UNCROP_TOP && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-top" );
if( i_val != 0 )
var_SetInteger( p_vout, "crop-top", i_val-1 );
}
else if( i_action == ACTIONID_CROP_BOTTOM && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-bottom" );
var_SetInteger( p_vout, "crop-bottom", i_val+1 );
}
else if( i_action == ACTIONID_UNCROP_BOTTOM && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-bottom" );
if( i_val != 0 )
var_SetInteger( p_vout, "crop-bottom", i_val-1 );
}
else if( i_action == ACTIONID_CROP_LEFT && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-left" );
var_SetInteger( p_vout, "crop-left", i_val+1 );
}
else if( i_action == ACTIONID_UNCROP_LEFT && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-left" );
if( i_val != 0 )
var_SetInteger( p_vout, "crop-left", i_val-1 );
}
else if( i_action == ACTIONID_CROP_RIGHT && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-right" );
var_SetInteger( p_vout, "crop-right", i_val+1 );
}
else if( i_action == ACTIONID_UNCROP_RIGHT && p_vout )
{
int i_val = var_GetInteger( p_vout, "crop-right" );
if( i_val != 0 )
var_SetInteger( p_vout, "crop-right", i_val-1 );
}
else if( i_action == ACTIONID_NEXT )
{
p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
......
......@@ -1088,6 +1088,26 @@ static char *ppsz_clock_descriptions[] =
#define UNZOOM_KEY_TEXT N_("Un-Zoom")
#define UNZOOM_KEY_LONGTEXT N_("Un-Zoom")
#define CROP_TOP_KEY_TEXT N_("Crop one pixel from the top of the video")
#define CROP_TOP_KEY_LONGTEXT N_("Crop one pixel from the top of the video")
#define UNCROP_TOP_KEY_TEXT N_("Uncrop one pixel from the top of the video")
#define UNCROP_TOP_KEY_LONGTEXT N_("Uncrop one pixel from the top of the video")
#define CROP_LEFT_KEY_TEXT N_("Crop one pixel from the left of the video")
#define CROP_LEFT_KEY_LONGTEXT N_("Crop one pixel from the left of the video")
#define UNCROP_LEFT_KEY_TEXT N_("Uncrop one pixel from the left of the video")
#define UNCROP_LEFT_KEY_LONGTEXT N_("Uncrop one pixel from the left of the video")
#define CROP_BOTTOM_KEY_TEXT N_("Crop one pixel from the bottom of the video")
#define CROP_BOTTOM_KEY_LONGTEXT N_("Crop one pixel from the bottom of the video")
#define UNCROP_BOTTOM_KEY_TEXT N_("Uncrop one pixel from the bottom of the video")
#define UNCROP_BOTTOM_KEY_LONGTEXT N_("Uncrop one pixel from the bottom of the video")
#define CROP_RIGHT_KEY_TEXT N_("Crop one pixel from the right of the video")
#define CROP_RIGHT_KEY_LONGTEXT N_("Crop one pixel from the right of the video")
#define UNCROP_RIGHT_KEY_TEXT N_("Uncrop one pixel from the right of the video")
#define UNCROP_RIGHT_KEY_LONGTEXT N_("Uncrop one pixel from the right of the video")
#define VLC_USAGE N_( \
"Usage: %s [options] [stream] ..." \
......@@ -1661,6 +1681,15 @@ vlc_module_begin();
# define KEY_ZOOM 'z'
# define KEY_UNZOOM KEY_MODIFIER_SHIFT|'z'
# define KEY_CROP_TOP KEY_MODIFIER_ALT|'i'
# define KEY_UNCROP_TOP KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'i'
# define KEY_CROP_LEFT KEY_MODIFIER_ALT|'j'
# define KEY_UNCROP_LEFT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'j'
# define KEY_CROP_BOTTOM KEY_MODIFIER_ALT|'k'
# define KEY_UNCROP_BOTTOM KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'k'
# define KEY_CROP_RIGHT KEY_MODIFIER_ALT|'l'
# define KEY_UNCROP_RIGHT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'l'
# define KEY_SET_BOOKMARK1 KEY_MODIFIER_COMMAND|KEY_F1
# define KEY_SET_BOOKMARK2 KEY_MODIFIER_COMMAND|KEY_F2
# define KEY_SET_BOOKMARK3 KEY_MODIFIER_COMMAND|KEY_F3
......@@ -1734,6 +1763,15 @@ vlc_module_begin();
# define KEY_ZOOM 'z'
# define KEY_UNZOOM KEY_MODIFIER_SHIFT|'z'
# define KEY_CROP_TOP KEY_MODIFIER_ALT|'i'
# define KEY_UNCROP_TOP KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'i'
# define KEY_CROP_LEFT KEY_MODIFIER_ALT|'j'
# define KEY_UNCROP_LEFT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'j'
# define KEY_CROP_BOTTOM KEY_MODIFIER_ALT|'k'
# define KEY_UNCROP_BOTTOM KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'k'
# define KEY_CROP_RIGHT KEY_MODIFIER_ALT|'l'
# define KEY_UNCROP_RIGHT KEY_MODIFIER_ALT|KEY_MODIFIER_SHIFT|'l'
# define KEY_SET_BOOKMARK1 KEY_MODIFIER_CTRL|KEY_F1
# define KEY_SET_BOOKMARK2 KEY_MODIFIER_CTRL|KEY_F2
# define KEY_SET_BOOKMARK3 KEY_MODIFIER_CTRL|KEY_F3
......@@ -1859,6 +1897,23 @@ vlc_module_begin();
add_key( "key-unzoom", KEY_UNZOOM, NULL,
UNZOOM_KEY_TEXT, UNZOOM_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-crop-top", KEY_CROP_TOP, NULL,
CROP_TOP_KEY_TEXT, CROP_TOP_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-uncrop-top", KEY_UNCROP_TOP, NULL,
UNCROP_TOP_KEY_TEXT, UNCROP_TOP_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-crop-left", KEY_CROP_LEFT, NULL,
CROP_LEFT_KEY_TEXT, CROP_LEFT_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-uncrop-left", KEY_UNCROP_LEFT, NULL,
UNCROP_LEFT_KEY_TEXT, UNCROP_LEFT_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-crop-bottom", KEY_CROP_BOTTOM, NULL,
CROP_BOTTOM_KEY_TEXT, CROP_BOTTOM_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-uncrop-bottom", KEY_UNCROP_BOTTOM, NULL,
UNCROP_BOTTOM_KEY_TEXT, UNCROP_BOTTOM_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-crop-right", KEY_CROP_RIGHT, NULL,
CROP_RIGHT_KEY_TEXT, CROP_RIGHT_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-uncrop-right", KEY_UNCROP_RIGHT, NULL,
UNCROP_RIGHT_KEY_TEXT, UNCROP_RIGHT_KEY_LONGTEXT, VLC_TRUE );
set_section ( N_("Jump sizes" ), NULL );
add_integer( "extrashort-jump-size", 3, NULL, JIEXTRASHORT_TEXT,
JIEXTRASHORT_LONGTEXT, VLC_FALSE );
......@@ -2014,6 +2069,14 @@ static struct hotkey p_hotkeys[] =
{ "key-snapshot", ACTIONID_SNAPSHOT, 0, 0, 0, 0 },
{ "key-zoom", ACTIONID_ZOOM, 0, 0, 0, 0 },
{ "key-unzoom", ACTIONID_UNZOOM, 0, 0, 0, 0 },
{ "key-crop-top", ACTIONID_CROP_TOP, 0, 0, 0, 0 },
{ "key-uncrop-top", ACTIONID_UNCROP_TOP, 0, 0, 0, 0 },
{ "key-crop-left", ACTIONID_CROP_LEFT, 0, 0, 0, 0 },
{ "key-uncrop-left", ACTIONID_UNCROP_LEFT, 0, 0, 0, 0 },
{ "key-crop-bottom", ACTIONID_CROP_BOTTOM, 0, 0, 0, 0 },
{ "key-uncrop-bottom", ACTIONID_UNCROP_BOTTOM, 0, 0, 0, 0 },
{ "key-crop-right", ACTIONID_CROP_RIGHT, 0, 0, 0, 0 },
{ "key-uncrop-right", ACTIONID_UNCROP_RIGHT, 0, 0, 0, 0 },
{ "key-nav-activate", ACTIONID_NAV_ACTIVATE, 0, 0, 0, 0 },
{ "key-nav-up", ACTIONID_NAV_UP, 0, 0, 0, 0 },
{ "key-nav-down", ACTIONID_NAV_DOWN, 0, 0, 0, 0 },
......
......@@ -225,6 +225,22 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_AddCallback( p_vout, "zoom", ZoomCallback, NULL );
/* Crop offset vars */
var_Create( p_vout, "crop-left", VLC_VAR_INTEGER );
var_Create( p_vout, "crop-top", VLC_VAR_INTEGER );
var_Create( p_vout, "crop-right", VLC_VAR_INTEGER );
var_Create( p_vout, "crop-bottom", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "crop-left", 0 );
var_SetInteger( p_vout, "crop-top", 0 );
var_SetInteger( p_vout, "crop-right", 0 );
var_SetInteger( p_vout, "crop-bottom", 0 );
var_AddCallback( p_vout, "crop-left", CropCallback, NULL );
var_AddCallback( p_vout, "crop-top", CropCallback, NULL );
var_AddCallback( p_vout, "crop-right", CropCallback, NULL );
var_AddCallback( p_vout, "crop-bottom", CropCallback, NULL );
/* Crop object var */
var_Create( p_vout, "crop", VLC_VAR_STRING |
VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT );
......@@ -782,14 +798,15 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
int64_t i_aspect_num, i_aspect_den;
unsigned int i_width, i_height;
char *psz_end, *psz_parser = strchr( newval.psz_string, ':' );
/* Restore defaults */
p_vout->fmt_in.i_x_offset = p_vout->fmt_render.i_x_offset;
p_vout->fmt_in.i_visible_width = p_vout->fmt_render.i_visible_width;
p_vout->fmt_in.i_y_offset = p_vout->fmt_render.i_y_offset;
p_vout->fmt_in.i_visible_height = p_vout->fmt_render.i_visible_height;
if( !strcmp( psz_cmd, "crop" ) )
{
char *psz_end, *psz_parser = strchr( newval.psz_string, ':' );
if( psz_parser )
{
/* We're using the 3:4 syntax */
......@@ -868,7 +885,6 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
i_crop_bottom = strtol( ++psz_end, &psz_end, 10 );
if( *psz_end != '\0' ) goto crop_end;
i_width = p_vout->fmt_render.i_visible_width
- i_crop_left - i_crop_right;
p_vout->fmt_in.i_visible_width = i_width;
......@@ -881,6 +897,30 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
p_vout->fmt_in.i_y_offset = i_crop_top;
}
}
}
else if( !strcmp( psz_cmd, "crop-top" )
|| !strcmp( psz_cmd, "crop-left" )
|| !strcmp( psz_cmd, "crop-bottom" )
|| !strcmp( psz_cmd, "crop-right" ) )
{
unsigned int i_crop_top, i_crop_left, i_crop_bottom, i_crop_right;
i_crop_top = var_GetInteger( p_vout, "crop-top" );
i_crop_left = var_GetInteger( p_vout, "crop-left" );
i_crop_right = var_GetInteger( p_vout, "crop-right" );
i_crop_bottom = var_GetInteger( p_vout, "crop-bottom" );
i_width = p_vout->fmt_render.i_visible_width
- i_crop_left - i_crop_right;
p_vout->fmt_in.i_visible_width = i_width;
i_height = p_vout->fmt_render.i_visible_height
- i_crop_top - i_crop_bottom;
p_vout->fmt_in.i_visible_height = i_height;
p_vout->fmt_in.i_x_offset = i_crop_left;
p_vout->fmt_in.i_y_offset = i_crop_top;
}
crop_end:
InitWindowSize( p_vout, &p_vout->i_window_width,
......
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