FFmpeg  4.0
Macros | Functions | Variables
vf_eq.c File Reference

very simple video equalizer More...

#include "libavfilter/internal.h"
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "vf_eq.h"

Go to the source code of this file.

Macros

#define TS2T(ts, tb)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
 
#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
 

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 process_c (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 void uninit (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *inlink)
 
static int query_formats (AVFilterContext *ctx)
 
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 const AVFilterPad eq_inputs []
 
static const AVFilterPad eq_outputs []
 
static const AVOption eq_options []
 
AVFilter ff_vf_eq
 

Detailed Description

very simple video equalizer

Definition in file vf_eq.c.

Macro Definition Documentation

◆ TS2T

#define TS2T (   ts,
  tb 
)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))

Definition at line 249 of file vf_eq.c.

Referenced by filter_frame().

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

Referenced by process_command().

◆ OFFSET

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

Definition at line 351 of file vf_eq.c.

◆ FLAGS

Definition at line 352 of file vf_eq.c.

Function Documentation

◆ create_lut()

static void create_lut ( EQParameters param)
static

Definition at line 37 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 62 of file vf_eq.c.

Referenced by check_values().

◆ process_c()

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

Definition at line 77 of file vf_eq.c.

Referenced by initialize().

◆ check_values()

static void check_values ( EQParameters param,
EQContext eq 
)
static

Definition at line 97 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 107 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_brightness()

static void set_brightness ( EQContext eq)
static

Definition at line 115 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_gamma()

static void set_gamma ( EQContext eq)
static

Definition at line 123 of file vf_eq.c.

Referenced by filter_frame(), and initialize().

◆ set_saturation()

static void set_saturation ( EQContext eq)
static

Definition at line 144 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 157 of file vf_eq.c.

Referenced by initialize(), and set_param().

◆ initialize()

static int initialize ( AVFilterContext ctx)
static

Definition at line 177 of file vf_eq.c.

◆ uninit()

static void uninit ( AVFilterContext ctx)
static

Definition at line 207 of file vf_eq.c.

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 221 of file vf_eq.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 232 of file vf_eq.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 251 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 302 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 314 of file vf_eq.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( eq  )

Variable Documentation

◆ eq_inputs

const AVFilterPad eq_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_props,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_props(AVFilterLink *inlink)
Definition: vf_eq.c:221
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_eq.c:251

Definition at line 333 of file vf_eq.c.

◆ eq_outputs

const AVFilterPad eq_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 343 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"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "brightness", "set the brightness adjustment",
OFFSET(brightness_expr), AV_OPT_TYPE_STRING, {.str = "0.0"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "saturation", "set the saturation adjustment",
OFFSET(saturation_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "gamma", "set the initial gamma value",
OFFSET(gamma_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "gamma_r", "gamma value for red",
OFFSET(gamma_r_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "gamma_g", "gamma value for green",
OFFSET(gamma_g_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "gamma_b", "gamma value for blue",
OFFSET(gamma_b_expr), AV_OPT_TYPE_STRING, {.str = "1.0"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "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"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "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 }
}
#define NULL
Definition: coverity.c:32
#define FLAGS
Definition: vf_eq.c:352
#define OFFSET(x)
Definition: vf_eq.c:351

Definition at line 354 of file vf_eq.c.

◆ ff_vf_eq

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,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static void uninit(AVFilterContext *ctx)
Definition: vf_eq.c:207
#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:125
static int flags
Definition: log.c:55
static const AVFilterPad eq_outputs[]
Definition: vf_eq.c:343
static int query_formats(AVFilterContext *ctx)
Definition: vf_eq.c:232
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static int initialize(AVFilterContext *ctx)
Definition: vf_eq.c:177
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_eq.c:314
static const AVFilterPad eq_inputs[]
Definition: vf_eq.c:333

Definition at line 379 of file vf_eq.c.