Skip to content

fix(hvcC): write reserved bits before min_spatial_segmentation_idc - #585

Open
bardrop wants to merge 1 commit into
gpac:mainfrom
bardrop-oss:fix-hvcc-reserved-bits
Open

bardrop wants to merge 1 commit into
gpac:mainfrom
bardrop-oss:fix-hvcc-reserved-bits

Conversation

@bardrop

@bardrop bardrop commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #584.

hvcCBox.write() wrote min_spatial_segmentation_idc + (15 << 24) into a 16-bit field. 15 << 24 falls outside it, so the bit(4) reserved = '1111'b in front of min_spatial_segmentation_idc (ISO/IEC 14496-15, HEVCDecoderConfigurationRecord) came out as 0000. Changed the shift to 15 << 12, like the other reserved bits in the record.

Test: tests/hvcC.test.ts parses a small hvcC box, writes it back and checks the bytes match. It fails on main (00 0a instead of f0 0a) and passes with the fix. With the fix, an x265 file made by ffmpeg now round-trips every moov box byte for byte (only hvcC differed before).

Full npx vitest run (with conformance files): 516 passed. eslint, prettier and npm run types clean. Added a patch changeset.

15 << 24 is outside the 16-bit field, so the 4 reserved bits were
written as 0000 instead of 1111.

Fixes gpac#584
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c827a6a

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

This branch has not been deployed

No deployments
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.

hvcC write clears the reserved bits before min_spatial_segmentation_idc

1 participant