void ff_vc1_interp_mc(VC1Context *v)

{

    MpegEncContext *s = &v->s;

    H264ChromaContext *h264chroma = &v->h264chroma;

    uint8_t *srcY, *srcU, *srcV;

    int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;

    int off, off_uv;

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

    int use_ic = v->next_use_ic;



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

        return;



    mx   = s->mv[1][0][0];

    my   = s->mv[1][0][1];

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

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

    if (v->field_mode) {

        if (v->cur_field_type != v->ref_field_type[1])

            my   = my   - 2 + 4 * v->cur_field_type;

            uvmy = uvmy - 2 + 4 * v->cur_field_type;

    }

    if (v->fastuvmc) {

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

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

    }

    srcY = s->next_picture.f->data[0];

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

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



    src_x   = s->mb_x * 16 + (mx   >> 2);

    src_y   = s->mb_y * 16 + (my   >> 2);

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

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



    if (v->profile != PROFILE_ADVANCED) {

        src_x   = av_clip(  src_x, -16, s->mb_width  * 16);

        src_y   = av_clip(  src_y, -16, s->mb_height * 16);

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

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

    } else {

        src_x   = av_clip(  src_x, -17, s->avctx->coded_width);

        src_y   = av_clip(  src_y, -18, s->avctx->coded_height + 1);

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

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

    }



    srcY += src_y   * s->linesize   + src_x;

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

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



    if (v->field_mode && v->ref_field_type[1]) {

        srcY += s->current_picture_ptr->f->linesize[0];

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

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

    }



    /* for grayscale we should not try to read from unknown area */

    if (s->flags & CODEC_FLAG_GRAY) {

        srcU = s->edge_emu_buffer + 18 * s->linesize;

        srcV = s->edge_emu_buffer + 18 * s->linesize;

    }



    if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || use_ic

        || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3

        || (unsigned)(src_y - 1) > v_edge_pos    - (my & 3) - 16 - 3) {

        uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;



        srcY -= s->mspel * (1 + s->linesize);

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY,

                                 s->linesize, s->linesize,

                                 17 + s->mspel * 2, 17 + s->mspel * 2,

                                 src_x - s->mspel, src_y - s->mspel,

                                 s->h_edge_pos, v_edge_pos);

        srcY = s->edge_emu_buffer;

        s->vdsp.emulated_edge_mc(uvbuf, srcU,

                                 s->uvlinesize, s->uvlinesize,

                                 8 + 1, 8 + 1,

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

        s->vdsp.emulated_edge_mc(uvbuf + 16, srcV,

                                 s->uvlinesize, s->uvlinesize,

                                 8 + 1, 8 + 1,

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

        srcU = uvbuf;

        srcV = uvbuf + 16;

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

        if (v->rangeredfrm) {

            int i, j;

            uint8_t *src, *src2;



            src = srcY;

            for (j = 0; j < 17 + s->mspel * 2; j++) {

                for (i = 0; i < 17 + s->mspel * 2; i++)

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

                src += s->linesize;

            }

            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 (use_ic) {

            uint8_t (*luty )[256] = v->next_luty;

            uint8_t (*lutuv)[256] = v->next_lutuv;

            int i, j;

            uint8_t *src, *src2;



            src = srcY;

            for (j = 0; j < 17 + s->mspel * 2; j++) {

                int f = v->field_mode ? v->ref_field_type[1] : ((j+src_y - s->mspel) & 1);

                for (i = 0; i < 17 + s->mspel * 2; i++)

                    src[i] = luty[f][src[i]];

                src += s->linesize;

            }

            src  = srcU;

            src2 = srcV;

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

                int f = v->field_mode ? v->ref_field_type[1] : ((j+uvsrc_y) & 1);

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

                    src[i]  = lutuv[f][src[i]];

                    src2[i] = lutuv[f][src2[i]];

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

        srcY += s->mspel * (1 + s->linesize);

    }



    off    = 0;

    off_uv = 0;



    if (s->mspel) {

        dxy = ((my & 3) << 2) | (mx & 3);

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off    , srcY    , s->linesize, v->rnd);

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd);

        srcY += s->linesize * 8;

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize    , srcY    , s->linesize, v->rnd);

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);

    } else { // hpel mc

        dxy = (my & 2) | ((mx & 2) >> 1);



        if (!v->rnd)

            s->hdsp.avg_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);

        else

            s->hdsp.avg_no_rnd_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, 16);

    }



    if (s->flags & CODEC_FLAG_GRAY) return;

    /* Chroma MC always uses qpel blilinear */

    uvmx = (uvmx & 3) << 1;

    uvmy = (uvmy & 3) << 1;

    if (!v->rnd) {

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

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

    } else {

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

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

    }

}

void ff_vc1_interp_mc(VC1Context *v)

{

    MpegEncContext *s = &v->s;

    H264ChromaContext *h264chroma = &v->h264chroma;

    uint8_t *srcY, *srcU, *srcV;

    int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;

    int off, off_uv;

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

    int use_ic = v->next_use_ic;



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

        return;



    mx   = s->mv[1][0][0];

    my   = s->mv[1][0][1];

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

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

    if (v->field_mode) {

        if (v->cur_field_type != v->ref_field_type[1])

            my   = my   - 2 + 4 * v->cur_field_type;

            uvmy = uvmy - 2 + 4 * v->cur_field_type;

    }

    if (v->fastuvmc) {

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

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

    }

    srcY = s->next_picture.f->data[0];

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

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



    src_x   = s->mb_x * 16 + (mx   >> 2);

    src_y   = s->mb_y * 16 + (my   >> 2);

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

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



    if (v->profile != PROFILE_ADVANCED) {

        src_x   = av_clip(  src_x, -16, s->mb_width  * 16);

        src_y   = av_clip(  src_y, -16, s->mb_height * 16);

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

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

    } else {

        src_x   = av_clip(  src_x, -17, s->avctx->coded_width);

        src_y   = av_clip(  src_y, -18, s->avctx->coded_height + 1);

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

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

    }



    srcY += src_y   * s->linesize   + src_x;

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

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



    if (v->field_mode && v->ref_field_type[1]) {

        srcY += s->current_picture_ptr->f->linesize[0];

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

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

    }



    

    if (s->flags & CODEC_FLAG_GRAY) {

        srcU = s->edge_emu_buffer + 18 * s->linesize;

        srcV = s->edge_emu_buffer + 18 * s->linesize;

    }



    if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || use_ic

        || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3

        || (unsigned)(src_y - 1) > v_edge_pos    - (my & 3) - 16 - 3) {

        uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;



        srcY -= s->mspel * (1 + s->linesize);

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY,

                                 s->linesize, s->linesize,

                                 17 + s->mspel * 2, 17 + s->mspel * 2,

                                 src_x - s->mspel, src_y - s->mspel,

                                 s->h_edge_pos, v_edge_pos);

        srcY = s->edge_emu_buffer;

        s->vdsp.emulated_edge_mc(uvbuf, srcU,

                                 s->uvlinesize, s->uvlinesize,

                                 8 + 1, 8 + 1,

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

        s->vdsp.emulated_edge_mc(uvbuf + 16, srcV,

                                 s->uvlinesize, s->uvlinesize,

                                 8 + 1, 8 + 1,

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

        srcU = uvbuf;

        srcV = uvbuf + 16;

        

        if (v->rangeredfrm) {

            int i, j;

            uint8_t *src, *src2;



            src = srcY;

            for (j = 0; j < 17 + s->mspel * 2; j++) {

                for (i = 0; i < 17 + s->mspel * 2; i++)

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

                src += s->linesize;

            }

            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 (use_ic) {

            uint8_t (*luty )[256] = v->next_luty;

            uint8_t (*lutuv)[256] = v->next_lutuv;

            int i, j;

            uint8_t *src, *src2;



            src = srcY;

            for (j = 0; j < 17 + s->mspel * 2; j++) {

                int f = v->field_mode ? v->ref_field_type[1] : ((j+src_y - s->mspel) & 1);

                for (i = 0; i < 17 + s->mspel * 2; i++)

                    src[i] = luty[f][src[i]];

                src += s->linesize;

            }

            src  = srcU;

            src2 = srcV;

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

                int f = v->field_mode ? v->ref_field_type[1] : ((j+uvsrc_y) & 1);

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

                    src[i]  = lutuv[f][src[i]];

                    src2[i] = lutuv[f][src2[i]];

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

        srcY += s->mspel * (1 + s->linesize);

    }



    off    = 0;

    off_uv = 0;



    if (s->mspel) {

        dxy = ((my & 3) << 2) | (mx & 3);

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off    , srcY    , s->linesize, v->rnd);

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd);

        srcY += s->linesize * 8;

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize    , srcY    , s->linesize, v->rnd);

        v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);

    } else { 

        dxy = (my & 2) | ((mx & 2) >> 1);



        if (!v->rnd)

            s->hdsp.avg_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);

        else

            s->hdsp.avg_no_rnd_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, 16);

    }



    if (s->flags & CODEC_FLAG_GRAY) return;

    

    uvmx = (uvmx & 3) << 1;

    uvmy = (uvmy & 3) << 1;

    if (!v->rnd) {

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

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

    } else {

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

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

    }

}

void FUNC_0(VC1Context *VAR_0)

{

    MpegEncContext *s = &VAR_0->s;

    H264ChromaContext *h264chroma = &VAR_0->h264chroma;

    uint8_t *srcY, *srcU, *srcV;

    int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;

    int VAR_10, VAR_11;

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

    int VAR_13 = VAR_0->next_use_ic;



    if (!VAR_0->field_mode && !VAR_0->s.next_picture.VAR_16->data[0])

        return;



    VAR_2   = s->mv[1][0][0];

    VAR_3   = s->mv[1][0][1];

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

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

    if (VAR_0->field_mode) {

        if (VAR_0->cur_field_type != VAR_0->ref_field_type[1])

            VAR_3   = VAR_3   - 2 + 4 * VAR_0->cur_field_type;

            VAR_5 = VAR_5 - 2 + 4 * VAR_0->cur_field_type;

    }

    if (VAR_0->fastuvmc) {

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

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

    }

    srcY = s->next_picture.VAR_16->data[0];

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

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



    VAR_6   = s->mb_x * 16 + (VAR_2   >> 2);

    VAR_7   = s->mb_y * 16 + (VAR_3   >> 2);

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

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



    if (VAR_0->profile != PROFILE_ADVANCED) {

        VAR_6   = av_clip(  VAR_6, -16, s->mb_width  * 16);

        VAR_7   = av_clip(  VAR_7, -16, s->mb_height * 16);

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

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

    } else {

        VAR_6   = av_clip(  VAR_6, -17, s->avctx->coded_width);

        VAR_7   = av_clip(  VAR_7, -18, s->avctx->coded_height + 1);

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

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

    }



    srcY += VAR_7   * s->linesize   + VAR_6;

    srcU += VAR_9 * s->uvlinesize + VAR_8;

    srcV += VAR_9 * s->uvlinesize + VAR_8;



    if (VAR_0->field_mode && VAR_0->ref_field_type[1]) {

        srcY += s->current_picture_ptr->VAR_16->linesize[0];

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

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

    }



    

    if (s->flags & CODEC_FLAG_GRAY) {

        srcU = s->edge_emu_buffer + 18 * s->linesize;

        srcV = s->edge_emu_buffer + 18 * s->linesize;

    }



    if (VAR_0->rangeredfrm || s->h_edge_pos < 22 || VAR_12 < 22 || VAR_13

        || (unsigned)(VAR_6 - 1) > s->h_edge_pos - (VAR_2 & 3) - 16 - 3

        || (unsigned)(VAR_7 - 1) > VAR_12    - (VAR_3 & 3) - 16 - 3) {

        uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;



        srcY -= s->mspel * (1 + s->linesize);

        s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY,

                                 s->linesize, s->linesize,

                                 17 + s->mspel * 2, 17 + s->mspel * 2,

                                 VAR_6 - s->mspel, VAR_7 - s->mspel,

                                 s->h_edge_pos, VAR_12);

        srcY = s->edge_emu_buffer;

        s->vdsp.emulated_edge_mc(uvbuf, srcU,

                                 s->uvlinesize, s->uvlinesize,

                                 8 + 1, 8 + 1,

                                 VAR_8, VAR_9, s->h_edge_pos >> 1, VAR_12 >> 1);

        s->vdsp.emulated_edge_mc(uvbuf + 16, srcV,

                                 s->uvlinesize, s->uvlinesize,

                                 8 + 1, 8 + 1,

                                 VAR_8, VAR_9, s->h_edge_pos >> 1, VAR_12 >> 1);

        srcU = uvbuf;

        srcV = uvbuf + 16;

        

        if (VAR_0->rangeredfrm) {

            int VAR_16, VAR_16;

            uint8_t *src, *src2;



            src = srcY;

            for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++) {

                for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++)

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

                src += s->linesize;

            }

            src = srcU;

            src2 = srcV;

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

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

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

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

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }



        if (VAR_13) {

            uint8_t (*luty )[256] = VAR_0->next_luty;

            uint8_t (*lutuv)[256] = VAR_0->next_lutuv;

            int VAR_16, VAR_16;

            uint8_t *src, *src2;



            src = srcY;

            for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++) {

                int VAR_16 = VAR_0->field_mode ? VAR_0->ref_field_type[1] : ((VAR_16+VAR_7 - s->mspel) & 1);

                for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++)

                    src[VAR_16] = luty[VAR_16][src[VAR_16]];

                src += s->linesize;

            }

            src  = srcU;

            src2 = srcV;

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

                int VAR_16 = VAR_0->field_mode ? VAR_0->ref_field_type[1] : ((VAR_16+VAR_9) & 1);

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

                    src[VAR_16]  = lutuv[VAR_16][src[VAR_16]];

                    src2[VAR_16] = lutuv[VAR_16][src2[VAR_16]];

                }

                src  += s->uvlinesize;

                src2 += s->uvlinesize;

            }

        }

        srcY += s->mspel * (1 + s->linesize);

    }



    VAR_10    = 0;

    VAR_11 = 0;



    if (s->mspel) {

        VAR_1 = ((VAR_3 & 3) << 2) | (VAR_2 & 3);

        VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10    , srcY    , s->linesize, VAR_0->rnd);

        VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10 + 8, srcY + 8, s->linesize, VAR_0->rnd);

        srcY += s->linesize * 8;

        VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10 + 8 * s->linesize    , srcY    , s->linesize, VAR_0->rnd);

        VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10 + 8 * s->linesize + 8, srcY + 8, s->linesize, VAR_0->rnd);

    } else { 

        VAR_1 = (VAR_3 & 2) | ((VAR_2 & 2) >> 1);



        if (!VAR_0->rnd)

            s->hdsp.avg_pixels_tab[0][VAR_1](s->dest[0] + VAR_10, srcY, s->linesize, 16);

        else

            s->hdsp.avg_no_rnd_pixels_tab[VAR_1](s->dest[0] + VAR_10, srcY, s->linesize, 16);

    }



    if (s->flags & CODEC_FLAG_GRAY) return;

    

    VAR_4 = (VAR_4 & 3) << 1;

    VAR_5 = (VAR_5 & 3) << 1;

    if (!VAR_0->rnd) {

        h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1] + VAR_11, srcU, s->uvlinesize, 8, VAR_4, VAR_5);

        h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2] + VAR_11, srcV, s->uvlinesize, 8, VAR_4, VAR_5);

    } else {

        VAR_0->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + VAR_11, srcU, s->uvlinesize, 8, VAR_4, VAR_5);

        VAR_0->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + VAR_11, srcV, s->uvlinesize, 8, VAR_4, VAR_5);

    }

}

void FUNC_0(VC1Context *VAR_0)
{ MpegEncContext *s = &VAR_0->s; H264ChromaContext *h264chroma = &VAR_0->h264chroma; uint8_t *srcY, *srcU, *srcV; int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; int VAR_10, VAR_11; int VAR_12 = s->VAR_12 >> VAR_0->field_mode; int VAR_13 = VAR_0->next_use_ic; if (!VAR_0->field_mode && !VAR_0->s.next_picture.VAR_16->data[0])
return; VAR_2   = s->mv[1][0][0]; VAR_3   = s->mv[1][0][1]; VAR_4 = (VAR_2 + ((VAR_2 & 3) == 3)) >> 1; VAR_5 = (VAR_3 + ((VAR_3 & 3) == 3)) >> 1; if (VAR_0->field_mode) { if (VAR_0->cur_field_type != VAR_0->ref_field_type[1])
VAR_3   = VAR_3   - 2 + 4 * VAR_0->cur_field_type; VAR_5 = VAR_5 - 2 + 4 * VAR_0->cur_field_type; } if (VAR_0->fastuvmc) { VAR_4 = VAR_4 + ((VAR_4 < 0) ? -(VAR_4 & 1) : (VAR_4 & 1)); VAR_5 = VAR_5 + ((VAR_5 < 0) ? -(VAR_5 & 1) : (VAR_5 & 1)); } srcY = s->next_picture.VAR_16->data[0]; srcU = s->next_picture.VAR_16->data[1]; srcV = s->next_picture.VAR_16->data[2]; VAR_6   = s->mb_x * 16 + (VAR_2   >> 2); VAR_7   = s->mb_y * 16 + (VAR_3   >> 2); VAR_8 = s->mb_x *  8 + (VAR_4 >> 2); VAR_9 = s->mb_y *  8 + (VAR_5 >> 2); if (VAR_0->profile != PROFILE_ADVANCED) { VAR_6   = av_clip(  VAR_6, -16, s->mb_width  * 16); VAR_7   = av_clip(  VAR_7, -16, s->mb_height * 16); VAR_8 = av_clip(VAR_8,  -8, s->mb_width  *  8); VAR_9 = av_clip(VAR_9,  -8, s->mb_height *  8); } else { VAR_6   = av_clip(  VAR_6, -17, s->avctx->coded_width); VAR_7   = av_clip(  VAR_7, -18, s->avctx->coded_height + 1); VAR_8 = av_clip(VAR_8,  -8, s->avctx->coded_width  >> 1); VAR_9 = av_clip(VAR_9,  -8, s->avctx->coded_height >> 1); } srcY += VAR_7   * s->linesize   + VAR_6; srcU += VAR_9 * s->uvlinesize + VAR_8; srcV += VAR_9 * s->uvlinesize + VAR_8; if (VAR_0->field_mode && VAR_0->ref_field_type[1]) { srcY += s->current_picture_ptr->VAR_16->linesize[0]; srcU += s->current_picture_ptr->VAR_16->linesize[1]; srcV += s->current_picture_ptr->VAR_16->linesize[2]; } if (s->flags & CODEC_FLAG_GRAY) { srcU = s->edge_emu_buffer + 18 * s->linesize; srcV = s->edge_emu_buffer + 18 * s->linesize; } if (VAR_0->rangeredfrm || s->h_edge_pos < 22 || VAR_12 < 22 || VAR_13
|| (unsigned)(VAR_6 - 1) > s->h_edge_pos - (VAR_2 & 3) - 16 - 3
|| (unsigned)(VAR_7 - 1) > VAR_12    - (VAR_3 & 3) - 16 - 3) { uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize; srcY -= s->mspel * (1 + s->linesize); s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY,
s->linesize, s->linesize,
17 + s->mspel * 2, 17 + s->mspel * 2,
VAR_6 - s->mspel, VAR_7 - s->mspel,
s->h_edge_pos, VAR_12); srcY = s->edge_emu_buffer; s->vdsp.emulated_edge_mc(uvbuf, srcU,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1,
VAR_8, VAR_9, s->h_edge_pos >> 1, VAR_12 >> 1); s->vdsp.emulated_edge_mc(uvbuf + 16, srcV,
s->uvlinesize, s->uvlinesize,
8 + 1, 8 + 1,
VAR_8, VAR_9, s->h_edge_pos >> 1, VAR_12 >> 1); srcU = uvbuf; srcV = uvbuf + 16; if (VAR_0->rangeredfrm) { int VAR_16, VAR_16; uint8_t *src, *src2; src = srcY; for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++) { for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++) src[VAR_16] = ((src[VAR_16] - 128) >> 1) + 128; src += s->linesize; } src = srcU; src2 = srcV; for (VAR_16 = 0; VAR_16 < 9; VAR_16++) { for (VAR_16 = 0; VAR_16 < 9; VAR_16++) { src[VAR_16]  = ((src[VAR_16]  - 128) >> 1) + 128; src2[VAR_16] = ((src2[VAR_16] - 128) >> 1) + 128; } src  += s->uvlinesize; src2 += s->uvlinesize; } } if (VAR_13) { uint8_t (*luty )[256] = VAR_0->next_luty; uint8_t (*lutuv)[256] = VAR_0->next_lutuv; int VAR_16, VAR_16; uint8_t *src, *src2; src = srcY; for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++) { int VAR_16 = VAR_0->field_mode ? VAR_0->ref_field_type[1] : ((VAR_16+VAR_7 - s->mspel) & 1); for (VAR_16 = 0; VAR_16 < 17 + s->mspel * 2; VAR_16++) src[VAR_16] = luty[VAR_16][src[VAR_16]]; src += s->linesize; } src  = srcU; src2 = srcV; for (VAR_16 = 0; VAR_16 < 9; VAR_16++) { int VAR_16 = VAR_0->field_mode ? VAR_0->ref_field_type[1] : ((VAR_16+VAR_9) & 1); for (VAR_16 = 0; VAR_16 < 9; VAR_16++) { src[VAR_16]  = lutuv[VAR_16][src[VAR_16]]; src2[VAR_16] = lutuv[VAR_16][src2[VAR_16]]; } src  += s->uvlinesize; src2 += s->uvlinesize; } } srcY += s->mspel * (1 + s->linesize); } VAR_10    = 0; VAR_11 = 0; if (s->mspel) { VAR_1 = ((VAR_3 & 3) << 2) | (VAR_2 & 3); VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10    , srcY    , s->linesize, VAR_0->rnd); VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10 + 8, srcY + 8, s->linesize, VAR_0->rnd); srcY += s->linesize * 8; VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10 + 8 * s->linesize    , srcY    , s->linesize, VAR_0->rnd); VAR_0->vc1dsp.avg_vc1_mspel_pixels_tab[VAR_1](s->dest[0] + VAR_10 + 8 * s->linesize + 8, srcY + 8, s->linesize, VAR_0->rnd); } else { VAR_1 = (VAR_3 & 2) | ((VAR_2 & 2) >> 1); if (!VAR_0->rnd)
s->hdsp.avg_pixels_tab[0][VAR_1](s->dest[0] + VAR_10, srcY, s->linesize, 16); else
s->hdsp.avg_no_rnd_pixels_tab[VAR_1](s->dest[0] + VAR_10, srcY, s->linesize, 16); } if (s->flags & CODEC_FLAG_GRAY) return; VAR_4 = (VAR_4 & 3) << 1; VAR_5 = (VAR_5 & 3) << 1; if (!VAR_0->rnd) { h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1] + VAR_11, srcU, s->uvlinesize, 8, VAR_4, VAR_5); h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2] + VAR_11, srcV, s->uvlinesize, 8, VAR_4, VAR_5); } else { VAR_0->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + VAR_11, srcU, s->uvlinesize, 8, VAR_4, VAR_5); VAR_0->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + VAR_11, srcV, s->uvlinesize, 8, VAR_4, VAR_5); } }