FFmpeg
Loading...
Searching...
No Matches
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)
 
#define HUESATURATION(name, type, clip, xall)
 
#define OFFSET(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 FFFilter 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.

Referenced by fill_map(), filter_frame(), and get_max_component_diff().

◆ 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.

Referenced by color_range(), fill_map(), filter_frame(), and get_max_component_diff().

◆ 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.

Referenced by fill_map(), filter_frame(), and get_max_component_diff().

◆ 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.

Referenced by filter_frame().

◆ DENOM

#define DENOM   0x10000

Definition at line 70 of file vf_huesaturation.c.

Referenced by matrix2imatrix().

◆ FAST_DIV255

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

Definition at line 81 of file vf_huesaturation.c.

Referenced by lerpi8().

◆ HUESATURATION

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

Definition at line 93 of file vf_huesaturation.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 436 of file vf_huesaturation.c.

◆ VF

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 identity_matrix(), and 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
Initial value:
= {
}
#define AV_PIX_FMT_BGR48
Definition pixfmt.h:536
#define AV_PIX_FMT_RGBA64
Definition pixfmt.h:535
#define AV_PIX_FMT_RGB48
Definition pixfmt.h:531
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition pixfmt.h:265
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition pixfmt.h:264
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition pixfmt.h:263
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition pixfmt.h:262
#define AV_PIX_FMT_BGRA64
Definition pixfmt.h:540

Definition at line 393 of file vf_huesaturation.c.

◆ huesaturation_inputs

const AVFilterPad huesaturation_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition filters.h:59

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 }
}
static IPT saturation(const CmsCtx *ctx, IPT ipt)
Definition cms.c:559
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition opt.h:254
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#define VF
Definition af_afir.c:731
#define ALL
#define MAGENTA
#define BLUE
#define RED
#define YELLOW
#define GREEN
#define CYAN

Definition at line 439 of file vf_huesaturation.c.

◆ ff_vf_huesaturation

const FFFilter ff_vf_huesaturation
Initial value:
= {
.p.name = "huesaturation",
.p.description = NULL_IF_CONFIG_SMALL("Apply hue-saturation-intensity adjustments."),
.p.priv_class = &huesaturation_class,
.priv_size = sizeof(HueSaturationContext),
.process_command = 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:906
#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:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pixel_fmts[]
Definition vf_amplify.c:52
static const AVFilterPad huesaturation_inputs[]
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

Definition at line 461 of file vf_huesaturation.c.