ImageIO's GIF decoder didn't decode interlaced images correctly when the height 
was 2-4 pixels.

For a tall gif (over 8px tall), interlacing is supposed to deliver pixels as 
follows:
Pass 1: rows 0, 8, 16, etc
Pass 2: rows 4, 12, 20, etc
Pass 3: rows 2, 6, 10, etc.
Pass 4: rows 1, 3, 5, etc.

But for a short gif (4px or less), we were computing the wrong value for 
`streamY` and screwing up the order rows were delivered.

With this PR: we immediately move on to the appropriate interlacing pass so 
`streamY` makes sense.

For example, here is some sample output from the attached test before this 
proposed change:

Failure #7; 3x2
Original image:
[ffff3333, ffffff66, ff33cc33]
[ffcc33ff, ffcc9933, ff663333]
Decoded image:
[ffff3333, ffffff66, ff33cc33]
[ff000000, ff000000, ff000000]

Failure #8; 3x3
Original image:
[ffff3333, ffffff66, ff33cc33]
[ffcc33ff, ffcc9933, ff663333]
[ff99ff66, ff00ccff, ffcc3366]
Decoded image:
[ffff3333, ffffff66, ff33cc33]
[ff000000, ff000000, ff000000]
[ffcc33ff, ffcc9933, ff663333]

Failure #9; 3x4
Original image:
[ffff3333, ffffff66, ff33cc33]
[ffcc33ff, ffcc9933, ff663333]
[ff99ff66, ff00ccff, ffcc3366]
[ffff9966, ff666633, ff33cccc]
Decoded image:
[ffff3333, ffffff66, ff33cc33]
[ffff9966, ff666633, ff33cccc]
[ffcc33ff, ffcc9933, ff663333]
[ff000000, ff000000, ff000000]


In each case: you can observe the first row is correct. One row is left black. 
And the remaining rows are not in the correct order. (But each non-black row in 
the decoded IS in the original image somewhere.)

This test is broadly written so it tests thousands of possible width/height 
combinations.

I successfully ran every test in the /jdk/test/jdk/javax/imageio/plugins/gif/ 
directory on my Mac.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

-------------

Commit messages:
 - 8395707: fixing mistaken commit
 - 8395707: increment interlacing pass sooner for short images
 - 8395707: add failing unit test
 - Merge branch 'master' of https://github.com/mickleness/jdk
 - Merge branch 'master' of https://github.com/mickleness/jdk
 - Merge branch 'openjdk:master' into master
 - 8385367: stop using stale/orphaned AccessibleContext

Changes: https://git.openjdk.org/jdk/pull/33787/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33787&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8395707
  Stats: 143 lines in 2 files changed: 142 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/33787.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33787/head:pull/33787

PR: https://git.openjdk.org/jdk/pull/33787

Reply via email to