BZ2_rand_update_mask() - Turn BZ_RAND_UPD_MASK into a function

parent 35242daa
......@@ -562,27 +562,27 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
s->state_out_len = 1;
s->state_out_ch = s->k0;
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
BZ_GET_FAST(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 2;
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
BZ_GET_FAST(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 3;
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
BZ_GET_FAST(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
BZ_GET_FAST(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
BZ_GET_FAST(s->k0); BZ2_rand_update_mask(&s->rand);
s->k0 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
}
......@@ -732,27 +732,27 @@ Bool unRLE_obuf_to_output_SMALL ( DState* s )
s->state_out_len = 1;
s->state_out_ch = s->k0;
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
BZ_GET_SMALL(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 2;
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
BZ_GET_SMALL(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
s->state_out_len = 3;
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
BZ_GET_SMALL(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
if (s->nblock_used == s->save_nblock+1) continue;
if (k1 != s->k0) { s->k0 = k1; continue; };
BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
BZ_GET_SMALL(k1); BZ2_rand_update_mask(&s->rand);
k1 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
s->state_out_len = ((Int32)k1) + 4;
BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
BZ_GET_SMALL(s->k0); BZ2_rand_update_mask(&s->rand);
s->k0 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
}
......
......@@ -139,14 +139,7 @@ extern RandState BZ2_rand_init(void);
extern Int32 BZ2_rand_mask(RandState *r);
#define BZ_RAND_UPD_MASK \
if (s->rand.rNToGo == 0) { \
s->rand.rNToGo = BZ2_rNums[s->rand.rTPos]; \
s->rand.rTPos++; \
if (s->rand.rTPos == 512) s->rand.rTPos = 0; \
} \
s->rand.rNToGo--;
extern void BZ2_rand_update_mask(RandState *r);
/*-- Stuff for doing CRCs. --*/
......
......@@ -549,7 +549,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) {
s->rand = BZ2_rand_init();
BZ_GET_SMALL(s->k0); s->nblock_used++;
BZ_RAND_UPD_MASK; s->k0 ^= BZ2_rand_mask(&s->rand);
BZ2_rand_update_mask(&s->rand); s->k0 ^= BZ2_rand_mask(&s->rand);
} else {
BZ_GET_SMALL(s->k0); s->nblock_used++;
}
......@@ -568,7 +568,7 @@ Int32 BZ2_decompress ( DState* s )
if (s->blockRandomised) {
s->rand = BZ2_rand_init();
BZ_GET_FAST(s->k0); s->nblock_used++;
BZ_RAND_UPD_MASK; s->k0 ^= BZ2_rand_mask(&s->rand);
BZ2_rand_update_mask(&s->rand); s->k0 ^= BZ2_rand_mask(&s->rand);
} else {
BZ_GET_FAST(s->k0); s->nblock_used++;
}
......
......@@ -95,6 +95,17 @@ BZ2_rand_mask(RandState *r)
return (r->rNToGo == 1) ? 1 : 0;
}
void
BZ2_rand_update_mask(RandState *r)
{
if (r->rNToGo == 0) {
r->rNToGo = BZ2_rNums[r->rTPos];
r->rTPos++;
if (r->rTPos == 512) r->rTPos = 0;
}
r->rNToGo--;
}
/*-------------------------------------------------------------*/
/*--- end randtable.c ---*/
/*-------------------------------------------------------------*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment