Golden Ogg FLAC streams #
The same three quarters of a second of a 440 Hz tone, encoded by ffmpeg twice: once into an Ogg FLAC stream and once into a native one.
$ 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 flac -sample_fmt s16 tone.flac
The pair is worth more than either file alone. FLAC is lossless in both
containers, so the two have to decode to the same samples — and that is a claim
about this implementation's two decoding paths agreeing with each other and
with a third implementation, which is what src/ogg.zig's test "the container
makes no difference to the audio" checks. A test that asserted what the Ogg path
produced would prove only that it had not changed.
The serial number is chosen at random by the muxer, so regenerating tone.oga
changes a number the tests assert nothing about but the framing does depend on.
What is being tested is these bytes.
What tone.oga looks like #
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
Three pages, eight packets. It exercises most of the mapping in a small file:
- The identification packet is alone on the first page, which is therefore exactly 79 bytes — the number the mapping states.
- ffmpeg writes
header_packets = 1, and that one header packet is a VORBIS_COMMENT block, which the mapping requires of the first. - The streaminfo block in the identification packet has a total sample count of
zero and an all-zero MD5. Those are two of the four fields the mapping says
"may be set to zero (indicating 'unknown' in native FLAC), which also
facilitates single-pass encoding", and a single-pass encoder does leave them —
so this file is also the case where a decoder has nothing to verify against,
which is why
zig-flac testreports "MD5 not stated" for it rather than claiming a check it did not make. - The last page holds six audio frames and one granule position, 6000, which belongs to the sixth of them. Every earlier frame on that page has no position of its own, which is the rule that is easiest to get wrong.
What is not here #
A file whose identification packet declares a header packet count greater than one, and a stream multiplexed alongside another codec. Both are built in the tests instead, out of this library's own writer and the container's, because ffmpeg's muxer will not produce either on request.