FFmpeg
Data Structures | Macros | Functions | Variables
vf_huesaturation.c File Reference
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  HueSaturationContext
 

Macros

#define R   0
 
#define G   1
 
#define B   2
 
#define REDS   0
 
#define YELLOWS   1
 
#define GREENS   2
 
#define CYANS   3
 
#define BLUES   4
 
#define MAGENTAS   5
 
#define RED   (1 << REDS)
 
#define YELLOW   (1 << YELLOWS)
 
#define GREEN   (1 << GREENS)
 
#define CYAN   (1 << CYANS)
 
#define BLUE   (1 << BLUES)
 
#define MAGENTA   (1 << MAGENTAS)
 
#define ALL   0x3F
 
#define DENOM   0x10000
 
#define FAST_DIV255(x)   ((((x) + 128) * 257) >> 16)
 
#define HUESATURATION(name, type, clip, xall)
 
#define OFFSET(x)   offsetof(HueSaturationContext, x)
 
#define VF   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

static void get_triplet (int64_t m[4][4], int *r, int *g, int *b)
 
static int lerpi8 (int v0, int v1, int f, int max)
 
static int lerpi16 (int v0, int v1, int f, int max)
 
static void identity_matrix (float matrix[4][4])
 
static void matrix_multiply (float a[4][4], float b[4][4], float c[4][4])
 
static void colorscale_matrix (float matrix[4][4], float r, float g, float b)
 
static void saturation_matrix (float matrix[4][4], float saturation, float rlw, float glw, float blw)
 
static void matrix2imatrix (float matrix[4][4], int64_t imatrix[4][4])
 
static void x_rotate_matrix (float matrix[4][4], float rs, float rc)
 
static void y_rotate_matrix (float matrix[4][4], float rs, float rc)
 
static void z_rotate_matrix (float matrix[4][4], float rs, float rc)
 
static void z_shear_matrix (float matrix[4][4], float dx, float dy)
 
static void transform_point (float matrix[4][4], float x, float y, float z, float *tx, float *ty, float *tz)
 
static void hue_rotate_matrix (float matrix[4][4], float rotation, float rlw, float glw, float blw)
 
static void shue_rotate_matrix (float m[4][4], float rotation)
 
static void init_matrix (HueSaturationContext *s)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static av_cold int config_input (AVFilterLink *inlink)
 
 AVFILTER_DEFINE_CLASS (huesaturation)
 

Variables

static enum AVPixelFormat pixel_fmts []
 
static const AVFilterPad huesaturation_inputs []
 
static const AVFilterPad huesaturation_outputs []
 
static const AVOption huesaturation_options []
 
const AVFilter ff_vf_huesaturation
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 27 of file vf_huesaturation.c.

◆ G

#define G   1

Definition at line 28 of file vf_huesaturation.c.

◆ B

#define B   2

Definition at line 29 of file vf_huesaturation.c.

◆ REDS

#define REDS   0

Definition at line 31 of file vf_huesaturation.c.

◆ YELLOWS

#define YELLOWS   1

Definition at line 32 of file vf_huesaturation.c.

◆ GREENS

#define GREENS   2

Definition at line 33 of file vf_huesaturation.c.

◆ CYANS

#define CYANS   3

Definition at line 34 of file vf_huesaturation.c.

◆ BLUES

#define BLUES   4

Definition at line 35 of file vf_huesaturation.c.

◆ MAGENTAS

#define MAGENTAS   5

Definition at line 36 of file vf_huesaturation.c.

◆ RED

#define RED   (1 << REDS)

Definition at line 38 of file vf_huesaturation.c.

◆ YELLOW

#define YELLOW   (1 << YELLOWS)

Definition at line 39 of file vf_huesaturation.c.

◆ GREEN

#define GREEN   (1 << GREENS)

Definition at line 40 of file vf_huesaturation.c.

◆ CYAN

#define CYAN   (1 << CYANS)

Definition at line 41 of file vf_huesaturation.c.

◆ BLUE

#define BLUE   (1 << BLUES)

Definition at line 42 of file vf_huesaturation.c.

◆ MAGENTA

#define MAGENTA   (1 << MAGENTAS)

Definition at line 43 of file vf_huesaturation.c.

◆ ALL

#define ALL   0x3F

Definition at line 44 of file vf_huesaturation.c.

◆ DENOM

#define DENOM   0x10000

Definition at line 71 of file vf_huesaturation.c.

◆ FAST_DIV255

#define FAST_DIV255 (   x)    ((((x) + 128) * 257) >> 16)

Definition at line 82 of file vf_huesaturation.c.

◆ HUESATURATION

#define HUESATURATION (   name,
  type,
  clip,
  xall 
)

Definition at line 94 of file vf_huesaturation.c.

◆ OFFSET

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

Definition at line 444 of file vf_huesaturation.c.

◆ VF

Definition at line 445 of file vf_huesaturation.c.

Function Documentation

◆ get_triplet()

static void get_triplet ( int64_t  m[4][4],
int r,
int g,
int b 
)
inlinestatic

Definition at line 73 of file vf_huesaturation.c.

◆ lerpi8()

static int lerpi8 ( int  v0,
int  v1,
int  f,
int  max 
)
inlinestatic

Definition at line 84 of file vf_huesaturation.c.

◆ lerpi16()

static int lerpi16 ( int  v0,
int  v1,
int  f,
int  max 
)
inlinestatic

Definition at line 89 of file vf_huesaturation.c.

◆ identity_matrix()

static void identity_matrix ( float  matrix[4][4])
static

Definition at line 179 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ matrix_multiply()

static void matrix_multiply ( float  a[4][4],
float  b[4][4],
float  c[4][4] 
)
static

◆ colorscale_matrix()

static void colorscale_matrix ( float  matrix[4][4],
float  r,
float  g,
float  b 
)
static

Definition at line 205 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ saturation_matrix()

static void saturation_matrix ( float  matrix[4][4],
float  saturation,
float  rlw,
float  glw,
float  blw 
)
static

Definition at line 217 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ matrix2imatrix()

static void matrix2imatrix ( float  matrix[4][4],
int64_t  imatrix[4][4] 
)
static

Definition at line 240 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ x_rotate_matrix()

static void x_rotate_matrix ( float  matrix[4][4],
float  rs,
float  rc 
)
static

Definition at line 247 of file vf_huesaturation.c.

Referenced by hue_rotate_matrix(), and shue_rotate_matrix().

◆ y_rotate_matrix()

static void y_rotate_matrix ( float  matrix[4][4],
float  rs,
float  rc 
)
static

Definition at line 259 of file vf_huesaturation.c.

Referenced by hue_rotate_matrix(), and shue_rotate_matrix().

◆ z_rotate_matrix()

static void z_rotate_matrix ( float  matrix[4][4],
float  rs,
float  rc 
)
static

Definition at line 271 of file vf_huesaturation.c.

Referenced by hue_rotate_matrix(), and shue_rotate_matrix().

◆ z_shear_matrix()

static void z_shear_matrix ( float  matrix[4][4],
float  dx,
float  dy 
)
static

Definition at line 283 of file vf_huesaturation.c.

Referenced by hue_rotate_matrix().

◆ transform_point()

static void transform_point ( float  matrix[4][4],
float  x,
float  y,
float  z,
float *  tx,
float *  ty,
float *  tz 
)
static

Definition at line 295 of file vf_huesaturation.c.

Referenced by hue_rotate_matrix().

◆ hue_rotate_matrix()

static void hue_rotate_matrix ( float  matrix[4][4],
float  rotation,
float  rlw,
float  glw,
float  blw 
)
static

Definition at line 305 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ shue_rotate_matrix()

static void shue_rotate_matrix ( float  m[4][4],
float  rotation 
)
static

Definition at line 339 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ init_matrix()

static void init_matrix ( HueSaturationContext s)
static

Definition at line 361 of file vf_huesaturation.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 381 of file vf_huesaturation.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 405 of file vf_huesaturation.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( huesaturation  )

Variable Documentation

◆ pixel_fmts

enum AVPixelFormat pixel_fmts[]
static

◆ huesaturation_inputs

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

Definition at line 427 of file vf_huesaturation.c.

◆ huesaturation_outputs

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

Definition at line 437 of file vf_huesaturation.c.

◆ huesaturation_options

const AVOption huesaturation_options[]
static
Initial value:
= {
{ "hue", "set the hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl=0},-180, 180, VF },
{ "saturation", "set the saturation shift", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
{ "intensity", "set the intensity shift", OFFSET(intensity), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
{ "colors", "set colors range", OFFSET(colors), AV_OPT_TYPE_FLAGS, {.i64=ALL}, 0,ALL,VF, "colors" },
{ "r", "set reds", 0, AV_OPT_TYPE_CONST, {.i64=RED}, 0, 0, VF, "colors" },
{ "y", "set yellows", 0, AV_OPT_TYPE_CONST, {.i64=YELLOW}, 0, 0, VF, "colors" },
{ "g", "set greens", 0, AV_OPT_TYPE_CONST, {.i64=GREEN}, 0, 0, VF, "colors" },
{ "c", "set cyans", 0, AV_OPT_TYPE_CONST, {.i64=CYAN}, 0, 0, VF, "colors" },
{ "b", "set blues", 0, AV_OPT_TYPE_CONST, {.i64=BLUE}, 0, 0, VF, "colors" },
{ "m", "set magentas", 0, AV_OPT_TYPE_CONST, {.i64=MAGENTA}, 0, 0, VF, "colors" },
{ "a", "set all colors", 0, AV_OPT_TYPE_CONST, {.i64=ALL}, 0, 0, VF, "colors" },
{ "strength", "set the filtering strength", OFFSET(strength), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0,100,VF },
{ "rw", "set the red weight", OFFSET(rlw), AV_OPT_TYPE_FLOAT, {.dbl=.333}, 0, 1, VF },
{ "gw", "set the green weight", OFFSET(glw), AV_OPT_TYPE_FLOAT, {.dbl=.334}, 0, 1, VF },
{ "bw", "set the blue weight", OFFSET(blw), AV_OPT_TYPE_FLOAT, {.dbl=.333}, 0, 1, VF },
{ "lightness", "set the preserve lightness", OFFSET(lightness), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, VF },
{ NULL }
}

Definition at line 447 of file vf_huesaturation.c.

◆ ff_vf_huesaturation

const AVFilter ff_vf_huesaturation
Initial value:
= {
.name = "huesaturation",
.description = NULL_IF_CONFIG_SMALL("Apply hue-saturation-intensity adjustments."),
.priv_size = sizeof(HueSaturationContext),
.priv_class = &huesaturation_class,
.process_command = ff_filter_process_command,
}

Definition at line 469 of file vf_huesaturation.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:171
OFFSET
#define OFFSET(x)
Definition: vf_huesaturation.c:444
VF
#define VF
Definition: vf_huesaturation.c:445
YELLOW
#define YELLOW
Definition: vf_huesaturation.c:39
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
HueSaturationContext
Definition: vf_huesaturation.c:46
MAGENTA
#define MAGENTA
Definition: vf_huesaturation.c:43
BLUE
#define BLUE
Definition: vf_huesaturation.c:42
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_huesaturation.c:381
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:394
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:395
NULL
#define NULL
Definition: coverity.c:32
ALL
#define ALL
Definition: vf_huesaturation.c:44
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:230
CYAN
#define CYAN
Definition: vf_huesaturation.c:41
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
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_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:390
huesaturation_inputs
static const AVFilterPad huesaturation_inputs[]
Definition: vf_huesaturation.c:427
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:228
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:146
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:399
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:229
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
RED
#define RED
Definition: vf_huesaturation.c:38
GREEN
#define GREEN
Definition: vf_huesaturation.c:40
huesaturation_outputs
static const AVFilterPad huesaturation_outputs[]
Definition: vf_huesaturation.c:437
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_huesaturation.c:394
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_huesaturation.c:405
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:223
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:227
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: internal.h:69