Commit fad2c659 authored by hkuang@chromium.org's avatar hkuang@chromium.org

Fix YUVConvert unittest failure on Android_X86.

This will also fix the WebRTC color bug fixed before on ARM:
https://codereview.chromium.org/17043007/

BUG=262319
TEST= Visit inear.se/bgra on Android_X86 phone. Color is right.
      Run media unittest on both ARM and x86, both passed.

Review URL: https://chromiumcodereview.appspot.com/23809010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222057 0039d316-1c4b-4281-b951-d872f2087c98
parent 16e43dd7
...@@ -21,6 +21,18 @@ namespace media { ...@@ -21,6 +21,18 @@ namespace media {
// Define a convenient macro to do static cast. // Define a convenient macro to do static cast.
#define INT16_FIX(x) static_cast<int16>(FIX(x)) #define INT16_FIX(x) static_cast<int16>(FIX(x))
// Android's pixel layout is RGBA, while other platforms
// are BGRA.
#if defined(OS_ANDROID)
SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = {
INT16_FIX(0.257), INT16_FIX(0.504), INT16_FIX(0.098), 0,
INT16_FIX(0.257), INT16_FIX(0.504), INT16_FIX(0.098), 0,
-INT16_FIX(0.148), -INT16_FIX(0.291), INT16_FIX(0.439), 0,
-INT16_FIX(0.148), -INT16_FIX(0.291), INT16_FIX(0.439), 0,
INT16_FIX(0.439), -INT16_FIX(0.368), -INT16_FIX(0.071), 0,
INT16_FIX(0.439), -INT16_FIX(0.368), -INT16_FIX(0.071), 0,
};
#else
SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = {
INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0,
INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0,
...@@ -29,6 +41,7 @@ SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { ...@@ -29,6 +41,7 @@ SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = {
-INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0,
-INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0,
}; };
#endif
#undef INT16_FIX #undef INT16_FIX
......
...@@ -20,31 +20,39 @@ namespace media { ...@@ -20,31 +20,39 @@ namespace media {
#define SK_G32_SHIFT 8 #define SK_G32_SHIFT 8
#define SK_B32_SHIFT 16 #define SK_B32_SHIFT 16
#define SK_A32_SHIFT 24 #define SK_A32_SHIFT 24
#define R_INDEX 0
#define G_INDEX 1
#define B_INDEX 2
#define A_INDEX 3
#else #else
#define SK_B32_SHIFT 0 #define SK_B32_SHIFT 0
#define SK_G32_SHIFT 8 #define SK_G32_SHIFT 8
#define SK_R32_SHIFT 16 #define SK_R32_SHIFT 16
#define SK_A32_SHIFT 24 #define SK_A32_SHIFT 24
#define B_INDEX 0
#define G_INDEX 1
#define R_INDEX 2
#define A_INDEX 3
#endif #endif
static inline void ConvertYUVToRGB32_C(uint8 y, static inline void ConvertYUVToRGB32_C(uint8 y,
uint8 u, uint8 u,
uint8 v, uint8 v,
uint8* rgb_buf) { uint8* rgb_buf) {
int b = kCoefficientsRgbY[256+u][0]; int b = kCoefficientsRgbY[256+u][B_INDEX];
int g = kCoefficientsRgbY[256+u][1]; int g = kCoefficientsRgbY[256+u][G_INDEX];
int r = kCoefficientsRgbY[256+u][2]; int r = kCoefficientsRgbY[256+u][R_INDEX];
int a = kCoefficientsRgbY[256+u][3]; int a = kCoefficientsRgbY[256+u][A_INDEX];
b = paddsw(b, kCoefficientsRgbY[512+v][0]); b = paddsw(b, kCoefficientsRgbY[512+v][B_INDEX]);
g = paddsw(g, kCoefficientsRgbY[512+v][1]); g = paddsw(g, kCoefficientsRgbY[512+v][G_INDEX]);
r = paddsw(r, kCoefficientsRgbY[512+v][2]); r = paddsw(r, kCoefficientsRgbY[512+v][R_INDEX]);
a = paddsw(a, kCoefficientsRgbY[512+v][3]); a = paddsw(a, kCoefficientsRgbY[512+v][A_INDEX]);
b = paddsw(b, kCoefficientsRgbY[y][0]); b = paddsw(b, kCoefficientsRgbY[y][B_INDEX]);
g = paddsw(g, kCoefficientsRgbY[y][1]); g = paddsw(g, kCoefficientsRgbY[y][G_INDEX]);
r = paddsw(r, kCoefficientsRgbY[y][2]); r = paddsw(r, kCoefficientsRgbY[y][R_INDEX]);
a = paddsw(a, kCoefficientsRgbY[y][3]); a = paddsw(a, kCoefficientsRgbY[y][A_INDEX]);
b >>= 6; b >>= 6;
g >>= 6; g >>= 6;
......
...@@ -17,20 +17,42 @@ extern "C" { ...@@ -17,20 +17,42 @@ extern "C" {
// Defines the R,G,B,A contributions from U. // Defines the R,G,B,A contributions from U.
// The contribution to A is the same for any value of U // The contribution to A is the same for any value of U
// causing the final A value to be 255 in every conversion. // causing the final A value to be 255 in every conversion.
// Android's pixel layout is RGBA, while other platforms
// are BGRA.
#if defined(OS_ANDROID)
#define RGBU(i) { \
0, \
static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \
static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \
static_cast<int16>(256 * 64 - 1) \
}
#else
#define RGBU(i) { \ #define RGBU(i) { \
static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \ static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \
static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \ static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \
0, \ 0, \
static_cast<int16>(256 * 64 - 1) \ static_cast<int16>(256 * 64 - 1) \
} }
#endif
// Defines the R,G,B,A contributions from V. // Defines the R,G,B,A contributions from V.
// Android's pixel layout is RGBA, while other platforms
// are BGRA.
#if defined(OS_ANDROID)
#define RGBV(i) { \
static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \
static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \
0, \
0 \
}
#else
#define RGBV(i) { \ #define RGBV(i) { \
0, \ 0, \
static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \ static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \
static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \ static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \
0 \ 0 \
} }
#endif
// Used to define a set of multiplier words for each alpha level. // Used to define a set of multiplier words for each alpha level.
#define ALPHA(i) { \ #define ALPHA(i) { \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment