vf_lut.c File Reference

Compute a look-up table for binding the input value to the output value, and apply it to input video. More...

#include "libavutil/eval.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  LutContext

Macros

#define Y   0
#define U   1
#define V   2
#define R   0
#define G   1
#define B   2
#define A   3
#define OFFSET(x)   offsetof(LutContext, x)
#define YUV_FORMATS
#define RGB_FORMATS
#define DEFINE_LUT_FILTER(name_, description_, init_)

Enumerations

enum  var_name {
  VAR_W, VAR_H, VAR_CW, VAR_CH,
  VAR_HSUB, VAR_VSUB, VARS_NB, VAR_E,
  VAR_PHI, VAR_PI, VAR_IN_W, VAR_IW,
  VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW,
  VAR_OUT_H, VAR_OH, VAR_X, VAR_Y,
  VAR_N, VAR_POS, VAR_T, VAR_VARS_NB,
  VAR_E, VAR_PHI, VAR_PI, VAR_MAIN_W,
  VAR_MW, VAR_MAIN_H, VAR_MH, VAR_TEXT_W,
  VAR_TW, VAR_TEXT_H, VAR_TH, VAR_X,
  VAR_Y, VAR_N, VAR_T, VAR_VARS_NB,
  VAR_E, VAR_PHI, VAR_PI, VAR_W,
  VAR_H, VAR_VAL, VAR_MAXVAL, VAR_MINVAL,
  VAR_NEGVAL, VAR_CLIPVAL, VAR_VARS_NB, VAR_E,
  VAR_PHI, VAR_PI, VAR_MAIN_W, VAR_MW,
  VAR_MAIN_H, VAR_MH, VAR_OVERLAY_W, VAR_OW,
  VAR_OVERLAY_H, VAR_OH, VAR_VARS_NB, VAR_PI,
  VAR_PHI, VAR_E, VAR_IN_W, VAR_IW,
  VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW,
  VAR_OUT_H, VAR_OH, VAR_X, VAR_Y,
  VAR_A, VAR_HSUB, VAR_VSUB, VARS_NB,
  VAR_PI, VAR_PHI, VAR_E, VAR_IN_W,
  VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W,
  VAR_OW, VAR_OUT_H, VAR_OH, VAR_A,
  VAR_DAR, VAR_SAR, VAR_HSUB, VAR_VSUB,
  VARS_NB, VAR_E, VAR_PHI, VAR_PI,
  VAR_TB, VAR_PTS, VAR_START_PTS, VAR_PREV_PTS,
  VAR_PREV_SELECTED_PTS, VAR_T, VAR_START_T, VAR_PREV_T,
  VAR_PREV_SELECTED_T, VAR_PICT_TYPE, VAR_PICT_TYPE_I, VAR_PICT_TYPE_P,
  VAR_PICT_TYPE_B, VAR_PICT_TYPE_S, VAR_PICT_TYPE_SI, VAR_PICT_TYPE_SP,
  VAR_PICT_TYPE_BI, VAR_INTERLACE_TYPE, VAR_INTERLACE_TYPE_P, VAR_INTERLACE_TYPE_T,
  VAR_INTERLACE_TYPE_B, VAR_N, VAR_SELECTED_N, VAR_PREV_SELECTED_N,
  VAR_KEY, VAR_POS, VAR_VARS_NB, VAR_E,
  VAR_INTERLACED, VAR_N, VAR_PHI, VAR_PI,
  VAR_POS, VAR_PREV_INPTS, VAR_PREV_OUTPTS, VAR_PTS,
  VAR_STARTPTS, VAR_TB, VAR_VARS_NB, VAR_E,
  VAR_PHI, VAR_PI, VAR_AVTB, VAR_INTB,
  VAR_VARS_NB, VAR_E, VAR_PHI, VAR_PI,
  VAR_AVTB, VAR_VARS_NB
}

Functions

static const char * lut_get_name (void *ctx)
static int init (AVFilterContext *ctx, const char *args, void *opaque)
static av_cold void uninit (AVFilterContext *ctx)
static int query_formats (AVFilterContext *ctx)
static double clip (void *opaque, double val)
 Clip value val in the minval - maxval range.
static double compute_gammaval (void *opaque, double gamma)
 Compute gamma correction for value val, assuming the minval-maxval range, val is clipped to a value contained in the same interval.
static int config_props (AVFilterLink *inlink)
static void draw_slice (AVFilterLink *inlink, int y, int h, int slice_dir)

Variables

static const char * var_names []
static const AVOption lut_options []
static const AVClass lut_class
static enum PixelFormat yuv_pix_fmts [] = { YUV_FORMATS, PIX_FMT_NONE }
static enum PixelFormat rgb_pix_fmts [] = { RGB_FORMATS, PIX_FMT_NONE }
static enum PixelFormat all_pix_fmts [] = { RGB_FORMATS, YUV_FORMATS, PIX_FMT_NONE }
static double(*const funcs1 [])(void *, double)
static const char *const funcs1_names []

Detailed Description

Compute a look-up table for binding the input value to the output value, and apply it to input video.

Definition in file vf_lut.c.

Macro Definition Documentation

#define A   3

Definition at line 81 of file vf_lut.c.

#define B   2

Definition at line 80 of file vf_lut.c.

Referenced by config_props().

#define DEFINE_LUT_FILTER (   name_,
  description_,
  init_ 
)
Value:
AVFilter avfilter_vf_##name_ = { \
.name = #name_, \
.description = NULL_IF_CONFIG_SMALL(description_), \
.priv_size = sizeof(LutContext), \
\
.init = init_, \
.uninit = uninit, \
\
.inputs = (AVFilterPad[]) {{ .name = "default", \
.type = AVMEDIA_TYPE_VIDEO, \
.draw_slice = draw_slice, \
.config_props = config_props, \
.min_perms = AV_PERM_READ, }, \
{ .name = NULL}}, \
.outputs = (AVFilterPad[]) {{ .name = "default", \
.type = AVMEDIA_TYPE_VIDEO, }, \
{ .name = NULL}}, \
}

Definition at line 343 of file vf_lut.c.

#define G   1

Definition at line 79 of file vf_lut.c.

Referenced by config_props().

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

Definition at line 83 of file vf_lut.c.

#define R   0

Definition at line 78 of file vf_lut.c.

Referenced by config_props().

#define RGB_FORMATS
Value:
PIX_FMT_ABGR, PIX_FMT_BGRA, \
PIX_FMT_RGB24, PIX_FMT_BGR24

Definition at line 150 of file vf_lut.c.

#define U   1

Definition at line 76 of file vf_lut.c.

#define V   2

Definition at line 77 of file vf_lut.c.

#define Y   0

Definition at line 75 of file vf_lut.c.

#define YUV_FORMATS
Value:
PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_YUV440P, \
PIX_FMT_YUVA420P, \
PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P, \
PIX_FMT_YUVJ440P

Definition at line 143 of file vf_lut.c.

Enumeration Type Documentation

enum var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PE 
VAR_PICT_TYPE_I 
VAR_PICT_TYPE_P 
VAR_PICT_TYPE_B 
VAR_PICT_TYPE_S 
VAR_PICT_TYPE_SI 
VAR_PICT_TYPE_SP 
VAR_PICT_TYPE_BI 
VAR_INTERLACE_TYPE 
VAR_INTERLACE_TYPE_P 
VAR_INTERLACE_TYPE_T 
VAR_INTERLACE_TYPE_B 
VAR_N 
VAR_SELECTED_N 
VAR_PREV_SELECTED_N 
VAR_KEY 
VAR_POS 
VAR_VARS_NB 
VAR_E 
VAR_INTERLACED 
VAR_N 
VAR_PHI 
VAR_PI 
VAR_POS 
VAR_PREV_INPTS 
VAR_PREV_OUTPTS 
VAR_PTS 
VAR_STARTPTS 
VAR_TB 
VAR_VARS_NB 
VAR_E 
VAR_PHI 
VAR_PI 
VAR_AVTB 
VAR_INTB 
VAR_VARS_NB 
VAR_E 
VAR_PHI 
VAR_PI 
VAR_AVTB 
VAR_VARS_NB 

Definition at line 48 of file vf_lut.c.

Function Documentation

static double clip ( void opaque,
double  val 
)
static

Clip value val in the minval - maxval range.

Definition at line 173 of file vf_lut.c.

Referenced by rv40_loop_filter(), and vc1_filter_line().

static double compute_gammaval ( void opaque,
double  gamma 
)
static

Compute gamma correction for value val, assuming the minval-maxval range, val is clipped to a value contained in the same interval.

Definition at line 186 of file vf_lut.c.

static int config_props ( AVFilterLink inlink)
static

Definition at line 208 of file vf_lut.c.

static void draw_slice ( AVFilterLink inlink,
int  y,
int  h,
int  slice_dir 
)
static

Definition at line 295 of file vf_lut.c.

static int init ( AVFilterContext ctx,
const char *  args,
void opaque 
)
static

Definition at line 111 of file vf_lut.c.

static const char* lut_get_name ( void ctx)
static

Definition at line 100 of file vf_lut.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 159 of file vf_lut.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 131 of file vf_lut.c.

Variable Documentation

enum PixelFormat all_pix_fmts[] = { RGB_FORMATS, YUV_FORMATS, PIX_FMT_NONE }
static

Definition at line 157 of file vf_lut.c.

Referenced by query_formats().

double(* const funcs1[])(void *, double)
static
Initial value:

Definition at line 196 of file vf_lut.c.

Referenced by av_expr_parse(), av_expr_parse_and_eval(), and config_props().

const char* const funcs1_names[]
static
Initial value:
{
"clip",
"gammaval",
}

Definition at line 202 of file vf_lut.c.

Referenced by config_props().

const AVClass lut_class
static
Initial value:
{
"LutContext",
}

Definition at line 105 of file vf_lut.c.

Referenced by init().

const AVOption lut_options[]
static
Initial value:
{
{"c0", "set component #0 expression", OFFSET(comp_expr_str[0]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"c1", "set component #1 expression", OFFSET(comp_expr_str[1]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"c2", "set component #2 expression", OFFSET(comp_expr_str[2]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"c3", "set component #3 expression", OFFSET(comp_expr_str[3]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"y", "set Y expression", OFFSET(comp_expr_str[Y]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"u", "set U expression", OFFSET(comp_expr_str[U]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"v", "set V expression", OFFSET(comp_expr_str[V]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"r", "set R expression", OFFSET(comp_expr_str[R]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"g", "set G expression", OFFSET(comp_expr_str[G]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"b", "set B expression", OFFSET(comp_expr_str[B]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{"a", "set A expression", OFFSET(comp_expr_str[A]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{NULL},
}

Definition at line 85 of file vf_lut.c.

enum PixelFormat rgb_pix_fmts[] = { RGB_FORMATS, PIX_FMT_NONE }
static

Definition at line 156 of file vf_lut.c.

Referenced by config_props(), and query_formats().

const char* var_names[]
static
Initial value:
{
"E",
"PHI",
"PI",
"w",
"h",
"val",
"maxval",
"minval",
"negval",
"clipval",
}

Definition at line 34 of file vf_lut.c.

Referenced by config_props().

enum PixelFormat yuv_pix_fmts[] = { YUV_FORMATS, PIX_FMT_NONE }
static

Definition at line 155 of file vf_lut.c.

Referenced by config_props(), and query_formats().