#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] ..." \
# 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
# 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
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 );
{ "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 },
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 );
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( psz_parser )
+ if( !strcmp( psz_cmd, "crop" ) )
{
- /* We're using the 3:4 syntax */
- i_aspect_num = strtol( newval.psz_string, &psz_end, 10 );
- if( psz_end == newval.psz_string || !i_aspect_num ) goto crop_end;
+ char *psz_end, *psz_parser = strchr( newval.psz_string, ':' );
+ if( psz_parser )
+ {
+ /* We're using the 3:4 syntax */
+ i_aspect_num = strtol( newval.psz_string, &psz_end, 10 );
+ if( psz_end == newval.psz_string || !i_aspect_num ) goto crop_end;
- i_aspect_den = strtol( ++psz_parser, &psz_end, 10 );
- if( psz_end == psz_parser || !i_aspect_den ) goto crop_end;
+ i_aspect_den = strtol( ++psz_parser, &psz_end, 10 );
+ if( psz_end == psz_parser || !i_aspect_den ) goto crop_end;
- i_width = p_vout->fmt_in.i_sar_den*p_vout->fmt_render.i_visible_height *
- i_aspect_num / i_aspect_den / p_vout->fmt_in.i_sar_num;
- i_height = p_vout->fmt_render.i_visible_width*p_vout->fmt_in.i_sar_num *
- i_aspect_den / i_aspect_num / p_vout->fmt_in.i_sar_den;
+ i_width = p_vout->fmt_in.i_sar_den*p_vout->fmt_render.i_visible_height *
+ i_aspect_num / i_aspect_den / p_vout->fmt_in.i_sar_num;
+ i_height = p_vout->fmt_render.i_visible_width*p_vout->fmt_in.i_sar_num *
+ i_aspect_den / i_aspect_num / p_vout->fmt_in.i_sar_den;
- if( i_width < p_vout->fmt_render.i_visible_width )
- {
- p_vout->fmt_in.i_x_offset = p_vout->fmt_render.i_x_offset +
- (p_vout->fmt_render.i_visible_width - i_width) / 2;
- p_vout->fmt_in.i_visible_width = i_width;
+ if( i_width < p_vout->fmt_render.i_visible_width )
+ {
+ p_vout->fmt_in.i_x_offset = p_vout->fmt_render.i_x_offset +
+ (p_vout->fmt_render.i_visible_width - i_width) / 2;
+ p_vout->fmt_in.i_visible_width = i_width;
+ }
+ else
+ {
+ p_vout->fmt_in.i_y_offset = p_vout->fmt_render.i_y_offset +
+ (p_vout->fmt_render.i_visible_height - i_height) / 2;
+ p_vout->fmt_in.i_visible_height = i_height;
+ }
}
else
{
- p_vout->fmt_in.i_y_offset = p_vout->fmt_render.i_y_offset +
- (p_vout->fmt_render.i_visible_height - i_height) / 2;
- p_vout->fmt_in.i_visible_height = i_height;
- }
- }
- else
- {
- psz_parser = strchr( newval.psz_string, 'x' );
- if( psz_parser )
- {
- /* Maybe we're using the <width>x<height>+<left>+<top> syntax */
- unsigned int i_crop_width, i_crop_height, i_crop_top, i_crop_left;
-
- i_crop_width = strtol( newval.psz_string, &psz_end, 10 );
- if( psz_end != psz_parser ) goto crop_end;
+ psz_parser = strchr( newval.psz_string, 'x' );
+ if( psz_parser )
+ {
+ /* Maybe we're using the <width>x<height>+<left>+<top> syntax */
+ unsigned int i_crop_width, i_crop_height, i_crop_top, i_crop_left;
- psz_parser = strchr( ++psz_end, '+' );
- i_crop_height = strtol( psz_end, &psz_end, 10 );
- if( psz_end != psz_parser ) goto crop_end;
+ i_crop_width = strtol( newval.psz_string, &psz_end, 10 );
+ if( psz_end != psz_parser ) goto crop_end;
- psz_parser = strchr( ++psz_end, '+' );
- i_crop_left = strtol( psz_end, &psz_end, 10 );
- if( psz_end != psz_parser ) goto crop_end;
+ psz_parser = strchr( ++psz_end, '+' );
+ i_crop_height = strtol( psz_end, &psz_end, 10 );
+ if( psz_end != psz_parser ) goto crop_end;
- i_crop_top = strtol( ++psz_end, &psz_end, 10 );
- if( *psz_end != '\0' ) goto crop_end;
+ psz_parser = strchr( ++psz_end, '+' );
+ i_crop_left = strtol( psz_end, &psz_end, 10 );
+ if( psz_end != psz_parser ) goto crop_end;
- i_width = i_crop_width;
- p_vout->fmt_in.i_visible_width = i_width;
+ i_crop_top = strtol( ++psz_end, &psz_end, 10 );
+ if( *psz_end != '\0' ) goto crop_end;
- i_height = i_crop_height;
- p_vout->fmt_in.i_visible_height = i_height;
+ i_width = i_crop_width;
+ p_vout->fmt_in.i_visible_width = i_width;
- p_vout->fmt_in.i_x_offset = i_crop_left;
- p_vout->fmt_in.i_y_offset = i_crop_top;
- }
- else
- {
- /* Maybe we're using the <left>+<top>+<right>+<bottom> syntax */
- unsigned int i_crop_top, i_crop_left, i_crop_bottom, i_crop_right;
+ i_height = i_crop_height;
+ p_vout->fmt_in.i_visible_height = i_height;
- psz_parser = strchr( newval.psz_string, '+' );
- i_crop_left = strtol( newval.psz_string, &psz_end, 10 );
- if( psz_end != psz_parser ) goto crop_end;
+ p_vout->fmt_in.i_x_offset = i_crop_left;
+ p_vout->fmt_in.i_y_offset = i_crop_top;
+ }
+ else
+ {
+ /* Maybe we're using the <left>+<top>+<right>+<bottom> syntax */
+ unsigned int i_crop_top, i_crop_left, i_crop_bottom, i_crop_right;
- psz_parser = strchr( ++psz_end, '+' );
- i_crop_top = strtol( psz_end, &psz_end, 10 );
- if( psz_end != psz_parser ) goto crop_end;
+ psz_parser = strchr( newval.psz_string, '+' );
+ i_crop_left = strtol( newval.psz_string, &psz_end, 10 );
+ if( psz_end != psz_parser ) goto crop_end;
- psz_parser = strchr( ++psz_end, '+' );
- i_crop_right = strtol( psz_end, &psz_end, 10 );
- if( psz_end != psz_parser ) goto crop_end;
+ psz_parser = strchr( ++psz_end, '+' );
+ i_crop_top = strtol( psz_end, &psz_end, 10 );
+ if( psz_end != psz_parser ) goto crop_end;
- i_crop_bottom = strtol( ++psz_end, &psz_end, 10 );
- if( *psz_end != '\0' ) goto crop_end;
+ psz_parser = strchr( ++psz_end, '+' );
+ i_crop_right = strtol( psz_end, &psz_end, 10 );
+ if( psz_end != psz_parser ) goto crop_end;
+ 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;
+ 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;
+ 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;
+ p_vout->fmt_in.i_x_offset = i_crop_left;
+ 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,