Skip to content

Commit

Permalink
Handle variable size atom header [#261]
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeugma440 committed Apr 19, 2024
1 parent 2eaec8f commit a9a5690
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ATL/AudioData/IO/MP4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ private static uint navigateToAtom(Stream source, string atomKey)
/// <param name="source">Source to read from</param>
/// <param name="atomKey">Atom key to look for (e.g. "udta")</param>
/// <returns>
/// - Item1 : If atom found : raw size of the atom (including the already-read 8-byte header);
/// - Item1 : If atom found : raw size of the atom (including the already-read 8 or 16-byte header);
/// If atom not found : 0
/// - Item2 : Size of the atom header (may vary if using the 64-bit variant)
/// </returns>
Expand All @@ -1584,13 +1584,13 @@ private static Tuple<uint, int> navigateToAtomSize(Stream source, string atomKey
string atomHeader;
bool first = true;
int iterations = 0;
int atomHeaderSize;
int atomHeaderSize = 8;
byte[] data = new byte[8];

do
{
atomHeaderSize = 8;
if (!first) source.Seek(atomSize - 8, SeekOrigin.Current);
if (!first) source.Seek(atomSize - atomHeaderSize, SeekOrigin.Current);
atomHeaderSize = 8; // Default 8-bit variant
source.Read(data, 0, 4);
atomSize = StreamUtils.DecodeBEUInt32(data);
source.Read(data, 0, 4);
Expand Down

0 comments on commit a9a5690

Please sign in to comment.