static int ivi_init_tiles(IVIBandDesc *band, IVITile *ref_tile,

                          int p, int b, int t_height, int t_width)

{

    int x, y;

    IVITile *tile = band->tiles;



    for (y = 0; y < band->height; y += t_height) {

        for (x = 0; x < band->width; x += t_width) {

            tile->xpos     = x;

            tile->ypos     = y;

            tile->mb_size  = band->mb_size;

            tile->width    = FFMIN(band->width - x,  t_width);

            tile->height   = FFMIN(band->height - y, t_height);

            tile->is_empty = tile->data_size = 0;

            /* calculate number of macroblocks */

            tile->num_MBs  = IVI_MBs_PER_TILE(tile->width, tile->height,

                                              band->mb_size);



            av_freep(&tile->mbs);

            tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));

            if (!tile->mbs)

                return AVERROR(ENOMEM);



            tile->ref_mbs = 0;

            if (p || b) {

                if (tile->num_MBs != ref_tile->num_MBs) {

                    av_log(NULL, AV_LOG_DEBUG, "ref_tile mismatch\n");

                    return AVERROR_INVALIDDATA;

                }

                tile->ref_mbs = ref_tile->mbs;

                ref_tile++;

            }

            tile++;

        }

    }



    return 0;

}

static int ivi_init_tiles(IVIBandDesc *band, IVITile *ref_tile,

                          int p, int b, int t_height, int t_width)

{

    int x, y;

    IVITile *tile = band->tiles;



    for (y = 0; y < band->height; y += t_height) {

        for (x = 0; x < band->width; x += t_width) {

            tile->xpos     = x;

            tile->ypos     = y;

            tile->mb_size  = band->mb_size;

            tile->width    = FFMIN(band->width - x,  t_width);

            tile->height   = FFMIN(band->height - y, t_height);

            tile->is_empty = tile->data_size = 0;

            

            tile->num_MBs  = IVI_MBs_PER_TILE(tile->width, tile->height,

                                              band->mb_size);



            av_freep(&tile->mbs);

            tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));

            if (!tile->mbs)

                return AVERROR(ENOMEM);



            tile->ref_mbs = 0;

            if (p || b) {

                if (tile->num_MBs != ref_tile->num_MBs) {

                    av_log(NULL, AV_LOG_DEBUG, "ref_tile mismatch\n");

                    return AVERROR_INVALIDDATA;

                }

                tile->ref_mbs = ref_tile->mbs;

                ref_tile++;

            }

            tile++;

        }

    }



    return 0;

}

            tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
static int FUNC_0(IVIBandDesc *VAR_0, IVITile *VAR_1,

                          int VAR_2, int VAR_3, int VAR_4, int VAR_5)

{

    int VAR_6, VAR_7;

    IVITile *tile = VAR_0->tiles;



    for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7 += VAR_4) {

        for (VAR_6 = 0; VAR_6 < VAR_0->width; VAR_6 += VAR_5) {

            tile->xpos     = VAR_6;

            tile->ypos     = VAR_7;

            tile->mb_size  = VAR_0->mb_size;

            tile->width    = FFMIN(VAR_0->width - VAR_6,  VAR_5);

            tile->height   = FFMIN(VAR_0->height - VAR_7, VAR_4);

            tile->is_empty = tile->data_size = 0;

            

            tile->num_MBs  = IVI_MBs_PER_TILE(tile->width, tile->height,

                                              VAR_0->mb_size);



            av_freep(&tile->mbs);

            tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));

            if (!tile->mbs)

                return AVERROR(ENOMEM);



            tile->ref_mbs = 0;

            if (VAR_2 || VAR_3) {

                if (tile->num_MBs != VAR_1->num_MBs) {

                    av_log(NULL, AV_LOG_DEBUG, "VAR_1 mismatch\n");

                    return AVERROR_INVALIDDATA;

                }

                tile->ref_mbs = VAR_1->mbs;

                VAR_1++;

            }

            tile++;

        }

    }



    return 0;

}

static int FUNC_0(IVIBandDesc *VAR_0, IVITile *VAR_1,
int VAR_2, int VAR_3, int VAR_4, int VAR_5)
{ int VAR_6, VAR_7; IVITile *tile = VAR_0->tiles; for (VAR_7 = 0; VAR_7 < VAR_0->height; VAR_7 += VAR_4) { for (VAR_6 = 0; VAR_6 < VAR_0->width; VAR_6 += VAR_5) { tile->xpos     = VAR_6; tile->ypos     = VAR_7; tile->mb_size  = VAR_0->mb_size; tile->width    = FFMIN(VAR_0->width - VAR_6,  VAR_5); tile->height   = FFMIN(VAR_0->height - VAR_7, VAR_4); tile->is_empty = tile->data_size = 0; tile->num_MBs  = IVI_MBs_PER_TILE(tile->width, tile->height,
VAR_0->mb_size); av_freep(&tile->mbs); tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo)); if (!tile->mbs)
return AVERROR(ENOMEM); tile->ref_mbs = 0; if (VAR_2 || VAR_3) { if (tile->num_MBs != VAR_1->num_MBs) { av_log(NULL, AV_LOG_DEBUG, "VAR_1 mismatch\n"); return AVERROR_INVALIDDATA; } tile->ref_mbs = VAR_1->mbs; VAR_1++; } tile++; } } return 0; }