s->avctx->current_qscale_table= s->qscale_table      = s->last_qscale_table; s->avctx->display_qscale_table= s->last_qscale_table = s->next_qscale_table; s->next_qscale_table= s->qscale_table;
int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx){    int i;    UINT8 *tmp;    s->mb_skiped = 0;    avctx->mbskip_table= s->mbskip_table;    if(avctx->flags&CODEC_FLAG_DR1){        if(avctx->get_buffer_callback(avctx, s->width, s->height, s->pict_type) < 0){            fprintf(stderr, "get_buffer() failed\n");            return -1;        }        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;            if(s->last_picture[i]==NULL)                s->last_picture[i]= s->next_picture[i];            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;        }    }    /* set dequantizer, we cant do it during init as it might change for mpeg4       and we cant do it in the header decode as init isnt called for mpeg4 there yet */    if(s->out_format == FMT_H263){        if(s->mpeg_quant)            s->dct_unquantize = s->dct_unquantize_mpeg2;        else            s->dct_unquantize = s->dct_unquantize_h263;    }else         s->dct_unquantize = s->dct_unquantize_mpeg1;    return 0;}