void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,

                               IVITile *tile, int32_t mv_scale)

{

    int             x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;

    int             offs, mb_offset, row_offset;

    IVIMbInfo       *mb, *ref_mb;

    const int16_t   *src;

    int16_t         *dst;

    void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,

                             int mc_type);



    offs       = tile->ypos * band->pitch + tile->xpos;

    mb         = tile->mbs;

    ref_mb     = tile->ref_mbs;

    row_offset = band->mb_size * band->pitch;

    need_mc    = 0; /* reset the mc tracking flag */



    for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {

        mb_offset = offs;



        for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {

            mb->xpos     = x;

            mb->ypos     = y;

            mb->buf_offs = mb_offset;



            mb->type = 1; /* set the macroblocks type = INTER */

            mb->cbp  = 0; /* all blocks are empty */



            if (!band->qdelta_present && !band->plane && !band->band_num) {

                mb->q_delta = band->glob_quant;

                mb->mv_x    = 0;

                mb->mv_y    = 0;

            }



            if (band->inherit_qdelta && ref_mb)

                mb->q_delta = ref_mb->q_delta;



            if (band->inherit_mv) {

                /* motion vector inheritance */

                if (mv_scale) {

                    mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);

                    mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);

                } else {

                    mb->mv_x = ref_mb->mv_x;

                    mb->mv_y = ref_mb->mv_y;

                }

                need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */

            }



            mb++;

            if (ref_mb)

                ref_mb++;

            mb_offset += band->mb_size;

        } // for x

        offs += row_offset;

    } // for y



    if (band->inherit_mv && need_mc) { /* apply motion compensation if there is at least one non-zero motion vector */

        num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; /* number of blocks per mb */

        mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta

                                                 : ff_ivi_mc_4x4_no_delta;



        for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {

            mv_x = mb->mv_x;

            mv_y = mb->mv_y;

            if (!band->is_halfpel) {

                mc_type = 0; /* we have only fullpel vectors */

            } else {

                mc_type = ((mv_y & 1) << 1) | (mv_x & 1);

                mv_x >>= 1;

                mv_y >>= 1; /* convert halfpel vectors into fullpel ones */

            }



            for (blk = 0; blk < num_blocks; blk++) {

                /* adjust block position in the buffer according with its number */

                offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);

                mc_no_delta_func(band->buf + offs,

                                 band->ref_buf + offs + mv_y * band->pitch + mv_x,

                                 band->pitch, mc_type);

            }

        }

    } else {

        /* copy data from the reference tile into the current one */

        src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;

        dst = band->buf     + tile->ypos * band->pitch + tile->xpos;

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

            memcpy(dst, src, tile->width*sizeof(band->buf[0]));

            src += band->pitch;

            dst += band->pitch;

        }

    }

}

void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,

                               IVITile *tile, int32_t mv_scale)

{

    int             x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;

    int             offs, mb_offset, row_offset;

    IVIMbInfo       *mb, *ref_mb;

    const int16_t   *src;

    int16_t         *dst;

    void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,

                             int mc_type);



    offs       = tile->ypos * band->pitch + tile->xpos;

    mb         = tile->mbs;

    ref_mb     = tile->ref_mbs;

    row_offset = band->mb_size * band->pitch;

    need_mc    = 0; 



    for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {

        mb_offset = offs;



        for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {

            mb->xpos     = x;

            mb->ypos     = y;

            mb->buf_offs = mb_offset;



            mb->type = 1; 

            mb->cbp  = 0; 



            if (!band->qdelta_present && !band->plane && !band->band_num) {

                mb->q_delta = band->glob_quant;

                mb->mv_x    = 0;

                mb->mv_y    = 0;

            }



            if (band->inherit_qdelta && ref_mb)

                mb->q_delta = ref_mb->q_delta;



            if (band->inherit_mv) {

                

                if (mv_scale) {

                    mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);

                    mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);

                } else {

                    mb->mv_x = ref_mb->mv_x;

                    mb->mv_y = ref_mb->mv_y;

                }

                need_mc |= mb->mv_x || mb->mv_y; 

            }



            mb++;

            if (ref_mb)

                ref_mb++;

            mb_offset += band->mb_size;

        } 

        offs += row_offset;

    } 



    if (band->inherit_mv && need_mc) { 

        num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; 

        mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta

                                                 : ff_ivi_mc_4x4_no_delta;



        for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {

            mv_x = mb->mv_x;

            mv_y = mb->mv_y;

            if (!band->is_halfpel) {

                mc_type = 0; 

            } else {

                mc_type = ((mv_y & 1) << 1) | (mv_x & 1);

                mv_x >>= 1;

                mv_y >>= 1; 

            }



            for (blk = 0; blk < num_blocks; blk++) {

                

                offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);

                mc_no_delta_func(band->buf + offs,

                                 band->ref_buf + offs + mv_y * band->pitch + mv_x,

                                 band->pitch, mc_type);

            }

        }

    } else {

        

        src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;

        dst = band->buf     + tile->ypos * band->pitch + tile->xpos;

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

            memcpy(dst, src, tile->width*sizeof(band->buf[0]));

            src += band->pitch;

            dst += band->pitch;

        }

    }

}

            if (band->inherit_mv) {
void FUNC_0(AVCodecContext *VAR_0, IVIBandDesc *VAR_1,

                               IVITile *VAR_2, int32_t VAR_3)

{

    int             VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_21;

    int             VAR_13, VAR_14, VAR_15;

    IVIMbInfo       *mb, *ref_mb;

    const int16_t   *VAR_16;

    int16_t         *dst;

    void (*VAR_17)(int16_t *VAR_18, const int16_t *VAR_19, uint32_t VAR_20,

                             int VAR_21);



    VAR_13       = VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;

    mb         = VAR_2->mbs;

    ref_mb     = VAR_2->ref_mbs;

    VAR_15 = VAR_1->mb_size * VAR_1->VAR_20;

    VAR_6    = 0; 



    for (VAR_5 = VAR_2->ypos; VAR_5 < (VAR_2->ypos + VAR_2->height); VAR_5 += VAR_1->mb_size) {

        VAR_14 = VAR_13;



        for (VAR_4 = VAR_2->xpos; VAR_4 < (VAR_2->xpos + VAR_2->width); VAR_4 += VAR_1->mb_size) {

            mb->xpos     = VAR_4;

            mb->ypos     = VAR_5;

            mb->buf_offs = VAR_14;



            mb->type = 1; 

            mb->cbp  = 0; 



            if (!VAR_1->qdelta_present && !VAR_1->plane && !VAR_1->band_num) {

                mb->q_delta = VAR_1->glob_quant;

                mb->VAR_10    = 0;

                mb->VAR_11    = 0;

            }



            if (VAR_1->inherit_qdelta && ref_mb)

                mb->q_delta = ref_mb->q_delta;



            if (VAR_1->inherit_mv) {

                

                if (VAR_3) {

                    mb->VAR_10 = ivi_scale_mv(ref_mb->VAR_10, VAR_3);

                    mb->VAR_11 = ivi_scale_mv(ref_mb->VAR_11, VAR_3);

                } else {

                    mb->VAR_10 = ref_mb->VAR_10;

                    mb->VAR_11 = ref_mb->VAR_11;

                }

                VAR_6 |= mb->VAR_10 || mb->VAR_11; 

            }



            mb++;

            if (ref_mb)

                ref_mb++;

            VAR_14 += VAR_1->mb_size;

        } 

        VAR_13 += VAR_15;

    } 



    if (VAR_1->inherit_mv && VAR_6) { 

        VAR_9 = (VAR_1->mb_size != VAR_1->blk_size) ? 4 : 1; 

        VAR_17 = (VAR_1->blk_size == 8) ? ff_ivi_mc_8x8_no_delta

                                                 : ff_ivi_mc_4x4_no_delta;



        for (VAR_7 = 0, mb = VAR_2->mbs; VAR_7 < VAR_2->num_MBs; mb++, VAR_7++) {

            VAR_10 = mb->VAR_10;

            VAR_11 = mb->VAR_11;

            if (!VAR_1->is_halfpel) {

                VAR_21 = 0; 

            } else {

                VAR_21 = ((VAR_11 & 1) << 1) | (VAR_10 & 1);

                VAR_10 >>= 1;

                VAR_11 >>= 1; 

            }



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

                

                VAR_13 = mb->buf_offs + VAR_1->blk_size * ((VAR_8 & 1) + !!(VAR_8 & 2) * VAR_1->VAR_20);

                VAR_17(VAR_1->VAR_18 + VAR_13,

                                 VAR_1->VAR_19 + VAR_13 + VAR_11 * VAR_1->VAR_20 + VAR_10,

                                 VAR_1->VAR_20, VAR_21);

            }

        }

    } else {

        

        VAR_16 = VAR_1->VAR_19 + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;

        dst = VAR_1->VAR_18     + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos;

        for (VAR_5 = 0; VAR_5 < VAR_2->height; VAR_5++) {

            memcpy(dst, VAR_16, VAR_2->width*sizeof(VAR_1->VAR_18[0]));

            VAR_16 += VAR_1->VAR_20;

            dst += VAR_1->VAR_20;

        }

    }

}

void FUNC_0(AVCodecContext *VAR_0, IVIBandDesc *VAR_1,
IVITile *VAR_2, int32_t VAR_3)
{ int             VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_21; int             VAR_13, VAR_14, VAR_15; IVIMbInfo       *mb, *ref_mb; const int16_t   *VAR_16; int16_t         *dst; void (*VAR_17)(int16_t *VAR_18, const int16_t *VAR_19, uint32_t VAR_20,
int VAR_21); VAR_13       = VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos; mb         = VAR_2->mbs; ref_mb     = VAR_2->ref_mbs; VAR_15 = VAR_1->mb_size * VAR_1->VAR_20; VAR_6    = 0; for (VAR_5 = VAR_2->ypos; VAR_5 < (VAR_2->ypos + VAR_2->height); VAR_5 += VAR_1->mb_size) { VAR_14 = VAR_13; for (VAR_4 = VAR_2->xpos; VAR_4 < (VAR_2->xpos + VAR_2->width); VAR_4 += VAR_1->mb_size) { mb->xpos     = VAR_4; mb->ypos     = VAR_5; mb->buf_offs = VAR_14; mb->type = 1; mb->cbp  = 0; if (!VAR_1->qdelta_present && !VAR_1->plane && !VAR_1->band_num) { mb->q_delta = VAR_1->glob_quant; mb->VAR_10    = 0; mb->VAR_11    = 0; } if (VAR_1->inherit_qdelta && ref_mb)
mb->q_delta = ref_mb->q_delta; if (VAR_1->inherit_mv) { if (VAR_3) { mb->VAR_10 = ivi_scale_mv(ref_mb->VAR_10, VAR_3); mb->VAR_11 = ivi_scale_mv(ref_mb->VAR_11, VAR_3); } else { mb->VAR_10 = ref_mb->VAR_10; mb->VAR_11 = ref_mb->VAR_11; } VAR_6 |= mb->VAR_10 || mb->VAR_11; } mb++; if (ref_mb)
ref_mb++; VAR_14 += VAR_1->mb_size; } VAR_13 += VAR_15; } if (VAR_1->inherit_mv && VAR_6) { VAR_9 = (VAR_1->mb_size != VAR_1->blk_size) ? 4 : 1; VAR_17 = (VAR_1->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
: ff_ivi_mc_4x4_no_delta; for (VAR_7 = 0, mb = VAR_2->mbs; VAR_7 < VAR_2->num_MBs; mb++, VAR_7++) { VAR_10 = mb->VAR_10; VAR_11 = mb->VAR_11; if (!VAR_1->is_halfpel) { VAR_21 = 0; } else { VAR_21 = ((VAR_11 & 1) << 1) | (VAR_10 & 1); VAR_10 >>= 1; VAR_11 >>= 1; } for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) { VAR_13 = mb->buf_offs + VAR_1->blk_size * ((VAR_8 & 1) + !!(VAR_8 & 2) * VAR_1->VAR_20); VAR_17(VAR_1->VAR_18 + VAR_13,
VAR_1->VAR_19 + VAR_13 + VAR_11 * VAR_1->VAR_20 + VAR_10,
VAR_1->VAR_20, VAR_21); } } } else { VAR_16 = VAR_1->VAR_19 + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos; dst = VAR_1->VAR_18     + VAR_2->ypos * VAR_1->VAR_20 + VAR_2->xpos; for (VAR_5 = 0; VAR_5 < VAR_2->height; VAR_5++) { memcpy(dst, VAR_16, VAR_2->width*sizeof(VAR_1->VAR_18[0])); VAR_16 += VAR_1->VAR_20; dst += VAR_1->VAR_20; } } }