static void vc1_mc_4mv_chroma(VC1Context *v, int dir)

{

    MpegEncContext *s = &v->s;

    H264ChromaContext *h264chroma = &v->h264chroma;

    uint8_t *srcU, *srcV;

    int uvmx, uvmy, uvsrc_x, uvsrc_y;

    int k, tx = 0, ty = 0;

    int mvx[4], mvy[4], intra[4], mv_f[4];

    int valid_count;

    int chroma_ref_type = v->cur_field_type, off = 0;

    int v_edge_pos = s->v_edge_pos >> v->field_mode;



    if (!v->field_mode && !v->s.last_picture.f.data[0])

        return;

    if (s->flags & CODEC_FLAG_GRAY)

        return;



    for (k = 0; k < 4; k++) {

        mvx[k] = s->mv[dir][k][0];

        mvy[k] = s->mv[dir][k][1];

        intra[k] = v->mb_type[0][s->block_index[k]];

        if (v->field_mode)

            mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off];

    }



    /* calculate chroma MV vector from four luma MVs */

    if (!v->field_mode || (v->field_mode && !v->numref)) {

        valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty);

        chroma_ref_type = v->reffield;

        if (!valid_count) {

            s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;

            s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;

            v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;

            return; //no need to do MC for intra blocks

        }

    } else {

        int dominant = 0;

        if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)

            dominant = 1;

        valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);

        if (dominant)

            chroma_ref_type = !v->cur_field_type;

    }

    if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])

        return;

    s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;

    s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;

    uvmx = (tx + ((tx & 3) == 3)) >> 1;

    uvmy = (ty + ((ty & 3) == 3)) >> 1;



    v->luma_mv[s->mb_x][0] = uvmx;

    v->luma_mv[s->mb_x][1] = uvmy;



    if (v->fastuvmc) {

        uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));

        uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));

    }

    // Field conversion bias

    if (v->cur_field_type != chroma_ref_type)

        uvmy += 2 - 4 * chroma_ref_type;



    uvsrc_x = s->mb_x * 8 + (uvmx >> 2);

    uvsrc_y = s->mb_y * 8 + (uvmy >> 2);



    if (v->profile != PROFILE_ADVANCED) {

        uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width  * 8);

        uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);

    } else {

        uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width  >> 1);

        uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);

    }



    if (!dir) {

        if (v->field_mode) {

            if ((v->cur_field_type != chroma_ref_type) && v->cur_field_type) {

                srcU = s->current_picture.f.data[1];

                srcV = s->current_picture.f.data[2];

            } else {

                srcU = s->last_picture.f.data[1];

                srcV = s->last_picture.f.data[2];

            }

        } else {

            srcU = s->last_picture.f.data[1];

            srcV = s->last_picture.f.data[2];

        }

    } else {

        srcU = s->next_picture.f.data[1];

        srcV = s->next_picture.f.data[2];

    }



    if(!srcU)

        return;



    srcU += uvsrc_y * s->uvlinesize + uvsrc_x;

    srcV += uvsrc_y * s->uvlinesize + uvsrc_x;



    if (v->field_mode) {

        if (chroma_ref_type) {

            srcU += s->current_picture_ptr->f.linesize[1];

            srcV += s->current_picture_ptr->f.linesize[2];

        }

        off = v->second_field ? s->current_picture_ptr->f.linesize[1] : 0;

    }



    if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)

        || s->h_edge_pos < 18 || v_edge_pos < 18

        || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9

        || (unsigned)uvsrc_y > (v_edge_pos    >> 1) - 9) {

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer     , srcU, s->uvlinesize,

                                 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,

                                 s->h_edge_pos >> 1, v_edge_pos >> 1);

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize,

                                 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,

                                 s->h_edge_pos >> 1, v_edge_pos >> 1);

        srcU = s->edge_emu_buffer;

        srcV = s->edge_emu_buffer + 16;



        /* if we deal with range reduction we need to scale source blocks */

        if (v->rangeredfrm) {

            int i, j;

            uint8_t *src, *src2;



            src  = srcU;

            src2 = srcV;

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

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

                    src[i]  = ((src[i]  - 128) >> 1) + 128;

                    src2[i] = ((src2[i] - 128) >> 1) + 128;

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

        /* if we deal with intensity compensation we need to scale source blocks */

        if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {

            int i, j;

            uint8_t *src, *src2;



            src  = srcU;

            src2 = srcV;

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

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

                    src[i]  = v->lutuv[src[i]];

                    src2[i] = v->lutuv[src2[i]];

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

    }



    /* Chroma MC always uses qpel bilinear */

    uvmx = (uvmx & 3) << 1;

    uvmy = (uvmy & 3) << 1;

    if (!v->rnd) {

        h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy);

        h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy);

    } else {

        v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy);

        v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy);

    }

}

static void vc1_mc_4mv_chroma(VC1Context *v, int dir)

{

    MpegEncContext *s = &v->s;

    H264ChromaContext *h264chroma = &v->h264chroma;

    uint8_t *srcU, *srcV;

    int uvmx, uvmy, uvsrc_x, uvsrc_y;

    int k, tx = 0, ty = 0;

    int mvx[4], mvy[4], intra[4], mv_f[4];

    int valid_count;

    int chroma_ref_type = v->cur_field_type, off = 0;

    int v_edge_pos = s->v_edge_pos >> v->field_mode;



    if (!v->field_mode && !v->s.last_picture.f.data[0])

        return;

    if (s->flags & CODEC_FLAG_GRAY)

        return;



    for (k = 0; k < 4; k++) {

        mvx[k] = s->mv[dir][k][0];

        mvy[k] = s->mv[dir][k][1];

        intra[k] = v->mb_type[0][s->block_index[k]];

        if (v->field_mode)

            mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off];

    }



    

    if (!v->field_mode || (v->field_mode && !v->numref)) {

        valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty);

        chroma_ref_type = v->reffield;

        if (!valid_count) {

            s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;

            s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;

            v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;

            return; 

        }

    } else {

        int dominant = 0;

        if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)

            dominant = 1;

        valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);

        if (dominant)

            chroma_ref_type = !v->cur_field_type;

    }

    if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_picture.f.data[0])

        return;

    s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;

    s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;

    uvmx = (tx + ((tx & 3) == 3)) >> 1;

    uvmy = (ty + ((ty & 3) == 3)) >> 1;



    v->luma_mv[s->mb_x][0] = uvmx;

    v->luma_mv[s->mb_x][1] = uvmy;



    if (v->fastuvmc) {

        uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));

        uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));

    }

    

    if (v->cur_field_type != chroma_ref_type)

        uvmy += 2 - 4 * chroma_ref_type;



    uvsrc_x = s->mb_x * 8 + (uvmx >> 2);

    uvsrc_y = s->mb_y * 8 + (uvmy >> 2);



    if (v->profile != PROFILE_ADVANCED) {

        uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width  * 8);

        uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);

    } else {

        uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width  >> 1);

        uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);

    }



    if (!dir) {

        if (v->field_mode) {

            if ((v->cur_field_type != chroma_ref_type) && v->cur_field_type) {

                srcU = s->current_picture.f.data[1];

                srcV = s->current_picture.f.data[2];

            } else {

                srcU = s->last_picture.f.data[1];

                srcV = s->last_picture.f.data[2];

            }

        } else {

            srcU = s->last_picture.f.data[1];

            srcV = s->last_picture.f.data[2];

        }

    } else {

        srcU = s->next_picture.f.data[1];

        srcV = s->next_picture.f.data[2];

    }



    if(!srcU)

        return;



    srcU += uvsrc_y * s->uvlinesize + uvsrc_x;

    srcV += uvsrc_y * s->uvlinesize + uvsrc_x;



    if (v->field_mode) {

        if (chroma_ref_type) {

            srcU += s->current_picture_ptr->f.linesize[1];

            srcV += s->current_picture_ptr->f.linesize[2];

        }

        off = v->second_field ? s->current_picture_ptr->f.linesize[1] : 0;

    }



    if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)

        || s->h_edge_pos < 18 || v_edge_pos < 18

        || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9

        || (unsigned)uvsrc_y > (v_edge_pos    >> 1) - 9) {

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer     , srcU, s->uvlinesize,

                                 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,

                                 s->h_edge_pos >> 1, v_edge_pos >> 1);

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize,

                                 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,

                                 s->h_edge_pos >> 1, v_edge_pos >> 1);

        srcU = s->edge_emu_buffer;

        srcV = s->edge_emu_buffer + 16;



        

        if (v->rangeredfrm) {

            int i, j;

            uint8_t *src, *src2;



            src  = srcU;

            src2 = srcV;

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

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

                    src[i]  = ((src[i]  - 128) >> 1) + 128;

                    src2[i] = ((src2[i] - 128) >> 1) + 128;

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

        

        if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {

            int i, j;

            uint8_t *src, *src2;



            src  = srcU;

            src2 = srcV;

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

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

                    src[i]  = v->lutuv[src[i]];

                    src2[i] = v->lutuv[src2[i]];

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

    }



    

    uvmx = (uvmx & 3) << 1;

    uvmy = (uvmy & 3) << 1;

    if (!v->rnd) {

        h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy);

        h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy);

    } else {

        v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy);

        v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy);

    }

}

static void FUNC_0(VC1Context *VAR_0, int VAR_1)

{

    MpegEncContext *s = &VAR_0->s;

    H264ChromaContext *h264chroma = &VAR_0->h264chroma;

    uint8_t *srcU, *srcV;

    int VAR_2, VAR_3, VAR_4, VAR_5;

    int VAR_6, VAR_7 = 0, VAR_8 = 0;

    int VAR_9[4], VAR_10[4], VAR_11[4], VAR_12[4];

    int VAR_13;

    int VAR_14 = VAR_0->cur_field_type, VAR_15 = 0;

    int VAR_16 = s->VAR_16 >> VAR_0->field_mode;



    if (!VAR_0->field_mode && !VAR_0->s.last_picture.f.data[0])

        return;

    if (s->flags & CODEC_FLAG_GRAY)

        return;



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

        VAR_9[VAR_6] = s->mv[VAR_1][VAR_6][0];

        VAR_10[VAR_6] = s->mv[VAR_1][VAR_6][1];

        VAR_11[VAR_6] = VAR_0->mb_type[0][s->block_index[VAR_6]];

        if (VAR_0->field_mode)

            VAR_12[VAR_6] = VAR_0->VAR_12[VAR_1][s->block_index[VAR_6] + VAR_0->blocks_off];

    }



    

    if (!VAR_0->field_mode || (VAR_0->field_mode && !VAR_0->numref)) {

        VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_11, 0, &VAR_7, &VAR_8);

        VAR_14 = VAR_0->reffield;

        if (!VAR_13) {

            s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = 0;

            s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = 0;

            VAR_0->luma_mv[s->mb_x][0] = VAR_0->luma_mv[s->mb_x][1] = 0;

            return; 

        }

    } else {

        int VAR_17 = 0;

        if (VAR_12[0] + VAR_12[1] + VAR_12[2] + VAR_12[3] > 2)

            VAR_17 = 1;

        VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_12, VAR_17, &VAR_7, &VAR_8);

        if (VAR_17)

            VAR_14 = !VAR_0->cur_field_type;

    }

    if (VAR_0->field_mode && VAR_14 == 1 && VAR_0->cur_field_type == 1 && !VAR_0->s.last_picture.f.data[0])

        return;

    s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = VAR_7;

    s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = VAR_8;

    VAR_2 = (VAR_7 + ((VAR_7 & 3) == 3)) >> 1;

    VAR_3 = (VAR_8 + ((VAR_8 & 3) == 3)) >> 1;



    VAR_0->luma_mv[s->mb_x][0] = VAR_2;

    VAR_0->luma_mv[s->mb_x][1] = VAR_3;



    if (VAR_0->fastuvmc) {

        VAR_2 = VAR_2 + ((VAR_2 < 0) ? (VAR_2 & 1) : -(VAR_2 & 1));

        VAR_3 = VAR_3 + ((VAR_3 < 0) ? (VAR_3 & 1) : -(VAR_3 & 1));

    }

    

    if (VAR_0->cur_field_type != VAR_14)

        VAR_3 += 2 - 4 * VAR_14;



    VAR_4 = s->mb_x * 8 + (VAR_2 >> 2);

    VAR_5 = s->mb_y * 8 + (VAR_3 >> 2);



    if (VAR_0->profile != PROFILE_ADVANCED) {

        VAR_4 = av_clip(VAR_4, -8, s->mb_width  * 8);

        VAR_5 = av_clip(VAR_5, -8, s->mb_height * 8);

    } else {

        VAR_4 = av_clip(VAR_4, -8, s->avctx->coded_width  >> 1);

        VAR_5 = av_clip(VAR_5, -8, s->avctx->coded_height >> 1);

    }



    if (!VAR_1) {

        if (VAR_0->field_mode) {

            if ((VAR_0->cur_field_type != VAR_14) && VAR_0->cur_field_type) {

                srcU = s->current_picture.f.data[1];

                srcV = s->current_picture.f.data[2];

            } else {

                srcU = s->last_picture.f.data[1];

                srcV = s->last_picture.f.data[2];

            }

        } else {

            srcU = s->last_picture.f.data[1];

            srcV = s->last_picture.f.data[2];

        }

    } else {

        srcU = s->next_picture.f.data[1];

        srcV = s->next_picture.f.data[2];

    }



    if(!srcU)

        return;



    srcU += VAR_5 * s->uvlinesize + VAR_4;

    srcV += VAR_5 * s->uvlinesize + VAR_4;



    if (VAR_0->field_mode) {

        if (VAR_14) {

            srcU += s->current_picture_ptr->f.linesize[1];

            srcV += s->current_picture_ptr->f.linesize[2];

        }

        VAR_15 = VAR_0->second_field ? s->current_picture_ptr->f.linesize[1] : 0;

    }



    if (VAR_0->rangeredfrm || (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP)

        || s->h_edge_pos < 18 || VAR_16 < 18

        || (unsigned)VAR_4 > (s->h_edge_pos >> 1) - 9

        || (unsigned)VAR_5 > (VAR_16    >> 1) - 9) {

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer     , srcU, s->uvlinesize,

                                 8 + 1, 8 + 1, VAR_4, VAR_5,

                                 s->h_edge_pos >> 1, VAR_16 >> 1);

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize,

                                 8 + 1, 8 + 1, VAR_4, VAR_5,

                                 s->h_edge_pos >> 1, VAR_16 >> 1);

        srcU = s->edge_emu_buffer;

        srcV = s->edge_emu_buffer + 16;



        

        if (VAR_0->rangeredfrm) {

            int VAR_20, VAR_20;

            uint8_t *src, *src2;



            src  = srcU;

            src2 = srcV;

            for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {

                for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {

                    src[VAR_20]  = ((src[VAR_20]  - 128) >> 1) + 128;

                    src2[VAR_20] = ((src2[VAR_20] - 128) >> 1) + 128;

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

        

        if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) {

            int VAR_20, VAR_20;

            uint8_t *src, *src2;



            src  = srcU;

            src2 = srcV;

            for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {

                for (VAR_20 = 0; VAR_20 < 9; VAR_20++) {

                    src[VAR_20]  = VAR_0->lutuv[src[VAR_20]];

                    src2[VAR_20] = VAR_0->lutuv[src2[VAR_20]];

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

    }



    

    VAR_2 = (VAR_2 & 3) << 1;

    VAR_3 = (VAR_3 & 3) << 1;

    if (!VAR_0->rnd) {

        h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + VAR_15, srcU, s->uvlinesize, 8, VAR_2, VAR_3);

        h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + VAR_15, srcV, s->uvlinesize, 8, VAR_2, VAR_3);

    } else {

        VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + VAR_15, srcU, s->uvlinesize, 8, VAR_2, VAR_3);

        VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + VAR_15, srcV, s->uvlinesize, 8, VAR_2, VAR_3);

    }

}

static void FUNC_0(VC1Context *VAR_0, int VAR_1)
{ MpegEncContext *s = &VAR_0->s; H264ChromaContext *h264chroma = &VAR_0->h264chroma; uint8_t *srcU, *srcV; int VAR_2, VAR_3, VAR_4, VAR_5; int VAR_6, VAR_7 = 0, VAR_8 = 0; int VAR_9[4], VAR_10[4], VAR_11[4], VAR_12[4]; int VAR_13; int VAR_14 = VAR_0->cur_field_type, VAR_15 = 0; int VAR_16 = s->VAR_16 >> VAR_0->field_mode; if (!VAR_0->field_mode && !VAR_0->s.last_picture.f.data[0])
return; if (s->flags & CODEC_FLAG_GRAY)
return; for (VAR_6 = 0; VAR_6 < 4; VAR_6++) { VAR_9[VAR_6] = s->mv[VAR_1][VAR_6][0]; VAR_10[VAR_6] = s->mv[VAR_1][VAR_6][1]; VAR_11[VAR_6] = VAR_0->mb_type[0][s->block_index[VAR_6]]; if (VAR_0->field_mode)
VAR_12[VAR_6] = VAR_0->VAR_12[VAR_1][s->block_index[VAR_6] + VAR_0->blocks_off]; } if (!VAR_0->field_mode || (VAR_0->field_mode && !VAR_0->numref)) { VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_11, 0, &VAR_7, &VAR_8); VAR_14 = VAR_0->reffield; if (!VAR_13) { s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = 0; s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = 0; VAR_0->luma_mv[s->mb_x][0] = VAR_0->luma_mv[s->mb_x][1] = 0; return; } } else { int VAR_17 = 0; if (VAR_12[0] + VAR_12[1] + VAR_12[2] + VAR_12[3] > 2)
VAR_17 = 1; VAR_13 = get_chroma_mv(VAR_9, VAR_10, VAR_12, VAR_17, &VAR_7, &VAR_8); if (VAR_17)
VAR_14 = !VAR_0->cur_field_type; } if (VAR_0->field_mode && VAR_14 == 1 && VAR_0->cur_field_type == 1 && !VAR_0->s.last_picture.f.data[0])
return; s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][0] = VAR_7; s->current_picture.f.motion_val[1][s->block_index[0] + VAR_0->blocks_off][1] = VAR_8; VAR_2 = (VAR_7 + ((VAR_7 & 3) == 3)) >> 1; VAR_3 = (VAR_8 + ((VAR_8 & 3) == 3)) >> 1; VAR_0->luma_mv[s->mb_x][0] = VAR_2; VAR_0->luma_mv[s->mb_x][1] = VAR_3; if (VAR_0->fastuvmc) { VAR_2 = VAR_2 + ((VAR_2 < 0) ? (VAR_2 & 1) : -(VAR_2 & 1)); VAR_3 = VAR_3 + ((VAR_3 < 0) ? (VAR_3 & 1) : -(VAR_3 & 1)); } if (VAR_0->cur_field_type != VAR_14)
VAR_3 += 2 - 4 * VAR_14; VAR_4 = s->mb_x * 8 + (VAR_2 >> 2); VAR_5 = s->mb_y * 8 + (VAR_3 >> 2); if (VAR_0->profile != PROFILE_ADVANCED) { VAR_4 = av_clip(VAR_4, -8, s->mb_width  * 8); VAR_5 = av_clip(VAR_5, -8, s->mb_height * 8); } else { VAR_4 = av_clip(VAR_4, -8, s->avctx->coded_width  >> 1); VAR_5 = av_clip(VAR_5, -8, s->avctx->coded_height >> 1); } if (!VAR_1) { if (VAR_0->field_mode) { if ((VAR_0->cur_field_type != VAR_14) && VAR_0->cur_field_type) { srcU = s->current_picture.f.data[1]; srcV = s->current_picture.f.data[2]; } else { srcU = s->last_picture.f.data[1]; srcV = s->last_picture.f.data[2]; } } else { srcU = s->last_picture.f.data[1]; srcV = s->last_picture.f.data[2]; } } else { srcU = s->next_picture.f.data[1]; srcV = s->next_picture.f.data[2]; } if(!srcU)
return; srcU += VAR_5 * s->uvlinesize + VAR_4; srcV += VAR_5 * s->uvlinesize + VAR_4; if (VAR_0->field_mode) { if (VAR_14) { srcU += s->current_picture_ptr->f.linesize[1]; srcV += s->current_picture_ptr->f.linesize[2]; } VAR_15 = VAR_0->second_field ? s->current_picture_ptr->f.linesize[1] : 0; } if (VAR_0->rangeredfrm || (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP)
|| s->h_edge_pos < 18 || VAR_16 < 18
|| (unsigned)VAR_4 > (s->h_edge_pos >> 1) - 9
|| (unsigned)VAR_5 > (VAR_16    >> 1) - 9) { s->vdsp.emulated_edge_mc(s->edge_emu_buffer     , srcU, s->uvlinesize,
8 + 1, 8 + 1, VAR_4, VAR_5,
s->h_edge_pos >> 1, VAR_16 >> 1); s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize,
8 + 1, 8 + 1, VAR_4, VAR_5,
s->h_edge_pos >> 1, VAR_16 >> 1); srcU = s->edge_emu_buffer; srcV = s->edge_emu_buffer + 16; if (VAR_0->rangeredfrm) { int VAR_20, VAR_20; uint8_t *src, *src2; src  = srcU; src2 = srcV; for (VAR_20 = 0; VAR_20 < 9; VAR_20++) { for (VAR_20 = 0; VAR_20 < 9; VAR_20++) { src[VAR_20]  = ((src[VAR_20]  - 128) >> 1) + 128; src2[VAR_20] = ((src2[VAR_20] - 128) >> 1) + 128; } src  += s->uvlinesize; src2 += s->uvlinesize; } } if (VAR_0->mv_mode == MV_PMODE_INTENSITY_COMP) { int VAR_20, VAR_20; uint8_t *src, *src2; src  = srcU; src2 = srcV; for (VAR_20 = 0; VAR_20 < 9; VAR_20++) { for (VAR_20 = 0; VAR_20 < 9; VAR_20++) { src[VAR_20]  = VAR_0->lutuv[src[VAR_20]]; src2[VAR_20] = VAR_0->lutuv[src2[VAR_20]]; } src  += s->uvlinesize; src2 += s->uvlinesize; } } } VAR_2 = (VAR_2 & 3) << 1; VAR_3 = (VAR_3 & 3) << 1; if (!VAR_0->rnd) { h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + VAR_15, srcU, s->uvlinesize, 8, VAR_2, VAR_3); h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + VAR_15, srcV, s->uvlinesize, 8, VAR_2, VAR_3); } else { VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + VAR_15, srcU, s->uvlinesize, 8, VAR_2, VAR_3); VAR_0->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + VAR_15, srcV, s->uvlinesize, 8, VAR_2, VAR_3); } }