OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #define INT16_FIX(x) static_cast<int16>(FIX(x)) |
20 | 21 |
21 SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { | 22 SIMD_ALIGNED(const int16 ConvertRGBAToYUV_kTable[8 * 3]) = { |
22 FIX(0.098), FIX(0.504), FIX(0.257), 0, | 23 INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, |
23 FIX(0.098), FIX(0.504), FIX(0.257), 0, | 24 INT16_FIX(0.098), INT16_FIX(0.504), INT16_FIX(0.257), 0, |
24 FIX(0.439), -FIX(0.291), -FIX(0.148), 0, | 25 INT16_FIX(0.439), -INT16_FIX(0.291), -INT16_FIX(0.148), 0, |
25 FIX(0.439), -FIX(0.291), -FIX(0.148), 0, | 26 INT16_FIX(0.439), -INT16_FIX(0.291), -INT16_FIX(0.148), 0, |
26 -FIX(0.071), -FIX(0.368), FIX(0.439), 0, | 27 -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, |
27 -FIX(0.071), -FIX(0.368), FIX(0.439), 0, | 28 -INT16_FIX(0.071), -INT16_FIX(0.368), INT16_FIX(0.439), 0, |
28 }; | 29 }; |
29 | 30 |
30 // This is the final offset for the conversion from signed yuv values to | 31 // This is the final offset for the conversion from signed yuv values to |
31 // unsigned values. It is arranged so that offset of 16 is applied to Y | 32 // unsigned values. It is arranged so that offset of 16 is applied to Y |
32 // components and 128 is added to UV components for 2 pixels. | 33 // components and 128 is added to UV components for 2 pixels. |
33 SIMD_ALIGNED(const int32 kYOffset[4]) = {16, 16, 16, 16}; | 34 SIMD_ALIGNED(const int32 kYOffset[4]) = {16, 16, 16, 16}; |
34 | 35 |
35 static inline int Clamp(int value) { | 36 static inline int Clamp(int value) { |
36 if (value < 0) | 37 if (value < 0) |
37 return 0; | 38 return 0; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 ++vplane; | 384 ++vplane; |
384 width -= 2; | 385 width -= 2; |
385 } | 386 } |
386 | 387 |
387 // Handle the last pixel in the last row. | 388 // Handle the last pixel in the last row. |
388 if (width) | 389 if (width) |
389 ConvertRGBToYUV_V1H1(rgbframe, yplane, uplane, vplane); | 390 ConvertRGBToYUV_V1H1(rgbframe, yplane, uplane, vplane); |
390 } | 391 } |
391 | 392 |
392 } // namespace media | 393 } // namespace media |
OLD | NEW |