Lines Matching full:bits
49 /* WATCHOUT: there are a few places where the code will not work unless uint32_t is >= 32 bits wide */
64 * read. With FLAC this is on the order of maybe a few hundred bits.
78 /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */
85 unsigned consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */
87 unsigned crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */
145 /* before reading, if the existing reader looks like this (say uint32_t is 32 bits wide)
276 fprintf(out, "bitreader: capacity=%u words=%u bytes=%u consumed: words=%u, bits=%u\n", br->capacity, br->words, br->bytes, br->consumed_words, br->consumed_bits);
340 FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits)
345 FLAC__ASSERT(bits <= 32);
346 FLAC__ASSERT((br->capacity*FLAC__BITS_PER_WORD) * 2 >= bits);
352 if(bits == 0) { /* OPT: investigate if this can ever happen, maybe change to assertion */
357 while((br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits < bits) {
367 if(bits < n) {
368 *val = (word & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (n-bits);
369 br->consumed_bits += bits;
373 bits -= n;
377 if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
378 *val <<= bits;
379 *val |= (br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
380 br->consumed_bits = bits;
386 if(bits < FLAC__BITS_PER_WORD) {
387 *val = word >> (FLAC__BITS_PER_WORD-bits);
388 br->consumed_bits = bits;
391 /* at this point 'bits' must be == FLAC__BITS_PER_WORD; because of previous assertions, it can't be larger */
400 * the reader has guaranteed that we have at least 'bits' bits
406 FLAC__ASSERT(br->consumed_bits + bits <= br->bytes*8);
407 *val = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits);
408 br->consumed_bits += bits;
412 *val = br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits);
413 br->consumed_bits += bits;
419 FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits)
422 if(!FLAC__bitreader_read_raw_uint32(br, (FLAC__uint32*)val, bits))
425 *val <<= (32-bits);
426 *val >>= (32-bits);
430 FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits)
434 if(bits > 32) {
435 if(!FLAC__bitreader_read_raw_uint32(br, &hi, bits-32))
444 if(!FLAC__bitreader_read_raw_uint32(br, &lo, bits))
476 FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
485 if(bits > 0) {
491 m = flac_min(8-n, bits);
494 bits -= m;
496 m = bits / 8;
500 bits %= 8;
502 if(bits > 0) {
503 if(!FLAC__bitreader_read_raw_uint32(br, &x, bits))
717 unsigned ucbits; /* keep track of the number of unconsumed bits in word */
755 b = br->buffer[cwords] << br->consumed_bits; /* keep unconsumed bits aligned to left */
783 /* there are still bits left to read, they will all be in the next word */
839 /* don't leave the head word with no unconsumed bits */