]> git.sesse.net Git - x264/commitdiff
Hotfix for some bugs in VBV emergency
authorAnton Mitrofanov <BugMaster@narod.ru>
Sat, 29 Jan 2011 20:43:34 +0000 (12:43 -0800)
committerFiona Glaser <fiona@x264.com>
Sat, 29 Jan 2011 20:46:35 +0000 (12:46 -0800)
encoder/cabac.c
encoder/cavlc.c
encoder/encoder.c
encoder/set.c
x264.c

index 87bebdb0d4fa3483d42e436314f919b28990061d..7341dde39332ad45e7cece65db3c7a61fcd1d98d 100644 (file)
@@ -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 );
index 8854279933b192673b2154d1dac4d87206351b5b..0e193dbf9de0a14bc2872fce44fb4c5e4a3c1101 100644 (file)
@@ -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 );
 }
index ecb24a7c5b4e0fe269a49db3b4a503db1ba66bd7..1836f2f1a4f9677cc67f6c77e60b2b32869e4a25 100644 (file)
@@ -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 ) )
index ee19574b4435a4ed5a2ee077a8614d748ad0cc16..077eeae09d7abb45471a377b3c229441d97a940e 100644 (file)
@@ -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 96a0a0227147a51bc6ecb77e172b46a87fb5614a..6f5cb6427118970fce711d89febe9869a64f236f 100644 (file)
--- 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 );