Golden Ogg streams #
Three files, so that the page parser is checked against pages somebody else framed rather than only against pages this library wrote. A test that asserts what this implementation produced proves only that it has not changed; these prove it agrees with libogg, which is what every Ogg file in the world was written by.
They were made with ffmpeg from a synthesised sine wave — nothing in them is anybody else's content, and none of them is large:
$ ffmpeg -f lavfi -i "sine=frequency=440:sample_rate=8000:duration=0.75" \
-c:a flac -sample_fmt s16 tone.oga
$ ffmpeg -f lavfi -i "sine=frequency=440:sample_rate=8000:duration=0.75" \
-c:a libvorbis -q:a 1 tone.ogg
$ ffmpeg -f lavfi -i "sine=frequency=440:sample_rate=8000:duration=0.75" \
-f lavfi -i "sine=frequency=660:sample_rate=8000:duration=0.75" \
-map 0:a -map 1:a -c:a:0 libvorbis -q:a:0 1 -c:a:1 libopus -b:a:1 32k \
grouped.ogg
The serial numbers are chosen at random by the muxer, so regenerating a file changes the numbers the tests assert. That is why these are committed rather than built: what is being tested is these bytes.
What each one exercises #
| File | Bytes | Pages | What it is for |
|---|---|---|---|
tone.oga |
2679 | 3 | Ogg FLAC: a bos page carrying the \x7fFLAC identification packet, a page carrying the metadata packet the mapping requires after it, and one page holding six audio frames. The page whose granule position belongs to the last of six packets is what pins the granule rule. |
tone.ogg |
3133 | 3 | Ogg Vorbis: a bos page, a page whose segment table runs 62, 255 × 9, 181 — a packet of more than two kilobytes laced across ten segments — and a page holding twenty-five small packets. |
grouped.ogg |
6527 | 6 | Two logical bitstreams, Vorbis and Opus, concurrently multiplexed: both bos pages first, then their pages alternating. Chaining is tested by concatenating two of these files, which is all chaining is. |
The page tables #
Read off the files with a script of their own, and what the tests in
src/reader.zig and src/demuxer.zig assert:
tone.oga page 0 bos granule 0 1 segment [51] 79 bytes
page 1 granule 0 1 segment [53] 81 bytes
page 2 eos granule 6000 12 segments [255,161,...] 2519 bytes
tone.ogg page 0 bos granule 0 1 segment [30] 58 bytes
page 1 granule 0 11 segments [62,255×9,181] 2576 bytes
page 2 eos granule 6000 25 segments [20,18,17,...] 499 bytes
Note what is not here: a packet that spans a page boundary. ffmpeg's muxer
has no option to make one, and forcing one out of it needs frames larger than a
page — eight channels of 24-bit audio at a block size of 4096 — which is a
hundred kilobytes of noise to commit for one property. That path is covered
instead by the round trips in src/demuxer.zig and src/tests/fuzz.zig, which
write packets of every length either side of a page, and by the pages built by
hand in src/page.zig.