Commit 62dfa2ba authored by Vittorio Giovara's avatar Vittorio Giovara

Add tonemap filter

Based off mpv automatic tonemapping capabilities.
Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent 8b9ae9a8
......@@ -14442,6 +14442,113 @@ Vertical low-pass filtering can only be enabled for @option{mode}
@end table
@section tonemap
Tone map colors from different dynamic ranges.
This filter expects data in single precision floating point, as it needs to
operate on (and can output) out-of-range values. Another filter, such as
@ref{zscale}, is needed to convert the resulting frame to a usable format.
The tonemapping algorithms implemented only work on linear light, so input
data should be linearized beforehand (and possibly correctly tagged).
@example
ffmpeg -i INPUT -vf zscale=transfer=linear,tonemap=clip,zscale=transfer=bt709,format=yuv420p OUTPUT
@end example
@subsection Options
The filter accepts the following options.
@table @option
@item tonemap
Set the tone map algorithm to use.
Possible values are:
@table @var
@item none
Do not apply any tone map, only desaturate overbright pixels.
@item clip
Hard-clip any out-of-range values. Use it for perfect color accuracy for
in-range values, while distorting out-of-range values.
@item linear
Stretch the entire reference gamut to a linear multiple of the display.
@item gamma
Fit a logarithmic transfer between the tone curves.
@item reinhard
Preserve overall image brightness with a simple curve, using nonlinear
contrast, which results in flattening details and degrading color accuracy.
@item hable
Peserve both dark and bright details better than @var{reinhard}, at the cost
of slightly darkening everything. Use it when detail preservation is more
important than color and brightness accuracy.
@item mobius
Smoothly map out-of-range values, while retaining contrast and colors for
in-range material as much as possible. Use it when color accuracy is more
important than detail preservation.
@end table
Default is none.
@item param
Tune the tone mapping algorithm.
This affects the following algorithms:
@table @var
@item none
Ignored.
@item linear
Specifies the scale factor to use while stretching.
Default to 1.0.
@item gamma
Specifies the exponent of the function.
Default to 1.8.
@item clip
Specify an extra linear coefficient to multiply into the signal before clipping.
Default to 1.0.
@item reinhard
Specify the local contrast coefficient at the display peak.
Default to 0.5, which means that in-gamut values will be about half as bright
as when clipping.
@item hable
Ignored.
@item mobius
Specify the transition point from linear to mobius transform. Every value
below this point is guaranteed to be mapped 1:1. The higher the value, the
more accurate the result will be, at the cost of losing bright details.
Default to 0.3, which due to the steep initial slope still preserves in-range
colors fairly accurately.
@end table
@item desat
Apply desaturation for highlights that exceed this level of brightness. The
higher the parameter, the more color information will be preserved. This
setting helps prevent unnaturally blown-out colors for super-highlights, by
(smoothly) turning into white instead. This makes images feel more natural,
at the cost of reducing information about out-of-range colors.
The default of 2.0 is somewhat conservative and will mostly just apply to
skies or directly sunlit surfaces. A setting of 0.0 disables this option.
This option works only if the input frame has a supported color tag.
@item peak
Override signal/nominal/reference peak with this value. Useful when the
embedded peak information in display metadata is not reliable or when tone
mapping from a lower range to a higher range.
@end table
@section transpose
Transpose rows with columns in the input video and optionally flip it.
......@@ -15627,6 +15734,7 @@ zoompan=z='min(max(zoom,pzoom)+0.0015,1.5)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2-(ih
@end example
@end itemize
@anchor{zscale}
@section zscale
Scale (resize) the input video, using the z.lib library:
https://github.com/sekrit-twc/zimg.
......
......@@ -314,6 +314,7 @@ OBJS-$(CONFIG_THUMBNAIL_FILTER) += vf_thumbnail.o
OBJS-$(CONFIG_TILE_FILTER) += vf_tile.o
OBJS-$(CONFIG_TINTERLACE_FILTER) += vf_tinterlace.o
OBJS-$(CONFIG_TLUT2_FILTER) += vf_lut2.o framesync2.o
OBJS-$(CONFIG_TONEMAP_FILTER) += vf_tonemap.o
OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o
OBJS-$(CONFIG_TRIM_FILTER) += trim.o
OBJS-$(CONFIG_UNPREMULTIPLY_FILTER) += vf_premultiply.o framesync2.o
......
......@@ -325,6 +325,7 @@ static void register_all(void)
REGISTER_FILTER(TILE, tile, vf);
REGISTER_FILTER(TINTERLACE, tinterlace, vf);
REGISTER_FILTER(TLUT2, tlut2, vf);
REGISTER_FILTER(TONEMAP, tonemap, vf);
REGISTER_FILTER(TRANSPOSE, transpose, vf);
REGISTER_FILTER(TRIM, trim, vf);
REGISTER_FILTER(UNPREMULTIPLY, unpremultiply, vf);
......
......@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFILTER_VERSION_MAJOR 6
#define LIBAVFILTER_VERSION_MINOR 98
#define LIBAVFILTER_VERSION_MINOR 99
#define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment