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 "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 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 enum AVPixelFormat pixel_fmts []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const 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 33 of file vf_deflicker.c.

◆ OFFSET

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

Definition at line 72 of file vf_deflicker.c.

◆ FLAGS

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

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( deflicker  )

◆ 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 116 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 135 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy8()

static float calc_avgy8 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 158 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy16()

static float calc_avgy16 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 181 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 204 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 219 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 234 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 249 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 265 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 281 of file vf_deflicker.c.

Referenced by config_input().

◆ comparef()

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

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

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 313 of file vf_deflicker.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 352 of file vf_deflicker.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 411 of file vf_deflicker.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 434 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, .unit = "mode" },
{ "m", "set how to smooth luminance", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_SMOOTH_MODE-1, FLAGS, .unit = "mode" },
{ "am", "arithmetic mean", 0, AV_OPT_TYPE_CONST, {.i64=ARITHMETIC_MEAN}, 0, 0, FLAGS, .unit = "mode" },
{ "gm", "geometric mean", 0, AV_OPT_TYPE_CONST, {.i64=GEOMETRIC_MEAN}, 0, 0, FLAGS, .unit = "mode" },
{ "hm", "harmonic mean", 0, AV_OPT_TYPE_CONST, {.i64=HARMONIC_MEAN}, 0, 0, FLAGS, .unit = "mode" },
{ "qm", "quadratic mean", 0, AV_OPT_TYPE_CONST, {.i64=QUADRATIC_MEAN}, 0, 0, FLAGS, .unit = "mode" },
{ "cm", "cubic mean", 0, AV_OPT_TYPE_CONST, {.i64=CUBIC_MEAN}, 0, 0, FLAGS, .unit = "mode" },
{ "pm", "power mean", 0, AV_OPT_TYPE_CONST, {.i64=POWER_MEAN}, 0, 0, FLAGS, .unit = "mode" },
{ "median", "median", 0, AV_OPT_TYPE_CONST, {.i64=MEDIAN}, 0, 0, FLAGS, .unit = "mode" },
{ "bypass", "leave frames unchanged", OFFSET(bypass), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ NULL }
}

Definition at line 75 of file vf_deflicker.c.

◆ pixel_fmts

enum AVPixelFormat pixel_fmts[]
static

◆ inputs

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

Definition at line 442 of file vf_deflicker.c.

◆ outputs

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

Definition at line 451 of file vf_deflicker.c.

◆ ff_vf_deflicker

const 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 459 of file vf_deflicker.c.

GEOMETRIC_MEAN
@ GEOMETRIC_MEAN
Definition: vf_deflicker.c:37
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:522
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:514
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:521
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:516
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:517
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:458
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:513
OFFSET
#define OFFSET(x)
Definition: vf_deflicker.c:72
FLAGS
#define FLAGS
Definition: vf_deflicker.c:73
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:523
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:476
NB_SMOOTH_MODE
@ NB_SMOOTH_MODE
Definition: vf_deflicker.c:43
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:462
ARITHMETIC_MEAN
@ ARITHMETIC_MEAN
Definition: vf_deflicker.c:36
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:481
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:490
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:491
CUBIC_MEAN
@ CUBIC_MEAN
Definition: vf_deflicker.c:40
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:520
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:475
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:489
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:461
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:459
DeflickerContext
Definition: vf_deflicker.c:46
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:480
MEDIAN
@ MEDIAN
Definition: vf_deflicker.c:42
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
outputs
static const AVFilterPad outputs[]
Definition: vf_deflicker.c:451
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_deflicker.c:411
SIZE
#define SIZE
Definition: vf_deflicker.c:33
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:106
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:483
size
int size
Definition: twinvq_data.h:10344
inputs
static const AVFilterPad inputs[]
Definition: vf_deflicker.c:442
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:485
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_deflicker.c:434
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:518
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: vf_deflicker.c:352
QUADRATIC_MEAN
@ QUADRATIC_MEAN
Definition: vf_deflicker.c:39
POWER_MEAN
@ POWER_MEAN
Definition: vf_deflicker.c:41
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:477
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_deflicker.c:93
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:515
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:482
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:487
mode
mode
Definition: ebur128.h:83
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:519
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_deflicker.c:313
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:484
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:488
HARMONIC_MEAN
@ HARMONIC_MEAN
Definition: vf_deflicker.c:38
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:460
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:486