Deleted Added
sdiff udiff text old ( 90067 ) new ( 146293 )
full compact
1
2/*-------------------------------------------------------------*/
3/*--- Compression machinery (not incl block sorting) ---*/
4/*--- compress.c ---*/
5/*-------------------------------------------------------------*/
6
7/*--
8 This file is a part of bzip2 and/or libbzip2, a program and
9 library for lossless, block-sorting data compression.
10
11 Copyright (C) 1996-2005 Julian R Seward. All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
15 are met:
16
17 1. Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
19

--- 17 unchanged lines hidden (view full) ---

37 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
44 Julian Seward, Cambridge, UK.
45 jseward@bzip.org
46 bzip2/libbzip2 version 1.0 of 21 March 2000
47
48 This program is based on (at least) the work of:
49 Mike Burrows
50 David Wheeler
51 Peter Fenwick
52 Alistair Moffat
53 Radford Neal

--- 429 unchanged lines hidden (view full) ---

483 for (t = 0; t < nGroups; t++)
484 VPrintf1 ( "%d ", fave[t] );
485 VPrintf0 ( "\n" );
486 }
487
488 /*--
489 Recompute the tables based on the accumulated frequencies.
490 --*/
491 /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
492 comment in huffman.c for details. */
493 for (t = 0; t < nGroups; t++)
494 BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
495 alphaSize, 17 /*20*/ );
496 }
497
498
499 AssertH( nGroups < 8, 3002 );
500 AssertH( nSelectors < 32768 &&
501 nSelectors <= (2 + (900000 / BZ_G_SIZE)),
502 3003 );
503

--- 20 unchanged lines hidden (view full) ---

524 /*--- Assign actual codes for the tables. --*/
525 for (t = 0; t < nGroups; t++) {
526 minLen = 32;
527 maxLen = 0;
528 for (i = 0; i < alphaSize; i++) {
529 if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
530 if (s->len[t][i] < minLen) minLen = s->len[t][i];
531 }
532 AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
533 AssertH ( !(minLen < 1), 3005 );
534 BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
535 minLen, maxLen, alphaSize );
536 }
537
538 /*--- Transmit the mapping table. ---*/
539 {
540 Bool inUse16[16];

--- 107 unchanged lines hidden (view full) ---

648 if (s->nblock > 0) {
649
650 BZ_FINALISE_CRC ( s->blockCRC );
651 s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
652 s->combinedCRC ^= s->blockCRC;
653 if (s->blockNo > 1) s->numZ = 0;
654
655 if (s->verbosity >= 2)
656 VPrintf4( " block %d: crc = 0x%08x, "
657 "combined CRC = 0x%08x, size = %d\n",
658 s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
659
660 BZ2_blockSort ( s );
661 }
662
663 s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
664
665 /*-- If this is the first block, create the stream header. --*/

--- 34 unchanged lines hidden (view full) ---

700 /*-- If this is the last block, add the stream trailer. --*/
701 if (is_last_block) {
702
703 bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
704 bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
705 bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
706 bsPutUInt32 ( s, s->combinedCRC );
707 if (s->verbosity >= 2)
708 VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC );
709 bsFinishWrite ( s );
710 }
711}
712
713
714/*-------------------------------------------------------------*/
715/*--- end compress.c ---*/
716/*-------------------------------------------------------------*/