Skip to content

Conversation

NicolasHug
Copy link
Contributor

In main, we have 2 different fields to indicate where the user requested a seek:

  • The desiredPtsSeconds_ field of the decoder
  • The discardFramesBeforePts field of active stream's streamInfo

They both morally represent the exact same thing. But one's a std::optional<double>, the other one's an int_64_t. One is set in setCursorPtsInSeconds, the other one is set in decodeAVFrame().

This is all pretty confusing, so this PR simplify things: there is now only one single cursor_ field, for the decoder, and it's set in one single place.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 9, 2025
if (cursorWasJustSet_) {
maybeSeekToBeforeDesiredPts();
desiredPtsSeconds_ = std::nullopt;
cursorWasJustSet_ = false;
Copy link
Contributor Author

@NicolasHug NicolasHug Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly fond of this logic, but don't shoot the messenger. This PR is only making an existing stateful logic a little bit more obvious. I.e. now we have an obvious bool field, while before we had a slightly obscure std::optional logic.

We could try to simplify this further, I gave it a quick try but our tests failed in some weird edge-cases, so I'm leaving this for later.

@scotts
Copy link
Contributor

scotts commented Mar 10, 2025

This is great! I also tried simplifying this logic in PR #262, but I abandoned it because I there was concern it would undo the lazy behavior that we want. Now that we've simplified other stuff, and there's only one active stream, I think this is obviously maintaining the lazy behavior we want.

@NicolasHug NicolasHug merged commit 374d950 into meta-pytorch:main Mar 10, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants