minor improvement in FLAC__bitbuffer_write_raw_uint32
authorJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 3 May 2001 20:10:11 +0000 (20:10 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 3 May 2001 20:10:11 +0000 (20:10 +0000)
src/libFLAC/bitbuffer.c

index 30dc655..ac96b61 100644 (file)
@@ -267,17 +267,6 @@ bool FLAC__bitbuffer_write_zeroes(FLAC__BitBuffer *bb, unsigned bits)
 
 bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, uint32 val, unsigned bits)
 {
-       static const uint32 mask[] = {
-               0,
-               0x00000001, 0x00000003, 0x00000007, 0x0000000F,
-               0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,
-               0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF,
-               0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF,
-               0x0001FFFF, 0x0003FFFF, 0x0007FFFF, 0x000FFFFF,
-               0x001FFFFF, 0x003FFFFF, 0x007FFFFF, 0x00FFFFFF,
-               0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF,
-               0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF
-       };
        unsigned n, k;
 
        assert(bb != 0);
@@ -288,7 +277,7 @@ bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, uint32 val, unsigned
                return true;
        if(!bitbuffer_ensure_size_(bb, bits))
                return false;
-       val &= mask[bits];
+       val &= (~(0xffffffffu << bits)); /* zero-out unused bits */
        bb->total_bits += bits;
        while(bits > 0) {
                n = 8 - bb->bits;