[FFmpeg-devel] [PATCH] Add crop filter

Michael Niedermayer michaelni
Wed Oct 14 01:37:46 CEST 2009


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


> +    } else {
> +        avcodec_get_chroma_sub_sample(link->format, &crop->hsub, &crop->vsub);
> +        crop->x &= ~((1 << crop->hsub) - 1);
> +        crop->y &= ~((1 << crop->vsub) - 1);
> +        crop->w &= ~((1 << crop->hsub) - 1);
> +        crop->h &= ~((1 << crop->vsub) - 1);

iam not sure this is ideal, i mean if i say crop=1:1:1:1 and i get 2:4:2:4
without any warning ...
but iam not sure what would be best so this can maybe be left and
investigated later


[...]
> +static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
> +{
> +    CropContext *crop = link->dst->priv;
> +    AVFilterPicRef *ref2 = avfilter_ref_pic(picref, ~0);
> +    int i, s;
> +
> +    ref2->w        = crop->w;
> +    ref2->h        = crop->h;
> +
> +    ref2->data[0] += (crop->y * ref2->linesize[0]);

> +    s = link->format == PIX_FMT_MONOWHITE || link->format == PIX_FMT_MONOBLACK ? 3 : 0;
> +    ref2->data[0] += (crop->x * crop->bpp) >> s;

please replace s by 3 and set BIT per pixel to its correct value


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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- 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/20091014/68328515/attachment.pgp>



More information about the ffmpeg-devel mailing list