1 /*****************************************************************************
2 * transforms_yuvmmx.c: MMX YUV transformation functions
3 * Provides functions to perform the YUV conversion.
4 *****************************************************************************
5 * Copyright (C) 1999, 2000 VideoLAN
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.
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 GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #include <math.h> /* exp(), pow() */
31 #include <errno.h> /* ENOMEM */
32 #include <stdlib.h> /* free() */
33 #include <string.h> /* strerror() */
42 #include "video_output.h"
44 #include "video_common.h"
45 #include "transforms_common.h"
46 #include "transforms_yuvmmx.h"
50 /*****************************************************************************
51 * ConvertY4Gray8: grayscale YUV 4:x:x to RGB 8 bpp
52 *****************************************************************************/
53 void ConvertY4Gray8( YUV_ARGS_8BPP )
55 intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 8" );
58 /*****************************************************************************
59 * ConvertYUV420RGB8: color YUV 4:2:0 to RGB 8 bpp
60 *****************************************************************************/
61 void ConvertYUV420RGB8( YUV_ARGS_8BPP )
63 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 420, bpp = 8" );
66 /*****************************************************************************
67 * ConvertYUV422RGB8: color YUV 4:2:2 to RGB 8 bpp
68 *****************************************************************************/
69 void ConvertYUV422RGB8( YUV_ARGS_8BPP )
71 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 8" );
74 /*****************************************************************************
75 * ConvertYUV444RGB8: color YUV 4:4:4 to RGB 8 bpp
76 *****************************************************************************/
77 void ConvertYUV444RGB8( YUV_ARGS_8BPP )
79 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 8" );
82 /*****************************************************************************
83 * ConvertY4Gray16: color YUV 4:4:4 to RGB 2 Bpp
84 *****************************************************************************/
85 void ConvertY4Gray16( YUV_ARGS_16BPP )
87 boolean_t b_horizontal_scaling; /* horizontal scaling type */
88 int i_vertical_scaling; /* vertical scaling type */
89 int i_x, i_y; /* horizontal and vertical indexes */
90 int i_scale_count; /* scale modulo counter */
91 int i_chroma_width; /* chroma width */
92 u16 * p_pic_start; /* beginning of the current line for copy */
93 u16 * p_buffer_start; /* conversion buffer start */
94 u16 * p_buffer; /* conversion buffer pointer */
95 int * p_offset_start; /* offset array start */
96 int * p_offset; /* offset array pointer */
99 * Initialize some values - i_pic_line_width will store the line skip
101 i_pic_line_width -= i_pic_width;
102 i_chroma_width = i_width / 2;
103 p_buffer_start = p_vout->yuv.p_buffer;
104 p_offset_start = p_vout->yuv.p_offset;
105 SetOffset( i_width, i_height, i_pic_width, i_pic_height,
106 &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
111 i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
112 for( i_y = 0; i_y < i_height; i_y++ )
114 /* Mark beginnning of line for possible later line copy, and initialize
117 p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
119 for ( i_x = i_width / 8; i_x--; )
121 __asm__( MMX_INIT_16_GRAY
122 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
127 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
136 SCALE_HEIGHT( 420, 2 );
140 /*****************************************************************************
141 * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
142 *****************************************************************************/
143 void ConvertYUV420RGB16( YUV_ARGS_16BPP )
145 boolean_t b_horizontal_scaling; /* horizontal scaling type */
146 int i_vertical_scaling; /* vertical scaling type */
147 int i_x, i_y; /* horizontal and vertical indexes */
148 int i_scale_count; /* scale modulo counter */
149 int i_chroma_width; /* chroma width */
150 u16 * p_pic_start; /* beginning of the current line for copy */
151 u16 * p_buffer_start; /* conversion buffer start */
152 u16 * p_buffer; /* conversion buffer pointer */
153 int * p_offset_start; /* offset array start */
154 int * p_offset; /* offset array pointer */
157 * Initialize some values - i_pic_line_width will store the line skip
159 i_pic_line_width -= i_pic_width;
160 i_chroma_width = i_width / 2;
161 p_buffer_start = p_vout->yuv.p_buffer;
162 p_offset_start = p_vout->yuv.p_offset;
163 SetOffset( i_width, i_height, i_pic_width, i_pic_height,
164 &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
169 i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
170 for( i_y = 0; i_y < i_height; i_y++ )
172 /* Mark beginnning of line for possible later line copy, and initialize
175 p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
177 for ( i_x = i_width / 8; i_x--; )
180 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
186 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
195 SCALE_HEIGHT( 420, 2 );
199 /*****************************************************************************
200 * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
201 *****************************************************************************/
202 void ConvertYUV422RGB16( YUV_ARGS_16BPP )
204 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 16" );
207 /*****************************************************************************
208 * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
209 *****************************************************************************/
210 void ConvertYUV444RGB16( YUV_ARGS_16BPP )
212 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 16" );
215 /*****************************************************************************
216 * ConvertY4Gray24: grayscale YUV 4:x:x to RGB 2 Bpp
217 *****************************************************************************/
218 void ConvertY4Gray24( YUV_ARGS_24BPP )
220 intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 24" );
223 /*****************************************************************************
224 * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 2 Bpp
225 *****************************************************************************/
226 void ConvertYUV420RGB24( YUV_ARGS_24BPP )
228 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 420, bpp = 24" );
231 /*****************************************************************************
232 * ConvertYUV422RGB24: color YUV 4:2:2 to RGB 2 Bpp
233 *****************************************************************************/
234 void ConvertYUV422RGB24( YUV_ARGS_24BPP )
236 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 24" );
239 /*****************************************************************************
240 * ConvertYUV444RGB24: color YUV 4:4:4 to RGB 2 Bpp
241 *****************************************************************************/
242 void ConvertYUV444RGB24( YUV_ARGS_24BPP )
244 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 24" );
247 /*****************************************************************************
248 * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 Bpp
249 *****************************************************************************/
250 void ConvertY4Gray32( YUV_ARGS_32BPP )
252 intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 32" );
255 /*****************************************************************************
256 * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 4 Bpp
257 *****************************************************************************/
258 void ConvertYUV420RGB32( YUV_ARGS_32BPP )
260 boolean_t b_horizontal_scaling; /* horizontal scaling type */
261 int i_vertical_scaling; /* vertical scaling type */
262 int i_x, i_y; /* horizontal and vertical indexes */
263 int i_scale_count; /* scale modulo counter */
264 int i_chroma_width; /* chroma width */
265 u32 * p_pic_start; /* beginning of the current line for copy */
266 u32 * p_buffer_start; /* conversion buffer start */
267 u32 * p_buffer; /* conversion buffer pointer */
268 int * p_offset_start; /* offset array start */
269 int * p_offset; /* offset array pointer */
272 * Initialize some values - i_pic_line_width will store the line skip
274 i_pic_line_width -= i_pic_width;
275 i_chroma_width = i_width / 2;
276 p_buffer_start = p_vout->yuv.p_buffer;
277 p_offset_start = p_vout->yuv.p_offset;
278 SetOffset( i_width, i_height, i_pic_width, i_pic_height,
279 &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
284 i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
285 for( i_y = 0; i_y < i_height; i_y++ )
287 /* Mark beginnning of line for possible later line copy, and initialize
290 p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
292 for ( i_x = i_width / 8; i_x--; )
296 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
302 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
311 SCALE_HEIGHT( 420, 4 );
315 /*****************************************************************************
316 * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 Bpp
317 *****************************************************************************/
318 void ConvertYUV422RGB32( YUV_ARGS_32BPP )
320 intf_ErrMsg( "yuv error: unhandled function, chroma = 422, bpp = 32" );
323 /*****************************************************************************
324 * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 Bpp
325 *****************************************************************************/
326 void ConvertYUV444RGB32( YUV_ARGS_32BPP )
328 intf_ErrMsg( "yuv error: unhandled function, chroma = 444, bpp = 32" );