summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/extras/tone_mapping.h
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/extras/tone_mapping.h')
-rw-r--r--third_party/jpeg-xl/lib/extras/tone_mapping.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/third_party/jpeg-xl/lib/extras/tone_mapping.h b/third_party/jpeg-xl/lib/extras/tone_mapping.h
new file mode 100644
index 0000000000..1f474101eb
--- /dev/null
+++ b/third_party/jpeg-xl/lib/extras/tone_mapping.h
@@ -0,0 +1,30 @@
+// Copyright (c) the JPEG XL Project Authors. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#ifndef LIB_EXTRAS_TONE_MAPPING_H_
+#define LIB_EXTRAS_TONE_MAPPING_H_
+
+#include "lib/jxl/codec_in_out.h"
+
+namespace jxl {
+
+// Important: after calling this, the result will contain many out-of-gamut
+// colors. It is very strongly recommended to call GamutMap afterwards to
+// rectify this.
+Status ToneMapTo(std::pair<float, float> display_nits, CodecInOut* io,
+ ThreadPool* pool = nullptr);
+
+// `preserve_saturation` indicates to what extent to favor saturation over
+// luminance when mapping out-of-gamut colors to Rec. 2020. 0 preserves
+// luminance at the complete expense of saturation, while 1 gives the most
+// saturated color with the same hue that Rec. 2020 can represent even if it
+// means lowering the luminance. Values in between correspond to linear mixtures
+// of those two extremes.
+Status GamutMap(CodecInOut* io, float preserve_saturation,
+ ThreadPool* pool = nullptr);
+
+} // namespace jxl
+
+#endif // LIB_EXTRAS_TONE_MAPPING_H_