-/**
- * Initialise the video format fields given chroma/size.
- *
- * This function initializes all the video_frame_format_t fields given the
- * static properties of a picture (chroma and size).
- * \param p_format Pointer to the format structure to initialize
- * \param i_chroma Chroma to set
- * \param i_width Width to set
- * \param i_height Height to set
- * \param i_aspect Aspect ratio
- */
-void vout_InitFormat( video_frame_format_t *p_format, vlc_fourcc_t i_chroma,
- int i_width, int i_height, int i_aspect )
-{
- video_format_Setup( p_format, i_chroma, i_width, i_height, i_aspect );
-}
-
-/**
- * Initialise the picture_t fields given chroma/size.
- *
- * This function initializes most of the picture_t fields given a chroma and
- * size. It makes the assumption that stride == width.
- * \param p_this The calling object
- * \param p_pic Pointer to the picture to initialize
- * \param i_chroma The chroma fourcc to set
- * \param i_width The width of the picture
- * \param i_height The height of the picture
- * \param i_aspect The aspect ratio of the picture
- */
-int __vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
- vlc_fourcc_t i_chroma,
- int i_width, int i_height, int i_aspect )
-{
- int i_index, i_width_aligned, i_height_aligned;
-
- /* 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 = NULL;
- p_pic->pf_lock = NULL;
- p_pic->pf_unlock = NULL;
- p_pic->i_refcount = 0;
-
- p_pic->i_qtype = QTYPE_NONE;
- p_pic->i_qstride = 0;
- p_pic->p_q = NULL;
-
- 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( vlc_fourcc_GetCodec( VIDEO_ES, i_chroma ) )
- {
- case VLC_CODEC_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 VLC_CODEC_I410:
- 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 VLC_CODEC_YV12:
- case VLC_CODEC_I420:
- case VLC_CODEC_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 VLC_CODEC_I422:
- case VLC_CODEC_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 VLC_CODEC_I440:
- case VLC_CODEC_J440:
- 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;
- p_pic->p[ U_PLANE ].i_visible_pitch = i_width;
- 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;
- p_pic->p[ V_PLANE ].i_visible_pitch = i_width;
- p_pic->i_planes = 3;
- break;
-
- case VLC_CODEC_I444:
- case VLC_CODEC_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 VLC_CODEC_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 VLC_CODEC_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 VLC_CODEC_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 VLC_CODEC_UYVY:
- case VLC_CODEC_VYUY:
- case VLC_CODEC_YUYV:
- case VLC_CODEC_YVYU:
- 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 VLC_CODEC_RGB8:
- 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 VLC_CODEC_RGB15:
- 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 VLC_CODEC_RGB16:
- 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 VLC_CODEC_RGB24:
- 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 VLC_CODEC_RGB32:
- case VLC_CODEC_RGBA:
- 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;
-
- case VLC_CODEC_GREY:
- case VLC_CODEC_RGBP:
- 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;
-
- default:
- if( p_this )
- 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;
-}
-