turbojpeg.h: Parenthesize TJSCALED() dimension arg This ensures that, for example, TJSCALED(dim0 + dim1, sf) will evaluate to (((dim0 + dim1) * sf.num + sf.denom - 1) / sf.denom) rather than ((dim0 + (dim1 * sf.num) + sf.denom - 1) / sf.denom)
diff --git a/turbojpeg.h b/turbojpeg.h index 7610221..7a3d07b 100644 --- a/turbojpeg.h +++ b/turbojpeg.h
@@ -487,7 +487,7 @@ * factor. This macro performs the integer equivalent of <tt>ceil(dimension * * scalingFactor)</tt>. */ -#define TJSCALED(dimension, scalingFactor) ((dimension * scalingFactor.num \ +#define TJSCALED(dimension, scalingFactor) (((dimension) * scalingFactor.num \ + scalingFactor.denom - 1) / scalingFactor.denom)