FFmpeg
vf_huesaturation.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/opt.h"
20 #include "libavutil/pixdesc.h"
21 #include "avfilter.h"
22 #include "drawutils.h"
23 #include "internal.h"
24 #include "video.h"
25 
26 #define R 0
27 #define G 1
28 #define B 2
29 
30 #define REDS 0
31 #define YELLOWS 1
32 #define GREENS 2
33 #define CYANS 3
34 #define BLUES 4
35 #define MAGENTAS 5
36 
37 #define RED (1 << REDS)
38 #define YELLOW (1 << YELLOWS)
39 #define GREEN (1 << GREENS)
40 #define CYAN (1 << CYANS)
41 #define BLUE (1 << BLUES)
42 #define MAGENTA (1 << MAGENTAS)
43 #define ALL 0x3F
44 
45 typedef struct HueSaturationContext {
46  const AVClass *class;
47 
48  float hue;
49  float saturation;
50  float intensity;
51  float strength;
52  float rlw, glw, blw;
53  int lightness;
54  int colors;
55 
56  int depth;
57  int planewidth[4];
58  int planeheight[4];
59 
60  float matrix[4][4];
62 
63  int bpp;
64  int step;
65  uint8_t rgba_map[4];
66 
67  int (*do_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
69 
70 #define DENOM 0x10000
71 
72 static inline void get_triplet(int64_t m[4][4], int *r, int *g, int *b)
73 {
74  const int ir = *r, ig = *g, ib = *b;
75 
76  *r = (ir * m[0][0] + ig * m[1][0] + ib * m[2][0] /*+ m[3][0]*/) >> 16;
77  *g = (ir * m[0][1] + ig * m[1][1] + ib * m[2][1] /*+ m[3][1]*/) >> 16;
78  *b = (ir * m[0][2] + ig * m[1][2] + ib * m[2][2] /*+ m[3][2]*/) >> 16;
79 }
80 
81 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
82 
83 static inline int lerpi8(int v0, int v1, int f, int max)
84 {
85  return v0 + FAST_DIV255((v1 - v0) * f);
86 }
87 
88 static inline int lerpi16(int v0, int v1, int f, int max)
89 {
90  return v0 + (v1 - v0) * (int64_t)f / max;
91 }
92 
93 #define HUESATURATION(name, type, clip, xall) \
94 static int do_slice_##name##_##xall(AVFilterContext *ctx, \
95  void *arg, \
96  int jobnr, int nb_jobs) \
97 { \
98  HueSaturationContext *s = ctx->priv; \
99  AVFrame *frame = arg; \
100  const int imax = (1 << name) - 1; \
101  const float strength = s->strength; \
102  const int colors = s->colors; \
103  const int step = s->step; \
104  const int width = frame->width; \
105  const int process_h = frame->height; \
106  const int slice_start = (process_h * jobnr ) / nb_jobs; \
107  const int slice_end = (process_h * (jobnr+1)) / nb_jobs; \
108  const ptrdiff_t linesize = frame->linesize[0] / sizeof(type); \
109  type *row = (type *)frame->data[0] + linesize * slice_start; \
110  const uint8_t offset_r = s->rgba_map[R]; \
111  const uint8_t offset_g = s->rgba_map[G]; \
112  const uint8_t offset_b = s->rgba_map[B]; \
113  type *dst_r = row + offset_r; \
114  type *dst_g = row + offset_g; \
115  type *dst_b = row + offset_b; \
116  \
117  for (int y = slice_start; y < slice_end; y++) { \
118  for (int x = 0; x < width * step; x += step) { \
119  int ir, ig, ib, ro, go, bo; \
120  \
121  ir = ro = dst_r[x]; \
122  ig = go = dst_g[x]; \
123  ib = bo = dst_b[x]; \
124  \
125  if (xall) { \
126  get_triplet(s->imatrix, &ir, &ig, &ib); \
127  } else { \
128  const int min = FFMIN3(ir, ig, ib); \
129  const int max = FFMAX3(ir, ig, ib); \
130  const int flags = (ir == max) << REDS \
131  | (ir == min) << CYANS \
132  | (ig == max) << GREENS \
133  | (ig == min) << MAGENTAS \
134  | (ib == max) << BLUES \
135  | (ib == min) << YELLOWS; \
136  if (colors & flags) { \
137  int f = 0; \
138  \
139  if (colors & RED) \
140  f = FFMAX(f, ir - FFMAX(ig, ib)); \
141  if (colors & YELLOW) \
142  f = FFMAX(f, FFMIN(ir, ig) - ib); \
143  if (colors & GREEN) \
144  f = FFMAX(f, ig - FFMAX(ir, ib)); \
145  if (colors & CYAN) \
146  f = FFMAX(f, FFMIN(ig, ib) - ir); \
147  if (colors & BLUE) \
148  f = FFMAX(f, ib - FFMAX(ir, ig)); \
149  if (colors & MAGENTA) \
150  f = FFMAX(f, FFMIN(ir, ib) - ig); \
151  f = FFMIN(f * strength, imax); \
152  get_triplet(s->imatrix, &ir, &ig, &ib); \
153  ir = lerpi##name(ro, ir, f, imax); \
154  ig = lerpi##name(go, ig, f, imax); \
155  ib = lerpi##name(bo, ib, f, imax); \
156  } \
157  } \
158  \
159  dst_r[x] = clip(ir); \
160  dst_g[x] = clip(ig); \
161  dst_b[x] = clip(ib); \
162  } \
163  \
164  dst_r += linesize; \
165  dst_g += linesize; \
166  dst_b += linesize; \
167  } \
168  \
169  return 0; \
170 }
171 
172 HUESATURATION(8, uint8_t, av_clip_uint8, 0)
173 HUESATURATION(16, uint16_t, av_clip_uint16, 0)
174 
175 HUESATURATION(8, uint8_t, av_clip_uint8, 1)
176 HUESATURATION(16, uint16_t, av_clip_uint16, 1)
177 
178 static void identity_matrix(float matrix[4][4])
179 {
180  for (int y = 0; y < 4; y++)
181  for (int x = 0; x < 4; x++)
182  matrix[y][x] = y == x;
183 }
184 
185 static void matrix_multiply(float a[4][4], float b[4][4], float c[4][4])
186 {
187  float temp[4][4];
188 
189  for (int y = 0; y < 4; y++) {
190  for (int x = 0; x < 4; x++) {
191  temp[y][x] = b[y][0] * a[0][x]
192  + b[y][1] * a[1][x]
193  + b[y][2] * a[2][x]
194  + b[y][3] * a[3][x];
195  }
196  }
197 
198  for (int y = 0; y < 4; y++) {
199  for (int x = 0; x < 4; x++)
200  c[y][x] = temp[y][x];
201  }
202 }
203 
204 static void colorscale_matrix(float matrix[4][4], float r, float g, float b)
205 {
206  float temp[4][4];
207 
208  temp[0][0] = r; temp[0][1] = 0.f; temp[0][2] = 0.f; temp[0][3] = 0.f;
209  temp[1][0] = 0.f; temp[1][1] = g; temp[1][2] = 0.f; temp[1][3] = 0.f;
210  temp[2][0] = 0.f; temp[2][1] = 0.f; temp[2][2] = b; temp[2][3] = 0.f;
211  temp[3][0] = 0.f; temp[3][1] = 0.f; temp[3][2] = 0.f; temp[3][3] = 1.f;
212 
214 }
215 
216 static void saturation_matrix(float matrix[4][4], float saturation,
217  float rlw, float glw, float blw)
218 {
219  float s = 1.f - saturation;
220  float a = s * rlw + saturation;
221  float b = s * rlw;
222  float c = s * rlw;
223  float d = s * glw;
224  float e = s * glw + saturation;
225  float f = s * glw;
226  float g = s * blw;
227  float h = s * blw;
228  float i = s * blw + saturation;
229  float m[4][4];
230 
231  m[0][0] = a; m[0][1] = b; m[0][2] = c; m[0][3] = 0.f;
232  m[1][0] = d; m[1][1] = e; m[1][2] = f; m[1][3] = 0.f;
233  m[2][0] = g; m[2][1] = h; m[2][2] = i; m[2][3] = 0.f;
234  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
235 
237 }
238 
239 static void matrix2imatrix(float matrix[4][4], int64_t imatrix[4][4])
240 {
241  for (int y = 0; y < 4; y++)
242  for (int x = 0; x < 4; x++)
243  imatrix[y][x] = lrintf(matrix[y][x] * DENOM);
244 }
245 
246 static void x_rotate_matrix(float matrix[4][4], float rs, float rc)
247 {
248  float m[4][4];
249 
250  m[0][0] = 1.f; m[0][1] = 0.f; m[0][2] = 0.f; m[0][3] = 0.f;
251  m[1][0] = 0.f; m[1][1] = rc; m[1][2] = rs; m[1][3] = 0.f;
252  m[2][0] = 0.f; m[2][1] = -rs; m[2][2] = rc; m[2][3] = 0.f;
253  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
254 
256 }
257 
258 static void y_rotate_matrix(float matrix[4][4], float rs, float rc)
259 {
260  float m[4][4];
261 
262  m[0][0] = rc; m[0][1] = 0.f; m[0][2] = -rs; m[0][3] = 0.f;
263  m[1][0] = 0.f; m[1][1] = 1.f; m[1][2] = 0.f; m[1][3] = 0.f;
264  m[2][0] = rs; m[2][1] = 0.f; m[2][2] = rc; m[2][3] = 0.f;
265  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
266 
268 }
269 
270 static void z_rotate_matrix(float matrix[4][4], float rs, float rc)
271 {
272  float m[4][4];
273 
274  m[0][0] = rc; m[0][1] = rs; m[0][2] = 0.f; m[0][3] = 0.f;
275  m[1][0] = -rs; m[1][1] = rc; m[1][2] = 0.f; m[1][3] = 0.f;
276  m[2][0] = 0.f; m[2][1] = 0.f; m[2][2] = 1.f; m[2][3] = 0.f;
277  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
278 
280 }
281 
282 static void z_shear_matrix(float matrix[4][4], float dx, float dy)
283 {
284  float m[4][4];
285 
286  m[0][0] = 1.f; m[0][1] = 0.f; m[0][2] = dx; m[0][3] = 0.f;
287  m[1][0] = 0.f; m[1][1] = 1.f; m[1][2] = dy; m[1][3] = 0.f;
288  m[2][0] = 0.f; m[2][1] = 0.f; m[2][2] = 1.f; m[2][3] = 0.f;
289  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
290 
292 }
293 
294 static void transform_point(float matrix[4][4],
295  float x, float y, float z,
296  float *tx, float *ty, float *tz)
297 {
298  x = y;
299  *tx = x * matrix[0][0] + y * matrix[1][0] + z * matrix[2][0] + matrix[3][0];
300  *ty = x * matrix[0][1] + y * matrix[1][1] + z * matrix[2][1] + matrix[3][1];
301  *tz = x * matrix[0][2] + y * matrix[1][2] + z * matrix[2][2] + matrix[3][2];
302 }
303 
304 static void hue_rotate_matrix(float matrix[4][4], float rotation,
305  float rlw, float glw, float blw)
306 {
307  float mag, lx, ly, lz;
308  float xrs, xrc;
309  float yrs, yrc;
310  float zrs, zrc;
311  float zsx, zsy;
312 
313  mag = M_SQRT2;
314  xrs = 1.f / mag;
315  xrc = 1.f / mag;
316  x_rotate_matrix(matrix, xrs, xrc);
317 
318  mag = sqrtf(3.f);
319  yrs = -1.f / mag;
320  yrc = M_SQRT2 / mag;
321  y_rotate_matrix(matrix, yrs, yrc);
322 
323  transform_point(matrix, rlw, glw, blw, &lx, &ly, &lz);
324  zsx = lx / lz;
325  zsy = ly / lz;
326  z_shear_matrix(matrix, zsx, zsy);
327 
328  zrs = sinf(rotation * M_PI / 180.f);
329  zrc = cosf(rotation * M_PI / 180.f);
330  z_rotate_matrix(matrix, zrs, zrc);
331 
332  z_shear_matrix(matrix, -zsx, -zsy);
333 
334  y_rotate_matrix(matrix, -yrs, yrc);
335  x_rotate_matrix(matrix, -xrs, xrc);
336 }
337 
338 static void shue_rotate_matrix(float m[4][4], float rotation)
339 {
340  float xrs, xrc, yrs, yrc, zrs, zrc, mag;
341 
342  mag = M_SQRT2;
343  xrs = 1.f / mag;
344  xrc = 1.f / mag;
345  x_rotate_matrix(m, xrs, xrc);
346 
347  mag = sqrtf(3.f);
348  yrs = -1.f / mag;
349  yrc = M_SQRT2 / mag;
350  y_rotate_matrix(m, yrs, yrc);
351 
352  zrs = sinf(rotation * M_PI / 180.f);
353  zrc = cosf(rotation * M_PI / 180.f);
354  z_rotate_matrix(m, zrs, zrc);
355 
356  y_rotate_matrix(m, -yrs, yrc);
357  x_rotate_matrix(m, -xrs, xrc);
358 }
359 
361 {
362  float i = 1.f + s->intensity;
363  float saturation = 1.f + s->saturation;
364  float hue = s->hue;
365 
366  identity_matrix(s->matrix);
367  colorscale_matrix(s->matrix, i, i, i);
368  saturation_matrix(s->matrix, saturation,
369  s->rlw, s->glw, s->blw);
370 
371  if (s->lightness)
372  hue_rotate_matrix(s->matrix, hue,
373  s->rlw, s->glw, s->blw);
374  else
375  shue_rotate_matrix(s->matrix, hue);
376 
377  matrix2imatrix(s->matrix, s->imatrix);
378 }
379 
381 {
382  AVFilterContext *ctx = inlink->dst;
383  HueSaturationContext *s = ctx->priv;
384 
385  init_matrix(s);
386 
387  ff_filter_execute(ctx, s->do_slice[(s->strength >= 99.f) && (s->colors == ALL)], frame, NULL,
388  FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
389 
390  return ff_filter_frame(ctx->outputs[0], frame);
391 }
392 
393 static const enum AVPixelFormat pixel_fmts[] = {
402 };
403 
405 {
406  AVFilterContext *ctx = inlink->dst;
407  HueSaturationContext *s = ctx->priv;
409 
410  s->depth = desc->comp[0].depth;
411  s->bpp = s->depth >> 3;
412  s->step = av_get_padded_bits_per_pixel(desc) >> (3 + (s->bpp == 2));
413  ff_fill_rgba_map(s->rgba_map, inlink->format);
414 
415  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
416  s->planewidth[0] = s->planewidth[3] = inlink->w;
417  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
418  s->planeheight[0] = s->planeheight[3] = inlink->h;
419 
420  s->do_slice[0] = s->depth <= 8 ? do_slice_8_0 : do_slice_16_0;
421  s->do_slice[1] = s->depth <= 8 ? do_slice_8_1 : do_slice_16_1;
422 
423  return 0;
424 }
425 
427  {
428  .name = "default",
429  .type = AVMEDIA_TYPE_VIDEO,
431  .filter_frame = filter_frame,
432  .config_props = config_input,
433  },
434 };
435 
436 #define OFFSET(x) offsetof(HueSaturationContext, x)
437 #define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
438 
439 static const AVOption huesaturation_options[] = {
440  { "hue", "set the hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl=0},-180, 180, VF },
441  { "saturation", "set the saturation shift", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
442  { "intensity", "set the intensity shift", OFFSET(intensity), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
443  { "colors", "set colors range", OFFSET(colors), AV_OPT_TYPE_FLAGS, {.i64=ALL}, 0,ALL,VF, .unit = "colors" },
444  { "r", "set reds", 0, AV_OPT_TYPE_CONST, {.i64=RED}, 0, 0, VF, .unit = "colors" },
445  { "y", "set yellows", 0, AV_OPT_TYPE_CONST, {.i64=YELLOW}, 0, 0, VF, .unit = "colors" },
446  { "g", "set greens", 0, AV_OPT_TYPE_CONST, {.i64=GREEN}, 0, 0, VF, .unit = "colors" },
447  { "c", "set cyans", 0, AV_OPT_TYPE_CONST, {.i64=CYAN}, 0, 0, VF, .unit = "colors" },
448  { "b", "set blues", 0, AV_OPT_TYPE_CONST, {.i64=BLUE}, 0, 0, VF, .unit = "colors" },
449  { "m", "set magentas", 0, AV_OPT_TYPE_CONST, {.i64=MAGENTA}, 0, 0, VF, .unit = "colors" },
450  { "a", "set all colors", 0, AV_OPT_TYPE_CONST, {.i64=ALL}, 0, 0, VF, .unit = "colors" },
451  { "strength", "set the filtering strength", OFFSET(strength), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0,100,VF },
452  { "rw", "set the red weight", OFFSET(rlw), AV_OPT_TYPE_FLOAT, {.dbl=.333}, 0, 1, VF },
453  { "gw", "set the green weight", OFFSET(glw), AV_OPT_TYPE_FLOAT, {.dbl=.334}, 0, 1, VF },
454  { "bw", "set the blue weight", OFFSET(blw), AV_OPT_TYPE_FLOAT, {.dbl=.333}, 0, 1, VF },
455  { "lightness", "set the preserve lightness", OFFSET(lightness), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, VF },
456  { NULL }
457 };
458 
459 AVFILTER_DEFINE_CLASS(huesaturation);
460 
462  .name = "huesaturation",
463  .description = NULL_IF_CONFIG_SMALL("Apply hue-saturation-intensity adjustments."),
464  .priv_size = sizeof(HueSaturationContext),
465  .priv_class = &huesaturation_class,
470  .process_command = ff_filter_process_command,
471 };
x_rotate_matrix
static void x_rotate_matrix(float matrix[4][4], float rs, float rc)
Definition: vf_huesaturation.c:246
get_triplet
static void get_triplet(int64_t m[4][4], int *r, int *g, int *b)
Definition: vf_huesaturation.c:72
lerpi16
static int lerpi16(int v0, int v1, int f, int max)
Definition: vf_huesaturation.c:88
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
HueSaturationContext::bpp
int bpp
Definition: vf_huesaturation.c:63
r
const char * r
Definition: vf_curves.c:126
opt.h
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2962
matrix
Definition: vc1dsp.c:42
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
OFFSET
#define OFFSET(x)
Definition: vf_huesaturation.c:436
int64_t
long long int64_t
Definition: coverity.c:34
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
pixdesc.h
saturation_matrix
static void saturation_matrix(float matrix[4][4], float saturation, float rlw, float glw, float blw)
Definition: vf_huesaturation.c:216
AVOption
AVOption.
Definition: opt.h:346
HueSaturationContext::saturation
float saturation
Definition: vf_huesaturation.c:49
b
#define b
Definition: input.c:41
HueSaturationContext::planeheight
int planeheight[4]
Definition: vf_huesaturation.c:58
VF
#define VF
Definition: vf_huesaturation.c:437
lerpi8
static int lerpi8(int v0, int v1, int f, int max)
Definition: vf_huesaturation.c:83
DENOM
#define DENOM
Definition: vf_huesaturation.c:70
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
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
init_matrix
static void init_matrix(HueSaturationContext *s)
Definition: vf_huesaturation.c:360
video.h
y_rotate_matrix
static void y_rotate_matrix(float matrix[4][4], float rs, float rc)
Definition: vf_huesaturation.c:258
v0
#define v0
Definition: regdef.h:26
cosf
#define cosf(x)
Definition: libm.h:78
HueSaturationContext
Definition: vf_huesaturation.c:45
MAGENTA
#define MAGENTA
Definition: vf_huesaturation.c:42
FAST_DIV255
#define FAST_DIV255(x)
Definition: vf_huesaturation.c:81
BLUE
#define BLUE
Definition: vf_huesaturation.c:41
matrix2imatrix
static void matrix2imatrix(float matrix[4][4], int64_t imatrix[4][4])
Definition: vf_huesaturation.c:239
HueSaturationContext::blw
float blw
Definition: vf_huesaturation.c:52
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
HueSaturationContext::do_slice
int(* do_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_huesaturation.c:67
av_cold
#define av_cold
Definition: attributes.h:90
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
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(huesaturation)
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
g
const char * g
Definition: vf_curves.c:127
HueSaturationContext::step
int step
Definition: vf_huesaturation.c:64
ctx
AVFormatContext * ctx
Definition: movenc.c:48
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_huesaturation.c:380
HueSaturationContext::rgba_map
uint8_t rgba_map[4]
Definition: vf_huesaturation.c:65
HueSaturationContext::colors
int colors
Definition: vf_huesaturation.c:54
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
frame
static AVFrame * frame
Definition: demux_decode.c:54
arg
const char * arg
Definition: jacosubdec.c:67
z_shear_matrix
static void z_shear_matrix(float matrix[4][4], float dx, float dy)
Definition: vf_huesaturation.c:282
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:468
HueSaturationContext::planewidth
int planewidth[4]
Definition: vf_huesaturation.c:57
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
AV_PIX_FMT_BGR48
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:469
NULL
#define NULL
Definition: coverity.c:32
ALL
#define ALL
Definition: vf_huesaturation.c:43
transform_point
static void transform_point(float matrix[4][4], float x, float y, float z, float *tx, float *ty, float *tz)
Definition: vf_huesaturation.c:294
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
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
sinf
#define sinf(x)
Definition: libm.h:419
matrix_multiply
static void matrix_multiply(float a[4][4], float b[4][4], float c[4][4])
Definition: vf_huesaturation.c:185
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
f
f
Definition: af_crystalizer.c:121
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:106
av_get_padded_bits_per_pixel
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
Definition: pixdesc.c:2927
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:464
ff_vf_huesaturation
const AVFilter ff_vf_huesaturation
Definition: vf_huesaturation.c:461
huesaturation_inputs
static const AVFilterPad huesaturation_inputs[]
Definition: vf_huesaturation.c:426
HueSaturationContext::lightness
int lightness
Definition: vf_huesaturation.c:53
HueSaturationContext::intensity
float intensity
Definition: vf_huesaturation.c:50
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:890
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
identity_matrix
static void identity_matrix(float matrix[4][4])
Definition: vf_huesaturation.c:178
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
M_PI
#define M_PI
Definition: mathematics.h:67
internal.h
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:147
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
Definition: opt.h:238
HueSaturationContext::rlw
float rlw
Definition: vf_huesaturation.c:52
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:473
huesaturation_options
static const AVOption huesaturation_options[]
Definition: vf_huesaturation.c:439
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:825
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
hue_rotate_matrix
static void hue_rotate_matrix(float matrix[4][4], float rotation, float rlw, float glw, float blw)
Definition: vf_huesaturation.c:304
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
colorscale_matrix
static void colorscale_matrix(float matrix[4][4], float r, float g, float b)
Definition: vf_huesaturation.c:204
AVFilter
Filter definition.
Definition: avfilter.h:166
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
HueSaturationContext::strength
float strength
Definition: vf_huesaturation.c:51
z_rotate_matrix
static void z_rotate_matrix(float matrix[4][4], float rs, float rc)
Definition: vf_huesaturation.c:270
HUESATURATION
#define HUESATURATION(name, type, clip, xall)
Definition: vf_huesaturation.c:93
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
avfilter.h
HueSaturationContext::imatrix
int64_t imatrix[4][4]
Definition: vf_huesaturation.c:61
temp
else temp
Definition: vf_mcdeint.c:263
HueSaturationContext::glw
float glw
Definition: vf_huesaturation.c:52
RED
#define RED
Definition: vf_huesaturation.c:37
av_clip_uint8
#define av_clip_uint8
Definition: common.h:104
GREEN
#define GREEN
Definition: vf_huesaturation.c:39
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
av_clip_uint16
#define av_clip_uint16
Definition: common.h:110
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:117
desc
const char * desc
Definition: libsvtav1.c:75
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ib
#define ib(width, name)
Definition: cbs_h2645.c:257
shue_rotate_matrix
static void shue_rotate_matrix(float m[4][4], float rotation)
Definition: vf_huesaturation.c:338
M_SQRT2
#define M_SQRT2
Definition: mathematics.h:109
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_huesaturation.c:393
HueSaturationContext::hue
float hue
Definition: vf_huesaturation.c:48
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
config_input
static av_cold int config_input(AVFilterLink *inlink)
Definition: vf_huesaturation.c:404
d
d
Definition: ffmpeg_filter.c:409
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:234
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
h
h
Definition: vp9dsp_template.c:2038
drawutils.h
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:134
HueSaturationContext::depth
int depth
Definition: vf_huesaturation.c:56
int
int
Definition: ffmpeg_filter.c:409
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
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:52