Commit 354efbc
committed
Fix UnrollPlanarWordsPremul() skipping only 1 plane instead of Extra planes
UnrollPlanarWordsPremul() in src/cmspack.c advances accum by a single
Stride when ExtraFirst is set, regardless of how many extra (non-color)
planes are declared via T_EXTRA(). For formats with Extra > 1 (e.g. two
extra planes ahead of the color planes), this shifts every subsequent
color-channel read one plane early and leaves the last color channel
unread, corrupting the unrolled pixel.
The chunky sibling UnrollAnyWordsPremul() had the identical bug, fixed
in a prior merge by adding an Extra local (T_EXTRA(info->InputFormat))
and multiplying it into the pre-skip offset. This applies the same fix
to the planar function: add the missing Extra local and change the
ExtraFirst pre-skip from `accum += Stride` to `accum += Extra * Stride`.
Verified with a formatter-dispatch harness exercising
COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|PLANAR_SH(1)|
EXTRA_SH(2)|PREMUL_SH(1)|DOSWAP_SH(1): before the fix, wIn came out as
{0x5555,0x4444,0x3333,0x2222} instead of the correct
{0x6666,0x5555,0x4444,0x3333}, with the K channel never read. After
the fix all 5 regression cases (Extra=1/2/3, both ExtraFirst settings)
pass with no change to previously-correct behavior.1 parent 8f7f96b commit 354efbc
1 file changed
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
| 662 | + | |
662 | 663 | | |
663 | 664 | | |
664 | 665 | | |
665 | | - | |
| 666 | + | |
666 | 667 | | |
667 | 668 | | |
668 | 669 | | |
669 | 670 | | |
670 | | - | |
| 671 | + | |
671 | 672 | | |
672 | 673 | | |
673 | 674 | | |
| |||
0 commit comments