[Mndiff-dev] [mndiff]: r18 - trunk/mnzip/mnzip.c

michael subversion at mplayerhq.hu
Sat Jun 9 13:15:59 CEST 2007


Author: michael
Date: Sat Jun  9 13:15:59 2007
New Revision: 18

Log:
proper rounding (negligible compression improvement)


Modified:
   trunk/mnzip/mnzip.c

Modified: trunk/mnzip/mnzip.c
==============================================================================
--- trunk/mnzip/mnzip.c	(original)
+++ trunk/mnzip/mnzip.c	Sat Jun  9 13:15:59 2007
@@ -438,20 +438,22 @@ static void init_prob(unsigned short *pr
 
 static inline void putbit(RangeCoder *c, uint32_t *state, int b, unsigned short *prob){
     int ctx= *state;
+    int p8= (prob[ctx] + 128)>>8;
 
-    uint8_t s= clip(prob[ctx]>>8, 1, 255);
+    uint8_t s= clip(p8, 1, 255);
     put_rac(c, &s, b);
-    prob[ctx]+= (b*65536 - prob[ctx] + 128)>>8;
+    prob[ctx]+= b*256 - p8;
 
     *state= state_table[ctx][b];
 }
 
 static inline int getbit(RangeCoder *c, uint32_t *state, unsigned short *prob){
     int ctx= *state;
+    int p8= (prob[ctx] + 128)>>8;
 
-    uint8_t s= clip(prob[ctx]>>8, 1, 255);
+    uint8_t s= clip(p8, 1, 255);
     int b= get_rac(c, &s);
-    prob[ctx]+= (b*65536 - prob[ctx] + 128)>>8;
+    prob[ctx]+= b*256 - p8;
 
     *state= state_table[ctx][b];
 



More information about the Mndiff-dev mailing list