diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/jpeg-xl/lib/jxl/image_ops_test.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/jpeg-xl/lib/jxl/image_ops_test.cc')
-rw-r--r-- | third_party/jpeg-xl/lib/jxl/image_ops_test.cc | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/third_party/jpeg-xl/lib/jxl/image_ops_test.cc b/third_party/jpeg-xl/lib/jxl/image_ops_test.cc index dfcb2292c5..6b308baab4 100644 --- a/third_party/jpeg-xl/lib/jxl/image_ops_test.cc +++ b/third_party/jpeg-xl/lib/jxl/image_ops_test.cc @@ -8,43 +8,19 @@ #include <stdint.h> #include <stdlib.h> -#include <utility> +#include <cstring> +#include "lib/jxl/base/compiler_specific.h" #include "lib/jxl/base/printf_macros.h" +#include "lib/jxl/base/random.h" +#include "lib/jxl/base/status.h" +#include "lib/jxl/cache_aligned.h" #include "lib/jxl/image.h" -#include "lib/jxl/image_test_utils.h" #include "lib/jxl/testing.h" namespace jxl { namespace { -template <typename T> -void TestPacked(const size_t xsize, const size_t ysize) { - Plane<T> image1(xsize, ysize); - RandomFillImage(&image1); - const std::vector<T>& packed = PackedFromImage(image1); - const Plane<T>& image2 = ImageFromPacked(packed, xsize, ysize); - JXL_EXPECT_OK(SamePixels(image1, image2, _)); -} - -TEST(ImageTest, TestPacked) { - TestPacked<uint8_t>(1, 1); - TestPacked<uint8_t>(7, 1); - TestPacked<uint8_t>(1, 7); - - TestPacked<int16_t>(1, 1); - TestPacked<int16_t>(7, 1); - TestPacked<int16_t>(1, 7); - - TestPacked<uint16_t>(1, 1); - TestPacked<uint16_t>(7, 1); - TestPacked<uint16_t>(1, 7); - - TestPacked<float>(1, 1); - TestPacked<float>(7, 1); - TestPacked<float>(1, 7); -} - // Ensure entire payload is readable/writable for various size/offset combos. TEST(ImageTest, TestAllocator) { Rng rng(0); @@ -70,18 +46,18 @@ TEST(ImageTest, TestAllocator) { template <typename T> void TestFillImpl(Image3<T>* img, const char* layout) { - FillImage(T(1), img); + FillImage(static_cast<T>(1), img); for (size_t y = 0; y < img->ysize(); ++y) { for (size_t c = 0; c < 3; ++c) { T* JXL_RESTRICT row = img->PlaneRow(c, y); for (size_t x = 0; x < img->xsize(); ++x) { - if (row[x] != T(1)) { + if (row[x] != static_cast<T>(1)) { printf("Not 1 at c=%" PRIuS " %" PRIuS ", %" PRIuS " (%" PRIuS " x %" PRIuS ") (%s)\n", c, x, y, img->xsize(), img->ysize(), layout); abort(); } - row[x] = T(2); + row[x] = static_cast<T>(2); } } } @@ -92,13 +68,13 @@ void TestFillImpl(Image3<T>* img, const char* layout) { for (size_t y = 0; y < img->ysize(); ++y) { T* JXL_RESTRICT row = img->PlaneRow(c, y); for (size_t x = 0; x < img->xsize(); ++x) { - if (row[x] != T(0)) { + if (row[x] != static_cast<T>(0)) { printf("Not 0 at c=%" PRIuS " %" PRIuS ", %" PRIuS " (%" PRIuS " x %" PRIuS ") (%s)\n", c, x, y, img->xsize(), img->ysize(), layout); abort(); } - row[x] = T(3); + row[x] = static_cast<T>(3); } } } @@ -108,12 +84,8 @@ template <typename T> void TestFillT() { for (uint32_t xsize : {0, 1, 15, 16, 31, 32}) { for (uint32_t ysize : {0, 1, 15, 16, 31, 32}) { - Image3<T> image(xsize, ysize); + JXL_ASSIGN_OR_DIE(Image3<T> image, Image3<T>::Create(xsize, ysize)); TestFillImpl(&image, "size ctor"); - - Image3<T> planar(Plane<T>(xsize, ysize), Plane<T>(xsize, ysize), - Plane<T>(xsize, ysize)); - TestFillImpl(&planar, "planar"); } } } @@ -127,7 +99,7 @@ TEST(ImageTest, TestFill) { } TEST(ImageTest, CopyImageToWithPaddingTest) { - Plane<uint32_t> src(100, 61); + JXL_ASSIGN_OR_DIE(Plane<uint32_t> src, Plane<uint32_t>::Create(100, 61)); for (size_t y = 0; y < src.ysize(); y++) { for (size_t x = 0; x < src.xsize(); x++) { src.Row(y)[x] = x * 1000 + y; @@ -136,7 +108,7 @@ TEST(ImageTest, CopyImageToWithPaddingTest) { Rect src_rect(10, 20, 30, 40); EXPECT_TRUE(src_rect.IsInside(src)); - Plane<uint32_t> dst(60, 50); + JXL_ASSIGN_OR_DIE(Plane<uint32_t> dst, Plane<uint32_t>::Create(60, 50)); FillImage(0u, &dst); Rect dst_rect(20, 5, 30, 40); EXPECT_TRUE(dst_rect.IsInside(dst)); |