summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fitz/filt_predict.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fitz/filt_predict.c b/fitz/filt_predict.c
index 5fbd7d1d..ebd712fd 100644
--- a/fitz/filt_predict.c
+++ b/fitz/filt_predict.c
@@ -63,9 +63,11 @@ fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int le
{
int left[MAXC];
int i, k;
+ const int mask = (1 << state->bpc)-1;
for (k = 0; k < state->colors; k++)
left[k] = 0;
+ memset(out, 0, state->stride);
for (i = 0; i < state->columns; i++)
{
@@ -73,7 +75,7 @@ fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int le
{
int a = getcomponent(in, i * state->colors + k, state->bpc);
int b = a + left[k];
- int c = b % (1 << state->bpc);
+ int c = b & mask;
putcomponent(out, i * state->colors + k, state->bpc, c);
left[k] = c;
}