aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive/bz/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/libarchive/bz/compress.c')
-rw-r--r--archival/libarchive/bz/compress.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c
index 271982cf2..4d0f77592 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -88,6 +88,22 @@ void bsW16(EState* s, uint32_t v)
88 s->bsBuff |= (v << (16 - s->bsLive)); 88 s->bsBuff |= (v << (16 - s->bsLive));
89 s->bsLive += 16; 89 s->bsLive += 16;
90} 90}
91/* Same with n == 1: */
92static
93#if CONFIG_BZIP2_FAST >= 5
94ALWAYS_INLINE
95#endif
96void bsW1(EState* s, uint32_t v)
97{
98 /* need space for only 1 bit, no need for loop freeing > 8 bits */
99 if (s->bsLive >= 8) {
100 *s->posZ++ = (uint8_t)(s->bsBuff >> 24);
101 s->bsBuff <<= 8;
102 s->bsLive -= 8;
103 }
104 s->bsBuff |= (v << (31 - s->bsLive));
105 s->bsLive += 1;
106}
91 107
92 108
93/*---------------------------------------------------*/ 109/*---------------------------------------------------*/
@@ -557,8 +573,8 @@ void sendMTFValues(EState* s)
557 for (i = 0; i < nSelectors; i++) { 573 for (i = 0; i < nSelectors; i++) {
558 unsigned j; 574 unsigned j;
559 for (j = 0; j < s->selectorMtf[i]; j++) 575 for (j = 0; j < s->selectorMtf[i]; j++)
560 bsW(s, 1, 1); 576 bsW1(s, 1);
561 bsW(s, 1, 0); 577 bsW1(s, 0);
562 } 578 }
563 579
564 /*--- Now the coding tables. ---*/ 580 /*--- Now the coding tables. ---*/
@@ -568,7 +584,7 @@ void sendMTFValues(EState* s)
568 for (i = 0; i < alphaSize; i++) { 584 for (i = 0; i < alphaSize; i++) {
569 while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ }; 585 while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ };
570 while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ }; 586 while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ };
571 bsW(s, 1, 0); 587 bsW1(s, 0);
572 } 588 }
573 } 589 }
574 590
@@ -682,7 +698,7 @@ void BZ2_compressBlock(EState* s, int is_last_block)
682 * so as to maintain backwards compatibility with 698 * so as to maintain backwards compatibility with
683 * older versions of bzip2. 699 * older versions of bzip2.
684 */ 700 */
685 bsW(s, 1, 0); 701 bsW1(s, 0);
686 702
687 bsW(s, 24, s->origPtr); 703 bsW(s, 24, s->origPtr);
688 generateMTFValues(s); 704 generateMTFValues(s);