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