Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sample time calculation for times >= 2^32. #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix sample time calculation for times >= 2^32. #24

wants to merge 1 commit into from

Conversation

enzo1982
Copy link

An issue handling long MP4 files containing audio books with hundreds of chapters was reported by a fre:ac user. Turned out the issue is with MP4v2.

In MP4Track::GetSampleTimes and MP4Track::GetSampleIdFromTime, sampleCount is a 32 bit value that is later multiplied by sampleDelta in 32 bit math. We need this multiplication to happen in 64 bit math to handle long tracks, so promote sampleCount to a 64 bit variable.

An alternative solution would be to add casts to uint64_t where the multiplications happen, but changing the value type seemed more elegant to me. If you prefer it the other way, I can change this PR accordingly.

In MP4Track::GetSampleTimes and MP4Track::GetSampleIdFromTime, sampleCount is a 32 bit value that is later multiplied by sampleDelta in 32 bit math. We need this multiplication to happen in 64 bit math to handle long tracks, so promote sampleCount to a 64 bit variable.
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.

1 participant