[FFmpeg-devel] [PATCH] lavfi: add kerndeint filter

Stefano Sabatini stefasab at gmail.com
Fri Jan 4 11:38:57 CET 2013


On date Friday 2013-01-04 03:47:32 +0100, Clément Bœsch encoded:
> On Thu, Jan 03, 2013 at 08:26:46PM +0100, Stefano Sabatini wrote:
> > On date Thursday 2013-01-03 16:47:07 +0100, Stefano Sabatini encoded:
> > > On date Friday 2012-12-28 18:18:27 +0100, Clément Bœsch encoded:
> > [...]
> > > Locally fixed and patch updated. Please don't comment yet since this
> > > is work in progress.
> > 
> > Update, ready for review.
> > 
> > I had to fix the yuyv422 code (which is broken in
> > mp=kerndeint/MPlayer). yuv420p is identical to mp=kerndeint, while I
> > couldn't test ARGB (which can't be enabled in mp=kerndeint and I
> > couldn't test in MPlayer).
> > 
> > I plan to remove the mp=kerndeint wrapper after this is committed.
> > -- 
> > FFmpeg = Faithful and Funny Mastodontic Perfectionist Esoteric Guru
> 
> > From 0cc2489a85f2404b89f6acee5c551f72b25618b6 Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefasab at gmail.com>
> > Date: Thu, 18 Oct 2012 09:50:53 +0200
> > Subject: [PATCH] lavfi: add kerndeint filter
> > MIME-Version: 1.0
> > Content-Type: text/plain; charset=UTF-8
> > Content-Transfer-Encoding: 8bit
> > 
> > This is a port of the vf_kerndeint filter (libmpcodecs/vf_kerndeint) by
> > Donal A. Graft (original avisynth plugin author), and is based on the
> > work by Jérémy Tran <tran.jeremy.av at gmail.com> done for SOCIS 2012.
> > ---
> >  LICENSE                    |    1 +
> >  configure                  |    1 +
> >  doc/filters.texi           |   62 +++++++++
> >  libavfilter/Makefile       |    1 +
> >  libavfilter/allfilters.c   |    1 +
> >  libavfilter/vf_kerndeint.c |  323 ++++++++++++++++++++++++++++++++++++++++++++
> >  tests/fate/avfilter.mak    |    1 +
> >  tests/lavfi-regression.sh  |    4 +-
> >  tests/ref/lavfi/kerndeint  |    3 +
> >  9 files changed, 396 insertions(+), 1 deletion(-)
> >  create mode 100644 libavfilter/vf_kerndeint.c
> >  create mode 100644 tests/ref/lavfi/kerndeint
> > 
> > diff --git a/LICENSE b/LICENSE
> > index d083e56..2f5076b 100644
> > --- a/LICENSE
> > +++ b/LICENSE
> > @@ -33,6 +33,7 @@ Specifically, the GPL parts of FFmpeg are
> >      - vf_geq.c
> >      - vf_hqdn3d.c
> >      - vf_hue.c
> > +    - vf_kerndeint.c
> >      - vf_mp.c
> >      - vf_pp.c
> >      - vf_smartblur.c
> > diff --git a/configure b/configure
> > index 32f7eb1..3cd164c 100755
> > --- a/configure
> > +++ b/configure
> > @@ -1987,6 +1987,7 @@ frei0r_src_filter_extralibs='$ldl'
> >  geq_filter_deps="gpl"
> >  hqdn3d_filter_deps="gpl"
> >  hue_filter_deps="gpl"
> > +kerndeint_filter_deps="gpl"
> >  movie_filter_deps="avcodec avformat"
> >  mp_filter_deps="gpl avcodec swscale inline_asm"
> >  mptestsrc_filter_deps="gpl"
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 76e8fb5..c568ca7 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -2810,6 +2810,68 @@ If a parameter is omitted, it is kept at its current value.
> >  Interlaceing detect filter. This filter tries to detect if the input is
> >  interlaced or progressive. Top or bottom field first.
> >  
> > + at section kerndeint
> > +
> > +Deinterlace input video by applying Donald Graft's adaptive kernel
> > +deinterling. Work on interlaced parts of a video to produce
> > +progressive frames.
> > +
> > +This filter accepts parameters as a list of @var{key}=@var{value}
> > +pairs, separated by ":". If the key of the first options is omitted,
> > +the arguments are interpreted according to the following syntax:
> > + at var{thresh}:@var{map}:@var{order}:@var{sharp}:@var{twoway}@
> > +
> 
> trailing '@' or that is wanted?

Fixed.

> 
> > +The description of the accepted parameters
> > +follows.
> > +
> > + at table @option
> > + at item thresh
> > +Set the threshold which affects the filter's tolerance when
> > +determining if a pixel line must be processed. Must be an integer in
> > +the range [0,255] and defaults to 10. A value of 0 will result in
> > +applying the process on every pixels.
> > +
> > + at item map
> > +Must be 0 (ignore pixels exceeding the threshold) or 1 (paint pixels
> > +exceeding the threshold white) and defaults to 0.
> > +
> > + at item order
> > +Must be 0 (leave fields alone) or 1 (swap fields) and defaults to 0.
> > +
> > + at item sharp
> > +Must be 0 (disable additional sharpening) or 1 (enable additional
> > +sharpening) and defaults to 0.
> > +
> > + at item twoway
> > +Must be 0 (disable twoway sharpening) or 1 (enable twoway sharpening)
> > +and defaults to 0.
> > +
> > + at item deint
> > +Enable deinterlacing if set to 1. Default is 1.
> > + at end table
> > +
> 
> nit: you use too forms, "and defaults to X" and "Default is X". It could
> be consistent.

Changed.

> > + at subsection Examples
> > +
> > + at itemize
> > + at item
> > +Apply default values:
> > + at example
> > +kerndeint=thresh=10:map=0:order=0:sharp=0:twoway=0:deint=1
> > + at end example
> > +
> > + at item
> > +Enable additional sharpening:
> > + at example
> > +kerndeint=sharp=1
> > + at end example
> > +
> > + at item
> > +Paint processed pixels in white:
> > + at example
> > +kerndeint=map=1
> > + at end example
> > + at end itemize
> > +
> >  @section lut, lutrgb, lutyuv
> >  
> >  Compute a look-up table for binding each pixel component input value
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > index d84bf5d..a7aa8cc 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -114,6 +114,7 @@ OBJS-$(CONFIG_HFLIP_FILTER)                  += vf_hflip.o
> >  OBJS-$(CONFIG_HQDN3D_FILTER)                 += vf_hqdn3d.o
> >  OBJS-$(CONFIG_HUE_FILTER)                    += vf_hue.o
> >  OBJS-$(CONFIG_IDET_FILTER)                   += vf_idet.o
> > +OBJS-$(CONFIG_KERNDEINT_FILTER)              += vf_kerndeint.o
> >  OBJS-$(CONFIG_LUT_FILTER)                    += vf_lut.o
> >  OBJS-$(CONFIG_LUTRGB_FILTER)                 += vf_lut.o
> >  OBJS-$(CONFIG_LUTYUV_FILTER)                 += vf_lut.o
> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> > index 4458917..fdb7f37 100644
> > --- a/libavfilter/allfilters.c
> > +++ b/libavfilter/allfilters.c
> > @@ -108,6 +108,7 @@ void avfilter_register_all(void)
> >      REGISTER_FILTER(HQDN3D,         hqdn3d,         vf);
> >      REGISTER_FILTER(HUE,            hue,            vf);
> >      REGISTER_FILTER(IDET,           idet,           vf);
> > +    REGISTER_FILTER(KERNDEINT,      kerndeint,      vf);
> >      REGISTER_FILTER(LUT,            lut,            vf);
> >      REGISTER_FILTER(LUTRGB,         lutrgb,         vf);
> >      REGISTER_FILTER(LUTYUV,         lutyuv,         vf);
> > diff --git a/libavfilter/vf_kerndeint.c b/libavfilter/vf_kerndeint.c
> > new file mode 100644
> > index 0000000..61a4249
> > --- /dev/null
> > +++ b/libavfilter/vf_kerndeint.c
> > @@ -0,0 +1,323 @@
> > +/*
> > + * Copyright (c) 2012 Jeremy Tran
> > + * Copyright (c) 2004 Tobias Diedrich
> > + * Copyright (c) 2003 Donald A. Graft
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License along
> > + * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
> > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> > + */
> > +
> > +/**
> > + * @file
> > + * Kernel Deinterlacer
> > + * Ported from MPlayer libmpcodecs/vf_kerndeint.c.
> > + */
> > +
> > +#include "libavutil/imgutils.h"
> > +#include "libavutil/intreadwrite.h"
> > +#include "libavutil/opt.h"
> > +#include "libavutil/pixdesc.h"
> > +
> > +#include "avfilter.h"
> > +#include "formats.h"
> > +#include "internal.h"
> > +
> > +typedef struct {
> > +    const AVClass *class;
> > +    int           frame; ///< frame count, starting from 0
> > +    int           thresh, map, order, sharp, twoway, deint;
> > +    int           hsub, vsub;
> > +    uint8_t       *temp_data[4]; ///< temporary video plane data buffer
> > +    int           temp_linesize[4];
> > +    int           pixel_step;
> > +} KerndeintContext;
> > +
> > +#define OFFSET(x) offsetof(KerndeintContext, x)
> > +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> > +static const AVOption kerndeint_options[] = {
> > +    { "thresh", "set the threshold", OFFSET(thresh), AV_OPT_TYPE_INT, { 10 }, 0, 255, FLAGS },
> > +    { "map",    "set the map", OFFSET(map), AV_OPT_TYPE_INT, { 0 }, 0, 1, FLAGS },
> > +    { "order",  "set the order", OFFSET(order), AV_OPT_TYPE_INT, { 0 }, 0, 1, FLAGS },
> > +    { "sharp",  "set the sharpening mode", OFFSET(sharp), AV_OPT_TYPE_INT, { 0 }, 0, 1, FLAGS },
> > +    { "twoway", "activate twoway", OFFSET(twoway), AV_OPT_TYPE_INT, { 0 }, 0, 1, FLAGS },
> > +    { "deint",  "enable deinterlacing", OFFSET(deint), AV_OPT_TYPE_INT, { 1 }, 0, 1, FLAGS },
> > +    { NULL }
> > +};
> > +
> > +AVFILTER_DEFINE_CLASS(kerndeint);
> > +
> > +static av_cold int init(AVFilterContext *ctx, const char *args)
> > +{
> > +    KerndeintContext *kerndeint = ctx->priv;
> > +    const char const * shorthand[] = { "thresh", "map", "order", "sharp", "twoway", NULL };
> > +
> > +    kerndeint->class = &kerndeint_class;
> > +    av_opt_set_defaults(kerndeint);
> > +
> > +    return av_opt_set_from_string(kerndeint, args, shorthand, "=", ":");
> > +}
> > +
> > +static av_cold void uninit(AVFilterContext *ctx)
> > +{
> > +    KerndeintContext *kerndeint = ctx->priv;
> > +
> > +    av_free(kerndeint->temp_data[0]);
> > +    av_opt_free(kerndeint);
> > +}
> > +
> > +static int query_formats(AVFilterContext *ctx)
> > +{
> > +    static const enum PixelFormat pix_fmts[] = {
> > +        PIX_FMT_YUV420P,
> > +        PIX_FMT_YUYV422,
> > +        PIX_FMT_ARGB,
> > +        PIX_FMT_NONE
> > +    };
> > +
> 
> Given how generic the code looks like, it's surprising to see so few pixel
> formats. I guess you could add some after the first version.

Main problem is the map option, and I don't feel much motivated into
extending this filter.

> > +    ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
> > +
> > +    return 0;
> > +}
> > +
> > +static int config_props(AVFilterLink *inlink)
> > +{
> > +    KerndeintContext *kerndeint = inlink->dst->priv;
> > +    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[inlink->format];
> > +
> > +    kerndeint->hsub = desc->log2_chroma_w;
> 

> Looks unused, but maybe you should.

It isn't, removed.
 
> > +    kerndeint->vsub = desc->log2_chroma_h;
> > +    kerndeint->pixel_step = av_get_bits_per_pixel(desc) >> 3;
> > +
> > +    return av_image_alloc(kerndeint->temp_data, kerndeint->temp_linesize,
> > +                          inlink->w, inlink->h, inlink->format, 1);
> > +}
> > +
> > +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *inpic)
> > +{
> > +    KerndeintContext *kerndeint = inlink->dst->priv;
> > +    AVFilterLink *outlink = inlink->dst->outputs[0];
> > +    AVFilterBufferRef *outpic;
> > +    const uint8_t *prvp;   ///< Previous field's pixel line number n
> > +    const uint8_t *prvpp;  ///< Previous field's pixel line number (n - 1)
> > +    const uint8_t *prvpn;  ///< Previous field's pixel line number (n + 1)
> > +    const uint8_t *prvppp; ///< Previous field's pixel line number (n - 2)
> > +    const uint8_t *prvpnn; ///< Previous field's pixel line number (n + 2)
> > +    const uint8_t *prvp4p; ///< Previous field's pixel line number (n - 4)
> > +    const uint8_t *prvp4n; ///< Previous field's pixel line number (n + 4)
> > +
> > +    const uint8_t *srcp;   ///< Current field's pixel line number n
> > +    const uint8_t *srcpp;  ///< Current field's pixel line number (n - 1)
> > +    const uint8_t *srcpn;  ///< Current field's pixel line number (n + 1)
> > +    const uint8_t *srcppp; ///< Current field's pixel line number (n - 2)
> > +    const uint8_t *srcpnn; ///< Current field's pixel line number (n + 2)
> > +    const uint8_t *srcp3p; ///< Current field's pixel line number (n - 3)
> > +    const uint8_t *srcp3n; ///< Current field's pixel line number (n + 3)
> > +    const uint8_t *srcp4p; ///< Current field's pixel line number (n - 4)
> > +    const uint8_t *srcp4n; ///< Current field's pixel line number (n + 4)
> > +
> > +    uint8_t *dstp, *dstp_saved;
> > +    const uint8_t *srcp_saved;
> > +
> > +    int src_linesize, psrc_linesize, dst_linesize, linesize;
> > +    int x, y, plane, val, hi, lo, g, h, n = kerndeint->frame++;
> > +    double valf;
> > +
> > +    const int thresh = kerndeint->thresh;
> > +    const int order  = kerndeint->order;
> > +    const int map    = kerndeint->map;
> > +    const int sharp  = kerndeint->sharp;
> > +    const int twoway = kerndeint->twoway;
> > +
> > +    if (!kerndeint->deint)
> > +        return ff_filter_frame(outlink, inpic);
> > +
> > +    outpic = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h);
> > +    if (!outpic) {
> > +        avfilter_unref_bufferp(&inpic);
> > +        return AVERROR(ENOMEM);
> > +    }
> > +    avfilter_copy_buffer_ref_props(outpic, inpic);
> > +    outpic->video->interlaced = 0;
> > +
> > +    for (plane = 0; inpic->data[plane] && plane < 4; plane++) {
> > +        h = plane == 0 ? inlink->h : inlink->h >> kerndeint->vsub;
> > +        linesize = kerndeint->temp_linesize[plane];
> > +
> > +        srcp = srcp_saved = inpic->data[plane];
> > +        src_linesize      = inpic->linesize[plane];
> > +        psrc_linesize     = outpic->linesize[plane];
> > +        dstp = dstp_saved = outpic->data[plane];
> > +        dst_linesize      = outpic->linesize[plane];
> > +        srcp              = srcp_saved + (1 - order) * src_linesize;
> > +        dstp              = dstp_saved + (1 - order) * dst_linesize;
> > +
> > +        for (y = 0; y < h; y += 2) {
> > +            memcpy(dstp, srcp, kerndeint->temp_linesize[plane]);
> 

> You can use the linesize variable here. Also, I find that variable very
> badly named; it's not the linesize, it's the width in bytes (or something
> is wrong).

Changed, variable renamed to "bwidth".

> 
> > +            srcp += 2 * src_linesize;
> > +            dstp += 2 * dst_linesize;
> > +        }
> > +
> > +        // Copy through the lines that will be missed below.
> > +        memcpy(dstp_saved + order            * dst_linesize, srcp_saved + (1 -     order) * src_linesize, linesize);
> > +        memcpy(dstp_saved + (2 + order    )  * dst_linesize, srcp_saved + (3 -     order) * src_linesize, linesize);
> > +        memcpy(dstp_saved + (h - 2 + order)  * dst_linesize, srcp_saved + (h - 1 - order) * src_linesize, linesize);
> > +        memcpy(dstp_saved + (h - 4 + order)  * dst_linesize, srcp_saved + (h - 3 - order) * src_linesize, linesize);
> > +
> > +        /* For the other field choose adaptively between using the previous field
> > +           or the interpolant from the current field. */
> > +        prvp   = kerndeint->temp_data[plane] + 5 * psrc_linesize - (1 - order) * psrc_linesize;
> > +        prvpp  = prvp - psrc_linesize;
> > +        prvppp = prvp - 2 * psrc_linesize;
> > +        prvp4p = prvp - 4 * psrc_linesize;
> > +        prvpn  = prvp + psrc_linesize;
> > +        prvpnn = prvp + 2 * psrc_linesize;
> > +        prvp4n = prvp + 4 * psrc_linesize;
> > +
> > +        srcp   = srcp_saved + 5 * src_linesize - (1 - order) * src_linesize;
> > +        srcpp  = srcp - src_linesize;
> > +        srcppp = srcp - 2 * src_linesize;
> > +        srcp3p = srcp - 3 * src_linesize;
> > +        srcp4p = srcp - 4 * src_linesize;
> > +
> > +        srcpn  = srcp + src_linesize;
> > +        srcpnn = srcp + 2 * src_linesize;
> > +        srcp3n = srcp + 3 * src_linesize;
> > +        srcp4n = srcp + 4 * src_linesize;
> > +
> > +        dstp   = dstp_saved + 5 * dst_linesize - (1 - order) * dst_linesize;
> > +
> > +        for (y = 5 - (1 - order); y <= h - 5 - (1 - order); y += 2) {
> > +            for (x = 0; x < linesize; x++) {
> > +                if (thresh == 0 || n == 0 ||
> > +                    (abs((int)prvp[x]  - (int)srcp[x])  > thresh) ||
> > +                    (abs((int)prvpp[x] - (int)srcpp[x]) > thresh) ||
> > +                    (abs((int)prvpn[x] - (int)srcpn[x]) > thresh)) {
> > +                    if (map) {
> > +                        g = x & ~3;
> > +
> > +                        if (inlink->format == AV_PIX_FMT_RGBA) {
> > +                            AV_WN32(dstp + g, 0xffffffff);
> > +                            x = g + 3;
> > +                        } else if (inlink->format == AV_PIX_FMT_YUYV422) {
> 
> This one is not in query_format.
> 
> > +                            // y <- 235, u <- 128, y <- 235, v <- 128
> > +                            AV_WN32(dstp + g, 0xeb80eb80);
> > +                            x = g + 3;
> > +                        } else {
> > +                            dstp[x] = plane == 0 ? 235 : 128;
> > +                        }
> > +                    } else {
> > +                        if (inlink->format == AV_PIX_FMT_RGBA) {
> > +                            hi = 255;
> > +                            lo = 0;
> > +                        } else if (inlink->format == AV_PIX_FMT_YUYV422) {
> > +                            hi = (x & 1) ? 240 : 235;
> > +                            lo = 16;
> > +                        } else {
> > +                            hi = (plane == 0) ? 235 : 240;
> > +                            lo = 16;
> > +                        }
> > +
> > +                        if (sharp == 1) {
> > +                            if (twoway == 1) {
> > +                                valf = + 0.526 * ((int)srcpp[x] + (int)srcpn[x])
> > +                                    + 0.170 * ((int)srcp[x] + (int)prvp[x])
> > +                                    - 0.116 * ((int)srcppp[x] + (int)srcpnn[x] + (int)prvppp[x] + (int)prvpnn[x])
> > +                                    - 0.026 * ((int)srcp3p[x] + (int)srcp3n[x])
> > +                                    + 0.031 * ((int)srcp4p[x] + (int)srcp4n[x] + (int)prvp4p[x] + (int)prvp4n[x]);
> > +                            } else {
> > +                                valf = + 0.526 * ((int)srcpp[x] + (int)srcpn[x])
> > +                                    + 0.170 * ((int)prvp[x])
> > +                                    - 0.116 * ((int)prvppp[x] + (int)prvpnn[x])
> > +                                    - 0.026 * ((int)srcp3p[x] + (int)srcp3n[x])
> > +                                    + 0.031 * ((int)prvp4p[x] + (int)prvp4p[x]);
> > +                            }
> > +                            dstp[x] = av_clip(valf, lo, hi);
> > +                        } else {
> > +                            if (twoway == 1) {
> > +                                val = (8 * ((int)srcpp[x] + (int)srcpn[x]) + 2 * ((int)srcp[x] + (int)prvp[x])
> > +                                       - (int)(srcppp[x]) - (int)(srcpnn[x])
> > +                                       - (int)(prvppp[x]) - (int)(prvpnn[x])) >> 4;
> > +                            } else {
> > +                                val = (8 * ((int)srcpp[x] + (int)srcpn[x]) + 2 * ((int)prvp[x])
> > +                                       - (int)(prvppp[x]) - (int)(prvpnn[x])) >> 4;
> > +                            }
> > +                            dstp[x] = av_clip(val, lo, hi);
> > +                        }
> > +                    }
> > +                } else {
> > +                    dstp[x] = srcp[x];
> > +                }
> > +            }
> > +            prvp   += 2 * psrc_linesize;
> > +            prvpp  += 2 * psrc_linesize;
> > +            prvppp += 2 * psrc_linesize;
> > +            prvpn  += 2 * psrc_linesize;
> > +            prvpnn += 2 * psrc_linesize;
> > +            prvp4p += 2 * psrc_linesize;
> > +            prvp4n += 2 * psrc_linesize;
> > +            srcp   += 2 * src_linesize;
> > +            srcpp  += 2 * src_linesize;
> > +            srcppp += 2 * src_linesize;
> > +            srcp3p += 2 * src_linesize;
> > +            srcp4p += 2 * src_linesize;
> > +            srcpn  += 2 * src_linesize;
> > +            srcpnn += 2 * src_linesize;
> > +            srcp3n += 2 * src_linesize;
> > +            srcp4n += 2 * src_linesize;
> > +            dstp   += 2 * dst_linesize;
> > +        }
> > +
> > +        srcp = inpic->data[plane];
> > +        dstp = kerndeint->temp_data[plane];
> > +        av_image_copy_plane(dstp, psrc_linesize, srcp, src_linesize, kerndeint->temp_linesize[plane], h);
> 
> I think you can use your badly named linesize variable here too ;)

Changed.

> 
> > +    }
> > +
> > +    avfilter_unref_buffer(inpic);
> > +    return ff_filter_frame(outlink, outpic);
> > +}
> > +
> > +static const AVFilterPad kerndeint_inputs[] = {
> > +    {
> > +        .name         = "default",
> > +        .type         = AVMEDIA_TYPE_VIDEO,
> > +        .filter_frame = filter_frame,
> > +        .config_props = config_props,
> > +        .min_perms    = AV_PERM_READ,
> > +    },
> > +    { NULL }
> > +};
> > +
> > +static const AVFilterPad kerndeint_outputs[] = {
> > +    {
> > +        .name = "default",
> > +        .type = AVMEDIA_TYPE_VIDEO,
> > +    },
> > +    { NULL }
> > +};
> > +
> > +AVFilter avfilter_vf_kerndeint = {
> > +    .name        = "kerndeint",
> > +    .description = NULL_IF_CONFIG_SMALL("Apply kernel deinterlacing to the input."),
> > +    .priv_size = sizeof(KerndeintContext),
> > +    .init          = init,
> 
> nit: I'm sure you can do a better alignment here.
> 
> > +    .uninit        = uninit,
> > +    .query_formats = query_formats,
> > +
> > +    .inputs        = kerndeint_inputs,
> > +    .outputs       = kerndeint_outputs,
> > +
> > +    .priv_class = &kerndeint_class,
> > +};
> > diff --git a/tests/fate/avfilter.mak b/tests/fate/avfilter.mak
> > index e69d6a1..ad865df 100644
> > --- a/tests/fate/avfilter.mak
> > +++ b/tests/fate/avfilter.mak
> > @@ -11,6 +11,7 @@ FATE_LAVFI = fate-lavfi-alphaextract_rgb                                \
> >               fate-lavfi-fade                                            \
> >               fate-lavfi-field                                           \
> >               fate-lavfi-idet                                            \
> > +             fate-lavfi-kerndeint                                       \
> >               fate-lavfi-life                                            \
> >               fate-lavfi-null                                            \
> >               fate-lavfi-overlay                                         \
> > diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh
> > index 741e716..a22331f 100755
> > --- a/tests/lavfi-regression.sh
> > +++ b/tests/lavfi-regression.sh
> > @@ -80,6 +80,7 @@ do_lavfi_pixfmts(){
> >      test ${test%_[bl]e} = $testname || return 0
> >      filter=$2
> >      filter_args=$3
> > +    prefilter_chain=$4
> >  
> >      showfiltfmts="$target_exec $target_path/libavfilter/filtfmts-test"
> >      scale_exclude_fmts=${outfile}${testname}_scale_exclude_fmts
> > @@ -96,7 +97,7 @@ do_lavfi_pixfmts(){
> >      pix_fmts=$(comm -12 $scale_exclude_fmts $in_fmts)
> >  
> >      for pix_fmt in $pix_fmts; do
> > -        do_video_filter $pix_fmt "format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt
> > +        do_video_filter $pix_fmt "${prefilter_chain}format=$pix_fmt,$filter=$filter_args" -pix_fmt $pix_fmt
> >      done
> >  
> >      rm $in_fmts $scale_in_fmts $scale_out_fmts $scale_exclude_fmts
> > @@ -104,6 +105,7 @@ do_lavfi_pixfmts(){
> >  
> >  # all these filters have exactly one input and exactly one output
> >  do_lavfi_pixfmts "field"               "field"   "bottom"
> > +do_lavfi_pixfmts "kerndeint"           "kerndeint" "" "tinterlace=interleave_top,"
> >  do_lavfi_pixfmts "pixfmts_copy"        "copy"    ""
> >  do_lavfi_pixfmts "pixfmts_crop"        "crop"    "100:100:100:100"
> >  do_lavfi_pixfmts "pixfmts_hflip"       "hflip"   ""
> > diff --git a/tests/ref/lavfi/kerndeint b/tests/ref/lavfi/kerndeint
> > new file mode 100644
> > index 0000000..d7ace93
> > --- /dev/null
> > +++ b/tests/ref/lavfi/kerndeint
> > @@ -0,0 +1,3 @@
> > +argb                484893f83e13c937328f13a7c84d2f50
> > +yuv420p             a935cce07c5287b92c6d5220361866ed
> > +yuyv422             f549c98059ba9ce50e28204256d13b5d
> 
> Rest should be OK.

Fixed a map endianess issue, updated.

Will push it soon if I read no more comments.
-- 
FFmpeg = Fancy & Furious Mind-dumbing Portentous Elegant Gadget
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-lavfi-add-kerndeint-filter.patch
Type: text/x-diff
Size: 20802 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130104/330093b7/attachment.bin>


More information about the ffmpeg-devel mailing list