Expand description
Online running statistics for bitrate estimation optimisation.
This module provides zero-allocation, single-pass statistical accumulators
that can be used instead of buffering the entire sample set. The primary
use-case is per-frame bitrate analysis inside the bitrate_estimator
pipeline: rather than storing every frame’s QP/bits and computing
statistics at the end of a full pass, callers update an accumulator for
each encoded frame and query the current statistics at any time.
§Algorithms
| Type | Algorithm | Notes |
|---|---|---|
RunningStats | Welford online algorithm | Numerically stable mean + variance |
Ewma | Exponential weighted moving average | Configurable α |
RollingWindow | Fixed-size circular buffer | Exact sliding-window mean / stddev |
PercentileEstimator | P² algorithm (Jain & Chlamtac 1985) | O(1) memory per quantile |
§Example
use oximedia_transcode::running_stats::{RunningStats, Ewma};
let mut stats = RunningStats::new();
for bits in [4_000u64, 5_000, 6_000, 4_500, 5_500] {
stats.push(bits as f64);
}
assert!((stats.mean() - 5_000.0).abs() < 1.0);
let mut ewma = Ewma::new(0.1);
ewma.update(100.0);
ewma.update(200.0);
assert!(ewma.value() > 100.0);Structs§
- Bitrate
Running Analyzer - A composite analyzer that tracks per-frame bitrate statistics across a single encode pass using all available online estimators.
- Bitrate
Summary - Point-in-time bitrate statistics produced by
BitrateRunningAnalyzer. - Ewma
- Exponentially weighted moving average (EWMA).
- Percentile
Estimator - P² algorithm for online quantile estimation with O(1) memory per quantile.
- Rolling
Window - Exact sliding-window mean and variance over the last
capacitysamples. - Running
Stats - Numerically-stable online mean and variance using Welford’s algorithm.