Go to the documentation of this file.
32 #include <libplacebo/renderer.h>
33 #include <libplacebo/utils/libav.h>
34 #include <libplacebo/utils/frame_queue.h>
35 #include <libplacebo/vulkan.h>
41 return frame->user_data;
46 #include <libplacebo/options.h>
60 #define pl_options_alloc(log) av_mallocz(sizeof(struct pl_options_t))
61 #define pl_options_free(ptr) av_freep(ptr)
243 #if FF_API_LIBPLACEBO_OPTS
251 int tonemapping_mode;
300 av_log(log_ctx, av_lev,
"%s\n", msg);
307 #if PL_API_VER >= 246
325 switch (gamut_mode) {
326 #if PL_API_VER >= 269
327 case GAMUT_MAP_CLIP: p->gamut_mapping = &pl_gamut_map_clip;
return;
352 const struct pl_filter_config **opt,
353 const char *
name,
int frame_mixing)
355 const struct pl_filter_preset *
preset, *presets_avail;
356 presets_avail = frame_mixing ? pl_frame_mixers : pl_scale_filters;
358 if (!strcmp(
name,
"help")) {
381 pl_options
opts =
s->opts;
382 int gamut_mode =
s->gamut_mode;
383 uint8_t color_rgba[4];
385 #if FF_API_LIBPLACEBO_OPTS
386 float hybrid_mix =
s->hybrid_mix;
388 switch (
s->tonemapping_mode) {
390 if (
s->desat_str >= 0.0f)
391 hybrid_mix =
s->desat_str;
393 case 1: hybrid_mix = 1.0f;
break;
394 case 2: hybrid_mix = 0.2f;
break;
395 case 3: hybrid_mix = 0.0f;
break;
396 case 4: hybrid_mix = 0.0f;
break;
405 if (
s->gamut_warning)
407 if (
s->gamut_clipping)
413 opts->deband_params = *pl_deband_params(
414 .iterations =
s->deband_iterations,
415 .threshold =
s->deband_threshold,
416 .radius =
s->deband_radius,
417 .grain =
s->deband_grain,
420 opts->sigmoid_params = pl_sigmoid_default_params;
422 opts->color_adjustment = (
struct pl_color_adjustment) {
423 .brightness =
s->brightness,
424 .contrast =
s->contrast,
425 .saturation =
s->saturation,
430 opts->peak_detect_params = *pl_peak_detect_params(
431 .smoothing_period =
s->smoothing,
432 .minimum_peak =
s->min_peak,
433 .scene_threshold_low =
s->scene_low,
434 .scene_threshold_high =
s->scene_high,
435 #
if PL_API_VER >= 263
436 .percentile =
s->percentile,
439 .overshoot_margin =
s->overshoot,
443 opts->color_map_params = *pl_color_map_params(
445 #
if PL_API_VER >= 269
446 .hybrid_mix = hybrid_mix,
448 .tone_mapping_mode =
s->tonemapping_mode,
449 .tone_mapping_crosstalk =
s->crosstalk,
453 .tone_mapping_param =
s->tonemapping_param,
454 .inverse_tone_mapping =
s->inverse_tonemapping,
455 .lut_size =
s->tonemapping_lut_size,
456 #
if PL_API_VER >= 285
457 .contrast_recovery =
s->contrast_recovery,
458 .contrast_smoothness =
s->contrast_smoothness,
464 opts->dither_params = *pl_dither_params(
465 .method =
s->dithering,
466 .lut_size =
s->dither_lut_size,
467 .temporal =
s->dither_temporal,
470 opts->cone_params = *pl_cone_params(
472 .strength =
s->cone_str,
475 opts->params = *pl_render_params(
476 .lut_entries =
s->lut_entries,
477 .antiringing_strength =
s->antiringing,
478 .background_transparency = 1.0f - (
float) color_rgba[3] / UINT8_MAX,
479 .background_color = {
480 (float) color_rgba[0] / UINT8_MAX,
481 (float) color_rgba[1] / UINT8_MAX,
482 (float) color_rgba[2] / UINT8_MAX,
484 #
if PL_API_VER >= 277
485 .corner_rounding =
s->corner_rounding,
488 .deband_params =
s->deband ? &
opts->deband_params :
NULL,
489 .sigmoid_params =
s->sigmoid ? &
opts->sigmoid_params :
NULL,
490 .color_adjustment = &
opts->color_adjustment,
491 .peak_detect_params =
s->peakdetect ? &
opts->peak_detect_params :
NULL,
492 .color_map_params = &
opts->color_map_params,
493 .dither_params =
s->dithering >= 0 ? &
opts->dither_params :
NULL,
494 .cone_params =
s->cones ? &
opts->cone_params :
NULL,
497 .num_hooks =
s->num_hooks,
499 .skip_anti_aliasing =
s->skip_aa,
500 .polar_cutoff =
s->polar_cutoff,
501 .disable_linear_scaling =
s->disable_linear,
502 .disable_builtin_scalers =
s->disable_builtin,
503 .force_dither =
s->force_dither,
504 .disable_fbos =
s->disable_fbos,
511 #if PL_API_VER >= 309
513 if (!pl_options_set_str(
s->opts, e->
key, e->
value)) {
533 const struct pl_hook *hook;
535 hook = pl_mpv_user_shader_parse(
s->gpu, shader,
len);
541 s->hooks[
s->num_hooks++] = hook;
554 s->log = pl_log_create(PL_API_VER, pl_log_params(
569 if (
s->out_format_string) {
573 s->out_format_string);
581 for (
int i = 0;
i <
s->nb_inputs;
i++) {
610 if (strcmp(
s->fps_string,
"none") != 0)
620 #if PL_API_VER >= 278
621 static void lock_queue(
void *priv, uint32_t qf, uint32_t qidx)
628 static void unlock_queue(
void *priv, uint32_t qf, uint32_t qidx)
644 input->queue = pl_queue_create(
s->gpu);
645 input->renderer = pl_renderer_create(
s->log,
s->gpu);
654 pl_renderer_destroy(&
input->renderer);
655 pl_queue_destroy(&
input->queue);
667 #if PL_API_VER >= 278
669 s->vulkan = pl_vulkan_import(
s->log, pl_vulkan_import_params(
670 .instance = hwctx->
inst,
681 .index = hwctx->queue_family_index,
682 .count = hwctx->nb_graphics_queues,
685 .index = hwctx->queue_family_comp_index,
686 .count = hwctx->nb_comp_queues,
689 .index = hwctx->queue_family_tx_index,
690 .count = hwctx->nb_tx_queues,
693 .max_api_version = VK_API_VERSION_1_3,
697 "Vulkan device, remove it or upgrade libplacebo to >= 5.278\n",
703 s->vulkan = pl_vulkan_create(
s->log, pl_vulkan_params(
710 hwctx ?
"importing" :
"creating");
715 s->gpu =
s->vulkan->gpu;
718 if (
s->shader_bin_len)
721 if (
s->shader_path &&
s->shader_path[0]) {
727 s->inputs =
av_calloc(
s->nb_inputs,
sizeof(*
s->inputs));
730 for (
int i = 0;
i <
s->nb_inputs;
i++)
745 pl_tex_destroy(
s->gpu, &
s->tex[
i]);
746 for (
int i = 0;
i <
s->num_hooks;
i++)
747 pl_mpv_user_shader_destroy(&
s->hooks[
i]);
749 for (
int i = 0;
i <
s->nb_inputs;
i++)
755 pl_vulkan_destroy(&
s->vulkan);
756 pl_log_destroy(&
s->log);
771 const char *
arg,
char *res,
int res_len,
785 for (
int i = 0;
i <
mix->num_frames;
i++) {
786 if (
i+1 ==
mix->num_frames ||
mix->timestamps[
i+1] > 0)
793 struct pl_frame *target,
double target_pts)
798 for (
int i = 0;
i < in->
mix.num_frames;
i++) {
801 struct pl_frame *image = (
struct pl_frame *) in->
mix.frames[
i];
814 s->var_values[
VAR_N] =
ctx->outputs[0]->frame_count_out;
838 image->crop.x1 = image->crop.x0 +
s->var_values[
VAR_CROP_W];
839 image->crop.y1 = image->crop.y0 +
s->var_values[
VAR_CROP_H];
845 target->crop.x1 = target->crop.x0 +
s->var_values[
VAR_POS_W];
846 target->crop.y1 = target->crop.y0 +
s->var_values[
VAR_POS_H];
847 if (
s->normalize_sar) {
848 float aspect = pl_rect2df_aspect(&image->crop);
850 pl_rect2df_aspect_set(&target->crop, aspect,
s->pad_crop_ratio);
859 int err = 0, ok, changed_csp;
861 pl_options
opts =
s->opts;
864 struct pl_frame target;
869 for (
int i = 0;
i <
s->nb_inputs;
i++) {
883 out->width = outlink->
w;
884 out->height = outlink->
h;
896 if (
s->colorspace >= 0)
897 out->colorspace =
s->colorspace;
898 if (
s->color_range >= 0)
899 out->color_range =
s->color_range;
900 if (
s->color_trc >= 0)
901 out->color_trc =
s->color_trc;
902 if (
s->color_primaries >= 0)
903 out->color_primaries =
s->color_primaries;
912 changed_csp =
ref->colorspace !=
out->colorspace ||
913 ref->color_range !=
out->color_range ||
914 ref->color_trc !=
out->color_trc ||
915 ref->color_primaries !=
out->color_primaries;
923 if (
s->apply_dovi || changed_csp) {
927 if (
s->apply_filmgrain)
932 ok = pl_map_avframe_ex(
s->gpu, &target, pl_avframe_params(
937 ok = pl_frame_recreate_from_avframe(
s->gpu, &target,
s->tex,
out);
945 opts->params.skip_target_clearing =
false;
947 for (
int i = 0;
i <
s->nb_inputs;
i++) {
950 if (in->
qstatus != PL_QUEUE_OK)
952 opts->params.skip_caching_single_frame = high_fps;
955 opts->params.skip_target_clearing =
true;
956 opts->params.blend_params = &pl_alpha_overlay;
960 pl_unmap_avframe(
s->gpu, &target);
961 }
else if (!pl_download_avframe(
s->gpu, &target,
out)) {
973 const struct pl_source_frame *
src,
974 struct pl_frame *
out)
978 bool ok = pl_map_avframe_ex(gpu,
out, pl_avframe_params(
981 .map_dovi =
s->apply_dovi,
984 if (!
s->apply_filmgrain)
985 out->film_grain.type = PL_FILM_GRAIN_NONE;
992 const struct pl_source_frame *
src)
994 pl_unmap_avframe(gpu,
frame);
1013 pl_queue_push(
input->queue, &(
struct pl_source_frame) {
1014 .pts = in->pts * av_q2d(input->link->time_base),
1015 .duration = in->duration * av_q2d(input->link->time_base),
1016 .first_field = pl_field_from_avframe(in),
1019 .unmap = unmap_frame,
1020 .discard = discard_frame,
1039 if (!
s->status ||
pts >=
s->status_pts) {
1042 s->status_pts =
pts;
1058 int ret, ok = 0, retry = 0;
1061 int64_t
pts, out_pts;
1066 for (
int i = 0;
i <
s->nb_inputs;
i++) {
1076 out_pts = INT64_MAX;
1077 for (
int i = 0;
i <
s->nb_inputs;
i++) {
1081 }
else if (!in->
status) {
1092 for (
int i = 0;
i <
s->nb_inputs;
i++) {
1101 .radius = pl_frame_mix_radius(&
s->opts->params),
1122 for (
int i = 0;
i <
s->nb_inputs;
i++)
1125 }
else if (
s->status) {
1144 if (
ctx->hw_device_ctx) {
1147 vkhwctx = avhwctx->
hwctx;
1155 #if PL_API_VER < 232
1163 if (!vkhwctx || vkhwctx->
act_dev !=
s->vulkan->device)
1167 if (!pl_test_pixfmt(
s->gpu,
pixfmt))
1180 }
else if (
pixfmt ==
s->out_format) {
1187 #if PL_API_VER >= 293
1188 if (!pl_test_pixfmt_caps(
s->gpu,
pixfmt, PL_FMT_CAP_RENDERABLE))
1195 if (!infmts || !outfmts) {
1196 if (
s->out_format) {
1204 for (
int i = 0;
i <
s->nb_inputs;
i++)
1212 if (outfmts && !outfmts->refcount)
1226 s->vkctx.input_format =
inlink->format;
1249 &outlink->
w, &outlink->
h));
1252 s->force_original_aspect_ratio,
1253 s->force_divisible_by);
1255 if (
s->normalize_sar ||
s->nb_inputs > 1) {
1262 if (
inlink->sample_aspect_ratio.num)
1273 for (
int i = 1;
i <
s->nb_inputs;
i++) {
1295 s->vkctx.output_width = outlink->
w;
1296 s->vkctx.output_height = outlink->
h;
1299 s->vkctx.output_format =
s->vkctx.input_format;
1301 s->vkctx.output_format =
s->out_format;
1306 vkfc->
usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
1314 #define OFFSET(x) offsetof(LibplaceboContext, x)
1315 #define STATIC (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
1316 #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM)
1332 {
"force_original_aspect_ratio",
"decrease or increase w/h if necessary to keep the original AR",
OFFSET(force_original_aspect_ratio),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2,
STATIC,
"force_oar" },
1336 {
"force_divisible_by",
"enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used",
OFFSET(force_divisible_by),
AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256,
STATIC },
1337 {
"normalize_sar",
"force SAR normalization to 1:1 by adjusting pos_x/y/w/h",
OFFSET(normalize_sar),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
STATIC },
1338 {
"pad_crop_ratio",
"ratio between padding and cropping when normalizing SAR (0=pad, 1=crop)",
OFFSET(pad_crop_ratio),
AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, 1.0,
DYNAMIC },
1341 {
"extra_opts",
"Pass extra libplacebo-specific options using a :-separated list of key=value pairs",
OFFSET(extra_opts),
AV_OPT_TYPE_DICT, .flags =
DYNAMIC },
1344 {
"auto",
"keep the same colorspace", 0,
AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX,
STATIC,
"colorspace"},
1368 {
"auto",
"keep the same color primaries", 0,
AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX,
STATIC,
"color_primaries"},
1384 {
"auto",
"keep the same color transfer", 0,
AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX,
STATIC,
"color_trc"},
1441 #if PL_API_VER >= 246
1453 {
"tonemapping_param",
"Tunable parameter for some tone-mapping functions",
OFFSET(tonemapping_param),
AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 100.0, .flags =
DYNAMIC },
1454 {
"inverse_tonemapping",
"Inverse tone mapping (range expansion)",
OFFSET(inverse_tonemapping),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
DYNAMIC },
1457 {
"contrast_smoothness",
"HDR contrast recovery smoothness",
OFFSET(contrast_smoothness),
AV_OPT_TYPE_FLOAT, {.dbl = 3.50}, 1.0, 32.0,
DYNAMIC },
1459 #if FF_API_LIBPLACEBO_OPTS
1467 {
"relative",
"Relative colorimetric", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_RELATIVE_COLORIMETRIC}, 0, 0,
STATIC,
"intent" },
1468 {
"absolute",
"Absolute colorimetric", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_ABSOLUTE_COLORIMETRIC}, 0, 0,
STATIC,
"intent" },
1469 {
"saturation",
"Saturation mapping", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_INTENT_SATURATION}, 0, 0,
STATIC,
"intent" },
1481 {
"dithering",
"Dither method to use",
OFFSET(dithering),
AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1,
DYNAMIC,
"dither" },
1485 {
"ordered_fixed",
"Fixed function ordered", 0,
AV_OPT_TYPE_CONST, {.i64 = PL_DITHER_ORDERED_FIXED}, 0, 0,
STATIC,
"dither" },
1504 #if FF_API_LIBPLACEBO_OPTS
1523 .
name =
"libplacebo",
1532 .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.
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)
static int libplacebo_query_format(AVFilterContext *ctx)
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
static int input_init(AVFilterContext *avctx, AVFilterLink *link, LibplaceboInput *input, int idx)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
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
@ 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 the instance-provided 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.
#define FILTER_QUERY_FUNC(func)
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
@ AV_FRAME_DATA_DOVI_RPU_BUFFER
Dolby Vision RPU raw data, suitable for passing to x265 or other libraries.
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.
#define FF_API_LIBPLACEBO_OPTS
FF_API_* defines may be placed below to indicate public API that will be dropped at a future version ...
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)
@ 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
offset must point to a pointer immediately followed by an int for the length
@ 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)
@ AV_ROUND_UP
Round toward +infinity.
#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
@ 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
int(* init)(AVBSFContext *ctx)
static void libplacebo_uninit(AVFilterContext *avctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
#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
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
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
@ 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.
AVFilterLink ** inputs
array of pointers to input links
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
int ff_vk_filter_config_output(AVFilterLink *outlink)
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
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
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)
@ AVCOL_PRI_BT2020
ITU-R BT2020.
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.
#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
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
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
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)
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
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.
@ 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)
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
#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.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
#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)
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.
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[]
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)
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.
#define FILTER_OUTPUTS(array)
static AVRational max_q(AVRational a, AVRational b)
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.
static av_cold int uninit(AVCodecContext *avctx)
#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
VkPhysicalDeviceFeatures2 device_features
This structure should be set to the set of features that present and enabled during device creation.
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
@ AVCOL_SPC_ICTCP
ITU-R BT.2100-0, ICtCp.
const struct pl_hook * hooks[2]
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.
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.
static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str)
#define AV_OPT_FLAG_DEPRECATED
set if option is deprecated, users should refer to AVOption.help text for more information