Skip to main content

Module streaming

Module streaming 

Source
Expand description

Phase 6E-C1a — Streaming sliding-window Viterbi prototype + K sweep.

This module is a research prototype for Task #18 (empirical K choice). It is NOT the production §6E-C1a implementation. It exists to:

  1. Validate that sliding-window Viterbi converges to the full-Viterbi reference (stc_embed_inline) at large enough K.
  2. Measure bias (Hamming distance vs reference) and per-position flip-rate divergence at varying K.
  3. Produce the K sweep table that goes into docs/design/h264-encoder-algorithms/streaming-viterbi.md.

Once K is chosen, §6E-C1a will reimplement streaming Viterbi with the chosen K baked in, integrated with ChaCha20 H-column generation, multi-IDR support, and the GOP-parallel Pass 1 + Pass 3 pipeline. This prototype takes pre-built H-hat and works on a single in-memory cover stream.

§Algorithm

Sliding-window (delay-line) Viterbi:

  • Forward pass identical to inline Viterbi (compute curr_cost + back_ptr at each position).
  • When the window reaches K back_ptr entries, commit the oldest position’s bit by tracing back from the current best state through the K-position window.
  • Commits are final — the streaming variant cannot revisit them even if a later position would have changed the optimum.
  • At end of stream, drain the remaining window with full traceback from the final best state (terminal syndrome = 0).

Bias source: positions where the global optimum requires a non-local flip whose payoff propagates beyond K positions.

Structs§

KSweepEntry
KSweepReport

Functions§

run_k_sweep
Empirical K sweep: compares the full-Viterbi reference to sliding-window plans at various K, reports bias metrics.
stc_embed_streaming
Sliding-window streaming Viterbi.