-
-
Notifications
You must be signed in to change notification settings - Fork 56
Byte skipping between ID3 and MP3 blocks #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Byte skipping between ID3 and MP3 blocks #29
Conversation
When a file contains an ID3 block, the following data might be an MP3 frame. The frame might be prepended by junk bytes, which are skipped with this commit.
The first MP3 frame behind metadata blocks is found by searching for frame sync bits. This skips junk bytes between any metadata blocks and the first MP3 frame.
|
Thanks for working on this! The locations of the tests are fine, could you rename the asset to something like
Since the only error that can occur is Lines 138 to 142 in c88cad0
We just use
That's actually a mistake, the length check shouldn't be there at all. I forgot to remove those when I chose to only return |
Serial-ATA
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just some minor things.
|
I have updated the pull request according to the code review and also fixed the clippy errors (very good to hve that in CI). Would it be useful to also change the type definition of |
|
Yeah, I'll save that change for the next major version. This can be included in the next minor release. Also, could you revert that clippy lint for the negative multiplication? I think that was a lot more readable. You can just throw an |
|
Thanks! |
As discussed in #28, junk bytes between initial metadata blocks and following MP3 frames are skipped with this implementation change.
The new function
search_for_frame_syncuses a reader to search for the first appearence of frame sync bits. This function is then used for probing the file type (Probe::guess_inner) and reading MP3 data (mp3::read::read_from). All three additions are checked by three new tests. The tests for the new function and theProbeare in the same module as the implementation, while themp3::read_fromtest is separted into thetestsand uses an example*.mp3file.Please comment on the positioning of the tests and the changes on the two existing functions.
I am a bit confused by the
Probe::guess_innerfunction:Result<Option<FileType>>?Ok(None)andErr(LoftyError::UnknownFormat)?Err(LoftyError::UnknownFormat)fromFileType::from_buffer_innertransfomed intoOk(None), but internal errors such asbuf_len < 3useErr(LoftyError::UnknownFormat)?Result<FileType>make more sense?