diff options
author | Ben Murdoch <benm@google.com> | 2013-07-10 11:40:50 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2013-07-10 11:40:50 +0100 |
commit | eb525c5499e34cc9c4b825d6d9e75bb07cc06ace (patch) | |
tree | d908ce4bfe1717d2cd53f41327d8b9ba8304355f /media/base/simd | |
parent | 3c54152607de4272b3da0c146b71dcba8a0e5610 (diff) | |
download | chromium_org-eb525c5499e34cc9c4b825d6d9e75bb07cc06ace.tar.gz |
Merge from Chromium at DEPS revision r210036
This commit was generated by merge_to_master.py.
Change-Id: Ib0e33a83ad5dfa541481e83d7acfc6970e68f471
Diffstat (limited to 'media/base/simd')
-rw-r--r-- | media/base/simd/convert_rgb_to_yuv_c.cc | 23 | ||||
-rw-r--r-- | media/base/simd/convert_yuv_to_rgb_c.cc | 29 |
2 files changed, 40 insertions, 12 deletions
diff --git a/media/base/simd/convert_rgb_to_yuv_c.cc b/media/base/simd/convert_rgb_to_yuv_c.cc index ae4c7313cd..4917d37bf3 100644 --- a/media/base/simd/convert_rgb_to_yuv_c.cc +++ b/media/base/simd/convert_rgb_to_yuv_c.cc @@ -24,20 +24,29 @@ void ConvertRGB32ToYUV_C(const uint8* rgbframe, int rgbstride, int ystride, int uvstride) { +#if defined(OS_ANDROID) + const int r = 0; + const int g = 1; + const int b = 2; +#else + const int r = 2; + const int g = 1; + const int b = 0; +#endif + for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { // Since the input pixel format is RGB32, there are 4 bytes per pixel. const uint8* pixel = rgbframe + 4 * j; - yplane[j] = clip_byte(((pixel[2] * 66 + pixel[1] * 129 + - pixel[0] * 25 + 128) >> 8) + 16); + yplane[j] = clip_byte(((pixel[r] * 66 + pixel[g] * 129 + + pixel[b] * 25 + 128) >> 8) + 16); if (i % 2 == 0 && j % 2 == 0) { - uplane[j / 2] = clip_byte(((pixel[2] * -38 + pixel[1] * -74 + - pixel[0] * 112 + 128) >> 8) + 128); - vplane[j / 2] = clip_byte(((pixel[2] * 112 + pixel[1] * -94 + - pixel[0] * -18 + 128) >> 8) + 128); + uplane[j / 2] = clip_byte(((pixel[r] * -38 + pixel[g] * -74 + + pixel[b] * 112 + 128) >> 8) + 128); + vplane[j / 2] = clip_byte(((pixel[r] * 112 + pixel[g] * -94 + + pixel[b] * -18 + 128) >> 8) + 128); } } - rgbframe += rgbstride; yplane += ystride; if (i % 2 == 0) { diff --git a/media/base/simd/convert_yuv_to_rgb_c.cc b/media/base/simd/convert_yuv_to_rgb_c.cc index f04a89dbf9..b8ebd1eeb1 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, |