FFmpeg
vf_libplacebo.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/file.h"
20 #include "libavutil/opt.h"
21 #include "internal.h"
22 #include "vulkan_filter.h"
23 #include "scale_eval.h"
24 
25 #include <libplacebo/renderer.h>
26 #include <libplacebo/utils/libav.h>
27 #include <libplacebo/vulkan.h>
28 
29 enum {
43 };
44 
45 static const struct pl_tone_map_function * const tonemapping_funcs[TONE_MAP_COUNT] = {
46  [TONE_MAP_AUTO] = &pl_tone_map_auto,
47  [TONE_MAP_CLIP] = &pl_tone_map_clip,
48 #if PL_API_VER >= 246
49  [TONE_MAP_ST2094_40] = &pl_tone_map_st2094_40,
50  [TONE_MAP_ST2094_10] = &pl_tone_map_st2094_10,
51 #endif
52  [TONE_MAP_BT2390] = &pl_tone_map_bt2390,
53  [TONE_MAP_BT2446A] = &pl_tone_map_bt2446a,
54  [TONE_MAP_SPLINE] = &pl_tone_map_spline,
55  [TONE_MAP_REINHARD] = &pl_tone_map_reinhard,
56  [TONE_MAP_MOBIUS] = &pl_tone_map_mobius,
57  [TONE_MAP_HABLE] = &pl_tone_map_hable,
58  [TONE_MAP_GAMMA] = &pl_tone_map_gamma,
59  [TONE_MAP_LINEAR] = &pl_tone_map_linear,
60 };
61 
62 typedef struct LibplaceboContext {
63  /* lavfi vulkan*/
65 
66  /* libplacebo */
67  pl_log log;
68  pl_vulkan vulkan;
69  pl_gpu gpu;
70  pl_renderer renderer;
71  pl_tex tex[8];
72 
73  /* settings */
76  char *w_expr;
77  char *h_expr;
88  int color_trc;
89 
90  /* pl_render_params */
91  char *upscaler;
92  char *downscaler;
94  float antiringing;
95  int sigmoid;
96  int skip_aa;
97  float polar_cutoff;
103 
104  /* pl_deband_params */
105  int deband;
110 
111  /* pl_color_adjustment */
112  float brightness;
113  float contrast;
114  float saturation;
115  float hue;
116  float gamma;
117 
118  /* pl_peak_detect_params */
120  float smoothing;
121  float min_peak;
122  float scene_low;
123  float scene_high;
124  float overshoot;
125 
126  /* pl_color_map_params */
127  int intent;
133  float crosstalk;
135  /* for backwards compatibility */
136  float desat_str;
137  float desat_exp;
140 
141  /* pl_dither_params */
145 
146  /* pl_cone_params */
147  int cones;
148  float cone_str;
149 
150  /* custom shaders */
151  char *shader_path;
152  void *shader_bin;
154  const struct pl_hook *hooks[2];
157 
158 static inline enum pl_log_level get_log_level(void)
159 {
160  int av_lev = av_log_get_level();
161  return av_lev >= AV_LOG_TRACE ? PL_LOG_TRACE :
162  av_lev >= AV_LOG_DEBUG ? PL_LOG_DEBUG :
163  av_lev >= AV_LOG_VERBOSE ? PL_LOG_INFO :
164  av_lev >= AV_LOG_WARNING ? PL_LOG_WARN :
165  av_lev >= AV_LOG_ERROR ? PL_LOG_ERR :
166  av_lev >= AV_LOG_FATAL ? PL_LOG_FATAL :
167  PL_LOG_NONE;
168 }
169 
170 static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
171 {
172  int av_lev;
173 
174  switch (level) {
175  case PL_LOG_FATAL: av_lev = AV_LOG_FATAL; break;
176  case PL_LOG_ERR: av_lev = AV_LOG_ERROR; break;
177  case PL_LOG_WARN: av_lev = AV_LOG_WARNING; break;
178  case PL_LOG_INFO: av_lev = AV_LOG_VERBOSE; break;
179  case PL_LOG_DEBUG: av_lev = AV_LOG_DEBUG; break;
180  case PL_LOG_TRACE: av_lev = AV_LOG_TRACE; break;
181  default: return;
182  }
183 
184  av_log(log_ctx, av_lev, "%s\n", msg);
185 }
186 
187 static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
188 {
189  LibplaceboContext *s = avctx->priv;
190  const struct pl_hook *hook;
191 
192  hook = pl_mpv_user_shader_parse(s->gpu, shader, len);
193  if (!hook) {
194  av_log(s, AV_LOG_ERROR, "Failed parsing custom shader!\n");
195  return AVERROR(EINVAL);
196  }
197 
198  s->hooks[s->num_hooks++] = hook;
199  return 0;
200 }
201 
202 static int find_scaler(AVFilterContext *avctx,
203  const struct pl_filter_config **opt,
204  const char *name)
205 {
206  const struct pl_filter_preset *preset;
207  if (!strcmp(name, "help")) {
208  av_log(avctx, AV_LOG_INFO, "Available scaler presets:\n");
209  for (preset = pl_scale_filters; preset->name; preset++)
210  av_log(avctx, AV_LOG_INFO, " %s\n", preset->name);
211  return AVERROR_EXIT;
212  }
213 
214  for (preset = pl_scale_filters; preset->name; preset++) {
215  if (!strcmp(name, preset->name)) {
216  *opt = preset->filter;
217  return 0;
218  }
219  }
220 
221  av_log(avctx, AV_LOG_ERROR, "No such scaler preset '%s'.\n", name);
222  return AVERROR(EINVAL);
223 }
224 
225 static void libplacebo_uninit(AVFilterContext *avctx);
226 
228 {
229  LibplaceboContext *s = avctx->priv;
230 
231  /* Create libplacebo log context */
232  s->log = pl_log_create(PL_API_VER, pl_log_params(
233  .log_level = get_log_level(),
234  .log_cb = pl_av_log,
235  .log_priv = s,
236  ));
237 
238  if (!s->log)
239  return AVERROR(ENOMEM);
240 
241  if (s->out_format_string) {
242  s->out_format = av_get_pix_fmt(s->out_format_string);
243  if (s->out_format == AV_PIX_FMT_NONE) {
244  av_log(avctx, AV_LOG_ERROR, "Invalid output format: %s\n",
245  s->out_format_string);
246  libplacebo_uninit(avctx);
247  return AVERROR(EINVAL);
248  }
249  } else {
250  s->out_format = AV_PIX_FMT_NONE;
251  }
252 
253  /* Note: s->vulkan etc. are initialized later, when hwctx is available */
254  return 0;
255 }
256 
257 static int init_vulkan(AVFilterContext *avctx)
258 {
259  int err = 0;
260  LibplaceboContext *s = avctx->priv;
261  const AVHWDeviceContext *avhwctx;
262  const AVVulkanDeviceContext *hwctx;
263  uint8_t *buf = NULL;
264  size_t buf_len;
265 
266  if (!avctx->hw_device_ctx) {
267  av_log(s, AV_LOG_ERROR, "Missing vulkan hwdevice for vf_libplacebo.\n");
268  return AVERROR(EINVAL);
269  }
270 
271  avhwctx = (AVHWDeviceContext *) avctx->hw_device_ctx->data;
272  if (avhwctx->type != AV_HWDEVICE_TYPE_VULKAN) {
273  av_log(s, AV_LOG_ERROR, "Expected vulkan hwdevice for vf_libplacebo, got %s.\n",
274  av_hwdevice_get_type_name(avhwctx->type));
275  return AVERROR(EINVAL);
276  }
277 
278  hwctx = avhwctx->hwctx;
279 
280  /* Import libavfilter vulkan context into libplacebo */
281  s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(
282  .instance = hwctx->inst,
283  .get_proc_addr = hwctx->get_proc_addr,
284  .phys_device = hwctx->phys_dev,
285  .device = hwctx->act_dev,
286  .extensions = hwctx->enabled_dev_extensions,
287  .num_extensions = hwctx->nb_enabled_dev_extensions,
288  .features = &hwctx->device_features,
289  .queue_graphics = {
290  .index = hwctx->queue_family_index,
291  .count = hwctx->nb_graphics_queues,
292  },
293  .queue_compute = {
294  .index = hwctx->queue_family_comp_index,
295  .count = hwctx->nb_comp_queues,
296  },
297  .queue_transfer = {
298  .index = hwctx->queue_family_tx_index,
299  .count = hwctx->nb_tx_queues,
300  },
301  /* This is the highest version created by hwcontext_vulkan.c */
302  .max_api_version = VK_API_VERSION_1_2,
303  ));
304 
305  if (!s->vulkan) {
306  av_log(s, AV_LOG_ERROR, "Failed importing vulkan device to libplacebo!\n");
307  err = AVERROR_EXTERNAL;
308  goto fail;
309  }
310 
311  /* Create the renderer */
312  s->gpu = s->vulkan->gpu;
313  s->renderer = pl_renderer_create(s->log, s->gpu);
314 
315  /* Parse the user shaders, if requested */
316  if (s->shader_bin_len)
317  RET(parse_shader(avctx, s->shader_bin, s->shader_bin_len));
318 
319  if (s->shader_path && s->shader_path[0]) {
320  RET(av_file_map(s->shader_path, &buf, &buf_len, 0, s));
321  RET(parse_shader(avctx, buf, buf_len));
322  }
323 
324  /* fall through */
325 fail:
326  if (buf)
327  av_file_unmap(buf, buf_len);
328  return err;
329 }
330 
332 {
333  LibplaceboContext *s = avctx->priv;
334 
335  for (int i = 0; i < FF_ARRAY_ELEMS(s->tex); i++)
336  pl_tex_destroy(s->gpu, &s->tex[i]);
337  for (int i = 0; i < s->num_hooks; i++)
338  pl_mpv_user_shader_destroy(&s->hooks[i]);
339  pl_renderer_destroy(&s->renderer);
340  pl_vulkan_destroy(&s->vulkan);
341  pl_log_destroy(&s->log);
342  ff_vk_uninit(&s->vkctx);
343  s->gpu = NULL;
344 }
345 
347 {
348  int err = 0, ok;
349  LibplaceboContext *s = avctx->priv;
350  struct pl_render_params params;
351  enum pl_tone_map_mode tonemapping_mode = s->tonemapping_mode;
352  const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(out->format);
353  enum pl_gamut_mode gamut_mode = s->gamut_mode;
354  struct pl_frame image, target;
355  ok = pl_map_avframe_ex(s->gpu, &image, pl_avframe_params(
356  .frame = in,
357  .tex = s->tex,
358  .map_dovi = s->apply_dovi,
359  ));
360 
361  if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
362  ok &= pl_map_avframe_ex(s->gpu, &target, pl_avframe_params(
363  .frame = out,
364  .map_dovi = false,
365  ));
366  } else {
367  ok &= pl_frame_recreate_from_avframe(s->gpu, &target, s->tex + 4, out);
368  }
369 
370  if (!ok) {
371  err = AVERROR_EXTERNAL;
372  goto fail;
373  }
374 
375  if (!s->apply_filmgrain)
376  image.film_grain.type = PL_FILM_GRAIN_NONE;
377 
378  if (s->target_sar.num) {
379  float aspect = pl_rect2df_aspect(&target.crop) * av_q2d(s->target_sar);
380  pl_rect2df_aspect_set(&target.crop, aspect, s->pad_crop_ratio);
381  }
382 
383  /* backwards compatibility with older API */
384  if (!tonemapping_mode && (s->desat_str >= 0.0f || s->desat_exp >= 0.0f)) {
385  float str = s->desat_str < 0.0f ? 0.9f : s->desat_str;
386  float exp = s->desat_exp < 0.0f ? 0.2f : s->desat_exp;
387  if (str >= 0.9f && exp <= 0.1f) {
388  tonemapping_mode = PL_TONE_MAP_RGB;
389  } else if (str > 0.1f) {
390  tonemapping_mode = PL_TONE_MAP_HYBRID;
391  } else {
392  tonemapping_mode = PL_TONE_MAP_LUMA;
393  }
394  }
395 
396  if (s->gamut_warning)
397  gamut_mode = PL_GAMUT_WARN;
398  if (s->gamut_clipping)
399  gamut_mode = PL_GAMUT_DESATURATE;
400 
401  /* Update render params */
402  params = (struct pl_render_params) {
403  PL_RENDER_DEFAULTS
404  .lut_entries = s->lut_entries,
405  .antiringing_strength = s->antiringing,
406 
407  .deband_params = !s->deband ? NULL : pl_deband_params(
408  .iterations = s->deband_iterations,
409  .threshold = s->deband_threshold,
410  .radius = s->deband_radius,
411  .grain = s->deband_grain,
412  ),
413 
414  .sigmoid_params = s->sigmoid ? &pl_sigmoid_default_params : NULL,
415 
416  .color_adjustment = &(struct pl_color_adjustment) {
417  .brightness = s->brightness,
418  .contrast = s->contrast,
419  .saturation = s->saturation,
420  .hue = s->hue,
421  .gamma = s->gamma,
422  },
423 
424  .peak_detect_params = !s->peakdetect ? NULL : pl_peak_detect_params(
425  .smoothing_period = s->smoothing,
426  .minimum_peak = s->min_peak,
427  .scene_threshold_low = s->scene_low,
428  .scene_threshold_high = s->scene_high,
429  .overshoot_margin = s->overshoot,
430  ),
431 
432  .color_map_params = pl_color_map_params(
433  .intent = s->intent,
434  .gamut_mode = gamut_mode,
435  .tone_mapping_function = tonemapping_funcs[s->tonemapping],
436  .tone_mapping_param = s->tonemapping_param,
437  .tone_mapping_mode = tonemapping_mode,
438  .inverse_tone_mapping = s->inverse_tonemapping,
439  .tone_mapping_crosstalk = s->crosstalk,
440  .lut_size = s->tonemapping_lut_size,
441  ),
442 
443  .dither_params = s->dithering < 0 ? NULL : pl_dither_params(
444  .method = s->dithering,
445  .lut_size = s->dither_lut_size,
446  .temporal = s->dither_temporal,
447  ),
448 
449  .cone_params = !s->cones ? NULL : pl_cone_params(
450  .cones = s->cones,
451  .strength = s->cone_str,
452  ),
453 
454  .hooks = s->hooks,
455  .num_hooks = s->num_hooks,
456 
457  .skip_anti_aliasing = s->skip_aa,
458  .polar_cutoff = s->polar_cutoff,
459  .disable_linear_scaling = s->disable_linear,
460  .disable_builtin_scalers = s->disable_builtin,
461  .force_icc_lut = s->force_icc_lut,
462  .force_dither = s->force_dither,
463  .disable_fbos = s->disable_fbos,
464  };
465 
466  RET(find_scaler(avctx, &params.upscaler, s->upscaler));
467  RET(find_scaler(avctx, &params.downscaler, s->downscaler));
468 
469  pl_render_image(s->renderer, &image, &target, &params);
470  pl_unmap_avframe(s->gpu, &image);
471 
472  if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
473  pl_unmap_avframe(s->gpu, &target);
474  } else if (!pl_download_avframe(s->gpu, &target, out)) {
475  err = AVERROR_EXTERNAL;
476  goto fail;
477  }
478 
479  /* Flush the command queues for performance */
480  pl_gpu_flush(s->gpu);
481  return 0;
482 
483 fail:
484  pl_unmap_avframe(s->gpu, &image);
485  pl_unmap_avframe(s->gpu, &target);
486  return err;
487 }
488 
490 {
491  int err, changed_csp;
492  AVFilterContext *ctx = link->dst;
493  LibplaceboContext *s = ctx->priv;
494  AVFilterLink *outlink = ctx->outputs[0];
495 
496  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
497  if (!out) {
498  err = AVERROR(ENOMEM);
499  goto fail;
500  }
501 
502  pl_log_level_update(s->log, get_log_level());
503 
505  out->width = outlink->w;
506  out->height = outlink->h;
507 
508  if (s->apply_dovi && av_frame_get_side_data(in, AV_FRAME_DATA_DOVI_METADATA)) {
509  /* Output of dovi reshaping is always BT.2020+PQ, so infer the correct
510  * output colorspace defaults */
511  out->colorspace = AVCOL_SPC_BT2020_NCL;
512  out->color_primaries = AVCOL_PRI_BT2020;
513  out->color_trc = AVCOL_TRC_SMPTE2084;
514  }
515 
516  if (s->colorspace >= 0)
517  out->colorspace = s->colorspace;
518  if (s->color_range >= 0)
519  out->color_range = s->color_range;
520  if (s->color_trc >= 0)
521  out->color_trc = s->color_trc;
522  if (s->color_primaries >= 0)
523  out->color_primaries = s->color_primaries;
524 
525  changed_csp = in->colorspace != out->colorspace ||
526  in->color_range != out->color_range ||
527  in->color_trc != out->color_trc ||
528  in->color_primaries != out->color_primaries;
529 
530  /* Strip side data if no longer relevant */
531  if (changed_csp) {
534  }
535  if (s->apply_dovi || changed_csp) {
538  }
539  if (s->apply_filmgrain)
541 
542  RET(process_frames(ctx, out, in));
543 
544  av_frame_free(&in);
545 
546  return ff_filter_frame(outlink, out);
547 
548 fail:
549  av_frame_free(&in);
550  av_frame_free(&out);
551  return err;
552 }
553 
555 {
556  int err;
557  LibplaceboContext *s = ctx->priv;
558  const AVPixFmtDescriptor *desc = NULL;
559  AVFilterFormats *infmts = NULL, *outfmts = NULL;
560 
561  RET(init_vulkan(ctx));
562 
563  while ((desc = av_pix_fmt_desc_next(desc))) {
565 
566 #if PL_API_VER < 232
567  // Older libplacebo can't handle >64-bit pixel formats, so safe-guard
568  // this to prevent triggering an assertion
569  if (av_get_bits_per_pixel(desc) > 64)
570  continue;
571 #endif
572 
573  if (!pl_test_pixfmt(s->gpu, pixfmt))
574  continue;
575 
576  RET(ff_add_format(&infmts, pixfmt));
577 
578  /* Filter for supported output pixel formats */
579  if (desc->flags & AV_PIX_FMT_FLAG_BE)
580  continue; /* BE formats are not supported by pl_download_avframe */
581 
582  /* Mask based on user specified format */
583  if (s->out_format != AV_PIX_FMT_NONE) {
584  if (pixfmt == AV_PIX_FMT_VULKAN && av_vkfmt_from_pixfmt(s->out_format)) {
585  /* OK */
586  } else if (pixfmt == s->out_format) {
587  /* OK */
588  } else {
589  continue; /* Not OK */
590  }
591  }
592 
593  RET(ff_add_format(&outfmts, pixfmt));
594  }
595 
596  if (!infmts || !outfmts) {
597  if (s->out_format) {
598  av_log(s, AV_LOG_ERROR, "Invalid output format '%s'!\n",
599  av_get_pix_fmt_name(s->out_format));
600  }
601  err = AVERROR(EINVAL);
602  goto fail;
603  }
604 
605  RET(ff_formats_ref(infmts, &ctx->inputs[0]->outcfg.formats));
606  RET(ff_formats_ref(outfmts, &ctx->outputs[0]->incfg.formats));
607  return 0;
608 
609 fail:
610  if (infmts && !infmts->refcount)
611  ff_formats_unref(&infmts);
612  if (outfmts && !outfmts->refcount)
613  ff_formats_unref(&outfmts);
614  return err;
615 }
616 
618 {
619  AVFilterContext *avctx = inlink->dst;
620  LibplaceboContext *s = avctx->priv;
621 
622  if (inlink->format == AV_PIX_FMT_VULKAN)
624 
625  /* Forward this to the vkctx for format selection */
626  s->vkctx.input_format = inlink->format;
627 
628  return 0;
629 }
630 
632 {
633  int err;
634  AVFilterContext *avctx = outlink->src;
635  LibplaceboContext *s = avctx->priv;
636  AVFilterLink *inlink = outlink->src->inputs[0];
637  AVHWFramesContext *hwfc;
638  AVVulkanFramesContext *vkfc;
639  AVRational scale_sar;
640 
641  RET(ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
642  &outlink->w, &outlink->h));
643 
644  ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
645  s->force_original_aspect_ratio,
646  s->force_divisible_by);
647 
648  scale_sar = (AVRational){outlink->h * inlink->w, outlink->w * inlink->h};
649  if (inlink->sample_aspect_ratio.num)
650  scale_sar = av_mul_q(scale_sar, inlink->sample_aspect_ratio);
651 
652  if (s->normalize_sar) {
653  /* Apply all SAR during scaling, so we don't need to set the out SAR */
654  outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
655  s->target_sar = scale_sar;
656  } else {
657  /* This is consistent with other scale_* filters, which only
658  * set the outlink SAR to be equal to the scale SAR iff the input SAR
659  * was set to something nonzero */
660  if (inlink->sample_aspect_ratio.num)
661  outlink->sample_aspect_ratio = scale_sar;
662  }
663 
664  if (outlink->format != AV_PIX_FMT_VULKAN)
665  return 0;
666 
667  s->vkctx.output_width = outlink->w;
668  s->vkctx.output_height = outlink->h;
669  /* Default to re-using the input format */
670  if (s->out_format == AV_PIX_FMT_NONE || s->out_format == AV_PIX_FMT_VULKAN) {
671  s->vkctx.output_format = s->vkctx.input_format;
672  } else {
673  s->vkctx.output_format = s->out_format;
674  }
676  hwfc = (AVHWFramesContext *) outlink->hw_frames_ctx->data;
677  vkfc = hwfc->hwctx;
678  vkfc->usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
679 
680  return 0;
681 
682 fail:
683  return err;
684 }
685 
686 #define OFFSET(x) offsetof(LibplaceboContext, x)
687 #define STATIC (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
688 #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM)
689 
690 static const AVOption libplacebo_options[] = {
691  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = STATIC },
692  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = STATIC },
693  { "format", "Output video format", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = STATIC },
694  { "force_original_aspect_ratio", "decrease or increase w/h if necessary to keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, STATIC, "force_oar" },
695  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, STATIC, "force_oar" },
696  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, "force_oar" },
697  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, "force_oar" },
698  { "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, STATIC },
699  { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
700  { "pad_crop_ratio", "ratio between padding and cropping when normalizing SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, 1.0, DYNAMIC },
701 
702  {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
703  {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"},
704  {"gbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_RGB}, INT_MIN, INT_MAX, STATIC, "colorspace"},
705  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT709}, INT_MIN, INT_MAX, STATIC, "colorspace"},
706  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "colorspace"},
707  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT470BG}, INT_MIN, INT_MAX, STATIC, "colorspace"},
708  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
709  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
710  {"ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, STATIC, "colorspace"},
711  {"bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
712  {"bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
713  {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, STATIC, "colorspace"},
714 
715  {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_RANGE_NB-1, DYNAMIC, "range"},
716  {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, STATIC, "range"},
717  {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
718  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
719  {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
720  {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
721  {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
722  {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
723  {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
724  {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
725 
726  {"color_primaries", "select color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_PRI_NB-1, DYNAMIC, "color_primaries"},
727  {"auto", "keep the same color primaries", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
728  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT709}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
729  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
730  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
731  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470BG}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
732  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
733  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
734  {"film", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_FILM}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
735  {"bt2020", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT2020}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
736  {"smpte428", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
737  {"smpte431", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
738  {"smpte432", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
739  {"jedec-p22", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_JEDEC_P22}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
740  {"ebu3213", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_EBU3213}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
741 
742  {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, DYNAMIC, "color_trc"},
743  {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
744  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT709}, INT_MIN, INT_MAX, STATIC, "color_trc"},
745  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_trc"},
746  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA22}, INT_MIN, INT_MAX, STATIC, "color_trc"},
747  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA28}, INT_MIN, INT_MAX, STATIC, "color_trc"},
748  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
749  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
750  {"linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LINEAR}, INT_MIN, INT_MAX, STATIC, "color_trc"},
751  {"iec61966-2-4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_4}, INT_MIN, INT_MAX, STATIC, "color_trc"},
752  {"bt1361e", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT1361_ECG}, INT_MIN, INT_MAX, STATIC, "color_trc"},
753  {"iec61966-2-1", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
754  {"bt2020-10", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_10}, INT_MIN, INT_MAX, STATIC, "color_trc"},
755  {"bt2020-12", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_12}, INT_MIN, INT_MAX, STATIC, "color_trc"},
756  {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, INT_MIN, INT_MAX, STATIC, "color_trc"},
757  {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, INT_MIN, INT_MAX, STATIC, "color_trc"},
758 
759  { "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC },
760  { "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC },
761  { "lut_entries", "Number of scaler LUT entries", OFFSET(lut_entries), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 256, DYNAMIC },
762  { "antiringing", "Antiringing strength (for non-EWA filters)", OFFSET(antiringing), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, DYNAMIC },
763  { "sigmoid", "Enable sigmoid upscaling", OFFSET(sigmoid), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
764  { "apply_filmgrain", "Apply film grain metadata", OFFSET(apply_filmgrain), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
765  { "apply_dolbyvision", "Apply Dolby Vision metadata", OFFSET(apply_dovi), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
766 
767  { "deband", "Enable debanding", OFFSET(deband), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
768  { "deband_iterations", "Deband iterations", OFFSET(deband_iterations), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 16, DYNAMIC },
769  { "deband_threshold", "Deband threshold", OFFSET(deband_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 4.0}, 0.0, 1024.0, DYNAMIC },
770  { "deband_radius", "Deband radius", OFFSET(deband_radius), AV_OPT_TYPE_FLOAT, {.dbl = 16.0}, 0.0, 1024.0, DYNAMIC },
771  { "deband_grain", "Deband grain", OFFSET(deband_grain), AV_OPT_TYPE_FLOAT, {.dbl = 6.0}, 0.0, 1024.0, DYNAMIC },
772 
773  { "brightness", "Brightness boost", OFFSET(brightness), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -1.0, 1.0, DYNAMIC },
774  { "contrast", "Contrast gain", OFFSET(contrast), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
775  { "saturation", "Saturation gain", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
776  { "hue", "Hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -M_PI, M_PI, DYNAMIC },
777  { "gamma", "Gamma adjustment", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
778 
779  { "peak_detect", "Enable dynamic peak detection for HDR tone-mapping", OFFSET(peakdetect), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
780  { "smoothing_period", "Peak detection smoothing period", OFFSET(smoothing), AV_OPT_TYPE_FLOAT, {.dbl = 100.0}, 0.0, 1000.0, DYNAMIC },
781  { "minimum_peak", "Peak detection minimum peak", OFFSET(min_peak), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 100.0, DYNAMIC },
782  { "scene_threshold_low", "Scene change low threshold", OFFSET(scene_low), AV_OPT_TYPE_FLOAT, {.dbl = 5.5}, -1.0, 100.0, DYNAMIC },
783  { "scene_threshold_high", "Scene change high threshold", OFFSET(scene_high), AV_OPT_TYPE_FLOAT, {.dbl = 10.0}, -1.0, 100.0, DYNAMIC },
784  { "overshoot", "Tone-mapping overshoot margin", OFFSET(overshoot), AV_OPT_TYPE_FLOAT, {.dbl = 0.05}, 0.0, 1.0, DYNAMIC },
785 
786  { "intent", "Rendering intent", OFFSET(intent), AV_OPT_TYPE_INT, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 3, DYNAMIC, "intent" },
787  { "perceptual", "Perceptual", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_PERCEPTUAL}, 0, 0, STATIC, "intent" },
788  { "relative", "Relative colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
789  { "absolute", "Absolute colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_ABSOLUTE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
790  { "saturation", "Saturation mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_SATURATION}, 0, 0, STATIC, "intent" },
791  { "gamut_mode", "Gamut-mapping mode", OFFSET(gamut_mode), AV_OPT_TYPE_INT, {.i64 = PL_GAMUT_CLIP}, 0, PL_GAMUT_MODE_COUNT - 1, DYNAMIC, "gamut_mode" },
792  { "clip", "Hard-clip gamut boundary", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_CLIP}, 0, 0, STATIC, "gamut_mode" },
793  { "warn", "Highlight out-of-gamut colors", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_WARN}, 0, 0, STATIC, "gamut_mode" },
794  { "darken", "Darken image to fit gamut", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_DARKEN}, 0, 0, STATIC, "gamut_mode" },
795  { "desaturate", "Colorimetrically desaturate colors", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_DESATURATE}, 0, 0, STATIC, "gamut_mode" },
796  { "tonemapping", "Tone-mapping algorithm", OFFSET(tonemapping), AV_OPT_TYPE_INT, {.i64 = TONE_MAP_AUTO}, 0, TONE_MAP_COUNT - 1, DYNAMIC, "tonemap" },
797  { "auto", "Automatic selection", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_AUTO}, 0, 0, STATIC, "tonemap" },
798  { "clip", "No tone mapping (clip", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_CLIP}, 0, 0, STATIC, "tonemap" },
799 #if PL_API_VER >= 246
800  { "st2094-40", "SMPTE ST 2094-40", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_ST2094_40}, 0, 0, STATIC, "tonemap" },
801  { "st2094-10", "SMPTE ST 2094-10", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_ST2094_10}, 0, 0, STATIC, "tonemap" },
802 #endif
803  { "bt.2390", "ITU-R BT.2390 EETF", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_BT2390}, 0, 0, STATIC, "tonemap" },
804  { "bt.2446a", "ITU-R BT.2446 Method A", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_BT2446A}, 0, 0, STATIC, "tonemap" },
805  { "spline", "Single-pivot polynomial spline", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_SPLINE}, 0, 0, STATIC, "tonemap" },
806  { "reinhard", "Reinhard", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_REINHARD}, 0, 0, STATIC, "tonemap" },
807  { "mobius", "Mobius", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_MOBIUS}, 0, 0, STATIC, "tonemap" },
808  { "hable", "Filmic tone-mapping (Hable)", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_HABLE}, 0, 0, STATIC, "tonemap" },
809  { "gamma", "Gamma function with knee", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_GAMMA}, 0, 0, STATIC, "tonemap" },
810  { "linear", "Perceptually linear stretch", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_LINEAR}, 0, 0, STATIC, "tonemap" },
811  { "tonemapping_param", "Tunable parameter for some tone-mapping functions", OFFSET(tonemapping_param), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 100.0, .flags = DYNAMIC },
812  { "tonemapping_mode", "Tone-mapping mode", OFFSET(tonemapping_mode), AV_OPT_TYPE_INT, {.i64 = PL_TONE_MAP_AUTO}, 0, PL_TONE_MAP_MODE_COUNT - 1, DYNAMIC, "tonemap_mode" },
813  { "auto", "Automatic selection", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_AUTO}, 0, 0, STATIC, "tonemap_mode" },
814  { "rgb", "Per-channel (RGB)", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_RGB}, 0, 0, STATIC, "tonemap_mode" },
815  { "max", "Maximum component", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_MAX}, 0, 0, STATIC, "tonemap_mode" },
816  { "hybrid", "Hybrid of Luma/RGB", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_HYBRID}, 0, 0, STATIC, "tonemap_mode" },
817  { "luma", "Luminance", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_LUMA}, 0, 0, STATIC, "tonemap_mode" },
818  { "inverse_tonemapping", "Inverse tone mapping (range expansion)", OFFSET(inverse_tonemapping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
819  { "tonemapping_crosstalk", "Crosstalk factor for tone-mapping", OFFSET(crosstalk), AV_OPT_TYPE_FLOAT, {.dbl = 0.04}, 0.0, 0.30, DYNAMIC },
820  { "tonemapping_lut_size", "Tone-mapping LUT size", OFFSET(tonemapping_lut_size), AV_OPT_TYPE_INT, {.i64 = 256}, 2, 1024, DYNAMIC },
821  /* deprecated options for backwards compatibility, defaulting to -1 to not override the new defaults */
822  { "desaturation_strength", "Desaturation strength", OFFSET(desat_str), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 1.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
823  { "desaturation_exponent", "Desaturation exponent", OFFSET(desat_exp), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 10.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
824  { "gamut_warning", "Highlight out-of-gamut colors", OFFSET(gamut_warning), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
825  { "gamut_clipping", "Enable colorimetric gamut clipping", OFFSET(gamut_clipping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
826 
827  { "dithering", "Dither method to use", OFFSET(dithering), AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1, DYNAMIC, "dither" },
828  { "none", "Disable dithering", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, STATIC, "dither" },
829  { "blue", "Blue noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_BLUE_NOISE}, 0, 0, STATIC, "dither" },
830  { "ordered", "Ordered LUT", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_LUT}, 0, 0, STATIC, "dither" },
831  { "ordered_fixed", "Fixed function ordered", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_FIXED}, 0, 0, STATIC, "dither" },
832  { "white", "White noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_WHITE_NOISE}, 0, 0, STATIC, "dither" },
833  { "dither_lut_size", "Dithering LUT size", OFFSET(dither_lut_size), AV_OPT_TYPE_INT, {.i64 = 6}, 1, 8, STATIC },
834  { "dither_temporal", "Enable temporal dithering", OFFSET(dither_temporal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
835 
836  { "cones", "Colorblindness adaptation model", OFFSET(cones), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, PL_CONE_LMS, DYNAMIC, "cone" },
837  { "l", "L cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_L}, 0, 0, STATIC, "cone" },
838  { "m", "M cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_M}, 0, 0, STATIC, "cone" },
839  { "s", "S cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_S}, 0, 0, STATIC, "cone" },
840  { "cone-strength", "Colorblindness adaptation strength", OFFSET(cone_str), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 10.0, DYNAMIC },
841 
842  { "custom_shader_path", "Path to custom user shader (mpv .hook format)", OFFSET(shader_path), AV_OPT_TYPE_STRING, .flags = STATIC },
843  { "custom_shader_bin", "Custom user shader as binary (mpv .hook format)", OFFSET(shader_bin), AV_OPT_TYPE_BINARY, .flags = STATIC },
844 
845  /* Performance/quality tradeoff options */
846  { "skip_aa", "Skip anti-aliasing", OFFSET(skip_aa), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 0, DYNAMIC },
847  { "polar_cutoff", "Polar LUT cutoff", OFFSET(polar_cutoff), AV_OPT_TYPE_FLOAT, {.dbl = 0}, 0.0, 1.0, DYNAMIC },
848  { "disable_linear", "Disable linear scaling", OFFSET(disable_linear), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
849  { "disable_builtin", "Disable built-in scalers", OFFSET(disable_builtin), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
850  { "force_icc_lut", "Force the use of a full ICC 3DLUT for color mapping", OFFSET(force_icc_lut), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
851  { "force_dither", "Force dithering", OFFSET(force_dither), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
852  { "disable_fbos", "Force-disable FBOs", OFFSET(disable_fbos), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
853  { NULL },
854 };
855 
856 AVFILTER_DEFINE_CLASS(libplacebo);
857 
858 static const AVFilterPad libplacebo_inputs[] = {
859  {
860  .name = "default",
861  .type = AVMEDIA_TYPE_VIDEO,
862  .filter_frame = &filter_frame,
863  .config_props = &libplacebo_config_input,
864  },
865 };
866 
867 static const AVFilterPad libplacebo_outputs[] = {
868  {
869  .name = "default",
870  .type = AVMEDIA_TYPE_VIDEO,
871  .config_props = &libplacebo_config_output,
872  },
873 };
874 
876  .name = "libplacebo",
877  .description = NULL_IF_CONFIG_SMALL("Apply various GPU filters from libplacebo"),
878  .priv_size = sizeof(LibplaceboContext),
879  .init = &libplacebo_init,
885  .priv_class = &libplacebo_class,
886  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
887 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:101
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:596
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:92
LibplaceboContext::colorspace
int colorspace
Definition: vf_libplacebo.c:85
LibplaceboContext::out_format
enum AVPixelFormat out_format
Definition: vf_libplacebo.c:75
AVVulkanDeviceContext::phys_dev
VkPhysicalDevice phys_dev
Physical device.
Definition: hwcontext_vulkan.h:63
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:592
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
level
uint8_t level
Definition: svq3.c:204
AVCOL_PRI_EBU3213
@ AVCOL_PRI_EBU3213
EBU Tech. 3213-E (nothing there) / one of JEDEC P22 group phosphors.
Definition: pixfmt.h:549
LibplaceboContext::gamut_clipping
int gamut_clipping
Definition: vf_libplacebo.c:139
libplacebo_query_format
static int libplacebo_query_format(AVFilterContext *ctx)
Definition: vf_libplacebo.c:554
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
LibplaceboContext::deband
int deband
Definition: vf_libplacebo.c:105
LibplaceboContext::deband_iterations
int deband_iterations
Definition: vf_libplacebo.c:106
LibplaceboContext::deband_threshold
float deband_threshold
Definition: vf_libplacebo.c:107
LibplaceboContext::gamut_mode
int gamut_mode
Definition: vf_libplacebo.c:128
out
FILE * out
Definition: movenc.c:54
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:682
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:374
LibplaceboContext::contrast
float contrast
Definition: vf_libplacebo.c:113
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:969
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2888
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:567
AV_FRAME_DATA_DOVI_METADATA
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
Definition: frame.h:204
TONE_MAP_BT2446A
@ TONE_MAP_BT2446A
Definition: vf_libplacebo.c:35
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
AV_FRAME_DATA_FILM_GRAIN_PARAMS
@ AV_FRAME_DATA_FILM_GRAIN_PARAMS
Film grain parameters for a frame, described by AVFilmGrainParams.
Definition: frame.h:184
AVFrame::color_primaries
enum AVColorPrimaries color_primaries
Definition: frame.h:594
LibplaceboContext::apply_filmgrain
int apply_filmgrain
Definition: vf_libplacebo.c:83
LibplaceboContext::intent
int intent
Definition: vf_libplacebo.c:127
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:99
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:603
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
AVCOL_TRC_NB
@ AVCOL_TRC_NB
Not part of ABI.
Definition: pixfmt.h:580
AVVulkanDeviceContext::get_proc_addr
PFN_vkGetInstanceProcAddr get_proc_addr
Pointer to the instance-provided vkGetInstanceProcAddr loading function.
Definition: hwcontext_vulkan.h:53
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:661
pl_av_log
static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
Definition: vf_libplacebo.c:170
AVOption
AVOption.
Definition: opt.h:251
AVCOL_SPC_NB
@ AVCOL_SPC_NB
Not part of ABI.
Definition: pixfmt.h:604
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:561
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:171
LibplaceboContext
Definition: vf_libplacebo.c:62
av_pix_fmt_desc_next
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
Definition: pixdesc.c:2895
AV_FRAME_DATA_DOVI_RPU_BUFFER
@ AV_FRAME_DATA_DOVI_RPU_BUFFER
Dolby Vision RPU raw data, suitable for passing to x265 or other libraries.
Definition: frame.h:197
AVVulkanDeviceContext::inst
VkInstance inst
Vulkan instance.
Definition: hwcontext_vulkan.h:58
AVCOL_PRI_JEDEC_P22
@ AVCOL_PRI_JEDEC_P22
Definition: pixfmt.h:550
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:588
ff_scale_eval_dimensions
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
Parse and evaluate string expressions for width and height.
Definition: scale_eval.c:57
AVCOL_TRC_BT2020_12
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Definition: pixfmt.h:574
AVFilterContext::hw_device_ctx
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:448
av_get_bits_per_pixel
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
Definition: pixdesc.c:2840
process_frames
static int process_frames(AVFilterContext *avctx, AVFrame *out, AVFrame *in)
Definition: vf_libplacebo.c:346
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees the main Vulkan context.
Definition: vulkan.c:1379
LibplaceboContext::sigmoid
int sigmoid
Definition: vf_libplacebo.c:95
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:165
LibplaceboContext::vkctx
FFVulkanContext vkctx
Definition: vf_libplacebo.c:64
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:599
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
AV_HWDEVICE_TYPE_VULKAN
@ AV_HWDEVICE_TYPE_VULKAN
Definition: hwcontext.h:39
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
libplacebo_config_output
static int libplacebo_config_output(AVFilterLink *outlink)
Definition: vf_libplacebo.c:631
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:593
TONE_MAP_AUTO
@ TONE_MAP_AUTO
Definition: vf_libplacebo.c:30
AV_OPT_TYPE_BINARY
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:231
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:572
av_file_map
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:54
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:407
LibplaceboContext::shader_bin_len
int shader_bin_len
Definition: vf_libplacebo.c:153
fail
#define fail()
Definition: checkasm.h:134
vulkan_filter.h
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
AVCOL_RANGE_NB
@ AVCOL_RANGE_NB
Not part of ABI.
Definition: pixfmt.h:662
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:564
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:157
find_scaler
static int find_scaler(AVFilterContext *avctx, const struct pl_filter_config **opt, const char *name)
Definition: vf_libplacebo.c:202
LibplaceboContext::lut_entries
int lut_entries
Definition: vf_libplacebo.c:93
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_libplacebo.c:489
LibplaceboContext::gamut_warning
int gamut_warning
Definition: vf_libplacebo.c:138
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:563
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
LibplaceboContext::antiringing
float antiringing
Definition: vf_libplacebo.c:94
preset
preset
Definition: vf_curves.c:46
LibplaceboContext::disable_linear
int disable_linear
Definition: vf_libplacebo.c:98
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
ff_vf_libplacebo
const AVFilter ff_vf_libplacebo
Definition: vf_libplacebo.c:875
TONE_MAP_MOBIUS
@ TONE_MAP_MOBIUS
Definition: vf_libplacebo.c:38
s
#define s(width, name)
Definition: cbs_vp9.c:256
AVCOL_PRI_NB
@ AVCOL_PRI_NB
Not part of ABI.
Definition: pixfmt.h:551
LibplaceboContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_libplacebo.c:80
AVCOL_TRC_BT1361_ECG
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
Definition: pixfmt.h:571
LibplaceboContext::force_dither
int force_dither
Definition: vf_libplacebo.c:101
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:594
init_vulkan
static int init_vulkan(AVFilterContext *avctx)
Definition: vf_libplacebo.c:257
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:596
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
libplacebo_inputs
static const AVFilterPad libplacebo_inputs[]
Definition: vf_libplacebo.c:858
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
libplacebo_uninit
static void libplacebo_uninit(AVFilterContext *avctx)
Definition: vf_libplacebo.c:331
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
LibplaceboContext::tonemapping
int tonemapping
Definition: vf_libplacebo.c:129
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:545
LibplaceboContext::disable_builtin
int disable_builtin
Definition: vf_libplacebo.c:99
tonemapping_funcs
static const struct pl_tone_map_function *const tonemapping_funcs[TONE_MAP_COUNT]
Definition: vf_libplacebo.c:45
LibplaceboContext::color_trc
int color_trc
Definition: vf_libplacebo.c:88
av_hwdevice_get_type_name
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:93
LibplaceboContext::w_expr
char * w_expr
Definition: vf_libplacebo.c:76
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:542
color_range
color_range
Definition: vf_selectivecolor.c:44
LibplaceboContext::force_divisible_by
int force_divisible_by
Definition: vf_libplacebo.c:81
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:536
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
av_file_unmap
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
Definition: file.c:145
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Definition: filter_design.txt:23
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:540
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:541
if
if(ret)
Definition: filter_design.txt:179
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:437
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:42
TONE_MAP_REINHARD
@ TONE_MAP_REINHARD
Definition: vf_libplacebo.c:37
NULL
#define NULL
Definition: coverity.c:32
LibplaceboContext::dither_temporal
int dither_temporal
Definition: vf_libplacebo.c:144
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:594
AVVulkanDeviceContext::nb_enabled_dev_extensions
int nb_enabled_dev_extensions
Definition: hwcontext_vulkan.h:97
LibplaceboContext::skip_aa
int skip_aa
Definition: vf_libplacebo.c:96
LibplaceboContext::shader_bin
void * shader_bin
Definition: vf_libplacebo.c:152
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
LibplaceboContext::cones
int cones
Definition: vf_libplacebo.c:147
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:570
LibplaceboContext::brightness
float brightness
Definition: vf_libplacebo.c:112
TONE_MAP_GAMMA
@ TONE_MAP_GAMMA
Definition: vf_libplacebo.c:40
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:400
LibplaceboContext::gpu
pl_gpu gpu
Definition: vf_libplacebo.c:69
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:535
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:449
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:133
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
LibplaceboContext::desat_str
float desat_str
Definition: vf_libplacebo.c:136
AVVulkanFramesContext::usage
VkImageUsageFlagBits usage
Defines extra usage of output frames.
Definition: hwcontext_vulkan.h:170
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:573
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:596
FFVulkanContext
Definition: vulkan.h:188
exp
int8_t exp
Definition: eval.c:72
AVFilterFormats::refcount
unsigned refcount
number of references to this list
Definition: formats.h:68
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
LibplaceboContext::desat_exp
float desat_exp
Definition: vf_libplacebo.c:137
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:627
parse_shader
static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
Definition: vf_libplacebo.c:187
libplacebo_config_input
static int libplacebo_config_input(AVFilterLink *inlink)
Definition: vf_libplacebo.c:617
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:544
LibplaceboContext::cone_str
float cone_str
Definition: vf_libplacebo.c:148
color_primaries
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition: csp.c:76
LibplaceboContext::hue
float hue
Definition: vf_libplacebo.c:115
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:575
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:547
TONE_MAP_HABLE
@ TONE_MAP_HABLE
Definition: vf_libplacebo.c:39
f
f
Definition: af_crystalizer.c:122
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:115
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:566
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:543
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:306
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(libplacebo)
LibplaceboContext::deband_grain
float deband_grain
Definition: vf_libplacebo.c:109
LibplaceboContext::out_format_string
char * out_format_string
Definition: vf_libplacebo.c:74
LibplaceboContext::disable_fbos
int disable_fbos
Definition: vf_libplacebo.c:102
LibplaceboContext::tonemapping_mode
int tonemapping_mode
Definition: vf_libplacebo.c:131
LibplaceboContext::saturation
float saturation
Definition: vf_libplacebo.c:114
LibplaceboContext::num_hooks
int num_hooks
Definition: vf_libplacebo.c:155
libplacebo_options
static const AVOption libplacebo_options[]
Definition: vf_libplacebo.c:690
scale_eval.h
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:842
av_frame_remove_side_data
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
Definition: frame.c:782
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
LibplaceboContext::overshoot
float overshoot
Definition: vf_libplacebo.c:124
LibplaceboContext::normalize_sar
int normalize_sar
Definition: vf_libplacebo.c:82
LibplaceboContext::polar_cutoff
float polar_cutoff
Definition: vf_libplacebo.c:97
av_pix_fmt_desc_get_id
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:2907
LibplaceboContext::apply_dovi
int apply_dovi
Definition: vf_libplacebo.c:84
LibplaceboContext::downscaler
char * downscaler
Definition: vf_libplacebo.c:92
LibplaceboContext::log
pl_log log
Definition: vf_libplacebo.c:67
LibplaceboContext::vulkan
pl_vulkan vulkan
Definition: vf_libplacebo.c:68
M_PI
#define M_PI
Definition: mathematics.h:52
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:560
internal.h
av_vkfmt_from_pixfmt
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the format of each image up to the number of planes for a given sw_format.
Definition: hwcontext_stub.c:30
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:595
get_log_level
static enum pl_log_level get_log_level(void)
Definition: vf_libplacebo.c:158
ff_formats_unref
void ff_formats_unref(AVFilterFormats **ref)
If *ref is non-NULL, remove *ref as a reference to the format list it currently points to,...
Definition: formats.c:635
TONE_MAP_CLIP
@ TONE_MAP_CLIP
Definition: vf_libplacebo.c:31
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
TONE_MAP_COUNT
@ TONE_MAP_COUNT
Definition: vf_libplacebo.c:42
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
LibplaceboContext::upscaler
char * upscaler
Definition: vf_libplacebo.c:91
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:598
LibplaceboContext::gamma
float gamma
Definition: vf_libplacebo.c:116
LibplaceboContext::target_sar
AVRational target_sar
Definition: vf_libplacebo.c:78
LibplaceboContext::force_icc_lut
int force_icc_lut
Definition: vf_libplacebo.c:100
LibplaceboContext::min_peak
float min_peak
Definition: vf_libplacebo.c:121
LibplaceboContext::tonemapping_lut_size
int tonemapping_lut_size
Definition: vf_libplacebo.c:134
LibplaceboContext::tonemapping_param
float tonemapping_param
Definition: vf_libplacebo.c:130
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:116
LibplaceboContext::color_primaries
int color_primaries
Definition: vf_libplacebo.c:87
len
int len
Definition: vorbis_enc_data.h:426
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:590
LibplaceboContext::dithering
int dithering
Definition: vf_libplacebo.c:142
LibplaceboContext::scene_high
float scene_high
Definition: vf_libplacebo.c:123
STATIC
#define STATIC
Definition: vf_libplacebo.c:687
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:644
AVFilter
Filter definition.
Definition: avfilter.h:161
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:538
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:365
AVHWDeviceContext::type
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition: hwcontext.h:79
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
LibplaceboContext::scene_low
float scene_low
Definition: vf_libplacebo.c:122
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:162
ff_scale_adjust_dimensions
int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by)
Transform evaluated width and height obtained from ff_scale_eval_dimensions into actual target width ...
Definition: scale_eval.c:113
LibplaceboContext::peakdetect
int peakdetect
Definition: vf_libplacebo.c:119
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2820
LibplaceboContext::deband_radius
float deband_radius
Definition: vf_libplacebo.c:108
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:579
libplacebo_outputs
static const AVFilterPad libplacebo_outputs[]
Definition: vf_libplacebo.c:867
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
LibplaceboContext::inverse_tonemapping
int inverse_tonemapping
Definition: vf_libplacebo.c:132
AVCOL_TRC_SMPTE170M
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition: pixfmt.h:565
file.h
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
OFFSET
#define OFFSET(x)
Definition: vf_libplacebo.c:686
AVFilterContext
An instance of a filter.
Definition: avfilter.h:392
TONE_MAP_ST2094_10
@ TONE_MAP_ST2094_10
Definition: vf_libplacebo.c:33
LibplaceboContext::crosstalk
float crosstalk
Definition: vf_libplacebo.c:133
desc
const char * desc
Definition: libsvtav1.c:83
AVVulkanDeviceContext::enabled_dev_extensions
const char *const * enabled_dev_extensions
Enabled device extensions.
Definition: hwcontext_vulkan.h:96
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:52
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
LibplaceboContext::renderer
pl_renderer renderer
Definition: vf_libplacebo.c:70
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
LibplaceboContext::pad_crop_ratio
float pad_crop_ratio
Definition: vf_libplacebo.c:79
TONE_MAP_ST2094_40
@ TONE_MAP_ST2094_40
Definition: vf_libplacebo.c:32
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:68
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:548
TONE_MAP_LINEAR
@ TONE_MAP_LINEAR
Definition: vf_libplacebo.c:41
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
LibplaceboContext::smoothing
float smoothing
Definition: vf_libplacebo.c:120
TONE_MAP_SPLINE
@ TONE_MAP_SPLINE
Definition: vf_libplacebo.c:36
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
convert_header.str
string str
Definition: convert_header.py:20
DYNAMIC
#define DYNAMIC
Definition: vf_libplacebo.c:688
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
LibplaceboContext::shader_path
char * shader_path
Definition: vf_libplacebo.c:151
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
AVVulkanDeviceContext::device_features
VkPhysicalDeviceFeatures2 device_features
This structure should be set to the set of features that present and enabled during device creation.
Definition: hwcontext_vulkan.h:76
LibplaceboContext::color_range
int color_range
Definition: vf_libplacebo.c:86
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
LibplaceboContext::dither_lut_size
int dither_lut_size
Definition: vf_libplacebo.c:143
libplacebo_init
static int libplacebo_init(AVFilterContext *avctx)
Definition: vf_libplacebo.c:227
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:589
LibplaceboContext::h_expr
char * h_expr
Definition: vf_libplacebo.c:77
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:603
LibplaceboContext::hooks
const struct pl_hook * hooks[2]
Definition: vf_libplacebo.c:154
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
TONE_MAP_BT2390
@ TONE_MAP_BT2390
Definition: vf_libplacebo.c:34
RET
#define RET(x)
Definition: vulkan.h:52
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2808
log_cb
static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
Definition: fflcms2.c:24
LibplaceboContext::tex
pl_tex tex[8]
Definition: vf_libplacebo.c:71
AV_OPT_FLAG_DEPRECATED
#define AV_OPT_FLAG_DEPRECATED
set if option is deprecated, users should refer to AVOption.help text for more information
Definition: opt.h:298