[FFmpeg-devel] [PATCH] Add crop filter
Michael Niedermayer
michaelni
Sat Oct 10 01:51:39 CEST 2009
On Wed, Oct 07, 2009 at 11:50:19PM +0200, Stefano Sabatini wrote:
> On date Tuesday 2009-10-06 15:01:32 +0200, Michael Niedermayer encoded:
> > On Tue, Oct 06, 2009 at 12:58:41AM +0200, Stefano Sabatini wrote:
[...]
> +static int norm_offset(int x, int max)
> +{
> + if (x < 0)
> + x = max + x;
> + return av_clip(x, 0, max-1);
> +}
using max before its validated and cliped like that does not work
anyway, iam not sure all that cliping is a good idea, i would just
tell the user that his parameters are partly beyond the input image
dimensions and that she should fix that.
[...]
> +static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
> +{
> + CropContext *crop = link->dst->priv;
> + AVFilterPicRef *ref2 = avfilter_ref_pic(picref, ~0);
> + int i;
> +
> + ref2->w = crop->w;
> + ref2->h = crop->h;
> + ref2->data[0] += crop->y * ref2->linesize[0];
> + ref2->data[0] += crop->x * crop->bpp;
> +
> + for (i = 1; i < 4; i ++) {
> + if (ref2->data[i]) {
> + ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i];
> + ref2->data[i] += crop->x >> crop->hsub;
> + }
> + }
fails for paletted formats
[...]
also it may be usefull if we had a filter that generated random images in
random pixel formats and random width/height for testing ...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- 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/20091010/6b429d8d/attachment.pgp>
More information about the ffmpeg-devel
mailing list