OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 #include "media/base/simd/convert_rgb_to_yuv.h" | 6 #include "media/base/simd/convert_rgb_to_yuv.h" |
7 #include "media/base/simd/yuv_to_rgb_table.h" | 7 #include "media/base/simd/yuv_to_rgb_table.h" |
8 | 8 |
9 #if defined(COMPILER_MSVC) | 9 #if defined(COMPILER_MSVC) |
10 #include <intrin.h> | 10 #include <intrin.h> |
11 #else | 11 #else |
12 #include <mmintrin.h> | 12 #include <mmintrin.h> |
13 #include <emmintrin.h> | 13 #include <emmintrin.h> |
14 #endif | 14 #endif |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 #define FIX_SHIFT 12 | 18 #define FIX_SHIFT 12 |
19 #define FIX(x) ((x) * (1 << FIX_SHIFT)) | 19 #define FIX(x) ((x) * (1 << FIX_SHIFT)) |
20 | 20 |
21 // Define a convenient macro to do static cast. | 21 // Define a convenient macro to do static cast. |
22 #define INT16_FIX(x) static_cast<int16>(FIX(x)) | 22 #define INT16_FIX(x) static_cast<int16>(FIX(x)) |
23 | 23 |
| 24 // Android's pixel layout is RGBA, while other platforms |
| 25 // are BGRA. |
| 26 #if defined(OS_ANDROID) |
| 27 SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { |
| 28 INT16_FIX(0.257), INT16_FIX(0.504), INT16_FIX(0.098), 0, |
| 29 INT16_FIX(0.257), INT16_FIX(0.504), INT16_FIX(0.098), 0, |
| 30 -INT16_FIX(0.148), -INT16_FIX(0.291), INT16_FIX(0.439), 0, |
| 31 -INT16_FIX(0.148), -INT16_FIX(0.291), INT16_FIX(0.439), 0, |
| 32 INT16_FIX(0.439), -INT16_FIX(0.368), -INT16_FIX(0.071), 0, |
| 33 INT16_FIX(0.439), -INT16_FIX(0.368), -INT16_FIX(0.071), 0, |
| 34 }; |
| 35 #else |
24 SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { | 36 SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { |
25 INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, | 37 INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, |
26 INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, | 38 INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, |
27 INT16_FIX(0.439), -INT16_FIX(0.291), -INT16_FIX(0.148), 0, | 39 INT16_FIX(0.439), -INT16_FIX(0.291), -INT16_FIX(0.148), 0, |
28 INT16_FIX(0.439), -INT16_FIX(0.291), -INT16_FIX(0.148), 0, | 40 INT16_FIX(0.439), -INT16_FIX(0.291), -INT16_FIX(0.148), 0, |
29 -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, | 41 -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, |
30 -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, | 42 -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, |
31 }; | 43 }; |
| 44 #endif |
32 | 45 |
33 #undef INT16_FIX | 46 #undef INT16_FIX |
34 | 47 |
35 // This is the final offset for the conversion from signed yuv values to | 48 // This is the final offset for the conversion from signed yuv values to |
36 // unsigned values. It is arranged so that offset of 16 is applied to Y | 49 // unsigned values. It is arranged so that offset of 16 is applied to Y |
37 // components and 128 is added to UV components for 2 pixels. | 50 // components and 128 is added to UV components for 2 pixels. |
38 SIMD_ALIGNED(const int32 kYOffset[4]) = {16, 16, 16, 16}; | 51 SIMD_ALIGNED(const int32 kYOffset[4]) = {16, 16, 16, 16}; |
39 | 52 |
40 static inline int Clamp(int value) { | 53 static inline int Clamp(int value) { |
41 if (value < 0) | 54 if (value < 0) |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 ++vplane; | 401 ++vplane; |
389 width -= 2; | 402 width -= 2; |
390 } | 403 } |
391 | 404 |
392 // Handle the last pixel in the last row. | 405 // Handle the last pixel in the last row. |
393 if (width) | 406 if (width) |
394 ConvertRGBToYUV_V1H1(rgbframe, yplane, uplane, vplane); | 407 ConvertRGBToYUV_V1H1(rgbframe, yplane, uplane, vplane); |
395 } | 408 } |
396 | 409 |
397 } // namespace media | 410 } // namespace media |
OLD | NEW |