[FFmpeg-soc] [soc]: r3925 - in dirac/libavcodec: dirac_arith.c dirac_arith.h

conrad subversion at mplayerhq.hu
Thu Jan 1 21:32:04 CET 2009


Author: conrad
Date: Thu Jan  1 21:32:03 2009
New Revision: 3925

Log:
Read in two bytes at a time in the arith decoder

Modified:
   dirac/libavcodec/dirac_arith.c
   dirac/libavcodec/dirac_arith.h

Modified: dirac/libavcodec/dirac_arith.c
==============================================================================
--- dirac/libavcodec/dirac_arith.c	Thu Jan  1 21:32:01 2009	(r3924)
+++ dirac/libavcodec/dirac_arith.c	Thu Jan  1 21:32:03 2009	(r3925)
@@ -128,9 +128,10 @@ void dirac_init_arith_decoder(dirac_arit
 {
     align_get_bits(gb);
     arith->pb        = NULL;
-    arith->bits_left = 8 * length - 16;
-    arith->low       = get_bits(gb, 16);
+    arith->bits_left = 8 * length - 32;
+    arith->low       = get_bits_long(gb, 32);
     arith->gb        = gb;
+    arith->counter   = 16;
 
     dirac_arith_init_common(arith);
 }
@@ -152,10 +153,11 @@ static inline void renorm_arith_decoder(
         arith->low   <<= 1;
         arith->range <<= 1;
 
-        if (arith->bits_left > 0) {
-            arith->low |= get_bits1(gb);
-            arith->bits_left--;
-        } else {
+        if (arith->bits_left > 0 && !--arith->counter) {
+            arith->low |= get_bits_long(gb, 16);
+            arith->bits_left -= 16;
+            arith->counter = 16;
+        } else if (arith->bits_left <= 0) {
             arith->low |= 1;
         }
     }
@@ -178,9 +180,9 @@ int dirac_get_arith_bit(dirac_arith_stat
     assert(!arith->pb);
 
     range_times_prob  = (arith->range * prob_zero) >> 16;
-    if (arith->low >= range_times_prob) {
+    if ((arith->low >> 16) >= range_times_prob) {
         ret = 1;
-        arith->low   -= range_times_prob;
+        arith->low   -= range_times_prob << 16;
         arith->range -= range_times_prob;
     } else {
         ret = 0;

Modified: dirac/libavcodec/dirac_arith.h
==============================================================================
--- dirac/libavcodec/dirac_arith.h	Thu Jan  1 21:32:01 2009	(r3924)
+++ dirac/libavcodec/dirac_arith.h	Thu Jan  1 21:32:03 2009	(r3925)
@@ -79,7 +79,8 @@ typedef struct dirac_arith_state {
     /* Arithmetic decoding. */
     unsigned int low;
     unsigned int range;
-    unsigned int bits_left;
+    int bits_left;
+    unsigned int counter;
     int carry;
     unsigned int contexts[ARITH_CONTEXT_COUNT];
 



More information about the FFmpeg-soc mailing list