FFmpeg
Loading...
Searching...
No Matches
vf_selectivecolor.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015-2016 Clément Bœsch <u pkh me>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @see http://blog.pkh.me/p/22-understanding-selective-coloring-in-adobe-photoshop.html
23 * @todo
24 * - use integers so it can be made bitexact and a FATE test can be added
25 */
26
27#include "libavutil/avassert.h"
28#include "libavutil/file.h"
30#include "libavutil/opt.h"
31#include "libavutil/pixdesc.h"
32#include "libavcodec/mathops.h" // for mid_pred(), which is a macro so no link dependency
33#include "avfilter.h"
34#include "drawutils.h"
35#include "filters.h"
36#include "video.h"
37
38#define R 0
39#define G 1
40#define B 2
41#define A 3
42
56
62
63static const char *const color_names[NB_RANGES] = {
64 "red", "yellow", "green", "cyan", "blue", "magenta", "white", "neutral", "black"
65};
66
67typedef int (*get_range_scale_func)(int r, int g, int b, int min_val, int max_val);
68
74
75typedef struct ThreadData {
76 AVFrame *in, *out;
78
91
92#define OFFSET(x) offsetof(SelectiveColorContext, x)
93#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
94#define RANGE_OPTION(color_name, range) \
95 { color_name"s", "adjust "color_name" regions", OFFSET(opt_cmyk_adjust[range]), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }
96
98 { "correction_method", "select correction method", OFFSET(correction_method), AV_OPT_TYPE_INT, {.i64 = CORRECTION_METHOD_ABSOLUTE}, 0, NB_CORRECTION_METHODS-1, FLAGS, .unit = "correction_method" },
99 { "absolute", NULL, 0, AV_OPT_TYPE_CONST, {.i64=CORRECTION_METHOD_ABSOLUTE}, INT_MIN, INT_MAX, FLAGS, .unit = "correction_method" },
100 { "relative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=CORRECTION_METHOD_RELATIVE}, INT_MIN, INT_MAX, FLAGS, .unit = "correction_method" },
101 RANGE_OPTION("red", RANGE_REDS),
102 RANGE_OPTION("yellow", RANGE_YELLOWS),
103 RANGE_OPTION("green", RANGE_GREENS),
104 RANGE_OPTION("cyan", RANGE_CYANS),
105 RANGE_OPTION("blue", RANGE_BLUES),
106 RANGE_OPTION("magenta", RANGE_MAGENTAS),
107 RANGE_OPTION("white", RANGE_WHITES),
108 RANGE_OPTION("neutral", RANGE_NEUTRALS),
109 RANGE_OPTION("black", RANGE_BLACKS),
110 { "psfile", "set Photoshop selectivecolor file name", OFFSET(psfile), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
111 { NULL }
112};
113
114AVFILTER_DEFINE_CLASS(selectivecolor);
115
116static int get_rgb_scale(int r, int g, int b, int min_val, int max_val)
117{
118 return max_val - mid_pred(r, g, b);
119}
120
121static int get_cmy_scale(int r, int g, int b, int min_val, int max_val)
122{
123 return mid_pred(r, g, b) - min_val;
124}
125
126#define DECLARE_RANGE_SCALE_FUNCS(nbits) \
127static int get_neutrals_scale##nbits(int r, int g, int b, int min_val, int max_val) \
128{ \
129 /* 1 - (|max-0.5| + |min-0.5|) */ \
130 return (((1<<nbits)-1)*2 - ( abs((max_val<<1) - ((1<<nbits)-1)) \
131 + abs((min_val<<1) - ((1<<nbits)-1))) + 1) >> 1; \
132} \
133 \
134static int get_whites_scale##nbits(int r, int g, int b, int min_val, int max_val) \
135{ \
136 /* (min - 0.5) * 2 */ \
137 return (min_val<<1) - ((1<<nbits)-1); \
138} \
139 \
140static int get_blacks_scale##nbits(int r, int g, int b, int min_val, int max_val) \
141{ \
142 /* (0.5 - max) * 2 */ \
143 return ((1<<nbits)-1) - (max_val<<1); \
144} \
145
148
150{
151 SelectiveColorContext *s = ctx->priv;
152 const float *cmyk = s->cmyk_adjust[range_id];
153
154 /* If the color range has user settings, register the color range
155 * as "to be processed" */
156 if (cmyk[0] || cmyk[1] || cmyk[2] || cmyk[3]) {
157 struct process_range *pr = &s->process_ranges[s->nb_process_ranges++];
158
159 if (cmyk[0] < -1.0 || cmyk[0] > 1.0 ||
160 cmyk[1] < -1.0 || cmyk[1] > 1.0 ||
161 cmyk[2] < -1.0 || cmyk[2] > 1.0 ||
162 cmyk[3] < -1.0 || cmyk[3] > 1.0) {
163 av_log(ctx, AV_LOG_ERROR, "Invalid %s adjustments (%g %g %g %g). "
164 "Settings must be set in [-1;1] range\n",
165 color_names[range_id], cmyk[0], cmyk[1], cmyk[2], cmyk[3]);
166 return AVERROR(EINVAL);
167 }
168
169 pr->range_id = range_id;
170 pr->mask = 1 << range_id;
171 if (pr->mask & (1<<RANGE_REDS | 1<<RANGE_GREENS | 1<<RANGE_BLUES)) pr->get_scale = get_rgb_scale;
172 else if (pr->mask & (1<<RANGE_CYANS | 1<<RANGE_MAGENTAS | 1<<RANGE_YELLOWS)) pr->get_scale = get_cmy_scale;
173 else if (!s->is_16bit && (pr->mask & 1<<RANGE_WHITES)) pr->get_scale = get_whites_scale8;
174 else if (!s->is_16bit && (pr->mask & 1<<RANGE_NEUTRALS)) pr->get_scale = get_neutrals_scale8;
175 else if (!s->is_16bit && (pr->mask & 1<<RANGE_BLACKS)) pr->get_scale = get_blacks_scale8;
176 else if ( s->is_16bit && (pr->mask & 1<<RANGE_WHITES)) pr->get_scale = get_whites_scale16;
177 else if ( s->is_16bit && (pr->mask & 1<<RANGE_NEUTRALS)) pr->get_scale = get_neutrals_scale16;
178 else if ( s->is_16bit && (pr->mask & 1<<RANGE_BLACKS)) pr->get_scale = get_blacks_scale16;
179 else
180 av_assert0(0);
181 }
182 return 0;
183}
184
185static int parse_psfile(AVFilterContext *ctx, const char *fname)
186{
187 int16_t val;
188 int ret, i, version;
189 uint8_t *map, *buf;
190 size_t map_size, size;
191 SelectiveColorContext *s = ctx->priv;
192
193 ret = av_file_map(fname, &map, &map_size, 0, NULL);
194 if (ret < 0)
195 return ret;
196 buf = map;
197 size = map_size;
198
199#define READ16(dst) do { \
200 if (size < 2) { \
201 ret = AVERROR_INVALIDDATA; \
202 goto end; \
203 } \
204 dst = AV_RB16(buf); \
205 buf += 2; \
206 size -= 2; \
207} while (0)
208
210 if (version != 1)
211 av_log(ctx, AV_LOG_WARNING, "Unsupported selective color file version %d, "
212 "the settings might not be loaded properly\n", version);
213
214 READ16(s->correction_method);
215 if (s->correction_method >= NB_CORRECTION_METHODS) {
217 goto end;
218 }
219
220 // 1st CMYK entry is reserved/unused
221 for (i = 0; i < FF_ARRAY_ELEMS(s->cmyk_adjust[0]); i++) {
222 READ16(val);
223 if (val)
224 av_log(ctx, AV_LOG_WARNING, "%c value of first CMYK entry is not 0 "
225 "but %d\n", "CMYK"[i], val);
226 }
227
228 for (i = 0; i < FF_ARRAY_ELEMS(s->cmyk_adjust); i++) {
229 int k;
230 for (k = 0; k < FF_ARRAY_ELEMS(s->cmyk_adjust[0]); k++) {
231 READ16(val);
232 s->cmyk_adjust[i][k] = val / 100.f;
233 }
235 if (ret < 0)
236 goto end;
237 }
238
239end:
240 av_file_unmap(map, map_size);
241 return ret;
242}
243
244static int config_input(AVFilterLink *inlink)
245{
246 int i, ret;
247 AVFilterContext *ctx = inlink->dst;
248 SelectiveColorContext *s = ctx->priv;
250
251 s->is_16bit = desc->comp[0].depth > 8;
252 s->step = av_get_padded_bits_per_pixel(desc) >> (3 + s->is_16bit);
253
254 ret = ff_fill_rgba_map(s->rgba_map, inlink->format);
255 if (ret < 0)
256 return ret;
257
258 /* If the following conditions are not met, it will cause trouble while
259 * parsing the PS file */
260 av_assert0(FF_ARRAY_ELEMS(s->cmyk_adjust) == 10 - 1);
261 av_assert0(FF_ARRAY_ELEMS(s->cmyk_adjust[0]) == 4);
262
263 if (s->psfile) {
264 ret = parse_psfile(ctx, s->psfile);
265 if (ret < 0)
266 return ret;
267 } else {
268 for (i = 0; i < FF_ARRAY_ELEMS(s->opt_cmyk_adjust); i++) {
269 const char *opt_cmyk_adjust = s->opt_cmyk_adjust[i];
270
271 if (opt_cmyk_adjust) {
272 float *cmyk = s->cmyk_adjust[i];
273
274 sscanf(s->opt_cmyk_adjust[i], "%f %f %f %f", cmyk, cmyk+1, cmyk+2, cmyk+3);
276 if (ret < 0)
277 return ret;
278 }
279 }
280 }
281
282 av_log(ctx, AV_LOG_VERBOSE, "Adjustments:%s\n", s->nb_process_ranges ? "" : " none");
283 for (i = 0; i < s->nb_process_ranges; i++) {
284 const struct process_range *pr = &s->process_ranges[i];
285 const float *cmyk = s->cmyk_adjust[pr->range_id];
286
287 av_log(ctx, AV_LOG_VERBOSE, "%8ss: C=%6g M=%6g Y=%6g K=%6g\n",
288 color_names[pr->range_id], cmyk[0], cmyk[1], cmyk[2], cmyk[3]);
289 }
290
291 return 0;
292}
293
304
305static inline int comp_adjust(int scale, float value, float adjust, float k, int correction_method)
306{
307 const float min = -value;
308 const float max = 1.f - value;
309 float res = (-1.f - adjust) * k - adjust;
311 res *= max;
312 return lrintf(av_clipf(res, min, max) * scale);
313}
314
315#define DECLARE_SELECTIVE_COLOR_FUNC(nbits) \
316static inline int selective_color_##nbits(AVFilterContext *ctx, ThreadData *td, \
317 int jobnr, int nb_jobs, int direct, int correction_method) \
318{ \
319 int i, x, y; \
320 const AVFrame *in = td->in; \
321 AVFrame *out = td->out; \
322 const SelectiveColorContext *s = ctx->priv; \
323 const int height = in->height; \
324 const int width = in->width; \
325 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs); \
326 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs); \
327 const int dst_linesize = out->linesize[0] / ((nbits + 7) / 8); \
328 const int src_linesize = in->linesize[0] / ((nbits + 7) / 8); \
329 const uint8_t roffset = s->rgba_map[R]; \
330 const uint8_t goffset = s->rgba_map[G]; \
331 const uint8_t boffset = s->rgba_map[B]; \
332 const uint8_t aoffset = s->rgba_map[A]; \
333 uint##nbits##_t *dst = (uint##nbits##_t *)out->data[0] + slice_start * dst_linesize; \
334 const uint##nbits##_t *src = (const uint##nbits##_t *)in->data[0] + slice_start * src_linesize; \
335 const uint##nbits##_t *src_r = (const uint##nbits##_t *)src + roffset; \
336 const uint##nbits##_t *src_g = (const uint##nbits##_t *)src + goffset; \
337 const uint##nbits##_t *src_b = (const uint##nbits##_t *)src + boffset; \
338 const uint##nbits##_t *src_a = (const uint##nbits##_t *)src + aoffset; \
339 uint##nbits##_t *dst_r = (uint##nbits##_t *)dst + roffset; \
340 uint##nbits##_t *dst_g = (uint##nbits##_t *)dst + goffset; \
341 uint##nbits##_t *dst_b = (uint##nbits##_t *)dst + boffset; \
342 uint##nbits##_t *dst_a = (uint##nbits##_t *)dst + aoffset; \
343 const int mid = 1<<(nbits-1); \
344 const int max = (1<<nbits)-1; \
345 const float scale = 1.f / max; \
346 \
347 for (y = slice_start; y < slice_end; y++) { \
348 for (x = 0; x < width * s->step; x += s->step) { \
349 const int r = src_r[x]; \
350 const int g = src_g[x]; \
351 const int b = src_b[x]; \
352 const int min_color = FFMIN3(r, g, b); \
353 const int max_color = FFMAX3(r, g, b); \
354 const int is_white = (r > mid && g > mid && b > mid); \
355 const int is_neutral = (r || g || b) && \
356 (r != max || g != max || b != max); \
357 const int is_black = (r < mid && g < mid && b < mid); \
358 const uint32_t range_flag = (r == max_color) << RANGE_REDS \
359 | (r == min_color) << RANGE_CYANS \
360 | (g == max_color) << RANGE_GREENS \
361 | (g == min_color) << RANGE_MAGENTAS \
362 | (b == max_color) << RANGE_BLUES \
363 | (b == min_color) << RANGE_YELLOWS \
364 | is_white << RANGE_WHITES \
365 | is_neutral << RANGE_NEUTRALS \
366 | is_black << RANGE_BLACKS; \
367 \
368 const float rnorm = r * scale; \
369 const float gnorm = g * scale; \
370 const float bnorm = b * scale; \
371 int adjust_r = 0, adjust_g = 0, adjust_b = 0; \
372 \
373 for (i = 0; i < s->nb_process_ranges; i++) { \
374 const struct process_range *pr = &s->process_ranges[i]; \
375 \
376 if (range_flag & pr->mask) { \
377 const int scale = pr->get_scale(r, g, b, min_color, max_color); \
378 \
379 if (scale > 0) { \
380 const float *cmyk_adjust = s->cmyk_adjust[pr->range_id]; \
381 const float adj_c = cmyk_adjust[0]; \
382 const float adj_m = cmyk_adjust[1]; \
383 const float adj_y = cmyk_adjust[2]; \
384 const float k = cmyk_adjust[3]; \
385 \
386 adjust_r += comp_adjust(scale, rnorm, adj_c, k, correction_method); \
387 adjust_g += comp_adjust(scale, gnorm, adj_m, k, correction_method); \
388 adjust_b += comp_adjust(scale, bnorm, adj_y, k, correction_method); \
389 } \
390 } \
391 } \
392 \
393 if (!direct || adjust_r || adjust_g || adjust_b) { \
394 dst_r[x] = av_clip_uint##nbits(r + adjust_r); \
395 dst_g[x] = av_clip_uint##nbits(g + adjust_g); \
396 dst_b[x] = av_clip_uint##nbits(b + adjust_b); \
397 if (!direct && s->step == 4) \
398 dst_a[x] = src_a[x]; \
399 } \
400 } \
401 \
402 src_r += src_linesize; \
403 src_g += src_linesize; \
404 src_b += src_linesize; \
405 src_a += src_linesize; \
406 \
407 dst_r += dst_linesize; \
408 dst_g += dst_linesize; \
409 dst_b += dst_linesize; \
410 dst_a += dst_linesize; \
411 } \
412 return 0; \
413}
414
415#define DEF_SELECTIVE_COLOR_FUNC(name, direct, correction_method, nbits) \
416static int selective_color_##name##_##nbits(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
417{ \
418 return selective_color_##nbits(ctx, arg, jobnr, nb_jobs, direct, correction_method); \
419}
420
421#define DEF_SELECTIVE_COLOR_FUNCS(nbits) \
422DECLARE_SELECTIVE_COLOR_FUNC(nbits) \
423DEF_SELECTIVE_COLOR_FUNC(indirect_absolute, 0, CORRECTION_METHOD_ABSOLUTE, nbits) \
424DEF_SELECTIVE_COLOR_FUNC(indirect_relative, 0, CORRECTION_METHOD_RELATIVE, nbits) \
425DEF_SELECTIVE_COLOR_FUNC( direct_absolute, 1, CORRECTION_METHOD_ABSOLUTE, nbits) \
426DEF_SELECTIVE_COLOR_FUNC( direct_relative, 1, CORRECTION_METHOD_RELATIVE, nbits)
427
430
431typedef int (*selective_color_func_type)(AVFilterContext *ctx, void *td, int jobnr, int nb_jobs);
432
433static int filter_frame(AVFilterLink *inlink, AVFrame *in)
434{
435 AVFilterContext *ctx = inlink->dst;
436 AVFilterLink *outlink = ctx->outputs[0];
437 int direct;
438 AVFrame *out;
439 ThreadData td;
440 const SelectiveColorContext *s = ctx->priv;
441 static const selective_color_func_type funcs[2][2][2] = {
442 {
443 {selective_color_indirect_absolute_8, selective_color_indirect_relative_8},
444 {selective_color_direct_absolute_8, selective_color_direct_relative_8},
445 },{
446 {selective_color_indirect_absolute_16, selective_color_indirect_relative_16},
447 {selective_color_direct_absolute_16, selective_color_direct_relative_16},
448 }
449 };
450
451 if (av_frame_is_writable(in)) {
452 direct = 1;
453 out = in;
454 } else {
455 direct = 0;
456 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
457 if (!out) {
458 av_frame_free(&in);
459 return AVERROR(ENOMEM);
460 }
462 }
463
464 td.in = in;
465 td.out = out;
466 ff_filter_execute(ctx, funcs[s->is_16bit][direct][s->correction_method],
467 &td, NULL, FFMIN(inlink->h, ff_filter_get_nb_threads(ctx)));
468
469 if (!direct)
470 av_frame_free(&in);
471 return ff_filter_frame(outlink, out);
472}
473
475 {
476 .name = "default",
477 .type = AVMEDIA_TYPE_VIDEO,
478 .filter_frame = filter_frame,
479 .config_props = config_input,
480 },
481};
482
484 .p.name = "selectivecolor",
485 .p.description = NULL_IF_CONFIG_SMALL("Apply CMYK adjustments to specific color ranges."),
486 .p.priv_class = &selectivecolor_class,
488 .priv_size = sizeof(SelectiveColorContext),
492};
static double val(void *priv, double ch)
Definition aeval.c:77
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_selectivecolor
static FILE * out
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1079
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1721
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:857
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:596
#define av_clipf
Definition common.h:145
#define NULL
Definition coverity.c:32
#define min(a, b)
#define max(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition drawutils.c:80
misc drawing utilities
double value
Definition eval.c:102
int ret
Definition ffplay.c:391
Misc file utilities.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
#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:202
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:172
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition frame.c:538
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:65
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:602
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
const VDPAUPixFmtMap * map
#define r
Definition input.c:42
#define b
Definition input.c:43
#define FILTER_INPUTS(array)
Definition filters.h:279
#define FILTER_OUTPUTS(array)
Definition filters.h:280
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:259
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:493
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
Definition file.c:175
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
Definition file.c:114
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
version
Definition libkvazaar.c:313
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
#define lrintf(x)
Definition libm_mips.h:74
const char * desc
Definition libsvtav1.c:83
#define FFMIN(a, b)
Definition macros.h:49
#define mid_pred
Definition mathops.h:115
static int adjust(int x, int size)
Definition mobiclip.c:514
AVOptions.
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:3449
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
#define AV_PIX_FMT_BGR48
Definition pixfmt.h:539
#define AV_PIX_FMT_RGBA64
Definition pixfmt.h:538
#define AV_PIX_FMT_RGB48
Definition pixfmt.h:534
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ 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:543
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:279
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
float cmyk_adjust[NB_RANGES][4]
struct process_range process_ranges[NB_RANGES]
char * opt_cmyk_adjust[NB_RANGES]
Used for passing data between threads.
Definition v210dec.c:35
get_range_scale_func get_scale
#define av_log(a,...)
int size
const char * g
Definition vf_curves.c:128
#define DEF_SELECTIVE_COLOR_FUNCS(nbits)
static int get_cmy_scale(int r, int g, int b, int min_val, int max_val)
static const char *const color_names[NB_RANGES]
static int get_rgb_scale(int r, int g, int b, int min_val, int max_val)
static const AVOption selectivecolor_options[]
static int config_input(AVFilterLink *inlink)
#define DECLARE_RANGE_SCALE_FUNCS(nbits)
#define READ16(dst)
static int parse_psfile(AVFilterContext *ctx, const char *fname)
color_range
@ RANGE_GREENS
@ NB_RANGES
@ RANGE_YELLOWS
@ RANGE_REDS
@ RANGE_MAGENTAS
@ RANGE_CYANS
@ RANGE_BLUES
@ RANGE_NEUTRALS
@ RANGE_WHITES
@ RANGE_BLACKS
int(* selective_color_func_type)(AVFilterContext *ctx, void *td, int jobnr, int nb_jobs)
static int comp_adjust(int scale, float value, float adjust, float k, int correction_method)
static const AVFilterPad selectivecolor_inputs[]
#define OFFSET(x)
#define RANGE_OPTION(color_name, range)
int(* get_range_scale_func)(int r, int g, int b, int min_val, int max_val)
correction_method
@ CORRECTION_METHOD_ABSOLUTE
@ CORRECTION_METHOD_RELATIVE
@ NB_CORRECTION_METHODS
static int register_range(AVFilterContext *ctx, int range_id)
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
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:120