Lines Matching refs:bits
54 /* WATCHOUT: there are a few places where the code will not work unless brword is >= 32 bits wide */
83 * read. With FLAC this is on the order of maybe a few hundred bits.
137 /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */
144 unsigned consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */
146 unsigned crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */
232 /* before reading, if the existing reader looks like this (say brword is 32 bits wide)
371 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);
435 FLaC__INLINE FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits)
440 FLAC__ASSERT(bits <= 32);
441 FLAC__ASSERT((br->capacity*FLAC__BITS_PER_WORD) * 2 >= bits);
447 if(bits == 0) { /* OPT: investigate if this can ever happen, maybe change to assertion */
452 while((br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits < bits) {
462 if(bits < n) {
463 *val = (word & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (n-bits);
464 br->consumed_bits += bits;
468 bits -= n;
472 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 */
473 *val <<= bits;
474 *val |= (br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
475 br->consumed_bits = bits;
481 if(bits < FLAC__BITS_PER_WORD) {
482 *val = word >> (FLAC__BITS_PER_WORD-bits);
483 br->consumed_bits = bits;
486 /* at this point 'bits' must be == FLAC__BITS_PER_WORD; because of previous assertions, it can't be larger */
495 * the reader has guaranteed that we have at least 'bits' bits
501 FLAC__ASSERT(br->consumed_bits + bits <= br->bytes*8);
502 *val = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits);
503 br->consumed_bits += bits;
507 *val = br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits);
508 br->consumed_bits += bits;
514 FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits)
517 if(!FLAC__bitreader_read_raw_uint32(br, (FLAC__uint32*)val, bits))
520 *val <<= (32-bits);
521 *val >>= (32-bits);
525 FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits)
529 if(bits > 32) {
530 if(!FLAC__bitreader_read_raw_uint32(br, &hi, bits-32))
539 if(!FLAC__bitreader_read_raw_uint32(br, &lo, bits))
571 FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
580 if(bits > 0) {
586 m = min(8-n, bits);
589 bits -= m;
591 m = bits / 8;
595 bits %= 8;
597 if(bits > 0) {
598 if(!FLAC__bitreader_read_raw_uint32(br, &x, bits))
813 unsigned bits; /* the # of binary LSBs left to read to finish a rice codeword */
852 bits = parameter;
883 bits = parameter;
910 if(bits) {
911 while((br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits < bits) {
927 if(bits < n) {
928 uval <<= bits;
929 uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-bits);
930 cbits += bits;
935 bits -= n;
939 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 */
940 uval <<= bits;
941 uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits));
942 cbits = bits;
947 FLAC__ASSERT(bits < FLAC__BITS_PER_WORD);
948 uval <<= bits;
949 uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits);
950 cbits = bits;
956 * the reader has guaranteed that we have at least 'bits' bits
959 uval <<= bits;
962 FLAC__ASSERT(cbits + bits <= br->bytes*8);
963 uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-bits);
964 cbits += bits;
968 uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits);
969 cbits += bits;
1001 unsigned ucbits; /* keep track of the number of unconsumed bits in the buffer */
1088 /* + uval to offset our count by the # of unary bits already
1129 if(cbits) { /* parameter > n, i.e. if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
1144 * bits available to read, which makes this case simpler.