📄 .#video_yuv.c.1.33
字号:
/* Horizontal scaling, conversion 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, conversion 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_WIDTH_DITHER: scale a line horizontally for dithered 8 bpp ***************************************************************************** * This macro scales a line using an offset array. *****************************************************************************/#define SCALE_WIDTH_DITHER( CHROMA ) \ if( b_horizontal_scaling ) \ { \ /* Horizontal scaling, but we can't use a buffer due to dither */ \ p_offset = p_offset_start; \ b_jump_uv = 0; \ for( i_x = i_pic_width / 16; i_x--; ) \ { \ CONVERT_4YUV_PIXELS_SCALE( CHROMA ) \ CONVERT_4YUV_PIXELS_SCALE( CHROMA ) \ CONVERT_4YUV_PIXELS_SCALE( CHROMA ) \ CONVERT_4YUV_PIXELS_SCALE( CHROMA ) \ } \ } \ else \ { \ for( i_x = i_width / 16; i_x--; ) \ { \ CONVERT_4YUV_PIXELS( CHROMA ) \ CONVERT_4YUV_PIXELS( CHROMA ) \ CONVERT_4YUV_PIXELS( CHROMA ) \ CONVERT_4YUV_PIXELS( CHROMA ) \ } \ } \ /* Increment of picture pointer to end of line is still needed */ \ p_pic += i_pic_line_width; \ i_real_y = (i_real_y + 1) & 0x3; \/***************************************************************************** * SCALE_HEIGHT: handle vertical scaling ***************************************************************************** * This macro handle vertical scaling for a picture. CHROMA may be 420, 422 or * 444 for RGB conversion, or 400 for gray conversion. It works for 1, 2, 3 * and 4 Bpp. *****************************************************************************/#define SCALE_HEIGHT( CHROMA, BPP ) \ /* 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)++ ); \ if( BPP > 1 ) /* 2, 3, 4 Bpp */ \ { \ *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ ); \ *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ ); \ } \ if( BPP > 2 ) /* 3, 4 Bpp */ \ { \ *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ ); \ *(((u64 *) p_pic)++) = *(((u64 *) p_pic_start)++ ); \ } \ if( BPP > 3 ) /* 4 Bpp */ \ { \ *(((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; \ } \/***************************************************************************** * SCALE_HEIGHT_DITHER: handle vertical scaling for dithered 8 bpp ***************************************************************************** * This macro handles vertical scaling for a picture. CHROMA may be 420, 422 or * 444 for RGB conversion, or 400 for gray conversion. *****************************************************************************/#define SCALE_HEIGHT_DITHER( 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 ) \ { \ SCALE_WIDTH_DITHER( CHROMA ); \ p_y -= i_width; \ p_u -= i_chroma_width; \ p_v -= i_chroma_width; \ p_pic += 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 */ /* Computes tables size - 3 Bpp use 32 bits pixel entries in tables */ switch( p_vout->i_bytes_per_pixel ) { case 1: tables_size = sizeof( u8 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : PALETTE_TABLE_SIZE); break; case 2: tables_size = sizeof( u16 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE); break; case 3: case 4: default: tables_size = sizeof( u32 ) * (p_vout->b_grayscale ? GRAY_TABLE_SIZE : RGB_TABLE_SIZE); break; } /* Allocate memory */ p_vout->yuv.p_base = malloc( tables_size ); if( p_vout->yuv.p_base == NULL ) { intf_ErrMsg("error: %s\n", strerror(ENOMEM)); return( 1 ); } /* Allocate memory for conversion buffer and offset array */ p_vout->yuv.p_buffer = malloc( VOUT_MAX_WIDTH * p_vout->i_bytes_per_pixel ); if( p_vout->yuv.p_buffer == NULL ) { intf_ErrMsg("error: %s\n", strerror(ENOMEM)); free( p_vout->yuv.p_base ); return( 1 ); } p_vout->yuv.p_offset = malloc( p_vout->i_width * sizeof( int ) ); if( p_vout->yuv.p_offset == NULL )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -