BZ2_rand_mask() - Turn BZ_RAND_MASK into a function

parent 95d3e979
......@@ -563,27 +563,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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
s->k0 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
}
} else {
......@@ -733,27 +733,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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
k1 ^= BZ_RAND_MASK; s->nblock_used++;
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;
s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
s->k0 ^= BZ2_rand_mask(&s->rand); s->nblock_used++;
}
} else {
......
......@@ -137,7 +137,7 @@ typedef struct {
extern RandState BZ2_rand_init(void);
#define BZ_RAND_MASK ((s->rand.rNToGo == 1) ? 1 : 0)
extern Int32 BZ2_rand_mask(RandState *r);
#define BZ_RAND_UPD_MASK \
if (s->rand.rNToGo == 0) { \
......
......@@ -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 ^= BZ_RAND_MASK;
BZ_RAND_UPD_MASK; 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 ^= BZ_RAND_MASK;
BZ_RAND_UPD_MASK; s->k0 ^= BZ2_rand_mask(&s->rand);
} else {
BZ_GET_FAST(s->k0); s->nblock_used++;
}
......
......@@ -89,6 +89,12 @@ BZ2_rand_init(void)
return r;
}
Int32
BZ2_rand_mask(RandState *r)
{
return (r->rNToGo == 1) ? 1 : 0;
}
/*-------------------------------------------------------------*/
/*--- 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