| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "media/base/djb2.h" | 8 #include "media/base/djb2.h" |
| 9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
| 10 #include "media/base/yuv_row.h" | 10 #include "media/base/yuv_row.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 // Reference images were created with the following steps | 13 // Reference images were created with the following steps |
| 14 // ffmpeg -vframes 25 -i bali.mov -vcodec rawvideo -pix_fmt yuv420p -an | 14 // ffmpeg -vframes 25 -i bali.mov -vcodec rawvideo -pix_fmt yuv420p -an |
| 15 // bali_1280x720_P420.yuv | 15 // bali_1280x720_P420.yuv |
| 16 // yuvhalf -yv12 -skip 24 bali_1280x720_P420.yuv bali_640x360_P420.yuv | 16 // yuvhalf -yv12 -skip 24 bali_1280x720_P420.yuv bali_640x360_P420.yuv |
| 17 | 17 |
| 18 // ffmpeg -vframes 25 -i bali.mov -vcodec rawvideo -pix_fmt yuv422p -an | 18 // ffmpeg -vframes 25 -i bali.mov -vcodec rawvideo -pix_fmt yuv422p -an |
| 19 // bali_1280x720_P422.yuv | 19 // bali_1280x720_P422.yuv |
| 20 // yuvhalf -yv16 -skip 24 bali_1280x720_P422.yuv bali_640x360_P422.yuv | 20 // yuvhalf -yv16 -skip 24 bali_1280x720_P422.yuv bali_640x360_P422.yuv |
| 21 // Size of raw image. | 21 // Size of raw image. |
| 22 | 22 |
| 23 // Size of raw image. | 23 // Size of raw image. |
| 24 static const int kWidth = 640; | 24 static const int kSourceWidth = 640; |
| 25 static const int kHeight = 360; | 25 static const int kSourceHeight = 360; |
| 26 static const int kScaledWidth = 1024; | 26 static const int kScaledWidth = 1024; |
| 27 static const int kScaledHeight = 768; | 27 static const int kScaledHeight = 768; |
| 28 static const int kBpp = 4; | 28 static const int kBpp = 4; |
| 29 | 29 |
| 30 // Surface sizes. | 30 // Surface sizes. |
| 31 static const size_t kYUV12Size = kWidth * kHeight * 12 / 8; | 31 static const size_t kYUV12Size = kSourceWidth * kSourceHeight * 12 / 8; |
| 32 static const size_t kYUV16Size = kWidth * kHeight * 16 / 8; | 32 static const size_t kYUV16Size = kSourceWidth * kSourceHeight * 16 / 8; |
| 33 static const size_t kRGBSize = kWidth * kHeight * kBpp; | 33 static const size_t kRGBSize = kSourceWidth * kSourceHeight * kBpp; |
| 34 static const size_t kRGBSizeConverted = kWidth * kHeight * kBpp; | 34 static const size_t kRGBSizeConverted = kSourceWidth * kSourceHeight * kBpp; |
| 35 | 35 |
| 36 // Set to 100 to time ConvertYUVToRGB32. | 36 // Set to 100 to time ConvertYUVToRGB32. |
| 37 static const int kTestTimes = 1; | 37 static const int kTestTimes = 1; |
| 38 | 38 |
| 39 TEST(YUVConvertTest, YV12) { | 39 TEST(YUVConvertTest, YV12) { |
| 40 // Allocate all surfaces. | 40 // Allocate all surfaces. |
| 41 scoped_array<uint8> yuv_bytes(new uint8[kYUV12Size]); | 41 scoped_array<uint8> yuv_bytes(new uint8[kYUV12Size]); |
| 42 scoped_array<uint8> rgb_bytes(new uint8[kRGBSize]); | 42 scoped_array<uint8> rgb_bytes(new uint8[kRGBSize]); |
| 43 scoped_array<uint8> rgb_converted_bytes(new uint8[kRGBSizeConverted]); | 43 scoped_array<uint8> rgb_converted_bytes(new uint8[kRGBSizeConverted]); |
| 44 | 44 |
| 45 // Read YUV reference data from file. | 45 // Read YUV reference data from file. |
| 46 FilePath yuv_url; | 46 FilePath yuv_url; |
| 47 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); | 47 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); |
| 48 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) | 48 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) |
| 49 .Append(FILE_PATH_LITERAL("test")) | 49 .Append(FILE_PATH_LITERAL("test")) |
| 50 .Append(FILE_PATH_LITERAL("data")) | 50 .Append(FILE_PATH_LITERAL("data")) |
| 51 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); | 51 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); |
| 52 EXPECT_EQ(static_cast<int>(kYUV12Size), | 52 EXPECT_EQ(static_cast<int>(kYUV12Size), |
| 53 file_util::ReadFile(yuv_url, | 53 file_util::ReadFile(yuv_url, |
| 54 reinterpret_cast<char*>(yuv_bytes.get()), | 54 reinterpret_cast<char*>(yuv_bytes.get()), |
| 55 static_cast<int>(kYUV12Size))); | 55 static_cast<int>(kYUV12Size))); |
| 56 | 56 |
| 57 for (int i = 0; i < kTestTimes; ++i) { | 57 for (int i = 0; i < kTestTimes; ++i) { |
| 58 // Convert a frame of YUV to 32 bit ARGB. | 58 // Convert a frame of YUV to 32 bit ARGB. |
| 59 media::ConvertYUVToRGB32(yuv_bytes.get(), // Y | 59 media::ConvertYUVToRGB32(yuv_bytes.get(), // Y |
| 60 yuv_bytes.get() + kWidth * kHeight, // U | 60 yuv_bytes.get() + kSourceWidth * kSourceHeight,
// U |
| 61 yuv_bytes.get() + kWidth * kHeight * 5 / 4, // V | 61 yuv_bytes.get() + kSourceWidth * kSourceHeight * 5
/ 4, // V |
| 62 rgb_converted_bytes.get(), // RGB output | 62 rgb_converted_bytes.get(), // RGB output |
| 63 kWidth, kHeight, // Dimensions | 63 kSourceWidth, kSourceHeight, // Dimensio
ns |
| 64 kWidth, // YStride | 64 kSourceWidth, // YStride |
| 65 kWidth / 2, // UVStride | 65 kSourceWidth / 2, // UVStride |
| 66 kWidth * kBpp, // RGBStride | 66 kSourceWidth * kBpp, // RGBStride |
| 67 media::YV12); | 67 media::YV12); |
| 68 } | 68 } |
| 69 | 69 |
| 70 unsigned int rgb_hash = DJB2Hash(rgb_converted_bytes.get(), kRGBSizeConverted, | 70 unsigned int rgb_hash = DJB2Hash(rgb_converted_bytes.get(), kRGBSizeConverted, |
| 71 kDJB2HashSeed); | 71 kDJB2HashSeed); |
| 72 | 72 |
| 73 // To get this hash value, run once and examine the following EXPECT_EQ. | 73 // To get this hash value, run once and examine the following EXPECT_EQ. |
| 74 // Then plug new hash value into EXPECT_EQ statements. | 74 // Then plug new hash value into EXPECT_EQ statements. |
| 75 | 75 |
| 76 // TODO(fbarchard): Make reference code mimic MMX exactly | |
| 77 #if USE_MMX | |
| 78 EXPECT_EQ(2413171226u, rgb_hash); | 76 EXPECT_EQ(2413171226u, rgb_hash); |
| 79 #else | |
| 80 EXPECT_EQ(2936300063u, rgb_hash); | |
| 81 #endif | |
| 82 } | 77 } |
| 83 | 78 |
| 84 TEST(YUVConvertTest, YV16) { | 79 TEST(YUVConvertTest, YV16) { |
| 85 // Allocate all surfaces. | 80 // Allocate all surfaces. |
| 86 scoped_array<uint8> yuv_bytes(new uint8[kYUV16Size]); | 81 scoped_array<uint8> yuv_bytes(new uint8[kYUV16Size]); |
| 87 scoped_array<uint8> rgb_bytes(new uint8[kRGBSize]); | 82 scoped_array<uint8> rgb_bytes(new uint8[kRGBSize]); |
| 88 scoped_array<uint8> rgb_converted_bytes(new uint8[kRGBSizeConverted]); | 83 scoped_array<uint8> rgb_converted_bytes(new uint8[kRGBSizeConverted]); |
| 89 | 84 |
| 90 // Read YV16 reference data from file. | 85 // Read YV16 reference data from file. |
| 91 FilePath yuv_url; | 86 FilePath yuv_url; |
| 92 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); | 87 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); |
| 93 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) | 88 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) |
| 94 .Append(FILE_PATH_LITERAL("test")) | 89 .Append(FILE_PATH_LITERAL("test")) |
| 95 .Append(FILE_PATH_LITERAL("data")) | 90 .Append(FILE_PATH_LITERAL("data")) |
| 96 .Append(FILE_PATH_LITERAL("bali_640x360_P422.yuv")); | 91 .Append(FILE_PATH_LITERAL("bali_640x360_P422.yuv")); |
| 97 EXPECT_EQ(static_cast<int>(kYUV16Size), | 92 EXPECT_EQ(static_cast<int>(kYUV16Size), |
| 98 file_util::ReadFile(yuv_url, | 93 file_util::ReadFile(yuv_url, |
| 99 reinterpret_cast<char*>(yuv_bytes.get()), | 94 reinterpret_cast<char*>(yuv_bytes.get()), |
| 100 static_cast<int>(kYUV16Size))); | 95 static_cast<int>(kYUV16Size))); |
| 101 | 96 |
| 102 for (int i = 0; i < kTestTimes; ++i) { | 97 for (int i = 0; i < kTestTimes; ++i) { |
| 103 // Convert a frame of YUV to 32 bit ARGB. | 98 // Convert a frame of YUV to 32 bit ARGB. |
| 104 media::ConvertYUVToRGB32(yuv_bytes.get(), // Y | 99 media::ConvertYUVToRGB32(yuv_bytes.get(), // Y |
| 105 yuv_bytes.get() + kWidth * kHeight, // U | 100 yuv_bytes.get() + kSourceWidth * kSourceHeight,
// U |
| 106 yuv_bytes.get() + kWidth * kHeight * 3 / 2, // V | 101 yuv_bytes.get() + kSourceWidth * kSourceHeight * 3
/ 2, // V |
| 107 rgb_converted_bytes.get(), // RGB output | 102 rgb_converted_bytes.get(), // RGB output |
| 108 kWidth, kHeight, // Dimensions | 103 kSourceWidth, kSourceHeight, // Dimensio
ns |
| 109 kWidth, // YStride | 104 kSourceWidth, // YStride |
| 110 kWidth / 2, // UVStride | 105 kSourceWidth / 2, // UVStride |
| 111 kWidth * kBpp, // RGBStride | 106 kSourceWidth * kBpp, // RGBStride |
| 112 media::YV16); | 107 media::YV16); |
| 113 } | 108 } |
| 114 | 109 |
| 115 unsigned int rgb_hash = DJB2Hash(rgb_converted_bytes.get(), kRGBSizeConverted, | 110 unsigned int rgb_hash = DJB2Hash(rgb_converted_bytes.get(), kRGBSizeConverted, |
| 116 kDJB2HashSeed); | 111 kDJB2HashSeed); |
| 117 | 112 |
| 118 // To get this hash value, run once and examine the following EXPECT_EQ. | 113 // To get this hash value, run once and examine the following EXPECT_EQ. |
| 119 // Then plug new hash value into EXPECT_EQ statements. | 114 // Then plug new hash value into EXPECT_EQ statements. |
| 120 | 115 |
| 121 // TODO(fbarchard): Make reference code mimic MMX exactly | |
| 122 #if USE_MMX | |
| 123 EXPECT_EQ(4222342047u, rgb_hash); | 116 EXPECT_EQ(4222342047u, rgb_hash); |
| 124 #else | |
| 125 EXPECT_EQ(106869773u, rgb_hash); | |
| 126 #endif | |
| 127 } | 117 } |
| 128 | 118 |
| 129 TEST(YUVScaleTest, YV12) { | 119 TEST(YUVScaleTest, YV12) { |
| 130 // Read YUV reference data from file. | 120 // Read YUV reference data from file. |
| 131 FilePath yuv_url; | 121 FilePath yuv_url; |
| 132 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); | 122 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); |
| 133 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) | 123 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) |
| 134 .Append(FILE_PATH_LITERAL("test")) | 124 .Append(FILE_PATH_LITERAL("test")) |
| 135 .Append(FILE_PATH_LITERAL("data")) | 125 .Append(FILE_PATH_LITERAL("data")) |
| 136 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); | 126 .Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv")); |
| 137 const size_t size_of_yuv = kWidth * kHeight * 12 / 8; // 12 bpp. | 127 const size_t size_of_yuv = kSourceWidth * kSourceHeight * 12 / 8; // 12 bpp. |
| 138 scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); | 128 scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); |
| 139 EXPECT_EQ(static_cast<int>(size_of_yuv), | 129 EXPECT_EQ(static_cast<int>(size_of_yuv), |
| 140 file_util::ReadFile(yuv_url, | 130 file_util::ReadFile(yuv_url, |
| 141 reinterpret_cast<char*>(yuv_bytes.get()), | 131 reinterpret_cast<char*>(yuv_bytes.get()), |
| 142 static_cast<int>(size_of_yuv))); | 132 static_cast<int>(size_of_yuv))); |
| 143 | 133 |
| 144 // Scale a frame of YUV to 32 bit ARGB. | 134 // Scale a frame of YUV to 32 bit ARGB. |
| 145 const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp; | 135 const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp; |
| 146 scoped_array<uint8> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]); | 136 scoped_array<uint8> rgb_source_bytes(new uint8[size_of_rgb_scaled]); |
| 147 | 137 |
| 148 for (int i = 0; i < kTestTimes; ++i) { | 138 for (int i = 0; i < kTestTimes; ++i) { |
| 149 media::ScaleYUVToRGB32(yuv_bytes.get(), // Y | 139 media::ScaleYUVToRGB32(yuv_bytes.get(), // Y |
| 150 yuv_bytes.get() + kWidth * kHeight, // U | 140 yuv_bytes.get() + kSourceWidth * kSourceHeight,
// U |
| 151 yuv_bytes.get() + kWidth * kHeight * 5 / 4, // V | 141 yuv_bytes.get() + kSourceWidth * kSourceHeight * 5 / 4,
// V |
| 152 rgb_scaled_bytes.get(), // Rgb output | 142 rgb_source_bytes.get(), // Rgb output |
| 153 kWidth, kHeight, // Dimensions | 143 kSourceWidth, kSourceHeight, // Dimensions |
| 154 kScaledWidth, kScaledHeight, // Dimensions | 144 kScaledWidth, kScaledHeight, // Dimensions |
| 155 kWidth, // YStride | 145 kSourceWidth, // YStride |
| 156 kWidth / 2, // UvStride | 146 kSourceWidth / 2, // UvStride |
| 157 kScaledWidth * kBpp, // RgbStride | 147 kScaledWidth * kBpp, // RgbStride |
| 158 media::YV12, | 148 media::YV12, |
| 159 media::ROTATE_0, | 149 media::ROTATE_0, |
| 160 media::FILTER_NONE); | 150 media::FILTER_NONE); |
| 161 } | 151 } |
| 162 | 152 |
| 163 unsigned int rgb_hash = DJB2Hash(rgb_scaled_bytes.get(), size_of_rgb_scaled, | 153 unsigned int rgb_hash = DJB2Hash(rgb_source_bytes.get(), size_of_rgb_scaled, |
| 164 kDJB2HashSeed); | 154 kDJB2HashSeed); |
| 165 | 155 |
| 166 // To get this hash value, run once and examine the following EXPECT_EQ. | 156 // To get this hash value, run once and examine the following EXPECT_EQ. |
| 167 // Then plug new hash value into EXPECT_EQ statements. | 157 // Then plug new hash value into EXPECT_EQ statements. |
| 168 | 158 |
| 169 // TODO(fbarchard): Make reference code mimic MMX exactly | |
| 170 #if USE_MMX | |
| 171 EXPECT_EQ(4259656254u, rgb_hash); | 159 EXPECT_EQ(4259656254u, rgb_hash); |
| 172 #else | |
| 173 EXPECT_EQ(197274901u, rgb_hash); | |
| 174 #endif | |
| 175 } | 160 } |
| 176 | 161 |
| 177 TEST(YUVScaleTest, YV16) { | 162 TEST(YUVScaleTest, YV16) { |
| 178 // Read YV16 reference data from file. | 163 // Read YV16 reference data from file. |
| 179 FilePath yuv_url; | 164 FilePath yuv_url; |
| 180 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); | 165 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &yuv_url)); |
| 181 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) | 166 yuv_url = yuv_url.Append(FILE_PATH_LITERAL("media")) |
| 182 .Append(FILE_PATH_LITERAL("test")) | 167 .Append(FILE_PATH_LITERAL("test")) |
| 183 .Append(FILE_PATH_LITERAL("data")) | 168 .Append(FILE_PATH_LITERAL("data")) |
| 184 .Append(FILE_PATH_LITERAL("bali_640x360_P422.yuv")); | 169 .Append(FILE_PATH_LITERAL("bali_640x360_P422.yuv")); |
| 185 const size_t size_of_yuv = kWidth * kHeight * 16 / 8; // 16 bpp. | 170 const size_t size_of_yuv = kSourceWidth * kSourceHeight * 16 / 8; // 16 bpp. |
| 186 scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); | 171 scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]); |
| 187 EXPECT_EQ(static_cast<int>(size_of_yuv), | 172 EXPECT_EQ(static_cast<int>(size_of_yuv), |
| 188 file_util::ReadFile(yuv_url, | 173 file_util::ReadFile(yuv_url, |
| 189 reinterpret_cast<char*>(yuv_bytes.get()), | 174 reinterpret_cast<char*>(yuv_bytes.get()), |
| 190 static_cast<int>(size_of_yuv))); | 175 static_cast<int>(size_of_yuv))); |
| 191 | 176 |
| 192 // Scale a frame of YUV to 32 bit ARGB. | 177 // Scale a frame of YUV to 32 bit ARGB. |
| 193 const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp; | 178 const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp; |
| 194 scoped_array<uint8> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]); | 179 scoped_array<uint8> rgb_source_bytes(new uint8[size_of_rgb_scaled]); |
| 195 | 180 |
| 196 for (int i = 0; i < kTestTimes; ++i) { | 181 for (int i = 0; i < kTestTimes; ++i) { |
| 197 media::ScaleYUVToRGB32(yuv_bytes.get(), // Y | 182 media::ScaleYUVToRGB32(yuv_bytes.get(), // Y |
| 198 yuv_bytes.get() + kWidth * kHeight, // U | 183 yuv_bytes.get() + kSourceWidth * kSourceHeight,
// U |
| 199 yuv_bytes.get() + kWidth * kHeight * 3 / 2, // V | 184 yuv_bytes.get() + kSourceWidth * kSourceHeight * 3 / 2,
// V |
| 200 rgb_scaled_bytes.get(), // Rgb output | 185 rgb_source_bytes.get(), // Rgb output |
| 201 kWidth, kHeight, // Dimensions | 186 kSourceWidth, kSourceHeight, // Dimensions |
| 202 kScaledWidth, kScaledHeight, // Dimensions | 187 kScaledWidth, kScaledHeight, // Dimensions |
| 203 kWidth, // YStride | 188 kSourceWidth, // YStride |
| 204 kWidth / 2, // UvStride | 189 kSourceWidth / 2, // UvStride |
| 205 kScaledWidth * kBpp, // RgbStride | 190 kScaledWidth * kBpp, // RgbStride |
| 206 media::YV16, | 191 media::YV16, |
| 207 media::ROTATE_0, | 192 media::ROTATE_0, |
| 208 media::FILTER_NONE); | 193 media::FILTER_NONE); |
| 209 } | 194 } |
| 210 | 195 |
| 211 unsigned int rgb_hash = DJB2Hash(rgb_scaled_bytes.get(), size_of_rgb_scaled, | 196 unsigned int rgb_hash = DJB2Hash(rgb_source_bytes.get(), size_of_rgb_scaled, |
| 212 kDJB2HashSeed); | 197 kDJB2HashSeed); |
| 213 | 198 |
| 214 // To get this hash value, run once and examine the following EXPECT_EQ. | 199 // To get this hash value, run once and examine the following EXPECT_EQ. |
| 215 // Then plug new hash value into EXPECT_EQ statements. | 200 // Then plug new hash value into EXPECT_EQ statements. |
| 216 | 201 |
| 217 // TODO(fbarchard): Make reference code mimic MMX exactly | |
| 218 #if USE_MMX | |
| 219 EXPECT_EQ(974965419u, rgb_hash); | 202 EXPECT_EQ(974965419u, rgb_hash); |
| 220 #else | |
| 221 EXPECT_EQ(2946450771u, rgb_hash); | |
| 222 #endif | |
| 223 } | 203 } |
| 224 | 204 |
| 225 // This tests a known worst case YUV value, and for overflow. | 205 // This tests a known worst case YUV value, and for overflow. |
| 226 TEST(YUVConvertTest, Clamp) { | 206 TEST(YUVConvertTest, Clamp) { |
| 227 // Allocate all surfaces. | 207 // Allocate all surfaces. |
| 228 scoped_array<uint8> yuv_bytes(new uint8[1]); | 208 scoped_array<uint8> yuv_bytes(new uint8[1]); |
| 229 scoped_array<uint8> rgb_bytes(new uint8[1]); | 209 scoped_array<uint8> rgb_bytes(new uint8[1]); |
| 230 scoped_array<uint8> rgb_converted_bytes(new uint8[1]); | 210 scoped_array<uint8> rgb_converted_bytes(new uint8[1]); |
| 231 | 211 |
| 232 // Values that failed previously in bug report. | 212 // Values that failed previously in bug report. |
| 233 unsigned char y = 255u; | 213 unsigned char y = 255u; |
| 234 unsigned char u = 255u; | 214 unsigned char u = 255u; |
| 235 unsigned char v = 19u; | 215 unsigned char v = 19u; |
| 236 | 216 |
| 237 // Prefill extra large destination buffer to test for overflow. | 217 // Prefill extra large destination buffer to test for overflow. |
| 238 unsigned char rgb[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; | 218 unsigned char rgb[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; |
| 239 // TODO(fbarchard): Make reference code mimic MMX exactly | |
| 240 // The code is fixed point and has slight rounding differences. | |
| 241 #if USE_MMX | |
| 242 unsigned char expected[8] = { 255, 255, 104, 255, 4, 5, 6, 7 }; | 219 unsigned char expected[8] = { 255, 255, 104, 255, 4, 5, 6, 7 }; |
| 243 #else | |
| 244 unsigned char expected[8] = { 255, 255, 105, 255, 4, 5, 6, 7 }; | |
| 245 #endif | |
| 246 // Convert a frame of YUV to 32 bit ARGB. | 220 // Convert a frame of YUV to 32 bit ARGB. |
| 247 media::ConvertYUVToRGB32(&y, // Y | 221 media::ConvertYUVToRGB32(&y, // Y |
| 248 &u, // U | 222 &u, // U |
| 249 &v, // V | 223 &v, // V |
| 250 &rgb[0], // RGB output | 224 &rgb[0], // RGB output |
| 251 1, 1, // Dimensions | 225 1, 1, // Dimensions |
| 252 0, // YStride | 226 0, // YStride |
| 253 0, // UVStride | 227 0, // UVStride |
| 254 0, // RGBStride | 228 0, // RGBStride |
| 255 media::YV12); | 229 media::YV12); |
| 256 | 230 |
| 257 int expected_test = memcmp(rgb, expected, sizeof(expected)); | 231 int expected_test = memcmp(rgb, expected, sizeof(expected)); |
| 258 EXPECT_EQ(0, expected_test); | 232 EXPECT_EQ(0, expected_test); |
| 259 } | 233 } |
| OLD | NEW |