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_rgb_to_yuv.h" | 5 #include "media/base/simd/convert_rgb_to_yuv.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "media/base/simd/convert_rgb_to_yuv_ssse3.h" | 8 #include "media/base/simd/convert_rgb_to_yuv_ssse3.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 void ConvertRGB32ToYUV_SSSE3(const uint8* rgbframe, | 12 void ConvertRGB32ToYUV_SSSE3(const uint8* rgbframe, |
13 uint8* yplane, | 13 uint8* yplane, |
14 uint8* uplane, | 14 uint8* uplane, |
15 uint8* vplane, | 15 uint8* vplane, |
16 int width, | 16 int width, |
17 int height, | 17 int height, |
18 int rgbstride, | 18 int rgbstride, |
19 int ystride, | 19 int ystride, |
20 int uvstride) { | 20 int uvstride) { |
21 #ifdef ENABLE_SUBSAMPLING | |
22 for (; height >= 2; height -= 2) { | |
23 ConvertARGBToYUVEven_SSSE3(rgbframe, yplane, uplane, vplane, width); | |
24 rgbframe += rgbstride; | |
25 yplane += ystride; | |
26 | |
27 ConvertARGBToYUVOdd_SSSE3(rgbframe, yplane, uplane, vplane, width); | |
28 rgbframe += rgbstride; | |
29 yplane += ystride; | |
30 | |
31 uplane += uvstride; | |
32 vplane += uvstride; | |
33 } | |
34 | |
35 if (height) | |
36 ConvertARGBToYUVEven_SSSE3(rgbframe, yplane, uplane, vplane, width); | |
37 #else | |
38 for (; height >= 2; height -= 2) { | 21 for (; height >= 2; height -= 2) { |
39 ConvertARGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); | 22 ConvertARGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); |
40 rgbframe += rgbstride; | 23 rgbframe += rgbstride; |
41 yplane += ystride; | 24 yplane += ystride; |
42 | 25 |
43 ConvertARGBToYUVRow_SSSE3(rgbframe, yplane, NULL, NULL, width); | 26 ConvertARGBToYUVRow_SSSE3(rgbframe, yplane, NULL, NULL, width); |
44 rgbframe += rgbstride; | 27 rgbframe += rgbstride; |
45 yplane += ystride; | 28 yplane += ystride; |
46 | 29 |
47 uplane += uvstride; | 30 uplane += uvstride; |
48 vplane += uvstride; | 31 vplane += uvstride; |
49 } | 32 } |
50 | 33 |
51 if (height) | 34 if (height) |
52 ConvertARGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); | 35 ConvertARGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); |
53 #endif | |
54 } | 36 } |
55 | 37 |
56 void ConvertRGB24ToYUV_SSSE3(const uint8* rgbframe, | 38 void ConvertRGB24ToYUV_SSSE3(const uint8* rgbframe, |
57 uint8* yplane, | 39 uint8* yplane, |
58 uint8* uplane, | 40 uint8* uplane, |
59 uint8* vplane, | 41 uint8* vplane, |
60 int width, | 42 int width, |
61 int height, | 43 int height, |
62 int rgbstride, | 44 int rgbstride, |
63 int ystride, | 45 int ystride, |
64 int uvstride) { | 46 int uvstride) { |
65 #ifdef ENABLE_SUBSAMPLING | |
66 for (; height >= 2; height -= 2) { | |
67 ConvertRGBToYUVEven_SSSE3(rgbframe, yplane, uplane, vplane, width); | |
68 rgbframe += rgbstride; | |
69 yplane += ystride; | |
70 | |
71 ConvertRGBToYUVOdd_SSSE3(rgbframe, yplane, uplane, vplane, width); | |
72 rgbframe += rgbstride; | |
73 yplane += ystride; | |
74 | |
75 uplane += uvstride; | |
76 vplane += uvstride; | |
77 } | |
78 | |
79 if (height) | |
80 ConvertRGBToYUVEven_SSSE3(rgbframe, yplane, uplane, vplane, width); | |
81 #else | |
82 for (; height >= 2; height -= 2) { | 47 for (; height >= 2; height -= 2) { |
83 ConvertRGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); | 48 ConvertRGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); |
84 rgbframe += rgbstride; | 49 rgbframe += rgbstride; |
85 yplane += ystride; | 50 yplane += ystride; |
86 | 51 |
87 ConvertRGBToYUVRow_SSSE3(rgbframe, yplane, NULL, NULL, width); | 52 ConvertRGBToYUVRow_SSSE3(rgbframe, yplane, NULL, NULL, width); |
88 rgbframe += rgbstride; | 53 rgbframe += rgbstride; |
89 yplane += ystride; | 54 yplane += ystride; |
90 | 55 |
91 uplane += uvstride; | 56 uplane += uvstride; |
92 vplane += uvstride; | 57 vplane += uvstride; |
93 } | 58 } |
94 | 59 |
95 if (height) | 60 if (height) |
96 ConvertRGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); | 61 ConvertRGBToYUVRow_SSSE3(rgbframe, yplane, uplane, vplane, width); |
97 #endif | |
98 } | 62 } |
99 | 63 |
100 } // namespace media | 64 } // namespace media |
OLD | NEW |