From: Loren Merritt Date: Thu, 16 Feb 2006 01:32:56 +0000 (+0000) Subject: allow delta_qp > 26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14b26394bd35f6ab03c6d4b7424ddea893a5bfa1;p=libx264 allow delta_qp > 26 git-svn-id: svn://svn.videolan.org/x264/trunk@438 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/encoder/cabac.c b/encoder/cabac.c index 790e7e59..1657d636 100644 --- a/encoder/cabac.c +++ b/encoder/cabac.c @@ -356,7 +356,6 @@ static void x264_cabac_mb_qp_delta( x264_t *h, x264_cabac_t *cb ) { int i_mbn_xy = h->mb.i_mb_xy - 1; int i_dqp = h->mb.i_qp - h->mb.i_last_qp; - int val = i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp - 1); int ctx; /* No need to test for PCM / SKIP */ @@ -366,14 +365,20 @@ static void x264_cabac_mb_qp_delta( x264_t *h, x264_cabac_t *cb ) else ctx = 0; - while( val > 0 ) + if( i_dqp != 0 ) { - x264_cabac_encode_decision( cb, 60 + ctx, 1 ); - if( ctx < 2 ) - ctx = 2; - else - ctx = 3; - val--; + int val = i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp - 1); + /* dqp is interpreted modulo 52 */ + if( val > 52 ) + val = 103 - val; + while( val-- ) + { + x264_cabac_encode_decision( cb, 60 + ctx, 1 ); + if( ctx < 2 ) + ctx = 2; + else + ctx = 3; + } } x264_cabac_encode_decision( cb, 60 + ctx, 0 ); }