VIDEO: Check validity of granulepos in TheoraVideoTrack::decodePacket - #7427
Merged
Conversation
A fix was introduced in 43c5d3e, which adds handling for dropped frames in theora decoding. However, this didn't handle the case where the granule position for the current packet is invalid. These changes introduce a check on the granule position of the current packet. If the granule position is valid, proceed to properly calculate the frame number and the next frame start time from the granule position. If the granule position is not valid, use best estimation of for these values. These changes also refactor to combine the checks for the two cases where the granule position is passed to theora functions. The documentation for both of these functions states that they will return -1 in the case that the provided granule position is negative.
Member
|
Nice catch, thanks! |
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.
A fix was introduced in 43c5d3e, which adds handling for dropped frames in theora decoding. However, this didn't handle the case where the granule position for the current packet is invalid.
These changes introduce a check on the granule position of the current packet. If the granule position is valid, proceed to properly calculate the frame number and the next frame start time from the granule position. If the granule position is not valid, use best estimation of for these values.
These changes also refactor to combine the checks for the two cases where the granule position is passed to theora functions. The documentation for both of these functions states that they will return -1 in the case that the provided granule position is negative.
Background
I was trying to play Syberia on ScummVM v2026.2.0, and found it unplayable due to the choppy video playback in the main menu and intro video, which also seemingly affects the UI in the game with high latency.
I found v2026.1.0 worked OK, so did a git bisect to locate the commit which introduced the problem for me as 43c5d3e.
Through some debugging I could see that
oggPacket.granuleposwas often-1, which led to_curFramebeing reset to-1frequently throughout video playback. It seems that the code below for calculating_nextFrameStartTimewas handling this case, so I applied a similar fix to callingth_granule_frame, but switching the condition to be onoggPacket.granuleposrather than calling the function and checking if the result is invalid. I think this is a reasonable change, having read the documentation forth_granule_frameandth_granule_time, but I can change the approach to check the result of the function call rather than its input if that is preferable.