printf("%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",
av_log(s->avctx, AV_LOG_DEBUG, "%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",
float ff_rate_estimate_qscale(MpegEncContext *s){    float q;    int qmin, qmax;    float br_compensation;    double diff;    double short_term_q;    double fps;    int picture_number= s->picture_number;    int64_t wanted_bits;    RateControlContext *rcc= &s->rc_context;    RateControlEntry local_rce, *rce;    double bits;    double rate_factor;    int var;    const int pict_type= s->pict_type;    Picture * const pic= &s->current_picture;    emms_c();    get_qminmax(&qmin, &qmax, s, pict_type);    fps= (double)s->avctx->frame_rate / (double)s->avctx->frame_rate_base;//printf("input_pic_num:%d pic_num:%d frame_rate:%d\n", s->input_picture_number, s->picture_number, s->frame_rate);        /* update predictors */    if(picture_number>2){        const int last_var= s->last_pict_type == I_TYPE ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum;        update_predictor(&rcc->pred[s->last_pict_type], rcc->last_qscale, sqrt(last_var), s->frame_bits);    }    if(s->flags&CODEC_FLAG_PASS2){        assert(picture_number>=0);        assert(picture_number<rcc->num_entries);        rce= &rcc->entry[picture_number];        wanted_bits= rce->expected_bits;    }else{        rce= &local_rce;        wanted_bits= (uint64_t)(s->bit_rate*(double)picture_number/fps);    }    diff= s->total_bits - wanted_bits;    br_compensation= (s->bit_rate_tolerance - diff)/s->bit_rate_tolerance;    if(br_compensation<=0.0) br_compensation=0.001;    var= pict_type == I_TYPE ? pic->mb_var_sum : pic->mc_mb_var_sum;        short_term_q = 0; /* avoid warning */    if(s->flags&CODEC_FLAG_PASS2){        if(pict_type!=I_TYPE)            assert(pict_type == rce->new_pict_type);        q= rce->new_qscale / br_compensation;//printf("%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale, br_compensation, s->frame_bits, var, pict_type);    }else{        rce->pict_type=         rce->new_pict_type= pict_type;        rce->mc_mb_var_sum= pic->mc_mb_var_sum;        rce->mb_var_sum   = pic->   mb_var_sum;        rce->qscale   = FF_QP2LAMBDA * 2;        rce->f_code   = s->f_code;        rce->b_code   = s->b_code;        rce->misc_bits= 1;        if(picture_number>0)            update_rc_buffer(s, s->frame_bits);        bits= predict_size(&rcc->pred[pict_type], rce->qscale, sqrt(var));        if(pict_type== I_TYPE){            rce->i_count   = s->mb_num;            rce->i_tex_bits= bits;            rce->p_tex_bits= 0;            rce->mv_bits= 0;        }else{            rce->i_count   = 0; //FIXME we do know this approx            rce->i_tex_bits= 0;            rce->p_tex_bits= bits*0.9;                        rce->mv_bits= bits*0.1;        }        rcc->i_cplx_sum [pict_type] += rce->i_tex_bits*rce->qscale;        rcc->p_cplx_sum [pict_type] += rce->p_tex_bits*rce->qscale;        rcc->mv_bits_sum[pict_type] += rce->mv_bits;        rcc->frame_count[pict_type] ++;        bits= rce->i_tex_bits + rce->p_tex_bits;        rate_factor= rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum * br_compensation;            q= get_qscale(s, rce, rate_factor, picture_number);        assert(q>0.0);//printf("%f ", q);        q= get_diff_limited_q(s, rce, q);//printf("%f ", q);        assert(q>0.0);        if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependant blur like in 2-pass            rcc->short_term_qsum*=s->qblur;            rcc->short_term_qcount*=s->qblur;            rcc->short_term_qsum+= q;            rcc->short_term_qcount++;//printf("%f ", q);            q= short_term_q= rcc->short_term_qsum/rcc->short_term_qcount;//printf("%f ", q);        }        assert(q>0.0);                q= modify_qscale(s, rce, q, picture_number);        rcc->pass1_wanted_bits+= s->bit_rate/fps;        assert(q>0.0);    }    if(s->avctx->debug&FF_DEBUG_RC){        printf("%c qp:%d<%2.1f<%d %d want:%d total:%d comp:%f st_q:%2.2f size:%d var:%d/%d br:%d fps:%d\n",        av_get_pict_type_char(pict_type), qmin, q, qmax, picture_number, (int)wanted_bits/1000, (int)s->total_bits/1000,        br_compensation, short_term_q, s->frame_bits, pic->mb_var_sum, pic->mc_mb_var_sum, s->bit_rate/1000, (int)fps        );    }    if     (q<qmin) q=qmin;     else if(q>qmax) q=qmax;    if(s->adaptive_quant)        adaptive_quantization(s, q);    else        q= (int)(q + 0.5);        rcc->last_qscale= q;    rcc->last_mc_mb_var_sum= pic->mc_mb_var_sum;    rcc->last_mb_var_sum= pic->mb_var_sum;#if 0{    static int mvsum=0, texsum=0;    mvsum += s->mv_bits;    texsum += s->i_tex_bits + s->p_tex_bits;    printf("%d %d//\n\n", mvsum, texsum);}#endif    return q;}