FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_deflicker.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/qsort.h"
#include "avfilter.h"
#include "bufferqueue.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  DeflickerContext
 

Macros

#define FF_BUFQUEUE_SIZE   129
 
#define SIZE   FF_BUFQUEUE_SIZE
 
#define OFFSET(x)   offsetof(DeflickerContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

enum  smooth_mode {
  ARITHMETIC_MEAN, GEOMETRIC_MEAN, HARMONIC_MEAN, QUADRATIC_MEAN,
  CUBIC_MEAN, POWER_MEAN, MEDIAN, NB_SMOOTH_MODE
}
 

Functions

 AVFILTER_DEFINE_CLASS (deflicker)
 
static int query_formats (AVFilterContext *ctx)
 
static int deflicker8 (AVFilterContext *ctx, const uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h, float f)
 
static int deflicker16 (AVFilterContext *ctx, const uint8_t *ssrc, ptrdiff_t src_linesize, uint8_t *ddst, ptrdiff_t dst_linesize, int w, int h, float f)
 
static float calc_avgy8 (AVFilterContext *ctx, AVFrame *in)
 
static float calc_avgy16 (AVFilterContext *ctx, AVFrame *in)
 
static void get_am_factor (AVFilterContext *ctx, float *f)
 
static void get_gm_factor (AVFilterContext *ctx, float *f)
 
static void get_hm_factor (AVFilterContext *ctx, float *f)
 
static void get_qm_factor (AVFilterContext *ctx, float *f)
 
static void get_cm_factor (AVFilterContext *ctx, float *f)
 
static void get_pm_factor (AVFilterContext *ctx, float *f)
 
static int comparef (const void *a, const void *b)
 
static void get_median_factor (AVFilterContext *ctx, float *f)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *buf)
 
static int request_frame (AVFilterLink *outlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption deflicker_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
AVFilter ff_vf_deflicker
 

Macro Definition Documentation

◆ FF_BUFQUEUE_SIZE

#define FF_BUFQUEUE_SIZE   129

Definition at line 27 of file vf_deflicker.c.

◆ SIZE

#define SIZE   FF_BUFQUEUE_SIZE

Definition at line 34 of file vf_deflicker.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(DeflickerContext, x)

Definition at line 73 of file vf_deflicker.c.

◆ FLAGS

Definition at line 74 of file vf_deflicker.c.

Enumeration Type Documentation

◆ smooth_mode

Enumerator
ARITHMETIC_MEAN 
GEOMETRIC_MEAN 
HARMONIC_MEAN 
QUADRATIC_MEAN 
CUBIC_MEAN 
POWER_MEAN 
MEDIAN 
NB_SMOOTH_MODE 

Definition at line 36 of file vf_deflicker.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( deflicker  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 94 of file vf_deflicker.c.

◆ deflicker8()

static int deflicker8 ( AVFilterContext ctx,
const uint8_t src,
ptrdiff_t  src_linesize,
uint8_t dst,
ptrdiff_t  dst_linesize,
int  w,
int  h,
float  f 
)
static

Definition at line 124 of file vf_deflicker.c.

Referenced by config_input().

◆ deflicker16()

static int deflicker16 ( AVFilterContext ctx,
const uint8_t ssrc,
ptrdiff_t  src_linesize,
uint8_t ddst,
ptrdiff_t  dst_linesize,
int  w,
int  h,
float  f 
)
static

Definition at line 143 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy8()

static float calc_avgy8 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 166 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy16()

static float calc_avgy16 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 189 of file vf_deflicker.c.

Referenced by config_input().

◆ get_am_factor()

static void get_am_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 212 of file vf_deflicker.c.

Referenced by config_input().

◆ get_gm_factor()

static void get_gm_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 227 of file vf_deflicker.c.

Referenced by config_input().

◆ get_hm_factor()

static void get_hm_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 242 of file vf_deflicker.c.

Referenced by config_input().

◆ get_qm_factor()

static void get_qm_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 257 of file vf_deflicker.c.

Referenced by config_input().

◆ get_cm_factor()

static void get_cm_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 273 of file vf_deflicker.c.

Referenced by config_input().

◆ get_pm_factor()

static void get_pm_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 289 of file vf_deflicker.c.

Referenced by config_input().

◆ comparef()

static int comparef ( const void *  a,
const void *  b 
)
static

Definition at line 305 of file vf_deflicker.c.

Referenced by get_median_factor().

◆ get_median_factor()

static void get_median_factor ( AVFilterContext ctx,
float *  f 
)
static

Definition at line 311 of file vf_deflicker.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 321 of file vf_deflicker.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 360 of file vf_deflicker.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 419 of file vf_deflicker.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 442 of file vf_deflicker.c.

Variable Documentation

◆ deflicker_options

const AVOption deflicker_options[]
static
Initial value:
= {
{ "size", "set how many frames to use", OFFSET(size), AV_OPT_TYPE_INT, {.i64=5}, 2, SIZE, FLAGS },
{ "s", "set how many frames to use", OFFSET(size), AV_OPT_TYPE_INT, {.i64=5}, 2, SIZE, FLAGS },
{ "mode", "set how to smooth luminance", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_SMOOTH_MODE-1, FLAGS, "mode" },
{ "m", "set how to smooth luminance", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_SMOOTH_MODE-1, FLAGS, "mode" },
{ "am", "arithmetic mean", 0, AV_OPT_TYPE_CONST, {.i64=ARITHMETIC_MEAN}, 0, 0, FLAGS, "mode" },
{ "gm", "geometric mean", 0, AV_OPT_TYPE_CONST, {.i64=GEOMETRIC_MEAN}, 0, 0, FLAGS, "mode" },
{ "hm", "harmonic mean", 0, AV_OPT_TYPE_CONST, {.i64=HARMONIC_MEAN}, 0, 0, FLAGS, "mode" },
{ "qm", "quadratic mean", 0, AV_OPT_TYPE_CONST, {.i64=QUADRATIC_MEAN}, 0, 0, FLAGS, "mode" },
{ "cm", "cubic mean", 0, AV_OPT_TYPE_CONST, {.i64=CUBIC_MEAN}, 0, 0, FLAGS, "mode" },
{ "pm", "power mean", 0, AV_OPT_TYPE_CONST, {.i64=POWER_MEAN}, 0, 0, FLAGS, "mode" },
{ "median", "median", 0, AV_OPT_TYPE_CONST, {.i64=MEDIAN}, 0, 0, FLAGS, "mode" },
{ "bypass", "leave frames unchanged", OFFSET(bypass), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 76 of file vf_deflicker.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
}

Definition at line 450 of file vf_deflicker.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
{ NULL }
}

Definition at line 460 of file vf_deflicker.c.

◆ ff_vf_deflicker

AVFilter ff_vf_deflicker
Initial value:
= {
.name = "deflicker",
.description = NULL_IF_CONFIG_SMALL("Remove temporal frame luminance variations."),
.priv_size = sizeof(DeflickerContext),
.priv_class = &deflicker_class,
}

Definition at line 469 of file vf_deflicker.c.

GEOMETRIC_MEAN
@ GEOMETRIC_MEAN
Definition: vf_deflicker.c:38
OFFSET
#define OFFSET(x)
Definition: vf_deflicker.c:73
FLAGS
#define FLAGS
Definition: vf_deflicker.c:74
NB_SMOOTH_MODE
@ NB_SMOOTH_MODE
Definition: vf_deflicker.c:44
ARITHMETIC_MEAN
@ ARITHMETIC_MEAN
Definition: vf_deflicker.c:37
CUBIC_MEAN
@ CUBIC_MEAN
Definition: vf_deflicker.c:41
DeflickerContext
Definition: vf_deflicker.c:47
NULL
#define NULL
Definition: coverity.c:32
MEDIAN
@ MEDIAN
Definition: vf_deflicker.c:43
outputs
static const AVFilterPad outputs[]
Definition: vf_deflicker.c:460
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_deflicker.c:419
SIZE
#define SIZE
Definition: vf_deflicker.c:34
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
size
int size
Definition: twinvq_data.h:11134
inputs
static const AVFilterPad inputs[]
Definition: vf_deflicker.c:450
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_deflicker.c:442
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: vf_deflicker.c:360
QUADRATIC_MEAN
@ QUADRATIC_MEAN
Definition: vf_deflicker.c:40
POWER_MEAN
@ POWER_MEAN
Definition: vf_deflicker.c:42
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_deflicker.c:94
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_deflicker.c:321
HARMONIC_MEAN
@ HARMONIC_MEAN
Definition: vf_deflicker.c:39
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232