1 #include "gfx_conv_mmx.h"
2 #include "gfx_conv_c.h"
5 extern "C" void _Convert_YUV422_RGBA32_SSE(void *fromYPtr
, void *toPtr
,
7 extern "C" void _Convert_YUV422_RGBA32_SSE2(void *fromYPtr
, void *toPtr
,
9 extern "C" void _Convert_YUV422_RGBA32_SSSE3(void *fromYPtr
, void *toPtr
,
13 extern "C" void _Convert_YUV420P_RGBA32_SSE(void *fromYPtr
, void *fromUPtr
,
14 void *fromVPtr
, void *toPtr
, int width
);
15 extern "C" void _Convert_YUV420P_RGBA32_SSE2(void *fromYPtr
, void *fromUPtr
,
16 void *fromVPtr
, void *toPtr
, int width
);
17 extern "C" void _Convert_YUV420P_RGBA32_SSSE3(void *fromYPtr
, void *fromUPtr
,
18 void *fromVPtr
, void *toPtr
, int width
);
21 // Planar YUV420 means 2 Y lines share a UV line
23 gfx_conv_yuv420p_rgba32_sse(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
25 // in and out buffers must be aligned to 16 bytes,
26 // in should be as ffmpeg allocates it
27 if ((off_t
)out
->data
[0] % 16 != 0) {
28 gfx_conv_YCbCr420p_RGB32_c(in
, out
, width
, height
);
32 uint8
*ybase
= (uint8
*)in
->data
[0];
33 uint8
*ubase
= (uint8
*)in
->data
[1];
34 uint8
*vbase
= (uint8
*)in
->data
[2];
35 uint8
*rgbbase
= (uint8
*)out
->data
[0];
37 int yBaseInc
= in
->linesize
[0];
38 int uBaseInc
= in
->linesize
[1];
39 int vBaseInc
= in
->linesize
[2];
40 int rgbBaseInc
= out
->linesize
[0];
42 for (int i
=0;i
<height
;i
+=2) {
44 _Convert_YUV420P_RGBA32_SSE(ybase
, ubase
, vbase
, rgbbase
, width
);
46 rgbbase
+= rgbBaseInc
;
48 // Second Y row but same u and v row
49 _Convert_YUV420P_RGBA32_SSE(ybase
, ubase
, vbase
, rgbbase
, width
);
53 rgbbase
+= rgbBaseInc
;
57 // Planar YUV420 means 2 Y lines share a UV line
59 gfx_conv_yuv420p_rgba32_sse2(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
61 // in and out buffers must be aligned to 32 bytes,
62 // in should be as ffmpeg allocates it
63 if ((off_t
)out
->data
[0] % 32 != 0) {
64 gfx_conv_YCbCr420p_RGB32_c(in
, out
, width
, height
);
68 uint8
*ybase
= (uint8
*)in
->data
[0];
69 uint8
*ubase
= (uint8
*)in
->data
[1];
70 uint8
*vbase
= (uint8
*)in
->data
[2];
71 uint8
*rgbbase
= (uint8
*)out
->data
[0];
73 int yBaseInc
= in
->linesize
[0];
74 int uBaseInc
= in
->linesize
[1];
75 int vBaseInc
= in
->linesize
[2];
76 int rgbBaseInc
= out
->linesize
[0];
78 for (int i
=0;i
<height
;i
+=2) {
80 _Convert_YUV420P_RGBA32_SSE2(ybase
, ubase
, vbase
, rgbbase
, width
);
82 rgbbase
+= rgbBaseInc
;
84 // Second Y row but same u and v row
85 _Convert_YUV420P_RGBA32_SSE2(ybase
, ubase
, vbase
, rgbbase
, width
);
89 rgbbase
+= rgbBaseInc
;
93 // Planar YUV420 means 2 Y lines share a UV line
95 gfx_conv_yuv420p_rgba32_ssse3(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
97 // in and out buffers must be aligned to 32 bytes,
98 // in should be as ffmpeg allocates it
99 if ((off_t
)out
->data
[0] % 32 != 0) {
100 gfx_conv_YCbCr420p_RGB32_c(in
, out
, width
, height
);
104 uint8
*ybase
= (uint8
*)in
->data
[0];
105 uint8
*ubase
= (uint8
*)in
->data
[1];
106 uint8
*vbase
= (uint8
*)in
->data
[2];
107 uint8
*rgbbase
= (uint8
*)out
->data
[0];
109 int yBaseInc
= in
->linesize
[0];
110 int uBaseInc
= in
->linesize
[1];
111 int vBaseInc
= in
->linesize
[2];
112 int rgbBaseInc
= out
->linesize
[0];
114 for (int i
=0;i
<height
;i
+=2) {
116 _Convert_YUV420P_RGBA32_SSSE3(ybase
, ubase
, vbase
, rgbbase
, width
);
118 rgbbase
+= rgbBaseInc
;
120 // Second Y row but same u and v row
121 _Convert_YUV420P_RGBA32_SSSE3(ybase
, ubase
, vbase
, rgbbase
, width
);
125 rgbbase
+= rgbBaseInc
;
129 // Planar YUV422 means each Y line has it's own UV line
131 gfx_conv_yuv422p_rgba32_sse(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
133 // in and out buffers must be aligned to 32 bytes,
134 // in should be as ffmpeg allocates it
135 if ((off_t
)out
->data
[0] % 32 != 0) {
136 gfx_conv_YCbCr422_RGB32_c(in
, out
, width
, height
);
140 uint8
*ybase
= (uint8
*)in
->data
[0];
141 uint8
*ubase
= (uint8
*)in
->data
[1];
142 uint8
*vbase
= (uint8
*)in
->data
[2];
143 uint8
*rgbbase
= (uint8
*)out
->data
[0];
145 int yBaseInc
= in
->linesize
[0];
146 int uBaseInc
= in
->linesize
[1];
147 int vBaseInc
= in
->linesize
[2];
148 int rgbBaseInc
= out
->linesize
[0];
150 for (int i
=0;i
<height
;i
++) {
151 _Convert_YUV420P_RGBA32_SSE(ybase
, ubase
, vbase
, rgbbase
, width
);
155 rgbbase
+= rgbBaseInc
;
159 // Planar YUV422 means each Y line has it's own UV line
161 gfx_conv_yuv422p_rgba32_sse2(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
163 // in and out buffers must be aligned to 32 bytes,
164 // in should be as ffmpeg allocates it
165 if ((off_t
)out
->data
[0] % 32 != 0) {
166 gfx_conv_YCbCr422_RGB32_c(in
, out
, width
, height
);
170 uint8
*ybase
= (uint8
*)in
->data
[0];
171 uint8
*ubase
= (uint8
*)in
->data
[1];
172 uint8
*vbase
= (uint8
*)in
->data
[2];
173 uint8
*rgbbase
= (uint8
*)out
->data
[0];
175 int yBaseInc
= in
->linesize
[0];
176 int uBaseInc
= in
->linesize
[1];
177 int vBaseInc
= in
->linesize
[2];
178 int rgbBaseInc
= out
->linesize
[0];
180 for (int i
=0;i
<height
;i
++) {
181 _Convert_YUV420P_RGBA32_SSE2(ybase
, ubase
, vbase
, rgbbase
, width
);
185 rgbbase
+= rgbBaseInc
;
189 // Planar YUV422 means each Y line has it's own UV line
191 gfx_conv_yuv422p_rgba32_ssse3(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
193 // in and out buffers must be aligned to 32 bytes,
194 // in should be as ffmpeg allocates it
195 if ((off_t
)out
->data
[0] % 32 != 0) {
196 gfx_conv_YCbCr422_RGB32_c(in
, out
, width
, height
);
200 uint8
*ybase
= (uint8
*)in
->data
[0];
201 uint8
*ubase
= (uint8
*)in
->data
[1];
202 uint8
*vbase
= (uint8
*)in
->data
[2];
203 uint8
*rgbbase
= (uint8
*)out
->data
[0];
205 int yBaseInc
= in
->linesize
[0];
206 int uBaseInc
= in
->linesize
[1];
207 int vBaseInc
= in
->linesize
[2];
208 int rgbBaseInc
= out
->linesize
[0];
210 for (int i
=0;i
<height
;i
++) {
211 _Convert_YUV420P_RGBA32_SSSE3(ybase
, ubase
, vbase
, rgbbase
, width
);
215 rgbbase
+= rgbBaseInc
;
219 // Packed YUV422 (YUYV)
221 gfx_conv_yuv422_rgba32_sse(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
223 // in and out buffers must be aligned to 16 bytes,
224 // in should be as ffmpeg allocates it
225 if ((off_t
)out
->data
[0] % 16 != 0) {
226 gfx_conv_YCbCr422_RGB32_c(in
, out
, width
, height
);
230 uint8
*ybase
= (uint8
*)in
->data
[0];
231 uint8
*rgbbase
= (uint8
*)out
->data
[0];
233 for (int i
= 0; i
<= height
; i
++) {
234 _Convert_YUV422_RGBA32_SSE(ybase
, rgbbase
, width
);
235 ybase
+= in
->linesize
[0];
236 rgbbase
+= out
->linesize
[0];
240 // Packed YUV422 (YUYV)
242 gfx_conv_yuv422_rgba32_sse2(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
244 // in and out buffers must be aligned to 32 bytes,
245 // in should be as ffmpeg allocates it
246 if ((off_t
)out
->data
[0] % 32 != 0) {
247 gfx_conv_YCbCr422_RGB32_c(in
, out
, width
, height
);
251 uint8
*ybase
= (uint8
*)in
->data
[0];
252 uint8
*rgbbase
= (uint8
*)out
->data
[0];
254 for (int i
= 0; i
<= height
; i
++) {
255 _Convert_YUV422_RGBA32_SSE2(ybase
, rgbbase
, width
);
256 ybase
+= in
->linesize
[0];
257 rgbbase
+= out
->linesize
[0];
261 // Packed YUV422 (YUYV)
263 gfx_conv_yuv422_rgba32_ssse3(AVFrame
*in
, AVFrame
*out
, int width
, int height
)
265 // in and out buffers must be aligned to 32 bytes,
266 // in should be as ffmpeg allocates it
267 if ((off_t
)out
->data
[0] % 32 != 0) {
268 gfx_conv_YCbCr422_RGB32_c(in
, out
, width
, height
);
272 uint8
*ybase
= (uint8
*)in
->data
[0];
273 uint8
*rgbbase
= (uint8
*)out
->data
[0];
275 for (int i
= 0; i
<= height
; i
++) {
276 _Convert_YUV422_RGBA32_SSSE3(ybase
, rgbbase
, width
);
277 ybase
+= in
->linesize
[0];
278 rgbbase
+= out
->linesize
[0];