MP3 decoding tweaks

This commit is contained in:
Chris McCord 2021-11-15 12:06:45 -05:00
parent 1fc60aae2a
commit 458900b522

View file

@ -55,14 +55,14 @@ defmodule LiveBeats.MP3Stat do
>>) do >>) do
tag_size = decode_synchsafe_integer(tag_size_synchsafe) tag_size = decode_synchsafe_integer(tag_size_synchsafe)
{rest, _ext_header_size} = {rest, ext_header_size} =
if extended_header == 1 do if extended_header == 1 do
skip_extended_header(major_version, rest) skip_extended_header(major_version, rest)
else else
{rest, 0} {rest, 0}
end end
parse_frames(major_version, rest, tag_size - extended_header) parse_frames(major_version, rest, tag_size - ext_header_size, [])
end end
defp parse_tag(_), do: %{} defp parse_tag(_), do: %{}
@ -100,7 +100,10 @@ defmodule LiveBeats.MP3Stat do
{rest, ext_header_size} {rest, ext_header_size}
end end
defp parse_frames(major_version, data, tag_length_remaining, frames \\ []) defp parse_frames(_, data, tag_length_remaining, frames)
when tag_length_remaining <= 0 do
{Map.new(frames), data}
end
defp parse_frames( defp parse_frames(
major_version, major_version,
@ -150,11 +153,6 @@ defmodule LiveBeats.MP3Stat do
end end
end end
defp parse_frames(_, data, tag_length_remaining, frames)
when tag_length_remaining <= 0 do
{Map.new(frames), data}
end
defp parse_frames(_, data, _, frames) do defp parse_frames(_, data, _, frames) do
{Map.new(frames), data} {Map.new(frames), data}
end end