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