diff options
author | Justin Green <greenjustin@google.com> | 2023-03-14 10:23:17 -0400 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-14 14:59:26 +0000 |
commit | 76468711d5c8302431a900499ff73d34fdfc146b (patch) | |
tree | a91e3f09e5b124c688eb809bb0b288db42eb8d46 /source/row_common.cc | |
parent | f9b23b9cc0ca3bd27b9acc07ea0450cd5097175d (diff) | |
download | libyuv-76468711d5c8302431a900499ff73d34fdfc146b.tar.gz |
M2T2 Unpack fixes
Fix the algorithm for unpacking the lower 2 bits of M2T2 pixels.
Bug: b:258474032
Change-Id: Iea1d63f26e3f127a70ead26bc04ea3d939e793e3
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4337978
Commit-Queue: Justin Green <greenjustin@google.com>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/row_common.cc')
-rw-r--r-- | source/row_common.cc | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/source/row_common.cc b/source/row_common.cc index 84afd35b..478d8ac6 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -2868,24 +2868,21 @@ void DetileToYUY2_C(const uint8_t* src_y, // Unpack MT2T into tiled P010 64 pixels at a time. MT2T's bitstream is encoded // in 80 byte blocks representing 64 pixels each. The first 16 bytes of the // block contain all of the lower 2 bits of each pixel packed together, and the -// next 64 bytes represent all the upper 8 bits of the pixel. +// next 64 bytes represent all the upper 8 bits of the pixel. The lower bits are +// packed into 1x4 blocks, whereas the upper bits are packed in normal raster +// order. void UnpackMT2T_C(const uint8_t* src, uint16_t* dst, size_t size) { for (size_t i = 0; i < size; i += 80) { const uint8_t* src_lower_bits = src; const uint8_t* src_upper_bits = src + 16; - for (int j = 0; j < 16; j++) { - uint8_t lower_bits = src_lower_bits[j]; - *dst++ = (lower_bits & 0x03) << 6 | (uint16_t)src_upper_bits[j * 4] << 8 | - (uint16_t)src_upper_bits[j * 4] >> 2; - *dst++ = (lower_bits & 0x0C) << 4 | - (uint16_t)src_upper_bits[j * 4 + 1] << 8 | - (uint16_t)src_upper_bits[j * 4 + 1] >> 2; - *dst++ = (lower_bits & 0x30) << 2 | - (uint16_t)src_upper_bits[j * 4 + 2] << 8 | - (uint16_t)src_upper_bits[j * 4 + 2] >> 2; - *dst++ = (lower_bits & 0xC0) | (uint16_t)src_upper_bits[j * 4 + 3] << 8 | - (uint16_t)src_upper_bits[j * 4 + 3] >> 2; + for (int j = 0; j < 4; j++) { + for (int k = 0; k < 16; k++) { + *dst++ = ((src_lower_bits[k] >> (j * 2)) & 0x3) << 6 | + (uint16_t)*src_upper_bits << 8 | + (uint16_t)*src_upper_bits >> 2; + src_upper_bits++; + } } src += 80; @@ -4547,4 +4544,4 @@ void HalfMergeUVRow_C(const uint8_t* src_u, #ifdef __cplusplus } // extern "C" } // namespace libyuv -#endif
\ No newline at end of file +#endif |