-/*****************************************************************************
- * ConvertY4Gray32: grayscale YUV 4:x:x to RGB 4 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 )
-{
- 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_chroma_width; /* chroma width, not used */
- u32 * p_gray; /* base conversion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* conversion buffer start */
- u32 * p_buffer; /* conversion 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;
- p_gray = p_vout->yuv.yuv.p_gray32;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- *p_buffer++ = p_gray[ *p_y++ ]; *p_buffer++ = p_gray[ *p_y++ ];
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(400, 4);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB8: color YUV 4:2:0 to RGB 8 bpp
- *****************************************************************************/
-static void ConvertYUV420RGB8( p_vout_thread_t p_vout, u8 *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 )
-{
- 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 b_jump_uv; /* should we jump u and v ? */
- int i_real_y; /* y % 4 */
- u8 * p_lookup; /* lookup table */
- int i_chroma_width; /* chroma width */
- int * p_offset_start; /* offset array start */
- int * p_offset; /* offset array pointer */
-
- int dither10[4] = { 0x0, 0x8, 0x2, 0xa };
- int dither11[4] = { 0xc, 0x4, 0xe, 0x6 };
- int dither12[4] = { 0x3, 0xb, 0x1, 0x9 };
- int dither13[4] = { 0xf, 0x7, 0xd, 0x5 };
- int dither20[4] = { 0x00, 0x10, 0x04, 0x14 };
- int dither21[4] = { 0x18, 0x08, 0x1c, 0x0c };
- int dither22[4] = { 0x06, 0x16, 0x02, 0x12 };
- int dither23[4] = { 0x1e, 0x0e, 0x1a, 0x0a };
-
- /* other matrices that can be interesting, either for debugging or for effects */
- //int dither[4][4] = { { 0, 8, 2, 10 }, { 12, 4, 14, 16 }, { 3, 11, 1, 9}, {15, 7, 13, 5} };
- //int dither[4][4] = { { 7, 8, 0, 15 }, { 0, 15, 8, 7 }, { 7, 0, 15, 8 }, { 15, 7, 8, 0 } };
- //int dither[4][4] = { { 0, 15, 0, 15 }, { 15, 0, 15, 0 }, { 0, 15, 0, 15 }, { 15, 0, 15, 0 } };
- //int dither[4][4] = { { 15, 15, 0, 0 }, { 15, 15, 0, 0 }, { 0, 0, 15, 15 }, { 0, 0, 15, 15 } };
- //int dither[4][4] = { { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 }, { 8, 8, 8, 8 } };
- //int dither[4][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 }, { 12, 13, 14, 15 } };
- /*
- * 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_offset_start = p_vout->yuv.p_offset;
- p_lookup = p_vout->yuv.p_base;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- i_scale_count = i_pic_height;
- i_real_y = 0;
- for( i_y = 0; i_y < i_height; i_y++ )
- {
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH_DITHER( 420 );
- SCALE_HEIGHT_DITHER( 420 );
- }
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB8: color YUV 4:2:2 to RGB 8 bpp
- *****************************************************************************/
-static void ConvertYUV422RGB8( p_vout_thread_t p_vout, u8 *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 )
-{
- 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 */
- u8 * p_yuv; /* base conversion table */
- u8 * p_ybase; /* Y dependant conversion table */
- u8 * p_pic_start; /* beginning of the current line for copy */
- u8 * p_buffer_start; /* conversion buffer start */
- u8 * p_buffer; /* conversion 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.yuv.p_rgb8;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_Y_PIXEL(1);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(422, 1);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB8: color YUV 4:4:4 to RGB 8 bpp
- *****************************************************************************/
-static void ConvertYUV444RGB8( p_vout_thread_t p_vout, u8 *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 )
-{
- 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, not used */
- u8 * p_yuv; /* base conversion table */
- u8 * p_ybase; /* Y dependant conversion table */
- u8 * p_pic_start; /* beginning of the current line for copy */
- u8 * p_buffer_start; /* conversion buffer start */
- u8 * p_buffer; /* conversion 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;
- p_yuv = p_vout->yuv.yuv.p_rgb8;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- CONVERT_YUV_PIXEL(1); CONVERT_YUV_PIXEL(1);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(444, 1);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB16: color YUV 4:2:0 to RGB 2 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 conversion table */
- u16 * p_ybase; /* Y dependant conversion table */
- u16 * p_pic_start; /* beginning of the current line for copy */
- u16 * p_buffer_start; /* conversion buffer start */
- u16 * p_buffer; /* conversion 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.yuv.p_rgb16;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(420, 2);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB16: color YUV 4:2:2 to RGB 2 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 )
-{
- 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 conversion table */
- u16 * p_ybase; /* Y dependant conversion table */
- u16 * p_pic_start; /* beginning of the current line for copy */
- u16 * p_buffer_start; /* conversion buffer start */
- u16 * p_buffer; /* conversion 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.yuv.p_rgb16;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_Y_PIXEL(2);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(422, 2);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB16: color YUV 4:4:4 to RGB 2 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 )
-{
- 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, not used */
- u16 * p_yuv; /* base conversion table */
- u16 * p_ybase; /* Y dependant conversion table */
- u16 * p_pic_start; /* beginning of the current line for copy */
- u16 * p_buffer_start; /* conversion buffer start */
- u16 * p_buffer; /* conversion 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;
- p_yuv = p_vout->yuv.yuv.p_rgb16;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- CONVERT_YUV_PIXEL(2); CONVERT_YUV_PIXEL(2);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(444, 2);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV420RGB24: color YUV 4:2:0 to RGB 3 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 3 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 3 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 4 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 )
-{
- 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 */
- u32 * p_yuv; /* base conversion table */
- u32 * p_ybase; /* Y dependant conversion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* conversion buffer start */
- u32 * p_buffer; /* conversion 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.yuv.p_rgb32;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(420, 4);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV422RGB32: color YUV 4:2:2 to RGB 4 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 )
-{
- 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 */
- u32 * p_yuv; /* base conversion table */
- u32 * p_ybase; /* Y dependant conversion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* conversion buffer start */
- u32 * p_buffer; /* conversion 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.yuv.p_rgb32;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_Y_PIXEL(4);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(422, 4);
- }
-}
-
-/*****************************************************************************
- * ConvertYUV444RGB32: color YUV 4:4:4 to RGB 4 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 )
-{
- 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, not used */
- u32 * p_yuv; /* base conversion table */
- u32 * p_ybase; /* Y dependant conversion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* conversion buffer start */
- u32 * p_buffer; /* conversion 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;
- p_yuv = p_vout->yuv.yuv.p_rgb32;
- p_buffer_start = p_vout->yuv.p_buffer;
- p_offset_start = p_vout->yuv.p_offset;
- SetOffset( i_width, i_height, i_pic_width, i_pic_height,
- &b_horizontal_scaling, &i_vertical_scaling, p_offset_start );
-
- /*
- * Perform conversion
- */
- 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 conversion to buffer - YUV picture is always formed of 16
- * pixels wide blocks */
- for( i_x = i_width / 16; i_x--; )
- {
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- CONVERT_YUV_PIXEL(4); CONVERT_YUV_PIXEL(4);
- }
-
- /* Do horizontal and vertical scaling */
- SCALE_WIDTH;
- SCALE_HEIGHT(444, 4);
- }
-}
-
-//-------------------- walken code follows ------------------------------------
-
-/*
- * 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.
- */
-
-#if 0
-//??
-static void yuvToRgb24 (unsigned char * Y,
- unsigned char * U, unsigned char * V,
- char * dest, int table[1935], int width)
-{
- int i;
- int u;
- int v;
- int uvRed;
- int uvGreen;
- int uvBlue;
- int * tableY;
- int tmp24;
-
- i = width >> 3;
- while (i--) {
- u = *(U++);
- v = *(V++);
- uvRed = (V_RED_COEF*v) >> SHIFT;
- uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
- uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- u = *(U++);
- v = *(V++);
- uvRed = (V_RED_COEF*v) >> SHIFT;
- uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
- uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- u = *(U++);
- v = *(V++);
- uvRed = (V_RED_COEF*v) >> SHIFT;
- uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
- uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- u = *(U++);
- v = *(V++);
- uvRed = (V_RED_COEF*v) >> SHIFT;
- uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
- uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
- }
-
- i = (width & 7) >> 1;
- while (i--) {
- u = *(U++);
- v = *(V++);
- uvRed = (V_RED_COEF*v) >> SHIFT;
- uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
- uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
- }
-
- if (width & 1) {
- u = *(U++);
- v = *(V++);
- uvRed = (V_RED_COEF*v) >> SHIFT;
- uvGreen = (U_GREEN_COEF*u + V_GREEN_COEF*v) >> SHIFT;
- uvBlue = (U_BLUE_COEF*u) >> SHIFT;
-
- tableY = table + *(Y++);
- tmp24 = (tableY [1501 - ((V_RED_COEF*128)>>SHIFT) + uvRed] |
- tableY [135 - (((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) +
- uvGreen] |
- tableY [818 - ((U_BLUE_COEF*128)>>SHIFT) + uvBlue]);
- *(dest++) = tmp24;
- *(dest++) = tmp24 >> 8;
- *(dest++) = tmp24 >> 16;
- }
-}
-#endif