FFmpeg
Loading...
Searching...
No Matches
vf_gainmap.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/**
20 * @file
21 * Filter to compute an HDR gain map from a base and alternate rendition.
22 */
23
24#include <float.h>
25#include <math.h>
26
27#include "libavutil/csp.h"
28#include "libavutil/gain_map.h"
29#include "libavutil/internal.h"
31#include "libavutil/mem.h"
32#include "libavutil/opt.h"
33#include "libavutil/pixdesc.h"
34
35#include "avfilter.h"
36#include "colorspace.h"
37#include "filters.h"
38#include "formats.h"
39#include "framesync.h"
40#include "video.h"
41
42#define SDR_DIFFUSE_WHITE 203.0
43
45 GAINMAP_CSP_BASE, ///< apply the map in the base rendition's space
46 GAINMAP_CSP_ALT, ///< apply it in the alternate rendition's space
48};
49
51 GAINMAP_RGB, ///< one channel per component
52 GAINMAP_LUMA, ///< single channel, from the luminance
53 GAINMAP_MAXRGB, ///< single channel, from max(R,G,B)
55};
56
64
65typedef struct GainMapEOTF {
68 double Lw;
69
70#define GAINMAP_LUT_SIZE 1025
71 float lut[GAINMAP_LUT_SIZE + 1]; /* extra padding entry */
73
74typedef struct GainMapContext {
75 const AVClass *class;
77
78 /* Filter options */
79 int mode;
88
91 int nb_threads; /* for slice threading */
92 int convert; /* colorspace conversion needed */
93 int sign; /* sign(alt_peak - base_peak) */
94
95 /* Colorspace parameters */
98 float rgb2y[3];
99 float rgb2rgb[3][3];
100
101 /* Quantization parameters, either static or recomputed dynamically */
102 float quant_scale[3];
103 float quant_offset[3];
104 float quant_gamma[3];
105
106 /* Measured frame statistics */
107 float (*slice_min)[3]; /* for MEASURE_MIN */
108 float (*slice_max)[3]; /* for MEASURE_MAX */
109 double (*slice_sum)[3]; /* for MEASURE_GAMMA */
111
112 /* Generated gain map parameters (recomputed per frame) */
115
116typedef struct ThreadData {
117 AVFrame *out;
118 const AVFrame *base, *alt;
119} ThreadData;
120
121#define OFFSET(x) offsetof(GainMapContext, x)
122#define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
123
124static const AVOption gainmap_options[] = {
125 { "mode", "quantity the gain is computed over", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = GAINMAP_RGB }, 0, GAINMAP_MODE_NB - 1, FLAGS, .unit = "mode" },
126 { "rgb", "one gain channel per component", 0, AV_OPT_TYPE_CONST, { .i64 = GAINMAP_RGB }, 0, 0, FLAGS, .unit = "mode" },
127 { "luma", "single gain channel, from luminance", 0, AV_OPT_TYPE_CONST, { .i64 = GAINMAP_LUMA }, 0, 0, FLAGS, .unit = "mode" },
128 { "maxrgb", "single gain channel, from max(R,G,B)", 0, AV_OPT_TYPE_CONST, { .i64 = GAINMAP_MAXRGB }, 0, 0, FLAGS, .unit = "mode" },
129 { "colorspace", "rendition whose colour space the map is applied in", OFFSET(colorspace), AV_OPT_TYPE_INT, { .i64 = GAINMAP_CSP_BASE }, 0, GAINMAP_CSP_NB - 1, FLAGS, .unit = "colorspace" },
130 { "base", "the base rendition's colour space", 0, AV_OPT_TYPE_CONST, { .i64 = GAINMAP_CSP_BASE }, 0, 0, FLAGS, .unit = "colorspace" },
131 { "alternate", "the alternate rendition's colour space", 0, AV_OPT_TYPE_CONST, { .i64 = GAINMAP_CSP_ALT }, 0, 0, FLAGS, .unit = "colorspace" },
132 { "min", "override lower bound on the encoded gain, in log2 space", OFFSET(gain_min), AV_OPT_TYPE_RATIONAL, { .dbl = NAN }, -32.0, 32.0, FLAGS },
133 { "max", "override upper bound on the encoded gain, in log2 space", OFFSET(gain_max), AV_OPT_TYPE_RATIONAL, { .dbl = NAN }, -32.0, 32.0, FLAGS },
134 { "gamma", "override encoding gamma of the stored map (default: measured)", OFFSET(gamma), AV_OPT_TYPE_RATIONAL, { .dbl = NAN }, 0.0001, 100.0, FLAGS },
135 { "base_offset", "constant added to the base rendition", OFFSET(base_offset), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 / 64.0 }, 1e-6, 1.0, FLAGS },
136 { "alt_offset", "constant added to the alternate rendition", OFFSET(alt_offset), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 / 64.0 }, 1e-6, 1.0, FLAGS },
137 { "base_nits", "override input luminance of the base rendition", OFFSET(base_nits), AV_OPT_TYPE_RATIONAL, { .dbl = NAN }, 1.0, 10000.0, FLAGS },
138 { "alt_nits", "override input luminance of the alternate rendition", OFFSET(alt_nits), AV_OPT_TYPE_RATIONAL, { .dbl = NAN }, 1.0, 10000.0, FLAGS },
139 { NULL }
140};
141
143
144/* Quantize to a fixed point representation with the correct rounding mode */
145static AVRational quantq(double x, enum AVRounding rnd)
146{
147 const int scale = 1 << 22;
148
149 switch (rnd) {
150 case AV_ROUND_DOWN: x = floor(x * scale); break;
151 case AV_ROUND_UP: x = ceil(x * scale); break;
152 case AV_ROUND_NEAR_INF: x = round(x * scale); break;
153 default: av_unreachable("not used / implemented");
154 }
155
156 AVRational q;
157 av_reduce(&q.num, &q.den, x, scale, INT_MAX);
158 return q;
159}
160
162{
163 GainMapContext *s = ctx->priv;
164 if (av_cmp_q(max, min) <= 0) {
165 /* Nothing to quantize; flat gain map */
166 s->quant_scale[ch] = s->quant_offset[ch] = 0.0f;
167 max = min; /* sanity */
168 } else {
169 const float minf = av_q2d(min), maxf = av_q2d(max);
170 s->quant_scale[ch] = 1.0f / (maxf - minf);
171 s->quant_offset[ch] = -minf * s->quant_scale[ch];
172 }
173
174 s->params.channels[ch].gain_map_min = min;
175 s->params.channels[ch].gain_map_max = max;
176 av_log(ctx, AV_LOG_TRACE, "channel %d: measured min=%g max=%g\n",
177 ch, av_q2d(min), av_q2d(max));
178}
179
180static void setup_gamma(AVFilterContext *ctx, int ch, AVRational gamma)
181{
182 GainMapContext *s = ctx->priv;
183 s->quant_gamma[ch] = av_q2d(gamma);
184 s->params.channels[ch].gamma = gamma;
185 av_log(ctx, AV_LOG_TRACE, "channel %d: measured gamma=%g\n",
186 ch, s->quant_gamma[ch]);
187}
188
190{
191 GainMapContext *s = ctx->priv;
192
193 if (av_cmp_q(s->gain_min, s->gain_max) >= 0) {
194 av_log(ctx, AV_LOG_ERROR, "min (%g) must be below max (%g)\n",
195 av_q2d(s->gain_min), av_q2d(s->gain_max));
196 return AVERROR(EINVAL);
197 }
198
199 s->nb_channels = s->mode == GAINMAP_RGB ? 3 : 1;
200 if (!s->gain_min.den)
201 s->measure |= MEASURE_MIN;
202 if (!s->gain_max.den)
203 s->measure |= MEASURE_MAX;
204 if (!s->gamma.den)
205 s->measure |= MEASURE_GAMMA;
206 if (s->measure) {
207 av_log(ctx, AV_LOG_VERBOSE, "Using two passes to measure gain map "
208 "parameters from the input frame.\n");
209 }
210
211 s->params = (AVGainMapParams) {
212 .version = 0,
213 .nb_channels = s->nb_channels,
214 .use_base_color_space = s->colorspace == GAINMAP_CSP_BASE,
215 /* payload metadata recomputed per frame */
216 };
217
218 for (int c = 0; c < s->nb_channels; c++) {
219 struct AVGainMapChannel *ch = &s->params.channels[c];
220 ch->base_offset = s->base_offset;
221 ch->alternate_offset = s->alt_offset;
222 if (!(s->measure & MEASURE_RANGE))
223 setup_range(ctx, c, s->gain_min, s->gain_max);
224 if (!(s->measure & MEASURE_GAMMA))
225 setup_gamma(ctx, c, s->gamma);
226 }
227
228 return 0;
229}
230
232 AVFilterFormatsConfig **cfg_in,
233 AVFilterFormatsConfig **cfg_out)
234{
235 const GainMapContext *s = ctx->priv;
236 enum AVPixelFormat in_fmt, out_fmt;
237 int ret;
238
239 in_fmt = AV_PIX_FMT_GBRPF32;
240 out_fmt = s->nb_channels == 1 ? AV_PIX_FMT_GRAYF32 : AV_PIX_FMT_GBRPF32;
241
242 ret = ff_formats_ref(ff_make_formats_list_singleton(out_fmt), &cfg_out[0]->formats);
243 if (ret < 0)
244 return ret;
245
246 return ff_set_common_formats2(ctx, cfg_in, cfg_out,
248}
249
250static double frame_luminance(const AVFrame *frame)
251{
252 const AVFrameSideData *sd;
254 if (sd) {
256 mdm = (const AVMasteringDisplayMetadata *) sd->data;
257 if (mdm->has_luminance && mdm->max_luminance.num > 0)
258 return av_q2d(mdm->max_luminance);
259 }
260
261 switch (frame->color_trc) {
262 case AVCOL_TRC_SMPTE2084: return 10000.0;
263 case AVCOL_TRC_ARIB_STD_B67: return 1000.0;
264 default: return SDR_DIFFUSE_WHITE;
265 }
266}
267
269 av_csp_eotf_function eotf, double Lw)
270{
271 if (trc == tf->trc && Lw == tf->Lw)
272 return; /* no change */
273 tf->trc = trc;
274 tf->Lw = Lw;
275
276 switch (trc) {
277 /* EOTFs that are safe to collapse into a 1D LUT */
278 case AVCOL_TRC_BT709:
283 case AVCOL_TRC_LINEAR:
289 case AVCOL_TRC_SMPTE2084: {
290 for (int i = 0; i < GAINMAP_LUT_SIZE; i++) {
291 double x[3] = { i / (GAINMAP_LUT_SIZE - 1.0) };
292 eotf(Lw, 0.0, x);
293 tf->lut[i] = x[0] / SDR_DIFFUSE_WHITE; /* normalize */
294 }
295
297 tf->eotf = NULL;
298 break;
299 }
300 /* EOTFs that use the av_csp_eotf_function fallback */
301 case AVCOL_TRC_ARIB_STD_B67: /* nontrivial OOTF */
302 case AVCOL_TRC_SMPTE428: /* different normalization per channel */
303 default:
304 tf->eotf = eotf;
305 break;
306 }
307}
308
309static const char *unknown_if_null(const char *s)
310{
311 return s ? s : "unknown";
312}
313
314/* Run per frame, since trc/primaries are not (yet) link-level properties */
316{
317 GainMapContext *const s = ctx->priv;
318 av_csp_eotf_function base_eotf = av_csp_itu_eotf(base->color_trc);
319 av_csp_eotf_function alt_eotf = av_csp_itu_eotf(alt->color_trc);
320 if (!base_eotf || !alt_eotf) {
321 av_log(ctx, AV_LOG_ERROR, "Unknown transfer: base=%s, alternate=%s\n",
324 return AVERROR(EINVAL);
325 }
326
327 const AVColorPrimariesDesc *base_desc, *alt_desc;
328 base_desc = av_csp_primaries_desc_from_id(base->color_primaries);
329 alt_desc = av_csp_primaries_desc_from_id(alt->color_primaries);
330 if (!base_desc || !alt_desc) {
331 av_log(ctx, AV_LOG_ERROR, "Unknown primaries: base=%s, alternate=%s\n",
333 unknown_if_null(av_color_primaries_name(alt->color_primaries)));
334 return AVERROR(EINVAL);
335 }
336
337 double base_lw = s->base_nits.den ? av_q2d(s->base_nits) : frame_luminance(base);
338 double alt_lw = s->alt_nits.den ? av_q2d(s->alt_nits) : frame_luminance(alt);
339 double base_headroom = fmax(log2(base_lw / SDR_DIFFUSE_WHITE), 0.0);
340 double alt_headroom = fmax(log2(alt_lw / SDR_DIFFUSE_WHITE), 0.0);
341 s->params.base_hdr_headroom = quantq(base_headroom, AV_ROUND_NEAR_INF);
342 s->params.alternate_hdr_headroom = quantq(alt_headroom, AV_ROUND_NEAR_INF);
343 s->sign = FFDIFFSIGN(alt_headroom, base_headroom);
344 if (!s->sign) {
345 /* No-op, set up empty gain map */
346 for (int i = 0; i < s->nb_channels; i++) {
347 setup_range(ctx, i, (AVRational) { 0, 1 }, (AVRational) { 0, 1 });
348 setup_gamma(ctx, i, (AVRational) { 1, 1 });
349 }
350
352 "Base and alternate renditions have the same peak "
353 "luminance (%g nits), gain map will be empty\n", base_lw);
354 return 0;
355 } else {
356 av_log(ctx, AV_LOG_DEBUG, "Base peak: %g nits, alternate peak: %g nits\n",
357 base_lw, alt_lw);
358 }
359
360 update_eotf(&s->base_eotf, base->color_trc, base_eotf, base_lw);
361 update_eotf(&s->alt_eotf, alt->color_trc, alt_eotf, alt_lw);
362
363 /* Assume conversion from alt to base */
364 if (s->colorspace == GAINMAP_CSP_ALT)
365 FFSWAP(const AVColorPrimariesDesc *, base_desc, alt_desc);
366
367 double rgb2xyz[3][3];
368 ff_fill_rgb2xyz_table(&base_desc->prim, &base_desc->wp, rgb2xyz);
369 for (int i = 0; i < 3; i++)
370 s->rgb2y[i] = rgb2xyz[1][i] / av_q2d(base_desc->wp.y);
371
372 s->convert = base->color_primaries != alt->color_primaries;
373 if (s->convert) {
374 /* Note: Ignores whitepoint differences (chromatic adaptation) */
375 double xyz2rgb[3][3], rgb2rgb[3][3];
376 ff_fill_rgb2xyz_table(&base_desc->prim, &base_desc->wp, rgb2xyz);
378 ff_fill_rgb2xyz_table(&alt_desc->prim, &alt_desc->wp, rgb2xyz);
379 ff_matrix_mul_3x3(rgb2rgb, rgb2xyz, xyz2rgb);
380 for (int i = 0; i < 3; i++)
381 for (int j = 0; j < 3; j++)
382 s->rgb2rgb[i][j] = (float) rgb2rgb[i][j];
383 } else {
384 memset(s->rgb2rgb, 0, sizeof(s->rgb2rgb));
385 for (int i = 0; i < 3; i++)
386 s->rgb2rgb[i][i] = 1.0f;
387 }
388
389 return 0;
390}
391
392static av_always_inline float quantize(float gain, float scale, float offset, float gamma)
393{
394 const float norm = av_clipf(scale * gain + offset, 0.0f, 1.0f);
395 return gamma == 1.0f ? norm : powf(norm, gamma);
396}
397
398static av_always_inline void
399get_pixel(const GainMapContext *s, float dst[3],
400 const float *restrict const src[3], int x, int alt)
401{
402 const GainMapEOTF *const tf = alt ? &s->alt_eotf : &s->base_eotf;
403 float rgb[3];
404
405 /* Linearize to normalized RGB */
406 if (tf->eotf) {
407 double rgbd[3] = { src[0][x], src[1][x], src[2][x] };
408 tf->eotf(tf->Lw, 0.0, rgbd);
409 for (int i = 0; i < 3; i++)
410 rgb[i] = rgbd[i] / SDR_DIFFUSE_WHITE;
411 } else {
412 for (int i = 0; i < 3; i++) {
413 const float fx = av_clipf(src[i][x], 0.0f, 1.0f) * (GAINMAP_LUT_SIZE - 1.0);
414 const int ix = (int) fx;
415 const float lo = tf->lut[ix];
416 const float hi = tf->lut[ix + 1];
417 rgb[i] = lo + (fx - ix) * (hi - lo);
418 }
419 }
420
421 /* Convert to correct colorspace if needed */
422 if (s->convert && (s->colorspace == GAINMAP_CSP_ALT) != alt) {
423 const float r = rgb[0], g = rgb[1], b = rgb[2];
424 for (int i = 0; i < 3; i++) {
425 dst[i] = fmaxf(r * s->rgb2rgb[i][0] +
426 g * s->rgb2rgb[i][1] +
427 b * s->rgb2rgb[i][2], 0.0f);
428 }
429 } else {
430 for (int i = 0; i < 3; i++)
431 dst[i] = fmaxf(rgb[i], 0.0f);
432 }
433}
434
435/* GBRP plane order */
436static const int gbr_order[3] = { 2, 0, 1 };
437
438static av_always_inline int
439slice_internal(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int quant)
440{
441 GainMapContext *s = ctx->priv;
442 const ThreadData *td = arg;
443 const AVFrame *base = td->base, *alt = td->alt, *out = td->out;
444
445 const float *restrict scale = s->quant_scale;
446 const float *restrict offset = s->quant_offset;
447 const float *restrict gamma = s->quant_gamma;
448
449 /* Normalize both to the base colorspace */
450 const float base_off = av_q2d(s->base_offset);
451 const float alt_off = av_q2d(s->alt_offset);
452 const float sign = s->sign;
453
454 const int y_start = ff_slice_pos(out->height, jobnr, nb_jobs);
455 const int y_end = ff_slice_pos(out->height, jobnr + 1, nb_jobs);
456 const int width = out->width;
457 const int mode = s->mode;
458 const int nb_ch = s->nb_channels;
459
460 float min[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
461 float max[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
462 double sum[3] = { 0.0, 0.0, 0.0 };
463
464 for (int y = y_start; y < y_end; y++) {
465 const float *restrict b_row[3], *restrict a_row[3];
466 for (int i = 0; i < 3; i++) {
467 const int p = gbr_order[i];
468 b_row[i] = (const float *) (base->data[p] + y * base->linesize[p]);
469 a_row[i] = (const float *) ( alt->data[p] + y * alt->linesize[p]);
470 }
471
472 float *restrict out_row[3];
473 for (int i = 0; i < nb_ch; i++) {
474 const int p = nb_ch == 1 ? 0 : gbr_order[i];
475 out_row[i] = (float *) (out->data[p] + y * out->linesize[p]);
476 }
477
478 for (int x = 0; x < width; x++) {
479 float b[3], a[3], gain[3];
480 get_pixel(s, b, b_row, x, 0);
481 get_pixel(s, a, a_row, x, 1);
482
483 #define GAIN(a, b) (sign * log2f(((a) + alt_off) / ((b) + base_off)))
484 switch (mode) {
485 case GAINMAP_MAXRGB: {
486 const float max_a = fmaxf(fmaxf(a[0], a[1]), a[2]);
487 const float max_b = fmaxf(fmaxf(b[0], b[1]), b[2]);
488 gain[0] = GAIN(max_a, max_b);
489 break;
490 }
491 case GAINMAP_LUMA: {
492 const float y_a = s->rgb2y[0] * a[0] + s->rgb2y[1] * a[1] + s->rgb2y[2] * a[2];
493 const float y_b = s->rgb2y[0] * b[0] + s->rgb2y[1] * b[1] + s->rgb2y[2] * b[2];
494 gain[0] = GAIN(y_a, y_b);
495 break;
496 }
497 case GAINMAP_RGB:
498 gain[0] = GAIN(a[0], b[0]);
499 gain[1] = GAIN(a[1], b[1]);
500 gain[2] = GAIN(a[2], b[2]);
501 break;
502 }
503 #undef GAIN
504
505 if (quant) {
506 for (int i = 0; i < nb_ch; i++)
507 out_row[i][x] = quantize(gain[i], scale[i], offset[i], gamma[i]);
508 } else {
509 for (int i = 0; i < nb_ch; i++) {
510 out_row[i][x] = gain[i];
511 min[i] = fminf(min[i], gain[i]);
512 max[i] = fmaxf(max[i], gain[i]);
513 sum[i] += gain[i];
514 }
515 }
516
517 }
518 }
519
520 for (int i = 0; !quant && i < 3; i++) {
521 s->slice_min[jobnr][i] = min[i];
522 s->slice_max[jobnr][i] = max[i];
523 s->slice_sum[jobnr][i] = sum[i];
524 }
525
526 return 0;
527}
528
529static int slice_gain(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
530{
531 return slice_internal(ctx, arg, jobnr, nb_jobs, 0);
532}
533
534static int slice_gain_quant(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
535{
536 return slice_internal(ctx, arg, jobnr, nb_jobs, 1);
537}
538
539static int slice_quant(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
540{
541 const ThreadData *td = arg;
542 const GainMapContext *s = ctx->priv;
543 const AVFrame *out = td->out;
544
545 const float *restrict scale = s->quant_scale;
546 const float *restrict offset = s->quant_offset;
547 const float *restrict gamma = s->quant_gamma;
548
549 const int y_start = ff_slice_pos(out->height, jobnr, nb_jobs);
550 const int y_end = ff_slice_pos(out->height, jobnr + 1, nb_jobs);
551 const int width = out->width;
552 const int nb_ch = s->nb_channels;
553
554 for (int y = y_start; y < y_end; y++) {
555 float *restrict out_row[3];
556 for (int i = 0; i < nb_ch; i++) {
557 const int p = nb_ch == 1 ? 0 : gbr_order[i];
558 out_row[i] = (float *) (out->data[p] + y * out->linesize[p]);
559 }
560
561 for (int x = 0; x < width; x++) {
562 for (int i = 0; i < nb_ch; i++)
563 out_row[i][x] = quantize(out_row[i][x], scale[i], offset[i], gamma[i]);
564 }
565 }
566
567 return 0;
568}
569
570static void choose_quant_params(AVFilterContext *ctx, const AVFrame *out, int nb_jobs)
571{
572 GainMapContext *s = ctx->priv;
573 float frame_min[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
574 float frame_max[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
575 double frame_sum[3] = { 0.0, 0.0, 0.0 };
576
577 for (int j = 0; j < nb_jobs; j++) {
578 for (int i = 0; i < s->nb_channels; i++) {
579 frame_min[i] = fminf(frame_min[i], s->slice_min[j][i]);
580 frame_max[i] = fmaxf(frame_max[i], s->slice_max[j][i]);
581 frame_sum[i] += s->slice_sum[j][i];
582 }
583 }
584
585 for (int i = 0; i < s->nb_channels; i++) {
586 AVRational min = s->gain_min, max = s->gain_max;
587 if (s->measure & MEASURE_MIN)
588 min = quantq(frame_min[i], AV_ROUND_DOWN);
589 if (s->measure & MEASURE_MAX)
590 max = quantq(frame_max[i], AV_ROUND_UP);
591 if (s->measure & MEASURE_RANGE)
592 setup_range(ctx, i, min, max);
593
594 if (!(s->measure & MEASURE_GAMMA))
595 continue;
596
597 const int64_t nb_pixels = (int64_t) out->width * out->height;
598 const double mean = frame_sum[i] / nb_pixels;
599 const double mean_quant = s->quant_scale[i] * mean + s->quant_offset[i];
600
601 /**
602 * Choose gamma such that mean_quant ^ gamma = 0.5; clamp to a sane
603 * value range of [1/8, 8] to prevent degenerate encodings. A gamma
604 * of >8 would collapse half the encoding space into a single 8-bit
605 * value, at which point we're losing more then gaining, and a value
606 * of <1/8 limits the amount by which a single high outlier pixel
607 * can determine the overall encoding gamma.
608 *
609 * We also clamp the mean to [0.01, 0.99] to prevent numerical explosion
610 * in the case that the mean is very close to 0 or 1. This is a looser
611 * bound than the final gamma clamp, so the exact values chosen do not
612 * matter as much.
613 */
614 double gamma = log(0.5) / log(av_clipd(mean_quant, 0.01, 0.99));
615 setup_gamma(ctx, i, quantq(av_clipd(gamma, 1/8.0, 8.0), AV_ROUND_NEAR_INF));
616 }
617}
618
620{
621 AVFilterContext *ctx = fs->parent;
622 GainMapContext *s = ctx->priv;
623 AVFilterLink *outlink = ctx->outputs[0];
624 AVFrame *base, *alt, *out;
625
626 int ret = ff_framesync_dualinput_get(fs, &base, &alt);
627 if (ret < 0)
628 return ret;
629 if (!base || !alt)
630 return AVERROR_BUG;
631
632 ret = setup_colorspace(ctx, base, alt);
633 if (ret < 0)
634 return ret;
635
636 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
637 if (!out)
638 return AVERROR(ENOMEM);
640 av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
642
643 out->color_trc = AVCOL_TRC_UNSPECIFIED;
644 out->color_primaries = AVCOL_PRI_UNSPECIFIED;
645 out->colorspace = AVCOL_SPC_UNSPECIFIED;
646 out->color_range = AVCOL_RANGE_JPEG;
647
648 ThreadData td = {
649 .out = out,
650 .base = base,
651 .alt = alt,
652 };
653
654 if (!s->sign) { /* no-op */
655 for (int i = 0; i < s->nb_channels; i++)
656 memset(out->data[i], 0, out->height * out->linesize[i]);
657 goto skip;
658 }
659
660 const int nb_jobs = FFMIN(outlink->h, s->nb_threads);
662 &td, NULL, nb_jobs);
663 if (ret < 0)
664 goto fail;
665
666 if (s->measure) {
667 choose_quant_params(ctx, out, nb_jobs);
668 ret = ff_filter_execute(ctx, slice_quant, &td, NULL, nb_jobs);
669 if (ret < 0)
670 goto fail;
671 }
672
673skip:;
675 params = av_gain_map_params_create_side_data(&out->side_data, &out->nb_side_data);
676 if (!params) {
677 ret = AVERROR(ENOMEM);
678 goto fail;
679 }
680
681 *params = s->params;
683 return AVERROR_BUG; /* should never happen */
684
685 return ff_filter_frame(outlink, out);
686
687fail:
689 return ret;
690}
691
692static int config_output(AVFilterLink *outlink)
693{
694 AVFilterContext *ctx = outlink->src;
695 GainMapContext *s = ctx->priv;
696 AVFilterLink *base = ctx->inputs[0];
697 AVFilterLink *alt = ctx->inputs[1];
698 int ret;
699
700 if (base->w != alt->w || base->h != alt->h) {
702 "Input dimensions must match (%dx%d != %dx%d)\n",
703 base->w, base->h, alt->w, alt->h);
704 return AVERROR(EINVAL);
705 }
706
707 outlink->w = base->w;
708 outlink->h = base->h;
710 outlink->color_range = AVCOL_RANGE_JPEG;
711
712 s->nb_threads = ff_filter_get_nb_threads(ctx);
713 s->slice_min = av_calloc(s->nb_threads, sizeof(*s->slice_min));
714 s->slice_max = av_calloc(s->nb_threads, sizeof(*s->slice_max));
715 s->slice_sum = av_calloc(s->nb_threads, sizeof(*s->slice_sum));
716 if (!s->slice_min || !s->slice_max || !s->slice_sum)
717 return AVERROR(ENOMEM);
718
719 ret = ff_framesync_init_dualinput(&s->fs, ctx);
720 if (ret < 0)
721 return ret;
722
723 s->fs.on_event = process_frame;
724 return ff_framesync_configure(&s->fs);
725}
726
728{
729 GainMapContext *s = ctx->priv;
730 return ff_framesync_activate(&s->fs);
731}
732
734{
735 GainMapContext *s = ctx->priv;
737 av_freep(&s->slice_min);
738 av_freep(&s->slice_max);
739 av_freep(&s->slice_sum);
740}
741
742static const AVFilterPad gainmap_inputs[] = {
743 {
744 .name = "base",
745 .type = AVMEDIA_TYPE_VIDEO,
746 },
747 {
748 .name = "alternate",
749 .type = AVMEDIA_TYPE_VIDEO,
750 },
751};
752
753static const AVFilterPad gainmap_outputs[] = {
754 {
755 .name = "default",
756 .type = AVMEDIA_TYPE_VIDEO,
757 .config_props = config_output,
758 },
759};
760
762 .p.name = "gainmap",
763 .p.description = NULL_IF_CONFIG_SMALL("Generate a gain map from a base/alternate pair."),
764 .p.priv_class = &gainmap_class,
766 .preinit = gainmap_framesync_preinit,
767 .priv_size = sizeof(GainMapContext),
768 .init = init,
769 .uninit = uninit,
774};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
SwsAArch64OpImplParams params
Definition ops.c:51
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
#define MEASURE_ALL
const FFFilter ff_vf_gainmap
Definition vf_gainmap.c:761
#define log2(x)
Definition math.h:26
static FILE * out
static AVFormatContext * ctx
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition avassert.h:109
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition avfilter.c:1696
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition avfilter.c:846
Main libavfilter public API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define fs(width, name, subs,...)
Definition cbs_vp9.c:200
#define rnd
Definition checkasm.h:137
#define FLAGS
Definition cmdutils.c:596
#define av_clipd
Definition common.h:148
#define av_clipf
Definition common.h:145
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
Colorspace value utility functions for libavutil.
static __device__ float ceil(float a)
static __device__ float floor(float a)
#define min(a, b)
#define max(a, b)
static AVFrame * frame
float fminf(float, float)
double fmax(double, double)
float fmaxf(float, float)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static const uint8_t gbr_order[4]
Definition exrenc.c:59
static const char * unknown_if_null(const char *str)
static av_always_inline int process_frame(AVTextFormatContext *tfc, InputFile *ifile, AVFrame *frame, const AVPacket *pkt, int *packet_new)
Definition ffprobe.c:1595
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add ref as a new reference to formats.
Definition formats.c:756
AVFilterFormats * ff_make_formats_list_singleton(int fmt)
Equivalent to ff_make_format_list({const int[]}{ fmt, -1 })
Definition formats.c:596
int ff_set_common_formats2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, AVFilterFormats *formats)
Definition formats.c:1137
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition framesync.c:137
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Definition framesync.c:390
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition framesync.c:352
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition framesync.c:372
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition framesync.c:301
#define FRAMESYNC_DEFINE_CLASS(name, context, field)
Definition framesync.h:352
#define fail
Definition test.h:479
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition opt.h:279
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
#define AVERROR(e)
Definition error.h:45
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition frame.c:659
void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd, int props)
Remove and free all side data instances that match any of the given side data properties.
Definition side_data.c:124
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
@ AV_SIDE_DATA_PROP_COLOR_DEPENDENT
Side data depends on the video color space.
Definition frame.h:368
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition frame.h:120
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition log.h:236
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#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
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
Definition csp.c:95
void(* av_csp_eotf_function)(double Lw, double Lb, double c[3])
Function pointer representing an ITU EOTF transfer for a given reference display configuration.
Definition csp.h:178
av_csp_eotf_function av_csp_itu_eotf(enum AVColorTransferCharacteristic trc)
Returns the ITU EOTF corresponding to a given TRC.
Definition csp.c:684
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition rational.c:35
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition rational.h:104
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition rational.h:89
AVRounding
Rounding methods.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_UP
Round toward +infinity.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
int a
#define r
Definition input.c:42
#define b
Definition input.c:43
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
unsigned offset
Definition libaomenc.c:763
const char * arg
Definition jacosubdec.c:65
void ff_matrix_mul_3x3(double dst[3][3], const double src1[3][3], const double src2[3][3])
Definition colorspace.c:54
void ff_fill_rgb2xyz_table(const AVPrimaryCoefficients *coeffs, const AVWhitepointCoefficients *wp, double rgb2xyz[3][3])
Definition colorspace.c:79
void ff_matrix_invert_3x3(const double in[3][3], double out[3][3])
Definition colorspace.c:27
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
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:763
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define av_always_inline
Definition attributes.h:72
#define av_cold
Definition attributes.h:117
int av_gain_map_params_validate(const AVGainMapParams *p)
Returns >= 0 if the given AVGainMapParams struct contains valid data; or a negative AVERROR otherwise...
Definition gain_map.c:46
AVGainMapParams * av_gain_map_params_create_side_data(AVFrameSideData ***fsd, int *nb_sd)
Allocate and add an AVGainMapParams structure to an existing AVFrameSideData array as AV_FRAME_DATA_G...
Definition gain_map.c:98
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
Definition log.c:450
#define FFSWAP(type, a, b)
Definition macros.h:52
#define FFMIN(a, b)
Definition macros.h:49
#define FFDIFFSIGN(x, y)
Comparator.
Definition macros.h:45
#define NAN
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
AVOptions.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
Definition pixdesc.c:3827
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
Definition pixdesc.c:3794
#define AV_PIX_FMT_GBRPF32
Definition pixfmt.h:584
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783
#define AV_PIX_FMT_GRAYF32
Definition pixfmt.h:588
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:645
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition pixfmt.h:672
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition pixfmt.h:679
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition pixfmt.h:689
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition pixfmt.h:677
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
Definition pixfmt.h:685
@ AVCOL_TRC_SMPTE240M
Definition pixfmt.h:680
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition pixfmt.h:684
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition pixfmt.h:681
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition pixfmt.h:678
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition pixfmt.h:693
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
Definition pixfmt.h:691
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition pixfmt.h:688
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition pixfmt.h:686
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition pixfmt.h:687
@ AVCOL_TRC_UNSPECIFIED
Definition pixfmt.h:675
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition pixfmt.h:674
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:709
formats
Definition signature.h:47
AVRational y
Definition csp.h:57
Describe the class of an AVClass context structure.
Definition log.h:76
Struct that contains both white point location and primaries location, providing the complete descrip...
Definition csp.h:78
AVWhitepointCoefficients wp
Definition csp.h:79
AVPrimaryCoefficients prim
Definition csp.h:80
An instance of a filter.
Definition avfilter.h:273
Lists of formats / etc.
Definition avfilter.h:120
A filter pad used for either input or output.
Definition filters.h:40
Structure to hold side data for an AVFrame.
Definition frame.h:334
uint8_t * data
Definition frame.h:336
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
Parameters describing how to combine a gain map rendition with its base rendition to recover the alte...
Definition gain_map.h:39
Mastering display metadata capable of representing the color volume of the display used to master the...
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
AVOption.
Definition opt.h:428
Rational number (pair of numerator and denominator).
Definition rational.h:58
int num
Numerator.
Definition rational.h:59
int den
Denominator.
Definition rational.h:60
Frame sync structure.
Definition framesync.h:168
float rgb2y[3]
Definition vf_gainmap.c:98
enum GainMapMeasure measure
Definition vf_gainmap.c:110
double(* slice_sum)[3]
Definition vf_gainmap.c:109
AVRational gamma
Definition vf_gainmap.c:83
float(* slice_min)[3]
Definition vf_gainmap.c:107
FFFrameSync fs
Definition vf_gainmap.c:76
GainMapEOTF base_eotf
Definition vf_gainmap.c:96
float rgb2rgb[3][3]
Definition vf_gainmap.c:99
AVRational base_nits
Definition vf_gainmap.c:86
AVRational base_offset
Definition vf_gainmap.c:84
AVRational gain_max
Definition vf_gainmap.c:82
float(* slice_max)[3]
Definition vf_gainmap.c:108
AVGainMapParams params
Definition vf_gainmap.c:113
AVRational gain_min
Definition vf_gainmap.c:81
float quant_scale[3]
Definition vf_gainmap.c:102
AVRational alt_nits
Definition vf_gainmap.c:87
GainMapEOTF alt_eotf
Definition vf_gainmap.c:97
AVRational alt_offset
Definition vf_gainmap.c:85
float quant_gamma[3]
Definition vf_gainmap.c:104
float quant_offset[3]
Definition vf_gainmap.c:103
double Lw
Definition vf_gainmap.c:68
av_csp_eotf_function eotf
Definition vf_gainmap.c:67
float lut[GAINMAP_LUT_SIZE+1]
Definition vf_gainmap.c:71
enum AVColorTransferCharacteristic trc
Definition vf_gainmap.c:66
Used for passing data between threads.
Definition v210dec.c:35
AVFrame * out
const AVFrame * base
Definition vf_gainmap.c:118
const AVFrame * alt
Definition vf_gainmap.c:118
Definition swscale.c:71
Definition rpzaenc.c:60
#define av_freep(p)
#define av_log(a,...)
#define alt(var)
#define src
Definition vp8dsp.c:248
#define width
Definition dsp.h:89
static const float xyz2rgb[3][3]
Definition tiff.c:1912
const char * g
Definition vf_curves.c:128
static void setup_range(AVFilterContext *ctx, int ch, AVRational min, AVRational max)
Definition vf_gainmap.c:161
static int slice_gain(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_gainmap.c:529
static double frame_luminance(const AVFrame *frame)
Definition vf_gainmap.c:250
GainMapMeasure
Definition vf_gainmap.c:57
@ MEASURE_MIN
Definition vf_gainmap.c:58
@ MEASURE_GAMMA
Definition vf_gainmap.c:60
@ MEASURE_MAX
Definition vf_gainmap.c:59
@ MEASURE_RANGE
Definition vf_gainmap.c:61
static int slice_quant(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_gainmap.c:539
static const AVFilterPad gainmap_outputs[]
Definition vf_gainmap.c:753
static int slice_gain_quant(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition vf_gainmap.c:534
static const AVOption gainmap_options[]
Definition vf_gainmap.c:124
static const char * unknown_if_null(const char *s)
Definition vf_gainmap.c:309
static int setup_colorspace(AVFilterContext *ctx, const AVFrame *base, const AVFrame *alt)
Definition vf_gainmap.c:315
#define GAINMAP_LUT_SIZE
Definition vf_gainmap.c:70
GainMapColorspace
Definition vf_gainmap.c:44
@ GAINMAP_CSP_ALT
apply it in the alternate rendition's space
Definition vf_gainmap.c:46
@ GAINMAP_CSP_NB
Definition vf_gainmap.c:47
@ GAINMAP_CSP_BASE
apply the map in the base rendition's space
Definition vf_gainmap.c:45
static av_always_inline float quantize(float gain, float scale, float offset, float gamma)
Definition vf_gainmap.c:392
static av_always_inline int slice_internal(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs, int quant)
Definition vf_gainmap.c:439
#define SDR_DIFFUSE_WHITE
Definition vf_gainmap.c:42
static void update_eotf(GainMapEOTF *tf, enum AVColorTransferCharacteristic trc, av_csp_eotf_function eotf, double Lw)
Definition vf_gainmap.c:268
GainMapMode
Definition vf_gainmap.c:50
@ GAINMAP_RGB
one channel per component
Definition vf_gainmap.c:51
@ GAINMAP_MODE_NB
Definition vf_gainmap.c:54
@ GAINMAP_LUMA
single channel, from the luminance
Definition vf_gainmap.c:52
@ GAINMAP_MAXRGB
single channel, from max(R,G,B)
Definition vf_gainmap.c:53
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition vf_gainmap.c:231
static int activate(AVFilterContext *ctx)
Definition vf_gainmap.c:727
static av_cold void uninit(AVFilterContext *ctx)
Definition vf_gainmap.c:733
static void setup_gamma(AVFilterContext *ctx, int ch, AVRational gamma)
Definition vf_gainmap.c:180
static void choose_quant_params(AVFilterContext *ctx, const AVFrame *out, int nb_jobs)
Definition vf_gainmap.c:570
#define OFFSET(x)
Definition vf_gainmap.c:121
static int config_output(AVFilterLink *outlink)
Definition vf_gainmap.c:692
#define GAIN(a, b)
static AVRational quantq(double x, enum AVRounding rnd)
Definition vf_gainmap.c:145
static av_always_inline void get_pixel(const GainMapContext *s, float dst[3], const float *restrict const src[3], int x, int alt)
Definition vf_gainmap.c:399
static int process_frame(FFFrameSync *fs)
Definition vf_gainmap.c:619
static const AVFilterPad gainmap_inputs[]
Definition vf_gainmap.c:742
static float mean(const float *input, int size)
Definition vf_nnedi.c:861
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition video.c:89
static const uint8_t quant[64]
Definition vmixdec.c:71
uint8_t base
Definition vp3data.h:128
static double c[64]