OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "media/base/simd/yuv_to_rgb_table.h" | 5 #include "media/base/simd/yuv_to_rgb_table.h" |
6 | 6 |
7 extern "C" { | 7 extern "C" { |
8 | 8 |
9 // Defines the R,G,B,A contributions from Y. | 9 // Defines the R,G,B,A contributions from Y. |
10 #define RGBY(i) { \ | 10 #define RGBY(i) { \ |
11 static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ | 11 static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ |
12 static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ | 12 static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ |
13 static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ | 13 static_cast<int16>(1.164 * 64 * (i - 16) + 0.5), \ |
14 0 \ | 14 0 \ |
15 } | 15 } |
16 | 16 |
17 // Defines the R,G,B,A contributions from U. | 17 // Defines the R,G,B,A contributions from U. |
18 // The contribution to A is the same for any value of U | 18 // The contribution to A is the same for any value of U |
19 // causing the final A value to be 255 in every conversion. | 19 // causing the final A value to be 255 in every conversion. |
| 20 // Android's pixel layout is RGBA, while other platforms |
| 21 // are BGRA. |
| 22 #if defined(OS_ANDROID) |
| 23 #define RGBU(i) { \ |
| 24 0, \ |
| 25 static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \ |
| 26 static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \ |
| 27 static_cast<int16>(256 * 64 - 1) \ |
| 28 } |
| 29 #else |
20 #define RGBU(i) { \ | 30 #define RGBU(i) { \ |
21 static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \ | 31 static_cast<int16>(2.018 * 64 * (i - 128) + 0.5), \ |
22 static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \ | 32 static_cast<int16>(-0.391 * 64 * (i - 128) + 0.5), \ |
23 0, \ | 33 0, \ |
24 static_cast<int16>(256 * 64 - 1) \ | 34 static_cast<int16>(256 * 64 - 1) \ |
25 } | 35 } |
| 36 #endif |
26 | 37 |
27 // Defines the R,G,B,A contributions from V. | 38 // Defines the R,G,B,A contributions from V. |
| 39 // Android's pixel layout is RGBA, while other platforms |
| 40 // are BGRA. |
| 41 #if defined(OS_ANDROID) |
| 42 #define RGBV(i) { \ |
| 43 static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \ |
| 44 static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \ |
| 45 0, \ |
| 46 0 \ |
| 47 } |
| 48 #else |
28 #define RGBV(i) { \ | 49 #define RGBV(i) { \ |
29 0, \ | 50 0, \ |
30 static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \ | 51 static_cast<int16>(-0.813 * 64 * (i - 128) + 0.5), \ |
31 static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \ | 52 static_cast<int16>(1.596 * 64 * (i - 128) + 0.5), \ |
32 0 \ | 53 0 \ |
33 } | 54 } |
| 55 #endif |
34 | 56 |
35 // Used to define a set of multiplier words for each alpha level. | 57 // Used to define a set of multiplier words for each alpha level. |
36 #define ALPHA(i) { \ | 58 #define ALPHA(i) { \ |
37 i, i, i, i \ | 59 i, i, i, i \ |
38 } | 60 } |
39 | 61 |
40 // The following table defines the RGBA contributions | 62 // The following table defines the RGBA contributions |
41 // for each component of YUVA. The Y table is first followed | 63 // for each component of YUVA. The Y table is first followed |
42 // by the U, and V tables. The alpha multiplier table follows. | 64 // by the U, and V tables. The alpha multiplier table follows. |
43 // These tables are aligned and kept adjacent to optimize for | 65 // These tables are aligned and kept adjacent to optimize for |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 ALPHA(0xF8), ALPHA(0xF9), ALPHA(0xFA), ALPHA(0xFB), | 329 ALPHA(0xF8), ALPHA(0xF9), ALPHA(0xFA), ALPHA(0xFB), |
308 ALPHA(0xFC), ALPHA(0xFD), ALPHA(0xFE), ALPHA(0xFF), | 330 ALPHA(0xFC), ALPHA(0xFD), ALPHA(0xFE), ALPHA(0xFF), |
309 }; | 331 }; |
310 | 332 |
311 #undef RGBY | 333 #undef RGBY |
312 #undef RGBU | 334 #undef RGBU |
313 #undef RGBV | 335 #undef RGBV |
314 #undef ALPHA | 336 #undef ALPHA |
315 | 337 |
316 } // extern "C" | 338 } // extern "C" |
OLD | NEW |