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 #if defined(_MSC_VER) | 5 #if defined(_MSC_VER) |
6 #include <intrin.h> | 6 #include <intrin.h> |
7 #else | 7 #else |
8 #include <mmintrin.h> | 8 #include <mmintrin.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "media/base/simd/convert_yuv_to_rgb.h" | 11 #include "media/base/simd/convert_yuv_to_rgb.h" |
12 #include "media/base/simd/yuv_to_rgb_table.h" | |
13 #include "media/base/yuv_convert.h" | 12 #include "media/base/yuv_convert.h" |
14 | 13 |
15 namespace media { | 14 namespace media { |
16 | 15 |
17 void ConvertYUVToRGB32_MMX(const uint8* yplane, | 16 void ConvertYUVToRGB32_MMX(const uint8* yplane, |
18 const uint8* uplane, | 17 const uint8* uplane, |
19 const uint8* vplane, | 18 const uint8* vplane, |
20 uint8* rgbframe, | 19 uint8* rgbframe, |
21 int width, | 20 int width, |
22 int height, | 21 int height, |
23 int ystride, | 22 int ystride, |
24 int uvstride, | 23 int uvstride, |
25 int rgbstride, | 24 int rgbstride, |
26 YUVType yuv_type) { | 25 YUVType yuv_type) { |
27 unsigned int y_shift = GetVerticalShift(yuv_type); | 26 unsigned int y_shift = yuv_type; |
28 for (int y = 0; y < height; ++y) { | 27 for (int y = 0; y < height; ++y) { |
29 uint8* rgb_row = rgbframe + y * rgbstride; | 28 uint8* rgb_row = rgbframe + y * rgbstride; |
30 const uint8* y_ptr = yplane + y * ystride; | 29 const uint8* y_ptr = yplane + y * ystride; |
31 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; | 30 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; |
32 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; | 31 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; |
33 | 32 |
34 ConvertYUVToRGB32Row_MMX(y_ptr, | 33 ConvertYUVToRGB32Row_MMX(y_ptr, |
35 u_ptr, | 34 u_ptr, |
36 v_ptr, | 35 v_ptr, |
37 rgb_row, | 36 rgb_row, |
38 width, | 37 width); |
39 GetLookupTable(yuv_type)); | |
40 } | 38 } |
41 | 39 |
42 EmptyRegisterState(); | 40 EmptyRegisterState(); |
43 } | 41 } |
44 | 42 |
45 void ConvertYUVAToARGB_MMX(const uint8* yplane, | 43 void ConvertYUVAToARGB_MMX(const uint8* yplane, |
46 const uint8* uplane, | 44 const uint8* uplane, |
47 const uint8* vplane, | 45 const uint8* vplane, |
48 const uint8* aplane, | 46 const uint8* aplane, |
49 uint8* rgbframe, | 47 uint8* rgbframe, |
50 int width, | 48 int width, |
51 int height, | 49 int height, |
52 int ystride, | 50 int ystride, |
53 int uvstride, | 51 int uvstride, |
54 int astride, | 52 int astride, |
55 int rgbstride, | 53 int rgbstride, |
56 YUVType yuv_type) { | 54 YUVType yuv_type) { |
57 unsigned int y_shift = GetVerticalShift(yuv_type); | 55 unsigned int y_shift = yuv_type; |
58 for (int y = 0; y < height; ++y) { | 56 for (int y = 0; y < height; ++y) { |
59 uint8* rgb_row = rgbframe + y * rgbstride; | 57 uint8* rgb_row = rgbframe + y * rgbstride; |
60 const uint8* y_ptr = yplane + y * ystride; | 58 const uint8* y_ptr = yplane + y * ystride; |
61 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; | 59 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; |
62 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; | 60 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; |
63 const uint8* a_ptr = aplane + y * astride; | 61 const uint8* a_ptr = aplane + y * astride; |
64 | 62 |
65 ConvertYUVAToARGBRow_MMX(y_ptr, | 63 ConvertYUVAToARGBRow_MMX(y_ptr, |
66 u_ptr, | 64 u_ptr, |
67 v_ptr, | 65 v_ptr, |
68 a_ptr, | 66 a_ptr, |
69 rgb_row, | 67 rgb_row, |
70 width, | 68 width); |
71 GetLookupTable(yuv_type)); | |
72 } | 69 } |
73 | 70 |
74 EmptyRegisterState(); | 71 EmptyRegisterState(); |
75 } | 72 } |
76 | 73 |
77 void ConvertYUVToRGB32_SSE(const uint8* yplane, | 74 void ConvertYUVToRGB32_SSE(const uint8* yplane, |
78 const uint8* uplane, | 75 const uint8* uplane, |
79 const uint8* vplane, | 76 const uint8* vplane, |
80 uint8* rgbframe, | 77 uint8* rgbframe, |
81 int width, | 78 int width, |
82 int height, | 79 int height, |
83 int ystride, | 80 int ystride, |
84 int uvstride, | 81 int uvstride, |
85 int rgbstride, | 82 int rgbstride, |
86 YUVType yuv_type) { | 83 YUVType yuv_type) { |
87 unsigned int y_shift = GetVerticalShift(yuv_type); | 84 unsigned int y_shift = yuv_type; |
88 for (int y = 0; y < height; ++y) { | 85 for (int y = 0; y < height; ++y) { |
89 uint8* rgb_row = rgbframe + y * rgbstride; | 86 uint8* rgb_row = rgbframe + y * rgbstride; |
90 const uint8* y_ptr = yplane + y * ystride; | 87 const uint8* y_ptr = yplane + y * ystride; |
91 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; | 88 const uint8* u_ptr = uplane + (y >> y_shift) * uvstride; |
92 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; | 89 const uint8* v_ptr = vplane + (y >> y_shift) * uvstride; |
93 | 90 |
94 ConvertYUVToRGB32Row_SSE(y_ptr, | 91 ConvertYUVToRGB32Row_SSE(y_ptr, |
95 u_ptr, | 92 u_ptr, |
96 v_ptr, | 93 v_ptr, |
97 rgb_row, | 94 rgb_row, |
98 width, | 95 width); |
99 GetLookupTable(yuv_type)); | |
100 } | 96 } |
101 | 97 |
102 EmptyRegisterState(); | 98 EmptyRegisterState(); |
103 } | 99 } |
104 | 100 |
105 } // namespace media | 101 } // namespace media |
OLD | NEW |