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

Unified Diff: media/base/simd/convert_rgb_to_yuv_unittest.cc

Issue 10837118: Dead code elimination: scythe.chrome_functions:segment.path %media% edition, round 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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
Index: media/base/simd/convert_rgb_to_yuv_unittest.cc
diff --git a/media/base/simd/convert_rgb_to_yuv_unittest.cc b/media/base/simd/convert_rgb_to_yuv_unittest.cc
index 020fb257464175c9efaa78f936b9fe46cfae46ec..08aa4dfb42ae3b6ab20722869c488274356b4a64 100644
--- a/media/base/simd/convert_rgb_to_yuv_unittest.cc
+++ b/media/base/simd/convert_rgb_to_yuv_unittest.cc
@@ -16,28 +16,14 @@ int ConvertRGBToY(const uint8* rgb) {
return std::max(0, std::min(255, y));
}
-int ConvertRGBToU(const uint8* rgb, int size, bool subsampling) {
- int u = 0;
- if (!subsampling) {
- u = 112 * rgb[0] - 74 * rgb[1] - 38 * rgb[2];
- } else {
- int u0 = 112 * rgb[0] - 74 * rgb[1] - 38 * rgb[2];
- int u1 = 112 * rgb[size] - 74 * rgb[size + 1] - 38 * rgb[size + 2];
- u = (u0 + u1 + 1) / 2;
- }
+int ConvertRGBToU(const uint8* rgb, int size) {
+ int u = 112 * rgb[0] - 74 * rgb[1] - 38 * rgb[2];
u = ((u + 128) >> 8) + 128;
return std::max(0, std::min(255, u));
}
-int ConvertRGBToV(const uint8* rgb, int size, bool subsampling) {
- int v = 0;
- if (!subsampling) {
- v = -18 * rgb[0] - 94 * rgb[1] + 112 * rgb[2];
- } else {
- int v0 = -18 * rgb[0] - 94 * rgb[1] + 112 * rgb[2];
- int v1 = -18 * rgb[size] - 94 * rgb[size + 1] + 112 * rgb[size + 2];
- v = (v0 + v1 + 1) / 2;
- }
+int ConvertRGBToV(const uint8* rgb, int size) {
+ int v = -18 * rgb[0] - 94 * rgb[1] + 112 * rgb[2];
v = ((v + 128) >> 8) + 128;
return std::max(0, std::min(255, v));
}
@@ -61,12 +47,6 @@ TEST(YUVConvertTest, SideBySideRGB) {
const int kStep = 8;
const int kWidth = 256 / kStep;
-#ifdef ENABLE_SUBSAMPLING
- const bool kSubsampling = true;
-#else
- const bool kSubsampling = false;
-#endif
-
for (int size = 3; size <= 4; ++size) {
// Create the output buffers.
scoped_array<uint8> rgb(new uint8[kWidth * size]);
@@ -109,14 +89,14 @@ TEST(YUVConvertTest, SideBySideRGB) {
// Check the output U pixels.
for (int i = 0; i < kWidth / 2; ++i) {
const uint8* p = &rgb[i * 2 * size];
- int error = ConvertRGBToU(p, size, kSubsampling) - u[i];
+ int error = ConvertRGBToU(p, size) - u[i];
total_error += error > 0 ? error : -error;
}
// Check the output V pixels.
for (int i = 0; i < kWidth / 2; ++i) {
const uint8* p = &rgb[i * 2 * size];
- int error = ConvertRGBToV(p, size, kSubsampling) - v[i];
+ int error = ConvertRGBToV(p, size) - v[i];
total_error += error > 0 ? error : -error;
}
}

Powered by Google App Engine
This is Rietveld 408576698