int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,

                     unsigned char *dest, int dest_size)

{

    PixFmtInfo* pf = &pix_fmt_info[pix_fmt];

    int i, j, w, h, data_planes;

    const unsigned char* s; 

    int size = avpicture_get_size(pix_fmt, width, height);



    if (size > dest_size)

        return -1;



    if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {

        if (pix_fmt == PIX_FMT_YUV422 || 

            pix_fmt == PIX_FMT_UYVY422 || 

            pix_fmt == PIX_FMT_RGB565 ||

            pix_fmt == PIX_FMT_RGB555)

            w = width * 2;

	else if (pix_fmt == PIX_FMT_UYVY411)

	  w = width + width/2;

	else if (pix_fmt == PIX_FMT_PAL8)

	  w = width;

	else

	  w = width * (pf->depth * pf->nb_channels / 8);

	  

	data_planes = 1;

	h = height;

    } else {

        data_planes = pf->nb_channels;

	w = (width*pf->depth + 7)/8;

	h = height;

    }

    

    for (i=0; i<data_planes; i++) {

         if (i == 1) {

	     w = width >> pf->x_chroma_shift;

	     h = height >> pf->y_chroma_shift;

	 }

         s = src->data[i];

	 for(j=0; j<h; j++) {

	     memcpy(dest, s, w);

	     dest += w;

	     s += src->linesize[i];

	 }

    }

    

    if (pf->pixel_type == FF_PIXEL_PALETTE)

	memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);

    

    return size;

}

int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,

                     unsigned char *dest, int dest_size)

{

    PixFmtInfo* pf = &pix_fmt_info[pix_fmt];

    int i, j, w, h, data_planes;

    const unsigned char* s; 

    int size = avpicture_get_size(pix_fmt, width, height);



    if (size > dest_size)

        return -1;



    if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {

        if (pix_fmt == PIX_FMT_YUV422 || 

            pix_fmt == PIX_FMT_UYVY422 || 

            pix_fmt == PIX_FMT_RGB565 ||

            pix_fmt == PIX_FMT_RGB555)

            w = width * 2;

	else if (pix_fmt == PIX_FMT_UYVY411)

	  w = width + width/2;

	else if (pix_fmt == PIX_FMT_PAL8)

	  w = width;

	else

	  w = width * (pf->depth * pf->nb_channels / 8);

	  

	data_planes = 1;

	h = height;

    } else {

        data_planes = pf->nb_channels;

	w = (width*pf->depth + 7)/8;

	h = height;

    }

    

    for (i=0; i<data_planes; i++) {

         if (i == 1) {

	     w = width >> pf->x_chroma_shift;

	     h = height >> pf->y_chroma_shift;

	 }

         s = src->data[i];

	 for(j=0; j<h; j++) {

	     memcpy(dest, s, w);

	     dest += w;

	     s += src->linesize[i];

	 }

    }

    

    if (pf->pixel_type == FF_PIXEL_PALETTE)

	memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4);

    

    return size;

}

    if (size > dest_size)
int FUNC_0(const AVPicture* VAR_0, int VAR_1, int VAR_2, int VAR_3,

                     unsigned char *VAR_4, int VAR_5)

{

    PixFmtInfo* pf = &pix_fmt_info[VAR_1];

    int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;

    const unsigned char* VAR_11; 

    int VAR_12 = avpicture_get_size(VAR_1, VAR_2, VAR_3);



    if (VAR_12 > VAR_5)

        return -1;



    if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) {

        if (VAR_1 == PIX_FMT_YUV422 || 

            VAR_1 == PIX_FMT_UYVY422 || 

            VAR_1 == PIX_FMT_RGB565 ||

            VAR_1 == PIX_FMT_RGB555)

            VAR_8 = VAR_2 * 2;

	else if (VAR_1 == PIX_FMT_UYVY411)

	  VAR_8 = VAR_2 + VAR_2/2;

	else if (VAR_1 == PIX_FMT_PAL8)

	  VAR_8 = VAR_2;

	else

	  VAR_8 = VAR_2 * (pf->depth * pf->nb_channels / 8);

	  

	VAR_10 = 1;

	VAR_9 = VAR_3;

    } else {

        VAR_10 = pf->nb_channels;

	VAR_8 = (VAR_2*pf->depth + 7)/8;

	VAR_9 = VAR_3;

    }

    

    for (VAR_6=0; VAR_6<VAR_10; VAR_6++) {

         if (VAR_6 == 1) {

	     VAR_8 = VAR_2 >> pf->x_chroma_shift;

	     VAR_9 = VAR_3 >> pf->y_chroma_shift;

	 }

         VAR_11 = VAR_0->data[VAR_6];

	 for(VAR_7=0; VAR_7<VAR_9; VAR_7++) {

	     memcpy(VAR_4, VAR_11, VAR_8);

	     VAR_4 += VAR_8;

	     VAR_11 += VAR_0->linesize[VAR_6];

	 }

    }

    

    if (pf->pixel_type == FF_PIXEL_PALETTE)

	memcpy((unsigned char *)(((size_t)VAR_4 + 3) & ~3), VAR_0->data[1], 256 * 4);

    

    return VAR_12;

}

int FUNC_0(const AVPicture* VAR_0, int VAR_1, int VAR_2, int VAR_3,
unsigned char *VAR_4, int VAR_5)
{ PixFmtInfo* pf = &pix_fmt_info[VAR_1]; int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; const unsigned char* VAR_11; int VAR_12 = avpicture_get_size(VAR_1, VAR_2, VAR_3); if (VAR_12 > VAR_5)
return -1; if (pf->pixel_type == FF_PIXEL_PACKED || pf->pixel_type == FF_PIXEL_PALETTE) { if (VAR_1 == PIX_FMT_YUV422 ||
VAR_1 == PIX_FMT_UYVY422 ||
VAR_1 == PIX_FMT_RGB565 ||
VAR_1 == PIX_FMT_RGB555)
VAR_8 = VAR_2 * 2; else if (VAR_1 == PIX_FMT_UYVY411)
VAR_8 = VAR_2 + VAR_2/2; else if (VAR_1 == PIX_FMT_PAL8)
VAR_8 = VAR_2; else
VAR_8 = VAR_2 * (pf->depth * pf->nb_channels / 8); VAR_10 = 1; VAR_9 = VAR_3; } else { VAR_10 = pf->nb_channels; VAR_8 = (VAR_2*pf->depth + 7)/8; VAR_9 = VAR_3; } for (VAR_6=0; VAR_6<VAR_10; VAR_6++) { if (VAR_6 == 1) { VAR_8 = VAR_2 >> pf->x_chroma_shift; VAR_9 = VAR_3 >> pf->y_chroma_shift; } VAR_11 = VAR_0->data[VAR_6]; for(VAR_7=0; VAR_7<VAR_9; VAR_7++) { memcpy(VAR_4, VAR_11, VAR_8); VAR_4 += VAR_8; VAR_11 += VAR_0->linesize[VAR_6]; } } if (pf->pixel_type == FF_PIXEL_PALETTE)
memcpy((unsigned char *)(((size_t)VAR_4 + 3) & ~3), VAR_0->data[1], 256 * 4); return VAR_12; }