From 24fdc35c90194f66d2077c6a58810406c9fd70a9 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sun, 2 Feb 2020 10:02:53 -0800 Subject: [PATCH] stb_image_write: fix jpeg to work on non-C99 compilers --- stb_image_write.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stb_image_write.h b/stb_image_write.h index 110ab87..aef2a77 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -1289,8 +1289,9 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt // Quantize/descale/zigzag the coefficients for(y = 0, j=0; y < 8; ++y) { for(x = 0; x < 8; ++x,++j) { + float v; i = y*du_stride+x; - float v = CDU[i]*fdtbl[j]; + v = CDU[i]*fdtbl[j]; // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f)); // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway? DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f);