Some minor updates to the flac parser#42
Merged
Conversation
Contributor
Author
|
r? @kinetiknz |
kinetiknz
reviewed
Oct 25, 2016
| #[derive(Debug, Clone)] | ||
| struct FLACMetadataBlock { | ||
| pub struct FLACMetadataBlock { | ||
| block_type: u8, |
Collaborator
There was a problem hiding this comment.
Don't you need the block_type to identify the block?
Contributor
Author
There was a problem hiding this comment.
Yes, except that STREAMINFO is always first. I didn't want to expose it because I thought an enum was better, but that's what semver bumps are for.
| // No public fields. | ||
| mp4::AudioCodecSpecific::FLACSpecificBox(flac) => { | ||
| assert!(flac.blocks.len() > 0); | ||
| assert!(flac.blocks[0].data.len() > 0); |
Collaborator
There was a problem hiding this comment.
The first block is required to be STREAMINFO, so check that it's == 34?
| AudioCodecSpecific::FLACSpecificBox(ref flac) => { | ||
| // Return the STREAMINFO metadata block in the codec_specific. | ||
| let streaminfo = &flac.blocks[0].data; | ||
| if streaminfo.len() > std::u32::MAX as usize { |
Collaborator
There was a problem hiding this comment.
Check the block_type and the size, since it's a known fixed value (34).
Contributor
Author
There was a problem hiding this comment.
Good ideas, thanks.
Decoders generally need access to these to configure output, display metadata and so on. The block type should probably be an enum instead, but this will work for now.
Make this first metadata block available since it's the minimum necessary metadata, and the complete list of blocks could be quite large.
This metadata block has a fixed length, so that's a better check and just verifying there's no overflow.
We cast a size to a u32 for the capi data return. Our serialization routine will never produce a large header, but be defensive and make sure we're not writing the wrong size when we cast down, as we do with the other, less-controlled headers.
Contributor
Author
|
r? @kinetiknz |
kinetiknz
approved these changes
Oct 26, 2016
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.
No description provided.