Skip to content

Replay from a key frame after hardware decoder send fallback - #93

Draft
Blackspirits wants to merge 2 commits into
upl/review-base-c77cfrom
fix/hardware-send-fallback-replay-c77c
Draft

Replay from a key frame after hardware decoder send fallback#93
Blackspirits wants to merge 2 commits into
upl/review-base-c77cfrom
fix/hardware-send-fallback-replay-c77c

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 13, 2026

Copy link
Copy Markdown
Owner

Summary

Hardware decoder fallback reopens the video decoder in software after a D3D11VA, DXVA2 or VideoToolbox failure. The compressed packet that triggered an avcodec_send_packet failure has already been freed, so recovery must replay from a key frame.

There is an additional ordering requirement: Seek(...) is asynchronous. Before the demux thread performs PerformSeek, the video thread can still pop already-demuxed packets from the failed serial. Feeding those packets to the freshly opened software decoder can resume in the middle of the same GOP the fallback was meant to abandon.

This revision:

  • requests a seek/replay for both send-packet and receive/transfer hardware failures;
  • records the new requested serial;
  • discards already-demuxed packets whose serial is older than that replay;
  • accepts a higher serial if a user seek supersedes the fallback seek;
  • flushes already-queued video frames from the failed serial immediately;
  • resumes normal decoding only from the fresh seek serial (or newer).

Validation

  • based on upstream c77c4b428649ce7030e6cf218b4d7c384b955232
  • supersedes the older one-line replay revision and draft Replay from a key frame after VideoToolbox send fallback #90
  • diff is limited to FfmpegPlayer.cs
  • revised full solution restore passed
  • revised full solution build passed
  • revised full solution test suite passed on the first run
  • UI suite: 5,151 passed, 9 skipped, 0 failed (5,160 total)
  • retry step was not used
  • validation run: #34779745073

AI assistance: ChatGPT was used to adversarially review asynchronous demux/decoder serial ordering after hardware fallback.

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent adversarial re-check on current upstream: the send-packet fallback still freed the rejected compressed packet before reopening software decoding, so without a seek the new decoder could resume mid-GOP. The one-line replay now matches the existing receive/transfer failure contract and applies equally to VideoToolbox, D3D11VA and DXVA2. Full CI #34778786895 passed restore, build and the complete suite on the first run; UITests reported 5,151 passed, 9 skipped, 0 failed. Retry was not used. No blocker identified. Keep draft; no merge performed.

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent adversarial re-check of the revised replay contract: Seek is asynchronous, so simply requesting a replay was insufficient; already-demuxed packets from the failed hardware serial could still reach the fresh software decoder before PerformSeek ran. The final revision records the requested replay serial, drops older queued packets, flushes queued video frames, and accepts a newer serial when a user seek supersedes the fallback. This closes the mid-GOP race for both send-packet and receive/transfer hardware failures. Full CI #34779745073 passed restore, build and the complete suite on the first run; UITests reported 5,151 passed, 9 skipped, 0 failed. Retry was not used. No blocker identified. Keep draft; no merge performed.

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent adversarial re-check of the revised fallback: the earlier one-line Seek(Position) still allowed already-demuxed packets from the failed serial to reach the fresh software decoder before PerformSeek ran. The final revision closes that ordering race by recording the requested replay serial, discarding older queued packets, flushing stale video frames, and accepting a higher serial if a user seek supersedes the fallback. Full CI #34779745073 passed restore, build and the complete suite on the first run; UITests reported 5,151 passed, 9 skipped, 0 failed. Retry was not used. No blocker identified. Keep draft; no merge performed.

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