[xiph-cvs] cvs commit: w3d Makefile golomb.h
Holger Waechtler
holger at xiph.org
Tue Nov 20 03:33:09 PST 2001
holger 01/11/20 03:33:08
Modified: . Makefile golomb.h
Log:
introduced a fast adaption path for large numbers in the golomb coder
Revision Changes Path
1.21 +2 -2 w3d/Makefile
Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/w3d/Makefile,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Makefile 2001/11/20 11:15:00 1.20
+++ Makefile 2001/11/20 11:33:05 1.21
@@ -1,7 +1,7 @@
CC = gcc
RM = rm -rf
-CFLAGS = -pg -O2 -Wall -I../ogg/ogg/include
+CFLAGS = -g -O0 -Wall -I../ogg/ogg/include
# use 16 bit signed integers as wavelet coefficients
CFLAGS+= -DTYPE=int16_t
@@ -24,7 +24,7 @@
# disable assertions
#CFLAGS+= -DNDEBUG
-LFLAGS = -pg -lefence -logg -L../ogg/ogg/src/.libs
+LFLAGS = -g -lefence -logg -L../ogg/ogg/src/.libs
OBJS = mem.o pnm.o wavelet.o wavelet_xform.o wavelet_coeff.o \
yuv.o tarkin.o info.o
1.2 +15 -45 w3d/golomb.h
Index: golomb.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/golomb.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- golomb.h 2001/11/20 11:15:00 1.1
+++ golomb.h 2001/11/20 11:33:05 1.2
@@ -6,28 +6,6 @@
static inline
-void write_number_unary (BitCoderState *b, unsigned int x)
-{
- while (x--)
- bitcoder_write_bit (b, 1);
-
- bitcoder_write_bit (b, 0);
-}
-
-
-static inline
-unsigned int read_number_unary (BitCoderState *b)
-{
- unsigned int x = 0;
-
- while (bitcoder_read_bit (b))
- x++;
-
- return x;
-}
-
-
-static inline
void write_number_binary (BitCoderState *b, unsigned int x, int bits)
{
while (bits) {
@@ -69,39 +47,31 @@
unsigned int q, r;
assert (x > 0);
+
+
+ while ((q = (x - 1) >> bits) > 0) {
+ bitcoder_write_bit (b, 1); /* fast temporary adaption, write */
+ bits++; /* unary representation of q */
+ };
- q = (x - 1) >> bits;
+ bitcoder_write_bit (b, 0);
+
r = x - 1 - (q << bits);
- if (q >= 15) {
- if (x > 0xffff) {
- write_number_unary (b, 16);
- write_number_binary (b, x, 32);
- } else {
- write_number_unary (b, 15);
- write_number_binary (b, x, 16);
- }
- } else {
- write_number_unary (b, q);
- write_number_binary (b, r, bits);
- }
+ write_number_binary (b, r, bits);
}
static inline
unsigned int golomb_read_number (BitCoderState *b, int bits)
{
- unsigned int q, r, x;
+ unsigned int q = 0, r, x;
- q = read_number_unary (b);
- if (q == 15)
- x = read_number_binary (b, 16);
- else if (q == 16)
- x = read_number_binary (b, 32);
- else {
- r = read_number_binary (b, bits);
- x = (q << bits) + r + 1;
- }
+ while (bitcoder_read_bit (b) != 0)
+ bits++;
+
+ r = read_number_binary (b, bits);
+ x = (q << bits) + r + 1;
return x;
}
--- >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