Skip to content

fix(softimage): support channel packets with differing bit depths#5309

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-softimage-bits
Open

fix(softimage): support channel packets with differing bit depths#5309
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-softimage-bits

Conversation

@lgritz

@lgritz lgritz commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

A Softimage PIC file stores a chain of channel packets, each carrying its own bit depth (8 or 16). The reader assumed one uniform per-channel size for the whole image, so a file mixing depths (e.g. 16-bit R with 8-bit G) wrote past the end of the scanline buffer.

Fix: always expose one uniform pixel format, the widest depth among the file's packets, and promote narrower channels to it on read via exact bit replication (v*257 for 8->16), which preserves the normalized value exactly. This keeps the pixel layout naturally aligned; representing channels with their true differing formats instead would pack them at non-uniform, sometimes misaligned byte offsets.

Assisted-by: Claude Code / claude-sonnet-5

@lgritz lgritz force-pushed the lg-softimage-bits branch 2 times, most recently from d4e709a to d0a9b9b Compare July 9, 2026 23:23
A Softimage PIC file stores a chain of channel packets, each carrying
its own bit depth (8 or 16). The reader assumed one uniform per-channel
size for the whole image, so a file mixing depths (e.g. 16-bit R with
8-bit G) wrote past the end of the scanline buffer -- a heap overflow
reachable via iconvert poc.pic -o out.exr.

Fix: always expose one uniform pixel format, the widest depth among the
file's packets, and promote narrower channels to it on read via exact
bit replication (v*257 for 8->16), which preserves the normalized value
exactly. This keeps the pixel layout naturally aligned; representing
channels with their true differing formats instead would pack them at
non-uniform, sometimes misaligned byte offsets.

Assisted-by: Claude Code / claude-sonnet-5

Signed-off-by: Larry Gritz <lg@larrygritz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant