[FFmpeg-devel] [PATCH] Port MPlayer 2xSaI filter to libavfilter

Nielkie nielkie
Thu Nov 25 12:11:43 CET 2010


On Thu, Nov 25, 2010 at 4:01 AM, Loren Merritt <lorenm at u.washington.edu>wrote:

> On Thu, 25 Nov 2010, Nielkie wrote:
>
>  +#define makecol(r, g, b) (r+(g<<8)+(b<<16))
>> +
>> +static int Init_2xSaI(enum PixelFormat pix_fmt, Super2xSaIContext *c)
>> +{
>> +    int minr = 0, ming = 0, minb = 0;
>> +    int i;
>> +
>> +    /* Get lowest color bit */
>> +    for (i = 0; i < 255; i++) {
>> +        if (!minr)
>> +            minr = makecol(i, 0, 0);
>> +        if (!ming)
>> +            ming = makecol(0, i, 0);
>> +        if (!minb)
>> +            minb = makecol(0, 0, i);
>> +    }
>> +
>> +    c->colorMask = (makecol(255, 0, 0) - minr) |
>> +                   (makecol(0, 255, 0) - ming) |
>> +                   (makecol(0, 0, 255) - minb);
>> +    c->lowPixelMask = minr | ming | minb;
>> +    c->qcolorMask = (makecol(255, 0, 0) - 3 * minr) |
>> +                    (makecol(0, 255, 0) - 3 * ming) |
>> +                    (makecol(0, 0, 255) - 3 * minb);
>> +    c->qlowpixelMask = (minr * 3) | (ming * 3) | (minb * 3);
>>
>
> What's all this for? colorMask at this point is just a constant 0xfefefe,
> and so on.
>
> Is this filter supposed to support RGBA, or RGB32? If RGBA, then masking
> off the alpha channel when interpolating is wrong. If RGB32, then not
> masking off the alpha channel before comparing pixel equality is wrong.
> Either way, I don't think colorMask etc need to vary with colorspace. You
> could just always interpolate all 4 channels.
>
>  +#define Q_INTERPOLATE(A, B, C, D) ((A & c->qcolorMask) >> 2) + ((B &
>> c->qcolorMask) >> 2) \
>> +                                + ((C & c->qcolorMask) >> 2) + ((D &
>> c->qcolorMask) >> 2) \
>> +                                + ((((A & c->qlowpixelMask) + (B &
>> c->qlowpixelMask) + \
>> +                                     (C & c->qlowpixelMask) + (D &
>> c->qlowpixelMask)) >> 2) & c->qlowpixelMask)
>>
>
> More complex than necessary when it's never actually given 4 different
> args.
>
>  +AVFilter avfilter_vf_super2xsai =
>>
>
> needs a .description
>
> --Loren Merritt
>
>
Thanks, updated. Let me know if there is anything else.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 15358 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101125/de550d08/attachment.obj>



More information about the ffmpeg-devel mailing list