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 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 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  )

◆ 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 117 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 136 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy8()

static float calc_avgy8 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 159 of file vf_deflicker.c.

Referenced by config_input().

◆ calc_avgy16()

static float calc_avgy16 ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 182 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 205 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 220 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 235 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 250 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 266 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 282 of file vf_deflicker.c.

Referenced by config_input().

◆ comparef()

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

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

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 314 of file vf_deflicker.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 353 of file vf_deflicker.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 412 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 }
}

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

◆ outputs

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

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

GEOMETRIC_MEAN
@ GEOMETRIC_MEAN
Definition: vf_deflicker.c:38
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:434
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:426
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:433
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:428
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:391
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:429
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:371
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:425
OFFSET
#define OFFSET(x)
Definition: vf_deflicker.c:73
FLAGS
#define FLAGS
Definition: vf_deflicker.c:74
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:435
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:389
NB_SMOOTH_MODE
@ NB_SMOOTH_MODE
Definition: vf_deflicker.c:44
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:375
ARITHMETIC_MEAN
@ ARITHMETIC_MEAN
Definition: vf_deflicker.c:37
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:394
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:248
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:403
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:79
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:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:404
CUBIC_MEAN
@ CUBIC_MEAN
Definition: vf_deflicker.c:41
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:432
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:388
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:402
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:374
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:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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:80
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:372
DeflickerContext
Definition: vf_deflicker.c:47
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:78
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:393
MEDIAN
@ MEDIAN
Definition: vf_deflicker.c:43
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:392
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
outputs
static const AVFilterPad outputs[]
Definition: vf_deflicker.c:452
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_deflicker.c:412
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:117
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:396
size
int size
Definition: twinvq_data.h:10344
inputs
static const AVFilterPad inputs[]
Definition: vf_deflicker.c:443
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:398
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_deflicker.c:435
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:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:430
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: vf_deflicker.c:353
QUADRATIC_MEAN
@ QUADRATIC_MEAN
Definition: vf_deflicker.c:40
POWER_MEAN
@ POWER_MEAN
Definition: vf_deflicker.c:42
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:100
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:390
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_deflicker.c:94
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:427
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:395
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:400
mode
mode
Definition: ebur128.h:83
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:431
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
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:71
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:70
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
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:73
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_deflicker.c:314
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:72
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:397
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:401
HARMONIC_MEAN
@ HARMONIC_MEAN
Definition: vf_deflicker.c:39
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:373
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
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:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:399