Skip to content

Conversation

@bradh
Copy link
Collaborator

@bradh bradh commented Jan 14, 2026

During checks for the MPEG file format conformance suite, a few files failed for missing stsz boxes.

It looks like there are two variations of the failure. One is that there are no sample sizes. The other is where stz2 (Compact Sample Size) is used - see ISO/IEC 14496-12:2022 Section 8.7.3.3.

Currently we mark stsz as required. However what is really required is "Exactly one variant shall be present".

So the simple approach is just to make stsz optional. However things will fail in strict mode when stz2 is present, so we really need that.

The part I need help on is how to handle the "stsz or stz2 is required" case.

There are four alternatives I considered:

  1. Don't worry about, make it a user problem. That is, no validation.
  2. Add something to the nested! macro definition like one_of: [[Stsz, Stz2]]. Then validate the exactly one case in macro code.
  3. Add a post-parse callback function argument, so the implementation can do whatever validation is useful.
  4. Try to work out a way to have Stsz parsing and encoding handle both the SampleSizeBox and CompactSampleSizeBox variations.

At this stage I lean to alternative 3, which is what this PR does. However the macro approach is no-skill (being approximately the skill I have), and involves a bunch of duplicate code. Trying to fix it made it uglier and even less comprehensible. Fixes much appreciated.

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