static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q){

    RateControlContext *rcc= &s->rc_context;

    AVCodecContext *a= s->avctx;

    const int pict_type= rce->new_pict_type;

    const double last_p_q    = rcc->last_qscale_for[P_TYPE];

    const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type];



    if     (pict_type==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))

        q= last_p_q    *FFABS(a->i_quant_factor) + a->i_quant_offset;

    else if(pict_type==B_TYPE && a->b_quant_factor>0.0)

        q= last_non_b_q*    a->b_quant_factor  + a->b_quant_offset;




    /* last qscale / qdiff stuff */

    if(rcc->last_non_b_pict_type==pict_type || pict_type!=I_TYPE){

        double last_q= rcc->last_qscale_for[pict_type];

        const int maxdiff= FF_QP2LAMBDA * a->max_qdiff;



        if     (q > last_q + maxdiff) q= last_q + maxdiff;

        else if(q < last_q - maxdiff) q= last_q - maxdiff;

    }



    rcc->last_qscale_for[pict_type]= q; //Note we cannot do that after blurring



    if(pict_type!=B_TYPE)

        rcc->last_non_b_pict_type= pict_type;



    return q;

}
static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q){

    RateControlContext *rcc= &s->rc_context;

    AVCodecContext *a= s->avctx;

    const int pict_type= rce->new_pict_type;

    const double last_p_q    = rcc->last_qscale_for[P_TYPE];

    const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type];



    if     (pict_type==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))

        q= last_p_q    *FFABS(a->i_quant_factor) + a->i_quant_offset;

    else if(pict_type==B_TYPE && a->b_quant_factor>0.0)

        q= last_non_b_q*    a->b_quant_factor  + a->b_quant_offset;




    

    if(rcc->last_non_b_pict_type==pict_type || pict_type!=I_TYPE){

        double last_q= rcc->last_qscale_for[pict_type];

        const int maxdiff= FF_QP2LAMBDA * a->max_qdiff;



        if     (q > last_q + maxdiff) q= last_q + maxdiff;

        else if(q < last_q - maxdiff) q= last_q - maxdiff;

    }



    rcc->last_qscale_for[pict_type]= q; 



    if(pict_type!=B_TYPE)

        rcc->last_non_b_pict_type= pict_type;



    return q;

}
static double FUNC_0(MpegEncContext *VAR_0, RateControlEntry *VAR_1, double VAR_2){

    RateControlContext *rcc= &VAR_0->rc_context;

    AVCodecContext *a= VAR_0->avctx;

    const int VAR_3= VAR_1->new_pict_type;

    const double VAR_4    = rcc->last_qscale_for[P_TYPE];

    const double VAR_5= rcc->last_qscale_for[rcc->last_non_b_pict_type];



    if     (VAR_3==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))

        VAR_2= VAR_4    *FFABS(a->i_quant_factor) + a->i_quant_offset;

    else if(VAR_3==B_TYPE && a->b_quant_factor>0.0)

        VAR_2= VAR_5*    a->b_quant_factor  + a->b_quant_offset;




    

    if(rcc->last_non_b_pict_type==VAR_3 || VAR_3!=I_TYPE){

        double VAR_6= rcc->last_qscale_for[VAR_3];

        const int VAR_7= FF_QP2LAMBDA * a->max_qdiff;



        if     (VAR_2 > VAR_6 + VAR_7) VAR_2= VAR_6 + VAR_7;

        else if(VAR_2 < VAR_6 - VAR_7) VAR_2= VAR_6 - VAR_7;

    }



    rcc->last_qscale_for[VAR_3]= VAR_2; 



    if(VAR_3!=B_TYPE)

        rcc->last_non_b_pict_type= VAR_3;



    return VAR_2;

}
static double FUNC_0(MpegEncContext *VAR_0, RateControlEntry *VAR_1, double VAR_2){ RateControlContext *rcc= &VAR_0->rc_context; AVCodecContext *a= VAR_0->avctx; const int VAR_3= VAR_1->new_pict_type; const double VAR_4    = rcc->last_qscale_for[P_TYPE]; const double VAR_5= rcc->last_qscale_for[rcc->last_non_b_pict_type]; if     (VAR_3==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))
VAR_2= VAR_4    *FFABS(a->i_quant_factor) + a->i_quant_offset; else if(VAR_3==B_TYPE && a->b_quant_factor>0.0)
VAR_2= VAR_5*    a->b_quant_factor  + a->b_quant_offset; if(rcc->last_non_b_pict_type==VAR_3 || VAR_3!=I_TYPE){ double VAR_6= rcc->last_qscale_for[VAR_3]; const int VAR_7= FF_QP2LAMBDA * a->max_qdiff; if     (VAR_2 > VAR_6 + VAR_7) VAR_2= VAR_6 + VAR_7; else if(VAR_2 < VAR_6 - VAR_7) VAR_2= VAR_6 - VAR_7; } rcc->last_qscale_for[VAR_3]= VAR_2; if(VAR_3!=B_TYPE)
rcc->last_non_b_pict_type= VAR_3; return VAR_2; }