Skip to main content

Module running_stats

Module running_stats 

Source
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

TypeAlgorithmNotes
RunningStatsWelford online algorithmNumerically stable mean + variance
EwmaExponential weighted moving averageConfigurable α
RollingWindowFixed-size circular bufferExact sliding-window mean / stddev
PercentileEstimatorP² 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§

BitrateRunningAnalyzer
A composite analyzer that tracks per-frame bitrate statistics across a single encode pass using all available online estimators.
BitrateSummary
Point-in-time bitrate statistics produced by BitrateRunningAnalyzer.
Ewma
Exponentially weighted moving average (EWMA).
PercentileEstimator
P² algorithm for online quantile estimation with O(1) memory per quantile.
RollingWindow
Exact sliding-window mean and variance over the last capacity samples.
RunningStats
Numerically-stable online mean and variance using Welford’s algorithm.