Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don't error on empty `SYLT` strings ([issue](https://github.com/Serial-ATA/lofty-rs/issues/563)) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/564))
- **Vorbis Comments**: Parse `TRACKNUMBER` with respect to `ParseOptions::implicit_conversions` ([issue](https://github.com/Serial-ATA/lofty-rs/issues/540)) ([PR](https://github.com/Serial-ATA/lofty-rs/issues/542))
- **APE**: Fix disc number removal/writing ([issue](https://github.com/Serial-ATA/lofty-rs/issues/545)) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/546))
- **AAC/ADTS**: Fix frame header search ([issue](https://github.com/Serial-ATA/lofty-rs/issues/584)) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/586))
- When searching for the next frame, the parser was not fully skipping the previous one. If the AAC payload contained the frame sync bits and an otherwise invalid ADTS
header, then the parser would error.

### Removed

Expand Down
7 changes: 5 additions & 2 deletions lofty/src/aac/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ where

let mut frame_count = 1;

while let Some((header, _)) = find_next_frame(reader, parse_mode)? {
while let Some((header, frame_end)) = find_next_frame(reader, parse_mode)? {
first_frame_header.bitrate += header.bitrate;
frame_count += 1u32;

reader.seek(SeekFrom::Start(frame_end))?;
}

first_frame_header.bitrate /= frame_count;
Expand All @@ -150,6 +152,7 @@ where
Ok(file)
}

// TODO: Does a lot of unnecessary seeking
// Searches for the next frame, comparing it to the following one
fn find_next_frame<R>(
reader: &mut R,
Expand Down Expand Up @@ -179,7 +182,7 @@ where
HeaderCmpResult::Equal => {
return Ok(Some((
first_header,
first_adts_frame_start_absolute + u64::from(header_len),
first_adts_frame_start_absolute + u64::from(first_header.len),
)));
},
HeaderCmpResult::Undetermined => return Ok(None),
Expand Down