{
FLAC__blurb *new_buffer;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
if(bb->capacity == new_capacity)
return true;
bb->consumed_bits = 0;
bb->total_consumed_bits = FLAC__BLURBS_TO_BITS(new_capacity);
}
- free(bb->buffer); // we've already asserted above that (bb->buffer != 0)
+ free(bb->buffer); /* we've already asserted above that (0 != bb->buffer) */
bb->buffer = new_buffer;
bb->capacity = new_capacity;
return true;
static FLAC__bool bitbuffer_ensure_size_(FLAC__BitBuffer *bb, unsigned bits_to_add)
{
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
if(FLAC__BLURBS_TO_BITS(bb->capacity) < bb->total_bits + bits_to_add)
return bitbuffer_grow_(bb, (bits_to_add >> FLAC__BITS_PER_BLURB_LOG2) + 2);
FLAC__BitBuffer *FLAC__bitbuffer_new()
{
- return (FLAC__BitBuffer*)malloc(sizeof(FLAC__BitBuffer));
+ FLAC__BitBuffer *bb = (FLAC__BitBuffer*)malloc(sizeof(FLAC__BitBuffer));
+
+ if(0 != bb) {
+ memset(bb, 0, sizeof(FLAC__BitBuffer));
+ bb->buffer = 0;
+ bb->capacity = 0;
+ bb->blurbs = bb->bits = bb->total_bits = 0;
+ bb->consumed_blurbs = bb->consumed_bits = bb->total_consumed_bits = 0;
+ }
+ return bb;
}
void FLAC__bitbuffer_delete(FLAC__BitBuffer *bb)
{
- FLAC__ASSERT(bb != 0);
+ FLAC__ASSERT(0 != bb);
FLAC__bitbuffer_free(bb);
free(bb);
FLAC__bool FLAC__bitbuffer_init(FLAC__BitBuffer *bb)
{
- FLAC__ASSERT(bb != 0);
+ FLAC__ASSERT(0 != bb);
bb->buffer = 0;
bb->capacity = 0;
FLAC__bool FLAC__bitbuffer_init_from(FLAC__BitBuffer *bb, const FLAC__byte buffer[], unsigned bytes)
{
- FLAC__ASSERT(bb != 0);
+ FLAC__ASSERT(0 != bb);
FLAC__ASSERT(bytes > 0);
if(!FLAC__bitbuffer_init(bb))
if(!bitbuffer_ensure_size_(bb, bytes << 3))
return false;
- FLAC__ASSERT(buffer != 0);
+ FLAC__ASSERT(0 != buffer);
/* @@@ WATCHOUT: code currently only works for 8-bits-per-blurb inclusive-or big-endian: */
memcpy((FLAC__byte*)bb->buffer, buffer, sizeof(FLAC__byte)*bytes);
bb->blurbs = bytes / FLAC__BYTES_PER_BLURB;
{
unsigned bits_to_add = src->total_bits - src->total_consumed_bits;
- FLAC__ASSERT(dest != 0);
- FLAC__ASSERT(src != 0);
+ FLAC__ASSERT(0 != dest);
+ FLAC__ASSERT(0 != src);
if(bits_to_add == 0)
return true;
void FLAC__bitbuffer_free(FLAC__BitBuffer *bb)
{
- FLAC__ASSERT(bb != 0);
+ FLAC__ASSERT(0 != bb);
- if(bb->buffer != 0)
+ if(0 != bb->buffer)
free(bb->buffer);
bb->buffer = 0;
bb->capacity = 0;
FLAC__bool FLAC__bitbuffer_clone(FLAC__BitBuffer *dest, const FLAC__BitBuffer *src)
{
- FLAC__ASSERT(dest != 0);
- FLAC__ASSERT(dest->buffer != 0);
- FLAC__ASSERT(src != 0);
- FLAC__ASSERT(src->buffer != 0);
+ FLAC__ASSERT(0 != dest);
+ FLAC__ASSERT(0 != dest->buffer);
+ FLAC__ASSERT(0 != src);
+ FLAC__ASSERT(0 != src->buffer);
if(dest->capacity < src->capacity)
if(!bitbuffer_resize_(dest, src->capacity))
void FLAC__bitbuffer_reset_read_crc16(FLAC__BitBuffer *bb, FLAC__uint16 seed)
{
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT((bb->consumed_bits & 7) == 0);
bb->read_crc16 = seed;
FLAC__uint16 FLAC__bitbuffer_get_read_crc16(FLAC__BitBuffer *bb)
{
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT((bb->bits & 7) == 0);
FLAC__ASSERT((bb->consumed_bits & 7) == 0);
FLAC__byte FLAC__bitbuffer_get_write_crc8(const FLAC__BitBuffer *bb)
{
FLAC__ASSERT(0 != bb);
- //@@@ WHY WAS THIS HERE? FLAC__ASSERT(bb->blurbs == 0);
- FLAC__ASSERT(bb->buffer[0] == 0xff); /* MAGIC NUMBER for the first byte of the sync code */
FLAC__ASSERT((bb->bits & 7) == 0); /* assert that we're byte-aligned */
+ FLAC__ASSERT(bb->buffer[0] == 0xff); /* MAGIC NUMBER for the first byte of the sync code */
#if FLAC__BITS_PER_BLURB == 8
return FLAC__crc8(bb->buffer, bb->blurbs);
#elif FLAC__BITS_PER_BLURB == 32
{
unsigned n;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
if(bits == 0)
return true;
{
unsigned n, k;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 32);
if(bits == 0)
};
unsigned n, k;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 64);
if(bits == 0)
unsigned total_bits, interesting_bits, msbs;
FLAC__uint32 pattern;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 31);
/* init pattern with the unary end bit and the sign bit */
unsigned total_bits, interesting_bits, msbs;
FLAC__uint32 pattern;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 31);
*overflow = false;
unsigned total_bits, val_bits;
FLAC__uint32 pattern;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 31);
val_bits = FLAC__bitmath_silog2(val);
unsigned total_bits, interesting_bits, msbs, uval;
FLAC__uint32 pattern;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 30);
/* fold signed to unsigned */
unsigned total_bits, interesting_bits, msbs, uval;
FLAC__uint32 pattern;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 30);
*overflow = false;
unsigned total_bits, msbs, uval;
unsigned k;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter > 0);
/* fold signed to unsigned */
unsigned total_bits, msbs;
unsigned k;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter > 0);
k = FLAC__bitmath_ilog2(parameter);
{
FLAC__bool ok = 1;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(!(val & 0x80000000)); /* this version only handles 31 bits */
{
FLAC__bool ok = 1;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(!(val & 0xFFFFFFF000000000)); /* this version only handles 36 bits */
FLAC__bool FLAC__bitbuffer_peek_bit(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data)
{
/* to avoid a drastic speed penalty we don't:
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bb->bits == 0);
*/
FLAC__bool FLAC__bitbuffer_read_bit(FLAC__BitBuffer *bb, unsigned *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data)
{
/* to avoid a drastic speed penalty we don't:
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bb->bits == 0);
*/
FLAC__bool FLAC__bitbuffer_read_bit_to_uint32(FLAC__BitBuffer *bb, FLAC__uint32 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data)
{
/* to avoid a drastic speed penalty we don't:
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bb->bits == 0);
*/
FLAC__bool FLAC__bitbuffer_read_bit_to_uint64(FLAC__BitBuffer *bb, FLAC__uint64 *val, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data)
{
/* to avoid a drastic speed penalty we don't:
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bb->bits == 0);
*/
{
unsigned i;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 32);
unsigned i, bits_ = bits;
FLAC__uint32 v = 0;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 32);
FLAC__ASSERT((bb->capacity*FLAC__BITS_PER_BLURB) * 2 >= bits);
return false;
}
#if FLAC__BITS_PER_BLURB > 8
- if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { //@@@ comment on why this is here
+ if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { /*@@@ comment on why this is here*/
#endif
if(bb->consumed_bits) {
i = FLAC__BITS_PER_BLURB - bb->consumed_bits;
unsigned i;
FLAC__uint32 v;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 32);
unsigned i, bits_ = bits;
FLAC__uint32 v = 0;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 32);
FLAC__ASSERT((bb->capacity*FLAC__BITS_PER_BLURB) * 2 >= bits);
return false;
}
#if FLAC__BITS_PER_BLURB > 8
- if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { //@@@ comment on why this is here
+ if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { /*@@@ comment on why this is here*/
#endif
if(bb->consumed_bits) {
i = FLAC__BITS_PER_BLURB - bb->consumed_bits;
{
unsigned i;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 64);
unsigned i, bits_ = bits;
FLAC__uint64 v = 0;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 64);
FLAC__ASSERT((bb->capacity*FLAC__BITS_PER_BLURB) * 2 >= bits);
return false;
}
#if FLAC__BITS_PER_BLURB > 8
- if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { //@@@ comment on why this is here
+ if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { /*@@@ comment on why this is here*/
#endif
if(bb->consumed_bits) {
i = FLAC__BITS_PER_BLURB - bb->consumed_bits;
unsigned i;
FLAC__uint64 v;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 64);
unsigned i, bits_ = bits;
FLAC__uint64 v = 0;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(bits <= 64);
FLAC__ASSERT((bb->capacity*FLAC__BITS_PER_BLURB) * 2 >= bits);
return false;
}
#if FLAC__BITS_PER_BLURB > 8
- if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { //@@@ comment on why this is here
+ if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { /*@@@ comment on why this is here*/
#endif
if(bb->consumed_bits) {
i = FLAC__BITS_PER_BLURB - bb->consumed_bits;
FLAC__bool FLAC__bitbuffer_read_byte_block_aligned(FLAC__BitBuffer *bb, FLAC__byte *val, unsigned nvals, FLAC__bool (*read_callback)(FLAC__byte buffer[], unsigned *bytes, void *client_data), void *client_data)
{
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(FLAC__bitbuffer_is_byte_aligned(bb));
FLAC__ASSERT(FLAC__bitbuffer_is_consumed_byte_aligned(bb));
#if FLAC__BITS_PER_BLURB == 8
{
unsigned bit, val_ = 0;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
while(1) {
if(!FLAC__bitbuffer_read_bit(bb, &bit, read_callback, client_data))
unsigned total_blurbs_ = (bb->total_bits + (FLAC__BITS_PER_BLURB-1)) / FLAC__BITS_PER_BLURB;
FLAC__blurb b;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
#if FLAC__BITS_PER_BLURB > 8
- if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { //@@@ comment on why this is here
+ if(bb->bits == 0 || bb->consumed_blurbs < bb->blurbs) { /*@@@ comment on why this is here*/
#endif
if(bb->consumed_bits) {
b = bb->buffer[bb->consumed_blurbs] << bb->consumed_bits;
{
FLAC__uint32 sign = 0, lsbs = 0, msbs = 0;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 31);
/* read the unary MSBs and end bit */
FLAC__uint32 lsbs = 0, msbs = 0;
unsigned uval;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 31);
/* read the unary MSBs and end bit */
FLAC__blurb blurb, save_blurb;
unsigned state = 0; /* 0 = getting unary MSBs, 1 = getting binary LSBs */
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
FLAC__ASSERT(parameter <= 31);
if(nvals == 0)
FLAC__uint32 lsbs = 0, msbs = 0;
unsigned bit, uval, k;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
k = FLAC__bitmath_ilog2(parameter);
FLAC__uint32 lsbs, msbs = 0;
unsigned bit, k;
- FLAC__ASSERT(bb != 0);
- FLAC__ASSERT(bb->buffer != 0);
+ FLAC__ASSERT(0 != bb);
+ FLAC__ASSERT(0 != bb->buffer);
k = FLAC__bitmath_ilog2(parameter);
}
else {
fprintf(out, "bitbuffer: capacity=%u blurbs=%u bits=%u total_bits=%u consumed: blurbs=%u, bits=%u, total_bits=%u\n", bb->capacity, bb->blurbs, bb->bits, bb->total_bits, bb->consumed_blurbs, bb->consumed_bits, bb->total_consumed_bits);
-return;//@@@
+return;/*@@@*/
for(i = 0; i < bb->blurbs; i++) {
fprintf(out, "%08X: ", i);
for(j = 0; j < FLAC__BITS_PER_BLURB; j++)