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 #ifndef MEDIA_BASE_YUV_CONVERT_H_ | 5 #ifndef MEDIA_BASE_YUV_CONVERT_H_ |
6 #define MEDIA_BASE_YUV_CONVERT_H_ | 6 #define MEDIA_BASE_YUV_CONVERT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "media/base/media_export.h" |
9 | 10 |
10 // Visual Studio 2010 does not support MMX intrinsics on x64. | 11 // Visual Studio 2010 does not support MMX intrinsics on x64. |
11 // Some win64 yuv_convert code paths use SSE+MMX yasm, so without rewriting | 12 // Some win64 yuv_convert code paths use SSE+MMX yasm, so without rewriting |
12 // them, we use yasm EmptyRegisterState_MMX in place of _mm_empty() or | 13 // them, we use yasm EmptyRegisterState_MMX in place of _mm_empty() or |
13 // hide the versions implemented with heavy use of MMX intrinsics. | 14 // hide the versions implemented with heavy use of MMX intrinsics. |
14 // TODO(wolenetz): Use MMX intrinsics when compiling win64 with Visual | 15 // TODO(wolenetz): Use MMX intrinsics when compiling win64 with Visual |
15 // Studio 2012? http://crbug.com/173450 | 16 // Studio 2012? http://crbug.com/173450 |
16 #if !(defined(ARCH_CPU_X86_64) && defined(COMPILER_MSVC)) | 17 #if !(defined(ARCH_CPU_X86_64) && defined(COMPILER_MSVC)) |
17 #define MEDIA_MMX_INTRINSICS_AVAILABLE | 18 #define MEDIA_MMX_INTRINSICS_AVAILABLE |
18 #endif | 19 #endif |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 | 22 |
22 // Type of YUV surface. | 23 // Type of YUV surface. |
23 // The value of these enums matter as they are used to shift vertical indices. | 24 // The value of these enums matter as they are used to shift vertical indices. |
24 enum YUVType { | 25 enum YUVType { |
25 YV16 = 0, // YV16 is half width and full height chroma channels. | 26 YV16 = 0, // YV16 is half width and full height chroma channels. |
26 YV12 = 1, // YV12 is half width and half height chroma channels. | 27 YV12 = 1, // YV12 is half width and half height chroma channels. |
27 }; | 28 }; |
28 | 29 |
29 // Mirror means flip the image horizontally, as in looking in a mirror. | 30 // Mirror means flip the image horizontally, as in looking in a mirror. |
30 // Rotate happens after mirroring. | 31 // Rotate happens after mirroring. |
31 enum Rotate { | 32 enum Rotate { |
32 ROTATE_0, // Rotation off. | 33 ROTATE_0, // Rotation off. |
33 ROTATE_90, // Rotate clockwise. | 34 ROTATE_90, // Rotate clockwise. |
34 ROTATE_180, // Rotate upside down. | 35 ROTATE_180, // Rotate upside down. |
35 ROTATE_270, // Rotate counter clockwise. | 36 ROTATE_270, // Rotate counter clockwise. |
36 MIRROR_ROTATE_0, // Mirror horizontally. | 37 MIRROR_ROTATE_0, // Mirror horizontally. |
37 MIRROR_ROTATE_90, // Mirror then Rotate clockwise. | 38 MIRROR_ROTATE_90, // Mirror then Rotate clockwise. |
38 MIRROR_ROTATE_180, // Mirror vertically. | 39 MIRROR_ROTATE_180, // Mirror vertically. |
39 MIRROR_ROTATE_270, // Transpose. | 40 MIRROR_ROTATE_270, // Transpose. |
40 }; | 41 }; |
41 | 42 |
42 // Filter affects how scaling looks. | 43 // Filter affects how scaling looks. |
43 enum ScaleFilter { | 44 enum ScaleFilter { |
44 FILTER_NONE = 0, // No filter (point sampled). | 45 FILTER_NONE = 0, // No filter (point sampled). |
45 FILTER_BILINEAR_H = 1, // Bilinear horizontal filter. | 46 FILTER_BILINEAR_H = 1, // Bilinear horizontal filter. |
46 FILTER_BILINEAR_V = 2, // Bilinear vertical filter. | 47 FILTER_BILINEAR_V = 2, // Bilinear vertical filter. |
47 FILTER_BILINEAR = 3, // Bilinear filter. | 48 FILTER_BILINEAR = 3, // Bilinear filter. |
48 }; | 49 }; |
49 | 50 |
50 // Convert a frame of YUV to 32 bit ARGB. | 51 // Convert a frame of YUV to 32 bit ARGB. |
51 // Pass in YV16/YV12 depending on source format | 52 // Pass in YV16/YV12 depending on source format |
52 void ConvertYUVToRGB32(const uint8* yplane, | 53 MEDIA_EXPORT void ConvertYUVToRGB32(const uint8* yplane, |
53 const uint8* uplane, | 54 const uint8* uplane, |
54 const uint8* vplane, | 55 const uint8* vplane, |
55 uint8* rgbframe, | 56 uint8* rgbframe, |
56 int width, | 57 int width, |
57 int height, | 58 int height, |
58 int ystride, | 59 int ystride, |
59 int uvstride, | 60 int uvstride, |
60 int rgbstride, | 61 int rgbstride, |
61 YUVType yuv_type); | 62 YUVType yuv_type); |
62 | 63 |
63 // Convert a frame of YUVA to 32 bit ARGB. | 64 // Convert a frame of YUVA to 32 bit ARGB. |
64 // Pass in YV12A | 65 // Pass in YV12A |
65 void ConvertYUVAToARGB(const uint8* yplane, | 66 MEDIA_EXPORT void ConvertYUVAToARGB(const uint8* yplane, |
66 const uint8* uplane, | 67 const uint8* uplane, |
67 const uint8* vplane, | 68 const uint8* vplane, |
68 const uint8* aplane, | 69 const uint8* aplane, |
69 uint8* rgbframe, | 70 uint8* rgbframe, |
70 int width, | 71 int width, |
71 int height, | 72 int height, |
72 int ystride, | 73 int ystride, |
73 int uvstride, | 74 int uvstride, |
74 int astride, | 75 int astride, |
75 int rgbstride, | 76 int rgbstride, |
76 YUVType yuv_type); | 77 YUVType yuv_type); |
77 | 78 |
78 // Scale a frame of YUV to 32 bit ARGB. | 79 // Scale a frame of YUV to 32 bit ARGB. |
79 // Supports rotation and mirroring. | 80 // Supports rotation and mirroring. |
80 void ScaleYUVToRGB32(const uint8* yplane, | 81 MEDIA_EXPORT void ScaleYUVToRGB32(const uint8* yplane, |
81 const uint8* uplane, | 82 const uint8* uplane, |
82 const uint8* vplane, | 83 const uint8* vplane, |
83 uint8* rgbframe, | 84 uint8* rgbframe, |
84 int source_width, | 85 int source_width, |
85 int source_height, | 86 int source_height, |
86 int width, | 87 int width, |
87 int height, | 88 int height, |
88 int ystride, | 89 int ystride, |
89 int uvstride, | 90 int uvstride, |
90 int rgbstride, | 91 int rgbstride, |
91 YUVType yuv_type, | 92 YUVType yuv_type, |
92 Rotate view_rotate, | 93 Rotate view_rotate, |
93 ScaleFilter filter); | 94 ScaleFilter filter); |
94 | 95 |
95 // Biliner Scale a frame of YV12 to 32 bits ARGB on a specified rectangle. | 96 // Biliner Scale a frame of YV12 to 32 bits ARGB on a specified rectangle. |
96 // |yplane|, etc and |rgbframe| should point to the top-left pixels of the | 97 // |yplane|, etc and |rgbframe| should point to the top-left pixels of the |
97 // source and destination buffers. | 98 // source and destination buffers. |
98 void ScaleYUVToRGB32WithRect(const uint8* yplane, | 99 MEDIA_EXPORT void ScaleYUVToRGB32WithRect(const uint8* yplane, |
99 const uint8* uplane, | 100 const uint8* uplane, |
100 const uint8* vplane, | 101 const uint8* vplane, |
101 uint8* rgbframe, | 102 uint8* rgbframe, |
102 int source_width, | 103 int source_width, |
103 int source_height, | 104 int source_height, |
104 int dest_width, | 105 int dest_width, |
105 int dest_height, | 106 int dest_height, |
106 int dest_rect_left, | 107 int dest_rect_left, |
107 int dest_rect_top, | 108 int dest_rect_top, |
108 int dest_rect_right, | 109 int dest_rect_right, |
109 int dest_rect_bottom, | 110 int dest_rect_bottom, |
110 int ystride, | 111 int ystride, |
111 int uvstride, | 112 int uvstride, |
112 int rgbstride); | 113 int rgbstride); |
113 | 114 |
114 void ConvertRGB32ToYUV(const uint8* rgbframe, | 115 MEDIA_EXPORT void ConvertRGB32ToYUV(const uint8* rgbframe, |
115 uint8* yplane, | 116 uint8* yplane, |
116 uint8* uplane, | 117 uint8* uplane, |
117 uint8* vplane, | 118 uint8* vplane, |
118 int width, | 119 int width, |
119 int height, | 120 int height, |
120 int rgbstride, | 121 int rgbstride, |
121 int ystride, | 122 int ystride, |
122 int uvstride); | 123 int uvstride); |
123 | 124 |
124 void ConvertRGB24ToYUV(const uint8* rgbframe, | 125 MEDIA_EXPORT void ConvertRGB24ToYUV(const uint8* rgbframe, |
125 uint8* yplane, | 126 uint8* yplane, |
126 uint8* uplane, | 127 uint8* uplane, |
127 uint8* vplane, | 128 uint8* vplane, |
128 int width, | 129 int width, |
129 int height, | 130 int height, |
130 int rgbstride, | 131 int rgbstride, |
131 int ystride, | 132 int ystride, |
132 int uvstride); | 133 int uvstride); |
133 | 134 |
134 void ConvertYUY2ToYUV(const uint8* src, | 135 MEDIA_EXPORT void ConvertYUY2ToYUV(const uint8* src, |
135 uint8* yplane, | 136 uint8* yplane, |
136 uint8* uplane, | 137 uint8* uplane, |
137 uint8* vplane, | 138 uint8* vplane, |
138 int width, | 139 int width, |
139 int height); | 140 int height); |
140 | 141 |
141 void ConvertNV21ToYUV(const uint8* src, | 142 MEDIA_EXPORT void ConvertNV21ToYUV(const uint8* src, |
142 uint8* yplane, | 143 uint8* yplane, |
143 uint8* uplane, | 144 uint8* uplane, |
144 uint8* vplane, | 145 uint8* vplane, |
145 int width, | 146 int width, |
146 int height); | 147 int height); |
147 | 148 |
148 // Empty SIMD register state after calling optimized scaler functions. | 149 // Empty SIMD register state after calling optimized scaler functions. |
149 void EmptyRegisterState(); | 150 MEDIA_EXPORT void EmptyRegisterState(); |
150 | 151 |
151 } // namespace media | 152 } // namespace media |
152 | 153 |
153 #endif // MEDIA_BASE_YUV_CONVERT_H_ | 154 #endif // MEDIA_BASE_YUV_CONVERT_H_ |
OLD | NEW |