Skip to main content

decide_hw_fullframe

Function decide_hw_fullframe 

Source
pub fn decide_hw_fullframe(
    st: &mut StripeState,
    settings: &RustCaptureSettings,
    frame_counter: u16,
    is_dirty: bool,
    is_animated: bool,
    requested_idr: bool,
) -> HwFrameDecision
Expand description

The send / quality / keyframe policy every full-frame H.264 encoder obeys.

A static screen costs almost nothing to stream; a client that just joined or reset can always recover a clean picture. The GOP is left infinite and an IDR is forced only when a consumer genuinely needs a fresh decode entry point. Every forced IDR is followed by a short “recovery burst” that keeps streaming until rate control converges. Both hardware encoders (NVENC / VAAPI) share this one function so they cannot drift apart; the software path applies the same policy per stripe inside encode_cpu.

Priority order: (1) recovery burst in progress, (2) always-on streaming/animated modes, (3) motion detected, (4) recovery keyframe on static screen, (5) paint-over refresh.

§Arguments

  • st - Per-stripe mutable state carrying paint-over and burst bookkeeping.
  • settings - Capture settings; reads CRF, paint-over CRF, burst frames, trigger frames, streaming mode, and keyframe interval.
  • frame_counter - Current frame number (wrapping u16).
  • is_dirty - Motion signal from the backend (compositor damage or stripe-hash change).
  • is_animated - Forces a send for animated overlays.
  • requested_idr - On-demand IDR request (client join / reset / recording cadence).

§Returns

HwFrameDecision with send (whether to encode this frame), force_idr (force a keyframe), and target_qp (quality target for rate control).