Browse Source

Change the syntax of the crop filter from x:y:w:h to w:h:x:y.

Slightly more intuitive and required by a pending changes for making
the filter parametric.

Originally committed as revision 25184 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/n0.8
Stefano Sabatini 14 years ago
parent
commit
2bc05d3547
7 changed files with 26 additions and 25 deletions
  1. +1
    -0
      Changelog
  2. +4
    -4
      doc/ffmpeg-doc.texi
  3. +8
    -8
      doc/filters.texi
  4. +3
    -3
      ffmpeg.c
  5. +1
    -1
      libavfilter/avfilter.h
  6. +4
    -4
      libavfilter/vf_crop.c
  7. +5
    -5
      tests/lavfi-regression.sh

+ 1
- 0
Changelog View File

@@ -37,6 +37,7 @@ version <next>:
- R10k video decoder
- ocv_smooth filter
- frei0r wrapper filter
- change crop filter syntax to width:height:x:y


version 0.6:


+ 4
- 4
doc/ffmpeg-doc.texi View File

@@ -226,13 +226,13 @@ The following abbreviations are recognized:

@item -aspect @var{aspect}
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
@item -croptop @var{size} (deprecated - use -vf crop=x:y:width:height instead)
@item -croptop @var{size} (deprecated - use the crop filter instead)
Set top crop band size (in pixels).
@item -cropbottom @var{size} (deprecated - use -vf crop=x:y:width:height instead)
@item -cropbottom @var{size} (deprecated - use the crop filter instead)
Set bottom crop band size (in pixels).
@item -cropleft @var{size} (deprecated - use -vf crop=x:y:width:height instead)
@item -cropleft @var{size} (deprecated - use the crop filter instead)
Set left crop band size (in pixels).
@item -cropright @var{size} (deprecated - use -vf crop=x:y:width:height instead)
@item -cropright @var{size} (deprecated - use the crop filter instead)
Set right crop band size (in pixels).
@item -padtop @var{size}
@item -padbottom @var{size}


+ 8
- 8
doc/filters.texi View File

@@ -26,27 +26,27 @@ Below is a description of the currently available video filters.

@section crop

Crop the input video to @var{x}:@var{y}:@var{width}:@var{height}.
Crop the input video to @var{width}:@var{height}:@var{x}:@var{y}.

@example
./ffmpeg -i in.avi -vf "crop=0:0:0:240" out.avi
./ffmpeg -i in.avi -vf "crop=0:240:0:0" out.avi
@end example

@var{x} and @var{y} specify the position of the top-left corner of the
output (non-cropped) area.

The default value of @var{x} and @var{y} is 0.

The @var{width} and @var{height} parameters specify the width and height
of the output (non-cropped) area.

A value of 0 is interpreted as the maximum possible size contained in
the area delimited by the top-left corner at position x:y.

@var{x} and @var{y} specify the position of the top-left corner of the
output (non-cropped) area.

The default value of @var{x} and @var{y} is 0.

For example the parameters:

@example
"crop=100:100:0:0"
"crop=0:0:100:100"
@end example

will delimit the rectangle with the top-left corner placed at position


+ 3
- 3
ffmpeg.c View File

@@ -432,9 +432,9 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
last_filter = ist->input_video_filter;

if (ost->video_crop) {
snprintf(args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand,
codec->width,
codec->height);
snprintf(args, 255, "%d:%d:%d:%d",
codec->width, codec->height,
ost->leftBand, ost->topBand);
if ((ret = avfilter_open(&filter, avfilter_get_by_name("crop"), NULL)) < 0)
return ret;
if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)


+ 1
- 1
libavfilter/avfilter.h View File

@@ -25,7 +25,7 @@
#include "libavutil/avutil.h"

#define LIBAVFILTER_VERSION_MAJOR 1
#define LIBAVFILTER_VERSION_MINOR 40
#define LIBAVFILTER_VERSION_MINOR 41
#define LIBAVFILTER_VERSION_MICRO 0

#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \


+ 4
- 4
libavfilter/vf_crop.c View File

@@ -73,7 +73,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
CropContext *crop = ctx->priv;

if (args)
sscanf(args, "%d:%d:%d:%d", &crop->x, &crop->y, &crop->w, &crop->h);
sscanf(args, "%d:%d:%d:%d", &crop->w, &crop->h, &crop->x, &crop->y);

return 0;
}
@@ -96,8 +96,8 @@ static int config_input(AVFilterLink *link)
crop->x &= ~((1 << crop->hsub) - 1);
crop->y &= ~((1 << crop->vsub) - 1);

av_log(link->dst, AV_LOG_INFO, "x:%d y:%d w:%d h:%d\n",
crop->x, crop->y, crop->w, crop->h);
av_log(link->dst, AV_LOG_INFO, "w:%d h:%d x:%d y:%d\n",
crop->w, crop->h, crop->x, crop->y);

if (crop->x < 0 || crop->y < 0 ||
crop->w <= 0 || crop->h <= 0 ||
@@ -172,7 +172,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)

AVFilter avfilter_vf_crop = {
.name = "crop",
.description = NULL_IF_CONFIG_SMALL("Crop the input video to x:y:width:height."),
.description = NULL_IF_CONFIG_SMALL("Crop the input video to width:height:x:y."),

.priv_size = sizeof(CropContext),



+ 5
- 5
tests/lavfi-regression.sh View File

@@ -22,15 +22,15 @@ do_lavfi() {
fi
}

do_lavfi "crop" "crop=100:100"
do_lavfi "crop_scale" "crop=100:100,scale=400:-1"
do_lavfi "crop_scale_vflip" "null,null,crop=200:200,crop=20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=100:100,vflip,scale=200:200,null,vflip,crop=100:100,null"
do_lavfi "crop_vflip" "crop=100:100,vflip"
do_lavfi "crop" "crop=0:0:100:100"
do_lavfi "crop_scale" "crop=0:0:100:100,scale=400:-1"
do_lavfi "crop_scale_vflip" "null,null,crop=0:0:200:200,crop=0:0:20:20,scale=200:200,scale=250:250,vflip,vflip,null,scale=200:200,crop=0:0:100:100,vflip,scale=200:200,null,vflip,crop=0:0:100:100,null"
do_lavfi "crop_vflip" "crop=0:0:100:100,vflip"
do_lavfi "null" "null"
do_lavfi "scale200" "scale=200:200"
do_lavfi "scale500" "scale=500:500"
do_lavfi "vflip" "vflip"
do_lavfi "vflip_crop" "vflip,crop=100:100"
do_lavfi "vflip_crop" "vflip,crop=0:0:100:100"
do_lavfi "vflip_vflip" "vflip,vflip"

do_lavfi_pixfmts(){


Loading…
Cancel
Save