-/*******************************************************************************
- * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 32 bpp
- *******************************************************************************/
-static void ConvertY4Gray32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- u32 * p_gray; /* gray table */
- int i_x, i_y; /* picture coordinates */
-
- p_gray = p_vout->yuv.yuv.gray32.p_gray;
- CONVERT_YUV_GRAY
-}
-
-/*******************************************************************************
- * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 15 or 16 bpp
- *******************************************************************************/
-static void ConvertYUV420RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
-/* MMX version */
- // int i_chroma_width, i_chroma_skip; /* width and eol for chroma */
-/*
- i_chroma_width = i_width / 2;
- i_chroma_skip = i_skip / 2;
- ConvertYUV420RGB16MMX( p_y, p_u, p_v, i_width, i_height,
- (i_width + i_skip) * sizeof( yuv_data_t ),
- (i_chroma_width + i_chroma_skip) * sizeof( yuv_data_t),
- i_scale, (u8 *)p_pic, 0, 0, (i_width + i_pic_eol) * sizeof( u16 ),
- p_vout->i_screen_depth == 15 );
-*/
- boolean_t b_horizontal_scaling; /* horizontal scaling type */
- int i_vertical_scaling; /* vertical scaling type */
- int i_x, i_y; /* horizontal and vertical indexes */
- int i_scale_count; /* scale modulo counter */
- int i_uval, i_vval; /* U and V samples */
- int i_red, i_green, i_blue; /* U and V modified samples */
- int i_chroma_width; /* chroma width */
- u16 * p_yuv; /* base convertion table */
- u16 * p_ybase; /* Y dependant convertion table */
- u16 * p_pic_start; /* beginning of the current line for copy */
- u16 * p_buffer_start; /* convertion buffer start */
- u16 * p_buffer; /* convertion buffer pointer */
- int * p_offset_start; /* offset array start */
- int * p_offset; /* offset array pointer */
-
- /*
- * Initialize some values - i_pic_line_width will store the line skip
- */
- i_pic_line_width -= i_pic_width;
- i_chroma_width = i_width / 2;
- p_yuv = p_vout->yuv.yuv2.p_rgb16;
-
- /*
- * Set scalings
- */
- if( i_pic_width - i_width > 0 )
- {
- /* Prepare scaling array for horizontal extension */
- b_horizontal_scaling = 1;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- p_offset = p_offset_start;
- i_scale_count = i_pic_width;
- for( i_x = i_width; i_x--; )
- {
- while( (i_scale_count -= i_width) > 0 )
- {
- *p_offset++ = 0;
- }
- *p_offset++ = 1;
- i_scale_count += i_pic_width;
- }
- }
- else if( i_pic_width - i_width < 0 )
- {
- /* Prepare scaling array for horizontal reduction */
- b_horizontal_scaling = 1;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- p_offset = p_offset_start;
- i_scale_count = i_pic_width;
- for( i_x = i_pic_width; i_x--; )
- {
- *p_offset = 1;
- while( (i_scale_count -= i_pic_width) >= 0 )
- {
- *p_offset += 1;
- }
- p_offset++;
- i_scale_count += i_width;
- }
- }
- else
- {
- /* No horizontal scaling: YUV convertion is done directly to picture */
- b_horizontal_scaling = 0;
- p_buffer_start = p_pic;
- p_offset_start = NULL; /* to avoid warning */
- }
- if( i_pic_height - i_height > 0 )
- {
- i_vertical_scaling = 1;
- }
- else if( i_pic_height - i_height < 0 )
- {
- i_vertical_scaling = -1;
- }
- else
- {
- i_vertical_scaling = 0;
- }
-
- /*
- * Perform convertion
- */
- i_scale_count = i_pic_height;
- for( i_y = 0; i_y < i_height; i_y++ )
- {
- /* Mark beginnning of line for possible later line copy, and initialize
- * buffer */
- p_pic_start = p_pic;
- p_buffer = b_horizontal_scaling ? p_buffer_start : p_pic;
-
- /* Do YUV convertion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- CONVERT_YUV_PIXEL; CONVERT_Y_PIXEL;
- }
-
- if( b_horizontal_scaling )
- {
- /* Horizontal scaling, convertion has been done to buffer.
- * Rewind buffer and offset, then copy and scale line */
- p_buffer = p_buffer_start;
- p_offset = p_offset_start;
- for( i_x = i_pic_width / 16; i_x--; )
- {
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- *p_pic++ = *p_buffer; p_buffer += *p_offset++;
- }
- }
- else
- {
- /* No scaling, convertion has been done directly in picture memory.
- * Increment of picture pointer to end of line is still needed */
- p_pic += i_pic_width;
- }
-
- /* If line is odd, rewind U and V samples */
- if( i_y & 0x1 )
- {
- p_u -= i_chroma_width;
- p_v -= i_chroma_width;
- }
-
- /* End of line: skip picture to reach beginning of next line */
- p_pic += i_pic_line_width;
-
- /*
- * Handle vertical scaling. The current line can be copied or next one
- * can be ignored.
- */
- switch( i_vertical_scaling )
- {
- case -1: /* vertical scaling factor is < 1 */
- while( (i_scale_count -= i_pic_height) >= 0 )
- {
- /* Height reduction: skip next source line */
- p_y += i_width;
- if( ! (++i_y & 0x1) )
- {
- p_u += i_chroma_width;
- p_v += i_chroma_width;
- }
- }
- i_scale_count += i_height;
- break;
- case 1: /* vertical scaling factor is > 1 */
- while( (i_scale_count -= i_height) > 0 )
- {
- /* Height increment: copy previous picture line */
- for( i_x = i_pic_width / 16; i_x--; )
- {
- *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );
- *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );
- *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );
- *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ );
- }
- p_pic += i_pic_line_width;
- p_pic_start += i_pic_line_width;
- }
- i_scale_count += i_pic_height;
- break;
- }
- }
-}
-
-/*******************************************************************************
- * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 15 or 16 bpp
- *******************************************************************************/
-static void ConvertYUV422RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //??
-}
-
-/*******************************************************************************
- * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 15 or 16 bpp
- *******************************************************************************/
-static void ConvertYUV444RGB16( p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //??
-}
-
-/*******************************************************************************
- * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 24 bpp
- *******************************************************************************/
-static void ConvertYUV420RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //???
-}
-
-/*******************************************************************************
- * ConvertYUV422RGB24: color YUV 4:2:2 to RGB 24 bpp
- *******************************************************************************/
-static void ConvertYUV422RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //???
-}
-
-/*******************************************************************************
- * ConvertYUV444RGB24: color YUV 4:4:4 to RGB 24 bpp
- *******************************************************************************/
-static void ConvertYUV444RGB24( p_vout_thread_t p_vout, void *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //???
-}
-
-/*******************************************************************************
- * ConvertYUV420RGB32: color YUV 4:2:0 to RGB 32 bpp
- *******************************************************************************/
-static void ConvertYUV420RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //??
-}
-
-/*******************************************************************************
- * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 32 bpp
- *******************************************************************************/
-static void ConvertYUV422RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //??
-}
-
-/*******************************************************************************
- * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 32 bpp
- *******************************************************************************/
-static void ConvertYUV444RGB32( p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v,
- int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
- int i_matrix_coefficients )
-{
- //??
-}
-
-//-------------------- walken code follow ---------------------------------------
-
-/*
- * YUV to RGB routines.
- *
- * these routines calculate r, g and b values from each pixel's y, u and v.
- * these r, g an b values are then passed thru a table lookup to take the
- * gamma curve into account and find the corresponding pixel value.
- *
- * the table must store more than 3*256 values because of the possibility
- * of overflow in the yuv->rgb calculation. actually the calculated r,g,b
- * values are in the following intervals :
- * -176 to 255+176 for red
- * -133 to 255+133 for green
- * -222 to 255+222 for blue
- *
- * If the input y,u,v values are right, the r,g,b results are not expected
- * to move out of the 0 to 255 interval but who knows what will happen in
- * real use...
- *
- * the red, green and blue conversion tables are stored in a single 1935-entry
- * array. The respective positions of each component in the array have been
- * calculated to minimize the cache interactions of the 3 tables.
- */
-
-static int rgbTable32 (int table [1935],
- int redMask, int greenMask, int blueMask,
- unsigned char gamma[256])