MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / get_diff_limited_q

Function get_diff_limited_q

libavcodec/ratecontrol.c:377–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q){
378 RateControlContext *rcc= &s->rc_context;
379 AVCodecContext *a= s->avctx;
380 const int pict_type= rce->new_pict_type;
381 const double last_p_q = rcc->last_qscale_for[FF_P_TYPE];
382 const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type];
383
384 if (pict_type==FF_I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==FF_P_TYPE))
385 q= last_p_q *FFABS(a->i_quant_factor) + a->i_quant_offset;
386 else if(pict_type==FF_B_TYPE && a->b_quant_factor>0.0)
387 q= last_non_b_q* a->b_quant_factor + a->b_quant_offset;
388 if(q<1) q=1;
389
390 /* last qscale / qdiff stuff */
391 if(rcc->last_non_b_pict_type==pict_type || pict_type!=FF_I_TYPE){
392 double last_q= rcc->last_qscale_for[pict_type];
393 const int maxdiff= FF_QP2LAMBDA * a->max_qdiff;
394
395 if (q > last_q + maxdiff) q= last_q + maxdiff;
396 else if(q < last_q - maxdiff) q= last_q - maxdiff;
397 }
398
399 rcc->last_qscale_for[pict_type]= q; //Note we cannot do that after blurring
400
401 if(pict_type!=FF_B_TYPE)
402 rcc->last_non_b_pict_type= pict_type;
403
404 return q;
405}
406
407/**
408 * gets the qmin & qmax for pict_type

Callers 2

ff_rate_estimate_qscaleFunction · 0.85
init_pass2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected