[xiph-cvs] cvs commit: w3d Makefile golomb.h

Holger Waechtler holger at xiph.org
Tue Nov 20 05:48:48 PST 2001



holger      01/11/20 05:48:48

  Modified:    .        Makefile golomb.h
  Log:
  - minor changes in the golomb code, gzip can compress the produced bitstream
    now only about 8% more - not too bad for simple RLE, isn't it?
  - removed some debug output

Revision  Changes    Path
1.22      +1 -1      w3d/Makefile

Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/w3d/Makefile,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Makefile	2001/11/20 11:33:05	1.21
+++ Makefile	2001/11/20 13:48:47	1.22
@@ -16,7 +16,7 @@
 #CFLAGS+= -DDBG_MEMLEAKS
 
 # dump a lot debug images
-#CFLAGS+= -DDBG_XFORM
+CFLAGS+= -DDBG_XFORM
 
 # dump ogg packet infos
 #CFLAGS+= -DDBG_OGG

1.4       +9 -7      w3d/golomb.h

Index: golomb.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/golomb.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- golomb.h	2001/11/20 13:06:37	1.3
+++ golomb.h	2001/11/20 13:48:47	1.4
@@ -18,13 +18,13 @@
 
 
 static inline
-void write_number_binary (BitCoderState *b, unsigned int x, int bits)
+void write_number_binary (BitCoderState *b, unsigned int x, int bits, int u)
 {
+//printf ("wrote %i with %i bits (%i+%i)\n", x, u+bits, u, bits);
    while (bits) {
       bits--;
       bitcoder_write_bit (b, (x >> bits) & 1);
    }
-printf ("wrote %i with %i bits\n", x, bits);
 }
 
 
@@ -46,20 +46,21 @@
 void golomb_write_number (BitCoderState *b, unsigned int x, int bits)
 {
    unsigned int q, r;
+int i = 0;
 
    assert (x > 0);
 
-
    while ((q = (x - 1) >> bits) > 0) {
       bitcoder_write_bit (b, 1);   /* fast temporary adaption, write  */ 
       bits++;                      /* unary representation of q       */
+i++;
    };
 
    bitcoder_write_bit (b, 0);
 
    r = x - 1 - (q << bits); 
 
-   write_number_binary (b, r, bits);
+   write_number_binary (b, r, bits, i+1);
 }
 
 
@@ -68,8 +69,9 @@
 {
    unsigned int q = 0, r, x;
 
-   while (bitcoder_read_bit (b) != 0)
+   while (bitcoder_read_bit (b) != 0) {
       bits++;
+   }
 
    r = read_number_binary (b, bits);
    x = (q << bits) + r + 1;
@@ -99,7 +101,7 @@
    golomb_write_number (b, x, g->bits >> 3);
 
    g->bits = ((256 - golomb_w_tab[g->count]) * (int) g->bits +
-                     golomb_w_tab[g->count] * ((required_bits(x)<<3) + 4)) / 256;
+                     golomb_w_tab[g->count] * (required_bits(x)<<3)) / 256;
    g->count++;
 
    if (g->count > 2)
@@ -116,7 +118,7 @@
    x = golomb_read_number (b, g->bits >> 3);
 
    g->bits = ((256 - golomb_w_tab[g->count]) * g->bits + 
-                     golomb_w_tab[g->count] * ((required_bits(x)<<3) + 4)) / 256;
+                     golomb_w_tab[g->count] * (required_bits(x)<<3)) / 256;
    g->count++;
 
    if (g->count > 2)

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list