Avoid round-off errors when determining raster dimensions.
@cloos
Submitted by James Cloos Assigned to poppler-bugs
Description
Created attachment 99199 Avoid round-off errors when determining raster dimensions.
The code in pdftoppm.cc and pdftocairo.cc carefully avoided overflow when converting page sizes from points to pixels.
This worked well when the math was performed at extended precision, as is done when using x387 opcodes, but could lead to results too large by a ulp when computed without extra precision.
The code then needs to call ceil(3) to round fractional results up to the next larger integer, resulting in an off-by-one error if the computed size is even one ulp more than an integer.
The initial size is already a multiple of 72, so rearranging the math to multiply before dividing by 72 avoids that imprecision.
Please consider pulling the signed tag at:
git://people.freedesktop.org/~cloos/poppler.git refs/tags/roundoff
utils/pdftocairo.cc | 4 ++-- utils/pdftoppm.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
I’ve also attached the formatted patch for review.
Attachment 99199, "Avoid round-off errors when determining raster dimensions.":
0001-Avoid-round-off-errors-when-determining-raster-dimen.patch