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/avassert.h"
20 #include "libavutil/eval.h"
21 #include "libavutil/fifo.h"
22 #include "libavutil/file.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/parseutils.h"
25 #include "formats.h"
26 #include "internal.h"
27 #include "filters.h"
28 #include "video.h"
29 #include "vulkan_filter.h"
30 #include "scale_eval.h"
31 
32 #include <libplacebo/renderer.h>
33 #include <libplacebo/utils/libav.h>
34 #include <libplacebo/utils/frame_queue.h>
35 #include <libplacebo/vulkan.h>
36 
37 /* Backwards compatibility with older libplacebo */
38 #if PL_API_VER < 276
39 static inline AVFrame *pl_get_mapped_avframe(const struct pl_frame *frame)
40 {
41  return frame->user_data;
42 }
43 #endif
44 
45 #if PL_API_VER >= 309
46 #include <libplacebo/options.h>
47 #else
48 typedef struct pl_options_t {
49  // Backwards compatibility shim of this struct
50  struct pl_render_params params;
51  struct pl_deband_params deband_params;
52  struct pl_sigmoid_params sigmoid_params;
53  struct pl_color_adjustment color_adjustment;
54  struct pl_peak_detect_params peak_detect_params;
55  struct pl_color_map_params color_map_params;
56  struct pl_dither_params dither_params;
57  struct pl_cone_params cone_params;
58 } *pl_options;
59 
60 #define pl_options_alloc(log) av_mallocz(sizeof(struct pl_options_t))
61 #define pl_options_free(ptr) av_freep(ptr)
62 #endif
63 
64 enum {
78 };
79 
80 enum {
91 };
92 
93 static const char *const var_names[] = {
94  "in_idx", "idx",///< index of input
95  "in_w", "iw", ///< width of the input video frame
96  "in_h", "ih", ///< height of the input video frame
97  "out_w", "ow", ///< width of the output video frame
98  "out_h", "oh", ///< height of the output video frame
99  "crop_w", "cw", ///< evaluated input crop width
100  "crop_h", "ch", ///< evaluated input crop height
101  "pos_w", "pw", ///< evaluated output placement width
102  "pos_h", "ph", ///< evaluated output placement height
103  "a", ///< iw/ih
104  "sar", ///< input pixel aspect ratio
105  "dar", ///< output pixel aspect ratio
106  "hsub", ///< input horizontal subsampling factor
107  "vsub", ///< input vertical subsampling factor
108  "ohsub", ///< output horizontal subsampling factor
109  "ovsub", ///< output vertical subsampling factor
110  "in_t", "t", ///< input frame pts
111  "out_t", "ot", ///< output frame pts
112  "n", ///< number of frame
113  NULL,
114 };
115 
116 enum var_name {
137 };
138 
139 /* per-input dynamic filter state */
140 typedef struct LibplaceboInput {
141  int idx;
142  pl_renderer renderer;
143  pl_queue queue;
144  enum pl_queue_status qstatus;
145  struct pl_frame_mix mix; ///< temporary storage
147  AVFifo *out_pts; ///< timestamps of wanted output frames
148  int64_t status_pts;
149  int status;
151 
152 typedef struct LibplaceboContext {
153  /* lavfi vulkan*/
155 
156  /* libplacebo */
157  pl_log log;
158  pl_vulkan vulkan;
159  pl_gpu gpu;
160  pl_tex tex[4];
161 
162  /* input state */
165  int64_t status_pts; ///< tracks status of most recently used input
166  int status;
167 
168  /* settings */
171  char *fillcolor;
173  char *w_expr;
174  char *h_expr;
175  char *fps_string;
176  AVRational fps; ///< parsed FPS, or 0/0 for "none"
181  // Parsed expressions for input/output crop
196 
197  /* pl_render_params */
198  pl_options opts;
199  char *upscaler;
200  char *downscaler;
201  char *frame_mixer;
203  float antiringing;
204  int sigmoid;
205  int skip_aa;
211 
212  /* pl_deband_params */
213  int deband;
218 
219  /* pl_color_adjustment */
220  float brightness;
221  float contrast;
222  float saturation;
223  float hue;
224  float gamma;
225 
226  /* pl_peak_detect_params */
228  float smoothing;
229  float min_peak;
230  float scene_low;
231  float scene_high;
232  float percentile;
233 
234  /* pl_color_map_params */
242 
243 #if FF_API_LIBPLACEBO_OPTS
244  /* for backwards compatibility */
245  float desat_str;
246  float desat_exp;
247  int gamut_warning;
248  int gamut_clipping;
249  int force_icc_lut;
250  int intent;
251  int tonemapping_mode;
252  float crosstalk;
253  float overshoot;
254  float hybrid_mix;
255 #endif
256 
257  /* pl_dither_params */
261 
262  /* pl_cone_params */
263  int cones;
264  float cone_str;
265 
266  /* custom shaders */
267  char *shader_path;
268  void *shader_bin;
270  const struct pl_hook *hooks[2];
273 
274 static inline enum pl_log_level get_log_level(void)
275 {
276  int av_lev = av_log_get_level();
277  return av_lev >= AV_LOG_TRACE ? PL_LOG_TRACE :
278  av_lev >= AV_LOG_DEBUG ? PL_LOG_DEBUG :
279  av_lev >= AV_LOG_VERBOSE ? PL_LOG_INFO :
280  av_lev >= AV_LOG_WARNING ? PL_LOG_WARN :
281  av_lev >= AV_LOG_ERROR ? PL_LOG_ERR :
282  av_lev >= AV_LOG_FATAL ? PL_LOG_FATAL :
283  PL_LOG_NONE;
284 }
285 
286 static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
287 {
288  int av_lev;
289 
290  switch (level) {
291  case PL_LOG_FATAL: av_lev = AV_LOG_FATAL; break;
292  case PL_LOG_ERR: av_lev = AV_LOG_ERROR; break;
293  case PL_LOG_WARN: av_lev = AV_LOG_WARNING; break;
294  case PL_LOG_INFO: av_lev = AV_LOG_VERBOSE; break;
295  case PL_LOG_DEBUG: av_lev = AV_LOG_DEBUG; break;
296  case PL_LOG_TRACE: av_lev = AV_LOG_TRACE; break;
297  default: return;
298  }
299 
300  av_log(log_ctx, av_lev, "%s\n", msg);
301 }
302 
303 static const struct pl_tone_map_function *get_tonemapping_func(int tm) {
304  switch (tm) {
305  case TONE_MAP_AUTO: return &pl_tone_map_auto;
306  case TONE_MAP_CLIP: return &pl_tone_map_clip;
307 #if PL_API_VER >= 246
308  case TONE_MAP_ST2094_40: return &pl_tone_map_st2094_40;
309  case TONE_MAP_ST2094_10: return &pl_tone_map_st2094_10;
310 #endif
311  case TONE_MAP_BT2390: return &pl_tone_map_bt2390;
312  case TONE_MAP_BT2446A: return &pl_tone_map_bt2446a;
313  case TONE_MAP_SPLINE: return &pl_tone_map_spline;
314  case TONE_MAP_REINHARD: return &pl_tone_map_reinhard;
315  case TONE_MAP_MOBIUS: return &pl_tone_map_mobius;
316  case TONE_MAP_HABLE: return &pl_tone_map_hable;
317  case TONE_MAP_GAMMA: return &pl_tone_map_gamma;
318  case TONE_MAP_LINEAR: return &pl_tone_map_linear;
319  default: av_assert0(0);
320  }
321 }
322 
323 static void set_gamut_mode(struct pl_color_map_params *p, int gamut_mode)
324 {
325  switch (gamut_mode) {
326 #if PL_API_VER >= 269
327  case GAMUT_MAP_CLIP: p->gamut_mapping = &pl_gamut_map_clip; return;
328  case GAMUT_MAP_PERCEPTUAL: p->gamut_mapping = &pl_gamut_map_perceptual; return;
329  case GAMUT_MAP_RELATIVE: p->gamut_mapping = &pl_gamut_map_relative; return;
330  case GAMUT_MAP_SATURATION: p->gamut_mapping = &pl_gamut_map_saturation; return;
331  case GAMUT_MAP_ABSOLUTE: p->gamut_mapping = &pl_gamut_map_absolute; return;
332  case GAMUT_MAP_DESATURATE: p->gamut_mapping = &pl_gamut_map_desaturate; return;
333  case GAMUT_MAP_DARKEN: p->gamut_mapping = &pl_gamut_map_darken; return;
334  case GAMUT_MAP_HIGHLIGHT: p->gamut_mapping = &pl_gamut_map_highlight; return;
335  case GAMUT_MAP_LINEAR: p->gamut_mapping = &pl_gamut_map_linear; return;
336 #else
337  case GAMUT_MAP_RELATIVE: p->intent = PL_INTENT_RELATIVE_COLORIMETRIC; return;
338  case GAMUT_MAP_SATURATION: p->intent = PL_INTENT_SATURATION; return;
339  case GAMUT_MAP_ABSOLUTE: p->intent = PL_INTENT_ABSOLUTE_COLORIMETRIC; return;
340  case GAMUT_MAP_DESATURATE: p->gamut_mode = PL_GAMUT_DESATURATE; return;
341  case GAMUT_MAP_DARKEN: p->gamut_mode = PL_GAMUT_DARKEN; return;
342  case GAMUT_MAP_HIGHLIGHT: p->gamut_mode = PL_GAMUT_WARN; return;
343  /* Use defaults for all other cases */
344  default: return;
345 #endif
346  }
347 
348  av_assert0(0);
349 };
350 
351 static int find_scaler(AVFilterContext *avctx,
352  const struct pl_filter_config **opt,
353  const char *name, int frame_mixing)
354 {
355  const struct pl_filter_preset *preset, *presets_avail;
356  presets_avail = frame_mixing ? pl_frame_mixers : pl_scale_filters;
357 
358  if (!strcmp(name, "help")) {
359  av_log(avctx, AV_LOG_INFO, "Available scaler presets:\n");
360  for (preset = presets_avail; preset->name; preset++)
361  av_log(avctx, AV_LOG_INFO, " %s\n", preset->name);
362  return AVERROR_EXIT;
363  }
364 
365  for (preset = presets_avail; preset->name; preset++) {
366  if (!strcmp(name, preset->name)) {
367  *opt = preset->filter;
368  return 0;
369  }
370  }
371 
372  av_log(avctx, AV_LOG_ERROR, "No such scaler preset '%s'.\n", name);
373  return AVERROR(EINVAL);
374 }
375 
377 {
378  int err = 0;
379  LibplaceboContext *s = ctx->priv;
380  AVDictionaryEntry *e = NULL;
381  pl_options opts = s->opts;
382  int gamut_mode = s->gamut_mode;
383  uint8_t color_rgba[4];
384 
385 #if FF_API_LIBPLACEBO_OPTS
386  float hybrid_mix = s->hybrid_mix;
387  /* backwards compatibility with older API */
388  switch (s->tonemapping_mode) {
389  case 0: /*PL_TONE_MAP_AUTO*/
390  if (s->desat_str >= 0.0f)
391  hybrid_mix = s->desat_str;
392  break;
393  case 1: /*PL_TONE_MAP_RGB*/ hybrid_mix = 1.0f; break;
394  case 2: /*PL_TONE_MAP_HYBRID*/ hybrid_mix = 0.2f; break;
395  case 3: /*PL_TONE_MAP_LUMA*/ hybrid_mix = 0.0f; break;
396  case 4: /*PL_TONE_MAP_MAX*/ hybrid_mix = 0.0f; break;
397  }
398 
399  switch (s->intent) {
400  case PL_INTENT_SATURATION: gamut_mode = GAMUT_MAP_SATURATION; break;
401  case PL_INTENT_RELATIVE_COLORIMETRIC: gamut_mode = GAMUT_MAP_RELATIVE; break;
402  case PL_INTENT_ABSOLUTE_COLORIMETRIC: gamut_mode = GAMUT_MAP_ABSOLUTE; break;
403  }
404 
405  if (s->gamut_warning)
406  gamut_mode = GAMUT_MAP_HIGHLIGHT;
407  if (s->gamut_clipping)
408  gamut_mode = GAMUT_MAP_DESATURATE;
409 #endif
410 
411  RET(av_parse_color(color_rgba, s->fillcolor, -1, s));
412 
413  opts->deband_params = *pl_deband_params(
414  .iterations = s->deband_iterations,
415  .threshold = s->deband_threshold,
416  .radius = s->deband_radius,
417  .grain = s->deband_grain,
418  );
419 
420  opts->sigmoid_params = pl_sigmoid_default_params;
421 
422  opts->color_adjustment = (struct pl_color_adjustment) {
423  .brightness = s->brightness,
424  .contrast = s->contrast,
425  .saturation = s->saturation,
426  .hue = s->hue,
427  .gamma = s->gamma,
428  };
429 
430  opts->peak_detect_params = *pl_peak_detect_params(
431  .smoothing_period = s->smoothing,
432  .minimum_peak = s->min_peak,
433  .scene_threshold_low = s->scene_low,
434  .scene_threshold_high = s->scene_high,
435 #if PL_API_VER >= 263
436  .percentile = s->percentile,
437 #endif
438 #if FF_API_LIBPLACEBO_OPTS && PL_API_VER < 256
439  .overshoot_margin = s->overshoot,
440 #endif
441  );
442 
443  opts->color_map_params = *pl_color_map_params(
445 # if PL_API_VER >= 269
446  .hybrid_mix = hybrid_mix,
447 # else
448  .tone_mapping_mode = s->tonemapping_mode,
449  .tone_mapping_crosstalk = s->crosstalk,
450 # endif
451 #endif
452  .tone_mapping_function = get_tonemapping_func(s->tonemapping),
453  .tone_mapping_param = s->tonemapping_param,
454  .inverse_tone_mapping = s->inverse_tonemapping,
455  .lut_size = s->tonemapping_lut_size,
456 #if PL_API_VER >= 285
457  .contrast_recovery = s->contrast_recovery,
458  .contrast_smoothness = s->contrast_smoothness,
459 #endif
460  );
461 
462  set_gamut_mode(&opts->color_map_params, gamut_mode);
463 
464  opts->dither_params = *pl_dither_params(
465  .method = s->dithering,
466  .lut_size = s->dither_lut_size,
467  .temporal = s->dither_temporal,
468  );
469 
470  opts->cone_params = *pl_cone_params(
471  .cones = s->cones,
472  .strength = s->cone_str,
473  );
474 
475  opts->params = *pl_render_params(
476  .lut_entries = s->lut_entries,
477  .antiringing_strength = s->antiringing,
478  .background_transparency = 1.0f - (float) color_rgba[3] / UINT8_MAX,
479  .background_color = {
480  (float) color_rgba[0] / UINT8_MAX,
481  (float) color_rgba[1] / UINT8_MAX,
482  (float) color_rgba[2] / UINT8_MAX,
483  },
484 #if PL_API_VER >= 277
485  .corner_rounding = s->corner_rounding,
486 #endif
487 
488  .deband_params = s->deband ? &opts->deband_params : NULL,
489  .sigmoid_params = s->sigmoid ? &opts->sigmoid_params : NULL,
490  .color_adjustment = &opts->color_adjustment,
491  .peak_detect_params = s->peakdetect ? &opts->peak_detect_params : NULL,
492  .color_map_params = &opts->color_map_params,
493  .dither_params = s->dithering >= 0 ? &opts->dither_params : NULL,
494  .cone_params = s->cones ? &opts->cone_params : NULL,
495 
496  .hooks = s->hooks,
497  .num_hooks = s->num_hooks,
498 
499  .skip_anti_aliasing = s->skip_aa,
500  .polar_cutoff = s->polar_cutoff,
501  .disable_linear_scaling = s->disable_linear,
502  .disable_builtin_scalers = s->disable_builtin,
503  .force_dither = s->force_dither,
504  .disable_fbos = s->disable_fbos,
505  );
506 
507  RET(find_scaler(ctx, &opts->params.upscaler, s->upscaler, 0));
508  RET(find_scaler(ctx, &opts->params.downscaler, s->downscaler, 0));
509  RET(find_scaler(ctx, &opts->params.frame_mixer, s->frame_mixer, 1));
510 
511 #if PL_API_VER >= 309
512  while ((e = av_dict_get(s->extra_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
513  if (!pl_options_set_str(s->opts, e->key, e->value)) {
514  err = AVERROR(EINVAL);
515  goto fail;
516  }
517  }
518 #else
519  (void) e;
520  if (av_dict_count(s->extra_opts) > 0)
521  av_log(s, AV_LOG_WARNING, "extra_opts requires libplacebo >= 6.309!\n");
522 #endif
523 
524  return 0;
525 
526 fail:
527  return err;
528 }
529 
530 static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
531 {
532  LibplaceboContext *s = avctx->priv;
533  const struct pl_hook *hook;
534 
535  hook = pl_mpv_user_shader_parse(s->gpu, shader, len);
536  if (!hook) {
537  av_log(s, AV_LOG_ERROR, "Failed parsing custom shader!\n");
538  return AVERROR(EINVAL);
539  }
540 
541  s->hooks[s->num_hooks++] = hook;
542  return update_settings(avctx);
543 }
544 
545 static void libplacebo_uninit(AVFilterContext *avctx);
547 
549 {
550  int err = 0;
551  LibplaceboContext *s = avctx->priv;
552 
553  /* Create libplacebo log context */
554  s->log = pl_log_create(PL_API_VER, pl_log_params(
555  .log_level = get_log_level(),
556  .log_cb = pl_av_log,
557  .log_priv = s,
558  ));
559 
560  if (!s->log)
561  return AVERROR(ENOMEM);
562 
563  s->opts = pl_options_alloc(s->log);
564  if (!s->opts) {
565  libplacebo_uninit(avctx);
566  return AVERROR(ENOMEM);
567  }
568 
569  if (s->out_format_string) {
570  s->out_format = av_get_pix_fmt(s->out_format_string);
571  if (s->out_format == AV_PIX_FMT_NONE) {
572  av_log(avctx, AV_LOG_ERROR, "Invalid output format: %s\n",
573  s->out_format_string);
574  libplacebo_uninit(avctx);
575  return AVERROR(EINVAL);
576  }
577  } else {
578  s->out_format = AV_PIX_FMT_NONE;
579  }
580 
581  for (int i = 0; i < s->nb_inputs; i++) {
582  AVFilterPad pad = {
583  .name = av_asprintf("input%d", i),
584  .type = AVMEDIA_TYPE_VIDEO,
585  .config_props = &libplacebo_config_input,
586  };
587  if (!pad.name)
588  return AVERROR(ENOMEM);
589  RET(ff_append_inpad_free_name(avctx, &pad));
590  }
591 
592  RET(update_settings(avctx));
593  RET(av_expr_parse(&s->crop_x_pexpr, s->crop_x_expr, var_names,
594  NULL, NULL, NULL, NULL, 0, s));
595  RET(av_expr_parse(&s->crop_y_pexpr, s->crop_y_expr, var_names,
596  NULL, NULL, NULL, NULL, 0, s));
597  RET(av_expr_parse(&s->crop_w_pexpr, s->crop_w_expr, var_names,
598  NULL, NULL, NULL, NULL, 0, s));
599  RET(av_expr_parse(&s->crop_h_pexpr, s->crop_h_expr, var_names,
600  NULL, NULL, NULL, NULL, 0, s));
601  RET(av_expr_parse(&s->pos_x_pexpr, s->pos_x_expr, var_names,
602  NULL, NULL, NULL, NULL, 0, s));
603  RET(av_expr_parse(&s->pos_y_pexpr, s->pos_y_expr, var_names,
604  NULL, NULL, NULL, NULL, 0, s));
605  RET(av_expr_parse(&s->pos_w_pexpr, s->pos_w_expr, var_names,
606  NULL, NULL, NULL, NULL, 0, s));
607  RET(av_expr_parse(&s->pos_h_pexpr, s->pos_h_expr, var_names,
608  NULL, NULL, NULL, NULL, 0, s));
609 
610  if (strcmp(s->fps_string, "none") != 0)
611  RET(av_parse_video_rate(&s->fps, s->fps_string));
612 
613  /* Note: s->vulkan etc. are initialized later, when hwctx is available */
614  return 0;
615 
616 fail:
617  return err;
618 }
619 
620 #if PL_API_VER >= 278
621 static void lock_queue(void *priv, uint32_t qf, uint32_t qidx)
622 {
623  AVHWDeviceContext *avhwctx = priv;
624  const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
625  hwctx->lock_queue(avhwctx, qf, qidx);
626 }
627 
628 static void unlock_queue(void *priv, uint32_t qf, uint32_t qidx)
629 {
630  AVHWDeviceContext *avhwctx = priv;
631  const AVVulkanDeviceContext *hwctx = avhwctx->hwctx;
632  hwctx->unlock_queue(avhwctx, qf, qidx);
633 }
634 #endif
635 
637  LibplaceboInput *input, int idx)
638 {
639  LibplaceboContext *s = avctx->priv;
640 
641  input->out_pts = av_fifo_alloc2(1, sizeof(int64_t), AV_FIFO_FLAG_AUTO_GROW);
642  if (!input->out_pts)
643  return AVERROR(ENOMEM);
644  input->queue = pl_queue_create(s->gpu);
645  input->renderer = pl_renderer_create(s->log, s->gpu);
646  input->link = link;
647  input->idx = idx;
648 
649  return 0;
650 }
651 
653 {
654  pl_renderer_destroy(&input->renderer);
655  pl_queue_destroy(&input->queue);
656  av_fifo_freep2(&input->out_pts);
657 }
658 
659 static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwctx)
660 {
661  int err = 0;
662  LibplaceboContext *s = avctx->priv;
663  uint8_t *buf = NULL;
664  size_t buf_len;
665 
666  if (hwctx) {
667 #if PL_API_VER >= 278
668  /* Import libavfilter vulkan context into libplacebo */
669  s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(
670  .instance = hwctx->inst,
671  .get_proc_addr = hwctx->get_proc_addr,
672  .phys_device = hwctx->phys_dev,
673  .device = hwctx->act_dev,
674  .extensions = hwctx->enabled_dev_extensions,
675  .num_extensions = hwctx->nb_enabled_dev_extensions,
676  .features = &hwctx->device_features,
677  .lock_queue = lock_queue,
678  .unlock_queue = unlock_queue,
679  .queue_ctx = avctx->hw_device_ctx->data,
680  .queue_graphics = {
681  .index = hwctx->queue_family_index,
682  .count = hwctx->nb_graphics_queues,
683  },
684  .queue_compute = {
685  .index = hwctx->queue_family_comp_index,
686  .count = hwctx->nb_comp_queues,
687  },
688  .queue_transfer = {
689  .index = hwctx->queue_family_tx_index,
690  .count = hwctx->nb_tx_queues,
691  },
692  /* This is the highest version created by hwcontext_vulkan.c */
693  .max_api_version = VK_API_VERSION_1_3,
694  ));
695 #else
696  av_log(s, AV_LOG_ERROR, "libplacebo version %s too old to import "
697  "Vulkan device, remove it or upgrade libplacebo to >= 5.278\n",
698  PL_VERSION);
699  err = AVERROR_EXTERNAL;
700  goto fail;
701 #endif
702  } else {
703  s->vulkan = pl_vulkan_create(s->log, pl_vulkan_params(
704  .queue_count = 0, /* enable all queues for parallelization */
705  ));
706  }
707 
708  if (!s->vulkan) {
709  av_log(s, AV_LOG_ERROR, "Failed %s Vulkan device!\n",
710  hwctx ? "importing" : "creating");
711  err = AVERROR_EXTERNAL;
712  goto fail;
713  }
714 
715  s->gpu = s->vulkan->gpu;
716 
717  /* Parse the user shaders, if requested */
718  if (s->shader_bin_len)
719  RET(parse_shader(avctx, s->shader_bin, s->shader_bin_len));
720 
721  if (s->shader_path && s->shader_path[0]) {
722  RET(av_file_map(s->shader_path, &buf, &buf_len, 0, s));
723  RET(parse_shader(avctx, buf, buf_len));
724  }
725 
726  /* Initialize inputs */
727  s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs));
728  if (!s->inputs)
729  return AVERROR(ENOMEM);
730  for (int i = 0; i < s->nb_inputs; i++)
731  RET(input_init(avctx, avctx->inputs[i], &s->inputs[i], i));
732 
733  /* fall through */
734 fail:
735  if (buf)
736  av_file_unmap(buf, buf_len);
737  return err;
738 }
739 
741 {
742  LibplaceboContext *s = avctx->priv;
743 
744  for (int i = 0; i < FF_ARRAY_ELEMS(s->tex); i++)
745  pl_tex_destroy(s->gpu, &s->tex[i]);
746  for (int i = 0; i < s->num_hooks; i++)
747  pl_mpv_user_shader_destroy(&s->hooks[i]);
748  if (s->inputs) {
749  for (int i = 0; i < s->nb_inputs; i++)
750  input_uninit(&s->inputs[i]);
751  av_freep(&s->inputs);
752  }
753 
754  pl_options_free(&s->opts);
755  pl_vulkan_destroy(&s->vulkan);
756  pl_log_destroy(&s->log);
757  ff_vk_uninit(&s->vkctx);
758  s->gpu = NULL;
759 
760  av_expr_free(s->crop_x_pexpr);
761  av_expr_free(s->crop_y_pexpr);
762  av_expr_free(s->crop_w_pexpr);
763  av_expr_free(s->crop_h_pexpr);
764  av_expr_free(s->pos_x_pexpr);
765  av_expr_free(s->pos_y_pexpr);
766  av_expr_free(s->pos_w_pexpr);
767  av_expr_free(s->pos_h_pexpr);
768 }
769 
770 static int libplacebo_process_command(AVFilterContext *ctx, const char *cmd,
771  const char *arg, char *res, int res_len,
772  int flags)
773 {
774  int err = 0;
775  RET(ff_filter_process_command(ctx, cmd, arg, res, res_len, flags));
777  return 0;
778 
779 fail:
780  return err;
781 }
782 
783 static const AVFrame *ref_frame(const struct pl_frame_mix *mix)
784 {
785  for (int i = 0; i < mix->num_frames; i++) {
786  if (i+1 == mix->num_frames || mix->timestamps[i+1] > 0)
787  return pl_get_mapped_avframe(mix->frames[i]);
788  }
789  return NULL;
790 }
791 
793  struct pl_frame *target, double target_pts)
794 {
795  LibplaceboContext *s = ctx->priv;
796  const AVFrame *ref = ref_frame(&in->mix);
797 
798  for (int i = 0; i < in->mix.num_frames; i++) {
799  // Mutate the `pl_frame.crop` fields in-place. This is fine because we
800  // own the entire pl_queue, and hence, the pointed-at frames.
801  struct pl_frame *image = (struct pl_frame *) in->mix.frames[i];
802  const AVFrame *src = pl_get_mapped_avframe(image);
803  double image_pts = src->pts * av_q2d(in->link->time_base);
804 
805  /* Update dynamic variables */
806  s->var_values[VAR_IN_IDX] = s->var_values[VAR_IDX] = in->idx;
807  s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = in->link->w;
808  s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = in->link->h;
809  s->var_values[VAR_A] = (double) in->link->w / in->link->h;
810  s->var_values[VAR_SAR] = in->link->sample_aspect_ratio.num ?
811  av_q2d(in->link->sample_aspect_ratio) : 1.0;
812  s->var_values[VAR_IN_T] = s->var_values[VAR_T] = image_pts;
813  s->var_values[VAR_OUT_T] = s->var_values[VAR_OT] = target_pts;
814  s->var_values[VAR_N] = ctx->outputs[0]->frame_count_out;
815 
816  /* Clear these explicitly to avoid leaking previous frames' state */
817  s->var_values[VAR_CROP_W] = s->var_values[VAR_CW] = NAN;
818  s->var_values[VAR_CROP_H] = s->var_values[VAR_CH] = NAN;
819  s->var_values[VAR_POS_W] = s->var_values[VAR_PW] = NAN;
820  s->var_values[VAR_POS_H] = s->var_values[VAR_PH] = NAN;
821 
822  /* Compute dimensions first and placement second */
823  s->var_values[VAR_CROP_W] = s->var_values[VAR_CW] =
824  av_expr_eval(s->crop_w_pexpr, s->var_values, NULL);
825  s->var_values[VAR_CROP_H] = s->var_values[VAR_CH] =
826  av_expr_eval(s->crop_h_pexpr, s->var_values, NULL);
827  s->var_values[VAR_CROP_W] = s->var_values[VAR_CW] =
828  av_expr_eval(s->crop_w_pexpr, s->var_values, NULL);
829  s->var_values[VAR_POS_W] = s->var_values[VAR_PW] =
830  av_expr_eval(s->pos_w_pexpr, s->var_values, NULL);
831  s->var_values[VAR_POS_H] = s->var_values[VAR_PH] =
832  av_expr_eval(s->pos_h_pexpr, s->var_values, NULL);
833  s->var_values[VAR_POS_W] = s->var_values[VAR_PW] =
834  av_expr_eval(s->pos_w_pexpr, s->var_values, NULL);
835 
836  image->crop.x0 = av_expr_eval(s->crop_x_pexpr, s->var_values, NULL);
837  image->crop.y0 = av_expr_eval(s->crop_y_pexpr, s->var_values, NULL);
838  image->crop.x1 = image->crop.x0 + s->var_values[VAR_CROP_W];
839  image->crop.y1 = image->crop.y0 + s->var_values[VAR_CROP_H];
840 
841  if (src == ref) {
842  /* Only update the target crop once, for the 'reference' frame */
843  target->crop.x0 = av_expr_eval(s->pos_x_pexpr, s->var_values, NULL);
844  target->crop.y0 = av_expr_eval(s->pos_y_pexpr, s->var_values, NULL);
845  target->crop.x1 = target->crop.x0 + s->var_values[VAR_POS_W];
846  target->crop.y1 = target->crop.y0 + s->var_values[VAR_POS_H];
847  if (s->normalize_sar) {
848  float aspect = pl_rect2df_aspect(&image->crop);
849  aspect *= av_q2d(in->link->sample_aspect_ratio);
850  pl_rect2df_aspect_set(&target->crop, aspect, s->pad_crop_ratio);
851  }
852  }
853  }
854 }
855 
856 /* Construct and emit an output frame for a given timestamp */
857 static int output_frame(AVFilterContext *ctx, int64_t pts)
858 {
859  int err = 0, ok, changed_csp;
860  LibplaceboContext *s = ctx->priv;
861  pl_options opts = s->opts;
862  AVFilterLink *outlink = ctx->outputs[0];
863  const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outlink->format);
864  struct pl_frame target;
865  const AVFrame *ref = NULL;
866  AVFrame *out;
867 
868  /* Use the first active input as metadata reference */
869  for (int i = 0; i < s->nb_inputs; i++) {
870  const LibplaceboInput *in = &s->inputs[i];
871  if (in->qstatus == PL_QUEUE_OK && (ref = ref_frame(&in->mix)))
872  break;
873  }
874  if (!ref)
875  return 0;
876 
877  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
878  if (!out)
879  return AVERROR(ENOMEM);
880 
882  out->pts = pts;
883  out->width = outlink->w;
884  out->height = outlink->h;
885  if (s->fps.num)
886  out->duration = 1;
887 
889  /* Output of dovi reshaping is always BT.2020+PQ, so infer the correct
890  * output colorspace defaults */
891  out->colorspace = AVCOL_SPC_BT2020_NCL;
892  out->color_primaries = AVCOL_PRI_BT2020;
893  out->color_trc = AVCOL_TRC_SMPTE2084;
894  }
895 
896  if (s->colorspace >= 0)
897  out->colorspace = s->colorspace;
898  if (s->color_range >= 0)
899  out->color_range = s->color_range;
900  if (s->color_trc >= 0)
901  out->color_trc = s->color_trc;
902  if (s->color_primaries >= 0)
903  out->color_primaries = s->color_primaries;
904 
905  /* Sanity colorspace overrides */
906  if (outdesc->flags & AV_PIX_FMT_FLAG_RGB) {
907  out->colorspace = AVCOL_SPC_RGB;
908  } else if (out->colorspace == AVCOL_SPC_RGB) {
909  out->colorspace = AVCOL_SPC_UNSPECIFIED;
910  }
911 
912  changed_csp = ref->colorspace != out->colorspace ||
913  ref->color_range != out->color_range ||
914  ref->color_trc != out->color_trc ||
915  ref->color_primaries != out->color_primaries;
916 
917  /* Strip side data if no longer relevant */
918  if (changed_csp) {
922  }
923  if (s->apply_dovi || changed_csp) {
926  }
927  if (s->apply_filmgrain)
929 
930  /* Map, render and unmap output frame */
931  if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
932  ok = pl_map_avframe_ex(s->gpu, &target, pl_avframe_params(
933  .frame = out,
934  .map_dovi = false,
935  ));
936  } else {
937  ok = pl_frame_recreate_from_avframe(s->gpu, &target, s->tex, out);
938  }
939  if (!ok) {
940  err = AVERROR_EXTERNAL;
941  goto fail;
942  }
943 
944  /* Draw first frame opaque, others with blending */
945  opts->params.skip_target_clearing = false;
946  opts->params.blend_params = NULL;
947  for (int i = 0; i < s->nb_inputs; i++) {
948  LibplaceboInput *in = &s->inputs[i];
949  int high_fps = av_cmp_q(in->link->frame_rate, outlink->frame_rate) >= 0;
950  if (in->qstatus != PL_QUEUE_OK)
951  continue;
952  opts->params.skip_caching_single_frame = high_fps;
953  update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base));
954  pl_render_image_mix(in->renderer, &in->mix, &target, &opts->params);
955  opts->params.skip_target_clearing = true;
956  opts->params.blend_params = &pl_alpha_overlay;
957  }
958 
959  if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
960  pl_unmap_avframe(s->gpu, &target);
961  } else if (!pl_download_avframe(s->gpu, &target, out)) {
962  err = AVERROR_EXTERNAL;
963  goto fail;
964  }
965  return ff_filter_frame(outlink, out);
966 
967 fail:
968  av_frame_free(&out);
969  return err;
970 }
971 
972 static bool map_frame(pl_gpu gpu, pl_tex *tex,
973  const struct pl_source_frame *src,
974  struct pl_frame *out)
975 {
976  AVFrame *avframe = src->frame_data;
977  LibplaceboContext *s = avframe->opaque;
978  bool ok = pl_map_avframe_ex(gpu, out, pl_avframe_params(
979  .frame = avframe,
980  .tex = tex,
981  .map_dovi = s->apply_dovi,
982  ));
983 
984  if (!s->apply_filmgrain)
985  out->film_grain.type = PL_FILM_GRAIN_NONE;
986 
987  av_frame_free(&avframe);
988  return ok;
989 }
990 
991 static void unmap_frame(pl_gpu gpu, struct pl_frame *frame,
992  const struct pl_source_frame *src)
993 {
994  pl_unmap_avframe(gpu, frame);
995 }
996 
997 static void discard_frame(const struct pl_source_frame *src)
998 {
999  AVFrame *avframe = src->frame_data;
1000  av_frame_free(&avframe);
1001 }
1002 
1004 {
1005  int ret, status;
1006  LibplaceboContext *s = ctx->priv;
1007  AVFilterLink *outlink = ctx->outputs[0];
1008  AVFrame *in;
1009  int64_t pts;
1010 
1011  while ((ret = ff_inlink_consume_frame(input->link, &in)) > 0) {
1012  in->opaque = s;
1013  pl_queue_push(input->queue, &(struct pl_source_frame) {
1014  .pts = in->pts * av_q2d(input->link->time_base),
1015  .duration = in->duration * av_q2d(input->link->time_base),
1016  .first_field = pl_field_from_avframe(in),
1017  .frame_data = in,
1018  .map = map_frame,
1019  .unmap = unmap_frame,
1020  .discard = discard_frame,
1021  });
1022 
1023  if (!s->fps.num) {
1024  /* Internally queue an output frame for the same PTS */
1025  pts = av_rescale_q(in->pts, input->link->time_base, outlink->time_base);
1026  av_fifo_write(input->out_pts, &pts, 1);
1027  }
1028  }
1029 
1030  if (ret < 0)
1031  return ret;
1032 
1033  if (!input->status && ff_inlink_acknowledge_status(input->link, &status, &pts)) {
1034  pts = av_rescale_q_rnd(pts, input->link->time_base, outlink->time_base,
1035  AV_ROUND_UP);
1036  pl_queue_push(input->queue, NULL); /* Signal EOF to pl_queue */
1037  input->status = status;
1038  input->status_pts = pts;
1039  if (!s->status || pts >= s->status_pts) {
1040  /* Also propagate to output unless overwritten by later status change */
1041  s->status = status;
1042  s->status_pts = pts;
1043  }
1044  }
1045 
1046  return 0;
1047 }
1048 
1049 static void drain_input_pts(LibplaceboInput *in, int64_t until)
1050 {
1051  int64_t pts;
1052  while (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0 && pts <= until)
1053  av_fifo_drain2(in->out_pts, 1);
1054 }
1055 
1057 {
1058  int ret, ok = 0, retry = 0;
1059  LibplaceboContext *s = ctx->priv;
1060  AVFilterLink *outlink = ctx->outputs[0];
1061  int64_t pts, out_pts;
1062 
1064  pl_log_level_update(s->log, get_log_level());
1065 
1066  for (int i = 0; i < s->nb_inputs; i++) {
1067  if ((ret = handle_input(ctx, &s->inputs[i])) < 0)
1068  return ret;
1069  }
1070 
1071  if (ff_outlink_frame_wanted(outlink)) {
1072  if (s->fps.num) {
1073  out_pts = outlink->frame_count_out;
1074  } else {
1075  /* Determine the PTS of the next frame from any active input */
1076  out_pts = INT64_MAX;
1077  for (int i = 0; i < s->nb_inputs; i++) {
1078  LibplaceboInput *in = &s->inputs[i];
1079  if (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0) {
1080  out_pts = FFMIN(out_pts, pts);
1081  } else if (!in->status) {
1083  retry = true;
1084  }
1085  }
1086 
1087  if (retry) /* some inputs are incomplete */
1088  return 0;
1089  }
1090 
1091  /* Update all input queues to the chosen out_pts */
1092  for (int i = 0; i < s->nb_inputs; i++) {
1093  LibplaceboInput *in = &s->inputs[i];
1094  if (in->status && out_pts >= in->status_pts) {
1095  in->qstatus = PL_QUEUE_EOF;
1096  continue;
1097  }
1098 
1099  in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params(
1100  .pts = out_pts * av_q2d(outlink->time_base),
1101  .radius = pl_frame_mix_radius(&s->opts->params),
1102  .vsync_duration = av_q2d(av_inv_q(outlink->frame_rate)),
1103  ));
1104 
1105  switch (in->qstatus) {
1106  case PL_QUEUE_MORE:
1108  retry = true;
1109  break;
1110  case PL_QUEUE_OK:
1111  ok = true;
1112  break;
1113  case PL_QUEUE_ERR:
1114  return AVERROR_EXTERNAL;
1115  }
1116  }
1117 
1118  if (retry) {
1119  return 0;
1120  } else if (ok) {
1121  /* Got any valid frame mixes, drain PTS queue and render output */
1122  for (int i = 0; i < s->nb_inputs; i++)
1123  drain_input_pts(&s->inputs[i], out_pts);
1124  return output_frame(ctx, out_pts);
1125  } else if (s->status) {
1126  ff_outlink_set_status(outlink, s->status, s->status_pts);
1127  return 0;
1128  }
1129 
1130  return AVERROR_BUG;
1131  }
1132 
1133  return FFERROR_NOT_READY;
1134 }
1135 
1137 {
1138  int err;
1139  LibplaceboContext *s = ctx->priv;
1140  const AVVulkanDeviceContext *vkhwctx = NULL;
1141  const AVPixFmtDescriptor *desc = NULL;
1142  AVFilterFormats *infmts = NULL, *outfmts = NULL;
1143 
1144  if (ctx->hw_device_ctx) {
1145  const AVHWDeviceContext *avhwctx = (void *) ctx->hw_device_ctx->data;
1146  if (avhwctx->type == AV_HWDEVICE_TYPE_VULKAN)
1147  vkhwctx = avhwctx->hwctx;
1148  }
1149 
1150  RET(init_vulkan(ctx, vkhwctx));
1151 
1152  while ((desc = av_pix_fmt_desc_next(desc))) {
1154 
1155 #if PL_API_VER < 232
1156  // Older libplacebo can't handle >64-bit pixel formats, so safe-guard
1157  // this to prevent triggering an assertion
1158  if (av_get_bits_per_pixel(desc) > 64)
1159  continue;
1160 #endif
1161 
1162  if (pixfmt == AV_PIX_FMT_VULKAN) {
1163  if (!vkhwctx || vkhwctx->act_dev != s->vulkan->device)
1164  continue;
1165  }
1166 
1167  if (!pl_test_pixfmt(s->gpu, pixfmt))
1168  continue;
1169 
1170  RET(ff_add_format(&infmts, pixfmt));
1171 
1172  /* Filter for supported output pixel formats */
1173  if (desc->flags & AV_PIX_FMT_FLAG_BE)
1174  continue; /* BE formats are not supported by pl_download_avframe */
1175 
1176  /* Mask based on user specified format */
1177  if (s->out_format != AV_PIX_FMT_NONE) {
1178  if (pixfmt == AV_PIX_FMT_VULKAN && av_vkfmt_from_pixfmt(s->out_format)) {
1179  /* OK */
1180  } else if (pixfmt == s->out_format) {
1181  /* OK */
1182  } else {
1183  continue; /* Not OK */
1184  }
1185  }
1186 
1187 #if PL_API_VER >= 293
1188  if (!pl_test_pixfmt_caps(s->gpu, pixfmt, PL_FMT_CAP_RENDERABLE))
1189  continue;
1190 #endif
1191 
1192  RET(ff_add_format(&outfmts, pixfmt));
1193  }
1194 
1195  if (!infmts || !outfmts) {
1196  if (s->out_format) {
1197  av_log(s, AV_LOG_ERROR, "Invalid output format '%s'!\n",
1198  av_get_pix_fmt_name(s->out_format));
1199  }
1200  err = AVERROR(EINVAL);
1201  goto fail;
1202  }
1203 
1204  for (int i = 0; i < s->nb_inputs; i++)
1205  RET(ff_formats_ref(infmts, &ctx->inputs[i]->outcfg.formats));
1206  RET(ff_formats_ref(outfmts, &ctx->outputs[0]->incfg.formats));
1207  return 0;
1208 
1209 fail:
1210  if (infmts && !infmts->refcount)
1211  ff_formats_unref(&infmts);
1212  if (outfmts && !outfmts->refcount)
1213  ff_formats_unref(&outfmts);
1214  return err;
1215 }
1216 
1218 {
1219  AVFilterContext *avctx = inlink->dst;
1220  LibplaceboContext *s = avctx->priv;
1221 
1222  if (inlink->format == AV_PIX_FMT_VULKAN)
1224 
1225  /* Forward this to the vkctx for format selection */
1226  s->vkctx.input_format = inlink->format;
1227 
1228  return 0;
1229 }
1230 
1232 {
1233  return av_cmp_q(a, b) < 0 ? b : a;
1234 }
1235 
1237 {
1238  int err;
1239  AVFilterContext *avctx = outlink->src;
1240  LibplaceboContext *s = avctx->priv;
1241  AVFilterLink *inlink = outlink->src->inputs[0];
1243  const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format);
1244  AVHWFramesContext *hwfc;
1245  AVVulkanFramesContext *vkfc;
1246 
1247  /* Frame dimensions */
1248  RET(ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
1249  &outlink->w, &outlink->h));
1250 
1251  ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
1252  s->force_original_aspect_ratio,
1253  s->force_divisible_by);
1254 
1255  if (s->normalize_sar || s->nb_inputs > 1) {
1256  /* SAR is normalized, or we have multiple inputs, set out to 1:1 */
1257  outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
1258  } else {
1259  /* This is consistent with other scale_* filters, which only
1260  * set the outlink SAR to be equal to the scale SAR iff the input SAR
1261  * was set to something nonzero */
1262  if (inlink->sample_aspect_ratio.num)
1263  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
1264  }
1265 
1266  /* Frame rate */
1267  if (s->fps.num) {
1268  outlink->frame_rate = s->fps;
1269  outlink->time_base = av_inv_q(s->fps);
1270  } else {
1271  outlink->frame_rate = avctx->inputs[0]->frame_rate;
1272  outlink->time_base = avctx->inputs[0]->time_base;
1273  for (int i = 1; i < s->nb_inputs; i++) {
1274  outlink->frame_rate = max_q(outlink->frame_rate,
1275  avctx->inputs[i]->frame_rate);
1276  outlink->time_base = av_gcd_q(outlink->time_base,
1277  avctx->inputs[i]->time_base,
1279  }
1280  }
1281 
1282  /* Static variables */
1283  s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = outlink->w;
1284  s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = outlink->h;
1285  s->var_values[VAR_DAR] = outlink->sample_aspect_ratio.num ?
1286  av_q2d(outlink->sample_aspect_ratio) : 1.0;
1287  s->var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
1288  s->var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
1289  s->var_values[VAR_OHSUB] = 1 << out_desc->log2_chroma_w;
1290  s->var_values[VAR_OVSUB] = 1 << out_desc->log2_chroma_h;
1291 
1292  if (outlink->format != AV_PIX_FMT_VULKAN)
1293  return 0;
1294 
1295  s->vkctx.output_width = outlink->w;
1296  s->vkctx.output_height = outlink->h;
1297  /* Default to re-using the input format */
1298  if (s->out_format == AV_PIX_FMT_NONE || s->out_format == AV_PIX_FMT_VULKAN) {
1299  s->vkctx.output_format = s->vkctx.input_format;
1300  } else {
1301  s->vkctx.output_format = s->out_format;
1302  }
1303  RET(ff_vk_filter_config_output(outlink));
1304  hwfc = (AVHWFramesContext *) outlink->hw_frames_ctx->data;
1305  vkfc = hwfc->hwctx;
1306  vkfc->usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1307 
1308  return 0;
1309 
1310 fail:
1311  return err;
1312 }
1313 
1314 #define OFFSET(x) offsetof(LibplaceboContext, x)
1315 #define STATIC (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
1316 #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM)
1317 
1318 static const AVOption libplacebo_options[] = {
1319  { "inputs", "Number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, .flags = STATIC },
1320  { "w", "Output video frame width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = STATIC },
1321  { "h", "Output video frame height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = STATIC },
1322  { "fps", "Output video frame rate", OFFSET(fps_string), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = STATIC },
1323  { "crop_x", "Input video crop x", OFFSET(crop_x_expr), AV_OPT_TYPE_STRING, {.str = "(iw-cw)/2"}, .flags = DYNAMIC },
1324  { "crop_y", "Input video crop y", OFFSET(crop_y_expr), AV_OPT_TYPE_STRING, {.str = "(ih-ch)/2"}, .flags = DYNAMIC },
1325  { "crop_w", "Input video crop w", OFFSET(crop_w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = DYNAMIC },
1326  { "crop_h", "Input video crop h", OFFSET(crop_h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = DYNAMIC },
1327  { "pos_x", "Output video placement x", OFFSET(pos_x_expr), AV_OPT_TYPE_STRING, {.str = "(ow-pw)/2"}, .flags = DYNAMIC },
1328  { "pos_y", "Output video placement y", OFFSET(pos_y_expr), AV_OPT_TYPE_STRING, {.str = "(oh-ph)/2"}, .flags = DYNAMIC },
1329  { "pos_w", "Output video placement w", OFFSET(pos_w_expr), AV_OPT_TYPE_STRING, {.str = "ow"}, .flags = DYNAMIC },
1330  { "pos_h", "Output video placement h", OFFSET(pos_h_expr), AV_OPT_TYPE_STRING, {.str = "oh"}, .flags = DYNAMIC },
1331  { "format", "Output video format", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = STATIC },
1332  { "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" },
1333  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, STATIC, "force_oar" },
1334  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, "force_oar" },
1335  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, "force_oar" },
1336  { "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 },
1337  { "normalize_sar", "force SAR normalization to 1:1 by adjusting pos_x/y/w/h", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
1338  { "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 },
1339  { "fillcolor", "Background fill color", OFFSET(fillcolor), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC },
1340  { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC },
1341  { "extra_opts", "Pass extra libplacebo-specific options using a :-separated list of key=value pairs", OFFSET(extra_opts), AV_OPT_TYPE_DICT, .flags = DYNAMIC },
1342 
1343  {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
1344  {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1345  {"gbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_RGB}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1346  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT709}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1347  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1348  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT470BG}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1349  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1350  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1351  {"ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1352  {"bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1353  {"bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1354  {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, STATIC, "colorspace"},
1355 
1356  {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_RANGE_NB-1, DYNAMIC, "range"},
1357  {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, STATIC, "range"},
1358  {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
1359  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
1360  {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
1361  {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
1362  {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
1363  {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
1364  {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
1365  {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
1366 
1367  {"color_primaries", "select color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_PRI_NB-1, DYNAMIC, "color_primaries"},
1368  {"auto", "keep the same color primaries", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1369  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT709}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1370  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1371  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1372  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470BG}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1373  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1374  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1375  {"film", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_FILM}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1376  {"bt2020", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT2020}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1377  {"smpte428", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1378  {"smpte431", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1379  {"smpte432", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1380  {"jedec-p22", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_JEDEC_P22}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1381  {"ebu3213", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_EBU3213}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
1382 
1383  {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, DYNAMIC, "color_trc"},
1384  {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1385  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT709}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1386  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1387  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA22}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1388  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA28}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1389  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1390  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1391  {"linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LINEAR}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1392  {"iec61966-2-4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_4}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1393  {"bt1361e", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT1361_ECG}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1394  {"iec61966-2-1", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1395  {"bt2020-10", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_10}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1396  {"bt2020-12", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_12}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1397  {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1398  {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, INT_MIN, INT_MAX, STATIC, "color_trc"},
1399 
1400  { "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC },
1401  { "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC },
1402  { "frame_mixer", "Frame mixing function", OFFSET(frame_mixer), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = DYNAMIC },
1403  { "lut_entries", "Number of scaler LUT entries", OFFSET(lut_entries), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 256, DYNAMIC },
1404  { "antiringing", "Antiringing strength (for non-EWA filters)", OFFSET(antiringing), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, DYNAMIC },
1405  { "sigmoid", "Enable sigmoid upscaling", OFFSET(sigmoid), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
1406  { "apply_filmgrain", "Apply film grain metadata", OFFSET(apply_filmgrain), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
1407  { "apply_dolbyvision", "Apply Dolby Vision metadata", OFFSET(apply_dovi), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
1408 
1409  { "deband", "Enable debanding", OFFSET(deband), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1410  { "deband_iterations", "Deband iterations", OFFSET(deband_iterations), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 16, DYNAMIC },
1411  { "deband_threshold", "Deband threshold", OFFSET(deband_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 4.0}, 0.0, 1024.0, DYNAMIC },
1412  { "deband_radius", "Deband radius", OFFSET(deband_radius), AV_OPT_TYPE_FLOAT, {.dbl = 16.0}, 0.0, 1024.0, DYNAMIC },
1413  { "deband_grain", "Deband grain", OFFSET(deband_grain), AV_OPT_TYPE_FLOAT, {.dbl = 6.0}, 0.0, 1024.0, DYNAMIC },
1414 
1415  { "brightness", "Brightness boost", OFFSET(brightness), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -1.0, 1.0, DYNAMIC },
1416  { "contrast", "Contrast gain", OFFSET(contrast), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
1417  { "saturation", "Saturation gain", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
1418  { "hue", "Hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -M_PI, M_PI, DYNAMIC },
1419  { "gamma", "Gamma adjustment", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
1420 
1421  { "peak_detect", "Enable dynamic peak detection for HDR tone-mapping", OFFSET(peakdetect), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
1422  { "smoothing_period", "Peak detection smoothing period", OFFSET(smoothing), AV_OPT_TYPE_FLOAT, {.dbl = 100.0}, 0.0, 1000.0, DYNAMIC },
1423  { "minimum_peak", "Peak detection minimum peak", OFFSET(min_peak), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 100.0, DYNAMIC },
1424  { "scene_threshold_low", "Scene change low threshold", OFFSET(scene_low), AV_OPT_TYPE_FLOAT, {.dbl = 5.5}, -1.0, 100.0, DYNAMIC },
1425  { "scene_threshold_high", "Scene change high threshold", OFFSET(scene_high), AV_OPT_TYPE_FLOAT, {.dbl = 10.0}, -1.0, 100.0, DYNAMIC },
1426  { "percentile", "Peak detection percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl = 99.995}, 0.0, 100.0, DYNAMIC },
1427 
1428  { "gamut_mode", "Gamut-mapping mode", OFFSET(gamut_mode), AV_OPT_TYPE_INT, {.i64 = GAMUT_MAP_PERCEPTUAL}, 0, GAMUT_MAP_COUNT - 1, DYNAMIC, "gamut_mode" },
1429  { "clip", "Hard-clip (RGB per-channel)", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_CLIP}, 0, 0, STATIC, "gamut_mode" },
1430  { "perceptual", "Colorimetric soft clipping", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_PERCEPTUAL}, 0, 0, STATIC, "gamut_mode" },
1431  { "relative", "Relative colorimetric clipping", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_RELATIVE}, 0, 0, STATIC, "gamut_mode" },
1432  { "saturation", "Saturation mapping (RGB -> RGB)", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_SATURATION}, 0, 0, STATIC, "gamut_mode" },
1433  { "absolute", "Absolute colorimetric clipping", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_ABSOLUTE}, 0, 0, STATIC, "gamut_mode" },
1434  { "desaturate", "Colorimetrically desaturate colors towards white", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_DESATURATE}, 0, 0, STATIC, "gamut_mode" },
1435  { "darken", "Colorimetric clip with bias towards darkening image to fit gamut", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_DARKEN}, 0, 0, STATIC, "gamut_mode" },
1436  { "warn", "Highlight out-of-gamut colors", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_HIGHLIGHT}, 0, 0, STATIC, "gamut_mode" },
1437  { "linear", "Linearly reduce chromaticity to fit gamut", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_LINEAR}, 0, 0, STATIC, "gamut_mode" },
1438  { "tonemapping", "Tone-mapping algorithm", OFFSET(tonemapping), AV_OPT_TYPE_INT, {.i64 = TONE_MAP_AUTO}, 0, TONE_MAP_COUNT - 1, DYNAMIC, "tonemap" },
1439  { "auto", "Automatic selection", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_AUTO}, 0, 0, STATIC, "tonemap" },
1440  { "clip", "No tone mapping (clip", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_CLIP}, 0, 0, STATIC, "tonemap" },
1441 #if PL_API_VER >= 246
1442  { "st2094-40", "SMPTE ST 2094-40", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_ST2094_40}, 0, 0, STATIC, "tonemap" },
1443  { "st2094-10", "SMPTE ST 2094-10", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_ST2094_10}, 0, 0, STATIC, "tonemap" },
1444 #endif
1445  { "bt.2390", "ITU-R BT.2390 EETF", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_BT2390}, 0, 0, STATIC, "tonemap" },
1446  { "bt.2446a", "ITU-R BT.2446 Method A", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_BT2446A}, 0, 0, STATIC, "tonemap" },
1447  { "spline", "Single-pivot polynomial spline", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_SPLINE}, 0, 0, STATIC, "tonemap" },
1448  { "reinhard", "Reinhard", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_REINHARD}, 0, 0, STATIC, "tonemap" },
1449  { "mobius", "Mobius", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_MOBIUS}, 0, 0, STATIC, "tonemap" },
1450  { "hable", "Filmic tone-mapping (Hable)", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_HABLE}, 0, 0, STATIC, "tonemap" },
1451  { "gamma", "Gamma function with knee", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_GAMMA}, 0, 0, STATIC, "tonemap" },
1452  { "linear", "Perceptually linear stretch", 0, AV_OPT_TYPE_CONST, {.i64 = TONE_MAP_LINEAR}, 0, 0, STATIC, "tonemap" },
1453  { "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 },
1454  { "inverse_tonemapping", "Inverse tone mapping (range expansion)", OFFSET(inverse_tonemapping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1455  { "tonemapping_lut_size", "Tone-mapping LUT size", OFFSET(tonemapping_lut_size), AV_OPT_TYPE_INT, {.i64 = 256}, 2, 1024, DYNAMIC },
1456  { "contrast_recovery", "HDR contrast recovery strength", OFFSET(contrast_recovery), AV_OPT_TYPE_FLOAT, {.dbl = 0.30}, 0.0, 3.0, DYNAMIC },
1457  { "contrast_smoothness", "HDR contrast recovery smoothness", OFFSET(contrast_smoothness), AV_OPT_TYPE_FLOAT, {.dbl = 3.50}, 1.0, 32.0, DYNAMIC },
1458 
1459 #if FF_API_LIBPLACEBO_OPTS
1460  /* deprecated options for backwards compatibility, defaulting to -1 to not override the new defaults */
1461  { "desaturation_strength", "Desaturation strength", OFFSET(desat_str), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 1.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1462  { "desaturation_exponent", "Desaturation exponent", OFFSET(desat_exp), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 10.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1463  { "gamut_warning", "Highlight out-of-gamut colors", OFFSET(gamut_warning), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1464  { "gamut_clipping", "Enable desaturating colorimetric gamut clipping", OFFSET(gamut_clipping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1465  { "intent", "Rendering intent", OFFSET(intent), AV_OPT_TYPE_INT, {.i64 = PL_INTENT_PERCEPTUAL}, 0, 3, DYNAMIC | AV_OPT_FLAG_DEPRECATED, "intent" },
1466  { "perceptual", "Perceptual", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_PERCEPTUAL}, 0, 0, STATIC, "intent" },
1467  { "relative", "Relative colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
1468  { "absolute", "Absolute colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_ABSOLUTE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
1469  { "saturation", "Saturation mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_SATURATION}, 0, 0, STATIC, "intent" },
1470  { "tonemapping_mode", "Tone-mapping mode", OFFSET(tonemapping_mode), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, DYNAMIC | AV_OPT_FLAG_DEPRECATED, "tonemap_mode" },
1471  { "auto", "Automatic selection", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, STATIC, "tonemap_mode" },
1472  { "rgb", "Per-channel (RGB)", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, STATIC, "tonemap_mode" },
1473  { "max", "Maximum component", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, STATIC, "tonemap_mode" },
1474  { "hybrid", "Hybrid of Luma/RGB", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, STATIC, "tonemap_mode" },
1475  { "luma", "Luminance", 0, AV_OPT_TYPE_CONST, {.i64 = 4}, 0, 0, STATIC, "tonemap_mode" },
1476  { "tonemapping_crosstalk", "Crosstalk factor for tone-mapping", OFFSET(crosstalk), AV_OPT_TYPE_FLOAT, {.dbl = 0.04}, 0.0, 0.30, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1477  { "overshoot", "Tone-mapping overshoot margin", OFFSET(overshoot), AV_OPT_TYPE_FLOAT, {.dbl = 0.05}, 0.0, 1.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1478  { "hybrid_mix", "Tone-mapping hybrid LMS mixing coefficient", OFFSET(hybrid_mix), AV_OPT_TYPE_FLOAT, {.dbl = 0.20}, 0.0, 1.00, DYNAMIC },
1479 #endif
1480 
1481  { "dithering", "Dither method to use", OFFSET(dithering), AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1, DYNAMIC, "dither" },
1482  { "none", "Disable dithering", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, STATIC, "dither" },
1483  { "blue", "Blue noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_BLUE_NOISE}, 0, 0, STATIC, "dither" },
1484  { "ordered", "Ordered LUT", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_LUT}, 0, 0, STATIC, "dither" },
1485  { "ordered_fixed", "Fixed function ordered", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_FIXED}, 0, 0, STATIC, "dither" },
1486  { "white", "White noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_WHITE_NOISE}, 0, 0, STATIC, "dither" },
1487  { "dither_lut_size", "Dithering LUT size", OFFSET(dither_lut_size), AV_OPT_TYPE_INT, {.i64 = 6}, 1, 8, STATIC },
1488  { "dither_temporal", "Enable temporal dithering", OFFSET(dither_temporal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1489 
1490  { "cones", "Colorblindness adaptation model", OFFSET(cones), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, PL_CONE_LMS, DYNAMIC, "cone" },
1491  { "l", "L cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_L}, 0, 0, STATIC, "cone" },
1492  { "m", "M cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_M}, 0, 0, STATIC, "cone" },
1493  { "s", "S cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_S}, 0, 0, STATIC, "cone" },
1494  { "cone-strength", "Colorblindness adaptation strength", OFFSET(cone_str), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 10.0, DYNAMIC },
1495 
1496  { "custom_shader_path", "Path to custom user shader (mpv .hook format)", OFFSET(shader_path), AV_OPT_TYPE_STRING, .flags = STATIC },
1497  { "custom_shader_bin", "Custom user shader as binary (mpv .hook format)", OFFSET(shader_bin), AV_OPT_TYPE_BINARY, .flags = STATIC },
1498 
1499  /* Performance/quality tradeoff options */
1500  { "skip_aa", "Skip anti-aliasing", OFFSET(skip_aa), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1501  { "polar_cutoff", "Polar LUT cutoff", OFFSET(polar_cutoff), AV_OPT_TYPE_FLOAT, {.dbl = 0}, 0.0, 1.0, DYNAMIC },
1502  { "disable_linear", "Disable linear scaling", OFFSET(disable_linear), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1503  { "disable_builtin", "Disable built-in scalers", OFFSET(disable_builtin), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1504 #if FF_API_LIBPLACEBO_OPTS
1505  { "force_icc_lut", "Deprecated, does nothing", OFFSET(force_icc_lut), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED },
1506 #endif
1507  { "force_dither", "Force dithering", OFFSET(force_dither), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1508  { "disable_fbos", "Force-disable FBOs", OFFSET(disable_fbos), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
1509  { NULL },
1510 };
1511 
1512 AVFILTER_DEFINE_CLASS(libplacebo);
1513 
1515  {
1516  .name = "default",
1517  .type = AVMEDIA_TYPE_VIDEO,
1518  .config_props = &libplacebo_config_output,
1519  },
1520 };
1521 
1523  .name = "libplacebo",
1524  .description = NULL_IF_CONFIG_SMALL("Apply various GPU filters from libplacebo"),
1525  .priv_size = sizeof(LibplaceboContext),
1526  .init = &libplacebo_init,
1532  .priv_class = &libplacebo_class,
1533  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
1535 };
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:108
GAMUT_MAP_SATURATION
@ GAMUT_MAP_SATURATION
Definition: vf_libplacebo.c:84
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:92
av_fifo_drain2
void av_fifo_drain2(AVFifo *f, size_t size)
Discard the specified amount of data from an AVFifo.
Definition: fifo.c:266
LibplaceboContext::colorspace
int colorspace
Definition: vf_libplacebo.c:191
VAR_IH
@ VAR_IH
Definition: vf_libplacebo.c:119
LibplaceboContext::out_format
enum AVPixelFormat out_format
Definition: vf_libplacebo.c:170
AVVulkanDeviceContext::phys_dev
VkPhysicalDevice phys_dev
Physical device.
Definition: hwcontext_vulkan.h:65
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
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:561
mix
static int mix(int c0, int c1)
Definition: 4xm.c:717
LibplaceboContext::fps_string
char * fps_string
Definition: vf_libplacebo.c:175
libplacebo_query_format
static int libplacebo_query_format(AVFilterContext *ctx)
Definition: vf_libplacebo.c:1136
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::percentile
float percentile
Definition: vf_libplacebo.c:232
LibplaceboContext::deband
int deband
Definition: vf_libplacebo.c:213
LibplaceboContext::deband_iterations
int deband_iterations
Definition: vf_libplacebo.c:214
input_init
static int input_init(AVFilterContext *avctx, AVFilterLink *link, LibplaceboInput *input, int idx)
Definition: vf_libplacebo.c:636
LibplaceboContext::deband_threshold
float deband_threshold
Definition: vf_libplacebo.c:215
LibplaceboContext::gamut_mode
int gamut_mode
Definition: vf_libplacebo.c:235
out
FILE * out
Definition: movenc.c:54
VAR_IN_H
@ VAR_IN_H
Definition: vf_libplacebo.c:119
LibplaceboContext::crop_y_pexpr
AVExpr * crop_y_pexpr
Definition: vf_libplacebo.c:182
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:824
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:364
LibplaceboContext::contrast
float contrast
Definition: vf_libplacebo.c:221
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2964
VAR_OUT_T
@ VAR_OUT_T
Definition: vf_libplacebo.c:134
av_parse_color
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
Definition: parseutils.c:356
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:579
av_dict_count
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
Definition: dict.c:39
pl_options_t::sigmoid_params
struct pl_sigmoid_params sigmoid_params
Definition: vf_libplacebo.c:52
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
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
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_asprintf
char * av_asprintf(const char *fmt,...)
Definition: avstring.c:115
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
VAR_OHSUB
@ VAR_OHSUB
Definition: vf_libplacebo.c:131
LibplaceboContext::apply_filmgrain
int apply_filmgrain
Definition: vf_libplacebo.c:189
find_scaler
static int find_scaler(AVFilterContext *avctx, const struct pl_filter_config **opt, const char *name, int frame_mixing)
Definition: vf_libplacebo.c:351
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
VAR_IN_IDX
@ VAR_IN_IDX
Definition: vf_libplacebo.c:117
AVFrame::opaque
void * opaque
Frame owner's private data.
Definition: frame.h:501
update_settings
static int update_settings(AVFilterContext *ctx)
Definition: vf_libplacebo.c:376
TONE_MAP_SPLINE
@ TONE_MAP_SPLINE
Definition: vf_libplacebo.c:71
av_fifo_peek
int av_fifo_peek(const AVFifo *f, void *buf, size_t nb_elems, size_t offset)
Read data from a FIFO without modifying FIFO state.
Definition: fifo.c:255
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
AVCOL_TRC_NB
@ AVCOL_TRC_NB
Not part of ABI.
Definition: pixfmt.h:592
pl_options_t::deband_params
struct pl_deband_params deband_params
Definition: vf_libplacebo.c:51
AVVulkanDeviceContext::get_proc_addr
PFN_vkGetInstanceProcAddr get_proc_addr
Pointer to the instance-provided vkGetInstanceProcAddr loading function.
Definition: hwcontext_vulkan.h:55
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:452
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:673
pl_av_log
static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
Definition: vf_libplacebo.c:286
GAMUT_MAP_RELATIVE
@ GAMUT_MAP_RELATIVE
Definition: vf_libplacebo.c:83
AVOption
AVOption.
Definition: opt.h:251
AVCOL_SPC_NB
@ AVCOL_SPC_NB
Not part of ABI.
Definition: pixfmt.h:616
b
#define b
Definition: input.c:41
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:573
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:169
LibplaceboContext
Definition: vf_libplacebo.c:152
LibplaceboInput::status
int status
Definition: vf_libplacebo.c:149
LibplaceboContext::crop_h_pexpr
AVExpr * crop_h_pexpr
Definition: vf_libplacebo.c:182
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:2971
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:60
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:75
AVCOL_PRI_JEDEC_P22
@ AVCOL_PRI_JEDEC_P22
Definition: pixfmt.h:562
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
LibplaceboContext::tex
pl_tex tex[4]
Definition: vf_libplacebo.c:160
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:600
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:586
handle_input
static int handle_input(AVFilterContext *ctx, LibplaceboInput *input)
Definition: vf_libplacebo.c:1003
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:457
FF_API_LIBPLACEBO_OPTS
#define FF_API_LIBPLACEBO_OPTS
FF_API_* defines may be placed below to indicate public API that will be dropped at a future version ...
Definition: version_major.h:38
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:2916
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
Definition: vulkan.c:1897
LibplaceboContext::sigmoid
int sigmoid
Definition: vf_libplacebo.c:204
LibplaceboContext::crop_h_expr
char * crop_h_expr
Definition: vf_libplacebo.c:178
AVDictionary
Definition: dict.c:34
pl_get_mapped_avframe
static AVFrame * pl_get_mapped_avframe(const struct pl_frame *frame)
Definition: vf_libplacebo.c:39
map_frame
static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src, struct pl_frame *out)
Definition: vf_libplacebo.c:972
VAR_OT
@ VAR_OT
Definition: vf_libplacebo.c:134
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
LibplaceboContext::fillcolor
char * fillcolor
Definition: vf_libplacebo.c:171
pl_options_t::color_adjustment
struct pl_color_adjustment color_adjustment
Definition: vf_libplacebo.c:53
video.h
GAMUT_MAP_PERCEPTUAL
@ GAMUT_MAP_PERCEPTUAL
Definition: vf_libplacebo.c:82
LibplaceboContext::vkctx
FFVulkanContext vkctx
Definition: vf_libplacebo.c:154
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:611
VAR_CROP_H
@ VAR_CROP_H
Definition: vf_libplacebo.c:123
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:376
libplacebo_activate
static int libplacebo_activate(AVFilterContext *ctx)
Definition: vf_libplacebo.c:1056
GAMUT_MAP_CLIP
@ GAMUT_MAP_CLIP
Definition: vf_libplacebo.c:81
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
formats.h
av_expr_parse
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:685
unmap_frame
static void unmap_frame(pl_gpu gpu, struct pl_frame *frame, const struct pl_source_frame *src)
Definition: vf_libplacebo.c:991
VAR_VSUB
@ VAR_VSUB
Definition: vf_libplacebo.c:130
libplacebo_config_output
static int libplacebo_config_output(AVFilterLink *outlink)
Definition: vf_libplacebo.c:1236
VAR_PH
@ VAR_PH
Definition: vf_libplacebo.c:125
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1383
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:605
FF_FILTER_FORWARD_STATUS_BACK_ALL
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
Definition: filters.h:212
fifo.h
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:584
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:55
LibplaceboContext::pos_w_pexpr
AVExpr * pos_w_pexpr
Definition: vf_libplacebo.c:183
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:412
LibplaceboContext::shader_bin_len
int shader_bin_len
Definition: vf_libplacebo.c:269
fail
#define fail()
Definition: checkasm.h:138
av_fifo_write
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
Definition: fifo.c:188
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:674
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:576
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:176
LibplaceboContext::nb_inputs
int nb_inputs
Definition: vf_libplacebo.c:164
TONE_MAP_BT2446A
@ TONE_MAP_BT2446A
Definition: vf_libplacebo.c:70
lock_queue
static void lock_queue(AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
Definition: hwcontext_vulkan.c:1393
LibplaceboContext::lut_entries
int lut_entries
Definition: vf_libplacebo.c:202
LibplaceboContext::pos_y_expr
char * pos_y_expr
Definition: vf_libplacebo.c:179
pts
static int64_t pts
Definition: transcode_aac.c:643
AV_ROUND_UP
@ AV_ROUND_UP
Round toward +infinity.
Definition: mathematics.h:134
LibplaceboContext::crop_y_expr
char * crop_y_expr
Definition: vf_libplacebo.c:177
TONE_MAP_ST2094_10
@ TONE_MAP_ST2094_10
Definition: vf_libplacebo.c:68
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:106
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:336
AVRational::num
int num
Numerator.
Definition: rational.h:59
LibplaceboContext::contrast_smoothness
float contrast_smoothness
Definition: vf_libplacebo.c:241
VAR_CROP_W
@ VAR_CROP_W
Definition: vf_libplacebo.c:122
LibplaceboInput::renderer
pl_renderer renderer
Definition: vf_libplacebo.c:142
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:575
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:47
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:61
LibplaceboContext::extra_opts
AVDictionary * extra_opts
Definition: vf_libplacebo.c:195
VAR_OW
@ VAR_OW
Definition: vf_libplacebo.c:120
TONE_MAP_COUNT
@ TONE_MAP_COUNT
Definition: vf_libplacebo.c:77
LibplaceboContext::antiringing
float antiringing
Definition: vf_libplacebo.c:203
preset
preset
Definition: vf_curves.c:46
avassert.h
LibplaceboContext::pos_w_expr
char * pos_w_expr
Definition: vf_libplacebo.c:180
LibplaceboContext::disable_linear
int disable_linear
Definition: vf_libplacebo.c:207
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
VAR_VARS_NB
@ VAR_VARS_NB
Definition: vf_libplacebo.c:136
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:1522
LibplaceboContext::crop_x_expr
char * crop_x_expr
Definition: vf_libplacebo.c:177
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:62
TONE_MAP_ST2094_40
@ TONE_MAP_ST2094_40
Definition: vf_libplacebo.c:67
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1506
ref_frame
static const AVFrame * ref_frame(const struct pl_frame_mix *mix)
Definition: vf_libplacebo.c:783
output_frame
static int output_frame(AVFilterContext *ctx, int64_t pts)
Definition: vf_libplacebo.c:857
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVCOL_PRI_NB
@ AVCOL_PRI_NB
Not part of ABI.
Definition: pixfmt.h:563
LibplaceboContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_libplacebo.c:186
AVCOL_TRC_BT1361_ECG
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
Definition: pixfmt.h:583
LibplaceboContext::force_dither
int force_dither
Definition: vf_libplacebo.c:209
LibplaceboContext::inputs
LibplaceboInput * inputs
Definition: vf_libplacebo.c:163
discard_frame
static void discard_frame(const struct pl_source_frame *src)
Definition: vf_libplacebo.c:997
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:606
AVDictionaryEntry::key
char * key
Definition: dict.h:90
LibplaceboContext::opts
pl_options opts
Definition: vf_libplacebo.c:198
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:617
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
libplacebo_uninit
static void libplacebo_uninit(AVFilterContext *avctx)
Definition: vf_libplacebo.c:740
LibplaceboContext::frame_mixer
char * frame_mixer
Definition: vf_libplacebo.c:201
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
filters.h
GAMUT_MAP_DARKEN
@ GAMUT_MAP_DARKEN
Definition: vf_libplacebo.c:87
var_name
var_name
Definition: noise_bsf.c:46
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
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
LibplaceboContext::tonemapping
int tonemapping
Definition: vf_libplacebo.c:236
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:557
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVExpr
Definition: eval.c:157
LibplaceboContext::crop_w_expr
char * crop_w_expr
Definition: vf_libplacebo.c:178
LibplaceboContext::disable_builtin
int disable_builtin
Definition: vf_libplacebo.c:208
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
LibplaceboContext::color_trc
int color_trc
Definition: vf_libplacebo.c:194
libplacebo_process_command
static int libplacebo_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_libplacebo.c:770
VAR_IN_T
@ VAR_IN_T
Definition: vf_libplacebo.c:133
LibplaceboContext::w_expr
char * w_expr
Definition: vf_libplacebo.c:173
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:554
LibplaceboInput
Definition: vf_libplacebo.c:140
color_range
color_range
Definition: vf_selectivecolor.c:43
pl_options_t::peak_detect_params
struct pl_peak_detect_params peak_detect_params
Definition: vf_libplacebo.c:54
LibplaceboContext::force_divisible_by
int force_divisible_by
Definition: vf_libplacebo.c:187
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:548
NAN
#define NAN
Definition: mathematics.h:115
TONE_MAP_BT2390
@ TONE_MAP_BT2390
Definition: vf_libplacebo.c:69
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:146
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:552
frame
static AVFrame * frame
Definition: demux_decode.c:54
arg
const char * arg
Definition: jacosubdec.c:67
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:553
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
get_tonemapping_func
static const struct pl_tone_map_function * get_tonemapping_func(int tm)
Definition: vf_libplacebo.c:303
VAR_IW
@ VAR_IW
Definition: vf_libplacebo.c:118
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:44
opts
AVDictionary * opts
Definition: movenc.c:50
VAR_PW
@ VAR_PW
Definition: vf_libplacebo.c:124
NULL
#define NULL
Definition: coverity.c:32
LibplaceboContext::dither_temporal
int dither_temporal
Definition: vf_libplacebo.c:260
TONE_MAP_REINHARD
@ TONE_MAP_REINHARD
Definition: vf_libplacebo.c:72
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:736
AVVulkanDeviceContext::nb_enabled_dev_extensions
int nb_enabled_dev_extensions
Definition: hwcontext_vulkan.h:99
LibplaceboContext::skip_aa
int skip_aa
Definition: vf_libplacebo.c:205
GAMUT_MAP_ABSOLUTE
@ GAMUT_MAP_ABSOLUTE
Definition: vf_libplacebo.c:85
LibplaceboContext::shader_bin
void * shader_bin
Definition: vf_libplacebo.c:268
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
LibplaceboContext::cones
int cones
Definition: vf_libplacebo.c:263
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:582
ff_append_inpad_free_name
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
Definition: avfilter.c:132
LibplaceboContext::brightness
float brightness
Definition: vf_libplacebo.c:220
activate
filter_frame For filters that do not use the activate() callback
TONE_MAP_GAMMA
@ TONE_MAP_GAMMA
Definition: vf_libplacebo.c:75
AVVulkanDeviceContext::unlock_queue
void(* unlock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
Similar to lock_queue(), unlocks a queue.
Definition: hwcontext_vulkan.h:152
AV_OPT_TYPE_DICT
@ AV_OPT_TYPE_DICT
Definition: opt.h:232
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:405
LibplaceboContext::gpu
pl_gpu gpu
Definition: vf_libplacebo.c:159
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:547
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:470
parseutils.h
VAR_OUT_W
@ VAR_OUT_W
Definition: vf_libplacebo.c:120
AV_FRAME_DATA_ICC_PROFILE
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:144
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:196
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
AVVulkanFramesContext::usage
VkImageUsageFlagBits usage
Defines extra usage of output frames.
Definition: hwcontext_vulkan.h:195
double
double
Definition: af_crystalizer.c:131
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:585
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:608
VAR_OUT_H
@ VAR_OUT_H
Definition: vf_libplacebo.c:121
LibplaceboContext::status_pts
int64_t status_pts
tracks status of most recently used input
Definition: vf_libplacebo.c:165
FFVulkanContext
Definition: vulkan.h:229
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
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1337
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:639
parse_shader
static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
Definition: vf_libplacebo.c:530
set_gamut_mode
static void set_gamut_mode(struct pl_color_map_params *p, int gamut_mode)
Definition: vf_libplacebo.c:323
libplacebo_config_input
static int libplacebo_config_input(AVFilterLink *inlink)
Definition: vf_libplacebo.c:1217
VAR_CW
@ VAR_CW
Definition: vf_libplacebo.c:122
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:556
LibplaceboInput::status_pts
int64_t status_pts
Definition: vf_libplacebo.c:148
LibplaceboContext::cone_str
float cone_str
Definition: vf_libplacebo.c:264
GAMUT_MAP_LINEAR
@ GAMUT_MAP_LINEAR
Definition: vf_libplacebo.c:89
color_primaries
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
Definition: csp.c:76
init_vulkan
static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwctx)
Definition: vf_libplacebo.c:659
LibplaceboContext::hue
float hue
Definition: vf_libplacebo.c:223
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:587
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:559
eval.h
AVFifo
Definition: fifo.c:35
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:106
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:578
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:555
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
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
LibplaceboInput::link
AVFilterLink * link
Definition: vf_libplacebo.c:146
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(libplacebo)
LibplaceboContext::deband_grain
float deband_grain
Definition: vf_libplacebo.c:217
LibplaceboInput::mix
struct pl_frame_mix mix
temporary storage
Definition: vf_libplacebo.c:145
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:138
LibplaceboContext::out_format_string
char * out_format_string
Definition: vf_libplacebo.c:169
LibplaceboContext::disable_fbos
int disable_fbos
Definition: vf_libplacebo.c:210
LibplaceboContext::saturation
float saturation
Definition: vf_libplacebo.c:222
LibplaceboContext::num_hooks
int num_hooks
Definition: vf_libplacebo.c:271
LibplaceboContext::status
int status
Definition: vf_libplacebo.c:166
libplacebo_options
static const AVOption libplacebo_options[]
Definition: vf_libplacebo.c:1318
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:851
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:919
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
pl_options_alloc
#define pl_options_alloc(log)
Definition: vf_libplacebo.c:60
LibplaceboContext::var_values
double var_values[VAR_VARS_NB]
Definition: vf_libplacebo.c:172
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
LibplaceboContext::normalize_sar
int normalize_sar
Definition: vf_libplacebo.c:188
LibplaceboContext::polar_cutoff
float polar_cutoff
Definition: vf_libplacebo.c:206
av_pix_fmt_desc_get_id
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
Definition: pixdesc.c:2983
LibplaceboContext::corner_rounding
float corner_rounding
Definition: vf_libplacebo.c:185
GAMUT_MAP_DESATURATE
@ GAMUT_MAP_DESATURATE
Definition: vf_libplacebo.c:86
LibplaceboContext::apply_dovi
int apply_dovi
Definition: vf_libplacebo.c:190
VAR_POS_H
@ VAR_POS_H
Definition: vf_libplacebo.c:125
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
GAMUT_MAP_HIGHLIGHT
@ GAMUT_MAP_HIGHLIGHT
Definition: vf_libplacebo.c:88
LibplaceboContext::downscaler
char * downscaler
Definition: vf_libplacebo.c:200
LibplaceboContext::log
pl_log log
Definition: vf_libplacebo.c:157
LibplaceboContext::vulkan
pl_vulkan vulkan
Definition: vf_libplacebo.c:158
M_PI
#define M_PI
Definition: mathematics.h:67
AVVulkanDeviceContext::lock_queue
void(* lock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
Locks a queue, preventing other threads from submitting any command buffers to this queue.
Definition: hwcontext_vulkan.h:147
LibplaceboContext::pos_h_pexpr
AVExpr * pos_h_pexpr
Definition: vf_libplacebo.c:183
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:572
TONE_MAP_LINEAR
@ TONE_MAP_LINEAR
Definition: vf_libplacebo.c:76
internal.h
av_vkfmt_from_pixfmt
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the optimal per-plane Vulkan format for a given sw_format, one for each plane.
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:607
av_parse_video_rate
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
Definition: parseutils.c:181
get_log_level
static enum pl_log_level get_log_level(void)
Definition: vf_libplacebo.c:274
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:656
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
LibplaceboContext::pos_x_expr
char * pos_x_expr
Definition: vf_libplacebo.c:179
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
LibplaceboContext::upscaler
char * upscaler
Definition: vf_libplacebo.c:199
pl_options_t::params
struct pl_render_params params
Definition: vf_libplacebo.c:50
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:610
pl_options_free
#define pl_options_free(ptr)
Definition: vf_libplacebo.c:61
av_gcd_q
AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def)
Return the best rational so that a and b are multiple of it.
Definition: rational.c:186
LibplaceboContext::gamma
float gamma
Definition: vf_libplacebo.c:224
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
VAR_OVSUB
@ VAR_OVSUB
Definition: vf_libplacebo.c:132
LibplaceboInput::qstatus
enum pl_queue_status qstatus
Definition: vf_libplacebo.c:144
LibplaceboContext::min_peak
float min_peak
Definition: vf_libplacebo.c:229
LibplaceboContext::tonemapping_lut_size
int tonemapping_lut_size
Definition: vf_libplacebo.c:239
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
LibplaceboContext::tonemapping_param
float tonemapping_param
Definition: vf_libplacebo.c:237
AV_PIX_FMT_FLAG_BE
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
Definition: pixdesc.h:116
TONE_MAP_AUTO
@ TONE_MAP_AUTO
Definition: vf_libplacebo.c:65
LibplaceboContext::pos_h_expr
char * pos_h_expr
Definition: vf_libplacebo.c:180
LibplaceboContext::color_primaries
int color_primaries
Definition: vf_libplacebo.c:193
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
len
int len
Definition: vorbis_enc_data.h:426
var_names
static const char *const var_names[]
Definition: vf_libplacebo.c:93
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:53
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:602
LibplaceboContext::dithering
int dithering
Definition: vf_libplacebo.c:258
LibplaceboContext::scene_high
float scene_high
Definition: vf_libplacebo.c:231
STATIC
#define STATIC
Definition: vf_libplacebo.c:1315
drain_input_pts
static void drain_input_pts(LibplaceboInput *in, int64_t until)
Definition: vf_libplacebo.c:1049
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:656
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
LibplaceboInput::queue
pl_queue queue
Definition: vf_libplacebo.c:143
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
AVFilter
Filter definition.
Definition: avfilter.h:166
pl_options_t::dither_params
struct pl_dither_params dither_params
Definition: vf_libplacebo.c:56
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:550
ret
ret
Definition: filter_design.txt:187
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
LibplaceboContext::scene_low
float scene_low
Definition: vf_libplacebo.c:230
VAR_OH
@ VAR_OH
Definition: vf_libplacebo.c:121
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:162
VAR_CH
@ VAR_CH
Definition: vf_libplacebo.c:123
unlock_queue
static void unlock_queue(AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
Definition: hwcontext_vulkan.c:1399
av_fifo_alloc2
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
Definition: fifo.c:47
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
VAR_T
@ VAR_T
Definition: vf_libplacebo.c:133
LibplaceboContext::peakdetect
int peakdetect
Definition: vf_libplacebo.c:227
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2896
LibplaceboContext::deband_radius
float deband_radius
Definition: vf_libplacebo.c:216
LibplaceboInput::idx
int idx
Definition: vf_libplacebo.c:141
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:591
status
ov_status_e status
Definition: dnn_backend_openvino.c:119
LibplaceboContext::contrast_recovery
float contrast_recovery
Definition: vf_libplacebo.c:240
VAR_IN_W
@ VAR_IN_W
Definition: vf_libplacebo.c:118
update_crops
static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, struct pl_frame *target, double target_pts)
Definition: vf_libplacebo.c:792
libplacebo_outputs
static const AVFilterPad libplacebo_outputs[]
Definition: vf_libplacebo.c:1514
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
VAR_HSUB
@ VAR_HSUB
Definition: vf_libplacebo.c:129
LibplaceboContext::inverse_tonemapping
int inverse_tonemapping
Definition: vf_libplacebo.c:238
TONE_MAP_HABLE
@ TONE_MAP_HABLE
Definition: vf_libplacebo.c:74
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
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:577
file.h
OFFSET
#define OFFSET(x)
Definition: vf_libplacebo.c:1314
VAR_SAR
@ VAR_SAR
Definition: vf_libplacebo.c:127
LibplaceboContext::fps
AVRational fps
parsed FPS, or 0/0 for "none"
Definition: vf_libplacebo.c:176
input_uninit
static void input_uninit(LibplaceboInput *input)
Definition: vf_libplacebo.c:652
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
TONE_MAP_MOBIUS
@ TONE_MAP_MOBIUS
Definition: vf_libplacebo.c:73
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:98
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:165
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
VAR_IDX
@ VAR_IDX
Definition: vf_libplacebo.c:117
LibplaceboInput::out_pts
AVFifo * out_pts
timestamps of wanted output frames
Definition: vf_libplacebo.c:147
LibplaceboContext::crop_w_pexpr
AVExpr * crop_w_pexpr
Definition: vf_libplacebo.c:182
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:184
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:70
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:560
AVDictionaryEntry
Definition: dict.h:89
TONE_MAP_CLIP
@ TONE_MAP_CLIP
Definition: vf_libplacebo.c:66
GAMUT_MAP_COUNT
@ GAMUT_MAP_COUNT
Definition: vf_libplacebo.c:90
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
VAR_POS_W
@ VAR_POS_W
Definition: vf_libplacebo.c:124
max_q
static AVRational max_q(AVRational a, AVRational b)
Definition: vf_libplacebo.c:1231
LibplaceboContext::smoothing
float smoothing
Definition: vf_libplacebo.c:228
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
pl_options_t::color_map_params
struct pl_color_map_params color_map_params
Definition: vf_libplacebo.c:55
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
DYNAMIC
#define DYNAMIC
Definition: vf_libplacebo.c:1316
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
VAR_N
@ VAR_N
Definition: vf_libplacebo.c:135
av_fifo_freep2
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
Definition: fifo.c:286
LibplaceboContext::shader_path
char * shader_path
Definition: vf_libplacebo.c:267
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:285
VAR_A
@ VAR_A
Definition: vf_libplacebo.c:126
LibplaceboContext::crop_x_pexpr
AVExpr * crop_x_pexpr
Definition: vf_libplacebo.c:182
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
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:78
LibplaceboContext::color_range
int color_range
Definition: vf_libplacebo.c:192
AVDictionaryEntry::value
char * value
Definition: dict.h:91
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
LibplaceboContext::dither_lut_size
int dither_lut_size
Definition: vf_libplacebo.c:259
LibplaceboContext::pos_x_pexpr
AVExpr * pos_x_pexpr
Definition: vf_libplacebo.c:183
libplacebo_init
static int libplacebo_init(AVFilterContext *avctx)
Definition: vf_libplacebo.c:548
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:601
LibplaceboContext::h_expr
char * h_expr
Definition: vf_libplacebo.c:174
VAR_DAR
@ VAR_DAR
Definition: vf_libplacebo.c:128
pl_options_t::cone_params
struct pl_cone_params cone_params
Definition: vf_libplacebo.c:57
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:615
LibplaceboContext::hooks
const struct pl_hook * hooks[2]
Definition: vf_libplacebo.c:270
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
RET
#define RET(x)
Definition: vulkan.h:68
av_rescale_q_rnd
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
Definition: mathematics.c:134
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
LibplaceboContext::pos_y_pexpr
AVExpr * pos_y_pexpr
Definition: vf_libplacebo.c:183
AV_FIFO_FLAG_AUTO_GROW
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
Definition: fifo.h:67
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:2884
log_cb
static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
Definition: fflcms2.c:24
pl_options_t
Definition: vf_libplacebo.c:48
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