[xiph-cvs] cvs commit: w3d .cvsignore Makefile TODO _test_bitcoder.c _test_rle.c bitcoder.h pnm.c pnm.h rle.h tarkin.c tarkin_enc.c wavelet.c wavelet.h wavelet_coeff.c yuv.c wavelet_coeff2.c zpcoder.c zpcoder.h
Holger Waechtler
holger at xiph.org
Fri Sep 7 03:56:32 PDT 2001
holger 01/09/07 03:56:32
Modified: . .cvsignore Makefile TODO _test_bitcoder.c
_test_rle.c bitcoder.h pnm.c pnm.h rle.h tarkin.c
tarkin_enc.c wavelet.c wavelet.h wavelet_coeff.c
yuv.c
Removed: . wavelet_coeff2.c zpcoder.c zpcoder.h
Log:
This commit applies a lot of my local changes of the last weeks,
some fixes and improvements as well as a major new introduced bug.
I removed the zpcoder files, I think we won't really need them. The idea
of using [huffman or range encoded required bits|binary written runlength]
in the entropy coder should work well.
The RLE coder implements this, but still uses the old static huffman coder,
this doesn't really fits this purpose. bzip2 squeezes out about 30% of the
compressed bitstream, that's ugly.
There is again a new major bug in the coefficient encoder, I hope to
fix this next days.
The Makefile now builds a non-debug version which performs about 5 times
faster. The command line help suggest much higher compression ratios now.
(I couldn't stand the 'this codec sucks, is slow etc.' talks anymore:)
Regression tests check now for correct end-of-stream handling.
Bitcoder is now marked empty when you read the first byte after end of stream.
16-bit coefficient images are not scaled anymore, offset is configurable
to allow correct Y as well as U and V and coefficient images.
Only the first component image (Y) is encoded with full bitstream length,
following images (U and V) are subsampled by a hardcoded factor of 4. This
should get configurable later.
The wavelet_3d_buf_dump() code moved into the wavelet.c core file.
I played a bit with truncation tables, I slowly get the feeling that the
current code should be able to compress a venuscube image downto about
900 bytes (a GIMP-created JPEG gets heavy artifacts at about 1100 bytes).
The current hardcoded truncation tables work well at 900-2000 bytes/frame
If there would not this nasty coefficient encoder bug...
Revision Changes Path
1.2 +4 -0 w3d/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /usr/local/cvsroot/w3d/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore 2001/08/07 14:37:41 1.1
+++ .cvsignore 2001/09/07 10:56:29 1.2
@@ -5,3 +5,7 @@
rle.histogram
tarkin_dec
tarkin_enc
+*.pgm
+*.ppm
+stream.tarkin
+
1.16 +1 -1 w3d/Makefile
Index: Makefile
===================================================================
RCS file: /usr/local/cvsroot/w3d/Makefile,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Makefile 2001/09/04 07:05:25 1.15
+++ Makefile 2001/09/07 10:56:29 1.16
@@ -4,7 +4,7 @@
CFLAGS = -g -O3 -Wall -DTYPE=int16_t -DRLECODER #-DDBG_XFORM -DDBG_MEMLEAKS
LFLAGS = -g #-lefence
-OBJS = mem.o pnm.o wavelet.o wavelet_xform.o wavelet_coeff.o wavelet_coeff2.o \
+OBJS = mem.o pnm.o wavelet.o wavelet_xform.o wavelet_coeff.o \
yuv.o tarkin.o tarkin-io.o
TEST_TARGETS = _test_bitcoder _test_rle _test_huffman
1.7 +5 -8 w3d/TODO
Index: TODO
===================================================================
RCS file: /usr/local/cvsroot/w3d/TODO,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TODO 2001/07/09 06:03:09 1.6
+++ TODO 2001/09/07 10:56:29 1.7
@@ -1,22 +1,19 @@
Open bugs and stuff required to fix them:
- - there is something really wrong in the truncation table code
- - there are strange errors accumulating over time ...
- (probably incomplete initialisation)
- - add the pnsr tools
+ - a bug in the yuv<->rgb24conversion, shows up in the clouds sequence
+ - clean up the pnsr tools
Wavelet-related TODO's:
- - implement truncation table setup
- - arithmetic binary entropy coders may be faster, simpler and more efficient;
- implement the ZP-Coder
- oggetize the stream format
+ - improve truncation table setup, the current code is pretty dumb
+ - try other approaches to encode coefficients, jack was talking about VQ
+ and reuse vorbis code
- write avitotarkin/quicktimetotarkin/mpegtotarkin/player/recorder
(a libsndfile/libaudiofile alike video library would be great !)
- profile
- add special transform functions for large strides to prevent cache misses
- - introduce fast paths in coefficient decoder if (mps == 0)
- mmx/3dnow/sse/altivec
1.3 +15 -7 w3d/_test_bitcoder.c
Index: _test_bitcoder.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/_test_bitcoder.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- _test_bitcoder.c 2001/07/09 06:03:09 1.2
+++ _test_bitcoder.c 2001/09/07 10:56:29 1.3
@@ -2,10 +2,10 @@
* Bitcoder regression test
*/
-#define TEST(x) \
- if(!(x)) { \
- fprintf(stderr, "Test ("#x") FAILED !!!\n"); \
- exit (-1); \
+#define TEST(x) \
+ if(!(x)) { \
+ fprintf(stderr, "line %i: Test ("#x") FAILED !!!\n", __LINE__); \
+ exit (-1); \
}
@@ -44,8 +44,9 @@
while (limit == 0)
limit = rand() * 1.0 * MAX_COUNT / RAND_MAX;
+ limit &= ~0x7;
- bit = (uint8_t*) MALLOC (limit);
+ bit = (uint8_t*) MALLOC (limit);
/**
* check encoding ...
@@ -63,7 +64,7 @@
count = bitcoder_flush (&encoder);
- TEST(count == limit/8 || count == limit/8 + 1);
+ TEST(count == limit/8);
bitstream = (uint8_t*) MALLOC (count);
memcpy (bitstream, encoder.bitstream, count);
@@ -78,10 +79,17 @@
BitCoderState decoder;
uint32_t i;
- bitcoder_decoder_init (&decoder, bitstream, limit);
+ bitcoder_decoder_init (&decoder, bitstream, count);
for (i=0; i<limit; i++) {
+ TEST(!decoder.eos);
TEST(bit[i] == bitcoder_read_bit (&decoder));
+ }
+
+ TEST(!decoder.eos);
+ for (i=0; i<limit; i++) {
+ TEST(bitcoder_read_bit (&decoder) == 0);
+ TEST(decoder.eos);
}
}
1.4 +2 -2 w3d/_test_rle.c
Index: _test_rle.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/_test_rle.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- _test_rle.c 2001/07/09 06:03:09 1.3
+++ _test_rle.c 2001/09/07 10:56:29 1.4
@@ -56,7 +56,7 @@
ENTROPY_ENCODER_INIT(&encoder, limit);
for (i=0; i<limit; i++) {
- bit[i] = (rand() > RAND_MAX/20) ? 0 : 1;
+ bit[i] = (rand() > RAND_MAX/100) ? 0 : 1; /* avg. runlength 100 */
OUTPUT_BIT(&encoder, bit[i]);
}
@@ -75,7 +75,7 @@
ENTROPY_CODER decoder;
uint32_t i;
- ENTROPY_DECODER_INIT(&decoder, bitstream, limit);
+ ENTROPY_DECODER_INIT(&decoder, bitstream, count);
for (i=0; i<limit; i++) {
int b = INPUT_BIT(&decoder);
1.8 +23 -20 w3d/bitcoder.h
Index: bitcoder.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/bitcoder.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- bitcoder.h 2001/07/31 08:07:00 1.7
+++ bitcoder.h 2001/09/07 10:56:30 1.8
@@ -26,11 +26,12 @@
typedef struct {
- uint32_t bit_count; /* number of valid bits in byte */
+ int32_t bit_count; /* number of valid bits in byte */
uint8_t byte; /* buffer to save bits */
uint32_t byte_count; /* number of bytes written */
uint8_t *bitstream;
uint32_t limit; /* don't write more bytes to bitstream ... */
+ int eos; /* end of stream reached */
} BitCoderState;
@@ -43,6 +44,7 @@
s->byte_count = 0;
s->bitstream = (uint8_t*) MALLOC (limit);
s->limit = limit;
+ s->eos = 0;
}
@@ -56,11 +58,12 @@
static inline
void bitcoder_decoder_init (BitCoderState *s, uint8_t *bitstream, uint32_t limit)
{
- s->bit_count = 0;
+ s->bit_count = -1;
s->byte = 0;
s->byte_count = 0;
s->bitstream = bitstream;
s->limit = limit;
+ s->eos = 0;
}
@@ -75,19 +78,7 @@
}
-static inline
-int bitcoder_is_empty (BitCoderState *s)
-{
- if (!s->bitstream || s->byte_count >= s->limit)
-{
-//printf ("bitcoder empty !!!\n");
- return 1;
-}
- return 0;
-}
-
-
static inline
void bitcoder_write_bit (BitCoderState *s, int bit)
{
@@ -96,9 +87,13 @@
s->bit_count++;
- if (s->bit_count == 8 && s->byte_count < s->limit) {
- s->bitstream [s->byte_count++] = s->byte;
- s->bit_count = 0;
+ if (s->bit_count == 8) {
+ if (s->byte_count < s->limit) {
+ s->bitstream [s->byte_count++] = s->byte;
+ s->bit_count = 0;
+ } else {
+ s->eos = 1;
+ }
}
}
@@ -108,11 +103,19 @@
{
int ret;
- if (s->bit_count == 0 && s->byte_count < s->limit) {
- if (!s->bitstream)
+ if (s->bit_count <= 0) {
+ if (!s->bitstream) {
+ s->eos = 1;
return 0;
+ }
+
+ if (s->byte_count < s->limit) {
+ s->byte = s->bitstream [s->byte_count++];
+ } else {
+ s->eos = 1;
+ s->byte = 0;
+ }
- s->byte = s->bitstream [s->byte_count++];
s->bit_count = 8;
}
1.3 +2 -4 w3d/pnm.c
Index: pnm.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/pnm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pnm.c 2001/07/09 06:59:56 1.2
+++ pnm.c 2001/09/07 10:56:30 1.3
@@ -155,13 +155,11 @@
static inline
uint8_t CLAMP(int16_t x)
{
- x *= 4;
- x += 128;
return ((x > 255) ? 255 : (x < 0) ? 0 : x);
}
-void write_pgm16 (char *fname, int16_t *rgb, int w, int h)
+void write_pgm16 (char *fname, int16_t *rgb, int w, int h, int16_t offset)
{
int i;
FILE *outfile;
@@ -175,7 +173,7 @@
fprintf (outfile, "P5\n%d %d\n%d\n", w, h, 255);
for (i=0; i<w*h; i++) {
- uint8_t c = CLAMP(rgb[i]);
+ uint8_t c = CLAMP(rgb[i] + offset);
fwrite (&c, 1, 1, outfile);
}
fclose (outfile);
1.2 +1 -1 w3d/pnm.h
Index: pnm.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/pnm.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pnm.h 2001/07/09 06:03:09 1.1
+++ pnm.h 2001/09/07 10:56:30 1.2
@@ -23,7 +23,7 @@
/**
* Write a int16_t buf into pgm file
*/
-extern void write_pgm16 (char *fname, int16_t *buf, int w, int h);
+extern void write_pgm16 (char *fname, int16_t *buf, int w, int h, int16_t offset);
#endif
1.9 +66 -16 w3d/rle.h
Index: rle.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/rle.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- rle.h 2001/07/31 08:07:00 1.8
+++ rle.h 2001/09/07 10:56:30 1.9
@@ -2,6 +2,7 @@
#define __RLE_H
#include <string.h>
+#include <assert.h>
#include "mem.h"
#include "bitcoder.h"
@@ -19,6 +20,7 @@
rlecoder_decoder_init(coder,bitstream,limit)
#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */
#define ENTROPY_CODER_BITSTREAM(coder) ((coder)->bitcoder.bitstream)
+#define ENTROPY_CODER_EOS(coder) ((coder)->bitcoder.eos)
#define ENTROPY_CODER_MPS(coder) ((coder)->mps)
#define ENTROPY_CODER_RUNLENGTH(coder) ((coder)->count+1)
@@ -29,14 +31,7 @@
#define RLE_HISTOGRAM 1
-typedef struct {
- int mps; /* more probable symbol */
- uint32_t count; /* have seen count+1 mps's */
- BitCoderState bitcoder;
-} RLECoderState;
-
-
/*
* Ugly.
*/
@@ -134,6 +129,62 @@
+static inline
+int required_bits (uint32_t x)
+{
+ int bits = 32;
+
+ assert (x >= 0);
+
+ while (--bits >= 0 && ((x >> bits) & 1) == 0)
+ ;
+
+ return bits;
+}
+
+
+static inline
+void write_unsigned_number (BitCoderState *s, uint32_t x)
+{
+ int bits;
+
+ assert (x >= 0);
+
+ bits = required_bits (x);
+
+ huffmancoder_write (s, bits);
+
+ while (--bits >= 0)
+ bitcoder_write_bit (s, (x >> bits) & 1);
+}
+
+static inline
+uint32_t read_unsigned_number (BitCoderState *s)
+{
+ int bits = huffmancoder_read (s);
+ uint32_t x = 1 << bits;
+
+ if (s->eos)
+ return ~0;
+
+ while (--bits >= 0) {
+ x |= bitcoder_read_bit (s) << bits;
+ if (s->eos)
+ return ~0;
+ }
+
+ return x;
+}
+
+
+typedef struct {
+ int mps; /* more probable symbol */
+ uint32_t count; /* have seen count mps's */
+ BitCoderState bitcoder;
+} RLECoderState;
+
+
+
#ifdef RLE_HISTOGRAM
uint32_t histogram [512];
uint32_t max_runlength;
@@ -153,7 +204,7 @@
#endif
s->mps = bit & 1;
s->count = 0;
- huffmancoder_write (&s->bitcoder, bit ? 1 : 0);
+ bitcoder_write_bit (&s->bitcoder, bit);
}
if (s->mps == bit) {
@@ -167,7 +218,7 @@
if (max_runlength < s->count)
max_runlength = s->count-1;
#endif
- huffmancoder_write (&s->bitcoder, s->count-1);
+ write_unsigned_number (&s->bitcoder, s->count);
s->mps = ~s->mps & 1;
s->count = 1;
}
@@ -177,9 +228,9 @@
int rlecoder_read_bit (RLECoderState *s)
{
if (s->count == 0) {
- s->count = huffmancoder_read (&s->bitcoder) + 1;
+ s->count = read_unsigned_number (&s->bitcoder);
s->mps = ~s->mps & 1;
- if (bitcoder_is_empty(&s->bitcoder)) {
+ if (s->bitcoder.eos) {
s->mps = 0;
s->count = ~0;
}
@@ -204,8 +255,7 @@
static inline
uint32_t rlecoder_encoder_flush (RLECoderState *s)
{
- huffmancoder_write (&s->bitcoder, s->count-1);
-
+ write_unsigned_number (&s->bitcoder, s->count);
return bitcoder_flush (&s->bitcoder);
}
@@ -214,9 +264,9 @@
void rlecoder_decoder_init (RLECoderState *s, uint8_t *bitstream, uint32_t limit)
{
bitcoder_decoder_init (&s->bitcoder, bitstream, limit);
- s->mps = huffmancoder_read (&s->bitcoder);
- s->count = huffmancoder_read (&s->bitcoder) + 1;
- if (bitcoder_is_empty(&s->bitcoder)) {
+ s->mps = bitcoder_read_bit (&s->bitcoder);
+ s->count = read_unsigned_number (&s->bitcoder);
+ if (s->bitcoder.eos) {
s->mps = 0;
s->count = ~0;
}
1.10 +14 -9 w3d/tarkin.c
Index: tarkin.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/tarkin.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- tarkin.c 2001/07/16 16:10:51 1.9
+++ tarkin.c 2001/09/07 10:56:30 1.10
@@ -131,21 +131,19 @@
for (j=0; j<layer->n_comp; j++) {
uint32_t bitstream_len;
- wavelet_3d_buf_dump ("color-%d-%03d.pgm",
- s->current_frame - s->current_frame_in_buf, j,
- layer->waveletbuf[j]);
-
wavelet_3d_buf_fwd_xform (layer->waveletbuf[j],
layer->desc.a_moments,
layer->desc.s_moments);
wavelet_3d_buf_dump ("coeff-%d-%03d.pgm",
s->current_frame - s->current_frame_in_buf, j,
- layer->waveletbuf[j]);
+ layer->waveletbuf[j], 128);
bitstream_len = wavelet_3d_buf_encode_coeff (layer->waveletbuf[j],
s->bitstream,
- layer->desc.bitstream_len);
+ j == 0 ?
+ layer->desc.bitstream_len :
+ layer->desc.bitstream_len/4);
write_tarkin_bitstream (s->fd, s->bitstream, bitstream_len);
}
}
@@ -154,13 +152,19 @@
uint32_t tarkin_stream_write_frame (TarkinStream *s, uint8_t **rgba)
{
- uint32_t i;
+ uint32_t i, j;
for (i=0; i<s->n_layers; i++) {
TarkinVideoLayer *layer = &s->layer[i];
layer->color_fwd_xform (rgba[i], layer->waveletbuf,
s->current_frame_in_buf);
+
+ for (j=0; j<layer->n_comp; j++)
+ wavelet_3d_buf_dump ("color-%d-%03d.pgm",
+ s->current_frame - s->current_frame_in_buf, j,
+ layer->waveletbuf[j], j == 0 ? 0 : 128);
+
}
s->current_frame_in_buf++;
@@ -280,7 +284,8 @@
bitstream_len);
wavelet_3d_buf_dump ("rcoeff-%d-%03d.pgm",
- s->current_frame, j, layer->waveletbuf[j]);
+ s->current_frame, j, layer->waveletbuf[j],
+ 128);
wavelet_3d_buf_inv_xform (layer->waveletbuf[j],
layer->desc.a_moments,
@@ -288,7 +293,7 @@
wavelet_3d_buf_dump ("rcolor-%d-%03d.pgm",
s->current_frame - s->current_frame_in_buf, j,
- layer->waveletbuf[j]);
+ layer->waveletbuf[j], j == 0 ? 0 : 128);
}
}
}
1.11 +1 -1 w3d/tarkin_enc.c
Index: tarkin_enc.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/tarkin_enc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- tarkin_enc.c 2001/09/04 07:05:25 1.10
+++ tarkin_enc.c 2001/09/07 10:56:30 1.11
@@ -34,7 +34,7 @@
int fd;
TarkinStream *tarkin_stream;
TarkinVideoLayerDesc layer [] = { { 0, 0, 1, 5000, TARKIN_RGB24 } };
- TarkinColorFormat type;
+ int type;
if (argc == 1) {
layer[0].bitstream_len = 1000;
1.12 +23 -0 w3d/wavelet.c
Index: wavelet.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- wavelet.c 2001/07/09 08:17:01 1.11
+++ wavelet.c 2001/09/07 10:56:30 1.12
@@ -97,3 +97,26 @@
}
+#if defined(DBG_XFORM)
+
+#include "pnm.h"
+
+void wavelet_3d_buf_dump (char *fmt,
+ uint32_t first_frame_in_buf,
+ uint32_t id,
+ Wavelet3DBuf* buf,
+ int16_t offset)
+{
+ char fname [256];
+ uint32_t f;
+
+ for (f=0; f<buf->frames; f++) {
+ snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
+
+ write_pgm16 (fname, buf->data + f * buf->width * buf->height,
+ buf->width, buf->height, offset);
+ }
+}
+#endif
+
+
1.5 +2 -1 w3d/wavelet.h
Index: wavelet.h
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- wavelet.h 2001/06/29 15:13:07 1.4
+++ wavelet.h 2001/09/07 10:56:30 1.5
@@ -46,7 +46,8 @@
extern void wavelet_3d_buf_dump (char *fmt,
uint32_t first_frame_in_buf,
uint32_t id,
- Wavelet3DBuf* buf);
+ Wavelet3DBuf* buf,
+ int16_t offset);
#else
#define wavelet_3d_buf_dump(x...)
#endif
1.4 +19 -29 w3d/wavelet_coeff.c
Index: wavelet_coeff.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/wavelet_coeff.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- wavelet_coeff.c 2001/07/31 08:07:00 1.3
+++ wavelet_coeff.c 2001/09/07 10:56:30 1.4
@@ -29,6 +29,7 @@
}
+
static inline
TYPE decode_coeff (ENTROPY_CODER significand_bitstream [],
ENTROPY_CODER insignificand_bitstream [])
@@ -41,9 +42,13 @@
do {
i--;
significance = INPUT_BIT(&significand_bitstream[i]) << i;
+ if (ENTROPY_CODER_EOS(&significand_bitstream[i]))
+ return 0;
} while (!significance && i > 0);
sign = INPUT_BIT(&significand_bitstream[i]);
+ if (ENTROPY_CODER_EOS(&significand_bitstream[i]))
+ return 0;
while (--i >= 0) {
significance |= INPUT_BIT(&insignificand_bitstream[i]) << i;
@@ -257,14 +262,16 @@
static
uint32_t insignificand_truncation_table [10] = {
-// 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
- 100, 100, 100, 100, 100, 100, 100, 100, 100, 100
+// 1, 2, 4, 8, 16, 12, 64, 128, 256, 512
+// 100, 100, 100, 100, 100, 100, 100, 100, 100, 100
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 48
};
static
uint32_t significand_truncation_table [9] = { //1, 2, 4, 8, 16, 32, 64, 128, 256 };
- 100, 100, 100, 100, 100, 100, 100, 100, 100
+// 100, 100, 100, 100, 100, 100, 100, 100, 100
+ 24, 24, 24, 24, 24, 24, 24, 24, 48
};
@@ -286,22 +293,27 @@
uint32_t bytes = ENTROPY_ENCODER_FLUSH(&insignificand_bitstream[i]);
insignificand_limittab[i] =
- limit * insignificand_truncation_table[i] / 2048;
+ limit * insignificand_truncation_table[i] / 2048;
if (bytes < insignificand_limittab[i])
insignificand_limittab[i] = bytes;
-printf ("insignificand_limittab[%i] == %u\n", i, insignificand_limittab[i]);
+printf ("insignificand_limittab[%i] == %u / %u\n", i, insignificand_limittab[i], bytes);
byte_count += insignificand_limittab[i];
}
for (i=9; i>0; i--) {
uint32_t bytes = ENTROPY_ENCODER_FLUSH(&significand_bitstream[i]);
+
+ significand_limittab[i] = limit * significand_truncation_table[9-i] / 2048
+ + (10-i)*(limit - byte_count)/10;
- significand_limittab[i] = limit * significand_truncation_table[9-i] / 2048;
+ if (significand_limittab[i] > limit - byte_count)
+ significand_limittab[i] = limit - byte_count;
if (bytes < significand_limittab[i])
significand_limittab[i] = bytes;
-printf ("significand_limittab[%i] == %u\n", i, significand_limittab[i]);
+printf ("significand_limittab[%i] == %u / %u\n", i, significand_limittab[i], bytes);
+
byte_count += significand_limittab[i];
}
@@ -479,26 +491,4 @@
}
}
-
-
-#if defined(DBG_XFORM)
-
-#include "pnm.h"
-
-void wavelet_3d_buf_dump (char *fmt,
- uint32_t first_frame_in_buf,
- uint32_t id,
- Wavelet3DBuf* buf)
-{
- char fname [256];
- uint32_t f;
-
- for (f=0; f<buf->frames; f++) {
- snprintf (fname, 256, fmt, id, first_frame_in_buf + f);
-
- write_pgm16 (fname, buf->data + f * buf->width * buf->height,
- buf->width, buf->height);
- }
-}
-#endif
1.7 +2 -2 w3d/yuv.c
Index: yuv.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/yuv.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- yuv.c 2001/06/29 09:19:25 1.6
+++ yuv.c 2001/09/07 10:56:30 1.7
@@ -1,12 +1,12 @@
#include "yuv.h"
+
+
static inline
uint8_t CLAMP(int16_t x)
{
return ((x > 255) ? 255 : (x < 0) ? 0 : 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