Skip to content

feat(mp4): elst media rate as one signed 16.16 fixed-point number - #552

Merged
tobbee merged 1 commit into
Eyevinn:masterfrom
nchitkara-xai:elst-media-rate
Aug 20, 2026
Merged

feat(mp4): elst media rate as one signed 16.16 fixed-point number#552
tobbee merged 1 commit into
Eyevinn:masterfrom
nchitkara-xai:elst-media-rate

Conversation

@nchitkara-xai

Copy link
Copy Markdown

Problem

The elst media rate is split across MediaRateInteger and MediaRateFraction,
two int16 halves of one signed 16.16 number, so reading or writing a rate means
knowing the bit layout, including the trap that sign-extending the fraction
corrupts the integer half when recombining.

Fix

ElstEntry.MediaRateFixed32() and SetMediaRateFixed32() combine and split
the halves as one signed int32. The raw fields are unchanged, so decode and
encode round-trips are untouched. The getter returns a plain int32 rather
than mp4.Fixed32, which is unsigned; the media rate is signed.

Tests

Table-driven round-trips in both directions for 1.0, 0.25, 2.5, -1.0, -0.5,
-1.5 and the 0x7fff/-1 extreme; the negative-fraction cases pin the sign
handling. go test ./..., go vet, gofmt, golangci-lint pass.

ElstEntry splits the media rate over MediaRateInteger and
MediaRateFraction, so reading or writing the actual rate required
callers to know the split int16/int16 bit layout, including the
sign-extension trap when combining a negative fraction half. Add
MediaRateFixed32 and SetMediaRateFixed32 to combine and split the
halves, handling negative rates correctly.
@nchitkara-xai
nchitkara-xai marked this pull request as ready for review August 18, 2026 16:25
@tobbee

tobbee commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

@nchitkara-xai This is an improved API. Thanks!

@tobbee
tobbee merged commit 2087e03 into Eyevinn:master Aug 20, 2026
9 checks passed
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