Repository navigation
fix(mvhd, tkhd): treat volume as 8.8 fixed point - #589
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 0bd56fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Member
|
Thank you. I'm a bit concerned if we add one full test and 100+ lines of code each time we fix a bug. Tests are good but adding one at each PR fixing one field in a box is not sustainable. Opinions? |
Contributor
Author
|
Fair point. Replaced the 104-line file with one 16-line round-trip case in |
Member
|
Thank you so much. Merging. |
Open
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.
Description
volumeinmvhdandtkhdis 8.8 fixed point, but it was handled as an integer in three places:parse()did>> 8, so 0.5 (0x0080) was read as 0 and written back as 0.print()shifted the already-shifted value again, so full volume printed asvolume: 0.init()setmvhd.volume = 0x0100, andwrite()did<< 8, sowriteUint16(0x10000)stored 0. Files created withcreateFile().init()/addTrack()without awidthgot a mutedmvhd.Now
volumeis a plain number (1 = full volume, asgetInfo()already returns), read with/ 256and written withMath.round(volume * 256). Integer volumes read the same as before.tests/header-volume.test.tscovers reading, printing and rewriting both boxes, and themvhdbytes written afterinit(). 6 of its 8 tests fail before the change.vitest run(Node 22): 529 passed.eslint,prettier --checkandnpm run typespass.Reference: ISO/IEC 14496-12, 8.2.2 (MovieHeaderBox) and 8.3.2 (TrackHeaderBox),
template int(16) volume = 0x0100as a fixed 8.8 number.