diff --git a/png.c b/png.c index 4dadc6d84..cece39f82 100644 --- a/png.c +++ b/png.c @@ -1342,7 +1342,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size, } /* Here on buffer too small. */ - png_error(png_ptr, "ASCII convertion buffer too small"); + png_error(png_ptr, "ASCII conversion buffer too small"); } # endif /* FLOATING_POINT */ @@ -1401,9 +1401,21 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, #else int negative = 0; png_uint_32 A, T, D; - if (a < 0) negative = 1, A = -a; else A = a; - if (times < 0) negative = !negative, T = -times; else T = times; - if (div < 0) negative = !negative, D = -div; else D = div; + + if (a < 0) + negative = 1, A = -a; + else + A = a; + + if (times < 0) + negative = !negative, T = -times; + else + T = times; + + if (div < 0) + negative = !negative, D = -div; + else + D = div; /* Following can't overflow because the arguments only * have 31 bits each, however the result may be 32 bits. @@ -1432,6 +1444,7 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, while (--bitshift >= 0) { png_uint_32 d32, d00; + if (bitshift > 0) d32 = D >> (32-bitshift), d00 = D << bitshift; else @@ -1442,8 +1455,9 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, if (s00 < d00) --s32; /* carry */ s32 -= d32, s00 -= d00, result += 1<= d00) - s32 = 0, s00 -= d00, result += 1<= d00) + s32 = 0, s00 -= d00, result += 1<>16); } @@ -1710,11 +1732,20 @@ png_log16bit(png_uint_32 x) unsigned log = 0; /* As above, but now the input has 16 bits. */ - if ((x &= 0xffff) == 0) return 0xffffffff; - if ((x & 0xff00) == 0) log = 8, x <<= 8; - if ((x & 0xf000) == 0) log += 4, x <<= 4; - if ((x & 0xc000) == 0) log += 2, x <<= 2; - if ((x & 0x8000) == 0) log += 1, x <<= 1; + if ((x &= 0xffff) == 0) + return 0xffffffff; + + if ((x & 0xff00) == 0) + log = 8, x <<= 8; + + if ((x & 0xf000) == 0) + log += 4, x <<= 4; + + if ((x & 0xc000) == 0) + log += 2, x <<= 2; + + if ((x & 0x8000) == 0) + log += 1, x <<= 1; /* Calculate the base logarithm from the top 8 bits as a 28 bit fractional * value. @@ -1800,12 +1831,23 @@ png_exp(png_uint_32 x) * converge on 45426 and this is used to allow linear interpolation of the * low bits. */ - if (x & 0x800) e -= (((e >> 16) * 44938U) + 16U) >> 5; - if (x & 0x400) e -= (((e >> 16) * 45181U) + 32U) >> 6; - if (x & 0x200) e -= (((e >> 16) * 45303U) + 64U) >> 7; - if (x & 0x100) e -= (((e >> 16) * 45365U) + 128U) >> 8; - if (x & 0x080) e -= (((e >> 16) * 45395U) + 256U) >> 9; - if (x & 0x040) e -= (((e >> 16) * 45410U) + 512U) >> 10; + if (x & 0x800) + e -= (((e >> 16) * 44938U) + 16U) >> 5; + + if (x & 0x400) + e -= (((e >> 16) * 45181U) + 32U) >> 6; + + if (x & 0x200) + e -= (((e >> 16) * 45303U) + 64U) >> 7; + + if (x & 0x100) + e -= (((e >> 16) * 45365U) + 128U) >> 8; + + if (x & 0x080) + e -= (((e >> 16) * 45395U) + 256U) >> 9; + + if (x & 0x040) + e -= (((e >> 16) * 45410U) + 512U) >> 10; /* And handle the low 6 bits in a single block. */ e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9; diff --git a/pngget.c b/pngget.c index 25cd87319..9634f807f 100644 --- a/pngget.c +++ b/pngget.c @@ -295,7 +295,7 @@ static png_uint_32 ppi_from_ppm(png_uint_32 ppm) { #if 0 - /* The convertion is *(2.54/100), in binary (32 digits): + /* The conversion is *(2.54/100), in binary (32 digits): * .00000110100000001001110101001001 */ png_uint_32 t1001, t1101; diff --git a/pngpriv.h b/pngpriv.h index b2ebf0d53..3c40cabda 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -116,11 +116,11 @@ */ #if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) - /* pngarith.c requires the following ANSI-C constants if the convertion of + /* png.c requires the following ANSI-C constants if the conversion of * floating point to ASCII is implemented therein: * * DBL_DIG Maximum number of decimal digits (can be set to any constant) - * DBL_MIN Smalles normalized fp number (can be set to an arbitrary value) + * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) * DBL_MAX Maximum floating point number (can be set to an arbitrary value) */ # include @@ -366,7 +366,7 @@ * when it is supposedly disabled.) */ #ifdef PNG_FLOATING_POINT_SUPPORTED -/* The floating point convertion can't overflow, though it can and +/* The floating point conversion can't overflow, though it can and * does lose accuracy relative to the original fixed point value. * In practice this doesn't matter because png_fixed_point only * stores numbers with very low precision. The png_ptr and s @@ -375,7 +375,7 @@ */ #define png_float(png_ptr, fixed, s) (.00001 * (fixed)) -/* The fixed point convertion performs range checking and evaluates +/* The fixed point conversion performs range checking and evaluates * its argument multiple times, so must be used with care. The * range checking uses the PNG specification values for a signed * 32 bit fixed point value except that the values are deliberately diff --git a/pngrutil.c b/pngrutil.c index 880da9a94..c25813f60 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -71,7 +71,7 @@ png_get_uint_32)(png_bytep buf) /* Grab a signed 32-bit integer from a buffer in big-endian format. The * data is stored in the PNG file in two's complement format and there * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore - * the following code does a two's complement to native convertion. + * the following code does a two's complement to native conversion. */ png_int_32 (PNGAPI png_get_int_32)(png_bytep buf) diff --git a/pngvalid.c b/pngvalid.c index 43358cb3f..a3a13b9a5 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -1876,7 +1876,7 @@ static void perform_gamma_strip16_tests(png_modifier *pm, int speed) * used by the library - otherwise we will get spurious errors from the * internal sbit style approximation. * - * The threshold test is here because otherwise the 16 to 8 convertion will + * The threshold test is here because otherwise the 16 to 8 conversion will * proceed *without* gamma correction, and the tests above will fail (but not * by much) - this could be fixed, it only appears with the -g option. */