]> git.tuebingen.mpg.de Git - paraslash.git/commit
mp4: Remove tracks array.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 26 Aug 2021 16:36:00 +0000 (18:36 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 5 Jun 2022 15:26:33 +0000 (17:26 +0200)
commit58288c7cb28d72c93ad5309f1cfe7163be8b12fd
treeff24ca961e8a288677218d8c370f024e4673789b
parent2ca18e6d22391a7eded4a21925a44860a9840ecf
mp4: Remove tracks array.

The mp4 structure currently contains an array of 1024 track pointers
which are initialized to point to track structures allocated as we
encounter tracks. This is kind of wasteful given that we will only
care about audio tracks, and only ever consider the first one.

This patch replaces the pointer array by a single track structure
embedded within struct mp4. Besides the above mentioned memory savings,
this approach allows us to remove a bunch of identical sanity checks
in the atom parsers.

The old code maintained the ->audio_track pointer of struct mp4 to
tell whether we already saw an mp4a atom and thus already allocated
a structure for the corresponding track. We now use a state based
approach with three states instead. The state value determines whether
we have to parse the atom. The first state transition takes place when
the mp4a atom is encountered while the second transition occurs at the
subsequent trak atom, if any. If an atom parser is called while the
state machine is in an unexpected state, we return success rather than
an error code to ignore the atom without failing the whole operation.
mp4.c