From 6d57946e8f20a2294b96eca2e379d3e8e1c93384 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 25 Oct 2023 08:44:28 +0100 Subject: gentoo auto-resync : 25:10:2023 - 08:44:27 --- .../files/libaom-3.7.0-big-endian-tests.patch | 43 +++++++ .../libaom/files/libaom-3.7.0-big-endian.patch | 130 +++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 media-libs/libaom/files/libaom-3.7.0-big-endian-tests.patch create mode 100644 media-libs/libaom/files/libaom-3.7.0-big-endian.patch (limited to 'media-libs/libaom/files') diff --git a/media-libs/libaom/files/libaom-3.7.0-big-endian-tests.patch b/media-libs/libaom/files/libaom-3.7.0-big-endian-tests.patch new file mode 100644 index 000000000000..38559c564726 --- /dev/null +++ b/media-libs/libaom/files/libaom-3.7.0-big-endian-tests.patch @@ -0,0 +1,43 @@ +https://bugs.chromium.org/p/aomedia/issues/detail?id=3487 +https://aomedia.googlesource.com/aom/+/7029529477e1473e6eb7417538cea18edc5e3bd0 + +From 7029529477e1473e6eb7417538cea18edc5e3bd0 Mon Sep 17 00:00:00 2001 +From: Wan-Teh Chang +Date: Wed, 13 Sep 2023 10:55:05 -0700 +Subject: [PATCH] Fix big-endian bugs in CodingPathSync tests + +Change Serialize() to read uint16_t samples correctly. Although only the +least significant byte of each sample is nonzero, we cannot assume the +least significant byte of the c-th sample in `row` is row[c * 2]. That +is correct only on little-endian systems. + +Bug: aomedia:3487 +Change-Id: I9919ce6e3c877608ca7488fe4cc6957bcfe8c4cc +--- + test/coding_path_sync.cc | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/test/coding_path_sync.cc b/test/coding_path_sync.cc +index c3e51fd565..31bc2d56b0 100644 +--- a/test/coding_path_sync.cc ++++ b/test/coding_path_sync.cc +@@ -130,11 +130,13 @@ std::vector Serialize(const aom_image_t *img) { + + for (int r = 0; r < h; ++r) { + for (int c = 0; c < w; ++c) { +- unsigned char *row = img->planes[plane] + r * img->stride[plane]; +- if (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) +- bytes.push_back(row[c * 2]); +- else ++ const unsigned char *row = img->planes[plane] + r * img->stride[plane]; ++ if (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) { ++ const uint16_t *row16 = reinterpret_cast(row); ++ bytes.push_back(row16[c]); ++ } else { + bytes.push_back(row[c]); ++ } + } + } + } +-- +2.42.0 diff --git a/media-libs/libaom/files/libaom-3.7.0-big-endian.patch b/media-libs/libaom/files/libaom-3.7.0-big-endian.patch new file mode 100644 index 000000000000..907e5fd1110e --- /dev/null +++ b/media-libs/libaom/files/libaom-3.7.0-big-endian.patch @@ -0,0 +1,130 @@ +https://bugs.chromium.org/p/aomedia/issues/detail?id=3487 +https://aomedia.googlesource.com/aom/+/8b65d76f2f95b1bfdc82b8f135246cb367d444e6%5E%21/ + +From 8b65d76f2f95b1bfdc82b8f135246cb367d444e6 Mon Sep 17 00:00:00 2001 +From: Wan-Teh Chang +Date: Tue, 12 Sep 2023 16:38:47 -0700 +Subject: [PATCH] Fix byte order issue in write_enc_data_to_out_buf + +Fix the byte order issue for big-endian systems introduced in +https://aomedia-review.googlesource.com/c/aom/+/167581. + +Use the existing HToBE64 macro defined in aom_util/endian_inl.h and +delete the new get_byteswap64 function from aom_ports/bitops.h. + +Based on the patch in bug aomedia:3487. + +Bug: aomedia:3487 +Change-Id: I56183e062a9f2b18c4c6158fd8e47c5062de85ee +--- + aom_dsp/entenc.h | 7 ++++--- + aom_ports/bitops.h | 35 +---------------------------------- + 2 files changed, 5 insertions(+), 37 deletions(-) + +diff --git a/aom_dsp/entenc.h b/aom_dsp/entenc.h +index 467e47bf56..d26f027ed0 100644 +--- a/aom_dsp/entenc.h ++++ b/aom_dsp/entenc.h +@@ -13,7 +13,7 @@ + #define AOM_AOM_DSP_ENTENC_H_ + #include + #include "aom_dsp/entcode.h" +-#include "aom_ports/bitops.h" ++#include "aom_util/endian_inl.h" + + #ifdef __cplusplus + extern "C" { +@@ -87,13 +87,14 @@ static AOM_INLINE void propagate_carry_bwd(unsigned char *buf, uint32_t offs) { + } while (carry); + } + +-// Reverse byte order and write data to buffer adding the carry-bit ++// Convert to big-endian byte order and write data to buffer adding the ++// carry-bit + static AOM_INLINE void write_enc_data_to_out_buf(unsigned char *out, + uint32_t offs, uint64_t output, + uint64_t carry, + uint32_t *enc_offs, + uint8_t num_bytes_ready) { +- const uint64_t reg = get_byteswap64(output) >> ((8 - num_bytes_ready) << 3); ++ const uint64_t reg = HToBE64(output << ((8 - num_bytes_ready) << 3)); + memcpy(&out[offs], ®, 8); + // Propagate carry backwards if exists + if (carry) { +diff --git a/aom_ports/bitops.h b/aom_ports/bitops.h +index 3c5b992bde..7f4c165f5a 100644 +--- a/aom_ports/bitops.h ++++ b/aom_ports/bitops.h +@@ -13,7 +13,6 @@ + #define AOM_AOM_PORTS_BITOPS_H_ + + #include +-#include + + #include "aom_ports/msvc.h" + #include "config/aom_config.h" +@@ -34,12 +33,8 @@ extern "C" { + // These versions of get_msb() are only valid when n != 0 because all + // of the optimized versions are undefined when n == 0: + +-// get_byteswap64: +-// Returns the number (uint64_t) with byte-positions reversed +-// e.g. input 0x123456789ABCDEF0 returns 0xF0DEBC9A78563412 +- + // GCC compiler: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html +-// MSVC: https://learn.microsoft.com/en-us/cpp/c-runtime-library/ ++// MSVC: https://learn.microsoft.com/en-us/cpp/intrinsics/compiler-intrinsics + + // use GNU builtins where available. + #if defined(__GNUC__) && \ +@@ -48,10 +43,6 @@ static INLINE int get_msb(unsigned int n) { + assert(n != 0); + return 31 ^ __builtin_clz(n); + } +- +-static INLINE uint64_t get_byteswap64(uint64_t num) { +- return __builtin_bswap64(num); +-} + #elif defined(USE_MSC_INTRINSICS) + #pragma intrinsic(_BitScanReverse) + +@@ -61,10 +52,6 @@ static INLINE int get_msb(unsigned int n) { + _BitScanReverse(&first_set_bit, n); + return first_set_bit; + } +- +-static INLINE uint64_t get_byteswap64(uint64_t num) { +- return _byteswap_uint64(num); +-} + #undef USE_MSC_INTRINSICS + #else + static INLINE int get_msb(unsigned int n) { +@@ -82,26 +69,6 @@ static INLINE int get_msb(unsigned int n) { + } + return log; + } +- +-static INLINE uint64_t get_byteswap64(uint64_t num) { +- uint64_t out = 0x00; +- uint64_t mask = 0xFF00000000000000; +- int bit_shift = 56; // 7 bytes +- // 4 ms bytes +- do { +- out |= (num & mask) >> bit_shift; +- mask >>= 8; +- bit_shift -= 16; +- } while (bit_shift >= 0); +- // 4 ls bytes +- bit_shift = 8; // 1 byte +- do { +- out |= (num & mask) << bit_shift; +- mask >>= 8; +- bit_shift += 16; +- } while (bit_shift <= 56); +- return out; +-} + #endif + + #ifdef __cplusplus +-- +2.42.0 -- cgit v1.2.3