]> git.sesse.net Git - x264/commitdiff
wrong modulus when delta_qp = +26
authorLoren Merritt <pengvado@videolan.org>
Fri, 10 Mar 2006 18:58:29 +0000 (18:58 +0000)
committerLoren Merritt <pengvado@videolan.org>
Fri, 10 Mar 2006 18:58:29 +0000 (18:58 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@466 df754926-b1dd-0310-bc7b-ec298dee348c

encoder/cabac.c
encoder/cavlc.c

index 1657d6363e7431abf330f84267f0b784a8248f11..8d45fbe8ad7934c721d9976f26af39c6c68d36fa 100644 (file)
@@ -369,7 +369,7 @@ static void x264_cabac_mb_qp_delta( x264_t *h, x264_cabac_t *cb )
     {
         int val = i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp - 1);
         /* dqp is interpreted modulo 52 */
-        if( val > 52 )
+        if( val >= 51 && val != 52 )
             val = 103 - val;
         while( val-- )
         {
index 893d90dfc17c982eeaae96e052f0fe21379bbcde..fc662907bd2890de3fce4d13a663a96d4c79f50f 100644 (file)
@@ -259,11 +259,12 @@ static void cavlc_qp_delta( x264_t *h, bs_t *s )
     int i_dqp = h->mb.i_qp - h->mb.i_last_qp;
     if( i_dqp )
     {
-        i_dqp = i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp - 1);
-        if( i_dqp > 52 )
-            i_dqp = 103 - i_dqp;
+        if( i_dqp < -26 )
+            i_dqp += 52;
+        else if( i_dqp > 25 )
+            i_dqp -= 52;
     }
-    bs_write_ue( s, i_dqp );
+    bs_write_se( s, i_dqp );
 }
 
 static void x264_sub_mb_mv_write_cavlc( x264_t *h, bs_t *s, int i_list )