[x264-devel] Cap ratecontrol predictor parameters
Anton Mitrofanov
git at videolan.org
Tue Jul 17 21:21:41 CEST 2012
x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Sat Jun 2 21:27:50 2012 +0400| [11e32c534a213168d8f466fb64bee75e1534d7af] | committer: Jason Garrett-Glaser
Cap ratecontrol predictor parameters
Limits VBV mispredictions after long periods of relatively constant video.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=11e32c534a213168d8f466fb64bee75e1534d7af
---
encoder/ratecontrol.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c
index 0437fbd..f9c8591 100644
--- a/encoder/ratecontrol.c
+++ b/encoder/ratecontrol.c
@@ -62,6 +62,7 @@ typedef struct
typedef struct
{
+ float coeff_min;
float coeff;
float count;
float decay;
@@ -689,17 +690,19 @@ int x264_ratecontrol_new( x264_t *h )
rc->lmax[i] = qp2qscale( h->param.rc.i_qp_max );
for( int j = 0; j < num_preds; j++ )
{
- rc->pred[i+j*5].coeff= 2.0;
- rc->pred[i+j*5].count= 1.0;
- rc->pred[i+j*5].decay= 0.5;
- rc->pred[i+j*5].offset= 0.0;
+ rc->pred[i+j*5].coeff_min = 2.0 / 4;
+ rc->pred[i+j*5].coeff = 2.0;
+ rc->pred[i+j*5].count = 1.0;
+ rc->pred[i+j*5].decay = 0.5;
+ rc->pred[i+j*5].offset = 0.0;
}
for( int j = 0; j < 2; j++ )
{
- rc->row_preds[i][j].coeff= .25;
- rc->row_preds[i][j].count= 1.0;
- rc->row_preds[i][j].decay= 0.5;
- rc->row_preds[i][j].offset= 0.0;
+ rc->row_preds[i][j].coeff_min = .25 / 4;
+ rc->row_preds[i][j].coeff = .25;
+ rc->row_preds[i][j].count = 1.0;
+ rc->row_preds[i][j].decay = 0.5;
+ rc->row_preds[i][j].offset = 0.0;
}
}
*rc->pred_b_from_p = rc->pred[0];
@@ -1922,7 +1925,7 @@ static void update_predictor( predictor_t *p, float q, float var, float bits )
if( var < 10 )
return;
float old_coeff = p->coeff / p->count;
- float new_coeff = bits*q / var;
+ float new_coeff = X264_MAX( bits*q / var, p->coeff_min );
float new_coeff_clipped = x264_clip3f( new_coeff, old_coeff/range, old_coeff*range );
float new_offset = bits*q - new_coeff_clipped * var;
if( new_offset >= 0 )
More information about the x264-devel
mailing list