s->picture_in_gop_number = 0;
int MPV_encode_init(AVCodecContext *avctx){    MpegEncContext *s = avctx->priv_data;    int i;    s->bit_rate = avctx->bit_rate;    s->bit_rate_tolerance = avctx->bit_rate_tolerance;    s->frame_rate = avctx->frame_rate;    s->width = avctx->width;    s->height = avctx->height;    s->gop_size = avctx->gop_size;    s->rtp_mode = avctx->rtp_mode;    s->rtp_payload_size = avctx->rtp_payload_size;    if (avctx->rtp_callback)        s->rtp_callback = avctx->rtp_callback;    s->qmin= avctx->qmin;    s->qmax= avctx->qmax;    s->max_qdiff= avctx->max_qdiff;    s->qcompress= avctx->qcompress;    s->qblur= avctx->qblur;    s->avctx = avctx;        if (s->gop_size <= 1) {        s->intra_only = 1;        s->gop_size = 12;    } else {        s->intra_only = 0;    }    s->full_search = motion_estimation_method;    s->fixed_qscale = (avctx->flags & CODEC_FLAG_QSCALE);        switch(avctx->codec->id) {    case CODEC_ID_MPEG1VIDEO:        s->out_format = FMT_MPEG1;        break;    case CODEC_ID_MJPEG:        s->out_format = FMT_MJPEG;        s->intra_only = 1; /* force intra only for jpeg */        s->mjpeg_write_tables = 1; /* write all tables */        s->mjpeg_vsample[0] = 2; /* set up default sampling factors */        s->mjpeg_vsample[1] = 1; /* the only currently supported values */        s->mjpeg_vsample[2] = 1;         s->mjpeg_hsample[0] = 2;         s->mjpeg_hsample[1] = 1;         s->mjpeg_hsample[2] = 1;         if (mjpeg_init(s) < 0)            return -1;        break;    case CODEC_ID_H263:        if (h263_get_picture_format(s->width, s->height) == 7) {            printf("Input picture size isn't suitable for h263 codec! try h263+\n");            return -1;        }        s->out_format = FMT_H263;        break;    case CODEC_ID_H263P:        s->out_format = FMT_H263;        s->rtp_mode = 1;        s->rtp_payload_size = 1200;         s->h263_plus = 1;        s->unrestricted_mv = 1;                /* These are just to be sure */        s->umvplus = 0;        s->umvplus_dec = 0;        break;    case CODEC_ID_RV10:        s->out_format = FMT_H263;        s->h263_rv10 = 1;        break;    case CODEC_ID_MPEG4:        s->out_format = FMT_H263;        s->h263_pred = 1;        s->unrestricted_mv = 1;        break;    case CODEC_ID_MSMPEG4:        s->out_format = FMT_H263;        s->h263_msmpeg4 = 1;        s->h263_pred = 1;        s->unrestricted_mv = 1;        break;    default:        return -1;    }    if (s->out_format == FMT_H263)        h263_encode_init_vlc(s);    s->encoding = 1;    /* init */    if (MPV_common_init(s) < 0)        return -1;        /* init default q matrix */    for(i=0;i<64;i++) {        s->intra_matrix[i] = default_intra_matrix[i];        s->non_intra_matrix[i] = default_non_intra_matrix[i];    }    /* rate control init */    rate_control_init(s);    s->picture_number = 0;    s->fake_picture_number = 0;    /* motion detector init */    s->f_code = 1;    return 0;}