Replay from a key frame after hardware decoder send fallback - #93
Replay from a key frame after hardware decoder send fallback#93Blackspirits wants to merge 2 commits into
Conversation
Blackspirits
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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_packetfailure 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 performsPerformSeek, 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:
Validation
c77c4b428649ce7030e6cf218b4d7c384b955232FfmpegPlayer.csAI assistance: ChatGPT was used to adversarially review asynchronous demux/decoder serial ordering after hardware fallback.