Add JPEG 2000 codestream-level validation for IMF App2E - #1
Draft
fschleich wants to merge 4 commits into
Draft
Conversation
Adds optional codestream-level validation (SMPTE ST 2067-21) that parses the JPEG 2000 codestream main header of sampled frames and checks profile conformance, codestream-vs-descriptor consistency, and marker presence. - JPEG2000Codestream: main-header parser (SOC/SIZ/CAP/COD/QCD) into the existing J2KHeaderParameters model, plus J2KHeaderParameters.fromCodestream. - IMFTrackFileReader: getEssenceElementHeaderBytes (CBE/VBE index resolution + KLV walk to first essence element); getPictureEssenceCodingUL and getDescriptorJ2KHeaderParameters; IndexTableSegment getters; GenericPictureEssenceDescriptorBO.getPictureEssenceCodingUL. - EssenceSamplingPolicy (none|first|every:N|all, default none), J2KProfileConstraints (IMF/Broadcast checkers), and J2KCodestreamValidator (dispatch by picture essence coding UL; reuses validateHTConstraints for HT). Findings are NON_FATAL. - Wired into IMPAnalyzer.analyzeDelivery and analyzeFile via the --j2k-codestream CLI flag (existing overloads preserved). - Constraint reference doc, README usage, and unit/integration tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two issues surfaced by running first-frame validation on real IMF J2K track files: - J2KHeaderParameters.fromJPEG2000PictureSubDescriptorBO dereferenced the JPEG 2000 extended capabilities (CAP) unconditionally, throwing an NPE for non-HT IMF/Broadcast essence that carries no CAP marker. Now null-guarded, matching the fromDOMNode convention (CAP left null when absent). - Essence frame extraction did not filter body partitions by BodySID, so for files that multiplex multiple essence containers (e.g. a picture track interleaved with a data/XML track) it could read the wrong container. The extractor now carries the target BodySID from the resolving index table and selects only matching body partitions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Walks the JPEG 2000 tile-part structure to verify the TLM marker, which is required by the App2E profiles and a known field-conformance issue. - JPEG2000Codestream now parses TLM marker segment(s) and walks the tile-part chain: it navigates SOT->SOT by Psot, verifies each jump lands on an SOT/EOC, measures each tile-part length, and detects the terminating EOC. Exposes getTLMEntries()/getTileParts()/isTilePartStructureValid()/reachedEndOfCodestream(). - IMFTrackFileReader.getEssenceElementBytes reads the whole essence element (shared offset resolution with getEssenceElementHeaderBytes). - J2KCodestreamValidator reads the full frame and checks TLM presence, tile-part structural consistency, EOC termination, and that the declared TLM lengths match the measured tile-part lengths (count, per-entry length, tile index). - Unit tests for tile-part walking and conformant/non-conformant TLM; validator test narrowed to consistency + structural invariants. Verified against real material: the IMF picture track passes TLM conformance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds optional codestream-level validation (SMPTE ST 2067-21) that parses the JPEG 2000 codestream main header of sampled frames and checks profile conformance, codestream-vs-descriptor consistency, and marker presence.