Chromium Code Reviews| 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 db6e557d28b8e2187f2ff0c89bc0047b25b46fa7..fdcadcd55c32859a2176b5b21db8682211947084 100644 |
| --- a/media/base/simd/convert_yuv_to_rgb_c.cc |
| +++ b/media/base/simd/convert_yuv_to_rgb_c.cc |
| @@ -39,6 +39,39 @@ static inline void ConvertYUVToRGB32_C(uint8 y, |
| (packuswb(a) << 24); |
| } |
| +static inline void ConvertYUVAToARGB_C(uint8 y, |
| + uint8 u, |
| + uint8 v, |
| + uint8 a, |
| + uint8* rgb_buf) { |
| + int b = kCoefficientsRgbY[256+u][0]; |
| + int g = kCoefficientsRgbY[256+u][1]; |
| + int r = kCoefficientsRgbY[256+u][2]; |
| + |
| + b = paddsw(b, kCoefficientsRgbY[512+v][0]); |
| + g = paddsw(g, kCoefficientsRgbY[512+v][1]); |
| + r = paddsw(r, kCoefficientsRgbY[512+v][2]); |
| + |
| + b = paddsw(b, kCoefficientsRgbY[y][0]); |
| + g = paddsw(g, kCoefficientsRgbY[y][1]); |
| + r = paddsw(r, kCoefficientsRgbY[y][2]); |
| + |
| + b >>= 6; |
| + g >>= 6; |
| + r >>= 6; |
| + |
| + b = packuswb(b) * a >> 8; |
| + g = packuswb(g) * a >> 8; |
| + r = packuswb(r) * a >> 8; |
| + |
| + *reinterpret_cast<uint32*>(rgb_buf) = b | (g << 8) | (r << 16) | (a << 24); |
| +} |
| + |
| +// 16.16 fixed point arithmetic |
| +const int kFractionBits = 16; |
| +const int kFractionMax = 1 << kFractionBits; |
| +const int kFractionMask = ((1 << kFractionBits) - 1); |
| + |
| extern "C" { |
| void ConvertYUVToRGB32Row_C(const uint8* y_buf, |
| @@ -59,6 +92,27 @@ void ConvertYUVToRGB32Row_C(const uint8* y_buf, |
| } |
| } |
| +void ConvertYUVAToARGBRow_C(const uint8* y_buf, |
| + const uint8* u_buf, |
| + const uint8* v_buf, |
| + const uint8* a_buf, |
| + uint8* rgba_buf, |
| + int width) { |
| + for (int x = 0; x < width; x = 2) { |
|
fgalligan1
2013/02/12 01:20:58
I think it should be x += 2.
vigneshv
2013/02/14 19:06:14
Done.
|
| + uint8 u = u_buf[x >> 1]; |
| + uint8 v = v_buf[x >> 1]; |
| + uint8 y0 = y_buf[x]; |
| + uint8 a0 = a_buf[x]; |
| + ConvertYUVAToARGB_C(y0, u, v, a0, rgba_buf); |
| + if ((x + 1) < width) { |
| + uint8 y1 = y_buf[x + 1]; |
| + uint8 a1 = a_buf[x + 1]; |
| + ConvertYUVAToARGB_C(y1, u, v, a1, rgba_buf + 4); |
| + } |
| + rgba_buf += 8; // Advance 2 pixels. |
| + } |
| +} |
| + |
| // 16.16 fixed point is used. A shift by 16 isolates the integer. |
| // A shift by 17 is used to further subsample the chrominence channels. |
| // & 0xffff isolates the fixed point fraction. >> 2 to get the upper 2 bits, |
| @@ -161,4 +215,33 @@ void ConvertYUVToRGB32_C(const uint8* yplane, |
| } |
| } |
| +void ConvertYUVAToARGB_C(const uint8* yplane, |
| + const uint8* uplane, |
| + const uint8* vplane, |
| + const uint8* aplane, |
| + uint8* rgbaframe, |
| + int width, |
| + int height, |
| + int ystride, |
| + int uvstride, |
| + int astride, |
| + int rgbastride, |
| + YUVType yuv_type) { |
| + unsigned int y_shift = yuv_type; |
| + for (int y = 0; y < height; y++) { |
| + uint8* rgba_row = rgbaframe + y * rgbastride; |
| + const uint8* y_ptr = yplane + y * ystride; |
| + const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; |
| + const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; |
| + const uint8* a_ptr = aplane + y * astride; |
| + |
| + ConvertYUVAToARGBRow_C(y_ptr, |
| + u_ptr, |
| + v_ptr, |
| + a_ptr, |
| + rgba_row, |
| + width); |
| + } |
| +} |
| + |
| } // namespace media |