[FFmpeg-devel] [RFC/PATCH] Add mode to enable disable deinterlacing based on input interlaced flag to yadif

Michael Niedermayer michaelni at gmx.at
Tue Jun 28 22:45:07 CEST 2011


On Tue, Jun 28, 2011 at 09:04:57PM +0200, elupus wrote:
> On Tue, 28 Jun 2011 12:39:36 +0200, Stefano Sabatini wrote:
> 
> > Please add mention of the new option on the manual, in
> > doc/filters.texi.
> 
> Updated..
Content-Description: Attached file: 0001-Add-mode-to-enable-disable-based-on-input-interlaced.patch
>  doc/filters.texi       |   14 +++++++++++++-
>  libavfilter/vf_yadif.c |   34 +++++++++++++++++++++++++++++++---
>  2 files changed, 44 insertions(+), 4 deletions(-)
> 6f0c8ae84921e89b3cefa4d808696577fbde9de5  0001-Add-mode-to-enable-disable-based-on-input-interlaced.patch
> From 0e00ad462b1168065278aacfc23460cfeab051c0 Mon Sep 17 00:00:00 2001
> From: Joakim <elupus at ecce.se>
> Date: Fri, 24 Jun 2011 01:16:18 +0200
> Subject: [PATCH] Add mode to enable/disable based on input "interlaced" flag to yadif
> 
> Signed-off-by: Joakim Plate <elupus at ecce.se>
> ---
>  doc/filters.texi       |   14 +++++++++++++-
>  libavfilter/vf_yadif.c |   34 +++++++++++++++++++++++++++++++---
>  2 files changed, 44 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index eb31714..7d3d249 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -1737,7 +1737,7 @@ Flip the input video vertically.
>  Deinterlace the input video ("yadif" means "yet another deinterlacing
>  filter").
>  
> -It accepts the optional parameters: @var{mode}:@var{parity}.
> +It accepts the optional parameters: @var{mode}:@var{parity}:@var(auto).

why dont you just use parity=-1 ?


>  
>  @var{mode} specifies the interlacing mode to adopt, accepts one of the
>  following values:
> @@ -1771,6 +1771,18 @@ Default value is -1.
>  If interlacing is unknown or decoder does not export this information,
>  top field first will be assumed.
>  
> + at var{auto] specifies if deinterlacer should trust the interlaced flag
> +and only deinterlace frames marked as interlaced
> +
> + at table @option
> + at item 0
> +deinterlace all frames
> + at item 1
> +only deinterlace frames marked as interlaced
> + at end table
> +
> +Default value is 0.
> +
>  @c man end VIDEO FILTERS
>  
>  @chapter Video Sources
> diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
> index 296328b..f89490a 100644
> --- a/libavfilter/vf_yadif.c
> +++ b/libavfilter/vf_yadif.c
> @@ -43,6 +43,13 @@ typedef struct {
>      int parity;
>  
>      int frame_pending;
> +    int skip;
> +
> +    /**
> +     *  0: deinterlace all frames
> +     *  1: only deinterlace frames marked as interlaced
> +     */
> +    int auto_enable;
>  
>      AVFilterBufferRef *cur;
>      AVFilterBufferRef *next;
> @@ -236,10 +243,21 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
>      yadif->prev = yadif->cur;
>      yadif->cur  = yadif->next;
>      yadif->next = picref;
> +    yadif->skip = 0;
>  
>      if (!yadif->cur)
>          return;
>  
> +    if (yadif->auto_enable && !yadif->cur->video->interlaced) {
> +        yadif->out  = yadif->cur;
> +        avfilter_unref_buffer(yadif->prev);
> +        yadif->cur  = NULL;
> +        yadif->prev = NULL;
> +        yadif->skip = 1;
> +        avfilter_start_frame(ctx->outputs[0], yadif->out);
> +        return;
> +    }

This doesnt look entirely correct.
consider that every second frame is interlaced. these frames should
be deinterlaced using the non interlaced frames as prev/next


> +
>      if (!yadif->prev)
>          yadif->prev = avfilter_ref_buffer(yadif->cur, AV_PERM_READ);
>  
> @@ -256,6 +274,12 @@ static void end_frame(AVFilterLink *link)
>      AVFilterContext *ctx = link->dst;
>      YADIFContext *yadif = ctx->priv;
>  
> +    if (yadif->skip) {
> +        avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1);
> +        avfilter_end_frame(ctx->outputs[0]);
> +        return;
> +    }
> +
>      if (!yadif->out)
>          return;
>



> @@ -277,7 +301,7 @@ static int request_frame(AVFilterLink *link)
>  
>          if ((ret = avfilter_request_frame(link->src->inputs[0])))
>              return ret;
> -    } while (!yadif->cur);
> +    } while (!yadif->out);
>  
>      return 0;
>  }

please elaborate on why this change is needed


> @@ -299,6 +323,9 @@ static int poll_frame(AVFilterLink *link)
>      }
>      assert(yadif->next || !val);
>  
> +    if (yadif->skip)
> +        return val;

please elaborate on why this change is needed

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110628/9dd4ffa0/attachment.asc>


More information about the ffmpeg-devel mailing list