[FFmpeg-devel] [PATCH] Add crop filter
Michael Niedermayer
michaelni
Thu Oct 15 16:11:20 CEST 2009
On Wed, Oct 14, 2009 at 08:49:16PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2009-10-14 01:37:46 +0200, Michael Niedermayer encoded:
> > On Tue, Oct 13, 2009 at 08:47:09PM +0200, Stefano Sabatini wrote:
> > > On date Tuesday 2009-10-13 13:16:29 +0200, Michael Niedermayer encoded:
> > > > On Mon, Oct 12, 2009 at 08:41:08PM +0200, Stefano Sabatini wrote:
> > > > > On date Monday 2009-10-12 09:28:29 +0200, Michael Niedermayer encoded:
> > [...]
> > > + if (link->format == PIX_FMT_MONOWHITE || link->format == PIX_FMT_MONOBLACK) {
> > > + crop->x &= ~7;
> > > + crop->y &= ~7;
> > > + crop->w &= ~7;
> > > + crop->h &= ~7;
> >
> > the y/h changes are wrong
>
> Fixed, and factorized the following (ab)using the crop->hsub field.
hacks requires a comment in the code at least
[...]
> +static int config_input(AVFilterLink *link)
> +{
> + AVFilterContext *ctx = link->dst;
> + CropContext *crop = ctx->priv;
> +
> + if (crop->w == 0)
> + crop->w = link->w - crop->x;
> + if (crop->h == 0)
> + crop->h = link->h - crop->y;
> +
> + if (crop->x < 0 || crop->y < 0 ||
> + crop->w < 0 || crop->h < 0 ||
<=
> + (unsigned)crop->x + (unsigned)crop->w > link->w ||
> + (unsigned)crop->y + (unsigned)crop->h > link->h) {
> + av_log(ctx, AV_LOG_ERROR,
> + "Output area %d:%d:%d:%d not within the input area 0:0:%d:%d\n",
> + crop->x, crop->y, crop->w, crop->h, link->w, link->h);
> + return -1;
> + }
[...]
> +
> + crop->x &= ~((1 << crop->hsub) - 1);
> + crop->y &= ~((1 << crop->vsub) - 1);
> + crop->w &= ~((1 << crop->hsub) - 1);
> + crop->h &= ~((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);
> +
> + if (crop->w == 0 || crop->h == 0) {
> + av_log(link->dst, AV_LOG_ERROR, "Size values too small\n");
> + return -1;
> + }
please move the check at the end, dont check and the change and then check
again. or dont round at all and rather complain that the value is not ok
[...]
> +static void draw_slice(AVFilterLink *link, int y, int h)
> +{
> + AVFilterContext *ctx = link->dst;
> + CropContext *crop = ctx->priv;
> +
> + int y1 = y;
> + int h1 = h;
why these variables?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091015/147b0774/attachment.pgp>
More information about the ffmpeg-devel
mailing list