[Poppler-bugs] [Bug 68360] Add option to manually disable bilinear filtering

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Aug 28 17:32:57 PDT 2013


https://bugs.freedesktop.org/show_bug.cgi?id=68360

--- Comment #21 from Charles Hyder <dr.hyder at gmail.com> ---
Reading Splash.cc:

----------

// determine if a scaled image requires interpolation based on the scale and
// the interpolate flag from the image dictionary
static GBool isImageInterpolationRequired(int srcWidth, int srcHeight,
                                          int scaledWidth, int scaledHeight,
                                          GBool interpolate) {
  if (interpolate)
    return gTrue;

  /* When scale factor is >= 400% we don't interpolate. See bugs #25268, #9860
*/
  if (scaledWidth / srcWidth >= 4 || scaledHeight / srcHeight >= 4)
    return gFalse;

  return gTrue;
}

-----------

I had to rearead the commend "When scale factor..." 3 or 4 times: I could not
believe what I was seeing.

https://bugs.freedesktop.org/show_bug.cgi?id=25268 -- here's what happened, in
simple words:

xpdf/early versions of Poppler used nearest neighbor scaling (same as discrete
sampling in the netpbm lingo). This, clearly, produced results much worse than
Adobe's, which uses pixel mixing, as it should. Some folks noticed that Evince
(based on Poppler) produces bad quality results and asked: how come Adobe does
so much better? Someone brought the "interpolate" tag into the discussion, and
as is usually the case when people don't know exactly what they are talking
about, there surfaced a hypothesis: "Adobe must be interpolating those images
despite the fact that the interpolate flag is not set" that is "Adobe is
cheating to get nice looking results". And so the developers introduced
interpolation for all images in Poppler. Soon people came forward who realized
that this downgrades the quality (essentially, the same issue as the one I
raised originally!). And so the compromise has been made: 

"When scale factor is >= 400% we don't interpolate."

Let me say a couple of things:

1) This "rule" is a) ad hoc; b) wrong
2) There's a fundamental misunderstanding: pixel mixing and interpolation are
two different things!

Again from Splash.cc:

    if (!tilingPattern && isImageInterpolationRequired(srcWidth, srcHeight,
scaledWidth, scaledHeight, interpolate)) {
      scaleImageYuXuBilinear(src, srcData, srcMode, nComps, srcAlpha,
                srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
    } else {
      scaleImageYuXu(src, srcData, srcMode, nComps, srcAlpha,
            srcWidth, srcHeight, scaledWidth, scaledHeight, dest);
    }

So, basically, it's either "bilinear" (Adobe with "interpolate" set) or
"nearest neighbor" ("poor" quality xpdf-style; "poor" here refers to the
quality for non-integer scaling factors - this is the issue people were
discussing). What about pixel mixing?? There's a third (Adobe with
"interpolate" not set) way - the pixel mixing way!

Doing some more reading now, hold on...

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler-bugs/attachments/20130829/378de0fa/attachment.html>


More information about the Poppler-bugs mailing list