[FFmpeg-soc] [soc]: r3923 - dirac/libavcodec/dirac_arith.c

conrad subversion at mplayerhq.hu
Thu Jan 1 21:31:59 CET 2009


Author: conrad
Date: Thu Jan  1 21:31:59 2009
New Revision: 3923

Log:
Move renormalization of the arith decoder to its own function

Modified:
   dirac/libavcodec/dirac_arith.c

Modified: dirac/libavcodec/dirac_arith.c
==============================================================================
--- dirac/libavcodec/dirac_arith.c	Thu Jan  1 21:31:56 2009	(r3922)
+++ dirac/libavcodec/dirac_arith.c	Thu Jan  1 21:31:59 2009	(r3923)
@@ -145,6 +145,29 @@ void dirac_init_arith_encoder(dirac_arit
     dirac_arith_init_common(arith);
 }
 
+static inline void renorm_arith_decoder(dirac_arith_state *arith)
+{
+    GetBitContext *gb = arith->gb;
+    while (arith->range <= 0x4000) {
+        if (((arith->low + arith->range - 1)^arith->low) >= 0x8000) {
+            arith->code ^= 0x4000;
+            arith->low  ^= 0x4000;
+        }
+        arith->low   <<= 1;
+        arith->range <<= 1;
+        arith->low    &= 0xFFFF;
+        arith->code  <<= 1;
+        if (arith->bits_left > 0) {
+            arith->code |= get_bits1(gb);
+            arith->bits_left--;
+        } else {
+            /* Get default: */
+            arith->code |= 1;
+        }
+        arith->code &= 0xffff;
+    }
+}
+
 /**
  * Read a single bit using the arithmetic decoder
  *
@@ -154,7 +177,6 @@ void dirac_init_arith_encoder(dirac_arit
  */
 int dirac_get_arith_bit(dirac_arith_state *arith, int context)
 {
-    GetBitContext *gb = arith->gb;
     unsigned int prob_zero = arith->contexts[context];
     unsigned int count;
     unsigned int range_times_prob;
@@ -179,24 +201,7 @@ int dirac_get_arith_bit(dirac_arith_stat
     else
         arith->contexts[context] += arith_lookup[255 - (arith->contexts[context] >> 8)];
 
-    while (arith->range <= 0x4000) {
-        if (((arith->low + arith->range - 1)^arith->low) >= 0x8000) {
-            arith->code ^= 0x4000;
-            arith->low  ^= 0x4000;
-        }
-        arith->low   <<= 1;
-        arith->range <<= 1;
-        arith->low    &= 0xFFFF;
-        arith->code  <<= 1;
-        if (arith->bits_left > 0) {
-            arith->code |= get_bits1(gb);
-            arith->bits_left--;
-        } else {
-            /* Get default: */
-            arith->code |= 1;
-        }
-        arith->code &= 0xffff;
-    }
+    renorm_arith_decoder(arith);
 
     return ret;
 }



More information about the FFmpeg-soc mailing list