📄 video_yuv.c
字号:
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_gray16; 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, 2); }}/***************************************************************************** * ConvertY4Gray24: grayscale YUV 4:x:x to RGB 3 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 ){ /* XXX?? */}/***************************************************************************** * 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] = { 0x0, 0x10, 0x4, 0x14 }; int dither21[4] = { 0x18, 0x8, 0x1c, 0xc }; int dither22[4] = { 0x6, 0x16, 0x2, 0x12 }; int dither23[4] = { 0x1e, 0xe, 0x1a, 0xa }; /* other matrices that can be interesting, either for debugging or for effects */#if 0 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 } };#endif /* * 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); }}/***********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -