[FFmpeg-devel] [PATCH 2/2] vf_crop: keepaspect support

Michael Niedermayer michaelni at gmx.at
Sun Mar 11 17:52:05 CET 2012


On Sun, Mar 11, 2012 at 05:44:11PM +0100, Stefano Sabatini wrote:
> On date Saturday 2012-03-10 08:26:07 +0100, Michael Niedermayer encoded:
> > From: Baptiste Coudurier <baptiste.coudurier at gmail.com>
> > 
> > ---
> >  libavfilter/vf_crop.c |   14 +++++++++++++-
> >  1 files changed, 13 insertions(+), 1 deletions(-)
> > 
> > diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
> > index 117cd43..c8c4fb2 100644
> > --- a/libavfilter/vf_crop.c
> > +++ b/libavfilter/vf_crop.c
> > @@ -74,6 +74,9 @@ typedef struct {
> >      int  w;             ///< width of the cropped area
> >      int  h;             ///< height of the cropped area
> >  
> > +    AVRational out_sar; ///< output sample aspect ratio
> > +    int keep_aspect;    ///< keep display aspect ratio when cropping
> > +
> >      int max_step[4];    ///< max pixel step for each plane, expressed as a number of bytes
> >      int hsub, vsub;     ///< chroma subsampling
> >      char x_expr[256], y_expr[256], ow_expr[256], oh_expr[256];
> > @@ -124,7 +127,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> >      av_strlcpy(crop->y_expr, "(in_h-out_h)/2", sizeof(crop->y_expr));
> > 
> >      if (args)
> > -        sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]", crop->ow_expr, crop->oh_expr, crop->x_expr, crop->y_expr);
> > +        sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%d", crop->ow_expr, crop->oh_expr, crop->x_expr, crop->y_expr, &crop->keep_aspect);
> >  
> >      return 0;
> >  }
> > @@ -210,6 +213,14 @@ static int config_input(AVFilterLink *link)
> >                               NULL, NULL, NULL, NULL, 0, ctx)) < 0)
> >          return AVERROR(EINVAL);
> >  
> > +    if (crop->keep_aspect) {
> > +        AVRational dar = av_mul_q(link->sample_aspect_ratio,
> > +                                  (AVRational){ link->w, link->h });
> > +        av_reduce(&crop->out_sar.num, &crop->out_sar.den,
> > +                  dar.num * crop->h, dar.den * crop->w, INT_MAX);
> > +    } else
> > +        crop->out_sar = link->sample_aspect_ratio;
> > +
> >      av_log(ctx, AV_LOG_INFO, "w:%d h:%d -> w:%d h:%d\n",
> >             link->w, link->h, crop->w, crop->h);
> >  
> > @@ -239,6 +250,7 @@ static int config_output(AVFilterLink *link)
> >  
> >      link->w = crop->w;
> >      link->h = crop->h;
> > +    link->sample_aspect_ratio = crop->out_sar;
> 
> OK but please update documentation (check attached diff). Also don't
> forget to bump micro so we know when the feature is available by
> reading the version numbers.

all done

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored awnser#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120311/8e68ad36/attachment.asc>


More information about the ffmpeg-devel mailing list