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;

Attachment: 3_bitwriter.patch
Description: Binary data

_______________________________________________
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev

Reply via email to