Skip to content

feat(mp4): add WaveBox.GetChildren and escape control chars in box types - #551

Open
tobbee wants to merge 1 commit into
masterfrom
wave-box-followups
Open

feat(mp4): add WaveBox.GetChildren and escape control chars in box types#551
tobbee wants to merge 1 commit into
masterfrom
wave-box-followups

Conversation

@tobbee

@tobbee tobbee commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Problem

Follow-up to #547, which added the wave box. Three small gaps were left:

  • WaveBox holds Children but has no GetChildren, so unlike the other
    container boxes it does not satisfy the ContainerBox interface.
  • The QuickTime terminator atom inside a wave has the four-byte type
    0x00000000, which Info() wrote out raw. Every mp4ff-info dump of a
    QuickTime audio file therefore contained NUL bytes and rendered the atom as
    [ ].
  • The RawTail semantics were undocumented: a malformed atom anywhere in the
    payload puts everything from it onwards in the tail, so boxes after it are
    not decoded into Children.

Fix

  • WaveBox.GetChildren, so a wave box is a ContainerBox. Its doc comment
    notes that RawTail is not part of the children, so a generic container
    encode would drop those bytes.
  • displayBoxType in the info dumper escapes C0 control characters and DEL as
    \xNN. It deliberately leaves 0xa9 alone, so the ©nam-style Apple atoms
    keep rendering as before and no golden dump changes. While there,
    fixStartingCopyrightChar is guarded against an empty box type, which would
    panic on the index of byte 0.
  • RawTail is documented, including that Encode writes it verbatim after
    the children.

mp4ff-info on an ffmpeg-written .mov, before and after:

-                [    ] size=8
+                [\x00\x00\x00\x00] size=8
                  - not implemented or unknown box

Tests

TestWaveBoxIsContainer asserts the ContainerBox interface and the
GetChildren contents; TestWaveBoxTerminatorInInfo asserts that no raw NUL
reaches the output and that the escaped form appears. go test ./...,
go vet, gofmt, and golangci-lint pass.

Also checked outside the test suite: an ffmpeg-generated AAC-in-.mov file
(which carries a real wave atom with frma, a 12-byte mp4a stub, esds,
and the terminator) still round trips byte-exact through both the
io.Reader/io.Writer and the SliceReader/SliceWriter paths.

🤖 Generated with Claude Code

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