*******************************************************************************/
typedef struct vout_font_s
{
- int i_type; /* font type */
- int i_width; /* character width in pixels */
- int i_height; /* character height in pixels */
- int i_interspacing; /* characters interspacing in pixels */
- int i_bytes_per_line; /* bytes per character line */
- int i_bytes_per_char; /* bytes per character */
- u16 i_first; /* first character */
- u16 i_last; /* last character */
- byte_t * p_data; /* font character data */
+ int i_type; /* font type */
+ int i_width; /* character width in pixels */
+ int i_height; /* character height in pixels */
+ int i_interspacing; /* characters interspacing in pixels */
+ int i_bytes_per_line; /* bytes per character line */
+ int i_bytes_per_char; /* bytes per character */
+ u16 i_first; /* first character */
+ u16 i_last; /* last character */
+ byte_t * p_data; /* font character data */
} vout_font_t;
/* Font types */
-#define VOUT_FIXED_FONT 0 /* simple fixed font */
+#define VOUT_FIXED_FONT 0 /* simple fixed font */
/*******************************************************************************
* vout_put_byte_t: PutByte function
/* PUT_BYTE_MASK: put pixels from a byte-wide mask. It uses a branching tree
* to optimize the number of tests. It is used in the PutByte functions. */
-#define TREE( i_mask, i_mask_color ) \
-if( i_mask & 0xf0 ) /* one from 1111 */ \
-{ \
- if( i_mask & 0xc0 ) /* one from 1100 */ \
- { \
- if( i_mask & 0x80 ) /* 1000 */ \
- { \
- p_pic[0] = i_mask_color; \
- if( i_mask & 0x40 ) /* 0100 */ \
- { \
- p_pic[1] = i_mask_color; \
- } \
- } \
- else /* not 1000 means 0100 */ \
- { \
- p_pic[1] = i_mask_color; \
- } \
- if( i_mask & 0x30 ) /* one from 0011 */ \
- { \
- if( i_mask & 0x20 ) /* 0010 */ \
- { \
- p_pic[2] = i_mask_color; \
- if( i_mask & 0x10 ) /* 0001 */ \
- { \
- p_pic[3] = i_mask_color; \
- } \
- } \
- else /* not 0010 means 0001 */ \
- { \
- p_pic[3] = i_mask_color; \
- } \
- } \
- } \
- else /* not 1100 means 0011 */ \
- { \
- if( i_mask & 0x20 ) /* 0010 */ \
- { \
- p_pic[2] = i_mask_color; \
- if( i_mask & 0x10 ) /* 0001 */ \
- { \
- p_pic[3] = i_mask_color; \
- } \
- } \
- else /* not 0010 means 0001 */ \
- { \
- p_pic[3] = i_mask_color; \
- } \
- } \
-} \
-if( i_mask & 0x0f ) \
-{ \
- if( i_mask & 0x0c ) /* one from 1100 */ \
- { \
- if( i_mask & 0x08 ) /* 1000 */ \
- { \
- p_pic[4] = i_mask_color; \
- if( i_mask & 0x04 ) /* 0100 */ \
- { \
- p_pic[5] = i_mask_color; \
- } \
- } \
- else /* not 1000 means 0100 */ \
- { \
- p_pic[5] = i_mask_color; \
- } \
- if( i_mask & 0x03 ) /* one from 0011 */ \
- { \
- if( i_mask & 0x02 ) /* 0010 */ \
- { \
- p_pic[6] = i_mask_color; \
- if( i_mask & 0x01 ) /* 0001 */ \
- { \
- p_pic[7] = i_mask_color; \
- } \
- } \
- else /* not 0010 means 0001 */ \
- { \
- p_pic[7] = i_mask_color; \
- } \
- } \
- } \
- else /* not 1100 means 0011 */ \
- { \
- if( i_mask & 0x02 ) /* 0010 */ \
- { \
- p_pic[6] = i_mask_color; \
- if( i_mask & 0x01 ) /* 0001 */ \
- { \
- p_pic[7] = i_mask_color; \
- } \
- } \
- else /* not 0010 means 0001 */ \
- { \
- p_pic[7] = i_mask_color; \
- } \
- } \
+#define TREE( i_mask, i_mask_color ) \
+if( i_mask & 0xf0 ) /* one from 1111 */ \
+{ \
+ if( i_mask & 0xc0 ) /* one from 1100 */ \
+ { \
+ if( i_mask & 0x80 ) /* 1000 */ \
+ { \
+ p_pic[0] = i_mask_color; \
+ if( i_mask & 0x40 ) /* 0100 */ \
+ { \
+ p_pic[1] = i_mask_color; \
+ } \
+ } \
+ else /* not 1000 means 0100 */ \
+ { \
+ p_pic[1] = i_mask_color; \
+ } \
+ if( i_mask & 0x30 ) /* one from 0011 */ \
+ { \
+ if( i_mask & 0x20 ) /* 0010 */ \
+ { \
+ p_pic[2] = i_mask_color; \
+ if( i_mask & 0x10 ) /* 0001 */ \
+ { \
+ p_pic[3] = i_mask_color; \
+ } \
+ } \
+ else /* not 0010 means 0001 */ \
+ { \
+ p_pic[3] = i_mask_color; \
+ } \
+ } \
+ } \
+ else /* not 1100 means 0011 */ \
+ { \
+ if( i_mask & 0x20 ) /* 0010 */ \
+ { \
+ p_pic[2] = i_mask_color; \
+ if( i_mask & 0x10 ) /* 0001 */ \
+ { \
+ p_pic[3] = i_mask_color; \
+ } \
+ } \
+ else /* not 0010 means 0001 */ \
+ { \
+ p_pic[3] = i_mask_color; \
+ } \
+ } \
+} \
+if( i_mask & 0x0f ) \
+{ \
+ if( i_mask & 0x0c ) /* one from 1100 */ \
+ { \
+ if( i_mask & 0x08 ) /* 1000 */ \
+ { \
+ p_pic[4] = i_mask_color; \
+ if( i_mask & 0x04 ) /* 0100 */ \
+ { \
+ p_pic[5] = i_mask_color; \
+ } \
+ } \
+ else /* not 1000 means 0100 */ \
+ { \
+ p_pic[5] = i_mask_color; \
+ } \
+ if( i_mask & 0x03 ) /* one from 0011 */ \
+ { \
+ if( i_mask & 0x02 ) /* 0010 */ \
+ { \
+ p_pic[6] = i_mask_color; \
+ if( i_mask & 0x01 ) /* 0001 */ \
+ { \
+ p_pic[7] = i_mask_color; \
+ } \
+ } \
+ else /* not 0010 means 0001 */ \
+ { \
+ p_pic[7] = i_mask_color; \
+ } \
+ } \
+ } \
+ else /* not 1100 means 0011 */ \
+ { \
+ if( i_mask & 0x02 ) /* 0010 */ \
+ { \
+ p_pic[6] = i_mask_color; \
+ if( i_mask & 0x01 ) /* 0001 */ \
+ { \
+ p_pic[7] = i_mask_color; \
+ } \
+ } \
+ else /* not 0010 means 0001 */ \
+ { \
+ p_pic[7] = i_mask_color; \
+ } \
+ } \
}
-/*******************************************************************************
+/*****************************************************************************
* Local prototypes
- *******************************************************************************/
-static void PutByte16( u16 *p_pic, int i_byte, int i_char, int i_border, int i_bg,
- u32 i_char_color, u32 i_border_color, u32 i_bg_color );
-static void PutByte24( void *p_pic, int i_byte, byte_t i_char, byte_t i_border, byte_t i_bg,
- u32 i_char_color, u32 i_border_color, u32 i_bg_color );
-static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, byte_t i_bg,
- u32 i_char_color, u32 i_border_color, u32 i_bg_color );
-
-/*******************************************************************************
+ *****************************************************************************/
+static void PutByte8 ( u8 *p_pic, int i_byte, int i_char, int i_border,
+ int i_bg, u32 i_char_color, u32 i_border_color,
+ u32 i_bg_color );
+static void PutByte16( u16 *p_pic, int i_byte, int i_char, int i_border,
+ int i_bg, u32 i_char_color, u32 i_border_color,
+ u32 i_bg_color );
+static void PutByte24( void *p_pic, int i_byte, byte_t i_char, byte_t i_border,
+ byte_t i_bg, u32 i_char_color, u32 i_border_color,
+ u32 i_bg_color );
+static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border,
+ byte_t i_bg, u32 i_char_color, u32 i_border_color,
+ u32 i_bg_color );
+
+/*****************************************************************************
* vout_LoadFont: load a bitmap font from a file
- *******************************************************************************
+ *****************************************************************************
* This function will try to open a .psf font and load it. It will return
* NULL on error.
- *******************************************************************************/
+ *****************************************************************************/
vout_font_t *vout_LoadFont( const char *psz_name )
{
- int i_char, i_line; /* character and line indexes */
- int i_file; /* source file */
- byte_t pi_buffer[2]; /* file buffer */
- vout_font_t * p_font; /* the font itself */
+ int i_char, i_line; /* character and line indexes */
+ int i_file; /* source file */
+ byte_t pi_buffer[2]; /* file buffer */
+ vout_font_t * p_font; /* the font itself */
/* Open file */
i_file = open( psz_name, O_RDONLY );
void vout_Print( vout_font_t *p_font, byte_t *p_pic, int i_bytes_per_pixel, int i_bytes_per_line,
u32 i_char_color, u32 i_border_color, u32 i_bg_color, int i_style, const char *psz_text )
{
- byte_t *p_char, *p_border; /* character and border mask data */
- int i_char_mask, i_border_mask, i_bg_mask; /* masks */
- int i_line; /* current line in character */
- int i_byte; /* current byte in character */
- int i_interspacing; /* offset between two chars */
- int i_font_bytes_per_line, i_font_height; /* font properties */
- vout_put_byte_t *p_PutByte; /* PutByte function */
+ byte_t *p_char, *p_border; /* character and border mask data */
+ int i_char_mask, i_border_mask, i_bg_mask; /* masks */
+ int i_line; /* current line in character */
+ int i_byte; /* current byte in character */
+ int i_interspacing; /* offset between two chars */
+ int i_font_bytes_per_line, i_font_height; /* font properties */
+ vout_put_byte_t *p_PutByte; /* PutByte function */
//?? background: can be something else that whole byte
/* Select output function */
switch( i_bytes_per_pixel )
{
- case 2:
- p_PutByte = (vout_put_byte_t *) PutByte16;
+ case 1:
+ p_PutByte = (vout_put_byte_t *) PutByte8;
break;
+ case 2:
+ p_PutByte = (vout_put_byte_t *) PutByte16;
+ break;
case 3:
- p_PutByte = (vout_put_byte_t *) PutByte24;
- break;
+ p_PutByte = (vout_put_byte_t *) PutByte24;
+ break;
case 4:
#ifndef DEBUG
- default:
+ default:
#endif
- p_PutByte = (vout_put_byte_t *) PutByte32;
- break;
+ p_PutByte = (vout_put_byte_t *) PutByte32;
+ break;
#ifdef DEBUG
default:
- intf_DbgMsg("error: invalid bytes per pixel %d\n", i_bytes_per_pixel );
- p_PutByte = NULL;
+ intf_DbgMsg("error: invalid bytes per pixel %d\n", i_bytes_per_pixel );
+ p_PutByte = NULL;
break;
#endif
- }
+ }
/* Choose masks and copy font data to local variables */
i_char_mask = (i_style & VOID_TEXT) ? 0 : 0xff;
/* following functions are local */
-/*******************************************************************************
+/*****************************************************************************
+ * PutByte8: print a fixed width font character byte in 15 or 16 bpp
+ *****************************************************************************/
+static void PutByte8( u8 *p_pic, int i_byte, int i_char, int i_border,
+ int i_bg, u32 i_char_color, u32 i_border_color,
+ u32 i_bg_color )
+{
+ /* Computes position offset and background mask */
+ p_pic += 8 * i_byte;
+ i_bg &= ~(i_char | i_border);
+
+ /* Put character bits */
+ TREE(i_char, i_char_color);
+ TREE(i_border, i_border_color);
+ TREE(i_bg, i_bg_color);
+}
+
+/*****************************************************************************
* PutByte16: print a fixed width font character byte in 15 or 16 bpp
- *******************************************************************************/
-static void PutByte16( u16 *p_pic, int i_byte, int i_char, int i_border, int i_bg,
- u32 i_char_color, u32 i_border_color, u32 i_bg_color )
+ *****************************************************************************/
+static void PutByte16( u16 *p_pic, int i_byte, int i_char, int i_border,
+ int i_bg, u32 i_char_color, u32 i_border_color,
+ u32 i_bg_color )
{
/* Computes position offset and background mask */
p_pic += 8 * i_byte;
TREE(i_bg, i_bg_color);
}
-/*******************************************************************************
+/*****************************************************************************
* PutByte24: print a fixed width font character byte in 24 bpp
- *******************************************************************************/
+ *****************************************************************************/
static void PutByte24( void *p_pic, int i_byte, byte_t i_char, byte_t i_border, byte_t i_bg,
u32 i_char_color, u32 i_border_color, u32 i_bg_color )
{
//??
}
-/*******************************************************************************
+/*****************************************************************************
* PutByte32: print a fixed width font character byte in 32 bpp
- *******************************************************************************/
+ *****************************************************************************/
static void PutByte32( u32 *p_pic, int i_byte, byte_t i_char, byte_t i_border, byte_t i_bg,
u32 i_char_color, u32 i_border_color, u32 i_bg_color )
{
static void SetOffset ( int i_width, int i_height, int i_pic_width, int i_pic_height,
boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset );
+static void ConvertY4Gray8 ( 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 );
static void ConvertY4Gray16 ( 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 );
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 );
+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 );
+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 );
+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 );
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 );
int i_width, int i_height, int i_pic_width, int i_pic_height, int i_pic_line_width,
int i_matrix_coefficients );
-/*******************************************************************************
+/*****************************************************************************
* CONVERT_YUV_PIXEL, CONVERT_Y_PIXEL: pixel convertion blocks
- *******************************************************************************
+ *****************************************************************************
* These convertion routines are used by YUV convertion functions.
* Convertion are made from p_y, p_u, p_v, which are modified, to p_buffer,
* which is also modified.
- *******************************************************************************/
-#define CONVERT_Y_PIXEL \
- /* Only Y sample is present */ \
- p_ybase = p_yuv + *p_y++; \
- *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128)>>SHIFT) + i_red] | \
- p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) + i_green ] | \
- p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128)>>SHIFT) + i_blue]; \
-
-#define CONVERT_YUV_PIXEL \
- /* Y, U and V samples are present */ \
- i_uval = *p_u++; \
- i_vval = *p_v++; \
- i_red = (V_RED_COEF * i_vval) >> SHIFT; \
- i_green = (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT; \
- i_blue = (U_BLUE_COEF * i_uval) >> SHIFT; \
- CONVERT_Y_PIXEL \
-
-/*******************************************************************************
+ *****************************************************************************/
+#define CONVERT_Y_PIXEL \
+ /* Only Y sample is present */ \
+ p_ybase = p_yuv + *p_y++; \
+ *p_buffer++ = p_ybase[RED_OFFSET-((V_RED_COEF*128)>>SHIFT) + i_red] | \
+ p_ybase[GREEN_OFFSET-(((U_GREEN_COEF+V_GREEN_COEF)*128)>>SHIFT) \
+ + i_green ] | p_ybase[BLUE_OFFSET-((U_BLUE_COEF*128)>>SHIFT) + i_blue];
+
+#define CONVERT_YUV_PIXEL \
+ /* Y, U and V samples are present */ \
+ i_uval = *p_u++; \
+ i_vval = *p_v++; \
+ i_red = (V_RED_COEF * i_vval) >> SHIFT; \
+ i_green = (U_GREEN_COEF * i_uval + V_GREEN_COEF * i_vval) >> SHIFT; \
+ i_blue = (U_BLUE_COEF * i_uval) >> SHIFT; \
+ CONVERT_Y_PIXEL \
+
+/*****************************************************************************
* SCALE_WIDTH: scale a line horizontally
- *******************************************************************************
+ *****************************************************************************
* This macro scale a line using rendering buffer and offset array.
- *******************************************************************************/
-#define SCALE_WIDTH \
- 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++; \
- } \
- p_pic += i_pic_line_width; \
- } \
- 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 + i_pic_line_width; \
- } \
-
-/*******************************************************************************
+ *****************************************************************************/
+#define SCALE_WIDTH \
+ 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++; \
+ } \
+ p_pic += i_pic_line_width; \
+ } \
+ 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 + i_pic_line_width; \
+ } \
+
+/*****************************************************************************
* SCALE_HEIGHT: handle vertical scaling
- *******************************************************************************
+ *****************************************************************************
* This macro handle vertical scaling for a picture. CHROMA may be 420, 422 or
* 444 for RGB convertion, or 400 for gray convertion.
- *******************************************************************************/
-#define SCALE_HEIGHT( CHROMA ) \
- /* If line is odd, rewind 4:2:0 U and V samples */ \
- if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \
- { \
- p_u -= i_chroma_width; \
- p_v -= i_chroma_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; \
- i_y++; \
- if( (CHROMA == 420) || (CHROMA == 422) ) \
- { \
- if( i_y & 0x1 ) \
- { \
- p_u += i_chroma_width; \
- p_v += i_chroma_width; \
- } \
- } \
- else if( CHROMA == 444 ) \
- { \
- p_u += i_width; \
- p_v += i_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; \
- } \
-
-/*******************************************************************************
+ *****************************************************************************/
+#define SCALE_HEIGHT( CHROMA ) \
+ /* If line is odd, rewind 4:2:0 U and V samples */ \
+ if( ((CHROMA == 420) || (CHROMA == 422)) && !(i_y & 0x1) ) \
+ { \
+ p_u -= i_chroma_width; \
+ p_v -= i_chroma_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; \
+ i_y++; \
+ if( (CHROMA == 420) || (CHROMA == 422) ) \
+ { \
+ if( i_y & 0x1 ) \
+ { \
+ p_u += i_chroma_width; \
+ p_v += i_chroma_width; \
+ } \
+ } \
+ else if( CHROMA == 444 ) \
+ { \
+ p_u += i_width; \
+ p_v += i_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; \
+ } \
+
+/*****************************************************************************
* vout_InitYUV: allocate and initialize translations tables
- *******************************************************************************
+ *****************************************************************************
* This function will allocate memory to store translation tables, depending
* of the screen depth.
- *******************************************************************************/
+ *****************************************************************************/
int vout_InitYUV( vout_thread_t *p_vout )
{
- size_t tables_size; /* tables size, in bytes */
+ size_t tables_size; /* tables size, in bytes */
/* Computes tables size */
switch( p_vout->i_screen_depth )
{
+ case 8:
+ tables_size = sizeof( u8 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
+ break;
case 15:
case 16:
tables_size = sizeof( u16 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE);
return( 0 );
}
-/*******************************************************************************
+/*****************************************************************************
* vout_ResetTables: re-initialize translations tables
- *******************************************************************************
+ *****************************************************************************
* This function will initialize the tables allocated by vout_CreateTables and
* set functions pointers.
- *******************************************************************************/
+ *****************************************************************************/
int vout_ResetYUV( vout_thread_t *p_vout )
{
vout_EndYUV( p_vout );
return( vout_InitYUV( p_vout ) );
}
-/*******************************************************************************
+/*****************************************************************************
* vout_EndYUV: destroy translations tables
- *******************************************************************************
+ *****************************************************************************
* Free memory allocated by vout_CreateTables.
- *******************************************************************************/
+ *****************************************************************************/
void vout_EndYUV( vout_thread_t *p_vout )
{
free( p_vout->yuv.p_base );
/* following functions are local */
-/*******************************************************************************
+/*****************************************************************************
* BinaryLog: computes the base 2 log of a binary value
- *******************************************************************************
+ *****************************************************************************
* This functions is used by MaskToShift during tables initialisation, to
* get a bit index from a binary value.
- *******************************************************************************/
+ *****************************************************************************/
static int BinaryLog(u32 i)
{
int i_log;
return( i_log );
}
-/*******************************************************************************
+/*****************************************************************************
* MaskToShift: Transform a color mask into right and left shifts
- *******************************************************************************
+ *****************************************************************************
* This function is used during table initialisation. It can return a value
- *******************************************************************************/
+ *****************************************************************************/
static void MaskToShift (int *pi_right, int *pi_left, u32 i_mask)
{
- u32 i_low, i_high; /* lower hand higher bits of the mask */
+ u32 i_low, i_high; /* lower hand higher bits of the mask */
/* Get bits */
- i_low = i_mask & (- i_mask); /* lower bit of the mask */
- i_high = i_mask + i_low; /* higher bit of the mask */
+ i_low = i_mask & (- i_mask); /* lower bit of the mask */
+ i_high = i_mask + i_low; /* higher bit of the mask */
/* Transform bits into an index */
i_low = BinaryLog (i_low);
*pi_right = (8 - i_high + i_low);
}
-/*******************************************************************************
+/*****************************************************************************
* SetGammaTable: return intensity table transformed by gamma curve.
- *******************************************************************************
+ *****************************************************************************
* pi_table is a table of 256 entries from 0 to 255.
- *******************************************************************************/
+ *****************************************************************************/
static void SetGammaTable( int *pi_table, double f_gamma )
{
- int i_y; /* base intensity */
+ int i_y; /* base intensity */
/* Use exp(gamma) instead of gamma */
f_gamma = exp(f_gamma );
}
}
-/*******************************************************************************
+/*****************************************************************************
* SetYUV: compute tables and set function pointers
-+ *******************************************************************************/
++ *****************************************************************************/
static void SetYUV( vout_thread_t *p_vout )
{
- int pi_gamma[256]; /* gamma table */
- int i_index; /* index in tables */
- int i_red_right, i_red_left; /* red shifts */
- int i_green_right, i_green_left; /* green shifts */
- int i_blue_right, i_blue_left; /* blue shifts */
+ int pi_gamma[256]; /* gamma table */
+ int i_index; /* index in tables */
+ int i_red_right, i_red_left; /* red shifts */
+ int i_green_right, i_green_left; /* green shifts */
+ int i_blue_right, i_blue_left; /* blue shifts */
/* Build gamma table */
SetGammaTable( pi_gamma, p_vout->f_gamma );
*/
switch( p_vout->i_screen_depth )
{
+ case 8:
+ MaskToShift( &i_red_right, &i_red_left, 0xe0 );
+ MaskToShift( &i_green_right, &i_green_left, 0x1c );
+ MaskToShift( &i_blue_right, &i_blue_left, 0x03 );
+ break;
case 15:
MaskToShift( &i_red_right, &i_red_left, 0xf800 );
MaskToShift( &i_green_right, &i_green_left, 0x03e0 );
/* Grayscale: build gray table */
switch( p_vout->i_screen_depth )
{
+ case 8:
+ p_vout->yuv.yuv.p_gray8 = (u8 *)p_vout->yuv.p_base + GRAY_MARGIN;
+ break;
case 15:
case 16:
p_vout->yuv.yuv.p_gray16 = (u16 *)p_vout->yuv.p_base + GRAY_MARGIN;
/* Color: build red, green and blue tables */
switch( p_vout->i_screen_depth )
{
+ case 8:
+ p_vout->yuv.yuv.p_rgb8 = (u8 *)p_vout->yuv.p_base;
+ break;
case 15:
case 16:
p_vout->yuv.yuv.p_rgb16 = (u16 *)p_vout->yuv.p_base;
}
for( i_index = 0; i_index < GREEN_MARGIN; i_index++ )
{
- p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET - GREEN_MARGIN + i_index] = (pi_gamma[0]>>i_green_right)<<i_green_left;
+ p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET - GREEN_MARGIN + i_index] = (pi_gamma[0]>>i_green_right) <<i_green_left;
p_vout->yuv.yuv.p_rgb16[GREEN_OFFSET + 256 + i_index] = (pi_gamma[255]>>i_green_right)<<i_green_left;
}
for( i_index = 0; i_index < BLUE_MARGIN; i_index++ )
/* Grayscale */
switch( p_vout->i_screen_depth )
{
+ case 8:
+ p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray8;
+ p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertY4Gray8;
+ p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertY4Gray8;
+ break;
case 15:
case 16:
p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertY4Gray16;
/* Color */
switch( p_vout->i_screen_depth )
{
+ case 8:
+ p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertYUV420RGB8;
+ p_vout->yuv.p_Convert422 = (vout_yuv_convert_t *) ConvertYUV422RGB8;
+ p_vout->yuv.p_Convert444 = (vout_yuv_convert_t *) ConvertYUV444RGB8;
+ break;
case 15:
case 16:
p_vout->yuv.p_Convert420 = (vout_yuv_convert_t *) ConvertYUV420RGB16;
}
}
-/*******************************************************************************
+/*****************************************************************************
* SetOffset: build offset array for convertion functions
- *******************************************************************************
+ *****************************************************************************
* This function will build an offset array used in later convertion functions.
* It will also set horizontal and vertical scaling indicators.
- *******************************************************************************/
+ *****************************************************************************/
static void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
boolean_t *pb_h_scaling, int *pi_v_scaling, int *p_offset )
{
- int i_x; /* x position in destination */
- int i_scale_count; /* modulo counter */
+ int i_x; /* x position in destination */
+ int i_scale_count; /* modulo counter */
/*
* Prepare horizontal offset array
}
}
-/*******************************************************************************
+/*****************************************************************************
+ * ConvertY4Gray8: grayscale YUV 4:x:x to RGB 8 bpp
+ *****************************************************************************/
+static void ConvertY4Gray8( 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_chroma_width; /* chroma width, not used */
+ u8 * p_gray; /* base convertion table */
+ u8 * p_pic_start; /* beginning of the current line for copy */
+ u8 * p_buffer_start; /* convertion buffer start */
+ u8 * 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;
+ p_gray = p_vout->yuv.yuv.p_gray8;
+ 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 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--; )
+ {
+ *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);
+ }
+}
+
+/*****************************************************************************
* ConvertY4Gray16: grayscale YUV 4:x:x to RGB 15 or 16 bpp
- *******************************************************************************/
+ *****************************************************************************/
static void ConvertY4Gray16( 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_chroma_width; /* chroma width, not used */
- u16 * p_gray; /* base 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 */
+ 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 */
+ u16 * p_gray; /* base 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
}
}
-/*******************************************************************************
+/*****************************************************************************
* ConvertY4Gray24: grayscale YUV 4:x:x to RGB 24 bpp
- *******************************************************************************/
+ *****************************************************************************/
static void ConvertY4Gray24( 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 )
//??
}
-/*******************************************************************************
+/*****************************************************************************
* 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 )
{
- 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 convertion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* convertion buffer start */
- u32 * p_buffer; /* convertion buffer pointer */
- int * p_offset_start; /* offset array start */
- int * p_offset; /* offset array pointer */
+ 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 convertion table */
+ u32 * p_pic_start; /* beginning of the current line for copy */
+ u32 * p_buffer_start; /* convertion buffer start */
+ u32 * 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
}
}
-/*******************************************************************************
+/*****************************************************************************
+ * 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 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 convertion table */
+ u8 * p_ybase; /* Y dependant convertion table */
+ u8 * p_pic_start; /* beginning of the current line for copy */
+ u8 * p_buffer_start; /* convertion buffer start */
+ u8 * 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.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 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;
+ }
+
+ /* Do horizontal and vertical scaling */
+ SCALE_WIDTH;
+ SCALE_HEIGHT(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 convertion table */
+ u8 * p_ybase; /* Y dependant convertion table */
+ u8 * p_pic_start; /* beginning of the current line for copy */
+ u8 * p_buffer_start; /* convertion buffer start */
+ u8 * 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.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 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;
+ }
+
+ /* Do horizontal and vertical scaling */
+ SCALE_WIDTH;
+ SCALE_HEIGHT(422);
+ }
+}
+
+/*****************************************************************************
+ * 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 convertion table */
+ u8 * p_ybase; /* Y dependant convertion table */
+ u8 * p_pic_start; /* beginning of the current line for copy */
+ u8 * p_buffer_start; /* convertion buffer start */
+ u8 * 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;
+ 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 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_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ CONVERT_YUV_PIXEL; CONVERT_YUV_PIXEL;
+ }
+
+ /* Do horizontal and vertical scaling */
+ SCALE_WIDTH;
+ SCALE_HEIGHT(444);
+ }
+}
+
+/*****************************************************************************
* 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 )
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 */
+ 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
}
}
-/*******************************************************************************
+/*****************************************************************************
* 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 )
{
- 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 */
+ 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
}
}
-/*******************************************************************************
+/*****************************************************************************
* 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 )
{
- 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 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 */
+ 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 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
}
}
-/*******************************************************************************
+/*****************************************************************************
* 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 )
{
- 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 convertion table */
- u32 * p_ybase; /* Y dependant convertion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* convertion buffer start */
- u32 * p_buffer; /* convertion buffer pointer */
- int * p_offset_start; /* offset array start */
- int * p_offset; /* offset array pointer */
+ 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 convertion table */
+ u32 * p_ybase; /* Y dependant convertion table */
+ u32 * p_pic_start; /* beginning of the current line for copy */
+ u32 * p_buffer_start; /* convertion buffer start */
+ u32 * 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
}
}
-/*******************************************************************************
+/*****************************************************************************
* 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 )
{
- 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 convertion table */
- u32 * p_ybase; /* Y dependant convertion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* convertion buffer start */
- u32 * p_buffer; /* convertion buffer pointer */
- int * p_offset_start; /* offset array start */
- int * p_offset; /* offset array pointer */
+ 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 convertion table */
+ u32 * p_ybase; /* Y dependant convertion table */
+ u32 * p_pic_start; /* beginning of the current line for copy */
+ u32 * p_buffer_start; /* convertion buffer start */
+ u32 * 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
}
}
-/*******************************************************************************
+/*****************************************************************************
* 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 )
{
- 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 convertion table */
- u32 * p_ybase; /* Y dependant convertion table */
- u32 * p_pic_start; /* beginning of the current line for copy */
- u32 * p_buffer_start; /* convertion buffer start */
- u32 * p_buffer; /* convertion buffer pointer */
- int * p_offset_start; /* offset array start */
- int * p_offset; /* offset array pointer */
+ 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 convertion table */
+ u32 * p_ybase; /* Y dependant convertion table */
+ u32 * p_pic_start; /* beginning of the current line for copy */
+ u32 * p_buffer_start; /* convertion buffer start */
+ u32 * 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
}
}
-//-------------------- walken code follow ---------------------------------------
+//-------------------- walken code follows ------------------------------------
/*
* YUV to RGB routines.