Basic flac support#32
Merged
Merged
Conversation
Contributor
Author
|
r? @kinetiknz |
kinetiknz
approved these changes
Oct 3, 2016
Collaborator
kinetiknz
left a comment
There was a problem hiding this comment.
LGTM, just a few nits.
| let a = try!(src.read_u8()) as u32; | ||
| let b = try!(src.read_u8()) as u32; | ||
| let c = try!(src.read_u8()) as u32; | ||
| Ok( a << 16 | b << 8 | c) |
| let mut track = super::Track::new(0); | ||
| let r = super::read_audio_desc(&mut stream, &mut track); | ||
| r.unwrap(); | ||
| //assert!(r.is_ok()); |
Collaborator
There was a problem hiding this comment.
Remove commented code?
Contributor
Author
There was a problem hiding this comment.
Yes. The assert!() was equivalent here, but .unwrap() gives a better error message.
| (*info).codec_specific_config.length = v.len() as u32; | ||
| (*info).codec_specific_config.data = v.as_ptr(); | ||
| } | ||
| AudioCodecSpecific::FLACSpecificBox(ref _flac) => { |
Collaborator
There was a problem hiding this comment.
FLACSpecificBox(_) might be clearer
| assert!(v.len() > 0); | ||
| "ES" | ||
| } | ||
| mp4::AudioCodecSpecific::FLACSpecificBox(_flac) => { |
Collaborator
There was a problem hiding this comment.
FLACSpecificBox(_) might be clearer
| // must be the METADATA_BLOCK_STREAMINFO | ||
| if blocks.len() < 1 { | ||
| return Err(Error::InvalidData("FLACSpecificBox missing metadata")); | ||
| } |
Collaborator
There was a problem hiding this comment.
} and else if on the same line
| } | ||
| // The box must have at least one meta block, and the first block | ||
| // must be the METADATA_BLOCK_STREAMINFO | ||
| if blocks.len() < 1 { |
Contributor
Author
There was a problem hiding this comment.
Oh, much better, thanks.
This adds parsing and a new codec type. Based on the draft spec attached to https://bugzilla.mozilla.org/show_bug.cgi?id=1286097
Fix flac metadata block type mask. Check flac metadata block lengths against parent box bounds. Also validate STREAMINFO being present and the first block. Add an example StreamInfo block from a real file and pass it to verify the new validation code. Use an enum instead of a u8 for FLAC Metadata Block types. We only use one of them, so mark the remaining variants with a leading underscore while they're unusued.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Basic support for the proposed FLAC encapsulation.