Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(701)

Unified Diff: media/base/yuv_convert_unittest.cc

Issue 1638008: yuv use a shared table for windows, posix and C... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/yuv_convert.cc ('k') | media/base/yuv_row.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/yuv_convert_unittest.cc
===================================================================
--- media/base/yuv_convert_unittest.cc (revision 44590)
+++ media/base/yuv_convert_unittest.cc (working copy)
@@ -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 @@
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 @@
// 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 @@
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 @@
// 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 @@
.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 @@
// 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 @@
.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 @@
// 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 @@
// 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
« no previous file with comments | « media/base/yuv_convert.cc ('k') | media/base/yuv_row.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698