[x264-devel] commit: use cabac context transition table from trellis in normal residual coding too (Jason Garrett-Glaser )

git version control git at videolan.org
Tue Mar 25 04:33:09 CET 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Mon Mar 24 19:21:24 2008 -0600| [e403fe9364ad1ea1cd8c3d5055759a538e97bb8b]

use cabac context transition table from trellis in normal residual coding too

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

 encoder/cabac.c |   26 ++++++++++++++++++--------
 encoder/rdo.c   |   13 -------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/encoder/cabac.c b/encoder/cabac.c
index e150cb0..b47b4bb 100644
--- a/encoder/cabac.c
+++ b/encoder/cabac.c
@@ -691,6 +691,19 @@ static const int last_coeff_flag_offset_8x8[63] = {
 };
 static const int identity[16] =
     { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+    
+// node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
+//           4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
+/* map node ctx => cabac ctx for level=1 */
+static const int coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
+/* map node ctx => cabac ctx for level>1 */
+static const int coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
+static const int coeff_abs_level_transition[2][8] = {
+/* update node ctx after coding a level=1 */
+    { 1, 2, 3, 3, 4, 5, 6, 7 },
+/* update node ctx after coding a level>1 */
+    { 4, 4, 4, 4, 5, 6, 7, 7 }
+};
 
 static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBlockCat, int i_idx, int16_t *l, int i_count )
 {
@@ -703,10 +716,7 @@ static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBl
     int i_coeff = 0;
     int i_last  = 0;
     int i_sigmap_size;
-
-    int i_abslevel1 = 0;
-    int i_abslevelgt1 = 0;
-
+    int node_ctx = 0;
     int i;
 
     const int *significant_coeff_flag_offset;
@@ -758,12 +768,12 @@ static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBl
     {
         /* write coeff_abs - 1 */
         const int i_prefix = X264_MIN( i_coeff_abs_m1[i], 14 );
-        const int i_ctxIdxInc = (i_abslevelgt1 ? 0 : X264_MIN( 4, i_abslevel1 + 1 )) + i_ctx_level;
+        const int i_ctxIdxInc = coeff_abs_level1_ctx[node_ctx] + i_ctx_level;
         x264_cabac_encode_decision( cb, i_ctxIdxInc, i_prefix != 0 );
 
         if( i_prefix != 0 )
         {
-            const int i_ctxIdxInc = 5 + X264_MIN( 4, i_abslevelgt1 ) + i_ctx_level;
+            const int i_ctxIdxInc = coeff_abs_levelgt1_ctx[node_ctx] + i_ctx_level;
 #ifdef RDO_SKIP_BS
             cb->f8_bits_encoded += cabac_prefix_size[i_prefix][cb->state[i_ctxIdxInc]];
             cb->state[i_ctxIdxInc] = cabac_prefix_transition[i_prefix][cb->state[i_ctxIdxInc]];
@@ -777,10 +787,10 @@ static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBl
             if( i_prefix >= 14 )
                 x264_cabac_encode_ue_bypass( cb, 0, i_coeff_abs_m1[i] - 14 );
 
-            i_abslevelgt1++;
+            node_ctx = coeff_abs_level_transition[1][node_ctx];
         }
         else
-            i_abslevel1++;
+            node_ctx = coeff_abs_level_transition[0][node_ctx];
 
         /* write sign */
 #ifdef RDO_SKIP_BS
diff --git a/encoder/rdo.c b/encoder/rdo.c
index 7967a92..31c720a 100644
--- a/encoder/rdo.c
+++ b/encoder/rdo.c
@@ -242,19 +242,6 @@ void x264_rdo_init( )
     }
 }
 
-// node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
-//           4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
-/* map node ctx => cabac ctx for level=1 */
-static const int coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
-/* map node ctx => cabac ctx for level>1 */
-static const int coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 };
-static const int coeff_abs_level_transition[2][8] = {
-/* update node.ctx after coding a level=1 */
-    { 1, 2, 3, 3, 4, 5, 6, 7 },
-/* update node.ctx after coding a level>1 */
-    { 4, 4, 4, 4, 5, 6, 7, 7 }
-};
-
 // should the intra and inter lambdas be different?
 // I'm just matching the behaviour of deadzone quant.
 static const int lambda2_tab[2][52] = {



More information about the x264-devel mailing list