Go to the documentation of this file.
33 #include <libplacebo/renderer.h>
34 #include <libplacebo/utils/libav.h>
35 #include <libplacebo/utils/frame_queue.h>
36 #include <libplacebo/vulkan.h>
42 return frame->user_data;
47 #include <libplacebo/options.h>
61 #define pl_options_alloc(log) av_mallocz(sizeof(struct pl_options_t))
62 #define pl_options_free(ptr) av_freep(ptr)
288 av_log(log_ctx, av_lev,
"%s\n", msg);
295 #if PL_API_VER >= 246
313 switch (gamut_mode) {
314 #if PL_API_VER >= 269
315 case GAMUT_MAP_CLIP: p->gamut_mapping = &pl_gamut_map_clip;
return;
340 const struct pl_filter_config **opt,
341 const char *
name,
int frame_mixing)
343 const struct pl_filter_preset *
preset, *presets_avail;
344 presets_avail = frame_mixing ? pl_frame_mixers : pl_scale_filters;
346 if (!strcmp(
name,
"help")) {
369 pl_options
opts =
s->opts;
370 int gamut_mode =
s->gamut_mode;
371 uint8_t color_rgba[4];
375 opts->deband_params = *pl_deband_params(
376 .iterations =
s->deband_iterations,
377 .threshold =
s->deband_threshold,
378 .radius =
s->deband_radius,
379 .grain =
s->deband_grain,
382 opts->sigmoid_params = pl_sigmoid_default_params;
384 opts->color_adjustment = (
struct pl_color_adjustment) {
385 .brightness =
s->brightness,
386 .contrast =
s->contrast,
387 .saturation =
s->saturation,
392 opts->peak_detect_params = *pl_peak_detect_params(
393 .smoothing_period =
s->smoothing,
394 .minimum_peak =
s->min_peak,
395 .scene_threshold_low =
s->scene_low,
396 .scene_threshold_high =
s->scene_high,
397 #
if PL_API_VER >= 263
398 .percentile =
s->percentile,
402 opts->color_map_params = *pl_color_map_params(
404 .tone_mapping_param =
s->tonemapping_param,
405 .inverse_tone_mapping =
s->inverse_tonemapping,
406 .lut_size =
s->tonemapping_lut_size,
407 #
if PL_API_VER >= 285
408 .contrast_recovery =
s->contrast_recovery,
409 .contrast_smoothness =
s->contrast_smoothness,
415 opts->dither_params = *pl_dither_params(
416 .method =
s->dithering,
417 .lut_size =
s->dither_lut_size,
418 .temporal =
s->dither_temporal,
421 opts->cone_params = *pl_cone_params(
423 .strength =
s->cone_str,
426 opts->params = *pl_render_params(
427 .lut_entries =
s->lut_entries,
428 .antiringing_strength =
s->antiringing,
429 .background_transparency = 1.0f - (
float) color_rgba[3] / UINT8_MAX,
430 .background_color = {
431 (float) color_rgba[0] / UINT8_MAX,
432 (float) color_rgba[1] / UINT8_MAX,
433 (float) color_rgba[2] / UINT8_MAX,
435 #
if PL_API_VER >= 277
436 .corner_rounding =
s->corner_rounding,
439 .deband_params =
s->deband ? &
opts->deband_params :
NULL,
440 .sigmoid_params =
s->sigmoid ? &
opts->sigmoid_params :
NULL,
441 .color_adjustment = &
opts->color_adjustment,
442 .peak_detect_params =
s->peakdetect ? &
opts->peak_detect_params :
NULL,
443 .color_map_params = &
opts->color_map_params,
444 .dither_params =
s->dithering >= 0 ? &
opts->dither_params :
NULL,
445 .cone_params =
s->cones ? &
opts->cone_params :
NULL,
448 .num_hooks =
s->num_hooks,
450 .skip_anti_aliasing =
s->skip_aa,
451 .polar_cutoff =
s->polar_cutoff,
452 .disable_linear_scaling =
s->disable_linear,
453 .disable_builtin_scalers =
s->disable_builtin,
454 .force_dither =
s->force_dither,
455 .disable_fbos =
s->disable_fbos,
462 #if PL_API_VER >= 309
464 if (!pl_options_set_str(
s->opts, e->
key, e->
value)) {
484 const struct pl_hook *hook;
486 hook = pl_mpv_user_shader_parse(
s->gpu, shader,
len);
492 s->hooks[
s->num_hooks++] = hook;
507 s->log = pl_log_create(PL_API_VER, pl_log_params(
522 if (
s->out_format_string) {
526 s->out_format_string);
534 for (
int i = 0;
i <
s->nb_inputs;
i++) {
563 if (strcmp(
s->fps_string,
"none") != 0)
569 vkhwctx = avhwctx->
hwctx;
580 #if PL_API_VER >= 278
581 static void lock_queue(
void *priv, uint32_t qf, uint32_t qidx)
588 static void unlock_queue(
void *priv, uint32_t qf, uint32_t qidx)
603 input->queue = pl_queue_create(
s->gpu);
604 input->renderer = pl_renderer_create(
s->log,
s->gpu);
612 pl_renderer_destroy(&
input->renderer);
613 pl_queue_destroy(&
input->queue);
625 #if PL_API_VER >= 278
627 s->vulkan = pl_vulkan_import(
s->log, pl_vulkan_import_params(
628 .instance = hwctx->
inst,
639 .index = hwctx->queue_family_index,
640 .count = hwctx->nb_graphics_queues,
643 .index = hwctx->queue_family_comp_index,
644 .count = hwctx->nb_comp_queues,
647 .index = hwctx->queue_family_tx_index,
648 .count = hwctx->nb_tx_queues,
651 .max_api_version = VK_API_VERSION_1_3,
655 "Vulkan device, remove it or upgrade libplacebo to >= 5.278\n",
661 s->have_hwdevice = 1;
663 s->vulkan = pl_vulkan_create(
s->log, pl_vulkan_params(
670 hwctx ?
"importing" :
"creating");
675 s->gpu =
s->vulkan->gpu;
678 if (
s->shader_bin_len)
681 if (
s->shader_path &&
s->shader_path[0]) {
687 s->inputs =
av_calloc(
s->nb_inputs,
sizeof(*
s->inputs));
690 for (
int i = 0;
i <
s->nb_inputs;
i++)
705 pl_tex_destroy(
s->gpu, &
s->tex[
i]);
706 for (
int i = 0;
i <
s->num_hooks;
i++)
707 pl_mpv_user_shader_destroy(&
s->hooks[
i]);
709 for (
int i = 0;
i <
s->nb_inputs;
i++)
715 pl_vulkan_destroy(&
s->vulkan);
716 pl_log_destroy(&
s->log);
731 const char *
arg,
char *res,
int res_len,
745 for (
int i = 0;
i <
mix->num_frames;
i++) {
746 if (
i+1 ==
mix->num_frames ||
mix->timestamps[
i+1] > 0)
753 struct pl_frame *target,
double target_pts)
760 for (
int i = 0;
i < in->
mix.num_frames;
i++) {
763 struct pl_frame *image = (
struct pl_frame *) in->
mix.frames[
i];
800 image->crop.x1 = image->crop.x0 +
s->var_values[
VAR_CROP_W];
801 image->crop.y1 = image->crop.y0 +
s->var_values[
VAR_CROP_H];
807 target->crop.x1 = target->crop.x0 +
s->var_values[
VAR_POS_W];
808 target->crop.y1 = target->crop.y0 +
s->var_values[
VAR_POS_H];
809 if (
s->normalize_sar) {
810 float aspect = pl_rect2df_aspect(&image->crop);
812 pl_rect2df_aspect_set(&target->crop, aspect,
s->pad_crop_ratio);
821 int err = 0, ok, changed;
823 pl_options
opts =
s->opts;
826 struct pl_frame target;
831 for (
int i = 0;
i <
s->nb_inputs;
i++) {
845 out->width = outlink->
w;
846 out->height = outlink->
h;
860 if (
s->color_trc >= 0)
861 out->color_trc =
s->color_trc;
862 if (
s->color_primaries >= 0)
863 out->color_primaries =
s->color_primaries;
866 if (
out->width !=
ref->width ||
out->height !=
ref->height)
868 if (
ref->color_trc !=
out->color_trc ||
ref->color_primaries !=
out->color_primaries)
872 if (
s->apply_filmgrain)
877 ok = pl_map_avframe_ex(
s->gpu, &target, pl_avframe_params(
882 ok = pl_frame_recreate_from_avframe(
s->gpu, &target,
s->tex,
out);
890 opts->params.skip_target_clearing =
false;
892 for (
int i = 0;
i <
s->nb_inputs;
i++) {
897 if (in->
qstatus != PL_QUEUE_OK)
899 opts->params.skip_caching_single_frame = high_fps;
902 opts->params.skip_target_clearing =
true;
903 opts->params.blend_params = &pl_alpha_overlay;
907 pl_unmap_avframe(
s->gpu, &target);
908 }
else if (!pl_download_avframe(
s->gpu, &target,
out)) {
920 const struct pl_source_frame *
src,
921 struct pl_frame *
out)
925 bool ok = pl_map_avframe_ex(gpu,
out, pl_avframe_params(
928 .map_dovi =
s->apply_dovi,
931 if (!
s->apply_filmgrain)
932 out->film_grain.type = PL_FILM_GRAIN_NONE;
939 const struct pl_source_frame *
src)
941 pl_unmap_avframe(gpu,
frame);
961 pl_queue_push(
input->queue, &(
struct pl_source_frame) {
962 .pts = in->pts * av_q2d(inlink->time_base),
963 .duration = in->duration * av_q2d(inlink->time_base),
964 .first_field = pl_field_from_avframe(in),
967 .unmap = unmap_frame,
968 .discard = discard_frame,
987 if (!
s->status ||
pts >=
s->status_pts) {
1006 int ret, ok = 0, retry = 0;
1015 for (
int i = 0;
i <
s->nb_inputs;
i++) {
1025 out_pts = INT64_MAX;
1026 for (
int i = 0;
i <
s->nb_inputs;
i++) {
1030 }
else if (!in->
status) {
1041 for (
int i = 0;
i <
s->nb_inputs;
i++) {
1051 .radius = pl_frame_mix_radius(&
s->opts->params),
1072 for (
int i = 0;
i <
s->nb_inputs;
i++)
1075 }
else if (
s->status) {
1098 #if PL_API_VER < 232
1108 if (!pl_test_pixfmt(
s->gpu,
pixfmt))
1121 }
else if (
pixfmt ==
s->out_format) {
1128 #if PL_API_VER >= 293
1129 if (!pl_test_pixfmt_caps(
s->gpu,
pixfmt, PL_FMT_CAP_RENDERABLE))
1136 if (!infmts || !outfmts) {
1141 for (
int i = 0;
i <
s->nb_inputs;
i++)
1161 if (outfmts && !outfmts->refcount)
1175 s->vkctx.input_format =
inlink->format;
1200 &outlink->
w, &outlink->
h));
1203 s->force_original_aspect_ratio,
1204 s->force_divisible_by);
1206 if (
s->normalize_sar ||
s->nb_inputs > 1) {
1213 if (
inlink->sample_aspect_ratio.num)
1225 for (
int i = 1;
i <
s->nb_inputs;
i++) {
1247 s->vkctx.output_width = outlink->
w;
1248 s->vkctx.output_height = outlink->
h;
1251 s->vkctx.output_format =
s->vkctx.input_format;
1253 s->vkctx.output_format =
s->out_format;
1258 vkfc->
usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1266 #define OFFSET(x) offsetof(LibplaceboContext, x)
1267 #define STATIC (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
1268 #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM)
1284 {
"force_original_aspect_ratio",
"decrease or increase w/h if necessary to keep the original AR",
OFFSET(force_original_aspect_ratio),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
STATIC, .unit =
"force_oar" },
1288 {
"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 },
1289 {
"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 },
1290 {
"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 },
1293 {
"extra_opts",
"Pass extra libplacebo-specific options using a :-separated list of key=value pairs",
OFFSET(extra_opts),
AV_OPT_TYPE_DICT, .flags =
DYNAMIC },
1296 {
"auto",
"keep the same colorspace", 0,
AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX,
STATIC, .unit =
"colorspace"},
1320 {
"auto",
"keep the same color primaries", 0,
AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX,
STATIC, .unit =
"color_primaries"},
1336 {
"auto",
"keep the same color transfer", 0,
AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX,
STATIC, .unit =
"color_trc"},
1393 #if PL_API_VER >= 246
1405 {
"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 },
1406 {
"inverse_tonemapping",
"Inverse tone mapping (range expansion)",
OFFSET(inverse_tonemapping),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
DYNAMIC },
1409 {
"contrast_smoothness",
"HDR contrast recovery smoothness",
OFFSET(contrast_smoothness),
AV_OPT_TYPE_FLOAT, {.dbl = 3.50}, 1.0, 32.0,
DYNAMIC },
1411 {
"dithering",
"Dither method to use",
OFFSET(dithering),
AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1,
DYNAMIC, .unit =
"dither" },
1413 {
"blue",
"Blue noise", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_BLUE_NOISE}, 0, 0,
STATIC, .unit =
"dither" },
1414 {
"ordered",
"Ordered LUT", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_LUT}, 0, 0,
STATIC, .unit =
"dither" },
1415 {
"ordered_fixed",
"Fixed function ordered", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_FIXED}, 0, 0,
STATIC, .unit =
"dither" },
1416 {
"white",
"White noise", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_WHITE_NOISE}, 0, 0,
STATIC, .unit =
"dither" },
1450 .
name =
"libplacebo",
1459 .priv_class = &libplacebo_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
@ AV_ROUND_UP
Round toward +infinity.
void av_fifo_drain2(AVFifo *f, size_t size)
Discard the specified amount of data from an AVFifo.
enum AVPixelFormat out_format
VkPhysicalDevice phys_dev
Physical device.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
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
@ AVCOL_PRI_EBU3213
EBU Tech. 3213-E (nothing there) / one of JEDEC P22 group phosphors.
static int mix(int c0, int c1)
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
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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.
uint8_t * data
The data buffer.
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
struct pl_sigmoid_params sigmoid_params
static IPT saturation(const CmsCtx *ctx, IPT ipt)
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
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
char * av_asprintf(const char *fmt,...)
@ AV_FRAME_DATA_FILM_GRAIN_PARAMS
Film grain parameters for a frame, described by AVFilmGrainParams.
static int find_scaler(AVFilterContext *avctx, const struct pl_filter_config **opt, const char *name, int frame_mixing)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void * opaque
Frame owner's private data.
static int update_settings(AVFilterContext *ctx)
int av_fifo_peek(const AVFifo *f, void *buf, size_t nb_elems, size_t offset)
Read data from a FIFO without modifying FIFO state.
This structure describes decoded (raw) audio or video data.
@ AVCOL_TRC_NB
Not part of ABI.
struct pl_deband_params deband_params
PFN_vkGetInstanceProcAddr get_proc_addr
Pointer to a vkGetInstanceProcAddr loading function.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
@ AVCOL_RANGE_JPEG
Full range content.
static void pl_av_log(void *log_ctx, enum pl_log_level level, const char *msg)
@ AVCOL_SPC_NB
Not part of ABI.
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
VkInstance inst
Vulkan instance.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_LOG_VERBOSE
Detailed information.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
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.
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
static int handle_input(AVFilterContext *ctx, LibplaceboInput *input)
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
static AVFrame * pl_get_mapped_avframe(const struct pl_frame *frame)
static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src, struct pl_frame *out)
const char * name
Filter name.
struct pl_color_adjustment color_adjustment
A link between two filters.
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
static int libplacebo_activate(AVFilterContext *ctx)
Link properties exposed to filter code, but not external callers.
@ AV_HWDEVICE_TYPE_VULKAN
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.
static void unmap_frame(pl_gpu gpu, struct pl_frame *frame, const struct pl_source_frame *src)
static int libplacebo_config_output(AVFilterLink *outlink)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
@ AV_OPT_TYPE_BINARY
Underlying C type is a uint8_t* that is either NULL or points to an array allocated with the av_mallo...
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
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...
void * priv
private data for use by the filter
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
@ AVCOL_RANGE_NB
Not part of ABI.
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
static void lock_queue(AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
float contrast_smoothness
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
A filter pad used for either input or output.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
AVDictionary * extra_opts
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
const AVFilter ff_vf_libplacebo
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static const AVFrame * ref_frame(const struct pl_frame_mix *mix)
static int output_frame(AVFilterContext *ctx, int64_t pts)
@ AVCOL_PRI_NB
Not part of ABI.
int force_original_aspect_ratio
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
static void discard_frame(const struct pl_source_frame *src)
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
static double av_q2d(AVRational a)
Convert an AVRational to a double.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static void libplacebo_uninit(AVFilterContext *avctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int libplacebo_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
struct pl_peak_detect_params peak_detect_params
#define FILTER_OUTPUTS(array)
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
int av_log_get_level(void)
Get the current log level.
static const struct pl_tone_map_function * get_tonemapping_func(int tm)
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
int nb_enabled_dev_extensions
Rational number (pair of numerator and denominator).
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
filter_frame For filters that do not use the activate() callback
void(* unlock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
Similar to lock_queue(), unlocks a queue.
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
AVFilterLink ** inputs
array of pointers to input links
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
int ff_vk_filter_config_output(AVFilterLink *outlink)
VkImageUsageFlagBits usage
Defines extra usage of output frames.
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
@ AVCOL_SPC_YCGCO
used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
static int input_init(AVFilterContext *avctx, LibplaceboInput *input, int idx)
int64_t status_pts
tracks status of most recently used input
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
@ AVCOL_RANGE_UNSPECIFIED
static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
static void set_gamut_mode(struct pl_color_map_params *p, int gamut_mode)
static int libplacebo_config_input(AVFilterLink *inlink)
static FilterLink * ff_filter_link(AVFilterLink *link)
@ AVCOL_PRI_BT2020
ITU-R BT2020.
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwctx)
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AVCOL_PRI_FILM
colour filters using Illuminant C
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
AVFILTER_DEFINE_CLASS(libplacebo)
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
int format
agreed upon media format
static const AVOption libplacebo_options[]
AVFilterContext * src
source filter
static float sigmoid(float x)
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.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
#define pl_options_alloc(log)
double var_values[VAR_VARS_NB]
#define AVERROR_EXTERNAL
Generic error in an external library.
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd, int props)
Remove and free all side data instances that match any of the given side data properties.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
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.
#define AV_LOG_INFO
Standard information.
@ AVCOL_TRC_BT709
also ITU-R BT1361
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.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
static enum pl_log_level get_log_level(void)
static void uninit(AVBSFContext *ctx)
#define i(width, name, range_min, range_max)
struct pl_render_params params
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
#define pl_options_free(ptr)
AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def)
Return the best rational so that a and b are multiple of it.
int w
agreed upon image width
#define AV_TIME_BASE
Internal time base represented as integer.
#define FILTER_QUERY_FUNC2(func)
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static const char *const var_names[]
const char * name
Pad name.
static void drain_input_pts(LibplaceboInput *in, int64_t until)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
void * av_calloc(size_t nmemb, size_t size)
@ AV_SIDE_DATA_PROP_COLOR_DEPENDENT
Side data depends on the video color space.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
struct pl_dither_params dither_params
This struct describes a set or pool of "hardware" frames (i.e.
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
enum AVPixelFormat pixfmt
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
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
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
static void unlock_queue(AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index)
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.
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 ...
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, struct pl_frame *target, double target_pts)
int h
agreed upon image height
static const AVFilterPad libplacebo_outputs[]
@ AV_OPT_TYPE_INT
Underlying C type is int.
static int ref[MAX_W *MAX_W]
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
AVRational fps
parsed FPS, or 0/0 for "none"
static void input_uninit(LibplaceboInput *input)
const char *const * enabled_dev_extensions
Enabled device extensions.
int ff_vk_filter_config_input(AVFilterLink *inlink)
static int libplacebo_query_format(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VkDevice act_dev
Active device.
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
enum AVColorSpace colorspace
For non-YUV links, these are respectively set to fallback values (as appropriate for that colorspace)...
static AVRational max_q(AVRational a, AVRational b)
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
struct pl_color_map_params color_map_params
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
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
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
VkPhysicalDeviceFeatures2 device_features
This structure should be set to the set of features that present and enabled during device creation.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
static int libplacebo_init(AVFilterContext *avctx)
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
struct pl_cone_params cone_params
enum AVColorRange color_range
agreed upon YUV color range
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
const struct pl_hook * hooks[2]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
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.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)