summaryrefslogtreecommitdiffstats
path: root/media/base/yuv_convert_unittest.cc
diff options
context:
space:
mode:
authorfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 00:35:46 +0000
committerfbarchard@chromium.org <fbarchard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-15 00:35:46 +0000
commita6bc15c3995c18e96b2444172bec1de96f5f86db (patch)
treec2131cd612d1c6bb30b6129f673757272867ee20 /media/base/yuv_convert_unittest.cc
parentdc0aaeaa225eecc6f51db34df00ebcf6cff1783c (diff)
downloadchromium_src-a6bc15c3995c18e96b2444172bec1de96f5f86db.zip
chromium_src-a6bc15c3995c18e96b2444172bec1de96f5f86db.tar.gz
chromium_src-a6bc15c3995c18e96b2444172bec1de96f5f86db.tar.bz2
Make C, MMX and SSE2 all output the same results
BUG=19113,41045 TEST=none. just cleanup and making all platforms produce the same results Review URL: http://codereview.chromium.org/1638008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/yuv_convert_unittest.cc')
-rw-r--r--media/base/yuv_convert_unittest.cc98
1 files changed, 36 insertions, 62 deletions
diff --git a/media/base/yuv_convert_unittest.cc b/media/base/yuv_convert_unittest.cc
index 29dbeea..8a919ad 100644
--- a/media/base/yuv_convert_unittest.cc
+++ b/media/base/yuv_convert_unittest.cc
@@ -21,17 +21,17 @@
// Size of raw image.
// Size of raw image.
-static const int kWidth = 640;
-static const int kHeight = 360;
+static const int kSourceWidth = 640;
+static const int kSourceHeight = 360;
static const int kScaledWidth = 1024;
static const int kScaledHeight = 768;
static const int kBpp = 4;
// Surface sizes.
-static const size_t kYUV12Size = kWidth * kHeight * 12 / 8;
-static const size_t kYUV16Size = kWidth * kHeight * 16 / 8;
-static const size_t kRGBSize = kWidth * kHeight * kBpp;
-static const size_t kRGBSizeConverted = kWidth * kHeight * kBpp;
+static const size_t kYUV12Size = kSourceWidth * kSourceHeight * 12 / 8;
+static const size_t kYUV16Size = kSourceWidth * kSourceHeight * 16 / 8;
+static const size_t kRGBSize = kSourceWidth * kSourceHeight * kBpp;
+static const size_t kRGBSizeConverted = kSourceWidth * kSourceHeight * kBpp;
// Set to 100 to time ConvertYUVToRGB32.
static const int kTestTimes = 1;
@@ -57,13 +57,13 @@ TEST(YUVConvertTest, YV12) {
for (int i = 0; i < kTestTimes; ++i) {
// Convert a frame of YUV to 32 bit ARGB.
media::ConvertYUVToRGB32(yuv_bytes.get(), // Y
- yuv_bytes.get() + kWidth * kHeight, // U
- yuv_bytes.get() + kWidth * kHeight * 5 / 4, // V
+ yuv_bytes.get() + kSourceWidth * kSourceHeight, // U
+ yuv_bytes.get() + kSourceWidth * kSourceHeight * 5 / 4, // V
rgb_converted_bytes.get(), // RGB output
- kWidth, kHeight, // Dimensions
- kWidth, // YStride
- kWidth / 2, // UVStride
- kWidth * kBpp, // RGBStride
+ kSourceWidth, kSourceHeight, // Dimensions
+ kSourceWidth, // YStride
+ kSourceWidth / 2, // UVStride
+ kSourceWidth * kBpp, // RGBStride
media::YV12);
}
@@ -73,12 +73,7 @@ TEST(YUVConvertTest, YV12) {
// To get this hash value, run once and examine the following EXPECT_EQ.
// Then plug new hash value into EXPECT_EQ statements.
- // TODO(fbarchard): Make reference code mimic MMX exactly
-#if USE_MMX
EXPECT_EQ(2413171226u, rgb_hash);
-#else
- EXPECT_EQ(2936300063u, rgb_hash);
-#endif
}
TEST(YUVConvertTest, YV16) {
@@ -102,13 +97,13 @@ TEST(YUVConvertTest, YV16) {
for (int i = 0; i < kTestTimes; ++i) {
// Convert a frame of YUV to 32 bit ARGB.
media::ConvertYUVToRGB32(yuv_bytes.get(), // Y
- yuv_bytes.get() + kWidth * kHeight, // U
- yuv_bytes.get() + kWidth * kHeight * 3 / 2, // V
+ yuv_bytes.get() + kSourceWidth * kSourceHeight, // U
+ yuv_bytes.get() + kSourceWidth * kSourceHeight * 3 / 2, // V
rgb_converted_bytes.get(), // RGB output
- kWidth, kHeight, // Dimensions
- kWidth, // YStride
- kWidth / 2, // UVStride
- kWidth * kBpp, // RGBStride
+ kSourceWidth, kSourceHeight, // Dimensions
+ kSourceWidth, // YStride
+ kSourceWidth / 2, // UVStride
+ kSourceWidth * kBpp, // RGBStride
media::YV16);
}
@@ -118,12 +113,7 @@ TEST(YUVConvertTest, YV16) {
// To get this hash value, run once and examine the following EXPECT_EQ.
// Then plug new hash value into EXPECT_EQ statements.
- // TODO(fbarchard): Make reference code mimic MMX exactly
-#if USE_MMX
EXPECT_EQ(4222342047u, rgb_hash);
-#else
- EXPECT_EQ(106869773u, rgb_hash);
-#endif
}
TEST(YUVScaleTest, YV12) {
@@ -134,7 +124,7 @@ TEST(YUVScaleTest, YV12) {
.Append(FILE_PATH_LITERAL("test"))
.Append(FILE_PATH_LITERAL("data"))
.Append(FILE_PATH_LITERAL("bali_640x360_P420.yuv"));
- const size_t size_of_yuv = kWidth * kHeight * 12 / 8; // 12 bpp.
+ const size_t size_of_yuv = kSourceWidth * kSourceHeight * 12 / 8; // 12 bpp.
scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]);
EXPECT_EQ(static_cast<int>(size_of_yuv),
file_util::ReadFile(yuv_url,
@@ -143,35 +133,30 @@ TEST(YUVScaleTest, YV12) {
// Scale a frame of YUV to 32 bit ARGB.
const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp;
- scoped_array<uint8> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]);
+ scoped_array<uint8> rgb_source_bytes(new uint8[size_of_rgb_scaled]);
for (int i = 0; i < kTestTimes; ++i) {
media::ScaleYUVToRGB32(yuv_bytes.get(), // Y
- yuv_bytes.get() + kWidth * kHeight, // U
- yuv_bytes.get() + kWidth * kHeight * 5 / 4, // V
- rgb_scaled_bytes.get(), // Rgb output
- kWidth, kHeight, // Dimensions
+ yuv_bytes.get() + kSourceWidth * kSourceHeight, // U
+ yuv_bytes.get() + kSourceWidth * kSourceHeight * 5 / 4, // V
+ rgb_source_bytes.get(), // Rgb output
+ kSourceWidth, kSourceHeight, // Dimensions
kScaledWidth, kScaledHeight, // Dimensions
- kWidth, // YStride
- kWidth / 2, // UvStride
+ kSourceWidth, // YStride
+ kSourceWidth / 2, // UvStride
kScaledWidth * kBpp, // RgbStride
media::YV12,
media::ROTATE_0,
media::FILTER_NONE);
}
- unsigned int rgb_hash = DJB2Hash(rgb_scaled_bytes.get(), size_of_rgb_scaled,
+ unsigned int rgb_hash = DJB2Hash(rgb_source_bytes.get(), size_of_rgb_scaled,
kDJB2HashSeed);
// To get this hash value, run once and examine the following EXPECT_EQ.
// Then plug new hash value into EXPECT_EQ statements.
- // TODO(fbarchard): Make reference code mimic MMX exactly
-#if USE_MMX
EXPECT_EQ(4259656254u, rgb_hash);
-#else
- EXPECT_EQ(197274901u, rgb_hash);
-#endif
}
TEST(YUVScaleTest, YV16) {
@@ -182,7 +167,7 @@ TEST(YUVScaleTest, YV16) {
.Append(FILE_PATH_LITERAL("test"))
.Append(FILE_PATH_LITERAL("data"))
.Append(FILE_PATH_LITERAL("bali_640x360_P422.yuv"));
- const size_t size_of_yuv = kWidth * kHeight * 16 / 8; // 16 bpp.
+ const size_t size_of_yuv = kSourceWidth * kSourceHeight * 16 / 8; // 16 bpp.
scoped_array<uint8> yuv_bytes(new uint8[size_of_yuv]);
EXPECT_EQ(static_cast<int>(size_of_yuv),
file_util::ReadFile(yuv_url,
@@ -191,35 +176,30 @@ TEST(YUVScaleTest, YV16) {
// Scale a frame of YUV to 32 bit ARGB.
const size_t size_of_rgb_scaled = kScaledWidth * kScaledHeight * kBpp;
- scoped_array<uint8> rgb_scaled_bytes(new uint8[size_of_rgb_scaled]);
+ scoped_array<uint8> rgb_source_bytes(new uint8[size_of_rgb_scaled]);
for (int i = 0; i < kTestTimes; ++i) {
media::ScaleYUVToRGB32(yuv_bytes.get(), // Y
- yuv_bytes.get() + kWidth * kHeight, // U
- yuv_bytes.get() + kWidth * kHeight * 3 / 2, // V
- rgb_scaled_bytes.get(), // Rgb output
- kWidth, kHeight, // Dimensions
+ yuv_bytes.get() + kSourceWidth * kSourceHeight, // U
+ yuv_bytes.get() + kSourceWidth * kSourceHeight * 3 / 2, // V
+ rgb_source_bytes.get(), // Rgb output
+ kSourceWidth, kSourceHeight, // Dimensions
kScaledWidth, kScaledHeight, // Dimensions
- kWidth, // YStride
- kWidth / 2, // UvStride
+ kSourceWidth, // YStride
+ kSourceWidth / 2, // UvStride
kScaledWidth * kBpp, // RgbStride
media::YV16,
media::ROTATE_0,
media::FILTER_NONE);
}
- unsigned int rgb_hash = DJB2Hash(rgb_scaled_bytes.get(), size_of_rgb_scaled,
+ unsigned int rgb_hash = DJB2Hash(rgb_source_bytes.get(), size_of_rgb_scaled,
kDJB2HashSeed);
// To get this hash value, run once and examine the following EXPECT_EQ.
// Then plug new hash value into EXPECT_EQ statements.
- // TODO(fbarchard): Make reference code mimic MMX exactly
-#if USE_MMX
EXPECT_EQ(974965419u, rgb_hash);
-#else
- EXPECT_EQ(2946450771u, rgb_hash);
-#endif
}
// This tests a known worst case YUV value, and for overflow.
@@ -236,13 +216,7 @@ TEST(YUVConvertTest, Clamp) {
// Prefill extra large destination buffer to test for overflow.
unsigned char rgb[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
- // TODO(fbarchard): Make reference code mimic MMX exactly
- // The code is fixed point and has slight rounding differences.
-#if USE_MMX
unsigned char expected[8] = { 255, 255, 104, 255, 4, 5, 6, 7 };
-#else
- unsigned char expected[8] = { 255, 255, 105, 255, 4, 5, 6, 7 };
-#endif
// Convert a frame of YUV to 32 bit ARGB.
media::ConvertYUVToRGB32(&y, // Y
&u, // U