diff --git a/jclossls.c b/jclossls.c index 8459b6e7..e9ba92a7 100644 --- a/jclossls.c +++ b/jclossls.c @@ -256,8 +256,9 @@ METHODDEF(void) simple_downscale(j_compress_ptr cinfo, _JSAMPROW input_buf, _JSAMPROW output_buf, JDIMENSION width) { - while (width--) + do { *output_buf++ = (_JSAMPLE)RIGHT_SHIFT(*input_buf++, cinfo->Al); + } while (--width); } diff --git a/jddiffct.c b/jddiffct.c index 1eb3a9d0..f1d7f61b 100644 --- a/jddiffct.c +++ b/jddiffct.c @@ -196,7 +196,8 @@ decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf) } /* Account for restart interval (no-op if not using restarts) */ - diff->restart_rows_to_go--; + if (cinfo->restart_interval) + diff->restart_rows_to_go--; /* Completed an MCU row, but perhaps not an iMCU row */ diff->MCU_ctr = 0; diff --git a/jdlossls.c b/jdlossls.c index 96790bff..f03164e4 100644 --- a/jdlossls.c +++ b/jdlossls.c @@ -216,16 +216,18 @@ METHODDEF(void) simple_upscale(j_decompress_ptr cinfo, JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width) { - while (width--) + do { *output_buf++ = (_JSAMPLE)(*diff_buf++ << cinfo->Al); + } while (--width); } METHODDEF(void) noscale(j_decompress_ptr cinfo, JDIFFROW diff_buf, _JSAMPROW output_buf, JDIMENSION width) { - while (width--) + do { *output_buf++ = (_JSAMPLE)(*diff_buf++); + } while (--width); }