Bug 78809 - Avoid round-off errors when determining raster dimensions.
Summary: Avoid round-off errors when determining raster dimensions.
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-17 04:43 UTC by James Cloos
Modified: 2018-08-21 10:33 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Avoid round-off errors when determining raster dimensions. (1.98 KB, text/plain)
2014-05-17 04:43 UTC, James Cloos
Details

Description James Cloos 2014-05-17 04:43:36 UTC
Created attachment 99199 [details]
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.
Comment 1 James Cloos 2014-05-17 22:03:57 UTC
I must have been more exhausted than I realized last night.

The repo is fixed, you can pull:

  git://people.freedesktop.org/~cloos/poppler.git roundoff

I also forgot to note that I tested a wide range of page sizes and output resolutions, each of standard inch and metric sizes, and odd sizes in inches, metres and points.  I also tried different optimization levels.

The new calcuation order matched up with exact results for every test I tried.

The existing order got it wrong a small but noticible percentage of the time.

To see the error when using pdftocairo, use -png output.
Comment 2 Albert Astals Cid 2014-07-20 22:20:04 UTC
So this would result in output files with wrong pixel size? Do you have a file that would cause that? Is this in some special architecture?
Comment 3 GitLab Migration User 2018-08-21 10:33:06 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/253.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.