[FFmpeg-devel] [PATCH] Port MPlayer 2xSaI filter to libavfilter
Loren Merritt
lorenm
Wed Nov 24 19:01:22 CET 2010
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
More information about the ffmpeg-devel
mailing list