--- jdhuff.c +++ jdhuff.c @@ -489,7 +489,7 @@ #define AVOID_TABLES #ifdef AVOID_TABLES -#define HUFF_EXTEND(x,s) ((x) + ((((x) - (1<<((s)-1))) >> 31) & (((-1)<<(s)) + 1))) +#define HUFF_EXTEND(x,s) ((x) + ((((x) - (1<<((s)-1))) >> 31) & (((unsigned)-1<<(s)) + 1))) #else --- jdphuff.c +++ jdphuff.c @@ -201,7 +201,7 @@ #define AVOID_TABLES #ifdef AVOID_TABLES -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) +#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((unsigned)-1<<(s)) + 1) : (x)) #else @@ -334,7 +334,7 @@ s += state.last_dc_val[ci]; state.last_dc_val[ci] = s; /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ - (*block)[0] = (JCOEF) (s << Al); + (*block)[0] = (JCOEF) ((unsigned)s << Al); } /* Completed MCU, so update state */ @@ -402,7 +402,7 @@ r = GET_BITS(s); s = HUFF_EXTEND(r, s); /* Scale and output coefficient in natural (dezigzagged) order */ - (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); + (*block)[jpeg_natural_order[k]] = (JCOEF) ((unsigned)s << Al); } else { if (r == 15) { /* ZRL */ k += 15; /* skip 15 zeroes in band */ @@ -494,7 +494,7 @@ phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; int Se = cinfo->Se; int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ + int m1 = (unsigned)-1 << cinfo->Al; /* -1 in the bit position being coded */ register int s, k, r; unsigned int EOBRUN; JBLOCKROW block;