FFmpeg
Loading...
Searching...
No Matches
vf_dejudder.c File Reference

remove judder in video stream More...

#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  DejudderContext
 

Macros

#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (dejudder)
 
static int config_out_props (AVFilterLink *outlink)
 
static av_cold int dejudder_init (AVFilterContext *ctx)
 
static av_cold void dejudder_uninit (AVFilterContext *ctx)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 

Variables

static const AVOption dejudder_options []
 
static const AVFilterPad dejudder_inputs []
 
static const AVFilterPad dejudder_outputs []
 
const FFFilter ff_vf_dejudder
 

Detailed Description

remove judder in video stream

Algorithm:

  • If the old packets had PTS of old_pts[i]. Replace these with new value based on the running average of the last n=cycle frames. So

    new_pts[i] = Sum(k=i-n+1, i, old_pts[k])/n

    • (old_pts[i]-old_pts[i-n])*(n-1)/2n

    For any repeating pattern of length n of judder this will produce an even progression of PTS's.

  • In order to avoid calculating this sum ever frame, a running tally is maintained in ctx->new_pts. Each frame the new term at the start of the sum is added, the one and the end is removed, and the offset terms (second line in formula above) are recalculated.
  • To aid in this a ringbuffer of the last n-2 PTS's is maintained in ctx->ringbuff. With the indices of the first two and last two entries stored in i1, i2, i3, & i4.
  • To ensure that the new PTS's are integers, time_base is divided by 2n. This removes the division in the new_pts calculation.
  • frame_rate is also multiplied by 2n to allow the frames to fall where they may in what may now be a VFR output. This produces more even output then setting frame_rate=1/0 in practice.

Definition in file vf_dejudder.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 68 of file vf_dejudder.c.

◆ FLAGS

Definition at line 69 of file vf_dejudder.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( dejudder )

◆ config_out_props()

static int config_out_props ( AVFilterLink * outlink)
static

Definition at line 79 of file vf_dejudder.c.

◆ dejudder_init()

static av_cold int dejudder_init ( AVFilterContext * ctx)
static

Definition at line 95 of file vf_dejudder.c.

◆ dejudder_uninit()

static av_cold void dejudder_uninit ( AVFilterContext * ctx)
static

Definition at line 113 of file vf_dejudder.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * frame )
static

Definition at line 120 of file vf_dejudder.c.

Variable Documentation

◆ dejudder_options

const AVOption dejudder_options[]
static
Initial value:
= {
{"cycle", "set the length of the cycle to use for dejuddering",
OFFSET(cycle), AV_OPT_TYPE_INT, {.i64 = 4}, 2, 240, .flags = FLAGS},
{NULL}
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 71 of file vf_dejudder.c.

◆ dejudder_inputs

const AVFilterPad dejudder_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 161 of file vf_dejudder.c.

◆ dejudder_outputs

const AVFilterPad dejudder_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_out_props,
},
}
static int config_out_props(AVFilterLink *outlink)
Definition vf_dejudder.c:79

Definition at line 169 of file vf_dejudder.c.

◆ ff_vf_dejudder

const FFFilter ff_vf_dejudder
Initial value:
= {
.p.name = "dejudder",
.p.description= NULL_IF_CONFIG_SMALL("Remove judder produced by pullup."),
.p.priv_class= &dejudder_class,
.priv_size = sizeof(DejudderContext),
.init = dejudder_init,
.uninit = dejudder_uninit,
}
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold void dejudder_uninit(AVFilterContext *ctx)
static av_cold int dejudder_init(AVFilterContext *ctx)
Definition vf_dejudder.c:95
static const AVFilterPad dejudder_inputs[]
static const AVFilterPad dejudder_outputs[]

Definition at line 177 of file vf_dejudder.c.