• Home
  • Raw
  • Download

Lines Matching refs:bd

115 static unsigned int INIT get_bits(struct bunzip_data *bd, char bits_wanted)  in get_bits()  argument
122 while (bd->inbufBitCount < bits_wanted) { in get_bits()
125 if (bd->inbufPos == bd->inbufCount) { in get_bits()
126 if (bd->io_error) in get_bits()
128 bd->inbufCount = bd->fill(bd->inbuf, BZIP2_IOBUF_SIZE); in get_bits()
129 if (bd->inbufCount <= 0) { in get_bits()
130 bd->io_error = RETVAL_UNEXPECTED_INPUT_EOF; in get_bits()
133 bd->inbufPos = 0; in get_bits()
136 if (bd->inbufBitCount >= 24) { in get_bits()
137 bits = bd->inbufBits&((1 << bd->inbufBitCount)-1); in get_bits()
138 bits_wanted -= bd->inbufBitCount; in get_bits()
140 bd->inbufBitCount = 0; in get_bits()
143 bd->inbufBits = (bd->inbufBits << 8)|bd->inbuf[bd->inbufPos++]; in get_bits()
144 bd->inbufBitCount += 8; in get_bits()
147 bd->inbufBitCount -= bits_wanted; in get_bits()
148 bits |= (bd->inbufBits >> bd->inbufBitCount)&((1 << bits_wanted)-1); in get_bits()
155 static int INIT get_next_block(struct bunzip_data *bd) in get_next_block() argument
165 dbuf = bd->dbuf; in get_next_block()
166 dbufSize = bd->dbufSize; in get_next_block()
167 selectors = bd->selectors; in get_next_block()
168 byteCount = bd->byteCount; in get_next_block()
169 symToByte = bd->symToByte; in get_next_block()
170 mtfSymbol = bd->mtfSymbol; in get_next_block()
174 i = get_bits(bd, 24); in get_next_block()
175 j = get_bits(bd, 24); in get_next_block()
176 bd->headerCRC = get_bits(bd, 32); in get_next_block()
184 if (get_bits(bd, 1)) in get_next_block()
186 origPtr = get_bits(bd, 24); in get_next_block()
194 t = get_bits(bd, 16); in get_next_block()
198 k = get_bits(bd, 16); in get_next_block()
205 groupCount = get_bits(bd, 3); in get_next_block()
213 nSelectors = get_bits(bd, 15); in get_next_block()
220 for (j = 0; get_bits(bd, 1); j++) in get_next_block()
245 t = get_bits(bd, 5)-1; in get_next_block()
257 k = get_bits(bd, 2); in get_next_block()
259 bd->inbufBitCount++; in get_next_block()
295 hufGroup = bd->groups+j; in get_next_block()
363 hufGroup = bd->groups+selectors[selector++]; in get_next_block()
379 while (bd->inbufBitCount < hufGroup->maxLen) { in get_next_block()
380 if (bd->inbufPos == bd->inbufCount) { in get_next_block()
381 j = get_bits(bd, hufGroup->maxLen); in get_next_block()
384 bd->inbufBits = in get_next_block()
385 (bd->inbufBits << 8)|bd->inbuf[bd->inbufPos++]; in get_next_block()
386 bd->inbufBitCount += 8; in get_next_block()
388 bd->inbufBitCount -= hufGroup->maxLen; in get_next_block()
389 j = (bd->inbufBits >> bd->inbufBitCount)& in get_next_block()
397 bd->inbufBitCount += (hufGroup->maxLen - i); in get_next_block()
505 bd->writePos = dbuf[origPtr]; in get_next_block()
506 bd->writeCurrent = (unsigned char)(bd->writePos&0xff); in get_next_block()
507 bd->writePos >>= 8; in get_next_block()
508 bd->writeRunCountdown = 5; in get_next_block()
510 bd->writeCount = dbufCount; in get_next_block()
522 static int INIT read_bunzip(struct bunzip_data *bd, char *outbuf, int len) in read_bunzip() argument
528 if (bd->writeCount < 0) in read_bunzip()
529 return bd->writeCount; in read_bunzip()
532 dbuf = bd->dbuf; in read_bunzip()
533 pos = bd->writePos; in read_bunzip()
534 xcurrent = bd->writeCurrent; in read_bunzip()
540 if (bd->writeCopies) { in read_bunzip()
542 --bd->writeCopies; in read_bunzip()
548 bd->writePos = pos; in read_bunzip()
549 bd->writeCurrent = xcurrent; in read_bunzip()
550 bd->writeCopies++; in read_bunzip()
555 bd->writeCRC = (((bd->writeCRC) << 8) in read_bunzip()
556 ^bd->crc32Table[((bd->writeCRC) >> 24) in read_bunzip()
560 if (bd->writeCopies) { in read_bunzip()
561 --bd->writeCopies; in read_bunzip()
565 if (!bd->writeCount--) in read_bunzip()
577 if (--bd->writeRunCountdown) { in read_bunzip()
579 bd->writeRunCountdown = 4; in read_bunzip()
583 bd->writeCopies = xcurrent; in read_bunzip()
585 bd->writeRunCountdown = 5; in read_bunzip()
588 if (!bd->writeCopies) in read_bunzip()
592 --bd->writeCopies; in read_bunzip()
596 bd->writeCRC = ~bd->writeCRC; in read_bunzip()
597 bd->totalCRC = ((bd->totalCRC << 1) | in read_bunzip()
598 (bd->totalCRC >> 31)) ^ bd->writeCRC; in read_bunzip()
600 if (bd->writeCRC != bd->headerCRC) { in read_bunzip()
601 bd->totalCRC = bd->headerCRC+1; in read_bunzip()
609 previous = get_next_block(bd); in read_bunzip()
611 bd->writeCount = previous; in read_bunzip()
614 bd->writeCRC = 0xffffffffUL; in read_bunzip()
615 pos = bd->writePos; in read_bunzip()
616 xcurrent = bd->writeCurrent; in read_bunzip()
631 struct bunzip_data *bd; in start_bunzip() local
641 bd = *bdp = malloc(i); in start_bunzip()
642 if (!bd) in start_bunzip()
644 memset(bd, 0, sizeof(struct bunzip_data)); in start_bunzip()
646 bd->inbuf = inbuf; in start_bunzip()
647 bd->inbufCount = len; in start_bunzip()
649 bd->fill = fill; in start_bunzip()
651 bd->fill = nofill; in start_bunzip()
658 bd->crc32Table[i] = c; in start_bunzip()
662 i = get_bits(bd, 32); in start_bunzip()
668 bd->dbufSize = 100000*(i-BZh0); in start_bunzip()
670 bd->dbuf = large_malloc(bd->dbufSize * sizeof(int)); in start_bunzip()
671 if (!bd->dbuf) in start_bunzip()
685 struct bunzip_data *bd; in bunzip2() local
705 i = start_bunzip(&bd, inbuf, len, fill); in bunzip2()
708 i = read_bunzip(bd, outbuf, BZIP2_IOBUF_SIZE); in bunzip2()
722 if (bd->headerCRC != bd->totalCRC) in bunzip2()
729 if (!bd) in bunzip2()
731 if (bd->dbuf) in bunzip2()
732 large_free(bd->dbuf); in bunzip2()
734 *pos = bd->inbufPos; in bunzip2()
735 free(bd); in bunzip2()