FFmpeg
Data Structures | Macros | Functions | Variables
vf_huesaturation.c File Reference
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "filters.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 AVOption huesaturation_options []
 
const AVFilter ff_vf_huesaturation
 

Macro Definition Documentation

◆ R

#define R   0

Definition at line 26 of file vf_huesaturation.c.

◆ G

#define G   1

Definition at line 27 of file vf_huesaturation.c.

◆ B

#define B   2

Definition at line 28 of file vf_huesaturation.c.

◆ REDS

#define REDS   0

Definition at line 30 of file vf_huesaturation.c.

◆ YELLOWS

#define YELLOWS   1

Definition at line 31 of file vf_huesaturation.c.

◆ GREENS

#define GREENS   2

Definition at line 32 of file vf_huesaturation.c.

◆ CYANS

#define CYANS   3

Definition at line 33 of file vf_huesaturation.c.

◆ BLUES

#define BLUES   4

Definition at line 34 of file vf_huesaturation.c.

◆ MAGENTAS

#define MAGENTAS   5

Definition at line 35 of file vf_huesaturation.c.

◆ RED

#define RED   (1 << REDS)

Definition at line 37 of file vf_huesaturation.c.

◆ YELLOW

#define YELLOW   (1 << YELLOWS)

Definition at line 38 of file vf_huesaturation.c.

◆ GREEN

#define GREEN   (1 << GREENS)

Definition at line 39 of file vf_huesaturation.c.

◆ CYAN

#define CYAN   (1 << CYANS)

Definition at line 40 of file vf_huesaturation.c.

◆ BLUE

#define BLUE   (1 << BLUES)

Definition at line 41 of file vf_huesaturation.c.

◆ MAGENTA

#define MAGENTA   (1 << MAGENTAS)

Definition at line 42 of file vf_huesaturation.c.

◆ ALL

#define ALL   0x3F

Definition at line 43 of file vf_huesaturation.c.

◆ DENOM

#define DENOM   0x10000

Definition at line 70 of file vf_huesaturation.c.

◆ FAST_DIV255

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

Definition at line 81 of file vf_huesaturation.c.

◆ HUESATURATION

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

Definition at line 93 of file vf_huesaturation.c.

◆ OFFSET

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

Definition at line 436 of file vf_huesaturation.c.

◆ VF

Definition at line 437 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 72 of file vf_huesaturation.c.

◆ lerpi8()

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

Definition at line 83 of file vf_huesaturation.c.

◆ lerpi16()

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

Definition at line 88 of file vf_huesaturation.c.

◆ identity_matrix()

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

Definition at line 178 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 204 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 216 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 239 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 246 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 258 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 270 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 282 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 294 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 304 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 338 of file vf_huesaturation.c.

Referenced by init_matrix().

◆ init_matrix()

static void init_matrix ( HueSaturationContext s)
static

Definition at line 360 of file vf_huesaturation.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 380 of file vf_huesaturation.c.

◆ config_input()

static av_cold int config_input ( AVFilterLink inlink)
static

Definition at line 404 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 426 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, .unit = "colors" },
{ "r", "set reds", 0, AV_OPT_TYPE_CONST, {.i64=RED}, 0, 0, VF, .unit = "colors" },
{ "y", "set yellows", 0, AV_OPT_TYPE_CONST, {.i64=YELLOW}, 0, 0, VF, .unit = "colors" },
{ "g", "set greens", 0, AV_OPT_TYPE_CONST, {.i64=GREEN}, 0, 0, VF, .unit = "colors" },
{ "c", "set cyans", 0, AV_OPT_TYPE_CONST, {.i64=CYAN}, 0, 0, VF, .unit = "colors" },
{ "b", "set blues", 0, AV_OPT_TYPE_CONST, {.i64=BLUE}, 0, 0, VF, .unit = "colors" },
{ "m", "set magentas", 0, AV_OPT_TYPE_CONST, {.i64=MAGENTA}, 0, 0, VF, .unit = "colors" },
{ "a", "set all colors", 0, AV_OPT_TYPE_CONST, {.i64=ALL}, 0, 0, VF, .unit = "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 439 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 461 of file vf_huesaturation.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
OFFSET
#define OFFSET(x)
Definition: vf_huesaturation.c:436
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
VF
#define VF
Definition: vf_huesaturation.c:437
YELLOW
#define YELLOW
Definition: vf_huesaturation.c:38
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
HueSaturationContext
Definition: vf_huesaturation.c:45
MAGENTA
#define MAGENTA
Definition: vf_huesaturation.c:42
BLUE
#define BLUE
Definition: vf_huesaturation.c:41
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:37
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_huesaturation.c:380
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:492
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:493
NULL
#define NULL
Definition: coverity.c:32
ALL
#define ALL
Definition: vf_huesaturation.c:43
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
CYAN
#define CYAN
Definition: vf_huesaturation.c:40
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: filters.h:57
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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:94
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:488
huesaturation_inputs
static const AVFilterPad huesaturation_inputs[]
Definition: vf_huesaturation.c:426
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:900
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
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:182
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:497
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
RED
#define RED
Definition: vf_huesaturation.c:37
GREEN
#define GREEN
Definition: vf_huesaturation.c:39
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:152
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_huesaturation.c:393
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_huesaturation.c:404
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299