Skip to content

Our JPEG differs from poppler by more than the ISO IDCT allowance on two thirds of compared pictures #40

Description

@tannevaled

Found by the per-channel measure landed in go-pdfkit/conformance#19, over 23 populations and 3280 documents. Recorded, not diagnosed — this issue is the observation, not a theory about it.

The observation

Replacing the old binarised comparison with a per-channel one, with a magnitude gate of 2 levels, moved the two lossy filters in opposite directions:

  • JPXDecode: 15.4% → 99.2% agreement, with 7 of 1225 pictures bit-identical. That is what a conformant lossy decoder looks like — the old figure was an artefact of the bisection.
  • DCTDecode: 33.2% → 34.0%. It did not move.

So on roughly two thirds of the JPEG pictures compared, we differ from poppler by 16 to 62 levels, where ISO/IEC 10918-2 allows a conformant IDCT at most one level per sample either side of the reference (the bound is enforced in FFmpeg's own conformance test, libavcodec/tests/dct.c:259).

The gate is 2, derived from that standard rather than borrowed. A difference of 16 levels is eight times it; 62 is thirty-one times.

Why this deserves investigation rather than a tolerance

The obvious response — widen the tolerance until DCT agrees — is the one to refuse. JPX now sits at 99.2% under the same gate, so the gate is not too tight in general; it is a JPEG-specific disagreement. And the previous measure hid this for as long as it existed: a binarisation at luma 128 cannot see a systematic level shift, which is exactly the shape of an IDCT or colour-conversion error.

What would identify it

Candidates worth separating before assuming any of them:

  • Colour conversion. Is the disagreement concentrated in YCbCr→RGB, or does it appear in greyscale JPEGs too? The measure now buckets by colour space, so this is answerable from the landed records rather than by guessing.
  • The IDCT itself — a rounding or scaling difference would show as a small, uniform, signed offset. The measure carries a signed mean precisely for this; read it.
  • Chroma upsampling, which would concentrate the error at edges rather than spreading it.
  • Which side is wrong. poppler is a judge, not an oracle. pdftoppm renders through a different path than pdfimages extracts; if the two disagree with each other, the finding is about poppler. Settle this before concluding it is ours — the stencil polarity investigation (conformance#13) found exactly that, twice.

The per-population records under baseline/ carry peak, share, MSE and signed mean per filter and per colour space, so the first three questions can be narrowed from data already on disk before a single new measurement is taken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions