diff options
author | Niklas Haas <git@haasn.dev> | 2023-07-08 12:54:49 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2023-07-08 12:54:49 +0200 |
commit | 13e989901468b2e53a7d3a099511aae6987c7b00 (patch) | |
tree | 164ffa66993307057ac9fc57cb29c027335806cd | |
parent | 2e83ba001d79e1b543f6c0e408ae17da4ca5251a (diff) | |
download | ffmpeg-13e989901468b2e53a7d3a099511aae6987c7b00.tar.gz |
lavfi/vf_libplacebo: add contrast recovery options
New upstream option. Enabled by default in the high-quality preset
upstream, so enable it by default here.
-rw-r--r-- | doc/filters.texi | 13 | ||||
-rw-r--r-- | libavfilter/vf_libplacebo.c | 8 |
2 files changed, 21 insertions, 0 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 95b04cea1a..54cc5ba820 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16664,6 +16664,19 @@ output color volumes. Disabled by default. Size of the tone-mapping LUT, between @code{2} and @code{1024}. Defaults to @code{256}. Note that this figure is squared when combined with @code{peak_detect}. + +@item contrast_recovery +Contrast recovery strength. If set to a value above @code{0.0}, the source +image will be divided into high-frequency and low-frequency components, and a +portion of the high-frequency image is added back onto the tone-mapped output. +May cause excessive ringing artifacts for some HDR sources, but can improve the +subjective sharpness and detail left over in the image after tone-mapping. +Defaults to @code{0.30}. + +@item contrast_smoothness +Contrast recovery lowpass kernel size. Defaults to @code{3.5}. Increasing or +decreasing this will affect the visual appearance substantially. Has no effect +when @code{contrast_recovery} is disabled. @end table @subsubsection Dithering diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 10a79ac950..031265b637 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -219,6 +219,8 @@ typedef struct LibplaceboContext { float tonemapping_param; int inverse_tonemapping; int tonemapping_lut_size; + float contrast_recovery; + float contrast_smoothness; #if FF_API_LIBPLACEBO_OPTS /* for backwards compatibility */ @@ -431,6 +433,10 @@ static int update_settings(AVFilterContext *ctx) .tone_mapping_param = s->tonemapping_param, .inverse_tone_mapping = s->inverse_tonemapping, .lut_size = s->tonemapping_lut_size, +#if PL_API_VER >= 285 + .contrast_recovery = s->contrast_recovery, + .contrast_smoothness = s->contrast_smoothness, +#endif ); set_gamut_mode(&s->color_map_params, gamut_mode); @@ -1398,6 +1404,8 @@ static const AVOption libplacebo_options[] = { { "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 }, { "inverse_tonemapping", "Inverse tone mapping (range expansion)", OFFSET(inverse_tonemapping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, { "tonemapping_lut_size", "Tone-mapping LUT size", OFFSET(tonemapping_lut_size), AV_OPT_TYPE_INT, {.i64 = 256}, 2, 1024, DYNAMIC }, + { "contrast_recovery", "HDR contrast recovery strength", OFFSET(contrast_recovery), AV_OPT_TYPE_FLOAT, {.dbl = 0.30}, 0.0, 3.0, DYNAMIC }, + { "contrast_smoothness", "HDR contrast recovery smoothness", OFFSET(contrast_smoothness), AV_OPT_TYPE_FLOAT, {.dbl = 3.50}, 1.0, 32.0, DYNAMIC }, #if FF_API_LIBPLACEBO_OPTS /* deprecated options for backwards compatibility, defaulting to -1 to not override the new defaults */ |