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

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: Addressing Andrew's comments. 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e3a16f442bcb9936ab0a70a03e2bc7cd1d730c51 100644
--- a/media/base/simd/convert_yuv_to_rgb_c.cc
+++ b/media/base/simd/convert_yuv_to_rgb_c.cc
@@ -11,6 +11,24 @@ namespace media {
#define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \
(((x) + (y)) > 32767 ? 32767 : ((x) + (y))))
+// On Android, pixel layout is RGBA
+// (see third_party/skia/include/core/SkColorPriv.h);
+// however, other Chrome platforms use BGRA
+// (see skia/config/SkUserConfig.h).
+// Ideally, android should not use the function here
+// due to performance issue(crbug/249980).
scherkus (not reviewing) 2013/06/15 00:31:56 nit: can you better format this comment? for exam
hkuang1 2013/06/15 00:54:01 Done.
+#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 +53,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 +84,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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698