FFmpeg
vf_libplacebo.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "libavutil/file.h"
20 #include "libavutil/opt.h"
21 #include "internal.h"
22 #include "vulkan_filter.h"
23 #include "scale_eval.h"
24 
25 #include <libplacebo/renderer.h>
26 #include <libplacebo/utils/libav.h>
27 #include <libplacebo/vulkan.h>
28 
29 typedef struct LibplaceboContext {
30  /* lavfi vulkan*/
33 
34  /* libplacebo */
35  pl_log log;
36  pl_vulkan vulkan;
37  pl_gpu gpu;
38  pl_renderer renderer;
39 
40  /* settings */
42  char *w_expr;
43  char *h_expr;
54  int color_trc;
55 
56  /* pl_render_params */
57  char *upscaler;
58  char *downscaler;
60  float antiringing;
61  int sigmoid;
62  int skip_aa;
63  float polar_cutoff;
69 
70  /* pl_deband_params */
71  int deband;
75  float deband_grain;
76 
77  /* pl_color_adjustment */
78  float brightness;
79  float contrast;
80  float saturation;
81  float hue;
82  float gamma;
83 
84  /* pl_peak_detect_params */
86  float smoothing;
87  float min_peak;
88  float scene_low;
89  float scene_high;
90  float overshoot;
91 
92  /* pl_color_map_params */
93  int intent;
96  float desat_str;
97  float desat_exp;
98  float desat_base;
99  float max_boost;
102 
103  /* pl_dither_params */
107 
108  /* pl_cone_params */
109  int cones;
110  float cone_str;
111 
112  /* custom shaders */
113  char *shader_path;
114  void *shader_bin;
116  const struct pl_hook *hooks[2];
119 
120 static inline enum pl_log_level get_log_level(void)
121 {
122  int av_lev = av_log_get_level();
123  return av_lev >= AV_LOG_TRACE ? PL_LOG_TRACE :
124  av_lev >= AV_LOG_DEBUG ? PL_LOG_DEBUG :
125  av_lev >= AV_LOG_VERBOSE ? PL_LOG_INFO :
126  av_lev >= AV_LOG_WARNING ? PL_LOG_WARN :
127  av_lev >= AV_LOG_ERROR ? PL_LOG_ERR :
128  av_lev >= AV_LOG_FATAL ? PL_LOG_FATAL :
129  PL_LOG_NONE;
130 }
131 
132 static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
133 {
134  int av_lev;
135 
136  switch (level) {
137  case PL_LOG_FATAL: av_lev = AV_LOG_FATAL; break;
138  case PL_LOG_ERR: av_lev = AV_LOG_ERROR; break;
139  case PL_LOG_WARN: av_lev = AV_LOG_WARNING; break;
140  case PL_LOG_INFO: av_lev = AV_LOG_VERBOSE; break;
141  case PL_LOG_DEBUG: av_lev = AV_LOG_DEBUG; break;
142  case PL_LOG_TRACE: av_lev = AV_LOG_TRACE; break;
143  default: return;
144  }
145 
146  av_log(log_ctx, av_lev, "%s\n", msg);
147 }
148 
149 static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
150 {
151  LibplaceboContext *s = avctx->priv;
152  const struct pl_hook *hook;
153 
154  hook = pl_mpv_user_shader_parse(s->gpu, shader, len);
155  if (!hook) {
156  av_log(s, AV_LOG_ERROR, "Failed parsing custom shader!\n");
157  return AVERROR(EINVAL);
158  }
159 
160  s->hooks[s->num_hooks++] = hook;
161  return 0;
162 }
163 
164 static int find_scaler(AVFilterContext *avctx,
165  const struct pl_filter_config **opt,
166  const char *name)
167 {
168  const struct pl_filter_preset *preset;
169  if (!strcmp(name, "help")) {
170  av_log(avctx, AV_LOG_INFO, "Available scaler presets:\n");
171  for (preset = pl_scale_filters; preset->name; preset++)
172  av_log(avctx, AV_LOG_INFO, " %s\n", preset->name);
173  return AVERROR_EXIT;
174  }
175 
176  for (preset = pl_scale_filters; preset->name; preset++) {
177  if (!strcmp(name, preset->name)) {
178  *opt = preset->filter;
179  return 0;
180  }
181  }
182 
183  av_log(avctx, AV_LOG_ERROR, "No such scaler preset '%s'.\n", name);
184  return AVERROR(EINVAL);
185 }
186 
188 {
189  LibplaceboContext *s = avctx->priv;
190 
191  /* Create libplacebo log context */
192  s->log = pl_log_create(PL_API_VER, pl_log_params(
193  .log_level = get_log_level(),
194  .log_cb = pl_av_log,
195  .log_priv = s,
196  ));
197 
198  if (!s->log)
199  return AVERROR(ENOMEM);
200 
201  /* Note: s->vulkan etc. are initialized later, when hwctx is available */
202  return 0;
203 }
204 
205 static int init_vulkan(AVFilterContext *avctx)
206 {
207  int err = 0;
208  LibplaceboContext *s = avctx->priv;
209  const AVVulkanDeviceContext *hwctx = s->vkctx.hwctx;
210  uint8_t *buf = NULL;
211  size_t buf_len;
212 
213  /* Import libavfilter vulkan context into libplacebo */
214  s->vulkan = pl_vulkan_import(s->log, pl_vulkan_import_params(
215  .instance = hwctx->inst,
216  .get_proc_addr = hwctx->get_proc_addr,
217  .phys_device = hwctx->phys_dev,
218  .device = hwctx->act_dev,
219  .extensions = hwctx->enabled_dev_extensions,
220  .num_extensions = hwctx->nb_enabled_dev_extensions,
221  .features = &hwctx->device_features,
222  .queue_graphics = {
223  .index = hwctx->queue_family_index,
224  .count = hwctx->nb_graphics_queues,
225  },
226  .queue_compute = {
227  .index = hwctx->queue_family_comp_index,
228  .count = hwctx->nb_comp_queues,
229  },
230  .queue_transfer = {
231  .index = hwctx->queue_family_tx_index,
232  .count = hwctx->nb_tx_queues,
233  },
234  /* This is the highest version created by hwcontext_vulkan.c */
235  .max_api_version = VK_API_VERSION_1_2,
236  ));
237 
238  if (!s->vulkan) {
239  av_log(s, AV_LOG_ERROR, "Failed importing vulkan device to libplacebo!\n");
240  err = AVERROR_EXTERNAL;
241  goto fail;
242  }
243 
244  /* Create the renderer */
245  s->gpu = s->vulkan->gpu;
246  s->renderer = pl_renderer_create(s->log, s->gpu);
247 
248  /* Parse the user shaders, if requested */
249  if (s->shader_bin_len)
250  RET(parse_shader(avctx, s->shader_bin, s->shader_bin_len));
251 
252  if (s->shader_path && s->shader_path[0]) {
253  RET(av_file_map(s->shader_path, &buf, &buf_len, 0, s));
254  RET(parse_shader(avctx, buf, buf_len));
255  }
256 
257  /* fall through */
258 fail:
259  if (buf)
260  av_file_unmap(buf, buf_len);
261  s->initialized = 1;
262  return err;
263 }
264 
266 {
267  LibplaceboContext *s = avctx->priv;
268 
269  for (int i = 0; i < s->num_hooks; i++)
270  pl_mpv_user_shader_destroy(&s->hooks[i]);
271  pl_renderer_destroy(&s->renderer);
272  pl_vulkan_destroy(&s->vulkan);
273  pl_log_destroy(&s->log);
274  ff_vk_uninit(&s->vkctx);
275  s->initialized = 0;
276  s->gpu = NULL;
277 }
278 
280 {
281  int err = 0, ok;
282  LibplaceboContext *s = avctx->priv;
283  struct pl_render_params params;
284  struct pl_frame image, target;
285  ok = pl_map_avframe_ex(s->gpu, &image, pl_avframe_params(
286  .frame = in,
287  .map_dovi = s->apply_dovi,
288  ));
289 
290  ok &= pl_map_avframe_ex(s->gpu, &target, pl_avframe_params(
291  .frame = out,
292  .map_dovi = false,
293  ));
294 
295  if (!ok) {
296  err = AVERROR_EXTERNAL;
297  goto fail;
298  }
299 
300  if (!s->apply_filmgrain)
301  image.film_grain.type = PL_FILM_GRAIN_NONE;
302 
303  if (s->target_sar.num) {
304  float aspect = pl_rect2df_aspect(&target.crop) * av_q2d(s->target_sar);
305  pl_rect2df_aspect_set(&target.crop, aspect, s->pad_crop_ratio);
306  }
307 
308  /* Update render params */
309  params = (struct pl_render_params) {
310  PL_RENDER_DEFAULTS
311  .lut_entries = s->lut_entries,
312  .antiringing_strength = s->antiringing,
313 
314  .deband_params = !s->deband ? NULL : pl_deband_params(
315  .iterations = s->deband_iterations,
316  .threshold = s->deband_threshold,
317  .radius = s->deband_radius,
318  .grain = s->deband_grain,
319  ),
320 
321  .sigmoid_params = s->sigmoid ? &pl_sigmoid_default_params : NULL,
322 
323  .color_adjustment = &(struct pl_color_adjustment) {
324  .brightness = s->brightness,
325  .contrast = s->contrast,
326  .saturation = s->saturation,
327  .hue = s->hue,
328  .gamma = s->gamma,
329  },
330 
331  .peak_detect_params = !s->peakdetect ? NULL : pl_peak_detect_params(
332  .smoothing_period = s->smoothing,
333  .minimum_peak = s->min_peak,
334  .scene_threshold_low = s->scene_low,
335  .scene_threshold_high = s->scene_high,
336  .overshoot_margin = s->overshoot,
337  ),
338 
339  .color_map_params = pl_color_map_params(
340  .intent = s->intent,
341  .tone_mapping_algo = s->tonemapping,
342  .tone_mapping_param = s->tonemapping_param,
343  .desaturation_strength = s->desat_str,
344  .desaturation_exponent = s->desat_exp,
345  .desaturation_base = s->desat_base,
346  .max_boost = s->max_boost,
347  .gamut_warning = s->gamut_warning,
348  .gamut_clipping = s->gamut_clipping,
349  ),
350 
351  .dither_params = s->dithering < 0 ? NULL : pl_dither_params(
352  .method = s->dithering,
353  .lut_size = s->dither_lut_size,
354  .temporal = s->dither_temporal,
355  ),
356 
357  .cone_params = !s->cones ? NULL : pl_cone_params(
358  .cones = s->cones,
359  .strength = s->cone_str,
360  ),
361 
362  .hooks = s->hooks,
363  .num_hooks = s->num_hooks,
364 
365  .skip_anti_aliasing = s->skip_aa,
366  .polar_cutoff = s->polar_cutoff,
367  .disable_linear_scaling = s->disable_linear,
368  .disable_builtin_scalers = s->disable_builtin,
369  .force_icc_lut = s->force_icc_lut,
370  .force_dither = s->force_dither,
371  .disable_fbos = s->disable_fbos,
372  };
373 
374  RET(find_scaler(avctx, &params.upscaler, s->upscaler));
375  RET(find_scaler(avctx, &params.downscaler, s->downscaler));
376 
377  pl_render_image(s->renderer, &image, &target, &params);
378  pl_unmap_avframe(s->gpu, &image);
379  pl_unmap_avframe(s->gpu, &target);
380 
381  /* Flush the command queues for performance */
382  pl_gpu_flush(s->gpu);
383  return 0;
384 
385 fail:
386  pl_unmap_avframe(s->gpu, &image);
387  pl_unmap_avframe(s->gpu, &target);
388  return err;
389 }
390 
392 {
393  int err, changed_csp;
394  AVFilterContext *ctx = link->dst;
395  LibplaceboContext *s = ctx->priv;
396  AVFilterLink *outlink = ctx->outputs[0];
397 
398  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
399  if (!out) {
400  err = AVERROR(ENOMEM);
401  goto fail;
402  }
403 
404  pl_log_level_update(s->log, get_log_level());
405  if (!s->initialized)
406  RET(init_vulkan(ctx));
407 
409  out->width = outlink->w;
410  out->height = outlink->h;
411 
412  if (s->apply_dovi && av_frame_get_side_data(in, AV_FRAME_DATA_DOVI_METADATA)) {
413  /* Output of dovi reshaping is always BT.2020+PQ, so infer the correct
414  * output colorspace defaults */
415  out->colorspace = AVCOL_SPC_BT2020_NCL;
416  out->color_primaries = AVCOL_PRI_BT2020;
417  out->color_trc = AVCOL_TRC_SMPTE2084;
418  }
419 
420  if (s->colorspace >= 0)
421  out->colorspace = s->colorspace;
422  if (s->color_range >= 0)
423  out->color_range = s->color_range;
424  if (s->color_trc >= 0)
425  out->color_trc = s->color_trc;
426  if (s->color_primaries >= 0)
427  out->color_primaries = s->color_primaries;
428 
429  changed_csp = in->colorspace != out->colorspace ||
430  in->color_range != out->color_range ||
431  in->color_trc != out->color_trc ||
432  in->color_primaries != out->color_primaries;
433 
434  /* Strip side data if no longer relevant */
435  if (changed_csp) {
438  }
439  if (s->apply_dovi || changed_csp) {
442  }
443  if (s->apply_filmgrain)
445 
446  RET(process_frames(ctx, out, in));
447 
448  av_frame_free(&in);
449 
450  return ff_filter_frame(outlink, out);
451 
452 fail:
453  av_frame_free(&in);
454  av_frame_free(&out);
455  return err;
456 }
457 
459 {
460  int err;
461  AVFilterContext *avctx = outlink->src;
462  LibplaceboContext *s = avctx->priv;
463  AVFilterLink *inlink = outlink->src->inputs[0];
464  AVHWFramesContext *hwfc;
465  AVVulkanFramesContext *vkfc;
466  AVRational scale_sar;
467  int *out_w = &s->vkctx.output_width;
468  int *out_h = &s->vkctx.output_height;
469 
470  RET(ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink,
471  out_w, out_h));
472 
473  ff_scale_adjust_dimensions(inlink, out_w, out_h,
474  s->force_original_aspect_ratio,
475  s->force_divisible_by);
476 
477  scale_sar = (AVRational){outlink->h * inlink->w, *out_w * *out_h};
478  if (inlink->sample_aspect_ratio.num)
479  scale_sar = av_mul_q(scale_sar, inlink->sample_aspect_ratio);
480 
481  if (s->normalize_sar) {
482  /* Apply all SAR during scaling, so we don't need to set the out SAR */
483  s->target_sar = scale_sar;
484  } else {
485  /* This is consistent with other scale_* filters, which only
486  * set the outlink SAR to be equal to the scale SAR iff the input SAR
487  * was set to something nonzero */
488  if (inlink->sample_aspect_ratio.num)
489  outlink->sample_aspect_ratio = scale_sar;
490  }
491 
492  if (s->out_format_string) {
493  s->vkctx.output_format = av_get_pix_fmt(s->out_format_string);
494  if (s->vkctx.output_format == AV_PIX_FMT_NONE) {
495  av_log(avctx, AV_LOG_ERROR, "Invalid output format.\n");
496  return AVERROR(EINVAL);
497  }
498  } else {
499  /* Default to re-using the input format */
500  s->vkctx.output_format = s->vkctx.input_format;
501  }
502 
504  hwfc = (AVHWFramesContext *) outlink->hw_frames_ctx->data;
505  vkfc = hwfc->hwctx;
506  vkfc->usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
507 
508  return 0;
509 
510 fail:
511  return err;
512 }
513 
514 #define OFFSET(x) offsetof(LibplaceboContext, x)
515 #define STATIC (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
516 #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM)
517 
518 static const AVOption libplacebo_options[] = {
519  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = STATIC },
520  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = STATIC },
521  { "format", "Output video format", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = STATIC },
522  { "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" },
523  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, STATIC, "force_oar" },
524  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, "force_oar" },
525  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, "force_oar" },
526  { "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 },
527  { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, STATIC },
528  { "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 },
529 
530  {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
531  {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"},
532  {"gbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_RGB}, INT_MIN, INT_MAX, STATIC, "colorspace"},
533  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT709}, INT_MIN, INT_MAX, STATIC, "colorspace"},
534  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "colorspace"},
535  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT470BG}, INT_MIN, INT_MAX, STATIC, "colorspace"},
536  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
537  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "colorspace"},
538  {"ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, STATIC, "colorspace"},
539  {"bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
540  {"bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, STATIC, "colorspace"},
541  {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, STATIC, "colorspace"},
542 
543  {"range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_RANGE_NB-1, DYNAMIC, "range"},
544  {"auto", "keep the same color range", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, STATIC, "range"},
545  {"unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
546  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, STATIC, "range"},
547  {"limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
548  {"tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
549  {"mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, STATIC, "range"},
550  {"full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
551  {"pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
552  {"jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, STATIC, "range"},
553 
554  {"color_primaries", "select color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_PRI_NB-1, DYNAMIC, "color_primaries"},
555  {"auto", "keep the same color primaries", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
556  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT709}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
557  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
558  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
559  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT470BG}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
560  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
561  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
562  {"film", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_FILM}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
563  {"bt2020", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_BT2020}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
564  {"smpte428", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE428}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
565  {"smpte431", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE431}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
566  {"smpte432", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_SMPTE432}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
567  {"jedec-p22", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_JEDEC_P22}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
568  {"ebu3213", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_PRI_EBU3213}, INT_MIN, INT_MAX, STATIC, "color_primaries"},
569 
570  {"color_trc", "select color transfer", OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_TRC_NB-1, DYNAMIC, "color_trc"},
571  {"auto", "keep the same color transfer", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
572  {"bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT709}, INT_MIN, INT_MAX, STATIC, "color_trc"},
573  {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_UNSPECIFIED}, INT_MIN, INT_MAX, STATIC, "color_trc"},
574  {"bt470m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA22}, INT_MIN, INT_MAX, STATIC, "color_trc"},
575  {"bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_GAMMA28}, INT_MIN, INT_MAX, STATIC, "color_trc"},
576  {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE170M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
577  {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE240M}, INT_MIN, INT_MAX, STATIC, "color_trc"},
578  {"linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_LINEAR}, INT_MIN, INT_MAX, STATIC, "color_trc"},
579  {"iec61966-2-4", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_4}, INT_MIN, INT_MAX, STATIC, "color_trc"},
580  {"bt1361e", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT1361_ECG}, INT_MIN, INT_MAX, STATIC, "color_trc"},
581  {"iec61966-2-1", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_IEC61966_2_1}, INT_MIN, INT_MAX, STATIC, "color_trc"},
582  {"bt2020-10", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_10}, INT_MIN, INT_MAX, STATIC, "color_trc"},
583  {"bt2020-12", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_BT2020_12}, INT_MIN, INT_MAX, STATIC, "color_trc"},
584  {"smpte2084", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_SMPTE2084}, INT_MIN, INT_MAX, STATIC, "color_trc"},
585  {"arib-std-b67", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_TRC_ARIB_STD_B67}, INT_MIN, INT_MAX, STATIC, "color_trc"},
586 
587  { "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC },
588  { "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC },
589  { "lut_entries", "Number of scaler LUT entries", OFFSET(lut_entries), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 256, DYNAMIC },
590  { "antiringing", "Antiringing strength (for non-EWA filters)", OFFSET(antiringing), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, DYNAMIC },
591  { "sigmoid", "Enable sigmoid upscaling", OFFSET(sigmoid), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
592  { "apply_filmgrain", "Apply film grain metadata", OFFSET(apply_filmgrain), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
593  { "apply_dolbyvision", "Apply Dolby Vision metadata", OFFSET(apply_dovi), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
594 
595  { "deband", "Enable debanding", OFFSET(deband), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
596  { "deband_iterations", "Deband iterations", OFFSET(deband_iterations), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 16, DYNAMIC },
597  { "deband_threshold", "Deband threshold", OFFSET(deband_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 4.0}, 0.0, 1024.0, DYNAMIC },
598  { "deband_radius", "Deband radius", OFFSET(deband_radius), AV_OPT_TYPE_FLOAT, {.dbl = 16.0}, 0.0, 1024.0, DYNAMIC },
599  { "deband_grain", "Deband grain", OFFSET(deband_grain), AV_OPT_TYPE_FLOAT, {.dbl = 6.0}, 0.0, 1024.0, DYNAMIC },
600 
601  { "brightness", "Brightness boost", OFFSET(brightness), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -1.0, 1.0, DYNAMIC },
602  { "contrast", "Contrast gain", OFFSET(contrast), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
603  { "saturation", "Saturation gain", OFFSET(saturation), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
604  { "hue", "Hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -M_PI, M_PI, DYNAMIC },
605  { "gamma", "Gamma adjustment", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
606 
607  { "peak_detect", "Enable dynamic peak detection for HDR tone-mapping", OFFSET(peakdetect), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
608  { "smoothing_period", "Peak detection smoothing period", OFFSET(smoothing), AV_OPT_TYPE_FLOAT, {.dbl = 100.0}, 0.0, 1000.0, DYNAMIC },
609  { "minimum_peak", "Peak detection minimum peak", OFFSET(min_peak), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 100.0, DYNAMIC },
610  { "scene_threshold_low", "Scene change low threshold", OFFSET(scene_low), AV_OPT_TYPE_FLOAT, {.dbl = 5.5}, -1.0, 100.0, DYNAMIC },
611  { "scene_threshold_high", "Scene change high threshold", OFFSET(scene_high), AV_OPT_TYPE_FLOAT, {.dbl = 10.0}, -1.0, 100.0, DYNAMIC },
612  { "overshoot", "Tone-mapping overshoot margin", OFFSET(overshoot), AV_OPT_TYPE_FLOAT, {.dbl = 0.05}, 0.0, 1.0, DYNAMIC },
613 
614  { "intent", "Rendering intent", OFFSET(intent), AV_OPT_TYPE_INT, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 3, DYNAMIC, "intent" },
615  { "perceptual", "Perceptual", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_PERCEPTUAL}, 0, 0, STATIC, "intent" },
616  { "relative", "Relative colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
617  { "absolute", "Absolute colorimetric", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_ABSOLUTE_COLORIMETRIC}, 0, 0, STATIC, "intent" },
618  { "saturation", "Saturation mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_SATURATION}, 0, 0, STATIC, "intent" },
619  { "tonemapping", "Tone-mapping algorithm", OFFSET(tonemapping), AV_OPT_TYPE_INT, {.i64 = PL_TONE_MAPPING_BT_2390}, 0, PL_TONE_MAPPING_ALGORITHM_COUNT - 1, DYNAMIC, "tonemap" },
620  { "clip", "Hard-clipping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_CLIP}, 0, 0, STATIC, "tonemap" },
621  { "mobius", "Mobius tone-mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_MOBIUS}, 0, 0, STATIC, "tonemap" },
622  { "reinhard", "Reinhard tone-mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_REINHARD}, 0, 0, STATIC, "tonemap" },
623  { "hable", "Hable/Filmic tone-mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_HABLE}, 0, 0, STATIC, "tonemap" },
624  { "gamma", "Gamma tone-mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_GAMMA}, 0, 0, STATIC, "tonemap" },
625  { "linear", "Linear tone-mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_LINEAR}, 0, 0, STATIC, "tonemap" },
626  { "bt.2390", "ITU-R BT.2390 tone-mapping", 0, AV_OPT_TYPE_CONST, {.i64 = PL_TONE_MAPPING_BT_2390}, 0, 0, STATIC, "tonemap" },
627  { "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 },
628  { "desaturation_strength", "Desaturation strength", OFFSET(desat_str), AV_OPT_TYPE_FLOAT, {.dbl = 0.90}, 0.0, 1.0, DYNAMIC },
629  { "desaturation_exponent", "Desaturation exponent", OFFSET(desat_exp), AV_OPT_TYPE_FLOAT, {.dbl = 0.2}, 0.0, 10.0, DYNAMIC },
630  { "desaturation_base", "Desaturation base", OFFSET(desat_base), AV_OPT_TYPE_FLOAT, {.dbl = 0.18}, 0.0, 10.0, DYNAMIC },
631  { "max_boost", "Tone-mapping maximum boost", OFFSET(max_boost), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 1.0, 10.0, DYNAMIC },
632  { "gamut_warning", "Highlight out-of-gamut colors", OFFSET(gamut_warning), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
633  { "gamut_clipping", "Enable colorimetric gamut clipping", OFFSET(gamut_clipping), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
634 
635  { "dithering", "Dither method to use", OFFSET(dithering), AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1, DYNAMIC, "dither" },
636  { "none", "Disable dithering", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, STATIC, "dither" },
637  { "blue", "Blue noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_BLUE_NOISE}, 0, 0, STATIC, "dither" },
638  { "ordered", "Ordered LUT", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_LUT}, 0, 0, STATIC, "dither" },
639  { "ordered_fixed", "Fixed function ordered", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_FIXED}, 0, 0, STATIC, "dither" },
640  { "white", "White noise", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_WHITE_NOISE}, 0, 0, STATIC, "dither" },
641  { "dither_lut_size", "Dithering LUT size", OFFSET(dither_lut_size), AV_OPT_TYPE_INT, {.i64 = 6}, 1, 8, STATIC },
642  { "dither_temporal", "Enable temporal dithering", OFFSET(dither_temporal), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
643 
644  { "cones", "Colorblindness adaptation model", OFFSET(cones), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, PL_CONE_LMS, DYNAMIC, "cone" },
645  { "l", "L cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_L}, 0, 0, STATIC, "cone" },
646  { "m", "M cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_M}, 0, 0, STATIC, "cone" },
647  { "s", "S cone", 0, AV_OPT_TYPE_CONST, {.i64 = PL_CONE_S}, 0, 0, STATIC, "cone" },
648  { "cone-strength", "Colorblindness adaptation strength", OFFSET(cone_str), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 10.0, DYNAMIC },
649 
650  { "custom_shader_path", "Path to custom user shader (mpv .hook format)", OFFSET(shader_path), AV_OPT_TYPE_STRING, .flags = STATIC },
651  { "custom_shader_bin", "Custom user shader as binary (mpv .hook format)", OFFSET(shader_bin), AV_OPT_TYPE_BINARY, .flags = STATIC },
652 
653  /* Performance/quality tradeoff options */
654  { "skip_aa", "Skip anti-aliasing", OFFSET(skip_aa), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 0, DYNAMIC },
655  { "polar_cutoff", "Polar LUT cutoff", OFFSET(polar_cutoff), AV_OPT_TYPE_FLOAT, {.i64 = 0}, 0.0, 1.0, DYNAMIC },
656  { "disable_linear", "Disable linear scaling", OFFSET(disable_linear), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
657  { "disable_builtin", "Disable built-in scalers", OFFSET(disable_builtin), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
658  { "force_icc_lut", "Force the use of a full ICC 3DLUT for color mapping", OFFSET(force_icc_lut), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
659  { "force_dither", "Force dithering", OFFSET(force_dither), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
660  { "disable_fbos", "Force-disable FBOs", OFFSET(disable_fbos), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
661  { NULL },
662 };
663 
664 AVFILTER_DEFINE_CLASS(libplacebo);
665 
666 static const AVFilterPad libplacebo_inputs[] = {
667  {
668  .name = "default",
669  .type = AVMEDIA_TYPE_VIDEO,
670  .filter_frame = &filter_frame,
671  .config_props = &ff_vk_filter_config_input,
672  },
673 };
674 
675 static const AVFilterPad libplacebo_outputs[] = {
676  {
677  .name = "default",
678  .type = AVMEDIA_TYPE_VIDEO,
679  .config_props = &libplacebo_config_output,
680  },
681 };
682 
684  .name = "libplacebo",
685  .description = NULL_IF_CONFIG_SMALL("Apply various GPU filters from libplacebo"),
686  .priv_size = sizeof(LibplaceboContext),
687  .init = &libplacebo_init,
693  .priv_class = &libplacebo_class,
694  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
695 };
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:98
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:570
LibplaceboContext::colorspace
int colorspace
Definition: vf_libplacebo.c:51
AVVulkanDeviceContext::phys_dev
VkPhysicalDevice phys_dev
Physical device.
Definition: hwcontext_vulkan.h:63
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:566
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
level
uint8_t level
Definition: svq3.c:202
AVCOL_PRI_EBU3213
@ AVCOL_PRI_EBU3213
EBU Tech. 3213-E (nothing there) / one of JEDEC P22 group phosphors.
Definition: pixfmt.h:485
LibplaceboContext::gamut_clipping
int gamut_clipping
Definition: vf_libplacebo.c:101
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
LibplaceboContext::deband
int deband
Definition: vf_libplacebo.c:71
log_cb
static int log_cb(void *arg, enum rist_log_level log_level, const char *msg)
Definition: librist.c:90
LibplaceboContext::deband_iterations
int deband_iterations
Definition: vf_libplacebo.c:72
LibplaceboContext::deband_threshold
float deband_threshold
Definition: vf_libplacebo.c:73
out
FILE * out
Definition: movenc.c:54
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:617
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:371
LibplaceboContext::contrast
float contrast
Definition: vf_libplacebo.c:79
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVCOL_TRC_LINEAR
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
Definition: pixfmt.h:503
AV_FRAME_DATA_DOVI_METADATA
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
Definition: frame.h:203
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:183
AVFrame::color_primaries
enum AVColorPrimaries color_primaries
Definition: frame.h:568
LibplaceboContext::apply_filmgrain
int apply_filmgrain
Definition: vf_libplacebo.c:49
LibplaceboContext::intent
int intent
Definition: vf_libplacebo.c:93
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:577
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
AVCOL_TRC_NB
@ AVCOL_TRC_NB
Not part of ABI.
Definition: pixfmt.h:516
AVVulkanDeviceContext::get_proc_addr
PFN_vkGetInstanceProcAddr get_proc_addr
Pointer to the instance-provided vkGetInstanceProcAddr loading function.
Definition: hwcontext_vulkan.h:53
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:597
pl_av_log
static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
Definition: vf_libplacebo.c:132
AVOption
AVOption.
Definition: opt.h:247
AVCOL_SPC_NB
@ AVCOL_SPC_NB
Not part of ABI.
Definition: pixfmt.h:540
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:497
LibplaceboContext
Definition: vf_libplacebo.c:29
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:196
AVVulkanDeviceContext::inst
VkInstance inst
Vulkan instance.
Definition: hwcontext_vulkan.h:58
AVCOL_PRI_JEDEC_P22
@ AVCOL_PRI_JEDEC_P22
Definition: pixfmt.h:486
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:524
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:510
process_frames
static int process_frames(AVFilterContext *avctx, AVFrame *out, AVFrame *in)
Definition: vf_libplacebo.c:279
ff_vk_uninit
void ff_vk_uninit(FFVulkanContext *s)
Frees the main Vulkan context.
Definition: vulkan.c:1378
LibplaceboContext::sigmoid
int sigmoid
Definition: vf_libplacebo.c:61
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
LibplaceboContext::vkctx
FFVulkanContext vkctx
Definition: vf_libplacebo.c:31
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:535
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:346
ff_vf_libplacebo
AVFilter ff_vf_libplacebo
Definition: vf_libplacebo.c:683
init
static int init
Definition: av_tx.c:47
libplacebo_config_output
static int libplacebo_config_output(AVFilterLink *outlink)
Definition: vf_libplacebo.c:458
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:529
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:230
AVCOL_TRC_IEC61966_2_1
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:508
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:53
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:417
LibplaceboContext::shader_bin_len
int shader_bin_len
Definition: vf_libplacebo.c:115
fail
#define fail()
Definition: checkasm.h:128
vulkan_filter.h
AVCOL_RANGE_NB
@ AVCOL_RANGE_NB
Not part of ABI.
Definition: pixfmt.h:598
AVCOL_TRC_GAMMA28
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Definition: pixfmt.h:500
AVVulkanFramesContext
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
Definition: hwcontext_vulkan.h:157
find_scaler
static int find_scaler(AVFilterContext *avctx, const struct pl_filter_config **opt, const char *name)
Definition: vf_libplacebo.c:164
LibplaceboContext::lut_entries
int lut_entries
Definition: vf_libplacebo.c:59
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_libplacebo.c:391
LibplaceboContext::gamut_warning
int gamut_warning
Definition: vf_libplacebo.c:100
AVCOL_TRC_GAMMA22
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:499
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
LibplaceboContext::antiringing
float antiringing
Definition: vf_libplacebo.c:60
preset
preset
Definition: vf_curves.c:46
LibplaceboContext::disable_linear
int disable_linear
Definition: vf_libplacebo.c:64
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
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVCOL_PRI_NB
@ AVCOL_PRI_NB
Not part of ABI.
Definition: pixfmt.h:487
LibplaceboContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_libplacebo.c:46
AVCOL_TRC_BT1361_ECG
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
Definition: pixfmt.h:507
LibplaceboContext::force_dither
int force_dither
Definition: vf_libplacebo.c:67
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:530
init_vulkan
static int init_vulkan(AVFilterContext *avctx)
Definition: vf_libplacebo.c:205
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:666
libplacebo_uninit
static void libplacebo_uninit(AVFilterContext *avctx)
Definition: vf_libplacebo.c:265
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
LibplaceboContext::tonemapping
int tonemapping
Definition: vf_libplacebo.c:94
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:481
LibplaceboContext::disable_builtin
int disable_builtin
Definition: vf_libplacebo.c:65
LibplaceboContext::color_trc
int color_trc
Definition: vf_libplacebo.c:54
LibplaceboContext::w_expr
char * w_expr
Definition: vf_libplacebo.c:42
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:478
color_range
color_range
Definition: vf_selectivecolor.c:44
LibplaceboContext::force_divisible_by
int force_divisible_by
Definition: vf_libplacebo.c:47
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:472
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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:144
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:476
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:477
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:435
AVVulkanDeviceContext
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_vulkan.h:42
NULL
#define NULL
Definition: coverity.c:32
LibplaceboContext::dither_temporal
int dither_temporal
Definition: vf_libplacebo.c:106
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:537
AVVulkanDeviceContext::nb_enabled_dev_extensions
int nb_enabled_dev_extensions
Definition: hwcontext_vulkan.h:97
LibplaceboContext::skip_aa
int skip_aa
Definition: vf_libplacebo.c:62
LibplaceboContext::shader_bin
void * shader_bin
Definition: vf_libplacebo.c:114
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
LibplaceboContext::cones
int cones
Definition: vf_libplacebo.c:109
AVCOL_TRC_IEC61966_2_4
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
Definition: pixfmt.h:506
LibplaceboContext::brightness
float brightness
Definition: vf_libplacebo.c:78
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:410
LibplaceboContext::gpu
pl_gpu gpu
Definition: vf_libplacebo.c:37
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:471
LibplaceboContext::initialized
int initialized
Definition: vf_libplacebo.c:32
ff_vk_filter_config_output
int ff_vk_filter_config_output(AVFilterLink *outlink)
Definition: vulkan_filter.c:133
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:119
LibplaceboContext::desat_str
float desat_str
Definition: vf_libplacebo.c:96
AVVulkanFramesContext::usage
VkImageUsageFlagBits usage
Defines extra usage of output frames.
Definition: hwcontext_vulkan.h:170
AVCOL_TRC_BT2020_10
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Definition: pixfmt.h:509
AVCOL_SPC_YCGCO
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: pixfmt.h:532
FFVulkanContext
Definition: vulkan.h:188
LibplaceboContext::desat_exp
float desat_exp
Definition: vf_libplacebo.c:97
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:563
parse_shader
static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
Definition: vf_libplacebo.c:149
LibplaceboContext::max_boost
float max_boost
Definition: vf_libplacebo.c:99
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:480
LibplaceboContext::cone_str
float cone_str
Definition: vf_libplacebo.c:110
LibplaceboContext::hue
float hue
Definition: vf_libplacebo.c:81
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:511
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:483
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:117
AVCOL_TRC_SMPTE240M
@ AVCOL_TRC_SMPTE240M
Definition: pixfmt.h:502
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:479
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:75
LibplaceboContext::out_format_string
char * out_format_string
Definition: vf_libplacebo.c:41
LibplaceboContext::disable_fbos
int disable_fbos
Definition: vf_libplacebo.c:68
LibplaceboContext::saturation
float saturation
Definition: vf_libplacebo.c:80
LibplaceboContext::num_hooks
int num_hooks
Definition: vf_libplacebo.c:117
libplacebo_options
static const AVOption libplacebo_options[]
Definition: vf_libplacebo.c:518
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:882
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:691
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
LibplaceboContext::overshoot
float overshoot
Definition: vf_libplacebo.c:90
LibplaceboContext::normalize_sar
int normalize_sar
Definition: vf_libplacebo.c:48
LibplaceboContext::polar_cutoff
float polar_cutoff
Definition: vf_libplacebo.c:63
LibplaceboContext::apply_dovi
int apply_dovi
Definition: vf_libplacebo.c:50
LibplaceboContext::downscaler
char * downscaler
Definition: vf_libplacebo.c:58
LibplaceboContext::log
pl_log log
Definition: vf_libplacebo.c:35
LibplaceboContext::vulkan
pl_vulkan vulkan
Definition: vf_libplacebo.c:36
M_PI
#define M_PI
Definition: mathematics.h:52
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:496
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:181
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:531
get_log_level
static enum pl_log_level get_log_level(void)
Definition: vf_libplacebo.c:120
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:136
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
LibplaceboContext::upscaler
char * upscaler
Definition: vf_libplacebo.c:57
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:534
LibplaceboContext::gamma
float gamma
Definition: vf_libplacebo.c:82
LibplaceboContext::target_sar
AVRational target_sar
Definition: vf_libplacebo.c:44
LibplaceboContext::force_icc_lut
int force_icc_lut
Definition: vf_libplacebo.c:66
LibplaceboContext::min_peak
float min_peak
Definition: vf_libplacebo.c:87
LibplaceboContext::tonemapping_param
float tonemapping_param
Definition: vf_libplacebo.c:95
LibplaceboContext::color_primaries
int color_primaries
Definition: vf_libplacebo.c:53
len
int len
Definition: vorbis_enc_data.h:426
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:526
LibplaceboContext::dithering
int dithering
Definition: vf_libplacebo.c:104
LibplaceboContext::scene_high
float scene_high
Definition: vf_libplacebo.c:89
STATIC
#define STATIC
Definition: vf_libplacebo.c:515
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:580
AVFilter
Filter definition.
Definition: avfilter.h:165
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
LibplaceboContext::desat_base
float desat_base
Definition: vf_libplacebo.c:98
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:474
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
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:88
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:162
ff_scale_adjust_dimensions
int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by)
Transform evaluated width and height obtained from ff_scale_eval_dimensions into actual target width ...
Definition: scale_eval.c:113
LibplaceboContext::peakdetect
int peakdetect
Definition: vf_libplacebo.c:85
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2592
LibplaceboContext::deband_radius
float deband_radius
Definition: vf_libplacebo.c:74
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:515
libplacebo_outputs
static const AVFilterPad libplacebo_outputs[]
Definition: vf_libplacebo.c:675
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
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:501
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:514
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AVVulkanDeviceContext::enabled_dev_extensions
const char *const * enabled_dev_extensions
Enabled device extensions.
Definition: hwcontext_vulkan.h:96
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:52
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
LibplaceboContext::renderer
pl_renderer renderer
Definition: vf_libplacebo.c:38
LibplaceboContext::pad_crop_ratio
float pad_crop_ratio
Definition: vf_libplacebo.c:45
AVVulkanDeviceContext::act_dev
VkDevice act_dev
Active device.
Definition: hwcontext_vulkan.h:68
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:484
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
LibplaceboContext::smoothing
float smoothing
Definition: vf_libplacebo.c:86
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:223
DYNAMIC
#define DYNAMIC
Definition: vf_libplacebo.c:516
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
LibplaceboContext::shader_path
char * shader_path
Definition: vf_libplacebo.c:113
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:282
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
AVVulkanDeviceContext::device_features
VkPhysicalDeviceFeatures2 device_features
This structure should be set to the set of features that present and enabled during device creation.
Definition: hwcontext_vulkan.h:76
LibplaceboContext::color_range
int color_range
Definition: vf_libplacebo.c:52
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
LibplaceboContext::dither_lut_size
int dither_lut_size
Definition: vf_libplacebo.c:105
libplacebo_init
static int libplacebo_init(AVFilterContext *avctx)
Definition: vf_libplacebo.c:187
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:525
LibplaceboContext::h_expr
char * h_expr
Definition: vf_libplacebo.c:43
AVCOL_SPC_ICTCP
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
Definition: pixfmt.h:539
LibplaceboContext::hooks
const struct pl_hook * hooks[2]
Definition: vf_libplacebo.c:116
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
color_primaries
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
Definition: vf_colorspace.c:211
RET
#define RET(x)
Definition: vulkan.h:52