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

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

Issue 17043007: Fix the WebRTC color bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test error on Android. Created 7 years, 6 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_yuv_to_rgb_c.cc
diff --git a/media/base/simd/convert_yuv_to_rgb_c.cc b/media/base/simd/convert_yuv_to_rgb_c.cc
index f04a89dbf9c7eb97825a37ff5ddf5c35164fca0f..b8ebd1eeb12981239d23d7727730f72623f9039d 100644
--- a/media/base/simd/convert_yuv_to_rgb_c.cc
+++ b/media/base/simd/convert_yuv_to_rgb_c.cc
@@ -11,6 +11,22 @@ namespace media {
#define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \
(((x) + (y)) > 32767 ? 32767 : ((x) + (y))))
+// On Android, pixel layout is RGBA (see skia/include/core/SkColorPriv.h);
+// however, other Chrome platforms use BGRA (see skia/config/SkUserConfig.h).
+// Ideally, android should not use the functions here due to performance issue
+// (http://crbug.com/249980).
+#if defined(OS_ANDROID)
+#define SK_R32_SHIFT 0
+#define SK_G32_SHIFT 8
+#define SK_B32_SHIFT 16
+#define SK_A32_SHIFT 24
+#else
+#define SK_B32_SHIFT 0
+#define SK_G32_SHIFT 8
+#define SK_R32_SHIFT 16
+#define SK_A32_SHIFT 24
+#endif
+
static inline void ConvertYUVToRGB32_C(uint8 y,
uint8 u,
uint8 v,
@@ -35,10 +51,10 @@ static inline void ConvertYUVToRGB32_C(uint8 y,
r >>= 6;
a >>= 6;
- *reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b)) |
- (packuswb(g) << 8) |
- (packuswb(r) << 16) |
- (packuswb(a) << 24);
+ *reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b) << SK_B32_SHIFT) |
+ (packuswb(g) << SK_G32_SHIFT) |
+ (packuswb(r) << SK_R32_SHIFT) |
+ (packuswb(a) << SK_A32_SHIFT);
}
static inline void ConvertYUVAToARGB_C(uint8 y,
@@ -66,7 +82,10 @@ static inline void ConvertYUVAToARGB_C(uint8 y,
g = packuswb(g) * a >> 8;
r = packuswb(r) * a >> 8;
- *reinterpret_cast<uint32*>(rgb_buf) = b | (g << 8) | (r << 16) | (a << 24);
+ *reinterpret_cast<uint32*>(rgb_buf) = (b << SK_B32_SHIFT) |
+ (g << SK_G32_SHIFT) |
+ (r << SK_R32_SHIFT) |
+ (a << SK_A32_SHIFT);
}
void ConvertYUVToRGB32Row_C(const uint8* y_buf,

Powered by Google App Engine
This is Rietveld 408576698