[flac-dev] [PATCH 3] for bitwriter.c

lvqcl lvqcl.mail at gmail.com
Mon Dec 28 12:03:20 PST 2015

1) Added assert
     FLAC__ASSERT((bits == 32) || (val>>bits == 0))
It was inspired by https://sourceforge.net/p/flac/bugs/351/
Such situation should be detected at least.

2) Unnecessary assignments removed:
     bw->accum = val;
     bw->bits = 0;
(bw->bits is already 0 at this place).

3) Asserts like
     FLAC__ASSERT(parameter < sizeof(unsigned)*8)
were changed to
     FLAC__ASSERT(parameter < 32)

I don't understand why sizeof is better here. Also, bitreader.c already uses
asserts like "FLAC__ASSERT(parameter <= 31)".

4) Fixed the calculation of mask1 and mask2. The current code is incorrect
if FLAC__WORD_ALL_ONES is not 32-bit, so better to replace it with the
proper 32-bit constant.

5) In FLAC__bitwriter_write_rice_signed_block() the new variable total_bits
was added (just as in FLAC__bitwriter_write_rice_signed()). The code was
simplified. Example:
-			bw->bits = bw->bits + msbits + lsbits;
+			bw->bits += total_bits;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3_bitwriter.patch
Type: application/octet-stream
Size: 4007 bytes
Desc: not available
Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20151228/5fab8c38/attachment.obj 

More information about the flac-dev mailing list