📄 vout_pictures.c
字号:
/* Store default values */ for( i_index = 0; i_index < VOUT_MAX_PLANES; i_index++ ) { p_pic->p[i_index].p_pixels = NULL; p_pic->p[i_index].i_pixel_pitch = 1; } p_pic->pf_release = 0; p_pic->pf_lock = 0; p_pic->pf_unlock = 0; p_pic->i_refcount = 0; vout_InitFormat( &p_pic->format, i_chroma, i_width, i_height, i_aspect ); /* Make sure the real dimensions are a multiple of 16 */ i_width_aligned = (i_width + 15) >> 4 << 4; i_height_aligned = (i_height + 15) >> 4 << 4; /* Calculate coordinates */ switch( i_chroma ) { case FOURCC_I411: p_pic->p[ Y_PLANE ].i_lines = i_height_aligned; p_pic->p[ Y_PLANE ].i_visible_lines = i_height; p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned; p_pic->p[ Y_PLANE ].i_visible_pitch = i_width; p_pic->p[ U_PLANE ].i_lines = i_height_aligned; p_pic->p[ U_PLANE ].i_visible_lines = i_height; p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 4; p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 4; p_pic->p[ V_PLANE ].i_lines = i_height_aligned; p_pic->p[ V_PLANE ].i_visible_lines = i_height; p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 4; p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 4; p_pic->i_planes = 3; break; case FOURCC_I410: case FOURCC_YVU9: p_pic->p[ Y_PLANE ].i_lines = i_height_aligned; p_pic->p[ Y_PLANE ].i_visible_lines = i_height; p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned; p_pic->p[ Y_PLANE ].i_visible_pitch = i_width; p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 4; p_pic->p[ U_PLANE ].i_visible_lines = i_height / 4; p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 4; p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 4; p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 4; p_pic->p[ V_PLANE ].i_visible_lines = i_height / 4; p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 4; p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 4; p_pic->i_planes = 3; break; case FOURCC_YV12: case FOURCC_I420: case FOURCC_IYUV: case FOURCC_J420: p_pic->p[ Y_PLANE ].i_lines = i_height_aligned; p_pic->p[ Y_PLANE ].i_visible_lines = i_height; p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned; p_pic->p[ Y_PLANE ].i_visible_pitch = i_width; p_pic->p[ U_PLANE ].i_lines = i_height_aligned / 2; p_pic->p[ U_PLANE ].i_visible_lines = i_height / 2; p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 2; p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 2; p_pic->p[ V_PLANE ].i_lines = i_height_aligned / 2; p_pic->p[ V_PLANE ].i_visible_lines = i_height / 2; p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 2; p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 2; p_pic->i_planes = 3; break; case FOURCC_I422: case FOURCC_J422: p_pic->p[ Y_PLANE ].i_lines = i_height_aligned; p_pic->p[ Y_PLANE ].i_visible_lines = i_height; p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned; p_pic->p[ Y_PLANE ].i_visible_pitch = i_width; p_pic->p[ U_PLANE ].i_lines = i_height_aligned; p_pic->p[ U_PLANE ].i_visible_lines = i_height; p_pic->p[ U_PLANE ].i_pitch = i_width_aligned / 2; p_pic->p[ U_PLANE ].i_visible_pitch = i_width / 2; p_pic->p[ V_PLANE ].i_lines = i_height_aligned; p_pic->p[ V_PLANE ].i_visible_lines = i_height; p_pic->p[ V_PLANE ].i_pitch = i_width_aligned / 2; p_pic->p[ V_PLANE ].i_visible_pitch = i_width / 2; p_pic->i_planes = 3; break; case FOURCC_I444: case FOURCC_J444: p_pic->p[ Y_PLANE ].i_lines = i_height_aligned; p_pic->p[ Y_PLANE ].i_visible_lines = i_height; p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned; p_pic->p[ Y_PLANE ].i_visible_pitch = i_width; p_pic->p[ U_PLANE ].i_lines = i_height_aligned; p_pic->p[ U_PLANE ].i_visible_lines = i_height; p_pic->p[ U_PLANE ].i_pitch = i_width_aligned; p_pic->p[ U_PLANE ].i_visible_pitch = i_width; p_pic->p[ V_PLANE ].i_lines = i_height_aligned; p_pic->p[ V_PLANE ].i_visible_lines = i_height; p_pic->p[ V_PLANE ].i_pitch = i_width_aligned; p_pic->p[ V_PLANE ].i_visible_pitch = i_width; p_pic->i_planes = 3; break; case FOURCC_YUVA: p_pic->p[ Y_PLANE ].i_lines = i_height_aligned; p_pic->p[ Y_PLANE ].i_visible_lines = i_height; p_pic->p[ Y_PLANE ].i_pitch = i_width_aligned; p_pic->p[ Y_PLANE ].i_visible_pitch = i_width; p_pic->p[ U_PLANE ].i_lines = i_height_aligned; p_pic->p[ U_PLANE ].i_visible_lines = i_height; p_pic->p[ U_PLANE ].i_pitch = i_width_aligned; p_pic->p[ U_PLANE ].i_visible_pitch = i_width; p_pic->p[ V_PLANE ].i_lines = i_height_aligned; p_pic->p[ V_PLANE ].i_visible_lines = i_height; p_pic->p[ V_PLANE ].i_pitch = i_width_aligned; p_pic->p[ V_PLANE ].i_visible_pitch = i_width; p_pic->p[ A_PLANE ].i_lines = i_height_aligned; p_pic->p[ A_PLANE ].i_visible_lines = i_height; p_pic->p[ A_PLANE ].i_pitch = i_width_aligned; p_pic->p[ A_PLANE ].i_visible_pitch = i_width; p_pic->i_planes = 4; break; case FOURCC_YUVP: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned; p_pic->p->i_visible_pitch = i_width; p_pic->p->i_pixel_pitch = 8; p_pic->i_planes = 1; break; case FOURCC_Y211: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned; p_pic->p->i_visible_pitch = i_width; p_pic->p->i_pixel_pitch = 4; p_pic->i_planes = 1; break; case FOURCC_UYVY: case FOURCC_YUY2: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned * 2; p_pic->p->i_visible_pitch = i_width * 2; p_pic->p->i_pixel_pitch = 4; p_pic->i_planes = 1; break; case FOURCC_RGB2: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned; p_pic->p->i_visible_pitch = i_width; p_pic->p->i_pixel_pitch = 1; p_pic->i_planes = 1; break; case FOURCC_RV15: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned * 2; p_pic->p->i_visible_pitch = i_width * 2; p_pic->p->i_pixel_pitch = 2; p_pic->i_planes = 1; break; case FOURCC_RV16: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned * 2; p_pic->p->i_visible_pitch = i_width * 2; p_pic->p->i_pixel_pitch = 2; p_pic->i_planes = 1; break; case FOURCC_RV24: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned * 3; p_pic->p->i_visible_pitch = i_width * 3; p_pic->p->i_pixel_pitch = 3; p_pic->i_planes = 1; break; case FOURCC_RV32: p_pic->p->i_lines = i_height_aligned; p_pic->p->i_visible_lines = i_height; p_pic->p->i_pitch = i_width_aligned * 4; p_pic->p->i_visible_pitch = i_width * 4; p_pic->p->i_pixel_pitch = 4; p_pic->i_planes = 1; break; default: msg_Err( p_this, "unknown chroma type 0x%.8x (%4.4s)", i_chroma, (char*)&i_chroma ); p_pic->i_planes = 0; return VLC_EGENERIC; } return VLC_SUCCESS;}/** * Compare two chroma values * * This function returns 1 if the two fourcc values given as argument are * the same format (eg. UYVY/UYNV) or almost the same format (eg. I420/YV12) */int vout_ChromaCmp( vlc_fourcc_t i_chroma, vlc_fourcc_t i_amorhc ){ /* If they are the same, they are the same ! */ if( i_chroma == i_amorhc ) { return 1; } /* Check for equivalence classes */ switch( i_chroma ) { case FOURCC_I420: case FOURCC_IYUV: case FOURCC_YV12: switch( i_amorhc ) { case FOURCC_I420: case FOURCC_IYUV: case FOURCC_YV12: return 1; default: return 0; } case FOURCC_UYVY: case FOURCC_UYNV: case FOURCC_Y422: switch( i_amorhc ) { case FOURCC_UYVY: case FOURCC_UYNV: case FOURCC_Y422: return 1; default: return 0; } case FOURCC_YUY2: case FOURCC_YUNV: switch( i_amorhc ) { case FOURCC_YUY2: case FOURCC_YUNV: return 1; default: return 0; } default: return 0; }}/***************************************************************************** * vout_CopyPicture: copy a picture to another one ***************************************************************************** * This function takes advantage of the image format, and reduces the * number of calls to memcpy() to the minimum. Source and destination * images must have same width (hence i_visible_pitch), height, and chroma. *****************************************************************************/void __vout_CopyPicture( vlc_object_t *p_this, picture_t *p_dest, picture_t *p_src ){ int i; for( i = 0; i < p_src->i_planes ; i++ ) { if( p_src->p[i].i_pitch == p_dest->p[i].i_pitch ) { /* There are margins, but with the same width : perfect ! */ p_this->p_vlc->pf_memcpy( p_dest->p[i].p_pixels, p_src->p[i].p_pixels, p_src->p[i].i_pitch * p_src->p[i].i_visible_lines ); } else { /* We need to proceed line by line */ uint8_t *p_in = p_src->p[i].p_pixels; uint8_t *p_out = p_dest->p[i].p_pixels; int i_line; for( i_line = p_src->p[i].i_visible_lines; i_line--; ) { p_this->p_vlc->pf_memcpy( p_out, p_in, p_src->p[i].i_visible_pitch ); p_in += p_src->p[i].i_pitch; p_out += p_dest->p[i].i_pitch; } } } p_dest->date = p_src->date; p_dest->b_force = p_src->b_force; p_dest->i_nb_fields = p_src->i_nb_fields; p_dest->b_progressive = p_src->b_progressive; p_dest->b_top_field_first = p_src->b_top_field_first;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -