Fix premature output of non-interleaved multi-scan JPEGs [chromium/src : main]

0 views
Skip to first unread message

Florin Malita (Gerrit)

unread,
Jul 24, 2026, 7:36:09 PM (20 hours ago) Jul 24
to Wan-Teh Chang, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org, blink-...@chromium.org, cblume+im...@chromium.org, kinuko...@chromium.org, mbarowsky+watc...@chromium.org
Attention needed from Wan-Teh Chang

Florin Malita added 5 comments

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Florin Malita . resolved

This change requires rebaselines for three jpeg images:

[12-55.jpg](https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/third_party/blink/web_tests/images/resources/jpegfuzz/12-55.jpg)
[182.jpg](https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/third_party/blink/web_tests/images/resources/jpegfuzz/182.jpg)
[23-55.jpg](https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/third_party/blink/web_tests/images/resources/jpegfuzz/23-55.jpg)

These are part of jpegfuzz and contain corrupted/truncated data (mainly missing some component scans). We are now rejecting them (jpeg_input_complete correctly returns false) instead of attempting to decode with missing components and producing junk pixels.

File third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.cc
Line 172, Patchset 3: kJpegDecompressSequential, // Output sequential pixels
Wan-Teh Chang . resolved

Should we change this comment to "Output pixels in sequential mode." for consistency?

Florin Malita

Done

Line 573, Patchset 3: // If this is a progressive JPEG ...
Wan-Teh Chang . resolved

Do we need to change the word "progressive" in this comment?

Florin Malita

Done

Line 593, Patchset 3: [](const jpeg_decompress_struct& info) -> bool {
Wan-Teh Chang . resolved

Should we remove the `const` here so that we don't need the `const_cast` at line 605?

Florin Malita

Done

Line 604, Patchset 3: // images, all components are only seen when the input is complete.
Wan-Teh Chang . resolved

Just for my own understanding: At this point, `info.coef_bits` is a null pointer. Could you explain why that implies the image is non-progressive?

Florin Malita

Per `coef_bits` [docs](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/c082e8697dfc4b6f8e2eacf0a23e41d98004ba65/src/jpeglib.h#L625): *This pointer is NULL when reading a non-progressive file.*

Open in Gerrit

Related details

Attention is currently required from:
  • Wan-Teh Chang
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I32a44452c2b74d259a3957176eb64f95159287fe
Gerrit-Change-Number: 8141869
Gerrit-PatchSet: 5
Gerrit-Owner: Florin Malita <fma...@chromium.org>
Gerrit-Reviewer: Florin Malita <fma...@chromium.org>
Gerrit-Reviewer: Wan-Teh Chang <w...@google.com>
Gerrit-Attention: Wan-Teh Chang <w...@google.com>
Gerrit-Comment-Date: Fri, 24 Jul 2026 23:35:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Wan-Teh Chang <w...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Wan-Teh Chang (Gerrit)

unread,
Jul 24, 2026, 7:44:50 PM (20 hours ago) Jul 24
to Florin Malita, Wan-Teh Chang, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org, blink-...@chromium.org, cblume+im...@chromium.org, kinuko...@chromium.org, mbarowsky+watc...@chromium.org
Attention needed from Florin Malita

Wan-Teh Chang added 1 comment

File third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.cc
Line 605, Patchset 5 (Latest): return jpeg_input_complete(&info);
Wan-Teh Chang . unresolved

IMPORTANT: I wonder if we should also test `info.input_scan_number == info.output_scan_number` here. See lines 670-672, reproduced here:

```
if (jpeg_input_complete(&info_) &&
(info_.input_scan_number == info_.output_scan_number)) {
break;
```

and the test file provided by DRC in https://crbug.com/504670493#comment10. Note that the condition DRC uses is NOT the negation of the condition above:

```
while (!jpeg_input_complete(&cinfo) &&
cinfo.input_scan_number != cinfo.output_scan_number) {
```

It would be good to get DRC's input on this.

Open in Gerrit

Related details

Attention is currently required from:
  • Florin Malita
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I32a44452c2b74d259a3957176eb64f95159287fe
    Gerrit-Change-Number: 8141869
    Gerrit-PatchSet: 5
    Gerrit-Owner: Florin Malita <fma...@chromium.org>
    Gerrit-Reviewer: Florin Malita <fma...@chromium.org>
    Gerrit-Reviewer: Wan-Teh Chang <w...@google.com>
    Gerrit-Attention: Florin Malita <fma...@chromium.org>
    Gerrit-Comment-Date: Fri, 24 Jul 2026 23:44:42 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Wan-Teh Chang (Gerrit)

    unread,
    Jul 24, 2026, 9:25:30 PM (18 hours ago) Jul 24
    to Florin Malita, Wan-Teh Chang, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org, blink-...@chromium.org, cblume+im...@chromium.org, kinuko...@chromium.org, mbarowsky+watc...@chromium.org
    Attention needed from Florin Malita

    Wan-Teh Chang voted and added 2 comments

    Votes added by Wan-Teh Chang

    Code-Review+1

    2 comments

    Patchset-level comments
    Wan-Teh Chang . resolved

    LGTM. Thanks!

    File third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.cc
    Line 573, Patchset 5 (Latest): // If this is a JPEG requiring buffered-image mode?
    Wan-Teh Chang . unresolved

    Why was a question mark added?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Florin Malita
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I32a44452c2b74d259a3957176eb64f95159287fe
      Gerrit-Change-Number: 8141869
      Gerrit-PatchSet: 5
      Gerrit-Owner: Florin Malita <fma...@chromium.org>
      Gerrit-Reviewer: Florin Malita <fma...@chromium.org>
      Gerrit-Reviewer: Wan-Teh Chang <w...@google.com>
      Gerrit-Attention: Florin Malita <fma...@chromium.org>
      Gerrit-Comment-Date: Sat, 25 Jul 2026 01:25:20 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Wan-Teh Chang (Gerrit)

      unread,
      Jul 24, 2026, 9:42:50 PM (18 hours ago) Jul 24
      to Florin Malita, Wan-Teh Chang, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org, blink-...@chromium.org, cblume+im...@chromium.org, kinuko...@chromium.org, mbarowsky+watc...@chromium.org
      Attention needed from Florin Malita

      Wan-Teh Chang added 1 comment

      File third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.cc
      Line 604, Patchset 3: // images, all components are only seen when the input is complete.
      Wan-Teh Chang . resolved

      Just for my own understanding: At this point, `info.coef_bits` is a null pointer. Could you explain why that implies the image is non-progressive?

      Florin Malita

      Per `coef_bits` [docs](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/c082e8697dfc4b6f8e2eacf0a23e41d98004ba65/src/jpeglib.h#L625): *This pointer is NULL when reading a non-progressive file.*

      Wan-Teh Chang

      Thanks. Code Search shows that the `coef_bits` table is allocated in `jinit_phuff_decoder()`. `jinit_phuff_decoder()` is called under the following condition:

      ```
      !cinfo->master->lossless && !cinfo->arith_code && cinfo->progressive_mode
      ```

      Does this match your understanding?

      Gerrit-Comment-Date: Sat, 25 Jul 2026 01:42:37 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Wan-Teh Chang <w...@google.com>
      Comment-In-Reply-To: Florin Malita <fma...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Wan-Teh Chang (Gerrit)

      unread,
      10:32 AM (5 hours ago) 10:32 AM
      to Florin Malita, Moritz Firsching, Wan-Teh Chang, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, chromium...@chromium.org, mac-r...@chromium.org, blink-...@chromium.org, cblume+im...@chromium.org, kinuko...@chromium.org, mbarowsky+watc...@chromium.org
      Attention needed from Florin Malita and Moritz Firsching

      Wan-Teh Chang added 1 comment

      File third_party/blink/renderer/platform/image-decoders/jpeg/jpeg_image_decoder.cc
      Line 609, Patchset 5 (Latest): all_components_seen(info_) ? info_.input_scan_number : 0;
      Wan-Teh Chang . resolved

      Moritz: You added the `first_scan_to_display` and `all_components_seen` code ([CL1](https://chromium-review.googlesource.com/c/chromium/src/+/2515401), [CL2](https://chromium-review.googlesource.com/c/chromium/src/+/2577498)). It would be good if you could take a look at this CL.

      If we ignore the renaming changes, the only change to the logic in this CL is line 605 -- what `all_components_seen()` should return when `info.coef_bits` is a null pointer.

      Since `all_components_seen()` is only used to set the `first_scan_to_display` variable, we can also take a step back and consider what value `first_scan_to_display` should be set to when `info.coef_bits` is a null pointer.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Florin Malita
      • Moritz Firsching
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I32a44452c2b74d259a3957176eb64f95159287fe
      Gerrit-Change-Number: 8141869
      Gerrit-PatchSet: 5
      Gerrit-Owner: Florin Malita <fma...@chromium.org>
      Gerrit-Reviewer: Florin Malita <fma...@chromium.org>
      Gerrit-Reviewer: Moritz Firsching <firs...@google.com>
      Gerrit-Attention: Moritz Firsching <firs...@google.com>
      Gerrit-Comment-Date: Sat, 25 Jul 2026 14:31:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages