diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2018-07-25 16:44:50 +0200 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2018-08-06 18:35:52 +0200 |
commit | e467179cfbe270c4b59b10f859b6925668d59583 (patch) | |
tree | 0966e8ab8d44bdbe65e15dc83f6ce1361d587f5b /libavfilter/colorspace.c | |
parent | ce7ca726b2cae0eeb4a4e688c5c7d0ea05776832 (diff) | |
download | ffmpeg-e467179cfbe270c4b59b10f859b6925668d59583.tar.gz |
vf_tonemap[_opencl]: Move determine_signal_peak() to a shared file
The two functions are identical. Use the shared LumaCoeffients type too.
Diffstat (limited to 'libavfilter/colorspace.c')
-rw-r--r-- | libavfilter/colorspace.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c index 45da1dd124..d6f6055401 100644 --- a/libavfilter/colorspace.c +++ b/libavfilter/colorspace.c @@ -17,6 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/frame.h" +#include "libavutil/mastering_display_metadata.h" +#include "libavutil/pixdesc.h" + #include "colorspace.h" @@ -89,3 +93,28 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs, rgb2xyz[2][1] *= sg; rgb2xyz[2][2] *= sb; } + +double ff_determine_signal_peak(AVFrame *in) +{ + AVFrameSideData *sd = av_frame_get_side_data(in, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); + double peak = 0; + + if (sd) { + AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data; + peak = clm->MaxCLL / REFERENCE_WHITE; + } + + sd = av_frame_get_side_data(in, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + if (!peak && sd) { + AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data; + if (metadata->has_luminance) + peak = av_q2d(metadata->max_luminance) / REFERENCE_WHITE; + } + + // For untagged source, use peak of 10000 if SMPTE ST.2084 + // otherwise assume HLG with reference display peak 1000. + if (!peak) + peak = in->color_trc == AVCOL_TRC_SMPTE2084 ? 100.0f : 10.0f; + + return peak; +} |