lavfi/vf_libplacebo: add extra_opts AVDictionary

Can be used to configure libplacebo's underlying raw options, which
sometimes includes new or advanced / in-depth settings not (yet) exposed
by vf_libplacebo.
This commit is contained in:
Niklas Haas 2023-08-18 18:48:43 +02:00
parent 816983d951
commit 3c9dc009b6
2 changed files with 23 additions and 0 deletions

View File

@ -16320,6 +16320,16 @@ Render frames with rounded corners. The value, given as a float ranging from
square to fully circular. In other words, it gives the radius divided by half square to fully circular. In other words, it gives the radius divided by half
the smaller side length. Defaults to @code{0.0}. the smaller side length. Defaults to @code{0.0}.
@item extra_opts
Pass extra libplacebo internal configuration options. These can be specified
as a list of @var{key}=@var{value} pairs separated by ':'. The following example
shows how to configure a custom filter kernel ("EWA LanczosSharp") and use it
to double the input image resolution:
@example
-vf "libplacebo=w=iw*2:h=ih*2:extra_opts='upscaler=custom\:upscaler_preset=ewa_lanczos\:upscaler_blur=0.9812505644269356'"
@end example
@item colorspace @item colorspace
@item color_primaries @item color_primaries
@item color_trc @item color_trc

View File

@ -192,6 +192,7 @@ typedef struct LibplaceboContext {
int color_range; int color_range;
int color_primaries; int color_primaries;
int color_trc; int color_trc;
AVDictionary *extra_opts;
/* pl_render_params */ /* pl_render_params */
pl_options opts; pl_options opts;
@ -376,6 +377,7 @@ static int update_settings(AVFilterContext *ctx)
{ {
int err = 0; int err = 0;
LibplaceboContext *s = ctx->priv; LibplaceboContext *s = ctx->priv;
AVDictionaryEntry *e = NULL;
pl_options opts = s->opts; pl_options opts = s->opts;
int gamut_mode = s->gamut_mode; int gamut_mode = s->gamut_mode;
uint8_t color_rgba[4]; uint8_t color_rgba[4];
@ -505,6 +507,16 @@ static int update_settings(AVFilterContext *ctx)
RET(find_scaler(ctx, &opts->params.upscaler, s->upscaler, 0)); RET(find_scaler(ctx, &opts->params.upscaler, s->upscaler, 0));
RET(find_scaler(ctx, &opts->params.downscaler, s->downscaler, 0)); RET(find_scaler(ctx, &opts->params.downscaler, s->downscaler, 0));
RET(find_scaler(ctx, &opts->params.frame_mixer, s->frame_mixer, 1)); RET(find_scaler(ctx, &opts->params.frame_mixer, s->frame_mixer, 1));
#if PL_API_VER >= 309
while ((e = av_dict_get(s->extra_opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
if (!pl_options_set_str(s->opts, e->key, e->value)) {
err = AVERROR(EINVAL);
goto fail;
}
}
#endif
return 0; return 0;
fail: fail:
@ -1322,6 +1334,7 @@ static const AVOption libplacebo_options[] = {
{ "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 }, { "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 },
{ "fillcolor", "Background fill color", OFFSET(fillcolor), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC }, { "fillcolor", "Background fill color", OFFSET(fillcolor), AV_OPT_TYPE_STRING, {.str = "black"}, .flags = DYNAMIC },
{ "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC }, { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC },
{ "extra_opts", "Pass extra libplacebo-specific options using a :-separated list of key=value pairs", OFFSET(extra_opts), AV_OPT_TYPE_DICT, .flags = DYNAMIC },
{"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"}, {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
{"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"}, {"auto", "keep the same colorspace", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, STATIC, "colorspace"},