f502e710afc83ac2c8d0f0068a30db727c573247
[vlc.git] / modules / video_chroma / i422_yuy2.h
1 /*****************************************************************************
2  * i422_yuy2.h : YUV to YUV conversion module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifdef MODULE_NAME_IS_i422_yuy2_mmx
25
26 #define MMX_YUV422_YUYV "                                                 \n\
27 movq       (%1), %%mm0  # Load 8 Y            y7 y6 y5 y4 y3 y2 y1 y0     \n\
28 movd       (%2), %%mm1  # Load 4 Cb           00 00 00 00 u3 u2 u1 u0     \n\
29 movd       (%3), %%mm2  # Load 4 Cr           00 00 00 00 v3 v2 v1 v0     \n\
30 punpcklbw %%mm2, %%mm1  #                     v3 u3 v2 u2 v1 u1 v0 u0     \n\
31 movq      %%mm0, %%mm2  #                     y7 y6 y5 y4 y3 y2 y1 y0     \n\
32 punpcklbw %%mm1, %%mm2  #                     v1 y3 u1 y2 v0 y1 u0 y0     \n\
33 movq      %%mm2, (%0)   # Store low YUYV                                  \n\
34 punpckhbw %%mm1, %%mm0  #                     v3 y7 u3 y6 v2 y5 u2 y4     \n\
35 movq      %%mm0, 8(%0)  # Store high YUYV                                 \n\
36 "
37
38 #define MMX_YUV422_YVYU "                                                 \n\
39 movq       (%1), %%mm0  # Load 8 Y            y7 y6 y5 y4 y3 y2 y1 y0     \n\
40 movd       (%2), %%mm2  # Load 4 Cb           00 00 00 00 u3 u2 u1 u0     \n\
41 movd       (%3), %%mm1  # Load 4 Cr           00 00 00 00 v3 v2 v1 v0     \n\
42 punpcklbw %%mm2, %%mm1  #                     u3 v3 u2 v2 u1 v1 u0 v0     \n\
43 movq      %%mm0, %%mm2  #                     y7 y6 y5 y4 y3 y2 y1 y0     \n\
44 punpcklbw %%mm1, %%mm2  #                     u1 y3 v1 y2 u0 y1 v0 y0     \n\
45 movq      %%mm2, (%0)   # Store low YUYV                                  \n\
46 punpckhbw %%mm1, %%mm0  #                     u3 y7 v3 y6 u2 y5 v2 y4     \n\
47 movq      %%mm0, 8(%0)  # Store high YUYV                                 \n\
48 "
49
50 #define MMX_YUV422_UYVY "                                                 \n\
51 movq       (%1), %%mm0  # Load 8 Y            y7 y6 y5 y4 y3 y2 y1 y0     \n\
52 movd       (%2), %%mm1  # Load 4 Cb           00 00 00 00 u3 u2 u1 u0     \n\
53 movd       (%3), %%mm2  # Load 4 Cr           00 00 00 00 v3 v2 v1 v0     \n\
54 punpcklbw %%mm2, %%mm1  #                     v3 u3 v2 u2 v1 u1 v0 u0     \n\
55 movq      %%mm1, %%mm2  #                     v3 u3 v2 u2 v1 u1 v0 u0     \n\
56 punpcklbw %%mm0, %%mm2  #                     y3 v1 y2 u1 y1 v0 y0 u0     \n\
57 movq      %%mm2, (%0)   # Store low UYVY                                  \n\
58 punpckhbw %%mm0, %%mm1  #                     y7 v3 y6 u3 y5 v2 y4 u2     \n\
59 movq      %%mm1, 8(%0)  # Store high UYVY                                 \n\
60 "
61
62 #define MMX_YUV422_Y211 "                                                 \n\
63 "
64
65 #else
66
67 #define C_YUV422_YUYV( p_line, p_y, p_u, p_v )                              \
68     *(p_line)++ = *(p_y)++;                                                 \
69     *(p_line)++ = *(p_u)++;                                                 \
70     *(p_line)++ = *(p_y)++;                                                 \
71     *(p_line)++ = *(p_v)++;                                                 \
72
73 #define C_YUV422_YVYU( p_line, p_y, p_u, p_v )                              \
74     *(p_line)++ = *(p_y)++;                                                 \
75     *(p_line)++ = *(p_v)++;                                                 \
76     *(p_line)++ = *(p_y)++;                                                 \
77     *(p_line)++ = *(p_u)++;                                                 \
78
79 #define C_YUV422_UYVY( p_line, p_y, p_u, p_v )                              \
80     *(p_line)++ = *(p_u)++;                                                 \
81     *(p_line)++ = *(p_y)++;                                                 \
82     *(p_line)++ = *(p_v)++;                                                 \
83     *(p_line)++ = *(p_y)++;                                                 \
84
85 #define C_YUV422_Y211( p_line, p_y, p_u, p_v )                              \
86     *(p_line)++ = *(p_y); p_y += 2;                                         \
87     *(p_line)++ = *(p_u) - 0x80; p_u += 2;                                  \
88     *(p_line)++ = *(p_y); p_y += 2;                                         \
89     *(p_line)++ = *(p_v) - 0x80; p_v += 2;                                  \
90
91 #endif
92