fix(rva2): use big-endian byte order for volume adjustment#664
Draft
joust wants to merge 1 commit into
Draft
Conversation
ID3v2.4 §4.11 specifies RVA2 volume adjustment as a 16-bit signed fixed-point value. Per §3, all multi-byte integers in ID3 are big-endian. The reader was using `getInt16(offset, true)` (little- endian flag) and the writer was using `new Int16Array([v]).buffer`, which is host byte order (little-endian on every common platform). The two errors were symmetric, so a mp3tag.js-to-mp3tag.js round-trip preserved values — but the bytes on disk were wrong, and every standards-compliant v2.4 reader saw corrupted volumes for every RVA2 frame written by this library. The new test asserts the raw bytes on disk are big-endian (0x1234 serialises as 0x12 0x34, not 0x34 0x12), so the regression cannot recur.
96b919c to
096f53d
Compare
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.
Summary
ID3v2.4 §4.11 specifies RVA2 volume adjustment as a 16-bit signed fixed-point value, big-endian per §3. The reader used
getInt16(offset, true)(little-endian flag) and the writer usednew Int16Array([v]).buffer(host byte order, little-endian on x86/ARM).The two errors were symmetric, so mp3tag.js-to-mp3tag.js round-trips preserved values — but the bytes on disk are wrong, and every standards-compliant v2.4 reader sees corrupted volumes for every RVA2 frame this library writes.
Changes
src/id3v2/parse.mjs: drop thetrueLE flag ongetInt16src/id3v2/write.mjs: manual big-endian byte split[(v >> 8) & 0xff, v & 0xff]test/id3v2/index.cjs: new test asserts raw bytes on disk are big-endian (0x1234 → 0x12 0x34), plus round-trip for positive and negative valuesTest plan
npm test— 79 passing (78 → 79)