int i;
void MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx){    int i;    UINT8 *tmp;    s->mb_skiped = 0;    s->decoding_error=0;    avctx->mbskip_table= s->mbskip_table;    if(avctx->flags&CODEC_FLAG_DR1){        int i;        avctx->get_buffer_callback(avctx, s->width, s->height, s->pict_type);        s->linesize  = avctx->dr_stride;        s->uvlinesize= avctx->dr_uvstride;        s->ip_buffer_count= avctx->dr_ip_buffer_count;    }    avctx->dr_ip_buffer_count= s->ip_buffer_count;        if (s->pict_type == B_TYPE) {        for(i=0;i<3;i++) {            if(avctx->flags&CODEC_FLAG_DR1)                s->aux_picture[i]= avctx->dr_buffer[i];                        //FIXME the following should never be needed, the decoder should drop b frames if no reference is available            if(s->next_picture[i]==NULL)                s->next_picture[i]= s->aux_picture[i];            if(s->last_picture[i]==NULL)                s->last_picture[i]= s->next_picture[i];            s->current_picture[i] = s->aux_picture[i];        }    } else {        for(i=0;i<3;i++) {            /* swap next and last */            if(avctx->flags&CODEC_FLAG_DR1)                tmp= avctx->dr_buffer[i];            else                tmp = s->last_picture[i];            s->last_picture[i] = s->next_picture[i];            s->next_picture[i] = tmp;            s->current_picture[i] = tmp;            s->last_dr_opaque= s->next_dr_opaque;            s->next_dr_opaque= avctx->dr_opaque_frame;            if(s->has_b_frames && s->last_dr_opaque && s->codec_id!=CODEC_ID_SVQ1)                avctx->dr_opaque_frame= s->last_dr_opaque;            else                avctx->dr_opaque_frame= s->next_dr_opaque;        }    }}