close
Skip to content

Some minor updates to the flac parser#42

Merged
kinetiknz merged 4 commits into
mozilla:masterfrom
rillian:flac
Oct 26, 2016
Merged

Some minor updates to the flac parser#42
kinetiknz merged 4 commits into
mozilla:masterfrom
rillian:flac

Conversation

@rillian
Copy link
Copy Markdown
Contributor

@rillian rillian commented Oct 25, 2016

No description provided.

@rillian
Copy link
Copy Markdown
Contributor Author

rillian commented Oct 25, 2016

r? @kinetiknz

Comment thread mp4parse/src/lib.rs Outdated
#[derive(Debug, Clone)]
struct FLACMetadataBlock {
pub struct FLACMetadataBlock {
block_type: u8,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need the block_type to identify the block?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread mp4parse/tests/public.rs Outdated
// No public fields.
mp4::AudioCodecSpecific::FLACSpecificBox(flac) => {
assert!(flac.blocks.len() > 0);
assert!(flac.blocks[0].data.len() > 0);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first block is required to be STREAMINFO, so check that it's == 34?

Comment thread mp4parse_capi/src/lib.rs Outdated
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 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the block_type and the size, since it's a known fixed value (34).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@rillian
Copy link
Copy Markdown
Contributor Author

rillian commented Oct 26, 2016

r? @kinetiknz

@kinetiknz kinetiknz merged commit c30d530 into mozilla:master Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants