From 0c282f009c0878de4903f68331f049a959477527 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 29 Oct 2024 11:32:03 +0100 Subject: [PATCH 1/5] unci: copy sample value into memory with endianness correction (#1256) --- .../codecs/uncompressed/decoder_abstract.cc | 24 ++++++++++++++++--- .../codecs/uncompressed/decoder_abstract.h | 3 +++ .../uncompressed/decoder_mixed_interleave.cc | 4 ++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libheif/codecs/uncompressed/decoder_abstract.cc b/libheif/codecs/uncompressed/decoder_abstract.cc index 4568340ccc..3fd71e13b8 100644 --- a/libheif/codecs/uncompressed/decoder_abstract.cc +++ b/libheif/codecs/uncompressed/decoder_abstract.cc @@ -56,12 +56,30 @@ void AbstractDecoder::buildChannelList(std::shared_ptr& img) } } +void AbstractDecoder::memcpy_to_native_endian(uint8_t* dst, uint32_t value, uint32_t bytes_per_sample) +{ + if (bytes_per_sample==1) { + *dst = static_cast(value); + return; + } + else if (std::endian::native == std::endian::big) { + for (uint32_t i = 0; i < bytes_per_sample; i++) { + dst[bytes_per_sample - 1 - i] = static_cast((value >> (i * 8)) & 0xFF); + } + } + else { + for (uint32_t i = 0; i < bytes_per_sample; i++) { + dst[bytes_per_sample] = static_cast((value >> (i * 8)) & 0xFF); + } + } +} + void AbstractDecoder::processComponentSample(UncompressedBitReader& srcBits, const ChannelListEntry& entry, uint64_t dst_row_offset, uint32_t tile_column, uint32_t tile_x) { uint64_t dst_col_number = static_cast(tile_column) * entry.tile_width + tile_x; uint64_t dst_column_offset = dst_col_number * entry.bytes_per_component_sample; - int val = srcBits.get_bits(entry.bits_per_component_sample); - memcpy(entry.dst_plane + dst_row_offset + dst_column_offset, &val, entry.bytes_per_component_sample); + int val = srcBits.get_bits(entry.bits_per_component_sample); // get_bits() reads input in big-endian order + memcpy_to_native_endian(entry.dst_plane + dst_row_offset + dst_column_offset, val, entry.bytes_per_component_sample); } // Handles the case where a row consists of a single component type @@ -85,7 +103,7 @@ void AbstractDecoder::processComponentTileSample(UncompressedBitReader& srcBits, { uint64_t dst_sample_offset = uint64_t{tile_x} * entry.bytes_per_component_sample; int val = srcBits.get_bits(entry.bits_per_component_sample); - memcpy(entry.dst_plane + dst_offset + dst_sample_offset, &val, entry.bytes_per_component_sample); + memcpy_to_native_endian(entry.dst_plane + dst_offset + dst_sample_offset, val, entry.bytes_per_component_sample); } // Handles the case where a row consists of a single component type diff --git a/libheif/codecs/uncompressed/decoder_abstract.h b/libheif/codecs/uncompressed/decoder_abstract.h index b36746beb2..74d6c0cc59 100644 --- a/libheif/codecs/uncompressed/decoder_abstract.h +++ b/libheif/codecs/uncompressed/decoder_abstract.h @@ -201,6 +201,9 @@ class AbstractDecoder std::vector compressed_data, std::vector* data) const; +protected: + void memcpy_to_native_endian(uint8_t* dst, uint32_t value, uint32_t bytes_per_sample); + private: ChannelListEntry buildChannelListEntry(Box_uncC::Component component, std::shared_ptr& img); }; diff --git a/libheif/codecs/uncompressed/decoder_mixed_interleave.cc b/libheif/codecs/uncompressed/decoder_mixed_interleave.cc index 582a9425eb..f1c915de36 100644 --- a/libheif/codecs/uncompressed/decoder_mixed_interleave.cc +++ b/libheif/codecs/uncompressed/decoder_mixed_interleave.cc @@ -106,9 +106,9 @@ void MixedInterleaveDecoder::processTile(UncompressedBitReader& srcBits, uint32_ uint64_t dst_column_number = out_x0 + tile_x; uint64_t dst_column_offset = dst_column_number * entry.bytes_per_component_sample; int val = srcBits.get_bits(entry.bytes_per_component_sample * 8); - memcpy(entry.dst_plane + dst_row_offset + dst_column_offset, &val, entry.bytes_per_component_sample); + memcpy_to_native_endian(entry.dst_plane + dst_row_offset + dst_column_offset, val, entry.bytes_per_component_sample); val = srcBits.get_bits(entry.bytes_per_component_sample * 8); - memcpy(entry.other_chroma_dst_plane + dst_row_offset + dst_column_offset, &val, entry.bytes_per_component_sample); + memcpy_to_native_endian(entry.other_chroma_dst_plane + dst_row_offset + dst_column_offset, val, entry.bytes_per_component_sample); } haveProcessedChromaForThisTile = true; } From 1257811ba314d5859a0f516a4d1beb084a37b395 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 29 Oct 2024 12:08:41 +0100 Subject: [PATCH 2/5] unci: fix memcpy to little endian --- libheif/codecs/uncompressed/decoder_abstract.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libheif/codecs/uncompressed/decoder_abstract.cc b/libheif/codecs/uncompressed/decoder_abstract.cc index 3fd71e13b8..bd4b026da8 100644 --- a/libheif/codecs/uncompressed/decoder_abstract.cc +++ b/libheif/codecs/uncompressed/decoder_abstract.cc @@ -69,7 +69,7 @@ void AbstractDecoder::memcpy_to_native_endian(uint8_t* dst, uint32_t value, uint } else { for (uint32_t i = 0; i < bytes_per_sample; i++) { - dst[bytes_per_sample] = static_cast((value >> (i * 8)) & 0xFF); + dst[i] = static_cast((value >> (i * 8)) & 0xFF); } } } From 6234c75b39ec1fa99e4a5d0fc927ff6fa618a0b5 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 29 Oct 2024 12:10:32 +0100 Subject: [PATCH 3/5] unci: fix tests for 16bit YCbCr 4:2:0 (#1256) --- tests/uncompressed_decode_ycbcr420.cc | 496 +++++++++----------------- 1 file changed, 170 insertions(+), 326 deletions(-) diff --git a/tests/uncompressed_decode_ycbcr420.cc b/tests/uncompressed_decode_ycbcr420.cc index 6f30e2693d..61fd152640 100644 --- a/tests/uncompressed_decode_ycbcr420.cc +++ b/tests/uncompressed_decode_ycbcr420.cc @@ -458,379 +458,223 @@ void check_image_content_ycbcr420_16bit(struct heif_context *&context) { heif_image *img = get_primary_image_ycbcr(handle, heif_chroma_420); int stride; - const uint8_t *img_plane = - heif_image_get_plane_readonly(img, heif_channel_Y, &stride); + const uint16_t *img_plane = + (const uint16_t*)heif_image_get_plane_readonly(img, heif_channel_Y, &stride); REQUIRE(stride == 128); + + stride /= 2; + for (int row = 0; row < 4; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 1])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 2])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 5])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 6])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 9])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 10])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 13])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 14])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 17])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 18])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 21])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 22])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 25])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 26])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 29])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 30])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 33])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 34])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 35])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 36])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 37])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 38])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 41])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 42])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 43])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 44])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 45])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 46])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 49])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 50])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 51])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 52])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 53])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 54])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 57])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 59])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 59])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 60])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 61])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 62])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0x80); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 1])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 5])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 9])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 11])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 13])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 15])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 17])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 18])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 19])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 21])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 22])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 23])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 25])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 26])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 27])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 29])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 30])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 31])) == 0x8080); } for (int row = 4; row < 8; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0xAD); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0xADC6); } for (int row = 8; row < 12; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x49); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0xAF); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0xADC6); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0xAF49); } for (int row = 12; row < 16; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x49); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0xAF); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0x4C); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xADC6); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0xAF49); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0x4C8A); } for (int row = 16; row < 20; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0x49); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xAF); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0x4B); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0xADC6); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xAF49); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0x4B6D); } - img_plane = heif_image_get_plane_readonly(img, heif_channel_Cb, &stride); + img_plane = (const uint16_t*)heif_image_get_plane_readonly(img, heif_channel_Cb, &stride); REQUIRE(stride == 128); + stride/=2; for (int row = 0; row < 2; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 1])) == 0x54); - REQUIRE(((int)(img_plane[stride * row + 2])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x54); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 5])) == 0x55); - REQUIRE(((int)(img_plane[stride * row + 6])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x55); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 9])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 10])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 13])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 14])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 17])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 18])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 21])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 22])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 25])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 26])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 29])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 30])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x7F); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x54BC); + REQUIRE(((int)(img_plane[stride * row + 1])) == 0x54BC); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x5576); + REQUIRE(((int)(img_plane[stride * row + 3])) == 0x5576); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 5])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 9])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 11])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 13])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7FDE); } for (int row = 2; row < 4; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x55); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x1D); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x5576); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x1DE8); } for (int row = 4; row < 6; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xA5); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xA3); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x1DE8); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xA3A5); } for (int row = 6; row < 8; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xA5); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xA3); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x54); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x1DE8); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xA3A5); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x54BC); } for (int row = 8; row < 10; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xA5); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xA3); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x54); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x55); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x1DE8); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xA3A5); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x54BC); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x5576); } - img_plane = heif_image_get_plane_readonly(img, heif_channel_Cr, &stride); + img_plane = (uint16_t*)heif_image_get_plane_readonly(img, heif_channel_Cr, &stride); REQUIRE(stride == 128); + stride/=2; for (int row = 0; row < 2; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 1])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 2])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 5])) == 0x4A); - REQUIRE(((int)(img_plane[stride * row + 6])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4A); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 9])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 10])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 13])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 14])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 17])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 18])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 21])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 22])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 25])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 26])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 29])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 30])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x7F); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 1])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x4A48); + REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4A48); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 5])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 9])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 11])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 13])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7FF5); } for (int row = 2; row < 4; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4A); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xBA); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x4A48); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xBA80); } for (int row = 4; row < 6; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xBA); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x3F); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xAD); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xBA80); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xAD3F); } for (int row = 6; row < 8; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xBA); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x3F); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xFF); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xBA80); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xAD3F); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xFFBD); } for (int row = 8; row < 10; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0xBA); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x3F); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x4A); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBA80); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xAD3F); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x4A48); } heif_image_release(img); From 94b15d9879608e4c1bc763d204736841f4f2bde7 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 29 Oct 2024 12:18:27 +0100 Subject: [PATCH 4/5] unci: fix tests for 16bit YCbCr 4:2:2 (#1256) --- tests/uncompressed_decode_ycbcr422.cc | 494 +++++++++----------------- 1 file changed, 168 insertions(+), 326 deletions(-) diff --git a/tests/uncompressed_decode_ycbcr422.cc b/tests/uncompressed_decode_ycbcr422.cc index 8baa983130..abcb399cdf 100644 --- a/tests/uncompressed_decode_ycbcr422.cc +++ b/tests/uncompressed_decode_ycbcr422.cc @@ -457,379 +457,221 @@ void check_image_content_ycbcr422_16bit(struct heif_context *&context) { heif_image *img = get_primary_image_ycbcr(handle, heif_chroma_422); int stride; - const uint8_t *img_plane = - heif_image_get_plane_readonly(img, heif_channel_Y, &stride); + const uint16_t *img_plane = + (const uint16_t*)heif_image_get_plane_readonly(img, heif_channel_Y, &stride); REQUIRE(stride == 128); + stride /= 2; for (int row = 0; row < 4; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 1])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 2])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 5])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 6])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 9])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 10])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 13])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 14])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 17])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 18])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 21])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 22])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 25])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 26])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 29])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 30])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 33])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 34])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 35])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 36])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 37])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 38])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 41])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 42])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 43])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 44])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 45])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 46])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 49])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 50])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 51])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 52])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 53])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 54])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 57])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 59])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 59])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 60])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 61])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 62])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0x80); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 1])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 5])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 9])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 11])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 13])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 15])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 17])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 18])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 19])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 21])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 22])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 23])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 25])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 26])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 27])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 29])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 30])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 31])) == 0x8080); } for (int row = 4; row < 8; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4B); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0xAD); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x4B6D); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0xADC6); } for (int row = 8; row < 12; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x2E); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x49); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0xAF); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x1D2E); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0xADC6); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0xAF49); } for (int row = 12; row < 16; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFE); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x49); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0xAF); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0x4C); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFFFE); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xADC6); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0xAF49); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0x4C8A); } for (int row = 16; row < 20; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xD0); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0xE2); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x74); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xB3); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 32])) == 0xC6); - REQUIRE(((int)(img_plane[stride * row + 39])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 40])) == 0x49); - REQUIRE(((int)(img_plane[stride * row + 47])) == 0xAF); - REQUIRE(((int)(img_plane[stride * row + 48])) == 0x8A); - REQUIRE(((int)(img_plane[stride * row + 55])) == 0x4C); - REQUIRE(((int)(img_plane[stride * row + 56])) == 0x6D); - REQUIRE(((int)(img_plane[stride * row + 63])) == 0x4B); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xE2D0); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xB374); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x8080); + REQUIRE(((int)(img_plane[stride * row + 16])) == 0xADC6); + REQUIRE(((int)(img_plane[stride * row + 20])) == 0xAF49); + REQUIRE(((int)(img_plane[stride * row + 24])) == 0x4C8A); + REQUIRE(((int)(img_plane[stride * row + 28])) == 0x4B6D); } - img_plane = heif_image_get_plane_readonly(img, heif_channel_Cb, &stride); + img_plane = (const uint16_t*)heif_image_get_plane_readonly(img, heif_channel_Cb, &stride); REQUIRE(stride == 128); + stride /= 2; for (int row = 0; row < 4; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 1])) == 0x54); - REQUIRE(((int)(img_plane[stride * row + 2])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x54); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 5])) == 0x55); - REQUIRE(((int)(img_plane[stride * row + 6])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x55); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 9])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 10])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 13])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 14])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 17])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 18])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 21])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 22])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 25])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 26])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 29])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 30])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x7F); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x54BC); + REQUIRE(((int)(img_plane[stride * row + 1])) == 0x54BC); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x5576); + REQUIRE(((int)(img_plane[stride * row + 3])) == 0x5576); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 5])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 9])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 11])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 13])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7FDE); } for (int row = 5; row < 8; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x55); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x1D); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x5576); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x1DE8); } for (int row = 9; row < 12; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xA5); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xA3); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x1DE8); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xA3A5); } for (int row = 12; row < 16; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xA5); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xA3); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x54); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FBD); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x1DE8); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xA3A5); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x54BC); } for (int row = 16; row < 20; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x01); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0xAB); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xDE); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xE8); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x1D); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xA5); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xA3); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xBC); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x54); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x76); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x55); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x0000); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0xAB01); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FDE); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x1DE8); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xA3A5); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x54BC); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x5576); } - img_plane = heif_image_get_plane_readonly(img, heif_channel_Cr, &stride); + img_plane = (const uint16_t*)heif_image_get_plane_readonly(img, heif_channel_Cr, &stride); REQUIRE(stride == 128); + stride /= 2; for (int row = 0; row < 4; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 1])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 2])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 5])) == 0x4A); - REQUIRE(((int)(img_plane[stride * row + 6])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x4A); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 9])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 10])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 13])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 14])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 17])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 18])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 21])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 22])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 25])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 26])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 29])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 30])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x7F); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 1])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x4A48); + REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4A48); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 5])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 9])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 11])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 13])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7FF5); } for (int row = 4; row < 8; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x4A); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xBA); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x4A48); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xBA80); } for (int row = 8; row < 12; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0x2F); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x6B); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xBA); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x3F); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xAD); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x6B2F); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xBA80); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xAD3F); } for (int row = 12; row < 16; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xEB); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xBA); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0x3F); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0xFF); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FEB); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xBA80); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xAD3F); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0xFFBD); } for (int row = 16; row < 20; row++) { INFO("row: " << row); - REQUIRE(((int)(img_plane[stride * row + 0])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 3])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 4])) == 0xBB); - REQUIRE(((int)(img_plane[stride * row + 7])) == 0x94); - REQUIRE(((int)(img_plane[stride * row + 8])) == 0x2D); - REQUIRE(((int)(img_plane[stride * row + 11])) == 0x00); - REQUIRE(((int)(img_plane[stride * row + 12])) == 0xF5); - REQUIRE(((int)(img_plane[stride * row + 15])) == 0x7F); - REQUIRE(((int)(img_plane[stride * row + 16])) == 0x80); - REQUIRE(((int)(img_plane[stride * row + 19])) == 0xBA); - REQUIRE(((int)(img_plane[stride * row + 20])) == 0x3F); - REQUIRE(((int)(img_plane[stride * row + 23])) == 0xAD); - REQUIRE(((int)(img_plane[stride * row + 24])) == 0xBD); - REQUIRE(((int)(img_plane[stride * row + 27])) == 0xFF); - REQUIRE(((int)(img_plane[stride * row + 28])) == 0x48); - REQUIRE(((int)(img_plane[stride * row + 31])) == 0x4A); + REQUIRE(((int)(img_plane[stride * row + 0])) == 0x7FFF); + REQUIRE(((int)(img_plane[stride * row + 2])) == 0x94BB); + REQUIRE(((int)(img_plane[stride * row + 4])) == 0x002D); + REQUIRE(((int)(img_plane[stride * row + 6])) == 0x7FF5); + REQUIRE(((int)(img_plane[stride * row + 8])) == 0xBA80); + REQUIRE(((int)(img_plane[stride * row + 10])) == 0xAD3F); + REQUIRE(((int)(img_plane[stride * row + 12])) == 0xFFBD); + REQUIRE(((int)(img_plane[stride * row + 14])) == 0x4A48); } heif_image_release(img); From dc49f576472dabd2dacef1c988e148a89a5d754f Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 29 Oct 2024 12:25:01 +0100 Subject: [PATCH 5/5] unci: add TODO comment --- libheif/codecs/uncompressed/decoder_abstract.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libheif/codecs/uncompressed/decoder_abstract.cc b/libheif/codecs/uncompressed/decoder_abstract.cc index bd4b026da8..a3029c675d 100644 --- a/libheif/codecs/uncompressed/decoder_abstract.cc +++ b/libheif/codecs/uncompressed/decoder_abstract.cc @@ -58,6 +58,8 @@ void AbstractDecoder::buildChannelList(std::shared_ptr& img) void AbstractDecoder::memcpy_to_native_endian(uint8_t* dst, uint32_t value, uint32_t bytes_per_sample) { + // TODO: this assumes that the file endianness is always big-endian. The endianness flags in the uncC header are not taken into account yet. + if (bytes_per_sample==1) { *dst = static_cast(value); return;