static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,

                              const AVFrame *pic_arg, int *got_packet)



{

    MpegEncContext *s = avctx->priv_data;

    AVFrame *pic;

    int i, ret;

    int chroma_h_shift, chroma_v_shift;



    av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);



    //CODEC_FLAG_EMU_EDGE have to be cleared

    if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)

        return AVERROR(EINVAL);



    if (avctx->height & 15) {

        av_log(avctx, AV_LOG_ERROR,

               "Height must be a multiple of 16, also note, "

               "if you have a AMV sample thats mod 16 != 0, please contact us\n");

        return AVERROR(EINVAL);

    }



    pic = av_frame_clone(pic_arg);

    if (!pic)

        return AVERROR(ENOMEM);

    //picture should be flipped upside-down

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

        int vsample = i ? 2 >> chroma_v_shift : 2;

        pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));

        pic->linesize[i] *= -1;

    }

    ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);

    av_frame_free(&pic);

    return ret;

}

static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,

                              const AVFrame *pic_arg, int *got_packet)



{

    MpegEncContext *s = avctx->priv_data;

    AVFrame *pic;

    int i, ret;

    int chroma_h_shift, chroma_v_shift;



    av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift);



    

    if(s->avctx->flags & CODEC_FLAG_EMU_EDGE)

        return AVERROR(EINVAL);



    if (avctx->height & 15) {

        av_log(avctx, AV_LOG_ERROR,

               "Height must be a multiple of 16, also note, "

               "if you have a AMV sample thats mod 16 != 0, please contact us\n");

        return AVERROR(EINVAL);

    }



    pic = av_frame_clone(pic_arg);

    if (!pic)

        return AVERROR(ENOMEM);

    

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

        int vsample = i ? 2 >> chroma_v_shift : 2;

        pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));

        pic->linesize[i] *= -1;

    }

    ret = ff_MPV_encode_picture(avctx, pkt, pic, got_packet);

    av_frame_free(&pic);

    return ret;

}

        pic->data[i] += (pic->linesize[i] * (vsample * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,

                              const AVFrame *VAR_2, int *VAR_3)



{

    MpegEncContext *s = VAR_0->priv_data;

    AVFrame *pic;

    int VAR_4, VAR_5;

    int VAR_6, VAR_7;



    av_pix_fmt_get_chroma_sub_sample(VAR_0->pix_fmt, &VAR_6, &VAR_7);



    

    if(s->VAR_0->flags & CODEC_FLAG_EMU_EDGE)

        return AVERROR(EINVAL);



    if (VAR_0->height & 15) {

        av_log(VAR_0, AV_LOG_ERROR,

               "Height must be a multiple of 16, also note, "

               "if you have a AMV sample thats mod 16 != 0, please contact us\n");

        return AVERROR(EINVAL);

    }



    pic = av_frame_clone(VAR_2);

    if (!pic)

        return AVERROR(ENOMEM);

    

    for(VAR_4=0; VAR_4 < 3; VAR_4++) {

        int VAR_8 = VAR_4 ? 2 >> VAR_7 : 2;

        pic->data[VAR_4] += (pic->linesize[VAR_4] * (VAR_8 * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 ));

        pic->linesize[VAR_4] *= -1;

    }

    VAR_5 = ff_MPV_encode_picture(VAR_0, VAR_1, pic, VAR_3);

    av_frame_free(&pic);

    return VAR_5;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{ MpegEncContext *s = VAR_0->priv_data; AVFrame *pic; int VAR_4, VAR_5; int VAR_6, VAR_7; av_pix_fmt_get_chroma_sub_sample(VAR_0->pix_fmt, &VAR_6, &VAR_7); if(s->VAR_0->flags & CODEC_FLAG_EMU_EDGE)
return AVERROR(EINVAL); if (VAR_0->height & 15) { av_log(VAR_0, AV_LOG_ERROR,
"Height must be a multiple of 16, also note, "
"if you have a AMV sample thats mod 16 != 0, please contact us\n"); return AVERROR(EINVAL); } pic = av_frame_clone(VAR_2); if (!pic)
return AVERROR(ENOMEM); for(VAR_4=0; VAR_4 < 3; VAR_4++) { int VAR_8 = VAR_4 ? 2 >> VAR_7 : 2; pic->data[VAR_4] += (pic->linesize[VAR_4] * (VAR_8 * (8 * s->mb_height -((s->height/V_MAX)&7)) - 1 )); pic->linesize[VAR_4] *= -1; } VAR_5 = ff_MPV_encode_picture(VAR_0, VAR_1, pic, VAR_3); av_frame_free(&pic); return VAR_5; }