summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc')
-rw-r--r--third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
new file mode 100644
index 0000000000..088253c2ce
--- /dev/null
+++ b/third_party/jpeg-xl/lib/jxl/opsin_inverse_test.cc
@@ -0,0 +1,57 @@
+// 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 "lib/jxl/base/data_parallel.h"
+#include "lib/jxl/codec_in_out.h"
+#include "lib/jxl/color_encoding_internal.h"
+#include "lib/jxl/color_management.h"
+#include "lib/jxl/dec_xyb.h"
+#include "lib/jxl/enc_color_management.h"
+#include "lib/jxl/enc_xyb.h"
+#include "lib/jxl/image.h"
+#include "lib/jxl/image_bundle.h"
+#include "lib/jxl/image_test_utils.h"
+#include "lib/jxl/testing.h"
+
+namespace jxl {
+namespace {
+
+TEST(OpsinInverseTest, LinearInverseInverts) {
+ Image3F linear(128, 128);
+ RandomFillImage(&linear, 0.0f, 1.0f);
+
+ CodecInOut io;
+ io.metadata.m.SetFloat32Samples();
+ io.metadata.m.color_encoding = ColorEncoding::LinearSRGB();
+ io.SetFromImage(CopyImage(linear), io.metadata.m.color_encoding);
+ ThreadPool* null_pool = nullptr;
+ Image3F opsin(io.xsize(), io.ysize());
+ (void)ToXYB(io.Main(), null_pool, &opsin, GetJxlCms());
+
+ OpsinParams opsin_params;
+ opsin_params.Init(/*intensity_target=*/255.0f);
+ OpsinToLinearInplace(&opsin, /*pool=*/nullptr, opsin_params);
+
+ JXL_ASSERT_OK(VerifyRelativeError(linear, opsin, 3E-3, 2E-4, _));
+}
+
+TEST(OpsinInverseTest, YcbCrInverts) {
+ Image3F rgb(128, 128);
+ RandomFillImage(&rgb, 0.0f, 1.0f);
+
+ ThreadPool* null_pool = nullptr;
+ Image3F ycbcr(rgb.xsize(), rgb.ysize());
+ EXPECT_TRUE(RgbToYcbcr(rgb.Plane(0), rgb.Plane(1), rgb.Plane(2),
+ &ycbcr.Plane(1), &ycbcr.Plane(0), &ycbcr.Plane(2),
+ null_pool));
+
+ Image3F rgb2(rgb.xsize(), rgb.ysize());
+ YcbcrToRgb(ycbcr, &rgb2, Rect(rgb));
+
+ JXL_ASSERT_OK(VerifyRelativeError(rgb, rgb2, 4E-5, 4E-7, _));
+}
+
+} // namespace
+} // namespace jxl