FFmpeg
Loading...
Searching...
No Matches
vf_colorcorrect.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Paul B Mahol
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#include <float.h>
22
23#include "libavutil/mem.h"
24#include "libavutil/opt.h"
25#include "libavutil/pixdesc.h"
26#include "avfilter.h"
27#include "filters.h"
28#include "video.h"
29
37
38typedef struct ColorCorrectContext {
39 const AVClass *class;
40
41 float rl, bl;
42 float rh, bh;
45
46 int depth;
47 float max, imax;
48
51 int planewidth[4];
52
53 unsigned *uhistogram;
54 unsigned *vhistogram;
55
57
58 int (*do_slice)(AVFilterContext *s, void *arg,
59 int jobnr, int nb_jobs);
61
62static int average_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
63{
64 ColorCorrectContext *s = ctx->priv;
65 AVFrame *frame = arg;
66 const float imax = s->imax;
67 const int width = s->planewidth[1];
68 const int height = s->planeheight[1];
69 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
70 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
71 const ptrdiff_t ulinesize = frame->linesize[1];
72 const ptrdiff_t vlinesize = frame->linesize[2];
73 const uint8_t *uptr = (const uint8_t *)frame->data[1] + slice_start * ulinesize;
74 const uint8_t *vptr = (const uint8_t *)frame->data[2] + slice_start * vlinesize;
75 int sum_u = 0, sum_v = 0;
76
77 for (int y = slice_start; y < slice_end; y++) {
78 for (int x = 0; x < width; x++) {
79 sum_u += uptr[x];
80 sum_v += vptr[x];
81 }
82
83 uptr += ulinesize;
84 vptr += vlinesize;
85 }
86
87 s->analyzeret[jobnr][0] = s->analyzeret[jobnr][2] = imax * sum_u / (float)((slice_end - slice_start) * width) - 0.5f;
88 s->analyzeret[jobnr][1] = s->analyzeret[jobnr][3] = imax * sum_v / (float)((slice_end - slice_start) * width) - 0.5f;
89
90 return 0;
91}
92
93static int average_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
94{
95 ColorCorrectContext *s = ctx->priv;
96 AVFrame *frame = arg;
97 const float imax = s->imax;
98 const int width = s->planewidth[1];
99 const int height = s->planeheight[1];
100 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
101 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
102 const ptrdiff_t ulinesize = frame->linesize[1] / 2;
103 const ptrdiff_t vlinesize = frame->linesize[2] / 2;
104 const uint16_t *uptr = (const uint16_t *)frame->data[1] + slice_start * ulinesize;
105 const uint16_t *vptr = (const uint16_t *)frame->data[2] + slice_start * vlinesize;
106 int64_t sum_u = 0, sum_v = 0;
107
108 for (int y = slice_start; y < slice_end; y++) {
109 for (int x = 0; x < width; x++) {
110 sum_u += uptr[x];
111 sum_v += vptr[x];
112 }
113
114 uptr += ulinesize;
115 vptr += vlinesize;
116 }
117
118 s->analyzeret[jobnr][0] = s->analyzeret[jobnr][2] = imax * sum_u / (float)((slice_end - slice_start) * width) - 0.5f;
119 s->analyzeret[jobnr][1] = s->analyzeret[jobnr][3] = imax * sum_v / (float)((slice_end - slice_start) * width) - 0.5f;
120
121 return 0;
122}
123
124static int minmax_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
125{
126 ColorCorrectContext *s = ctx->priv;
127 AVFrame *frame = arg;
128 const float imax = s->imax;
129 const int width = s->planewidth[1];
130 const int height = s->planeheight[1];
131 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
132 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
133 const ptrdiff_t ulinesize = frame->linesize[1];
134 const ptrdiff_t vlinesize = frame->linesize[2];
135 const uint8_t *uptr = (const uint8_t *)frame->data[1] + slice_start * ulinesize;
136 const uint8_t *vptr = (const uint8_t *)frame->data[2] + slice_start * vlinesize;
137 int min_u = 255, min_v = 255;
138 int max_u = 0, max_v = 0;
139
140 for (int y = slice_start; y < slice_end; y++) {
141 for (int x = 0; x < width; x++) {
142 min_u = FFMIN(min_u, uptr[x]);
143 min_v = FFMIN(min_v, vptr[x]);
144 max_u = FFMAX(max_u, uptr[x]);
145 max_v = FFMAX(max_v, vptr[x]);
146 }
147
148 uptr += ulinesize;
149 vptr += vlinesize;
150 }
151
152 s->analyzeret[jobnr][0] = imax * min_u - 0.5f;
153 s->analyzeret[jobnr][1] = imax * min_v - 0.5f;
154 s->analyzeret[jobnr][2] = imax * max_u - 0.5f;
155 s->analyzeret[jobnr][3] = imax * max_v - 0.5f;
156
157 return 0;
158}
159
160static int minmax_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
161{
162 ColorCorrectContext *s = ctx->priv;
163 AVFrame *frame = arg;
164 const float imax = s->imax;
165 const int width = s->planewidth[1];
166 const int height = s->planeheight[1];
167 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
168 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
169 const ptrdiff_t ulinesize = frame->linesize[1] / 2;
170 const ptrdiff_t vlinesize = frame->linesize[2] / 2;
171 const uint16_t *uptr = (const uint16_t *)frame->data[1] + slice_start * ulinesize;
172 const uint16_t *vptr = (const uint16_t *)frame->data[2] + slice_start * vlinesize;
173 int min_u = INT_MAX, min_v = INT_MAX;
174 int max_u = INT_MIN, max_v = INT_MIN;
175
176 for (int y = slice_start; y < slice_end; y++) {
177 for (int x = 0; x < width; x++) {
178 min_u = FFMIN(min_u, uptr[x]);
179 min_v = FFMIN(min_v, vptr[x]);
180 max_u = FFMAX(max_u, uptr[x]);
181 max_v = FFMAX(max_v, vptr[x]);
182 }
183
184 uptr += ulinesize;
185 vptr += vlinesize;
186 }
187
188 s->analyzeret[jobnr][0] = imax * min_u - 0.5f;
189 s->analyzeret[jobnr][1] = imax * min_v - 0.5f;
190 s->analyzeret[jobnr][2] = imax * max_u - 0.5f;
191 s->analyzeret[jobnr][3] = imax * max_v - 0.5f;
192
193 return 0;
194}
195
196static int median_8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
197{
198 ColorCorrectContext *s = ctx->priv;
199 AVFrame *frame = arg;
200 const float imax = s->imax;
201 const int width = s->planewidth[1];
202 const int height = s->planeheight[1];
203 const ptrdiff_t ulinesize = frame->linesize[1];
204 const ptrdiff_t vlinesize = frame->linesize[2];
205 const uint8_t *uptr = (const uint8_t *)frame->data[1];
206 const uint8_t *vptr = (const uint8_t *)frame->data[2];
207 unsigned *uhistogram = s->uhistogram;
208 unsigned *vhistogram = s->vhistogram;
209 const int half_size = width * height / 2;
210 int umedian = s->max, vmedian = s->max;
211 unsigned ucnt = 0, vcnt = 0;
212
213 memset(uhistogram, 0, sizeof(*uhistogram) * (s->max + 1));
214 memset(vhistogram, 0, sizeof(*vhistogram) * (s->max + 1));
215
216 for (int y = 0; y < height; y++) {
217 for (int x = 0; x < width; x++) {
218 uhistogram[uptr[x]]++;
219 vhistogram[vptr[x]]++;
220 }
221
222 uptr += ulinesize;
223 vptr += vlinesize;
224 }
225
226 for (int i = 0; i < s->max + 1; i++) {
227 ucnt += uhistogram[i];
228 if (ucnt >= half_size) {
229 umedian = i;
230 break;
231 }
232 }
233
234 for (int i = 0; i < s->max + 1; i++) {
235 vcnt += vhistogram[i];
236 if (vcnt >= half_size) {
237 vmedian = i;
238 break;
239 }
240 }
241
242 s->analyzeret[0][0] = imax * umedian - 0.5f;
243 s->analyzeret[0][1] = imax * vmedian - 0.5f;
244 s->analyzeret[0][2] = imax * umedian - 0.5f;
245 s->analyzeret[0][3] = imax * vmedian - 0.5f;
246
247 return 0;
248}
249
250static int median_16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
251{
252 ColorCorrectContext *s = ctx->priv;
253 AVFrame *frame = arg;
254 const float imax = s->imax;
255 const int width = s->planewidth[1];
256 const int height = s->planeheight[1];
257 const ptrdiff_t ulinesize = frame->linesize[1] / 2;
258 const ptrdiff_t vlinesize = frame->linesize[2] / 2;
259 const uint16_t *uptr = (const uint16_t *)frame->data[1];
260 const uint16_t *vptr = (const uint16_t *)frame->data[2];
261 unsigned *uhistogram = s->uhistogram;
262 unsigned *vhistogram = s->vhistogram;
263 const int half_size = width * height / 2;
264 int umedian = s->max, vmedian = s->max;
265 unsigned ucnt = 0, vcnt = 0;
266
267 memset(uhistogram, 0, sizeof(*uhistogram) * (s->max + 1));
268 memset(vhistogram, 0, sizeof(*vhistogram) * (s->max + 1));
269
270 for (int y = 0; y < height; y++) {
271 for (int x = 0; x < width; x++) {
272 uhistogram[uptr[x]]++;
273 vhistogram[vptr[x]]++;
274 }
275
276 uptr += ulinesize;
277 vptr += vlinesize;
278 }
279
280 for (int i = 0; i < s->max + 1; i++) {
281 ucnt += uhistogram[i];
282 if (ucnt >= half_size) {
283 umedian = i;
284 break;
285 }
286 }
287
288 for (int i = 0; i < s->max + 1; i++) {
289 vcnt += vhistogram[i];
290 if (vcnt >= half_size) {
291 vmedian = i;
292 break;
293 }
294 }
295
296 s->analyzeret[0][0] = imax * umedian - 0.5f;
297 s->analyzeret[0][1] = imax * vmedian - 0.5f;
298 s->analyzeret[0][2] = imax * umedian - 0.5f;
299 s->analyzeret[0][3] = imax * vmedian - 0.5f;
300
301 return 0;
302}
303
304#define PROCESS() \
305 float y = yptr[x * chroma_w] * imax; \
306 float u = uptr[x] * imax - .5f; \
307 float v = vptr[x] * imax - .5f; \
308 float nu, nv; \
309 \
310 nu = saturation * (u + y * bd + bl); \
311 nv = saturation * (v + y * rd + rl);
312
313static int colorcorrect_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
314{
315 ColorCorrectContext *s = ctx->priv;
316 AVFrame *frame = arg;
317 const float max = s->max;
318 const float imax = s->imax;
319 const int chroma_w = s->chroma_w;
320 const int chroma_h = s->chroma_h;
321 const int width = s->planewidth[1];
322 const int height = s->planeheight[1];
323 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
324 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
325 const ptrdiff_t ylinesize = frame->linesize[0];
326 const ptrdiff_t ulinesize = frame->linesize[1];
327 const ptrdiff_t vlinesize = frame->linesize[2];
328 uint8_t *yptr = frame->data[0] + slice_start * chroma_h * ylinesize;
329 uint8_t *uptr = frame->data[1] + slice_start * ulinesize;
330 uint8_t *vptr = frame->data[2] + slice_start * vlinesize;
331 const float saturation = s->saturation;
332 const float bl = s->bl;
333 const float rl = s->rl;
334 const float bd = s->bh - bl;
335 const float rd = s->rh - rl;
336
337 for (int y = slice_start; y < slice_end; y++) {
338 for (int x = 0; x < width; x++) {
339 PROCESS()
340
341 uptr[x] = av_clip_uint8((nu + 0.5f) * max);
342 vptr[x] = av_clip_uint8((nv + 0.5f) * max);
343 }
344
345 yptr += ylinesize * chroma_h;
346 uptr += ulinesize;
347 vptr += vlinesize;
348 }
349
350 return 0;
351}
352
353static int colorcorrect_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
354{
355 ColorCorrectContext *s = ctx->priv;
356 AVFrame *frame = arg;
357 const int depth = s->depth;
358 const float max = s->max;
359 const float imax = s->imax;
360 const int chroma_w = s->chroma_w;
361 const int chroma_h = s->chroma_h;
362 const int width = s->planewidth[1];
363 const int height = s->planeheight[1];
364 const int slice_start = ff_slice_pos(height, jobnr, nb_jobs);
365 const int slice_end = ff_slice_pos(height, jobnr + 1, nb_jobs);
366 const ptrdiff_t ylinesize = frame->linesize[0] / 2;
367 const ptrdiff_t ulinesize = frame->linesize[1] / 2;
368 const ptrdiff_t vlinesize = frame->linesize[2] / 2;
369 uint16_t *yptr = (uint16_t *)frame->data[0] + slice_start * chroma_h * ylinesize;
370 uint16_t *uptr = (uint16_t *)frame->data[1] + slice_start * ulinesize;
371 uint16_t *vptr = (uint16_t *)frame->data[2] + slice_start * vlinesize;
372 const float saturation = s->saturation;
373 const float bl = s->bl;
374 const float rl = s->rl;
375 const float bd = s->bh - bl;
376 const float rd = s->rh - rl;
377
378 for (int y = slice_start; y < slice_end; y++) {
379 for (int x = 0; x < width; x++) {
380 PROCESS()
381
382 uptr[x] = av_clip_uintp2_c((nu + 0.5f) * max, depth);
383 vptr[x] = av_clip_uintp2_c((nv + 0.5f) * max, depth);
384 }
385
386 yptr += ylinesize * chroma_h;
387 uptr += ulinesize;
388 vptr += vlinesize;
389 }
390
391 return 0;
392}
393
394static int (*const analyze_slice[NB_ANALYZE][2])(AVFilterContext *s, void *arg,
395 int jobnr, int nb_jobs) = {
398 [MEDIAN] = { median_8, median_16 },
399};
400
402{
403 AVFilterContext *ctx = inlink->dst;
404 ColorCorrectContext *s = ctx->priv;
405 const int nb_threads = s->analyze == MEDIAN ? 1 : FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx));
406
407 if (s->analyze) {
408 const int nb_athreads = s->analyze == MEDIAN ? 1 : nb_threads;
409 float bl = 0.f, rl = 0.f, bh = 0.f, rh = 0.f;
410
411 ff_filter_execute(ctx, analyze_slice[s->analyze][s->depth > 8], frame, NULL, nb_athreads);
412
413 for (int i = 0; i < nb_athreads; i++) {
414 bl += s->analyzeret[i][0];
415 rl += s->analyzeret[i][1];
416 bh += s->analyzeret[i][2];
417 rh += s->analyzeret[i][3];
418 }
419
420 bl /= nb_athreads;
421 rl /= nb_athreads;
422 bh /= nb_athreads;
423 rh /= nb_athreads;
424
425 s->bl = -bl;
426 s->rl = -rl;
427 s->bh = -bh;
428 s->rh = -rh;
429 }
430
431 ff_filter_execute(ctx, s->do_slice, frame, NULL, nb_threads);
432
433 return ff_filter_frame(ctx->outputs[0], frame);
434}
435
451
453{
454 AVFilterContext *ctx = inlink->dst;
455 ColorCorrectContext *s = ctx->priv;
457
458 s->depth = desc->comp[0].depth;
459 s->max = (1 << s->depth) - 1;
460 s->imax = 1.f / s->max;
461 s->do_slice = s->depth <= 8 ? colorcorrect_slice8 : colorcorrect_slice16;
462
463 s->uhistogram = av_calloc(s->max == 255 ? 256 : 65536, sizeof(*s->uhistogram));
464 if (!s->uhistogram)
465 return AVERROR(ENOMEM);
466
467 s->vhistogram = av_calloc(s->max == 255 ? 256 : 65536, sizeof(*s->vhistogram));
468 if (!s->vhistogram)
469 return AVERROR(ENOMEM);
470
471 s->analyzeret = av_calloc(inlink->h, sizeof(*s->analyzeret));
472 if (!s->analyzeret)
473 return AVERROR(ENOMEM);
474
475 s->chroma_w = 1 << desc->log2_chroma_w;
476 s->chroma_h = 1 << desc->log2_chroma_h;
477 s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
478 s->planeheight[0] = s->planeheight[3] = inlink->h;
479 s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
480 s->planewidth[0] = s->planewidth[3] = inlink->w;
481
482 return 0;
483}
484
486{
487 ColorCorrectContext *s = ctx->priv;
488
489 av_freep(&s->analyzeret);
490 av_freep(&s->uhistogram);
491 av_freep(&s->vhistogram);
492}
493
495 {
496 .name = "default",
497 .type = AVMEDIA_TYPE_VIDEO,
499 .filter_frame = filter_frame,
500 .config_props = config_input,
501 },
502};
503
504#define OFFSET(x) offsetof(ColorCorrectContext, x)
505#define VF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
506
508 { "rl", "set the red shadow spot", OFFSET(rl), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
509 { "bl", "set the blue shadow spot", OFFSET(bl), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
510 { "rh", "set the red highlight spot", OFFSET(rh), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
511 { "bh", "set the blue highlight spot", OFFSET(bh), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, VF },
512 { "saturation", "set the amount of saturation", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl=1}, -3, 3, VF },
513 { "analyze", "set the analyze mode", OFFSET(analyze), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_ANALYZE-1, VF, .unit = "analyze" },
514 { "manual", "manually set options", 0, AV_OPT_TYPE_CONST, {.i64=MANUAL}, 0, 0, VF, .unit = "analyze" },
515 { "average", "use average pixels", 0, AV_OPT_TYPE_CONST, {.i64=AVERAGE}, 0, 0, VF, .unit = "analyze" },
516 { "minmax", "use minmax pixels", 0, AV_OPT_TYPE_CONST, {.i64=MINMAX}, 0, 0, VF, .unit = "analyze" },
517 { "median", "use median pixels", 0, AV_OPT_TYPE_CONST, {.i64=MEDIAN}, 0, 0, VF, .unit = "analyze" },
518 { NULL }
519};
520
522
524 .p.name = "colorcorrect",
525 .p.description = NULL_IF_CONFIG_SMALL("Adjust color white balance selectively for blacks and whites."),
526 .p.priv_class = &colorcorrect_class,
528 .priv_size = sizeof(ColorCorrectContext),
529 .uninit = uninit,
533 .process_command = ff_filter_process_command,
534};
static int config_input(AVFilterLink *inlink)
const FFFilter ff_vf_colorcorrect
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1079
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:917
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
static IPT saturation(const CmsCtx *ctx, IPT ipt)
Definition cms.c:559
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
Clip a signed integer to an unsigned power of two range.
Definition common.h:280
#define av_clip_uint8
Definition common.h:106
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#define max(a, b)
static AVFrame * frame
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ 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_FLOAT
Underlying C type is float.
Definition opt.h:270
#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(e)
Definition error.h:45
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_cold void uninit(AVBitStreamFilterContext *ctx)
const char * arg
Definition jacosubdec.c:66
#define VF
Definition af_afir.c:733
#define FILTER_INPUTS(array)
Definition filters.h:279
#define FILTER_OUTPUTS(array)
Definition filters.h:280
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:789
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition filters.h:59
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:259
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:493
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
const char * desc
Definition libsvtav1.c:83
#define FFMIN(a, b)
Definition macros.h:49
#define FFMAX(a, b)
Definition macros.h:47
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition mpeg12dec.c:1711
static int analyze(const uint8_t *buf, int size, int packet_size, int probe)
Definition mpegts.c:644
AVOptions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:559
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:547
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:548
#define AV_PIX_FMT_YUV440P12
Definition pixfmt.h:554
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:546
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:601
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:604
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:599
#define AV_PIX_FMT_YUVA422P9
Definition pixfmt.h:597
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:545
#define AV_PIX_FMT_YUVA420P9
Definition pixfmt.h:596
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:600
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition pixfmt.h:283
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
#define AV_PIX_FMT_YUVA422P12
Definition pixfmt.h:602
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:557
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:560
#define AV_PIX_FMT_YUV440P10
Definition pixfmt.h:550
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:606
#define AV_PIX_FMT_YUVA422P16
Definition pixfmt.h:605
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:598
#define AV_PIX_FMT_YUVA444P12
Definition pixfmt.h:603
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:561
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
#define MEDIAN(x)
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
int(* do_slice)(AVFilterContext *s, void *arg, int jobnr, int nb_jobs)
#define av_freep(p)
static int imax(const int a, const int b)
Definition internal.h:178
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
static enum AVPixelFormat pixel_fmts[]
Definition vf_amplify.c:52
static int minmax_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int colorcorrect_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVOption colorcorrect_options[]
#define PROCESS()
static int average_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static int median_8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVFilterPad colorcorrect_inputs[]
static int minmax_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold int config_input(AVFilterLink *inlink)
static av_cold void uninit(AVFilterContext *ctx)
static int median_16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define OFFSET(x)
AnalyzeMode
@ MANUAL
@ MINMAX
@ AVERAGE
@ NB_ANALYZE
static int colorcorrect_slice8(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int(*const analyze_slice[NB_ANALYZE][2])(AVFilterContext *s, void *arg, int jobnr, int nb_jobs)
static int average_slice16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition dec.c:851