Replay from a key frame after VideoToolbox send fallback - #90
Closed
Blackspirits wants to merge 1 commit into
Closed
Replay from a key frame after VideoToolbox send fallback#90Blackspirits wants to merge 1 commit into
Blackspirits wants to merge 1 commit into
Conversation
Blackspirits
commented
Sep 13, 2026
Blackspirits
left a comment
Owner
Author
There was a problem hiding this comment.
Independent adversarial re-check: the send-packet hardware-failure path had diverged from the receive/transfer fallback after the rejected packet was already freed. The final diff restores the same replay contract by seeking from the current position after reopening software decoding. Full CI #34771533047 passed restore, build and the complete suite on the first run; UITests reported 5,150 passed, 9 skipped and 0 failed. macOS VideoToolbox failure injection is not exercised by Linux CI, but the control-flow defect is deterministic from the packet lifetime and existing fallback contract. No blocker identified. Keep draft; no merge performed.
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The new VideoToolbox decoder fallback handles two classes of hardware failure differently.
When
avcodec_receive_frameorav_hwframe_transfer_datafails, the player reopens the decoder in software and callsSeek(Position), which gives the demuxer a new serial, seeks backward, flushes packet/frame queues and replays from a key frame.When
avcodec_send_packetfails, however, the code reopens the decoder in software, sets only the video loop's localserial = -1, frees the rejected packet and continues with the next already-demuxed packet. A fresh software decoder can therefore start in the middle of a GOP without the reference frames required by that packet.This change makes the send-packet failure path use the same recovery contract as the other VideoToolbox failures:
Seek(Position)so demux replays from a key frame.Validation
f67b07f5b143fa47c87255ca1c3ed7adb3bd7142FfmpegPlayer.csPerformSeek: it callsav_seek_frame(..., AVSEEK_FLAG_BACKWARD), advances the serial and flushes video/audio/frame queuesAI assistance: ChatGPT was used to adversarially review the newly merged VideoToolbox fallback paths and identify the missing demux replay after a hardware
avcodec_send_packetfailure.