FFmpeg
Macros | Functions | Variables
vf_eq.c File Reference
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "internal.h"
#include "vf_eq.h"
#include "video.h"

Go to the source code of this file.

Macros

#define SET_PARAM(param_name, set_fn_name)   if (!strcmp(cmd, #param_name)) return set_param(&eq->param_name##_pexpr, args, cmd, set_##set_fn_name, ctx);
 
#define OFFSET(x)   offsetof(EQContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define TFLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

static void create_lut (EQParameters *param)
 
static void apply_lut (EQParameters *param, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
 
static void check_values (EQParameters *param, EQContext *eq)
 
static void set_contrast (EQContext *eq)
 
static void set_brightness (EQContext *eq)
 
static void set_gamma (EQContext *eq)
 
static void set_saturation (EQContext *eq)
 
static int set_expr (AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
 
static int initialize (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int set_param (AVExpr **pexpr, const char *args, const char *cmd, void(*set_fn)(EQContext *eq), AVFilterContext *ctx)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
 AVFILTER_DEFINE_CLASS (eq)
 

Variables

static enum AVPixelFormat pixel_fmts_eq []
 
static const AVFilterPad eq_inputs []
 
static const AVOption eq_options []
 
const AVFilter ff_vf_eq
 

Detailed Description

very simple video equalizer

Definition in file vf_eq.c.

Macro Definition Documentation

◆ SET_PARAM

#define SET_PARAM (   param_name,
  set_fn_name 
)    if (!strcmp(cmd, #param_name)) return set_param(&eq->param_name##_pexpr, args, cmd, set_##set_fn_name, ctx);

◆ OFFSET

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

Definition at line 317 of file vf_eq.c.

◆ FLAGS

Definition at line 318 of file vf_eq.c.

◆ TFLAGS

Definition at line 319 of file vf_eq.c.

Function Documentation

◆ create_lut()

static void create_lut ( EQParameters param)
static

Definition at line 38 of file vf_eq.c.

Referenced by apply_lut().

◆ apply_lut()

static void apply_lut ( EQParameters param,
uint8_t *  dst,
int  dst_stride,
const uint8_t *  src,
int  src_stride,
int  w,
int  h 
)
static

Definition at line 63 of file vf_eq.c.

Referenced by check_values().

◆ check_values()

static void check_values ( EQParameters param,
EQContext eq 
)
static

Definition at line 78 of file vf_eq.c.

Referenced by set_brightness(), set_contrast(), set_gamma(), and set_saturation().

◆ set_contrast()

static void set_contrast ( EQContext eq)
static

Definition at line 88 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_brightness()

static void set_brightness ( EQContext eq)
static

Definition at line 96 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_gamma()

static void set_gamma ( EQContext eq)
static

Definition at line 104 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_saturation()

static void set_saturation ( EQContext eq)
static

Definition at line 125 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_expr()

static int set_expr ( AVExpr **  pexpr,
const char *  expr,
const char *  option,
void *  log_ctx 
)
static

Definition at line 138 of file vf_eq.c.

Referenced by initialize(), and set_param().

◆ initialize()

static int initialize ( AVFilterContext ctx)
static

Definition at line 158 of file vf_eq.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 184 of file vf_eq.c.

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 198 of file vf_eq.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 219 of file vf_eq.c.

◆ set_param()

static int set_param ( AVExpr **  pexpr,
const char *  args,
const char *  cmd,
void(*)(EQContext *eq set_fn,
AVFilterContext ctx 
)
inlinestatic

Definition at line 277 of file vf_eq.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 289 of file vf_eq.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( eq  )

Variable Documentation

◆ pixel_fmts_eq

enum AVPixelFormat pixel_fmts_eq[]
static

◆ eq_inputs

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

Definition at line 308 of file vf_eq.c.

◆ eq_options

const AVOption eq_options[]
static
Initial value:
= {
{ "contrast", "set the contrast adjustment, negative values give a negative image",
OFFSET(contrast_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "brightness", "set the brightness adjustment",
OFFSET(brightness_expr), AV_OPT_TYPE_STRING, {.str = "0.0"}, 0, 0, TFLAGS },
{ "saturation", "set the saturation adjustment",
OFFSET(saturation_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "gamma", "set the initial gamma value",
OFFSET(gamma_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "gamma_r", "gamma value for red",
OFFSET(gamma_r_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "gamma_g", "gamma value for green",
OFFSET(gamma_g_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "gamma_b", "gamma value for blue",
OFFSET(gamma_b_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "gamma_weight", "set the gamma weight which reduces the effect of gamma on bright areas",
OFFSET(gamma_weight_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, 0, 0, TFLAGS },
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
{ "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
{ "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
{ NULL }
}

Definition at line 320 of file vf_eq.c.

◆ ff_vf_eq

const AVFilter ff_vf_eq
Initial value:
= {
.name = "eq",
.description = NULL_IF_CONFIG_SMALL("Adjust brightness, contrast, gamma, and saturation."),
.priv_size = sizeof(EQContext),
.priv_class = &eq_class,
.process_command = process_command,
.init = initialize,
.uninit = uninit,
}

Definition at line 345 of file vf_eq.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:172
initialize
static int initialize(AVFilterContext *ctx)
Definition: vf_eq.c:158
eq_inputs
static const AVFilterPad eq_inputs[]
Definition: vf_eq.c:308
OFFSET
#define OFFSET(x)
Definition: vf_eq.c:317
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_eq.c:198
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:36
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
FLAGS
#define FLAGS
Definition: vf_eq.c:318
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
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_eq.c:289
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
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
EQContext
Definition: vf_eq.h:62
pixel_fmts_eq
static enum AVPixelFormat pixel_fmts_eq[]
Definition: vf_eq.c:209
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
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:147
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_eq.c:219
TFLAGS
#define TFLAGS
Definition: vf_eq.c:319
EVAL_MODE_NB
@ EVAL_MODE_NB
Definition: af_volume.h:42
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_eq.c:184
EVAL_MODE_FRAME
@ EVAL_MODE_FRAME
Definition: af_volume.h:41
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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
EVAL_MODE_INIT
@ EVAL_MODE_INIT
Definition: vf_fftfilt.c:41
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
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
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_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
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