-
Notifications
You must be signed in to change notification settings - Fork 107
videosource: Prevent SeekTo() from targeting negative frame numbers #456
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
base: master
Are you sure you want to change the base?
Conversation
This prevents an exception from being thrown if -SeekOffset > n, which can occur if the first frame is skipped by FrameFromPTS.
c407657 to
1364262
Compare
|
Tagging @arch1t3cht in this since I know you have a big regression suite you run (and I think you're the original author). |
No, its just autotools that use c++11 Line 19 in 6601f8c
|
|
Do you have an example file triggering this? That'd make it easier to find out where exactly the current logic is going wrong. It's hard to know for sure without an example file, but to me it feels like this should be fixed elsewhere instead, like for example in the It's been over a year so I don't remember all the details, but the "The first frame after seeking being hidden" seems to be the case we're running into here, so it may be time to look into whether |
|
@arch1t3cht here is a 10mb cut (simple |
01cae89 added the AllowHidden parameter to FrameFromPTS/Pos to be able to recognize the current packet in DecodePacket, but kept it set to false in the other invocations to change as little existing behavior as possible. However, it looks like it's actually correct to also allow hidden frames in the other invocations in GetFrame, since those call FrameFromPTS to find out what packet the demuxer ended up at after a seek. FFMS#456 shows a file where this makes a difference, since its first few frames are marked as hidden. Setting AllowHidden to true everywhere in the decoding loop (just not in GetFrameByTime) also causes no regressions on the Doom9 seeking sample collection (https://forum.doom9.org/showthread.php?p=1992736#post1992736).
|
Thanks. This is indeed fixed by also including hidden frames in GetFrameFromPTS/Pos everywhere in GetFrame, and I confirmed that this doesn't cause any regressions on my set of samples, so I'd propose to fix this that way instead. I'll send a PR in a second. |
|
I know it's not ideal because it still decreases the seek offset and keeps it there, I just went with the solution that I found least likely to cause side effects, and I think it makes sense to set a minimum |
This prevents an exception from being thrown if the source's first frame is marked as skipped. The initial seek call ignores this, but 6467a17 forces a reseek and calls
FFMS_Track::FrameFromPTS()withAllowHiddenset to false. This leads it to return -1, andGetFrame()then decreasesSeekOffsetto -10. WhenSeekTo()is called again, the offset points it to a negative frame number, and it throws the exception. By clampingTargetFrameinSeekTo()to [0, n + SeekOffset, ], subsequent seek calls can target the first frame or keyframe again and continue decoding normally.(Can't replace
std::min()andstd::max()withstd::clamp()because the CI runner doesn't support C++17 it seems.)