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 intf_ErrMsg( "yuvmmx error: unhandled function, grayscale, bpp = 16\n" );
58 /*****************************************************************************
59 * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 Bpp
60 *****************************************************************************/
61 void ConvertYUV420RGB16( YUV_ARGS_16BPP )
63 boolean_t b_horizontal_scaling; /* horizontal scaling type */
64 int i_vertical_scaling; /* vertical scaling type */
65 int i_x, i_y; /* horizontal and vertical indexes */
66 int i_scale_count; /* scale modulo counter */
67 int i_chroma_width; /* chroma width */
68 u16 * p_yuv; /* base conversion table */
69 u16 * p_pic_start; /* beginning of the current line for copy */
70 u16 * p_buffer_start; /* conversion buffer start */
71 u16 * p_buffer; /* conversion buffer pointer */
72 int * p_offset_start; /* offset array start */
73 int * p_offset; /* offset array pointer */
76 * Initialize some values - i_pic_line_width will store the line skip
78 i_pic_line_width -= i_pic_width;
79 i_chroma_width = i_width / 2;
80 p_yuv = p_vout->yuv.yuv.p_rgb16;
81 p_buffer_start = p_vout->yuv.p_buffer;
82 p_offset_start = p_vout->yuv.p_offset;
83 SetOffset( i_width, i_height, i_pic_width, i_pic_height,
84 &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
89 i_scale_count = i_pic_height;
90 for( i_y = 0; i_y < i_height; i_y++ )
92 /* Mark beginnning of line for possible later line copy, and initialize
95 p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
97 for ( i_x = i_width / 8; i_x--; )
100 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
102 __asm__( ".align 8" MMX_YUV_MUL MMX_YUV_ADD MMX_UNPACK_16
103 : : "r" (p_y), "r" (p_u), "r" (p_v), "r" (p_buffer) );
112 SCALE_HEIGHT( 420, 2 );
117 /*****************************************************************************
118 * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 Bpp
119 *****************************************************************************/
120 void ConvertYUV422RGB16( YUV_ARGS_16BPP )
122 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 422, bpp = 16\n" );
125 /*****************************************************************************
126 * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 Bpp
127 *****************************************************************************/
128 void ConvertYUV444RGB16( YUV_ARGS_16BPP )
130 intf_ErrMsg( "yuvmmx error: unhandled function, chroma = 444, bpp = 16\n" );