From: Jonathan Rosser <[EMAIL PROTECTED]>

Signed-off-by: David Flynn <[EMAIL PROTECTED]>
---
 schroedinger/schroarith.c |   11 ++++++-----
 schroedinger/schroarith.h |   13 ++++++++++---
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/schroedinger/schroarith.c b/schroedinger/schroarith.c
index 224c34b..f251507 100644
--- a/schroedinger/schroarith.c
+++ b/schroedinger/schroarith.c
@@ -147,16 +147,17 @@ schro_arith_decode_init (SchroArith *arith, SchroBuffer 
*buffer)
   arith->range[1] = 0xffff;
   arith->range_size = arith->range[1] - arith->range[0];
   arith->code = 0;
-  arith->cntr = 8;
+  arith->cntr = 16;
 
   arith->buffer = buffer;
 
   size = arith->buffer->length;
   arith->dataptr = arith->buffer->data;
-  arith->code = ((size > 0) ? arith->dataptr[0] : 0xff) << 16;
-  arith->code |= ((size > 1) ? arith->dataptr[1] : 0xff) << 8;
-  arith->code |= ((size > 2) ? arith->dataptr[2] : 0xff);
-  arith->offset = 2;
+  arith->code = ((size > 0) ? arith->dataptr[0] : 0xff) << 24;
+  arith->code |= ((size > 1) ? arith->dataptr[1] : 0xff) << 16;
+  arith->code |= ((size > 2) ? arith->dataptr[2] : 0xff) << 8;
+  arith->code |= ((size > 3) ? arith->dataptr[3] : 0xff);
+  arith->offset = 3;
 
   for(i=0;i<SCHRO_CTX_LAST;i++){
     arith->contexts[i].next = next_list[i];
diff --git a/schroedinger/schroarith.h b/schroedinger/schroarith.h
index 228e89d..42f92c6 100644
--- a/schroedinger/schroarith.h
+++ b/schroedinger/schroarith.h
@@ -167,23 +167,30 @@ _schro_arith_decode_bit (SchroArith *arith, unsigned int 
i)
     if (!--arith->cntr) {
       arith->offset++;
       if (arith->offset < arith->buffer->length) {
+        code_minus_low |= arith->dataptr[arith->offset] << 8;
+      } else {
+        code_minus_low |= 0xff00;
+      }
+
+      arith->offset++;
+      if (arith->offset < arith->buffer->length) {
         code_minus_low |= arith->dataptr[arith->offset];
       } else {
         code_minus_low |= 0xff;
       }
 
-      arith->cntr = 8;
+      arith->cntr = 16;
     }
   }
 
   range_x_prob = (range * arith->probabilities[i]) >> 16;
   lut_index = arith->probabilities[i]>>7 & ~1;
 
-  value = ((code_minus_low >> 8) >= range_x_prob);
+  value = ((code_minus_low >> 16) >= range_x_prob);
   arith->probabilities[i] += arith->lut[lut_index | value];
 
   if (value) {
-    code_minus_low -= range_x_prob << 8;
+    code_minus_low -= range_x_prob << 16;
     range -= range_x_prob;
   } else {
     range = range_x_prob;
-- 
1.5.5




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Schrodinger-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/schrodinger-devel

Reply via email to