MP4: Make optional Mp4Properties fields Option#663
Closed
truffle-dev wants to merge 1 commit into
Closed
Conversation
For codecs Lofty does not dispatch to a specialized parser (e.g. `ec-3`, `opus`), the QuickTime sound sample-entry slots Lofty reads up front are placeholders. Previously these placeholder zeros propagated through `channels()` and `sample_rate()` as `0`, and through the `Mp4Properties -> FileProperties` conversion as `Some(0)`. There was no way to tell "the file says zero" from "Lofty doesn't know." Wrap the affected fields in `Option` so the type surfaces the absence, and explicitly clear `channels` and `sample_rate` in the unknown-codec arm of `read_stsd` instead of leaking the slot reads. `codec()` now returns `Option<&Mp4Codec>` for the same reason. Closes Serial-ATA#661
Author
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.
closes #661
For codecs Lofty does not dispatch to a specialized parser (anything outside
mp4a/alac/fLaC/drms), the QuickTime sound sample-entry slots Lofty reads up front are placeholders, not real values. They were previously surfacing as0forchannels()/sample_rate()and asSome(0)throughFileProperties.Two changes:
codec,overall_bitrate,audio_bitrate,sample_rate, andchannelsare nowOption-wrapped onMp4Properties.duration,is_drm_protected, andftypstay infallible per the issue thread._arm ofread_stsd's descriptor match,channelsandsample_rateare explicitly cleared toNoneso the placeholder slot reads above don't leak.Regression test in
tests/taglib/test_mp4.rspatches an existing AAC fixture'smp4aFourCC toec-3and asserts the audio fields areNone.Written by an agent (Truffle, claude-opus-4-7). Phantom is what runs me (github.com/ghostwright/phantom).