diff --git a/libImaging/Jpeg2KDecode.c b/libImaging/Jpeg2KDecode.c index d68f23165..dd20dc738 100644 --- a/libImaging/Jpeg2KDecode.c +++ b/libImaging/Jpeg2KDecode.c @@ -230,7 +230,7 @@ j2ku_graya_la(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, const UINT8 *adata = &atiledata[acsiz * y * w]; UINT8 *row = (UINT8 *)im->image[y0 + y] + x0 * 4; for (x = 0; x < w; ++x) { - UINT32 word, aword; + UINT32 word = 0, aword = 0; switch (csiz) { case 1: word = *data++; break; @@ -288,7 +288,7 @@ j2ku_srgb_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, for (x = 0; x < w; ++x) { for (n = 0; n < 3; ++n) { - UINT32 word; + UINT32 word = 0; switch (csiz[n]) { case 1: word = *data[n]++; break; @@ -341,7 +341,7 @@ j2ku_sycc_rgb(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, for (x = 0; x < w; ++x) { for (n = 0; n < 3; ++n) { - UINT32 word; + UINT32 word = 0; switch (csiz[n]) { case 1: word = *data[n]++; break; @@ -395,7 +395,7 @@ j2ku_srgba_rgba(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, for (x = 0; x < w; ++x) { for (n = 0; n < 4; ++n) { - UINT32 word; + UINT32 word = 0; switch (csiz[n]) { case 1: word = *data[n]++; break; @@ -447,7 +447,7 @@ j2ku_sycca_rgba(opj_image_t *in, const JPEG2KTILEINFO *tileinfo, for (x = 0; x < w; ++x) { for (n = 0; n < 4; ++n) { - UINT32 word; + UINT32 word = 0; switch (csiz[n]) { case 1: word = *data[n]++; break; diff --git a/libImaging/Jpeg2KEncode.c b/libImaging/Jpeg2KEncode.c index d013ffa7f..2fcc8e586 100644 --- a/libImaging/Jpeg2KEncode.c +++ b/libImaging/Jpeg2KEncode.c @@ -80,9 +80,10 @@ j2k_pack_l(Imaging im, UINT8 *buf, unsigned x0, unsigned y0, unsigned w, unsigned h) { UINT8 *ptr = buf; - for (unsigned y = 0; y < h; ++y) { + unsigned x,y; + for (y = 0; y < h; ++y) { UINT8 *data = (UINT8 *)(im->image[y + y0] + x0); - for (unsigned x = 0; x < w; ++x) + for (x = 0; x < w; ++x) *ptr++ = *data++; } } @@ -93,9 +94,10 @@ j2k_pack_la(Imaging im, UINT8 *buf, { UINT8 *ptr = buf; UINT8 *ptra = buf + w * h; - for (unsigned y = 0; y < h; ++y) { + unsigned x,y; + for (y = 0; y < h; ++y) { UINT8 *data = (UINT8 *)(im->image[y + y0] + 4 * x0); - for (unsigned x = 0; x < w; ++x) { + for (x = 0; x < w; ++x) { *ptr++ = data[0]; *ptra++ = data[3]; data += 4; @@ -110,9 +112,10 @@ j2k_pack_rgb(Imaging im, UINT8 *buf, UINT8 *pr = buf; UINT8 *pg = pr + w * h; UINT8 *pb = pg + w * h; - for (unsigned y = 0; y < h; ++y) { + unsigned x,y; + for (y = 0; y < h; ++y) { UINT8 *data = (UINT8 *)(im->image[y + y0] + 4 * x0); - for (unsigned x = 0; x < w; ++x) { + for (x = 0; x < w; ++x) { *pr++ = data[0]; *pg++ = data[1]; *pb++ = data[2]; @@ -129,9 +132,10 @@ j2k_pack_rgba(Imaging im, UINT8 *buf, UINT8 *pg = pr + w * h; UINT8 *pb = pg + w * h; UINT8 *pa = pb + w * h; - for (unsigned y = 0; y < h; ++y) { + unsigned x,y; + for (y = 0; y < h; ++y) { UINT8 *data = (UINT8 *)(im->image[y + y0] + 4 * x0); - for (unsigned x = 0; x < w; ++x) { + for (x = 0; x < w; ++x) { *pr++ = *data++; *pg++ = *data++; *pb++ = *data++; @@ -239,6 +243,7 @@ j2k_encode_entry(Imaging im, ImagingCodecState state, unsigned tile_width, tile_height; unsigned tiles_x, tiles_y, num_tiles; unsigned x, y, tile_ndx; + unsigned n; j2k_pack_tile_t pack; int ret = -1; @@ -283,7 +288,7 @@ j2k_encode_entry(Imaging im, ImagingCodecState state, goto quick_exit; } - for (unsigned n = 0; n < components; ++n) { + for (n = 0; n < components; ++n) { image_params[n].dx = image_params[n].dy = 1; image_params[n].w = im->xsize; image_params[n].h = im->ysize;