Skip to content

RFI Recovery Frames - #62

Merged
hgaiser merged 3 commits into
hgaiser:mainfrom
porkloin:rfi-recovery-frames
Nov 18, 2026
Merged

hgaiser merged 3 commits into
hgaiser:mainfrom
porkloin:rfi-recovery-frames

Conversation

@porkloin

Copy link
Copy Markdown
Contributor

Lets a streaming host recover from a lost frame without an IDR, and tell the client which frame recovers.

  • EncodeConfig::with_active_reference_frames(n): predict from n references while keeping the whole DPB window for invalidation. On RADV, H.264 takes about 75% longer per frame with two references than with one.
  • EncodedPacket::is_recovery_frame: set on the first frame after an invalidation that recovers without a keyframe (Moonlight's frame type 5).
  • Breaking: Encoder::invalidate_reference_frames now returns bool: false means no reference survived and the next frame is an IDR. Needs a 0.13.0 release.

Testing

  • tests/rfi.rs updated and passing on a 7900 XTX (RADV); b_frames adjusted for the new API.
  • rate_control_changes (H.264 + B-frames) fails, but identically on plain main (92c6275), so it's not from this change.
  • End to end through Moonshine with moonshine-test-headless, over loopback (full results in the Moonshine PR . Settings: HEVC, 1080p120, 40 ms simulated client latency, simulated frame dropped every 120): all 18 drops recovered with recovery frames and 1 keyframe was sent, against 127 keyframes with Moonshine's current main.

Known limit

AV1's window is capped at 7 references (NUM_REF_FRAMES = 8), about 58 ms at 120 fps, so at higher RTT AV1 falls back to IDRs. Spacing the older AV1 references out is a possible follow-up, not in this PR.

@hgaiser

hgaiser commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Nice!

@hgaiser
hgaiser merged commit dccc6d0 into hgaiser:main Nov 18, 2026
7 checks passed
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