[x264-devel] Hotfix for some bugs in VBV emergency

Anton Mitrofanov git at videolan.org
Sat Jan 29 23:06:39 CET 2011


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Sat Jan 29 12:43:34 2011 -0800| [7313bb53ff8545eda68eca219b1bee77ea4a25a6] | committer: Jason Garrett-Glaser

Hotfix for some bugs in VBV emergency

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=7313bb53ff8545eda68eca219b1bee77ea4a25a6
---

 encoder/cabac.c   |    6 +++---
 encoder/cavlc.c   |    8 ++++----
 encoder/encoder.c |    2 +-
 encoder/set.c     |    2 +-
 x264.c            |    2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/encoder/cabac.c b/encoder/cabac.c
index a553190..6333737 100644
--- a/encoder/cabac.c
+++ b/encoder/cabac.c
@@ -265,9 +265,9 @@ static void x264_cabac_mb_qp_delta( x264_t *h, x264_cabac_t *cb )
     if( i_dqp != 0 )
     {
         int val = i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp - 1);
-        /* dqp is interpreted modulo (QP_MAX+1) */
-        if( val >= QP_MAX && val != QP_MAX+1 )
-            val = 2*QP_MAX+1 - val;
+        /* dqp is interpreted modulo (QP_MAX_SPEC+1) */
+        if( val >= QP_MAX_SPEC && val != QP_MAX_SPEC+1 )
+            val = 2*QP_MAX_SPEC+1 - val;
         do
         {
             x264_cabac_encode_decision( cb, 60 + ctx, 1 );
diff --git a/encoder/cavlc.c b/encoder/cavlc.c
index 4d6b1dd..720cd18 100644
--- a/encoder/cavlc.c
+++ b/encoder/cavlc.c
@@ -222,10 +222,10 @@ static void cavlc_qp_delta( x264_t *h )
 
     if( i_dqp )
     {
-        if( i_dqp < -(QP_MAX+1)/2 )
-            i_dqp += QP_MAX+1;
-        else if( i_dqp > QP_MAX/2 )
-            i_dqp -= QP_MAX+1;
+        if( i_dqp < -(QP_MAX_SPEC+1)/2 )
+            i_dqp += QP_MAX_SPEC+1;
+        else if( i_dqp > QP_MAX_SPEC/2 )
+            i_dqp -= QP_MAX_SPEC+1;
     }
     bs_write_se( s, i_dqp );
 }
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 217bfa8..0182c8c 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -1066,7 +1066,7 @@ x264_t *x264_encoder_open( x264_param_t *param )
     x264_log( h, X264_LOG_INFO, "%s\n", buf );
 
     int qp_max = h->param.rc.i_qp_max == QP_MAX_SPEC ? QP_MAX : h->param.rc.i_qp_max;
-    for( qp = h->param.rc.i_qp_min; qp <= qp_max; qp++ )
+    for( qp = X264_MIN( h->param.rc.i_qp_min, QP_MAX_SPEC ); qp <= qp_max; qp++ )
         if( x264_analyse_init_costs( h, qp ) )
             goto fail;
     if( x264_analyse_init_costs( h, X264_LOOKAHEAD_QP ) )
diff --git a/encoder/set.c b/encoder/set.c
index ee19574..077eeae 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -445,7 +445,7 @@ void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *
     pps->b_weighted_pred = param->analyse.i_weighted_pred > 0;
     pps->b_weighted_bipred = param->analyse.b_weighted_bipred ? 2 : 0;
 
-    pps->i_pic_init_qp = param->rc.i_rc_method == X264_RC_ABR ? 26 + QP_BD_OFFSET : param->rc.i_qp_constant;
+    pps->i_pic_init_qp = param->rc.i_rc_method == X264_RC_ABR ? 26 + QP_BD_OFFSET : SPEC_QP( param->rc.i_qp_constant );
     pps->i_pic_init_qs = 26 + QP_BD_OFFSET;
 
     pps->i_chroma_qp_index_offset = param->analyse.i_chroma_qp_offset;
diff --git a/x264.c b/x264.c
index c0d7a0f..c6261d8 100644
--- a/x264.c
+++ b/x264.c
@@ -568,7 +568,7 @@ static void help( x264_param_t *defaults, int longhelp )
     H0( "\n" );
     H1( "  -q, --qp <integer>          Force constant QP (0-%d, 0=lossless)\n", QP_MAX );
     H0( "  -B, --bitrate <integer>     Set bitrate (kbit/s)\n" );
-    H0( "      --crf <float>           Quality-based VBR (%d-51) [%.1f]\n", 51 - QP_MAX, defaults->rc.f_rf_constant );
+    H0( "      --crf <float>           Quality-based VBR (%d-51) [%.1f]\n", 51 - QP_MAX_SPEC, defaults->rc.f_rf_constant );
     H1( "      --rc-lookahead <integer> Number of frames for frametype lookahead [%d]\n", defaults->rc.i_lookahead );
     H0( "      --vbv-maxrate <integer> Max local bitrate (kbit/s) [%d]\n", defaults->rc.i_vbv_max_bitrate );
     H0( "      --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [%d]\n", defaults->rc.i_vbv_buffer_size );



More information about the x264-devel mailing list