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 "media/base/simd/convert_yuv_to_rgb.h" | 5 #include "media/base/simd/convert_yuv_to_rgb.h" |
6 #include "media/base/simd/yuv_to_rgb_table.h" | 6 #include "media/base/simd/yuv_to_rgb_table.h" |
7 | 7 |
8 #define packuswb(x) ((x) < 0 ? 0 : ((x) > 255 ? 255 : (x))) | 8 #define packuswb(x) ((x) < 0 ? 0 : ((x) > 255 ? 255 : (x))) |
9 #define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \ | 9 #define paddsw(x, y) (((x) + (y)) < -32768 ? -32768 : \ |
10 (((x) + (y)) > 32767 ? 32767 : ((x) + (y)))) | 10 (((x) + (y)) > 32767 ? 32767 : ((x) + (y)))) |
(...skipping 21 matching lines...) Expand all Loading... |
32 g >>= 6; | 32 g >>= 6; |
33 r >>= 6; | 33 r >>= 6; |
34 a >>= 6; | 34 a >>= 6; |
35 | 35 |
36 *reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b)) | | 36 *reinterpret_cast<uint32*>(rgb_buf) = (packuswb(b)) | |
37 (packuswb(g) << 8) | | 37 (packuswb(g) << 8) | |
38 (packuswb(r) << 16) | | 38 (packuswb(r) << 16) | |
39 (packuswb(a) << 24); | 39 (packuswb(a) << 24); |
40 } | 40 } |
41 | 41 |
42 // 16.16 fixed point arithmetic | |
43 const int kFractionBits = 16; | |
44 const int kFractionMax = 1 << kFractionBits; | |
45 const int kFractionMask = ((1 << kFractionBits) - 1); | |
46 | |
47 extern "C" { | 42 extern "C" { |
48 | 43 |
49 void ConvertYUVToRGB32Row_C(const uint8* y_buf, | 44 void ConvertYUVToRGB32Row_C(const uint8* y_buf, |
50 const uint8* u_buf, | 45 const uint8* u_buf, |
51 const uint8* v_buf, | 46 const uint8* v_buf, |
52 uint8* rgb_buf, | 47 uint8* rgb_buf, |
53 int width) { | 48 int width) { |
54 for (int x = 0; x < width; x += 2) { | 49 for (int x = 0; x < width; x += 2) { |
55 uint8 u = u_buf[x >> 1]; | 50 uint8 u = u_buf[x >> 1]; |
56 uint8 v = v_buf[x >> 1]; | 51 uint8 v = v_buf[x >> 1]; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 155 |
161 ConvertYUVToRGB32Row_C(y_ptr, | 156 ConvertYUVToRGB32Row_C(y_ptr, |
162 u_ptr, | 157 u_ptr, |
163 v_ptr, | 158 v_ptr, |
164 rgb_row, | 159 rgb_row, |
165 width); | 160 width); |
166 } | 161 } |
167 } | 162 } |
168 | 163 |
169 } // namespace media | 164 } // namespace media |
OLD | NEW |