Skip to content

Commit

Permalink
Fix single-code-{ordered,sparse}.ogg decoding error
Browse files Browse the repository at this point in the history
Decoding of the files single-code-ordered.ogg
and single-code-sparse.ogg gave us the error
that current_length was bigger than
codebook_entries. But this was a bug.

Apparently we were comparing current_length
with codebook_entries, but the spec tells us
to use current_entry instead of current_length.

Now, after having changed the behaviour to
follow the spec, we can decode the files
successfully.

The second file can be decoded by libvorbis
as well, and here some discrepancy still seems
to exist (25 packets with mismatches of 26 total).
However, having the files decode successfully
is already progress.
  • Loading branch information
est31 committed Sep 13, 2018
1 parent 10c479d commit b312ce4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions dev/cmp/tests/vals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ fn test_libnogg_vals() {
// We can't cmp the output here because native
// libvorbis doesn't accept the file as valid
ensure_okay!("single-code-nonsparse.ogg");
//cmp_output!("single-code-ordered.ogg", 0);
// TODO fix this
//cmp_output!("single-code-sparse.ogg", 0);
ensure_okay!("single-code-ordered.ogg");
// TODO get this number down to zero
// This test is ensuring already though that
// the file decodes without errors, which wasn't
// the case until a bug in lewton got fixed.
cmp_output!("single-code-sparse.ogg", 25);
cmp_output!("sketch008-floor0.ogg", 4);
cmp_output!("sketch008.ogg", 0);
cmp_output!("sketch039.ogg", 0);
Expand Down
2 changes: 1 addition & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ fn read_codebook(rdr :&mut BitpackCursor) -> Result<Codebook, HeaderReadError> {
}
current_entry += number;
current_length += 1;
if current_length as u32 > codebook_entries {
if current_entry as u32 > codebook_entries {
try!(Err(HeaderReadError::HeaderBadFormat));
}
}
Expand Down

0 comments on commit b312ce4

Please sign in to comment.