Skip to content

Fix FFmpeg video decoder packet and frame draining - #2195

Draft
darioriccio wants to merge 1 commit into
ossia:masterfrom
darioriccio:codex/preserve-packet-on-decoder-backpressure
Draft

Fix FFmpeg video decoder packet and frame draining#2195
darioriccio wants to merge 1 commit into
ossia:masterfrom
darioriccio:codex/preserve-packet-on-decoder-backpressure

Conversation

@darioriccio

Copy link
Copy Markdown

Summary

  • retry the same AVPacket when avcodec_send_packet reports decoder back-pressure
  • drain every frame made available by a packet before reading the next packet
  • preserve output ordering when one packet yields multiple frames and use the same path for EOF flushing

Root cause

The previous loop consumed the next demuxed packet after avcodec_send_packet returned EAGAIN, even though FFmpeg requires the caller to receive pending frames and retry the unchanged packet. Inter-frame HEVC streams then lost reference packets and repeatedly emitted Could not find ref with POC, eventually freezing.

Verification

  • standalone send/receive probe on the affected HEVC stream: 400/400 frames decoded with the corrected loop, versus 252/400 and reference-frame errors with the previous loop
  • integrated macOS Domeport Pro build using the background VideoDecoder path and hardware decoding disabled: an 8K HEVC video advanced continuously, produced distinct rendered frames, and emitted no HEVC POC/reference errors
  • EOF drain uses the same multi-frame receive path

This is intentionally limited to the background decoder send/receive contract; it does not change renderer selection or UI behavior.

@jcelerier

Copy link
Copy Markdown
Member

hello ! can you check if this works fine on top of #2121 ? as it's a pretty big refactor of all the video part to enable better performance

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.

2 participants