Repository navigation
Fix grid property amplification, Apple alpha, narrow grids and AV1 header strictness - #17
laurens-pilot wants to merge 5 commits into
Conversation
A grid can reference the same tile item many times, and many tile items can share one ipco property. Every reference cloned its tile's hvcC NAL units, ICC profile and transform list, and only tile payloads counted against the tile data budget. A 68 KB file whose 32x32 grid points every cell at one tile carrying about 65,000 irot associations peaked at 2.4 GB before any decoding started, and a tile hvcC holding hundreds of thousands of one-byte NAL units multiplies the same way. HeicGridTileItemData now holds its hvcC, colour properties and transforms behind Arc. Each hvcC property is parsed once and shared by every tile that uses it, colour properties are shared per nclx and ICC combination, and each distinct tile item resolves its transforms once, so a repeated reference costs a handle instead of a copy. ICC bytes copied into each new colour combination still count against the tile data budget, so one large profile cannot be multiplied through many distinct combinations. Grids that attach one large ICC profile to every tile, as ImageIO writes them, keep decoding. This changes the field types of the public HeicGridTileItemData.
intra_chroma_pred_mode is only coded when ChromaArrayType is not 0 (H.265 7.3.8.5), but the CTU decoder read it for every intra coding unit. In 4:0:0 streams that consumed bins belonging to the next syntax element and desynchronised CABAC without an error. Apple stores alpha as 4:0:0 Range Extensions streams, so transparent HEICs from ImageIO decoded with garbage alpha. Return the luma mode without reading anything when there is no chroma. A 192x64 ImageIO fixture now decodes to within 2 of its source alpha ramp, the same tolerance ImageIO's own decode has.
ImageIO codes HEVC frames at no less than 160x64 and crops them with the conformance window, so the alpha plane of a 40x30 image is a 160x64 frame. Preflight rejected auxiliary frames whose coded size went past the primary's visible size rounded up to a CTB, and such images decoded without their transparency. Drop that bound. The alpha's visible geometry must still match the primary, and its coded frame still counts against max_pixels and the decoded-byte allowance of the primary area, so cropping cannot hide an oversized frame.
ImageIO stores images narrower than its 512x512 tiles as 1xN or Nx1 grids of full tiles. ente#22 lets a single-span tile reach 512 px on such grids, but the decoded-byte allowance still came from the visible output area, which the tiles' decoded planes far exceed. ImageIO files at 40x30000, 60x30000, 100x40000 and 30000x40 all failed preflight. Count a dimension covered by one tile row or column as at least 512 px when tiles are stacked along the other dimension, matching the tile extent rule. max_pixels still caps the allowance.
The preflight rejected OBUs with the forbidden or reserved header bit set. rav1d ignores both unless strict standard compliance is enabled, which this decoder never does, so the preflight failed files the decoder itself accepts. Parse OBU headers the way the decoder does.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Superseded by ente#29. |
Fixes for five problems found while reviewing last week's changes (ente#13 through ente#26), one commit each:
HeicGridTileItemData'shvcc,colrandtransformsare nowArcs.intra_chroma_pred_mode. Reading it desynchronised CABAC in 4:0:0 streams, so Apple's alpha planes decoded to wrong values.Checked against a 283-file sweep (libheif and ente fixture corpora plus
sips-generated HEIC/AVIF): only the files these fixes target changed output; ImageIO alpha now matches ImageIO's own decode. The libheifverifycorpus job was not run locally.Grid-shaped alpha (e.g. 4000×3000 Apple images) is still unsupported, as before.