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/imgutils.h"
21 #include "avfilter.h"
22 #include "drawutils.h"
23 #include "formats.h"
24 #include "internal.h"
25 #include "video.h"
26 
27 #define R 0
28 #define G 1
29 #define B 2
30 
31 #define REDS 0
32 #define YELLOWS 1
33 #define GREENS 2
34 #define CYANS 3
35 #define BLUES 4
36 #define MAGENTAS 5
37 
38 #define RED (1 << REDS)
39 #define YELLOW (1 << YELLOWS)
40 #define GREEN (1 << GREENS)
41 #define CYAN (1 << CYANS)
42 #define BLUE (1 << BLUES)
43 #define MAGENTA (1 << MAGENTAS)
44 #define ALL 0x3F
45 
46 typedef struct HueSaturationContext {
47  const AVClass *class;
48 
49  float hue;
50  float saturation;
51  float intensity;
52  float strength;
53  float rlw, glw, blw;
54  int lightness;
55  int colors;
56 
57  int depth;
58  int planewidth[4];
59  int planeheight[4];
60 
61  float matrix[4][4];
62  int64_t imatrix[4][4];
63 
64  int bpp;
65  int step;
66  uint8_t rgba_map[4];
67 
68  int (*do_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
70 
71 #define DENOM 0x10000
72 
73 static inline void get_triplet(int64_t m[4][4], int *r, int *g, int *b)
74 {
75  const int ir = *r, ig = *g, ib = *b;
76 
77  *r = (ir * m[0][0] + ig * m[1][0] + ib * m[2][0] /*+ m[3][0]*/) >> 16;
78  *g = (ir * m[0][1] + ig * m[1][1] + ib * m[2][1] /*+ m[3][1]*/) >> 16;
79  *b = (ir * m[0][2] + ig * m[1][2] + ib * m[2][2] /*+ m[3][2]*/) >> 16;
80 }
81 
82 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
83 
84 static inline int lerpi8(int v0, int v1, int f, int max)
85 {
86  return v0 + FAST_DIV255((v1 - v0) * f);
87 }
88 
89 static inline int lerpi16(int v0, int v1, int f, int max)
90 {
91  return v0 + (v1 - v0) * (int64_t)f / max;
92 }
93 
94 #define HUESATURATION(name, type, clip, xall) \
95 static int do_slice_##name##_##xall(AVFilterContext *ctx, \
96  void *arg, \
97  int jobnr, int nb_jobs) \
98 { \
99  HueSaturationContext *s = ctx->priv; \
100  AVFrame *frame = arg; \
101  const int imax = (1 << name) - 1; \
102  const float strength = s->strength; \
103  const int colors = s->colors; \
104  const int step = s->step; \
105  const int width = frame->width; \
106  const int process_h = frame->height; \
107  const int slice_start = (process_h * jobnr ) / nb_jobs; \
108  const int slice_end = (process_h * (jobnr+1)) / nb_jobs; \
109  const int linesize = frame->linesize[0] / sizeof(type); \
110  type *row = (type *)frame->data[0] + linesize * slice_start; \
111  const uint8_t offset_r = s->rgba_map[R]; \
112  const uint8_t offset_g = s->rgba_map[G]; \
113  const uint8_t offset_b = s->rgba_map[B]; \
114  type *dst_r = row + offset_r; \
115  type *dst_g = row + offset_g; \
116  type *dst_b = row + offset_b; \
117  \
118  for (int y = slice_start; y < slice_end; y++) { \
119  for (int x = 0; x < width * step; x += step) { \
120  int ir, ig, ib, ro, go, bo; \
121  \
122  ir = ro = dst_r[x]; \
123  ig = go = dst_g[x]; \
124  ib = bo = dst_b[x]; \
125  \
126  if (xall) { \
127  get_triplet(s->imatrix, &ir, &ig, &ib); \
128  } else { \
129  const int min = FFMIN3(ir, ig, ib); \
130  const int max = FFMAX3(ir, ig, ib); \
131  const int flags = (ir == max) << REDS \
132  | (ir == min) << CYANS \
133  | (ig == max) << GREENS \
134  | (ig == min) << MAGENTAS \
135  | (ib == max) << BLUES \
136  | (ib == min) << YELLOWS; \
137  if (colors & flags) { \
138  int f = 0; \
139  \
140  if (colors & RED) \
141  f = FFMAX(f, ir - FFMAX(ig, ib)); \
142  if (colors & YELLOW) \
143  f = FFMAX(f, FFMIN(ir, ig) - ib); \
144  if (colors & GREEN) \
145  f = FFMAX(f, ig - FFMAX(ir, ib)); \
146  if (colors & CYAN) \
147  f = FFMAX(f, FFMIN(ig, ib) - ir); \
148  if (colors & BLUE) \
149  f = FFMAX(f, ib - FFMAX(ir, ig)); \
150  if (colors & MAGENTA) \
151  f = FFMAX(f, FFMIN(ir, ib) - ig); \
152  f = FFMIN(f * strength, imax); \
153  get_triplet(s->imatrix, &ir, &ig, &ib); \
154  ir = lerpi##name(ro, ir, f, imax); \
155  ig = lerpi##name(go, ig, f, imax); \
156  ib = lerpi##name(bo, ib, f, imax); \
157  } \
158  } \
159  \
160  dst_r[x] = clip(ir); \
161  dst_g[x] = clip(ig); \
162  dst_b[x] = clip(ib); \
163  } \
164  \
165  dst_r += linesize; \
166  dst_g += linesize; \
167  dst_b += linesize; \
168  } \
169  \
170  return 0; \
171 }
172 
173 HUESATURATION(8, uint8_t, av_clip_uint8, 0)
174 HUESATURATION(16, uint16_t, av_clip_uint16, 0)
175 
176 HUESATURATION(8, uint8_t, av_clip_uint8, 1)
177 HUESATURATION(16, uint16_t, av_clip_uint16, 1)
178 
179 static void identity_matrix(float matrix[4][4])
180 {
181  for (int y = 0; y < 4; y++)
182  for (int x = 0; x < 4; x++)
183  matrix[y][x] = y == x;
184 }
185 
186 static void matrix_multiply(float a[4][4], float b[4][4], float c[4][4])
187 {
188  float temp[4][4];
189 
190  for (int y = 0; y < 4; y++) {
191  for (int x = 0; x < 4; x++) {
192  temp[y][x] = b[y][0] * a[0][x]
193  + b[y][1] * a[1][x]
194  + b[y][2] * a[2][x]
195  + b[y][3] * a[3][x];
196  }
197  }
198 
199  for (int y = 0; y < 4; y++) {
200  for (int x = 0; x < 4; x++)
201  c[y][x] = temp[y][x];
202  }
203 }
204 
205 static void colorscale_matrix(float matrix[4][4], float r, float g, float b)
206 {
207  float temp[4][4];
208 
209  temp[0][0] = r; temp[0][1] = 0.f; temp[0][2] = 0.f; temp[0][3] = 0.f;
210  temp[1][0] = 0.f; temp[1][1] = g; temp[1][2] = 0.f; temp[1][3] = 0.f;
211  temp[2][0] = 0.f; temp[2][1] = 0.f; temp[2][2] = b; temp[2][3] = 0.f;
212  temp[3][0] = 0.f; temp[3][1] = 0.f; temp[3][2] = 0.f; temp[3][3] = 1.f;
213 
215 }
216 
217 static void saturation_matrix(float matrix[4][4], float saturation,
218  float rlw, float glw, float blw)
219 {
220  float s = 1.f - saturation;
221  float a = s * rlw + saturation;
222  float b = s * rlw;
223  float c = s * rlw;
224  float d = s * glw;
225  float e = s * glw + saturation;
226  float f = s * glw;
227  float g = s * blw;
228  float h = s * blw;
229  float i = s * blw + saturation;
230  float m[4][4];
231 
232  m[0][0] = a; m[0][1] = b; m[0][2] = c; m[0][3] = 0.f;
233  m[1][0] = d; m[1][1] = e; m[1][2] = f; m[1][3] = 0.f;
234  m[2][0] = g; m[2][1] = h; m[2][2] = i; m[2][3] = 0.f;
235  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
236 
238 }
239 
240 static void matrix2imatrix(float matrix[4][4], int64_t imatrix[4][4])
241 {
242  for (int y = 0; y < 4; y++)
243  for (int x = 0; x < 4; x++)
244  imatrix[y][x] = lrintf(matrix[y][x] * DENOM);
245 }
246 
247 static void x_rotate_matrix(float matrix[4][4], float rs, float rc)
248 {
249  float m[4][4];
250 
251  m[0][0] = 1.f; m[0][1] = 0.f; m[0][2] = 0.f; m[0][3] = 0.f;
252  m[1][0] = 0.f; m[1][1] = rc; m[1][2] = rs; m[1][3] = 0.f;
253  m[2][0] = 0.f; m[2][1] = -rs; m[2][2] = rc; m[2][3] = 0.f;
254  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
255 
257 }
258 
259 static void y_rotate_matrix(float matrix[4][4], float rs, float rc)
260 {
261  float m[4][4];
262 
263  m[0][0] = rc; m[0][1] = 0.f; m[0][2] = -rs; m[0][3] = 0.f;
264  m[1][0] = 0.f; m[1][1] = 1.f; m[1][2] = 0.f; m[1][3] = 0.f;
265  m[2][0] = rs; m[2][1] = 0.f; m[2][2] = rc; m[2][3] = 0.f;
266  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
267 
269 }
270 
271 static void z_rotate_matrix(float matrix[4][4], float rs, float rc)
272 {
273  float m[4][4];
274 
275  m[0][0] = rc; m[0][1] = rs; m[0][2] = 0.f; m[0][3] = 0.f;
276  m[1][0] = -rs; m[1][1] = rc; m[1][2] = 0.f; m[1][3] = 0.f;
277  m[2][0] = 0.f; m[2][1] = 0.f; m[2][2] = 1.f; m[2][3] = 0.f;
278  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
279 
281 }
282 
283 static void z_shear_matrix(float matrix[4][4], float dx, float dy)
284 {
285  float m[4][4];
286 
287  m[0][0] = 1.f; m[0][1] = 0.f; m[0][2] = dx; m[0][3] = 0.f;
288  m[1][0] = 0.f; m[1][1] = 1.f; m[1][2] = dy; m[1][3] = 0.f;
289  m[2][0] = 0.f; m[2][1] = 0.f; m[2][2] = 1.f; m[2][3] = 0.f;
290  m[3][0] = 0.f; m[3][1] = 0.f; m[3][2] = 0.f; m[3][3] = 1.f;
291 
293 }
294 
295 static void transform_point(float matrix[4][4],
296  float x, float y, float z,
297  float *tx, float *ty, float *tz)
298 {
299  x = y;
300  *tx = x * matrix[0][0] + y * matrix[1][0] + z * matrix[2][0] + matrix[3][0];
301  *ty = x * matrix[0][1] + y * matrix[1][1] + z * matrix[2][1] + matrix[3][1];
302  *tz = x * matrix[0][2] + y * matrix[1][2] + z * matrix[2][2] + matrix[3][2];
303 }
304 
305 static void hue_rotate_matrix(float matrix[4][4], float rotation,
306  float rlw, float glw, float blw)
307 {
308  float mag, lx, ly, lz;
309  float xrs, xrc;
310  float yrs, yrc;
311  float zrs, zrc;
312  float zsx, zsy;
313 
314  mag = M_SQRT2;
315  xrs = 1.f / mag;
316  xrc = 1.f / mag;
317  x_rotate_matrix(matrix, xrs, xrc);
318 
319  mag = sqrtf(3.f);
320  yrs = -1.f / mag;
321  yrc = M_SQRT2 / mag;
322  y_rotate_matrix(matrix, yrs, yrc);
323 
324  transform_point(matrix, rlw, glw, blw, &lx, &ly, &lz);
325  zsx = lx / lz;
326  zsy = ly / lz;
327  z_shear_matrix(matrix, zsx, zsy);
328 
329  zrs = sinf(rotation * M_PI / 180.f);
330  zrc = cosf(rotation * M_PI / 180.f);
331  z_rotate_matrix(matrix, zrs, zrc);
332 
333  z_shear_matrix(matrix, -zsx, -zsy);
334 
335  y_rotate_matrix(matrix, -yrs, yrc);
336  x_rotate_matrix(matrix, -xrs, xrc);
337 }
338 
339 static void shue_rotate_matrix(float m[4][4], float rotation)
340 {
341  float xrs, xrc, yrs, yrc, zrs, zrc, mag;
342 
343  mag = M_SQRT2;
344  xrs = 1.f / mag;
345  xrc = 1.f / mag;
346  x_rotate_matrix(m, xrs, xrc);
347 
348  mag = sqrtf(3.f);
349  yrs = -1.f / mag;
350  yrc = M_SQRT2 / mag;
351  y_rotate_matrix(m, yrs, yrc);
352 
353  zrs = sinf(rotation * M_PI / 180.f);
354  zrc = cosf(rotation * M_PI / 180.f);
355  z_rotate_matrix(m, zrs, zrc);
356 
357  y_rotate_matrix(m, -yrs, yrc);
358  x_rotate_matrix(m, -xrs, xrc);
359 }
360 
362 {
363  float i = 1.f + s->intensity;
364  float saturation = 1.f + s->saturation;
365  float hue = s->hue;
366 
367  identity_matrix(s->matrix);
368  colorscale_matrix(s->matrix, i, i, i);
369  saturation_matrix(s->matrix, saturation,
370  s->rlw, s->glw, s->blw);
371 
372  if (s->lightness)
373  hue_rotate_matrix(s->matrix, hue,
374  s->rlw, s->glw, s->blw);
375  else
376  shue_rotate_matrix(s->matrix, hue);
377 
378  matrix2imatrix(s->matrix, s->imatrix);
379 }
380 
382 {
383  AVFilterContext *ctx = inlink->dst;
384  HueSaturationContext *s = ctx->priv;
385 
386  init_matrix(s);
387 
388  ff_filter_execute(ctx, s->do_slice[(s->strength >= 99.f) && (s->colors == ALL)], frame, NULL,
389  FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
390 
391  return ff_filter_frame(ctx->outputs[0], frame);
392 }
393 
394 static const enum AVPixelFormat pixel_fmts[] = {
403 };
404 
406 {
407  AVFilterContext *ctx = inlink->dst;
408  HueSaturationContext *s = ctx->priv;
410 
411  s->depth = desc->comp[0].depth;
412  s->bpp = s->depth >> 3;
413  s->step = av_get_padded_bits_per_pixel(desc) >> (3 + (s->bpp == 2));
414  ff_fill_rgba_map(s->rgba_map, inlink->format);
415 
416  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
417  s->planewidth[0] = s->planewidth[3] = inlink->w;
418  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
419  s->planeheight[0] = s->planeheight[3] = inlink->h;
420 
421  s->do_slice[0] = s->depth <= 8 ? do_slice_8_0 : do_slice_16_0;
422  s->do_slice[1] = s->depth <= 8 ? do_slice_8_1 : do_slice_16_1;
423 
424  return 0;
425 }
426 
428  {
429  .name = "default",
430  .type = AVMEDIA_TYPE_VIDEO,
432  .filter_frame = filter_frame,
433  .config_props = config_input,
434  },
435 };
436 
438  {
439  .name = "default",
440  .type = AVMEDIA_TYPE_VIDEO,
441  },
442 };
443 
444 #define OFFSET(x) offsetof(HueSaturationContext, x)
445 #define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
446 
447 static const AVOption huesaturation_options[] = {
448  { "hue", "set the hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl=0},-180, 180, VF },
449  { "saturation", "set the saturation shift", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
450  { "intensity", "set the intensity shift", OFFSET(intensity), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
451  { "colors", "set colors range", OFFSET(colors), AV_OPT_TYPE_FLAGS, {.i64=ALL}, 0,ALL,VF, "colors" },
452  { "r", "set reds", 0, AV_OPT_TYPE_CONST, {.i64=RED}, 0, 0, VF, "colors" },
453  { "y", "set yellows", 0, AV_OPT_TYPE_CONST, {.i64=YELLOW}, 0, 0, VF, "colors" },
454  { "g", "set greens", 0, AV_OPT_TYPE_CONST, {.i64=GREEN}, 0, 0, VF, "colors" },
455  { "c", "set cyans", 0, AV_OPT_TYPE_CONST, {.i64=CYAN}, 0, 0, VF, "colors" },
456  { "b", "set blues", 0, AV_OPT_TYPE_CONST, {.i64=BLUE}, 0, 0, VF, "colors" },
457  { "m", "set magentas", 0, AV_OPT_TYPE_CONST, {.i64=MAGENTA}, 0, 0, VF, "colors" },
458  { "a", "set all colors", 0, AV_OPT_TYPE_CONST, {.i64=ALL}, 0, 0, VF, "colors" },
459  { "strength", "set the filtering strength", OFFSET(strength), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0,100,VF },
460  { "rw", "set the red weight", OFFSET(rlw), AV_OPT_TYPE_FLOAT, {.dbl=.333}, 0, 1, VF },
461  { "gw", "set the green weight", OFFSET(glw), AV_OPT_TYPE_FLOAT, {.dbl=.334}, 0, 1, VF },
462  { "bw", "set the blue weight", OFFSET(blw), AV_OPT_TYPE_FLOAT, {.dbl=.333}, 0, 1, VF },
463  { "lightness", "set the preserve lightness", OFFSET(lightness), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, VF },
464  { NULL }
465 };
466 
467 AVFILTER_DEFINE_CLASS(huesaturation);
468 
470  .name = "huesaturation",
471  .description = NULL_IF_CONFIG_SMALL("Apply hue-saturation-intensity adjustments."),
472  .priv_size = sizeof(HueSaturationContext),
473  .priv_class = &huesaturation_class,
478  .process_command = ff_filter_process_command,
479 };
x_rotate_matrix
static void x_rotate_matrix(float matrix[4][4], float rs, float rc)
Definition: vf_huesaturation.c:247
get_triplet
static void get_triplet(int64_t m[4][4], int *r, int *g, int *b)
Definition: vf_huesaturation.c:73
lerpi16
static int lerpi16(int v0, int v1, int f, int max)
Definition: vf_huesaturation.c:89
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
HueSaturationContext::bpp
int bpp
Definition: vf_huesaturation.c:64
r
const char * r
Definition: vf_curves.c:116
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:999
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2662
matrix
Definition: vc1dsp.c:42
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:170
OFFSET
#define OFFSET(x)
Definition: vf_huesaturation.c:444
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:325
saturation_matrix
static void saturation_matrix(float matrix[4][4], float saturation, float rlw, float glw, float blw)
Definition: vf_huesaturation.c:217
AVOption
AVOption.
Definition: opt.h:251
HueSaturationContext::saturation
float saturation
Definition: vf_huesaturation.c:50
b
#define b
Definition: input.c:34
HueSaturationContext::planeheight
int planeheight[4]
Definition: vf_huesaturation.c:59
VF
#define VF
Definition: vf_huesaturation.c:445
lerpi8
static int lerpi8(int v0, int v1, int f, int max)
Definition: vf_huesaturation.c:84
DENOM
#define DENOM
Definition: vf_huesaturation.c:71
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
max
#define max(a, b)
Definition: cuda_runtime.h:33
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:175
init_matrix
static void init_matrix(HueSaturationContext *s)
Definition: vf_huesaturation.c:361
video.h
formats.h
y_rotate_matrix
static void y_rotate_matrix(float matrix[4][4], float rs, float rc)
Definition: vf_huesaturation.c:259
v0
#define v0
Definition: regdef.h:26
cosf
#define cosf(x)
Definition: libm.h:78
HueSaturationContext
Definition: vf_huesaturation.c:46
MAGENTA
#define MAGENTA
Definition: vf_huesaturation.c:43
FAST_DIV255
#define FAST_DIV255(x)
Definition: vf_huesaturation.c:82
BLUE
#define BLUE
Definition: vf_huesaturation.c:42
matrix2imatrix
static void matrix2imatrix(float matrix[4][4], int64_t imatrix[4][4])
Definition: vf_huesaturation.c:240
HueSaturationContext::blw
float blw
Definition: vf_huesaturation.c:53
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
HueSaturationContext::do_slice
int(* do_slice[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_huesaturation.c:68
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:256
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(huesaturation)
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:50
g
const char * g
Definition: vf_curves.c:117
HueSaturationContext::step
int step
Definition: vf_huesaturation.c:65
ctx
AVFormatContext * ctx
Definition: movenc.c:48
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_huesaturation.c:381
HueSaturationContext::rgba_map
uint8_t rgba_map[4]
Definition: vf_huesaturation.c:66
HueSaturationContext::colors
int colors
Definition: vf_huesaturation.c:55
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
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:283
AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:396
HueSaturationContext::planewidth
int planewidth[4]
Definition: vf_huesaturation.c:58
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:397
NULL
#define NULL
Definition: coverity.c:32
ALL
#define ALL
Definition: vf_huesaturation.c:44
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:295
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:230
CYAN
#define CYAN
Definition: vf_huesaturation.c:41
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:186
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
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:122
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_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:2627
AV_PIX_FMT_RGB48
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:392
ff_vf_huesaturation
const AVFilter ff_vf_huesaturation
Definition: vf_huesaturation.c:469
huesaturation_inputs
static const AVFilterPad huesaturation_inputs[]
Definition: vf_huesaturation.c:427
HueSaturationContext::lightness
int lightness
Definition: vf_huesaturation.c:54
HueSaturationContext::intensity
float intensity
Definition: vf_huesaturation.c:51
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:863
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:179
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:228
M_PI
#define M_PI
Definition: mathematics.h:52
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:152
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:228
HueSaturationContext::rlw
float rlw
Definition: vf_huesaturation.c:53
AV_PIX_FMT_BGRA64
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:401
huesaturation_options
static const AVOption huesaturation_options[]
Definition: vf_huesaturation.c:447
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:783
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:305
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
colorscale_matrix
static void colorscale_matrix(float matrix[4][4], float r, float g, float b)
Definition: vf_huesaturation.c:205
AVFilter
Filter definition.
Definition: avfilter.h:171
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:229
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
HueSaturationContext::strength
float strength
Definition: vf_huesaturation.c:52
z_rotate_matrix
static void z_rotate_matrix(float matrix[4][4], float rs, float rc)
Definition: vf_huesaturation.c:271
HUESATURATION
#define HUESATURATION(name, type, clip, xall)
Definition: vf_huesaturation.c:94
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
HueSaturationContext::imatrix
int64_t imatrix[4][4]
Definition: vf_huesaturation.c:62
temp
else temp
Definition: vf_mcdeint.c:248
HueSaturationContext::glw
float glw
Definition: vf_huesaturation.c:53
RED
#define RED
Definition: vf_huesaturation.c:38
av_clip_uint8
#define av_clip_uint8
Definition: common.h:101
GREEN
#define GREEN
Definition: vf_huesaturation.c:40
huesaturation_outputs
static const AVFilterPad huesaturation_outputs[]
Definition: vf_huesaturation.c:437
AVFilterContext
An instance of a filter.
Definition: avfilter.h:408
av_clip_uint16
#define av_clip_uint16
Definition: common.h:107
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:127
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ib
#define ib(width, name)
Definition: cbs_h2645.c:271
shue_rotate_matrix
static void shue_rotate_matrix(float m[4][4], float rotation)
Definition: vf_huesaturation.c:339
M_SQRT2
#define M_SQRT2
Definition: mathematics.h:61
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:394
HueSaturationContext::hue
float hue
Definition: vf_huesaturation.c:49
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
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:405
d
d
Definition: ffmpeg_filter.c:153
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
imgutils.h
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:227
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:142
HueSaturationContext::depth
int depth
Definition: vf_huesaturation.c:57
int
int
Definition: ffmpeg_filter.c:153
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
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:68