Skip to content

Add JPEG 2000 codestream-level validation for IMF App2E - #1

Draft
fschleich wants to merge 4 commits into
masterfrom
feature/j2k-codestream-validation
Draft

Add JPEG 2000 codestream-level validation for IMF App2E#1
fschleich wants to merge 4 commits into
masterfrom
feature/j2k-codestream-validation

Conversation

@fschleich

Copy link
Copy Markdown
Owner

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.

fschleich and others added 4 commits June 25, 2026 21:46
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>
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