s->num_available_buffers++; if(s->num_available_buffers>2) s->num_available_buffers= 2;
void MPV_frame_end(MpegEncContext *s){    int i;    /* draw edge for correct motion prediction if outside */    if(s->codec_id!=CODEC_ID_SVQ1){        if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) {            draw_edges(s->current_picture.data[0], s->linesize  , s->h_edge_pos   , s->v_edge_pos   , EDGE_WIDTH  );            draw_edges(s->current_picture.data[1], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2);            draw_edges(s->current_picture.data[2], s->uvlinesize, s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2);        }    }    emms_c();        s->last_pict_type    = s->pict_type;    if(s->pict_type!=B_TYPE){        s->last_non_b_pict_type= s->pict_type;        s->num_available_buffers++;        if(s->num_available_buffers>2) s->num_available_buffers= 2;    }        s->current_picture.quality= s->qscale; //FIXME get average of qscale_table    s->current_picture.pict_type= s->pict_type;    s->current_picture.key_frame= s->pict_type == I_TYPE;        /* copy back current_picture variables */    for(i=0; i<MAX_PICTURE_COUNT; i++){        if(s->picture[i].data[0] == s->current_picture.data[0]){            s->picture[i]= s->current_picture;            break;        }        }    assert(i<MAX_PICTURE_COUNT);    /* release non refernce frames */    for(i=0; i<MAX_PICTURE_COUNT; i++){        if(s->picture[i].data[0] && !s->picture[i].reference)            s->avctx->release_buffer(s->avctx, (AVVideoFrame*)&s->picture[i]);    }}