-
-
Notifications
You must be signed in to change notification settings - Fork 29
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 calculation of frame rate in JRSR parser #1638
Comments
I've tested your code in my local environment just now, and while it does work as intended, it seems
This was an "issue" on the old site, which had a different parser. Although if I recall correctly, it just ignored the frame count altogether, so the total run time is still correct. |
Yes, I would prefer a PR that casts as double like you show here |
Computing Since you have to compute Ignoring the loss of precision, the way the current code divides by 16666667 ns is a roundabout way to express what it's really doing: multiplying by 60 Hz. I think it's more clear if the code actually says I noted an error in a comment in the patch I originally posted. It should have said "divided by", not "multiplied by". Here is a revision. |
In the current code, would dividing Although I personally don't think it matters either way, considering most DOS games run at closer to 70 FPS anyway (according to JPC-RR). |
Yes—which is what the suggested patch does.
is the same as
which is the same as
Right. This invention of a frame count and framerate is a complete fiction on the part of the parser. JRSR has no notion of frames, only nanoseconds. I can only guess that it works this way because other parts of the site code have a requirement that movie duration be expressed in the form num_frames / frame_rate. In terms of getting the correct total duration, it's true that the frame count doesn't matter, as the frame rate can always be adjusted appropriately. If all that matters is the total duration, it would be enough to always set |
Feel free to open a PR with your fixes. Though I did notice one small error which I forgot to tell you, my bad on that (it's supposed to be |
This was fixed with the merged PR |
@fsvgm777 discovered that
Frames
andFrameRateOverride
get set such thatFrames / FrameRateOverride
is not quite equal to the total movie duration. This is because the computation uses integer math that loses precision in intermediate results. The bug exists before and after #1062, which overhauled the parser.You can see this in the fact that JRSR movies since the new site was inaugurated have an exact integer frame rate, whereas earlier movies have a frame rate that is close to 60.0 but not exactly equal, such that multiplying the frame rate by the number of frames gives the correct total duration. The exception is 6944, which I can't explain: besides the integer frame rate, the frame count should be 23458, not 23459, if computed by the formula in the code as I understand it.
I do not have a dev environment set up, so I won't make a pull request, but something like the patch below should fix it. It's possible some tests will have to be adjusted. The change also avoids a divide-by-zero when the move is less than 1 second long. (
if (lastNonSpecialTimestamp > 0)
looks like it was trying to avoid division by zero, but it was inadequate, becauselastNonSpecialTimestamp / 1000000000L
could still be zero.)The text was updated successfully, but these errors were encountered: