[FFmpeg-devel] [PATCH 1/2] libavfilter: Add new tinterlace mode

Stefano Sabatini stefasab at gmail.com
Fri Apr 27 23:42:48 CEST 2012


On date Friday 2012-04-27 22:14:29 +0100, Stuart Morris encoded:
> --- On Fri, 27/4/12, Stefano Sabatini <stefasab at gmail.com> wrote:
> > Please resend the patch as an attachment, merging it with
> > the next
> > documentation patch, something funny (encoding or stuff)
> > happened to
> > the mail so git complains with it.
> 
> Ok attached as requested.
> 
> > 
> > Missing avfilter_unref_buffer()?
> 
> Buffer 'cur' will become unref'd at the next call of start_frame()
> 
> > I don't know if we should use symbolic names rather than
> > numbers here,
> > maybe you can suggest a name for this specific mode.
> 
> The same feature on MythTV is referred to as interlaced x2.
> Interlacedx2 perhaps?
> 

> From de9eced9f437839a8e179abb9368d4685fb293ef Mon Sep 17 00:00:00 2001
> From: stuart <stuart at localhost.localdomain>
> Date: Thu, 26 Apr 2012 21:12:45 +0100
> Subject: [PATCH 1/2] Add new tinterlace mode 6
> 
> ---
>  libavfilter/vf_tinterlace.c |   33 +++++++++++++++++++++++++++++++--
>  1 files changed, 31 insertions(+), 2 deletions(-)
>  mode change 100644 => 100755 libavfilter/vf_tinterlace.c
> 
> diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c
> old mode 100644
> new mode 100755
> index 8407d1f..0f79708
> --- a/libavfilter/vf_tinterlace.c
> +++ b/libavfilter/vf_tinterlace.c
> @@ -68,9 +68,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
>      if (args) {
>          n = sscanf(args, "%d", &tinterlace->mode);
>  
> -        if (n != 1 || tinterlace->mode < 0 || tinterlace->mode > 5) {
> +        if (n != 1 || tinterlace->mode < 0 || tinterlace->mode > 6) {
>              av_log(ctx, AV_LOG_ERROR,
> -                   "Invalid mode '%s', use an integer between 0 and 5\n", args);
> +                   "Invalid mode '%s', use an integer between 0 and 6\n", args);
>              return AVERROR(EINVAL);
>          }
>      }
> @@ -257,12 +257,41 @@ static void end_frame(AVFilterLink *inlink)
>          avfilter_unref_buffer(tinterlace->next);
>          tinterlace->next = NULL;
>          break;
> +    case 6: /* re-interlace preserving image height, double frame rate 
> +             * Output current frame first */
> +        out = avfilter_ref_buffer(cur, AV_PERM_READ);
> +        break;
>      }
>  
>      avfilter_start_frame(outlink, out);
>      avfilter_draw_slice(outlink, 0, outlink->h, 1);
>      avfilter_end_frame(outlink);
>  

> +    switch (tinterlace->mode) {
> +    case 6: /* re-interlace preserving image height, double frame rate 
> +             * Output mix of current and next frame */
> +        tff = next->video->top_field_first;
> +        out = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
> +        avfilter_copy_buffer_ref_props(out, next);
> +        out->video->interlaced = 1;
> +
> +        /* write odd frame second field lines into the second field of the new frame */
> +        copy_picture_field(out->data, out->linesize,
> +                           cur->data, cur->linesize,
> +                           inlink->format, inlink->w, inlink->h,
> +                           tff ? FIELD_LOWER : FIELD_UPPER, 1, tff ? FIELD_LOWER : FIELD_UPPER);
> +        /* write even frame first field lines into the first field of the new frame */
> +        copy_picture_field(out->data, out->linesize,
> +                           next->data, next->linesize,
> +                           inlink->format, inlink->w, inlink->h,
> +                           tff ? FIELD_UPPER : FIELD_LOWER, 1, tff ? FIELD_UPPER : FIELD_LOWER);
> +                           
> +        avfilter_start_frame(outlink, out);
> +        avfilter_draw_slice(outlink, 0, outlink->h, 1);
> +        avfilter_end_frame(outlink);
> +        break;    
> +    }

You can merge this in the previous switch block.

[...]

Looks fine otherwise.
-- 
FFmpeg = Frightening & Fantastic Multimedia Puritan Ecletic Glue


More information about the ffmpeg-devel mailing list