diff options
author | Jiyong <jiyong.min@samsung.com> | 2023-12-26 10:55:00 +0900 |
---|---|---|
committer | Jiyong <jiyong.min@samsung.com> | 2023-12-26 11:08:07 +0900 |
commit | 3b773d382e34fcfc7c8995d8bd681a6ef0529b02 (patch) | |
tree | 2dd316dd1fb388662a34065d3e15b2298384fbfe /lib/jxl/image.cc | |
parent | 7fa2aaed0a5c855460b77fb1fedcc01591ff6470 (diff) | |
download | libjxl-3b773d382e34fcfc7c8995d8bd681a6ef0529b02.tar.gz libjxl-3b773d382e34fcfc7c8995d8bd681a6ef0529b02.tar.bz2 libjxl-3b773d382e34fcfc7c8995d8bd681a6ef0529b02.zip |
Imported Upstream version 0.9.0upstream/0.9.0upstream
Change-Id: I60862786d19d92bb65425923bfeaa8ec236d8722
Diffstat (limited to 'lib/jxl/image.cc')
-rw-r--r-- | lib/jxl/image.cc | 72 |
1 files changed, 15 insertions, 57 deletions
diff --git a/lib/jxl/image.cc b/lib/jxl/image.cc index 34b315d..382c957 100644 --- a/lib/jxl/image.cc +++ b/lib/jxl/image.cc @@ -12,8 +12,8 @@ #include <hwy/foreach_target.h> #include <hwy/highway.h> -#include "lib/jxl/base/profiler.h" -#include "lib/jxl/common.h" +#include "lib/jxl/base/common.h" +#include "lib/jxl/frame_dimensions.h" #include "lib/jxl/image_ops.h" #include "lib/jxl/sanitizers.h" @@ -34,11 +34,6 @@ namespace { HWY_EXPORT(GetVectorSize); // Local function. -size_t VectorSize() { - static size_t bytes = HWY_DYNAMIC_DISPATCH(GetVectorSize)(); - return bytes; -} - // Returns distance [bytes] between the start of two consecutive rows, a // multiple of vector/cache line size but NOT CacheAligned::kAlias - see below. size_t BytesPerRow(const size_t xsize, const size_t sizeof_t) { @@ -71,15 +66,17 @@ size_t BytesPerRow(const size_t xsize, const size_t sizeof_t) { } // namespace +size_t VectorSize() { + static size_t bytes = HWY_DYNAMIC_DISPATCH(GetVectorSize)(); + return bytes; +} + PlaneBase::PlaneBase(const size_t xsize, const size_t ysize, const size_t sizeof_t) : xsize_(static_cast<uint32_t>(xsize)), ysize_(static_cast<uint32_t>(ysize)), orig_xsize_(static_cast<uint32_t>(xsize)), orig_ysize_(static_cast<uint32_t>(ysize)) { - // (Can't profile CacheAligned itself because it is used by profiler.h) - PROFILER_FUNC; - JXL_CHECK(xsize == xsize_); JXL_CHECK(ysize == ysize_); @@ -111,7 +108,10 @@ void PlaneBase::InitializePadding(const size_t sizeof_t, Padding padding) { for (size_t y = 0; y < ysize_; ++y) { uint8_t* JXL_RESTRICT row = static_cast<uint8_t*>(VoidRow(y)); -#if defined(__clang__) && (__clang_major__ <= 6) +#if defined(__clang__) && \ + ((!defined(__apple_build_version__) && __clang_major__ <= 6) || \ + (defined(__apple_build_version__) && \ + __apple_build_version__ <= 10001145)) // There's a bug in msan in clang-6 when handling AVX2 operations. This // workaround allows tests to pass on msan, although it is slower and // prevents msan warnings from uninitialized images. @@ -133,54 +133,12 @@ void PlaneBase::Swap(PlaneBase& other) { std::swap(bytes_, other.bytes_); } -Image3F PadImageMirror(const Image3F& in, const size_t xborder, - const size_t yborder) { - size_t xsize = in.xsize(); - size_t ysize = in.ysize(); - Image3F out(xsize + 2 * xborder, ysize + 2 * yborder); - if (xborder > xsize || yborder > ysize) { - for (size_t c = 0; c < 3; c++) { - for (int32_t y = 0; y < static_cast<int32_t>(out.ysize()); y++) { - float* row_out = out.PlaneRow(c, y); - const float* row_in = in.PlaneRow( - c, Mirror(y - static_cast<int32_t>(yborder), in.ysize())); - for (int32_t x = 0; x < static_cast<int32_t>(out.xsize()); x++) { - int32_t xin = Mirror(x - static_cast<int32_t>(xborder), in.xsize()); - row_out[x] = row_in[xin]; - } - } - } - return out; - } - CopyImageTo(in, Rect(xborder, yborder, xsize, ysize), &out); - for (size_t c = 0; c < 3; c++) { - // Horizontal pad. - for (size_t y = 0; y < ysize; y++) { - for (size_t x = 0; x < xborder; x++) { - out.PlaneRow(c, y + yborder)[x] = - in.ConstPlaneRow(c, y)[xborder - x - 1]; - out.PlaneRow(c, y + yborder)[x + xsize + xborder] = - in.ConstPlaneRow(c, y)[xsize - 1 - x]; - } - } - // Vertical pad. - for (size_t y = 0; y < yborder; y++) { - memcpy(out.PlaneRow(c, y), out.ConstPlaneRow(c, 2 * yborder - 1 - y), - out.xsize() * sizeof(float)); - memcpy(out.PlaneRow(c, y + ysize + yborder), - out.ConstPlaneRow(c, ysize + yborder - 1 - y), - out.xsize() * sizeof(float)); - } - } - return out; -} - -void PadImageToBlockMultipleInPlace(Image3F* JXL_RESTRICT in) { - PROFILER_FUNC; +void PadImageToBlockMultipleInPlace(Image3F* JXL_RESTRICT in, + size_t block_dim) { const size_t xsize_orig = in->xsize(); const size_t ysize_orig = in->ysize(); - const size_t xsize = RoundUpToBlockDim(xsize_orig); - const size_t ysize = RoundUpToBlockDim(ysize_orig); + const size_t xsize = RoundUpTo(xsize_orig, block_dim); + const size_t ysize = RoundUpTo(ysize_orig, block_dim); // Expands image size to the originally-allocated size. in->ShrinkTo(xsize, ysize); for (size_t c = 0; c < 3; c++) { |