|
From: James B. <ja...@ex...> - 2000-04-28 07:00:49
|
I'm experimenting with a new bitstream implementation that avoids
branches. Basically it avoids keeping any state about the bitstream
around, avoids branches, and makes parse.o 2k smaller. It looks like
this:
typedef struct bitstream_s {
guint8 *buf;
gint32 offset;
} bitstream_t;
static inline guint32 bitstream_show_16(bitstream_t * bs) {
guint32 a, b, c;
guint r = bs->offset & 7;
guint8 *s = &bs->buf[bs->offset >> 3];
return (((s[0] << 16) | (s[1] << 8) | s[2]) >> (8 - r)) & 0xffff;
}
static inline guint32 bitstream_show(bitstream_t * bs, guint32 num_bits)
{
return bitstream_show_16(bs) >> (16 - num_bits);
}
static inline void bitstream_flush(bitstream_t * bs, guint32 num_bits) {
bs->offset += num_bits;
}
static inline void bitstream_seek_set(bitstream_t *bs, guint32 offset) {
bs->offset = offset;
}
[I've skipped a couple of functions, but you get the idea...]
Here's the trouble: dv_parse_ac_coeffs calls dv_find_spilled_vlc which
uses bitstream_unget to push bits back into the stream. Any suggestions
on an alternative implementation which avoids doing this?
--
James Bowman
ja...@ex...
|