1 /*****************************************************************************
2 * video_yuv16.c: YUV transformation functions for 16bpp
3 * Provides functions to perform the YUV conversion. The functions provided here
4 * are a complete and portable C implementation, and may be replaced in certain
5 * case by optimized functions.
6 *****************************************************************************
7 * Copyright (C) 1999, 2000 VideoLAN
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public
22 * License along with this program; if not, write to the
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
32 #include <math.h> /* exp(), pow() */
33 #include <errno.h> /* ENOMEM */
34 #include <stdlib.h> /* free() */
35 #include <string.h> /* strerror() */
43 #include "video_output.h"
44 #include "video_yuv.h"
45 #include "video_yuv_macros.h"
46 #include "video_yuv_asm.h"
50 /*****************************************************************************
51 * ConvertY4Gray16: color YUV 4:4:4 to RGB 2 Bpp
52 *****************************************************************************/
53 void ConvertY4Gray16( YUV_ARGS_16BPP )
55 boolean_t b_horizontal_scaling; /* horizontal scaling type */
56 int i_vertical_scaling; /* vertical scaling type */
57 int i_x, i_y; /* horizontal and vertical indexes */
58 int i_scale_count; /* scale modulo counter */
59 int i_chroma_width; /* chroma width */
60 u16 * p_pic_start; /* beginning of the current line for copy */
61 u16 * p_buffer_start; /* conversion buffer start */
62 u16 * p_buffer; /* conversion buffer pointer */
63 int * p_offset_start; /* offset array start */
64 int * p_offset; /* offset array pointer */
67 * Initialize some values - i_pic_line_width will store the line skip
69 i_pic_line_width -= i_pic_width;
70 i_chroma_width = i_width / 2;
71 p_buffer_start = p_vout->yuv.p_buffer;
72 p_offset_start = p_vout->yuv.p_offset;
73 SetOffset( i_width, i_height, i_pic_width, i_pic_height,
74 &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
79 i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
80 for( i_y = 0; i_y < i_height; i_y++ )
82 /* Mark beginnning of line for possible later line copy, and initialize
85 p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
87 for ( i_x = i_width / 8; i_x--; )
89 __asm__( MMX_INIT_16_GRAY
90 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
95 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
104 SCALE_HEIGHT( 420, 2 );
108 /*****************************************************************************
109 * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
110 *****************************************************************************/
111 void ConvertYUV420RGB16( YUV_ARGS_16BPP )
113 boolean_t b_horizontal_scaling; /* horizontal scaling type */
114 int i_vertical_scaling; /* vertical scaling type */
115 int i_x, i_y; /* horizontal and vertical indexes */
116 int i_scale_count; /* scale modulo counter */
117 int i_chroma_width; /* chroma width */
118 u16 * p_pic_start; /* beginning of the current line for copy */
119 u16 * p_buffer_start; /* conversion buffer start */
120 u16 * p_buffer; /* conversion buffer pointer */
121 int * p_offset_start; /* offset array start */
122 int * p_offset; /* offset array pointer */
125 * Initialize some values - i_pic_line_width will store the line skip
127 i_pic_line_width -= i_pic_width;
128 i_chroma_width = i_width / 2;
129 p_buffer_start = p_vout->yuv.p_buffer;
130 p_offset_start = p_vout->yuv.p_offset;
131 SetOffset( i_width, i_height, i_pic_width, i_pic_height,
132 &b_horizontal_scaling, &i_vertical_scaling, p_offset_start, 0 );
137 i_scale_count = ( i_vertical_scaling == 1 ) ? i_pic_height : i_height;
138 for( i_y = 0; i_y < i_height; i_y++ )
140 /* Mark beginnning of line for possible later line copy, and initialize
143 p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
145 for ( i_x = i_width / 8; i_x--; )
148 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
154 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
163 SCALE_HEIGHT( 420, 2 );
167 /*****************************************************************************
168 * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
169 *****************************************************************************/
170 void ConvertYUV422RGB16( YUV_ARGS_16BPP )
172 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 16\n" );
175 /*****************************************************************************
176 * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
177 *****************************************************************************/
178 void ConvertYUV444RGB16( YUV_ARGS_16BPP )
180 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 16\n" );