FFmpeg  4.0
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 120 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 139 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy8()

static float calc_avgy8 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 162 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy16()

static float calc_avgy16 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 185 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 208 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 223 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 238 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 253 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 269 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 285 of file vf_deflicker.c.

Referenced by config_input().

◆ comparef()

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

Definition at line 301 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 307 of file vf_deflicker.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 317 of file vf_deflicker.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 356 of file vf_deflicker.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 415 of file vf_deflicker.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 435 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 }
}
#define NULL
Definition: coverity.c:32
int size
#define OFFSET(x)
Definition: vf_deflicker.c:73
#define FLAGS
Definition: vf_deflicker.c:74
#define SIZE
Definition: vf_deflicker.c:34
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83

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 }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: vf_deflicker.c:356
static int config_input(AVFilterLink *inlink)
Definition: vf_deflicker.c:317

Definition at line 443 of file vf_deflicker.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *outlink)
Definition: vf_deflicker.c:415

Definition at line 453 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,
}
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_deflicker.c:435
static const AVFilterPad outputs[]
Definition: vf_deflicker.c:453
static int query_formats(AVFilterContext *ctx)
Definition: vf_deflicker.c:94
static const AVFilterPad inputs[]
Definition: vf_deflicker.c:443

Definition at line 462 of file vf_deflicker.c.