Work around an issue in Visual C++ 2010 and 2013 that was causing the 256-bit bitmap test in the regression tests to fail. More specifically, when optimization is enabled in these versions of Visual C++, the optimizer seems to get confused by the following code block:

delta = cur0 * 2;
       cur0 += delta;          /* form error * 3 */
       errorptr[0] = (FSERROR) (bpreverr0 + cur0);
       cur0 += delta;          /* form error * 5 */
       bpreverr0 = belowerr0 + cur0;
       cur0 += delta;          /* form error * 7 */

Each time cur0 is incremented by delta, the compiled code doubles the value of delta (WTF?!)  Thus, by the time the end of the block is reached, cur0 is equal to 15 times its former self, not 7 times its former self as it should be.  At any rate, it was a lot simpler to just refactor the code so that it uses multiplication.


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.3.x@1253 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
DRC 2014-04-20 07:22:21 +00:00
Родитель 06fa20d407 beb0b33764
Коммит ac9a92ebbd
2 изменённых файлов: 34 добавлений и 33 удалений

Просмотреть файл

@ -1,3 +1,13 @@
1.3.2
=====
[1] Worked around an issue with Visual C++ 2010 and later that caused incorrect
pixels to be generated when decompressing a JPEG image to a 256-color bitmap,
if compiler optimization was enabled when libjpeg-turbo was built. This caused
the regression tests to fail when doing a release build under Visual C++ 2010
and later.
1.3.1
=====

Просмотреть файл

@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright (C) 2009, D. R. Commander.
* Copyright (C) 2009, 2014, D. R. Commander.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains 2-pass color quantization (color mapping) routines.
@ -1025,32 +1025,23 @@ pass2_fs_dither (j_decompress_ptr cinfo,
* Add these into the running sums, and simultaneously shift the
* next-line error sums left by 1 column.
*/
{ register LOCFSERROR bnexterr, delta;
{ register LOCFSERROR bnexterr;
bnexterr = cur0; /* Process component 0 */
delta = cur0 * 2;
cur0 += delta; /* form error * 3 */
errorptr[0] = (FSERROR) (bpreverr0 + cur0);
cur0 += delta; /* form error * 5 */
bpreverr0 = belowerr0 + cur0;
errorptr[0] = (FSERROR) (bpreverr0 + cur0 * 3);
bpreverr0 = belowerr0 + cur0 * 5;
belowerr0 = bnexterr;
cur0 += delta; /* form error * 7 */
cur0 *= 7;
bnexterr = cur1; /* Process component 1 */
delta = cur1 * 2;
cur1 += delta; /* form error * 3 */
errorptr[1] = (FSERROR) (bpreverr1 + cur1);
cur1 += delta; /* form error * 5 */
bpreverr1 = belowerr1 + cur1;
errorptr[1] = (FSERROR) (bpreverr1 + cur1 * 3);
bpreverr1 = belowerr1 + cur1 * 5;
belowerr1 = bnexterr;
cur1 += delta; /* form error * 7 */
cur1 *= 7;
bnexterr = cur2; /* Process component 2 */
delta = cur2 * 2;
cur2 += delta; /* form error * 3 */
errorptr[2] = (FSERROR) (bpreverr2 + cur2);
cur2 += delta; /* form error * 5 */
bpreverr2 = belowerr2 + cur2;
errorptr[2] = (FSERROR) (bpreverr2 + cur2 * 3);
bpreverr2 = belowerr2 + cur2 * 5;
belowerr2 = bnexterr;
cur2 += delta; /* form error * 7 */
cur2 *= 7;
}
/* At this point curN contains the 7/16 error value to be propagated
* to the next pixel on the current line, and all the errors for the