summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc')
-rw-r--r--third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc b/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc
new file mode 100644
index 0000000000..f1d5357345
--- /dev/null
+++ b/third_party/jpeg-xl/lib/extras/tone_mapping_gbench.cc
@@ -0,0 +1,40 @@
+// 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.
+
+#include "benchmark/benchmark.h"
+#include "lib/extras/codec.h"
+#include "lib/extras/tone_mapping.h"
+#include "lib/jxl/enc_color_management.h"
+
+namespace jxl {
+
+static void BM_ToneMapping(benchmark::State& state) {
+ Image3F color(2268, 1512);
+ FillImage(0.5f, &color);
+
+ // Use linear Rec. 2020 so that `ToneMapTo` doesn't have to convert to it and
+ // we mainly measure the tone mapping itself.
+ ColorEncoding linear_rec2020;
+ linear_rec2020.SetColorSpace(ColorSpace::kRGB);
+ linear_rec2020.primaries = Primaries::k2100;
+ linear_rec2020.white_point = WhitePoint::kD65;
+ linear_rec2020.tf.SetTransferFunction(TransferFunction::kLinear);
+ JXL_CHECK(linear_rec2020.CreateICC());
+
+ for (auto _ : state) {
+ state.PauseTiming();
+ CodecInOut tone_mapping_input;
+ tone_mapping_input.SetFromImage(CopyImage(color), linear_rec2020);
+ tone_mapping_input.metadata.m.SetIntensityTarget(255);
+ state.ResumeTiming();
+
+ JXL_CHECK(ToneMapTo({0.1, 100}, &tone_mapping_input));
+ }
+
+ state.SetItemsProcessed(state.iterations() * color.xsize() * color.ysize());
+}
+BENCHMARK(BM_ToneMapping);
+
+} // namespace jxl