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 {
41 };
42 
43 static const struct pl_tone_map_function * const tonemapping_funcs[TONE_MAP_COUNT] = {
44  [TONE_MAP_AUTO] = &pl_tone_map_auto,
45  [TONE_MAP_CLIP] = &pl_tone_map_clip,
46  [TONE_MAP_BT2390] = &pl_tone_map_bt2390,
47  [TONE_MAP_BT2446A] = &pl_tone_map_bt2446a,
48  [TONE_MAP_SPLINE] = &pl_tone_map_spline,
49  [TONE_MAP_REINHARD] = &pl_tone_map_reinhard,
50  [TONE_MAP_MOBIUS] = &pl_tone_map_mobius,
51  [TONE_MAP_HABLE] = &pl_tone_map_hable,
52  [TONE_MAP_GAMMA] = &pl_tone_map_gamma,
53  [TONE_MAP_LINEAR] = &pl_tone_map_linear,
54 };
55 
56 typedef struct LibplaceboContext {
57  /* lavfi vulkan*/
59 
60  /* libplacebo */
61  pl_log log;
62  pl_vulkan vulkan;
63  pl_gpu gpu;
64  pl_renderer renderer;
65  pl_tex tex[8];
66 
67  /* settings */
70  char *w_expr;
71  char *h_expr;
82  int color_trc;
83 
84  /* pl_render_params */
85  char *upscaler;
86  char *downscaler;
88  float antiringing;
89  int sigmoid;
90  int skip_aa;
91  float polar_cutoff;
97 
98  /* pl_deband_params */
99  int deband;
104 
105  /* pl_color_adjustment */
106  float brightness;
107  float contrast;
108  float saturation;
109  float hue;
110  float gamma;
111 
112  /* pl_peak_detect_params */
114  float smoothing;
115  float min_peak;
116  float scene_low;
117  float scene_high;
118  float overshoot;
119 
120  /* pl_color_map_params */
121  int intent;
127  float crosstalk;
129  /* for backwards compatibility */
130  float desat_str;
131  float desat_exp;
134 
135  /* pl_dither_params */
139 
140  /* pl_cone_params */
141  int cones;
142  float cone_str;
143 
144  /* custom shaders */
145  char *shader_path;
146  void *shader_bin;
148  const struct pl_hook *hooks[2];
151 
152 static inline enum pl_log_level get_log_level(void)
153 {
154  int av_lev = av_log_get_level();
155  return av_lev >= AV_LOG_TRACE ? PL_LOG_TRACE :
156  av_lev >= AV_LOG_DEBUG ? PL_LOG_DEBUG :
157  av_lev >= AV_LOG_VERBOSE ? PL_LOG_INFO :
158  av_lev >= AV_LOG_WARNING ? PL_LOG_WARN :
159  av_lev >= AV_LOG_ERROR ? PL_LOG_ERR :
160  av_lev >= AV_LOG_FATAL ? PL_LOG_FATAL :
161  PL_LOG_NONE;
162 }
163 
164 static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
165 {
166  int av_lev;
167 
168  switch (level) {
169  case PL_LOG_FATAL: av_lev = AV_LOG_FATAL; break;
170  case PL_LOG_ERR: av_lev = AV_LOG_ERROR; break;
171  case PL_LOG_WARN: av_lev = AV_LOG_WARNING; break;
172  case PL_LOG_INFO: av_lev = AV_LOG_VERBOSE; break;
173  case PL_LOG_DEBUG: av_lev = AV_LOG_DEBUG; break;
174  case PL_LOG_TRACE: av_lev = AV_LOG_TRACE; break;
175  default: return;
176  }
177 
178  av_log(log_ctx, av_lev, "%s\n", msg);
179 }
180 
181 static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
182 {
183  LibplaceboContext *s = avctx->priv;
184  const struct pl_hook *hook;
185 
186  hook = pl_mpv_user_shader_parse(s->gpu, shader, len);
187  if (!hook) {
188  av_log(s, AV_LOG_ERROR, "Failed parsing custom shader!\n");
189  return AVERROR(EINVAL);
190  }
191 
192  s->hooks[s->num_hooks++] = hook;
193  return 0;
194 }
195 
196 static int find_scaler(AVFilterContext *avctx,
197  const struct pl_filter_config **opt,
198  const char *name)
199 {
200  const struct pl_filter_preset *preset;
201  if (!strcmp(name, "help")) {
202  av_log(avctx, AV_LOG_INFO, "Available scaler presets:\n");
203  for (preset = pl_scale_filters; preset->name; preset++)
204  av_log(avctx, AV_LOG_INFO, " %s\n", preset->name);
205  return AVERROR_EXIT;
206  }
207 
208  for (preset = pl_scale_filters; preset->name; preset++) {
209  if (!strcmp(name, preset->name)) {
210  *opt = preset->filter;
211  return 0;
212  }
213  }
214 
215  av_log(avctx, AV_LOG_ERROR, "No such scaler preset '%s'.\n", name);
216  return AVERROR(EINVAL);
217 }
218 
219 static void libplacebo_uninit(AVFilterContext *avctx);
220 
222 {
223  LibplaceboContext *s = avctx->priv;
224 
225  /* Create libplacebo log context */
226  s->log = pl_log_create(PL_API_VER, pl_log_params(
227  .log_level = get_log_level(),
228  .log_cb = pl_av_log,
229  .log_priv = s,
230  ));
231 
232  if (!s->log)
233  return AVERROR(ENOMEM);
234 
235  if (s->out_format_string) {
236  s->out_format = av_get_pix_fmt(s->out_format_string);
237  if (s->out_format == AV_PIX_FMT_NONE) {
238  av_log(avctx, AV_LOG_ERROR, "Invalid output format: %s\n",
239  s->out_format_string);
240  libplacebo_uninit(avctx);
241  return AVERROR(EINVAL);
242  }
243  } else {
244  s->out_format = AV_PIX_FMT_NONE;
245  }
246 
247  /* Note: s->vulkan etc. are initialized later, when hwctx is available */
248  return 0;
249 }
250 
251 static int init_vulkan(AVFilterContext *avctx)
252 {
253  int err = 0;
254  LibplaceboContext *s = avctx->priv;
255  const AVVulkanDeviceContext *hwctx;
256  uint8_t *buf = NULL;
257  size_t buf_len;
258 
259  if (!avctx->hw_device_ctx) {
260  av_log(s, AV_LOG_ERROR, "Missing vulkan hwdevice for vf_libplacebo.\n");
261  return AVERROR(EINVAL);
262  }
263 
264  hwctx = ((AVHWDeviceContext*) avctx->hw_device_ctx->data)->hwctx;
265 
266  /* Import libavfilter vulkan context into libplacebo */
267  s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(
268  .instance = hwctx->inst,
269  .get_proc_addr = hwctx->get_proc_addr,
270  .phys_device = hwctx->phys_dev,
271  .device = hwctx->act_dev,
272  .extensions = hwctx->enabled_dev_extensions,
273  .num_extensions = hwctx->nb_enabled_dev_extensions,
274  .features = &hwctx->device_features,
275  .queue_graphics = {
276  .index = hwctx->queue_family_index,
277  .count = hwctx->nb_graphics_queues,
278  },
279  .queue_compute = {
280  .index = hwctx->queue_family_comp_index,
281  .count = hwctx->nb_comp_queues,
282  },
283  .queue_transfer = {
284  .index = hwctx->queue_family_tx_index,
285  .count = hwctx->nb_tx_queues,
286  },
287  /* This is the highest version created by hwcontext_vulkan.c */
288  .max_api_version = VK_API_VERSION_1_2,
289  ));
290 
291  if (!s->vulkan) {
292  av_log(s, AV_LOG_ERROR, "Failed importing vulkan device to libplacebo!\n");
293  err = AVERROR_EXTERNAL;
294  goto fail;
295  }
296 
297  /* Create the renderer */
298  s->gpu = s->vulkan->gpu;
299  s->renderer = pl_renderer_create(s->log, s->gpu);
300 
301  /* Parse the user shaders, if requested */
302  if (s->shader_bin_len)
303  RET(parse_shader(avctx, s->shader_bin, s->shader_bin_len));
304 
305  if (s->shader_path && s->shader_path[0]) {
306  RET(av_file_map(s->shader_path, &buf, &buf_len, 0, s));
307  RET(parse_shader(avctx, buf, buf_len));
308  }
309 
310  /* fall through */
311 fail:
312  if (buf)
313  av_file_unmap(buf, buf_len);
314  return err;
315 }
316 
318 {
319  LibplaceboContext *s = avctx->priv;
320 
321  for (int i = 0; i < FF_ARRAY_ELEMS(s->tex); i++)
322  pl_tex_destroy(s->gpu, &s->tex[i]);
323  for (int i = 0; i < s->num_hooks; i++)
324  pl_mpv_user_shader_destroy(&s->hooks[i]);
325  pl_renderer_destroy(&s->renderer);
326  pl_vulkan_destroy(&s->vulkan);
327  pl_log_destroy(&s->log);
328  ff_vk_uninit(&s->vkctx);
329  s->gpu = NULL;
330 }
331 
333 {
334  int err = 0, ok;
335  LibplaceboContext *s = avctx->priv;
336  struct pl_render_params params;
337  enum pl_tone_map_mode tonemapping_mode = s->tonemapping_mode;
338  const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(out->format);
339  enum pl_gamut_mode gamut_mode = s->gamut_mode;
340  struct pl_frame image, target;
341  ok = pl_map_avframe_ex(s->gpu, &image, pl_avframe_params(
342  .frame = in,
343  .tex = s->tex,
344  .map_dovi = s->apply_dovi,
345  ));
346 
347  if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
348  ok &= pl_map_avframe_ex(s->gpu, &target, pl_avframe_params(
349  .frame = out,
350  .map_dovi = false,
351  ));
352  } else {
353  ok &= pl_frame_recreate_from_avframe(s->gpu, &target, s->tex + 4, out);
354  }
355 
356  if (!ok) {
357  err = AVERROR_EXTERNAL;
358  goto fail;
359  }
360 
361  if (!s->apply_filmgrain)
362  image.film_grain.type = PL_FILM_GRAIN_NONE;
363 
364  if (s->target_sar.num) {
365  float aspect = pl_rect2df_aspect(&target.crop) * av_q2d(s->target_sar);
366  pl_rect2df_aspect_set(&target.crop, aspect, s->pad_crop_ratio);
367  }
368 
369  /* backwards compatibility with older API */
370  if (!tonemapping_mode && (s->desat_str >= 0.0f || s->desat_exp >= 0.0f)) {
371  float str = s->desat_str < 0.0f ? 0.9f : s->desat_str;
372  float exp = s->desat_exp < 0.0f ? 0.2f : s->desat_exp;
373  if (str >= 0.9f && exp <= 0.1f) {
374  tonemapping_mode = PL_TONE_MAP_RGB;
375  } else if (str > 0.1f) {
376  tonemapping_mode = PL_TONE_MAP_HYBRID;
377  } else {
378  tonemapping_mode = PL_TONE_MAP_LUMA;
379  }
380  }
381 
382  if (s->gamut_warning)
383  gamut_mode = PL_GAMUT_WARN;
384  if (s->gamut_clipping)
385  gamut_mode = PL_GAMUT_DESATURATE;
386 
387  /* Update render params */
388  params = (struct pl_render_params) {
389  PL_RENDER_DEFAULTS
390  .lut_entries = s->lut_entries,
391  .antiringing_strength = s->antiringing,
392 
393  .deband_params = !s->deband ? NULL : pl_deband_params(
394  .iterations = s->deband_iterations,
395  .threshold = s->deband_threshold,
396  .radius = s->deband_radius,
397  .grain = s->deband_grain,
398  ),
399 
400  .sigmoid_params = s->sigmoid ? &pl_sigmoid_default_params : NULL,
401 
402  .color_adjustment = &(struct pl_color_adjustment) {
403  .brightness = s->brightness,
404  .contrast = s->contrast,
405  .saturation = s->saturation,
406  .hue = s->hue,
407  .gamma = s->gamma,
408  },
409 
410  .peak_detect_params = !s->peakdetect ? NULL : pl_peak_detect_params(
411  .smoothing_period = s->smoothing,
412  .minimum_peak = s->min_peak,
413  .scene_threshold_low = s->scene_low,
414  .scene_threshold_high = s->scene_high,
415  .overshoot_margin = s->overshoot,
416  ),
417 
418  .color_map_params = pl_color_map_params(
419  .intent = s->intent,
420  .gamut_mode = gamut_mode,
421  .tone_mapping_function = tonemapping_funcs[s->tonemapping],
422  .tone_mapping_param = s->tonemapping_param,
423  .tone_mapping_mode = tonemapping_mode,
424  .inverse_tone_mapping = s->inverse_tonemapping,
425  .tone_mapping_crosstalk = s->crosstalk,
426  .lut_size = s->tonemapping_lut_size,
427  ),
428 
429  .dither_params = s->dithering < 0 ? NULL : pl_dither_params(
430  .method = s->dithering,
431  .lut_size = s->dither_lut_size,
432  .temporal = s->dither_temporal,
433  ),
434 
435  .cone_params = !s->cones ? NULL : pl_cone_params(
436  .cones = s->cones,
437  .strength = s->cone_str,
438  ),
439 
440  .hooks = s->hooks,
441  .num_hooks = s->num_hooks,
442 
443  .skip_anti_aliasing = s->skip_aa,
444  .polar_cutoff = s->polar_cutoff,
445  .disable_linear_scaling = s->disable_linear,
446  .disable_builtin_scalers = s->disable_builtin,
447  .force_icc_lut = s->force_icc_lut,
448  .force_dither = s->force_dither,
449  .disable_fbos = s->disable_fbos,
450  };
451 
452  RET(find_scaler(avctx, &params.upscaler, s->upscaler));
453  RET(find_scaler(avctx, &params.downscaler, s->downscaler));
454 
455  pl_render_image(s->renderer, &image, &target, &params);
456  pl_unmap_avframe(s->gpu, &image);
457 
458  if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
459  pl_unmap_avframe(s->gpu, &target);
460  } else if (!pl_download_avframe(s->gpu, &target, out)) {
461  err = AVERROR_EXTERNAL;
462  goto fail;
463  }
464 
465  /* Flush the command queues for performance */
466  pl_gpu_flush(s->gpu);
467  return 0;
468 
469 fail:
470  pl_unmap_avframe(s->gpu, &image);
471  pl_unmap_avframe(s->gpu, &target);
472  return err;
473 }
474 
476 {
477  int err, changed_csp;
478  AVFilterContext *ctx = link->dst;
479  LibplaceboContext *s = ctx->priv;
480  AVFilterLink *outlink = ctx->outputs[0];
481 
482  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
483  if (!out) {
484  err = AVERROR(ENOMEM);
485  goto fail;
486  }
487 
488  pl_log_level_update(s->log, get_log_level());
489 
491  out->width = outlink->w;
492  out->height = outlink->h;
493 
494  if (s->apply_dovi && av_frame_get_side_data(in, AV_FRAME_DATA_DOVI_METADATA)) {
495  /* Output of dovi reshaping is always BT.2020+PQ, so infer the correct
496  * output colorspace defaults */
497  out->colorspace = AVCOL_SPC_BT2020_NCL;
498  out->color_primaries = AVCOL_PRI_BT2020;
499  out->color_trc = AVCOL_TRC_SMPTE2084;
500  }
501 
502  if (s->colorspace >= 0)
503  out->colorspace = s->colorspace;
504  if (s->color_range >= 0)
505  out->color_range = s->color_range;
506  if (s->color_trc >= 0)
507  out->color_trc = s->color_trc;
508  if (s->color_primaries >= 0)
509  out->color_primaries = s->color_primaries;
510 
511  changed_csp = in->colorspace != out->colorspace ||
512  in->color_range != out->color_range ||
513  in->color_trc != out->color_trc ||
514  in->color_primaries != out->color_primaries;
515 
516  /* Strip side data if no longer relevant */
517  if (changed_csp) {
520  }
521  if (s->apply_dovi || changed_csp) {
524  }
525  if (s->apply_filmgrain)
527 
528  RET(process_frames(ctx, out, in));
529 
530  av_frame_free(&in);
531 
532  return ff_filter_frame(outlink, out);
533 
534 fail:
535  av_frame_free(&in);
536  av_frame_free(&out);
537  return err;
538 }
539 
541 {
542  int err = 0;
543  LibplaceboContext *s = ctx->priv;
544  const AVPixFmtDescriptor *desc = NULL;
546 
547  RET(init_vulkan(ctx));
548 
549  while ((desc = av_pix_fmt_desc_next(desc))) {
551 
552 #if PL_API_VER < 232
553  // Older libplacebo can't handle >64-bit pixel formats, so safe-guard
554  // this to prevent triggering an assertion
555  if (av_get_bits_per_pixel(desc) > 64)
556  continue;
557 #endif
558 
559  if (pl_test_pixfmt(s->gpu, pixfmt)) {
560  if ((err = ff_add_format(&formats, pixfmt)) < 0)
561  return err;
562  }
563  }
564 
565  RET(ff_formats_ref(formats, &ctx->inputs[0]->outcfg.formats));
566 
567  if (s->out_format != AV_PIX_FMT_NONE) {
568  /* Support only requested format, and hwaccel (vulkan) */
569  const enum AVPixelFormat out_fmts[] = {
570  s->out_format, AV_PIX_FMT_VULKAN, AV_PIX_FMT_NONE,
571  };
573  &ctx->outputs[0]->incfg.formats));
574  } else {
575  /* Support all formats */
576  RET(ff_formats_ref(formats, &ctx->outputs[0]->incfg.formats));
577  }
578 
579  return 0;
580 
581 fail:
582  return err;
583 }
584 
586 {
587  AVFilterContext *avctx = inlink->dst;
588  LibplaceboContext *s = avctx->priv;
589 
590  if (inlink->format == AV_PIX_FMT_VULKAN)
592 
593  /* Forward this to the vkctx for format selection */
594  s->vkctx.input_format = inlink->format;
595 
596  return 0;
597 }
598 
600 {
601  int err;
602  AVFilterContext *avctx = outlink->src;
603  LibplaceboContext *s = avctx->priv;
604  AVFilterLink *inlink = outlink->src->inputs[0];
605  AVHWFramesContext *hwfc;
606  AVVulkanFramesContext *vkfc;
607  AVRational scale_sar;
608 
609  RET(ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
610  &outlink->w, &outlink->h));
611 
612  ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
613  s->force_original_aspect_ratio,
614  s->force_divisible_by);
615 
616  scale_sar = (AVRational){outlink->h * inlink->w, outlink->w * inlink->h};
617  if (inlink->sample_aspect_ratio.num)
618  scale_sar = av_mul_q(scale_sar, inlink->sample_aspect_ratio);
619 
620  if (s->normalize_sar) {
621  /* Apply all SAR during scaling, so we don't need to set the out SAR */
622  outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
623  s->target_sar = scale_sar;
624  } else {
625  /* This is consistent with other scale_* filters, which only
626  * set the outlink SAR to be equal to the scale SAR iff the input SAR
627  * was set to something nonzero */
628  if (inlink->sample_aspect_ratio.num)
629  outlink->sample_aspect_ratio = scale_sar;
630  }
631 
632  if (outlink->format != AV_PIX_FMT_VULKAN)
633  return 0;
634 
635  s->vkctx.output_width = outlink->w;
636  s->vkctx.output_height = outlink->h;
637  /* Default to re-using the input format */
638  if (s->out_format == AV_PIX_FMT_NONE || s->out_format == AV_PIX_FMT_VULKAN) {
639  s->vkctx.output_format = s->vkctx.input_format;
640  } else {
641  s->vkctx.output_format = s->out_format;
642  }
644  hwfc = (AVHWFramesContext *) outlink->hw_frames_ctx->data;
645  vkfc = hwfc->hwctx;
646  vkfc->usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
647 
648  return 0;
649 
650 fail:
651  return err;
652 }
653 
654 #define OFFSET(x) offsetof(LibplaceboContext, x)
655 #define STATIC (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
656 #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM)
657 
658 static const AVOption libplacebo_options[] = {
659  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = STATIC },
660  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = STATIC },
661  { "format", "Output video format", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = STATIC },
662  { "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" },
663  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, STATIC, "force_oar" },
664  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, "force_oar" },
665  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, "force_oar" },
666  { "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 },
667  { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
668  { "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 },
669 
670  {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
671  {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"},
672  {"gbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_RGB}, INT_MIN, INT_MAX, STATIC, "colorspace"},
673  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT709}, INT_MIN, INT_MAX, STATIC, "colorspace"},
674  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "colorspace"},
675  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT470BG}, INT_MIN, INT_MAX, STATIC, "colorspace"},
676  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
677  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
678  {"ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, STATIC, "colorspace"},
679  {"bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
680  {"bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
681  {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, STATIC, "colorspace"},
682 
683  {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_RANGE_NB-1, DYNAMIC, "range"},
684  {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, STATIC, "range"},
685  {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
686  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
687  {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
688  {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
689  {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
690  {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
691  {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
692  {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
693 
694  {"color_primaries", "select color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_PRI_NB-1, DYNAMIC, "color_primaries"},
695  {"auto", "keep the same color primaries", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
696  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT709}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
697  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
698  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
699  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470BG}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
700  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
701  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
702  {"film", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_FILM}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
703  {"bt2020", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT2020}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
704  {"smpte428", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
705  {"smpte431", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
706  {"smpte432", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
707  {"jedec-p22", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_JEDEC_P22}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
708  {"ebu3213", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_EBU3213}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
709 
710  {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, DYNAMIC, "color_trc"},
711  {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
712  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT709}, INT_MIN, INT_MAX, STATIC, "color_trc"},
713  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_trc"},
714  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA22}, INT_MIN, INT_MAX, STATIC, "color_trc"},
715  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA28}, INT_MIN, INT_MAX, STATIC, "color_trc"},
716  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
717  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
718  {"linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LINEAR}, INT_MIN, INT_MAX, STATIC, "color_trc"},
719  {"iec61966-2-4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_4}, INT_MIN, INT_MAX, STATIC, "color_trc"},
720  {"bt1361e", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT1361_ECG}, INT_MIN, INT_MAX, STATIC, "color_trc"},
721  {"iec61966-2-1", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
722  {"bt2020-10", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_10}, INT_MIN, INT_MAX, STATIC, "color_trc"},
723  {"bt2020-12", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_12}, INT_MIN, INT_MAX, STATIC, "color_trc"},
724  {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, INT_MIN, INT_MAX, STATIC, "color_trc"},
725  {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, INT_MIN, INT_MAX, STATIC, "color_trc"},
726 
727  { "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC },
728  { "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC },
729  { "lut_entries", "Number of scaler LUT entries", OFFSET(lut_entries), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 256, DYNAMIC },
730  { "antiringing", "Antiringing strength (for non-EWA filters)", OFFSET(antiringing), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, DYNAMIC },
731  { "sigmoid", "Enable sigmoid upscaling", OFFSET(sigmoid), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
732  { "apply_filmgrain", "Apply film grain metadata", OFFSET(apply_filmgrain), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
733  { "apply_dolbyvision", "Apply Dolby Vision metadata", OFFSET(apply_dovi), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
734 
735  { "deband", "Enable debanding", OFFSET(deband), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
736  { "deband_iterations", "Deband iterations", OFFSET(deband_iterations), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 16, DYNAMIC },
737  { "deband_threshold", "Deband threshold", OFFSET(deband_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 4.0}, 0.0, 1024.0, DYNAMIC },
738  { "deband_radius", "Deband radius", OFFSET(deband_radius), AV_OPT_TYPE_FLOAT, {.dbl = 16.0}, 0.0, 1024.0, DYNAMIC },
739  { "deband_grain", "Deband grain", OFFSET(deband_grain), AV_OPT_TYPE_FLOAT, {.dbl = 6.0}, 0.0, 1024.0, DYNAMIC },
740 
741  { "brightness", "Brightness boost", OFFSET(brightness), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -1.0, 1.0, DYNAMIC },
742  { "contrast", "Contrast gain", OFFSET(contrast), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
743  { "saturation", "Saturation gain", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
744  { "hue", "Hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -M_PI, M_PI, DYNAMIC },
745  { "gamma", "Gamma adjustment", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
746 
747  { "peak_detect", "Enable dynamic peak detection for HDR tone-mapping", OFFSET(peakdetect), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
748  { "smoothing_period", "Peak detection smoothing period", OFFSET(smoothing), AV_OPT_TYPE_FLOAT, {.dbl = 100.0}, 0.0, 1000.0, DYNAMIC },
749  { "minimum_peak", "Peak detection minimum peak", OFFSET(min_peak), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 100.0, DYNAMIC },
750  { "scene_threshold_low", "Scene change low threshold", OFFSET(scene_low), AV_OPT_TYPE_FLOAT, {.dbl = 5.5}, -1.0, 100.0, DYNAMIC },
751  { "scene_threshold_high", "Scene change high threshold", OFFSET(scene_high), AV_OPT_TYPE_FLOAT, {.dbl = 10.0}, -1.0, 100.0, DYNAMIC },
752  { "overshoot", "Tone-mapping overshoot margin", OFFSET(overshoot), AV_OPT_TYPE_FLOAT, {.dbl = 0.05}, 0.0, 1.0, DYNAMIC },
753 
754  { "intent", "Rendering intent", OFFSET(intent), AV_OPT_TYPE_INT, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 3, DYNAMIC, "intent" },
755  { "perceptual", "Perceptual", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_PERCEPTUAL}, 0, 0, STATIC, "intent" },
756  { "relative", "Relative colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
757  { "absolute", "Absolute colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_ABSOLUTE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
758  { "saturation", "Saturation mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_SATURATION}, 0, 0, STATIC, "intent" },
759  { "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" },
760  { "clip", "Hard-clip gamut boundary", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_CLIP}, 0, 0, STATIC, "gamut_mode" },
761  { "warn", "Highlight out-of-gamut colors", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_WARN}, 0, 0, STATIC, "gamut_mode" },
762  { "darken", "Darken image to fit gamut", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_DARKEN}, 0, 0, STATIC, "gamut_mode" },
763  { "desaturate", "Colorimetrically desaturate colors", 0, AV_OPT_TYPE_CONST, {.i64 = PL_GAMUT_DESATURATE}, 0, 0, STATIC, "gamut_mode" },
764  { "tonemapping", "Tone-mapping algorithm", OFFSET(tonemapping), AV_OPT_TYPE_INT, {.i64 = TONE_MAP_AUTO}, 0, TONE_MAP_COUNT - 1, DYNAMIC, "tonemap" },
765  { "auto", "Automatic selection", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_AUTO}, 0, 0, STATIC, "tonemap" },
766  { "clip", "No tone mapping (clip", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_CLIP}, 0, 0, STATIC, "tonemap" },
767  { "bt.2390", "ITU-R BT.2390 EETF", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_BT2390}, 0, 0, STATIC, "tonemap" },
768  { "bt.2446a", "ITU-R BT.2446 Method A", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_BT2446A}, 0, 0, STATIC, "tonemap" },
769  { "spline", "Single-pivot polynomial spline", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_SPLINE}, 0, 0, STATIC, "tonemap" },
770  { "reinhard", "Reinhard", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_REINHARD}, 0, 0, STATIC, "tonemap" },
771  { "mobius", "Mobius", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_MOBIUS}, 0, 0, STATIC, "tonemap" },
772  { "hable", "Filmic tone-mapping (Hable)", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_HABLE}, 0, 0, STATIC, "tonemap" },
773  { "gamma", "Gamma function with knee", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_GAMMA}, 0, 0, STATIC, "tonemap" },
774  { "linear", "Perceptually linear stretch", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_LINEAR}, 0, 0, STATIC, "tonemap" },
775  { "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 },
776  { "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" },
777  { "auto", "Automatic selection", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_AUTO}, 0, 0, STATIC, "tonemap_mode" },
778  { "rgb", "Per-channel (RGB)", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_RGB}, 0, 0, STATIC, "tonemap_mode" },
779  { "max", "Maximum component", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_MAX}, 0, 0, STATIC, "tonemap_mode" },
780  { "hybrid", "Hybrid of Luma/RGB", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_HYBRID}, 0, 0, STATIC, "tonemap_mode" },
781  { "luma", "Luminance", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAP_LUMA}, 0, 0, STATIC, "tonemap_mode" },
782  { "inverse_tonemapping", "Inverse tone mapping (range expansion)", OFFSET(inverse_tonemapping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
783  { "tonemapping_crosstalk", "Crosstalk factor for tone-mapping", OFFSET(crosstalk), AV_OPT_TYPE_FLOAT, {.dbl = 0.04}, 0.0, 0.30, DYNAMIC },
784  { "tonemapping_lut_size", "Tone-mapping LUT size", OFFSET(tonemapping_lut_size), AV_OPT_TYPE_INT, {.i64 = 256}, 2, 1024, DYNAMIC },
785  /* deprecated options for backwards compatibility, defaulting to -1 to not override the new defaults */
786  { "desaturation_strength", "Desaturation strength", OFFSET(desat_str), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 1.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
787  { "desaturation_exponent", "Desaturation exponent", OFFSET(desat_exp), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 10.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
788  { "gamut_warning", "Highlight out-of-gamut colors", OFFSET(gamut_warning), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
789  { "gamut_clipping", "Enable colorimetric gamut clipping", OFFSET(gamut_clipping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
790 
791  { "dithering", "Dither method to use", OFFSET(dithering), AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1, DYNAMIC, "dither" },
792  { "none", "Disable dithering", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, STATIC, "dither" },
793  { "blue", "Blue noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_BLUE_NOISE}, 0, 0, STATIC, "dither" },
794  { "ordered", "Ordered LUT", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_LUT}, 0, 0, STATIC, "dither" },
795  { "ordered_fixed", "Fixed function ordered", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_FIXED}, 0, 0, STATIC, "dither" },
796  { "white", "White noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_WHITE_NOISE}, 0, 0, STATIC, "dither" },
797  { "dither_lut_size", "Dithering LUT size", OFFSET(dither_lut_size), AV_OPT_TYPE_INT, {.i64 = 6}, 1, 8, STATIC },
798  { "dither_temporal", "Enable temporal dithering", OFFSET(dither_temporal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
799 
800  { "cones", "Colorblindness adaptation model", OFFSET(cones), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, PL_CONE_LMS, DYNAMIC, "cone" },
801  { "l", "L cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_L}, 0, 0, STATIC, "cone" },
802  { "m", "M cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_M}, 0, 0, STATIC, "cone" },
803  { "s", "S cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_S}, 0, 0, STATIC, "cone" },
804  { "cone-strength", "Colorblindness adaptation strength", OFFSET(cone_str), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 10.0, DYNAMIC },
805 
806  { "custom_shader_path", "Path to custom user shader (mpv .hook format)", OFFSET(shader_path), AV_OPT_TYPE_STRING, .flags = STATIC },
807  { "custom_shader_bin", "Custom user shader as binary (mpv .hook format)", OFFSET(shader_bin), AV_OPT_TYPE_BINARY, .flags = STATIC },
808 
809  /* Performance/quality tradeoff options */
810  { "skip_aa", "Skip anti-aliasing", OFFSET(skip_aa), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 0, DYNAMIC },
811  { "polar_cutoff", "Polar LUT cutoff", OFFSET(polar_cutoff), AV_OPT_TYPE_FLOAT, {.dbl = 0}, 0.0, 1.0, DYNAMIC },
812  { "disable_linear", "Disable linear scaling", OFFSET(disable_linear), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
813  { "disable_builtin", "Disable built-in scalers", OFFSET(disable_builtin), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
814  { "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 },
815  { "force_dither", "Force dithering", OFFSET(force_dither), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
816  { "disable_fbos", "Force-disable FBOs", OFFSET(disable_fbos), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
817  { NULL },
818 };
819 
820 AVFILTER_DEFINE_CLASS(libplacebo);
821 
822 static const AVFilterPad libplacebo_inputs[] = {
823  {
824  .name = "default",
825  .type = AVMEDIA_TYPE_VIDEO,
826  .filter_frame = &filter_frame,
827  .config_props = &libplacebo_config_input,
828  },
829 };
830 
831 static const AVFilterPad libplacebo_outputs[] = {
832  {
833  .name = "default",
834  .type = AVMEDIA_TYPE_VIDEO,
835  .config_props = &libplacebo_config_output,
836  },
837 };
838 
840  .name = "libplacebo",
841  .description = NULL_IF_CONFIG_SMALL("Apply various GPU filters from libplacebo"),
842  .priv_size = sizeof(LibplaceboContext),
843  .init = &libplacebo_init,
849  .priv_class = &libplacebo_class,
850  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
851 };
formats
formats
Definition: signature.h:48
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:582
LibplaceboContext::colorspace
int colorspace
Definition: vf_libplacebo.c:79
LibplaceboContext::out_format
enum AVPixelFormat out_format
Definition: vf_libplacebo.c:69
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:578
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:133
libplacebo_query_format
static int libplacebo_query_format(AVFilterContext *ctx)
Definition: vf_libplacebo.c:540
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:99
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:380
LibplaceboContext::deband_iterations
int deband_iterations
Definition: vf_libplacebo.c:100
LibplaceboContext::deband_threshold
float deband_threshold
Definition: vf_libplacebo.c:101
LibplaceboContext::gamut_mode
int gamut_mode
Definition: vf_libplacebo.c:122
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:691
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:370
LibplaceboContext::contrast
float contrast
Definition: vf_libplacebo.c:107
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1009
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2858
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:33
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:580
LibplaceboContext::apply_filmgrain
int apply_filmgrain
Definition: vf_libplacebo.c:77
LibplaceboContext::intent
int intent
Definition: vf_libplacebo.c:121
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:116
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:589
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
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:164
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:167
LibplaceboContext
Definition: vf_libplacebo.c:56
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:2865
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:471
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:2810
process_frames
static int process_frames(AVFilterContext *avctx, AVFrame *out, AVFrame *in)
Definition: vf_libplacebo.c:332
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:89
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:175
LibplaceboContext::vkctx
FFVulkanContext vkctx
Definition: vf_libplacebo.c:58
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
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:599
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:430
LibplaceboContext::shader_bin_len
int shader_bin_len
Definition: vf_libplacebo.c:147
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:196
LibplaceboContext::lut_entries
int lut_entries
Definition: vf_libplacebo.c:87
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_libplacebo.c:475
LibplaceboContext::gamut_warning
int gamut_warning
Definition: vf_libplacebo.c:132
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:88
preset
preset
Definition: vf_curves.c:46
LibplaceboContext::disable_linear
int disable_linear
Definition: vf_libplacebo.c:92
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:839
TONE_MAP_MOBIUS
@ TONE_MAP_MOBIUS
Definition: vf_libplacebo.c:36
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:74
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:95
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:251
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:822
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:363
libplacebo_uninit
static void libplacebo_uninit(AVFilterContext *avctx)
Definition: vf_libplacebo.c:317
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:123
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:93
tonemapping_funcs
static const struct pl_tone_map_function *const tonemapping_funcs[TONE_MAP_COUNT]
Definition: vf_libplacebo.c:43
LibplaceboContext::color_trc
int color_trc
Definition: vf_libplacebo.c:82
LibplaceboContext::w_expr
char * w_expr
Definition: vf_libplacebo.c:70
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:75
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:536
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
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
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:35
NULL
#define NULL
Definition: coverity.c:32
LibplaceboContext::dither_temporal
int dither_temporal
Definition: vf_libplacebo.c:138
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:603
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:90
LibplaceboContext::shader_bin
void * shader_bin
Definition: vf_libplacebo.c:146
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
LibplaceboContext::cones
int cones
Definition: vf_libplacebo.c:141
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:106
TONE_MAP_GAMMA
@ TONE_MAP_GAMMA
Definition: vf_libplacebo.c:38
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:423
LibplaceboContext::gpu
pl_gpu gpu
Definition: vf_libplacebo.c:63
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:130
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
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:131
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:181
libplacebo_config_input
static int libplacebo_config_input(AVFilterLink *inlink)
Definition: vf_libplacebo.c:585
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:544
LibplaceboContext::cone_str
float cone_str
Definition: vf_libplacebo.c:142
color_primaries
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition: csp.c:71
LibplaceboContext::hue
float hue
Definition: vf_libplacebo.c:109
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:37
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:103
LibplaceboContext::out_format_string
char * out_format_string
Definition: vf_libplacebo.c:68
LibplaceboContext::disable_fbos
int disable_fbos
Definition: vf_libplacebo.c:96
LibplaceboContext::tonemapping_mode
int tonemapping_mode
Definition: vf_libplacebo.c:125
LibplaceboContext::saturation
float saturation
Definition: vf_libplacebo.c:108
LibplaceboContext::num_hooks
int num_hooks
Definition: vf_libplacebo.c:149
libplacebo_options
static const AVOption libplacebo_options[]
Definition: vf_libplacebo.c:658
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:873
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:791
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
LibplaceboContext::overshoot
float overshoot
Definition: vf_libplacebo.c:118
LibplaceboContext::normalize_sar
int normalize_sar
Definition: vf_libplacebo.c:76
LibplaceboContext::polar_cutoff
float polar_cutoff
Definition: vf_libplacebo.c:91
av_pix_fmt_desc_get_id
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:2877
LibplaceboContext::apply_dovi
int apply_dovi
Definition: vf_libplacebo.c:78
LibplaceboContext::downscaler
char * downscaler
Definition: vf_libplacebo.c:86
LibplaceboContext::log
pl_log log
Definition: vf_libplacebo.c:61
LibplaceboContext::vulkan
pl_vulkan vulkan
Definition: vf_libplacebo.c:62
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_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:152
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:40
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
LibplaceboContext::upscaler
char * upscaler
Definition: vf_libplacebo.c:85
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:110
LibplaceboContext::target_sar
AVRational target_sar
Definition: vf_libplacebo.c:72
LibplaceboContext::force_icc_lut
int force_icc_lut
Definition: vf_libplacebo.c:94
LibplaceboContext::min_peak
float min_peak
Definition: vf_libplacebo.c:115
LibplaceboContext::tonemapping_lut_size
int tonemapping_lut_size
Definition: vf_libplacebo.c:128
LibplaceboContext::tonemapping_param
float tonemapping_param
Definition: vf_libplacebo.c:124
LibplaceboContext::color_primaries
int color_primaries
Definition: vf_libplacebo.c:81
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:136
LibplaceboContext::scene_high
float scene_high
Definition: vf_libplacebo.c:117
STATIC
#define STATIC
Definition: vf_libplacebo.c:655
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:644
AVFilter
Filter definition.
Definition: avfilter.h:171
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
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:116
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:113
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2790
LibplaceboContext::deband_radius
float deband_radius
Definition: vf_libplacebo.c:102
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:831
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:126
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:654
AVFilterContext
An instance of a filter.
Definition: avfilter.h:415
LibplaceboContext::crosstalk
float crosstalk
Definition: vf_libplacebo.c:127
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:64
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:73
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:39
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
LibplaceboContext::smoothing
float smoothing
Definition: vf_libplacebo.c:114
TONE_MAP_SPLINE
@ TONE_MAP_SPLINE
Definition: vf_libplacebo.c:34
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:656
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
LibplaceboContext::shader_path
char * shader_path
Definition: vf_libplacebo.c:145
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:80
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
LibplaceboContext::dither_lut_size
int dither_lut_size
Definition: vf_libplacebo.c:137
libplacebo_init
static int libplacebo_init(AVFilterContext *avctx)
Definition: vf_libplacebo.c:221
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:71
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:148
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
TONE_MAP_BT2390
@ TONE_MAP_BT2390
Definition: vf_libplacebo.c:32
RET
#define RET(x)
Definition: vulkan.h:52
log_cb
static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
Definition: fflcms2.c:25
LibplaceboContext::tex
pl_tex tex[8]
Definition: vf_libplacebo.c:65
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