Skip to content

feat(mp4): decode QuickTime audio sample entries .mp3, lpcm, twos, and sowt - #554

Open
nchitkara-xai wants to merge 1 commit into
Eyevinn:masterfrom
nchitkara-xai:qt-legacy-audio-entries
Open

feat(mp4): decode QuickTime audio sample entries .mp3, lpcm, twos, and sowt#554
nchitkara-xai wants to merge 1 commit into
Eyevinn:masterfrom
nchitkara-xai:qt-legacy-audio-entries

Conversation

@nchitkara-xai

Copy link
Copy Markdown

Problem

The QuickTime audio sample entries .mp3, lpcm, twos, and sowt fall
through to UnknownBox, so their sound description fields (channel count,
sample size, sample rate, and the version 1/2 extensions — lpcm entries carry
a version 2 description in practice) are unreachable without hand-parsing.

Fix

Register the four names in both dispatch tables so they decode as
AudioSampleEntryBox, reachable as StsdBox.Mp3 and StsdBox.QtPcm (one
shared pointer for the three PCM names, like AvcX/HvcX — check Type()).
Two safeguards keep hostile or odd files decodable:

  • a body that does not parse as a sound sample description becomes an
    UnknownBox with its bytes verbatim, so nothing that decoded before stops
    decoding;
  • the StsdBox.AddChild cases for these names use comma-ok assertions to
    tolerate that fallback, so an stsd containing e.g. a truncated .mp3
    entry decodes cleanly instead of panicking.

Note that a .mp3 entry carries no esds; its codec facts live in the sound
description fields themselves.

Tests

All four names decode with correct fixed fields and round-trip; an lpcm
version 2 description populates QuickTimeV2; a truncated body falls back to
UnknownBox byte-verbatim; and an stsd containing that truncated entry
decodes cleanly on both decode paths. go test ./..., go vet, gofmt,
golangci-lint pass.

…d sowt

These QuickTime sample description names use the standard sound sample
description layout, but fell through to UnknownBox, so their channel
count, sample size, and sample rate were unreachable without hand
parsing. Register them with the audio sample entry decoder and expose
them as StsdBox.Mp3 and StsdBox.QtPcm.

Since these names decoded as UnknownBox before, a body that does not
parse as a sound sample description falls back to UnknownBox instead of
failing the file, and the StsdBox.AddChild type assertions for the new
names tolerate that fallback instead of panicking on it.
@nchitkara-xai
nchitkara-xai marked this pull request as ready for review August 18, 2026 16:48
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