q*= pow(d, 1.0/s->avctx->rc_buffer_aggressivity);
else if(d<0.0001) d=0.0001; q/= pow(d, 1.0/s->avctx->rc_buffer_aggressivity);
static double modify_qscale(MpegEncContext *s, RateControlEntry *rce, double q, int frame_num){    RateControlContext *rcc= &s->rc_context;    int qmin, qmax;    double bits;    const int pict_type= rce->new_pict_type;    const double buffer_size= s->avctx->rc_buffer_size;    const double min_rate= s->avctx->rc_min_rate;    const double max_rate= s->avctx->rc_max_rate;        get_qminmax(&qmin, &qmax, s, pict_type);    /* modulation */    if(s->avctx->rc_qmod_freq && frame_num%s->avctx->rc_qmod_freq==0 && pict_type==P_TYPE)        q*= s->avctx->rc_qmod_amp;    bits= qp2bits(rce, q);    /* buffer overflow/underflow protection */    if(buffer_size){        double expected_size= rcc->buffer_index - bits;        if(min_rate){            double d= 2*(buffer_size - (expected_size + min_rate))/buffer_size;            if(d>1.0) d=1.0;            q/= pow(d, 1.0/s->avctx->rc_buffer_aggressivity);        }        if(max_rate){            double d= 2*expected_size/buffer_size;            if(d>1.0) d=1.0;            q*= pow(d, 1.0/s->avctx->rc_buffer_aggressivity);        }    }    if(s->avctx->rc_qsquish==0.0 || qmin==qmax){        if     (q<qmin) q=qmin;        else if(q>qmax) q=qmax;    }else{        double min2= log(qmin);        double max2= log(qmax);                q= log(q);        q= (q - min2)/(max2-min2) - 0.5;        q*= -4.0;        q= 1.0/(1.0 + exp(q));        q= q*(max2-min2) + min2;                q= exp(q);    }    return q;}