Skip to content

fix(vvc): rebuild constraint bytes in the order stored in vvcC - #590

Merged
rbouqueau merged 2 commits into
gpac:mainfrom
zzoraemon043:fix/vvc-constraint-codec-string
Nov 23, 2026
Merged

rbouqueau merged 2 commits into
gpac:mainfrom
zzoraemon043:fix/vvc-constraint-codec-string

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Description

The C part of vvc1 / vvi1 codec strings is the base32 of ptl_frame_only_constraint_flag, ptl_multilayer_enabled_flag and general_constraint_info as stored in the PTL record. vvcC parsing keeps those bits shifted by 2: each general_constraint_info[i] holds 8 bits starting after the two flags, and the last entry holds the remaining 6 bits.

getCodec() did not undo that shift correctly:

  • the 2 bits carried into the next byte were (gci[i] >> 2) & 0x03 and went to the low end, instead of (gci[i] & 0x03) << 6
  • the last entry was shifted right by 2 again, dropping its 2 lowest bits

So any record with general_constraint_info beyond the first byte got a wrong string. For constraint bytes a5 c3 80 it gave vvc1.1.L83.CUUBQG instead of CUXBYA.

Now the bytes are rebuilt as they appear in the record and then encoded as before. Records with a single zero byte still give CA.

tests/codec.test.ts parses three vvcC boxes and checks the codec string. 2 of the 3 tests fail before the change. vitest run (Node 22): 525 passed. eslint, prettier --check, npm run types and npm run build pass.

Note: MP4Box rfc_6381_get_codec_vvc writes the last 6-bit entry as 8 bits, so the two match when those last 6 bits are zero (the alignment bits when gci_num_additional_bits is 0) and differ otherwise.

Reference: ISO/IEC 14496-15, VvcPTLRecord, and Annex E for the codecs parameter.

@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a39eb9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mp4box Patch

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

@rbouqueau

Copy link
Copy Markdown
Member

Indeed, thanks!

@rbouqueau
rbouqueau added this pull request to the merge queue Nov 23, 2026
Merged via the queue into gpac:main with commit 8d187c2 Nov 23, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
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