Skip to content

Add missing start-trim to Opus testdata to match declared pre_skip - #77

Merged
jwcullen merged 1 commit into
AOMediaCodec:mainfrom
trsonic:upstream-pr/opus-preskip-testdata
Aug 4, 2026
Merged

Add missing start-trim to Opus testdata to match declared pre_skip#77
jwcullen merged 1 commit into
AOMediaCodec:mainfrom
trsonic:upstream-pr/opus-preskip-testdata

Conversation

@trsonic

@trsonic trsonic commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #76.

The three Opus files under iamf/cli/testdata/iamf/ declare a non-zero pre_skip, but no audio frame OBU carries a start-trim, violating IAMF v1.1 §3.11.1. This patch sets the trimming-status flag on each substream's first audio frame and inserts num_samples_to_trim_at_end = 0 / num_samples_to_trim_at_start = pre_skip (120 for noise_3s_stereo_opus, 312 for the other two). No other bytes change; the files grow by 2–15 bytes.

Why patch the trim instead of zeroing pre_skip:

  • ComplianceWarden also rejects pre_skip == 0 on streams with audio frames, so the 2-byte patch would just trade one Rule Example command to convert 5.1 wav directly with ffmpeg throws error #15 error for another.
  • The existing end-trims already assume the start-trim: tones_100ms_3OA delivers 5760 − 312 − 648 = exactly 4800 samples (100 ms), noise_1024samp 1920 − 312 − 584 = exactly 1024. The original encode intended the trim; only the field went missing. This restores the filenames' stated durations.

Verified: all three patched files pass ComplianceWarden (-s iamf) with no errors, decode to exactly the intended durations (including noise_3s, whose first 120-sample frame is fully trimmed), and bazel test //iamf/... passes on this branch.

The three Opus files under iamf/cli/testdata/iamf/ declare a non-zero
pre_skip but no audio frame OBU carried num_samples_to_trim_at_start,
violating IAMF v1.1 Section 3.11.1 ("Pre-skip SHALL be the same as the
number of audio samples to be trimmed at the start of coded Audio
Substreams"), as flagged by ComplianceWarden's new IAMF checks.

The existing end-trims show the trim was always intended: 648 = 960 -
312 for tones_100ms_3OA (yielding exactly 4800 samples = 100 ms) and
1920 - 312 - 584 = 1024 for noise_1024samp. This patch sets the
trimming-status flag on each substream's first audio frame and inserts
num_samples_to_trim_at_end = 0 / num_samples_to_trim_at_start =
pre_skip, leaving every other byte unchanged.

After patching, all three files pass ComplianceWarden (-s iamf) with no
errors, and decoding yields exactly the intended durations (1024, 4800,
and 10224 samples per channel).

Fixes AOMediaCodec#76.
@trsonic
trsonic marked this pull request as ready for review August 3, 2026 17:46
@jwcullen
jwcullen merged commit 6b787f6 into AOMediaCodec:main Aug 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opus testdata fixtures declare pre_skip that is never trimmed (IAMF §3.11.1)

2 participants