diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/bz/blocksort.c | 21 | ||||
-rw-r--r-- | archival/bz/bzlib_private.h | 19 | ||||
-rw-r--r-- | archival/bz/compress.c | 10 | ||||
-rw-r--r-- | archival/bz/huffman.c | 11 |
4 files changed, 47 insertions, 14 deletions
diff --git a/archival/bz/blocksort.c b/archival/bz/blocksort.c index cddbfcbea..0e73ffeba 100644 --- a/archival/bz/blocksort.c +++ b/archival/bz/blocksort.c | |||
@@ -721,7 +721,8 @@ void mainQSort3(uint32_t* ptr, | |||
721 | #define CLEARMASK (~(SETMASK)) | 721 | #define CLEARMASK (~(SETMASK)) |
722 | 722 | ||
723 | static NOINLINE | 723 | static NOINLINE |
724 | void mainSort(uint32_t* ptr, | 724 | void mainSort(EState* state, |
725 | uint32_t* ptr, | ||
725 | uint8_t* block, | 726 | uint8_t* block, |
726 | uint16_t* quadrant, | 727 | uint16_t* quadrant, |
727 | uint32_t* ftab, | 728 | uint32_t* ftab, |
@@ -729,13 +730,18 @@ void mainSort(uint32_t* ptr, | |||
729 | int32_t* budget) | 730 | int32_t* budget) |
730 | { | 731 | { |
731 | int32_t i, j, k, ss, sb; | 732 | int32_t i, j, k, ss, sb; |
732 | int32_t runningOrder[256]; | ||
733 | Bool bigDone[256]; | ||
734 | int32_t copyStart[256]; | ||
735 | int32_t copyEnd [256]; | ||
736 | uint8_t c1; | 733 | uint8_t c1; |
737 | int32_t numQSorted; | 734 | int32_t numQSorted; |
738 | uint16_t s; | 735 | uint16_t s; |
736 | Bool bigDone[256]; | ||
737 | /* bbox: moved to EState to save stack | ||
738 | int32_t runningOrder[256]; | ||
739 | int32_t copyStart[256]; | ||
740 | int32_t copyEnd [256]; | ||
741 | */ | ||
742 | #define runningOrder (state->mainSort__runningOrder) | ||
743 | #define copyStart (state->mainSort__copyStart) | ||
744 | #define copyEnd (state->mainSort__copyEnd) | ||
739 | 745 | ||
740 | /*-- set up the 2-byte frequency table --*/ | 746 | /*-- set up the 2-byte frequency table --*/ |
741 | /* was: for (i = 65536; i >= 0; i--) ftab[i] = 0; */ | 747 | /* was: for (i = 65536; i >= 0; i--) ftab[i] = 0; */ |
@@ -985,6 +991,9 @@ void mainSort(uint32_t* ptr, | |||
985 | AssertH(((bbSize-1) >> shifts) <= 65535, 1002); | 991 | AssertH(((bbSize-1) >> shifts) <= 65535, 1002); |
986 | } | 992 | } |
987 | } | 993 | } |
994 | #undef runningOrder | ||
995 | #undef copyStart | ||
996 | #undef copyEnd | ||
988 | } | 997 | } |
989 | 998 | ||
990 | #undef BIGFREQ | 999 | #undef BIGFREQ |
@@ -1041,7 +1050,7 @@ void BZ2_blockSort(EState* s) | |||
1041 | */ | 1050 | */ |
1042 | budget = nblock * ((wfact-1) / 3); | 1051 | budget = nblock * ((wfact-1) / 3); |
1043 | 1052 | ||
1044 | mainSort(ptr, block, quadrant, ftab, nblock, &budget); | 1053 | mainSort(s, ptr, block, quadrant, ftab, nblock, &budget); |
1045 | if (budget < 0) { | 1054 | if (budget < 0) { |
1046 | fallbackSort(s->arr1, s->arr2, ftab, nblock); | 1055 | fallbackSort(s->arr1, s->arr2, ftab, nblock); |
1047 | } | 1056 | } |
diff --git a/archival/bz/bzlib_private.h b/archival/bz/bzlib_private.h index 02f177eb2..48676a391 100644 --- a/archival/bz/bzlib_private.h +++ b/archival/bz/bzlib_private.h | |||
@@ -178,13 +178,22 @@ typedef struct EState { | |||
178 | uint8_t selector [BZ_MAX_SELECTORS]; | 178 | uint8_t selector [BZ_MAX_SELECTORS]; |
179 | uint8_t selectorMtf[BZ_MAX_SELECTORS]; | 179 | uint8_t selectorMtf[BZ_MAX_SELECTORS]; |
180 | 180 | ||
181 | uint8_t len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | 181 | uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
182 | int32_t code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | 182 | |
183 | int32_t rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | 183 | /* stack-saving measures: these can be local, but they are too big */ |
184 | int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
185 | int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; | ||
184 | #if CONFIG_BZIP2_FEATURE_SPEED >= 5 | 186 | #if CONFIG_BZIP2_FEATURE_SPEED >= 5 |
185 | /* second dimension: only 3 needed; 4 makes index calculations faster */ | 187 | /* second dimension: only 3 needed; 4 makes index calculations faster */ |
186 | uint32_t len_pack[BZ_MAX_ALPHA_SIZE][4]; | 188 | uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4]; |
187 | #endif | 189 | #endif |
190 | int32_t BZ2_hbMakeCodeLengths__heap [BZ_MAX_ALPHA_SIZE + 2]; | ||
191 | int32_t BZ2_hbMakeCodeLengths__weight[BZ_MAX_ALPHA_SIZE * 2]; | ||
192 | int32_t BZ2_hbMakeCodeLengths__parent[BZ_MAX_ALPHA_SIZE * 2]; | ||
193 | |||
194 | int32_t mainSort__runningOrder[256]; | ||
195 | int32_t mainSort__copyStart[256]; | ||
196 | int32_t mainSort__copyEnd[256]; | ||
188 | } EState; | 197 | } EState; |
189 | 198 | ||
190 | 199 | ||
@@ -203,7 +212,7 @@ static void | |||
203 | BZ2_hbAssignCodes(int32_t*, uint8_t*, int32_t, int32_t, int32_t); | 212 | BZ2_hbAssignCodes(int32_t*, uint8_t*, int32_t, int32_t, int32_t); |
204 | 213 | ||
205 | static void | 214 | static void |
206 | BZ2_hbMakeCodeLengths(uint8_t*, int32_t*, int32_t, int32_t); | 215 | BZ2_hbMakeCodeLengths(EState*, uint8_t*, int32_t*, int32_t, int32_t); |
207 | 216 | ||
208 | /*-------------------------------------------------------------*/ | 217 | /*-------------------------------------------------------------*/ |
209 | /*--- end bzlib_private.h ---*/ | 218 | /*--- end bzlib_private.h ---*/ |
diff --git a/archival/bz/compress.c b/archival/bz/compress.c index b72edbbd4..640b8872b 100644 --- a/archival/bz/compress.c +++ b/archival/bz/compress.c | |||
@@ -264,13 +264,16 @@ void sendMTFValues(EState* s) | |||
264 | * are also globals only used in this proc. | 264 | * are also globals only used in this proc. |
265 | * Made global to keep stack frame size small. | 265 | * Made global to keep stack frame size small. |
266 | */ | 266 | */ |
267 | #define code sendMTFValues__code | ||
268 | #define rfreq sendMTFValues__rfreq | ||
269 | #define len_pack sendMTFValues__len_pack | ||
267 | 270 | ||
268 | uint16_t cost[BZ_N_GROUPS]; | 271 | uint16_t cost[BZ_N_GROUPS]; |
269 | int32_t fave[BZ_N_GROUPS]; | 272 | int32_t fave[BZ_N_GROUPS]; |
270 | 273 | ||
271 | uint16_t* mtfv = s->mtfv; | 274 | uint16_t* mtfv = s->mtfv; |
272 | 275 | ||
273 | alphaSize = s->nInUse+2; | 276 | alphaSize = s->nInUse + 2; |
274 | for (t = 0; t < BZ_N_GROUPS; t++) | 277 | for (t = 0; t < BZ_N_GROUPS; t++) |
275 | for (v = 0; v < alphaSize; v++) | 278 | for (v = 0; v < alphaSize; v++) |
276 | s->len[t][v] = BZ_GREATER_ICOST; | 279 | s->len[t][v] = BZ_GREATER_ICOST; |
@@ -453,7 +456,7 @@ void sendMTFValues(EState* s) | |||
453 | /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See | 456 | /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See |
454 | * comment in huffman.c for details. */ | 457 | * comment in huffman.c for details. */ |
455 | for (t = 0; t < nGroups; t++) | 458 | for (t = 0; t < nGroups; t++) |
456 | BZ2_hbMakeCodeLengths(&(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/); | 459 | BZ2_hbMakeCodeLengths(s, &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/); |
457 | } | 460 | } |
458 | 461 | ||
459 | AssertH(nGroups < 8, 3002); | 462 | AssertH(nGroups < 8, 3002); |
@@ -602,6 +605,9 @@ void sendMTFValues(EState* s) | |||
602 | selCtr++; | 605 | selCtr++; |
603 | } | 606 | } |
604 | AssertH(selCtr == nSelectors, 3007); | 607 | AssertH(selCtr == nSelectors, 3007); |
608 | #undef code | ||
609 | #undef rfreq | ||
610 | #undef len_pack | ||
605 | } | 611 | } |
606 | 612 | ||
607 | 613 | ||
diff --git a/archival/bz/huffman.c b/archival/bz/huffman.c index 02838c496..676b1af66 100644 --- a/archival/bz/huffman.c +++ b/archival/bz/huffman.c | |||
@@ -98,7 +98,8 @@ void DOWNHEAP1(int32_t *heap, int32_t *weight, int32_t nHeap) | |||
98 | 98 | ||
99 | /*---------------------------------------------------*/ | 99 | /*---------------------------------------------------*/ |
100 | static | 100 | static |
101 | void BZ2_hbMakeCodeLengths(uint8_t *len, | 101 | void BZ2_hbMakeCodeLengths(EState *s, |
102 | uint8_t *len, | ||
102 | int32_t *freq, | 103 | int32_t *freq, |
103 | int32_t alphaSize, | 104 | int32_t alphaSize, |
104 | int32_t maxLen) | 105 | int32_t maxLen) |
@@ -110,9 +111,14 @@ void BZ2_hbMakeCodeLengths(uint8_t *len, | |||
110 | int32_t nNodes, nHeap, n1, n2, i, j, k; | 111 | int32_t nNodes, nHeap, n1, n2, i, j, k; |
111 | Bool tooLong; | 112 | Bool tooLong; |
112 | 113 | ||
114 | /* bbox: moved to EState to save stack | ||
113 | int32_t heap [BZ_MAX_ALPHA_SIZE + 2]; | 115 | int32_t heap [BZ_MAX_ALPHA_SIZE + 2]; |
114 | int32_t weight[BZ_MAX_ALPHA_SIZE * 2]; | 116 | int32_t weight[BZ_MAX_ALPHA_SIZE * 2]; |
115 | int32_t parent[BZ_MAX_ALPHA_SIZE * 2]; | 117 | int32_t parent[BZ_MAX_ALPHA_SIZE * 2]; |
118 | */ | ||
119 | #define heap (s->BZ2_hbMakeCodeLengths__heap) | ||
120 | #define weight (s->BZ2_hbMakeCodeLengths__weight) | ||
121 | #define parent (s->BZ2_hbMakeCodeLengths__parent) | ||
116 | 122 | ||
117 | for (i = 0; i < alphaSize; i++) | 123 | for (i = 0; i < alphaSize; i++) |
118 | weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; | 124 | weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; |
@@ -189,6 +195,9 @@ void BZ2_hbMakeCodeLengths(uint8_t *len, | |||
189 | weight[i] = j << 8; | 195 | weight[i] = j << 8; |
190 | } | 196 | } |
191 | } | 197 | } |
198 | #undef heap | ||
199 | #undef weight | ||
200 | #undef parent | ||
192 | } | 201 | } |
193 | 202 | ||
194 | 203 | ||