summaryrefslogtreecommitdiff
blob: 38559c564726165866bdd96e12e719610d3307d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 <wtc@google.com>
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<int16_t> 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<const uint16_t *>(row);
+          bytes.push_back(row16[c]);
+        } else {
           bytes.push_back(row[c]);
+        }
       }
     }
   }
-- 
2.42.0