[FFmpeg-devel] [PATCH 4/4] Make the crop filter accept parametric expressions.

Michael Niedermayer michaelni
Wed Sep 8 15:56:27 CEST 2010


On Thu, Jul 22, 2010 at 07:52:35PM +0200, Stefano Sabatini wrote:
> ---
>  doc/filters.texi      |   45 +++++++++++++++++++++++++---------
>  libavfilter/vf_crop.c |   65 ++++++++++++++++++++++++++++++++++++++++++++----
>  2 files changed, 92 insertions(+), 18 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 7f0cb71..a767b2c 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -12,32 +12,53 @@ Below is a description of the currently available video filters.
>  
>  Crop the input video to @var{x}:@var{y}:@var{width}:@var{height}.
>  
> - at example
> -./ffmpeg -i in.avi -vf "crop=0:0:0:240" out.avi
> - at end example
> +The parameters are expressions containing one the following constants:
>  
> - at var{x} and @var{y} specify the position of the top-left corner of the
> -output (non-cropped) area.
> + at table
> + at item E, PI, PHI
> +Represent the corresponding mathematical approximated values for e
> +(euler number), pi (greek PI), PHI (golden ratio).
>  
> -The default value of @var{x} and @var{y} is 0.
> + at item w, h
> +Specify the input width and heigth.
> +
> + at item x, y
> +Represent the computed values for @var{x} and @var{y}.
> +
> + at end table
> +
> + at var{x} and @var{y} specify the expression for 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.
> +The @var{width} and @var{height} parameters specify the expression for
> +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.
> +The default value of @var{width} is "w-x", and the default value of
> + at var{height} is "h-y", which specify the maximum possible size
> +contained in the area delimited by the top-left corner at position
> +x:y.
>  
>  For example the parameters:
>  
>  @example
> -"crop=100:100:0:0"
> +"crop=100:100"
>  @end example
>  
>  will delimit the rectangle with the top-left corner placed at position
>  100:100 and the right-bottom corner corresponding to the right-bottom
>  corner of the input image.
>  
> -The default value of @var{width} and @var{height} is 0.
> +Follow other examples:
> + at example:
> +# crop 10 pixels from the lefth and right borders, and 20 pixels from
> +# the top and bottom borders
> +crop=10:20:w-2*x:h-2*y
> +
> +# keep only the bottom right quarter of the input image
> +crop=w/2:h/2
> + at end example
>  
>  @section format
>  
> diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
> index 6a7ae70..df9b5a2 100644
> --- a/libavfilter/vf_crop.c
> +++ b/libavfilter/vf_crop.c
> @@ -24,7 +24,31 @@
>   */
>  
>  #include "avfilter.h"
> +#include "libavutil/eval.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/avstring.h"
> +
> +static const char *var_names[] = {
> +    "E",
> +    "PHI",
> +    "PI",
> +    "x",
> +    "y",
> +    "w",      ///< width  of the input video
> +    "h",      ///< height of the input video

t for timestamp in seconds
f for frame number

otherwise the patch looks ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100908/378c90fb/attachment.pgp>



More information about the ffmpeg-devel mailing list