Expand description
Frame/chunk-parallel Opus encoding (R1) — the structural win that beats a single-threaded libopus on wall-clock.
Opus carries real inter-frame state (SILK LTP/NSQ/NLSF/entropy, CELT
pre-emphasis/overlap/prefilter/energy, the HP filter and input resampler), so
a frame range cannot be encoded byte-identically from a cold encoder the way
AAC/Vorbis frames can. Instead each worker primes its encoder by
re-encoding warmup frames before its chunk (output discarded), which
converges the state to the true continuous state — a stable encoder forgets
its initial conditions over a few frames. The primed boundary is
perceptually-neutral (PEAQ ΔODG ≤ 0.03 vs serial), not byte-identical, so this
is an opt-in fast path, gated perceptually.
Deterministic: fixed chunk boundaries → identical output across runs. Uses
only std::thread (no rayon).
Structs§
- Parallel
Config - Configuration for a parallel encode; mirrors the knobs on
OpusEncoder.
Functions§
- encode_
parallel - Encode
pcm(interleaved f32,channels-interleaved) inframe_sizesamples-per-channel frames, acrosscfg.threadsworkers, returning one Opus packet per frame in order. Falls back to a single serial encoder when the input is too small to split usefully. - encode_
serial - Single-threaded reference: encode every frame with one continuous encoder.
The correctness/quality anchor for
encode_parallel. - encode_
streams - R1a — per-stream parallelism (byte-identical). Encode several independent
PCM streams concurrently, one serial encoder per worker. Each stream’s output
is exactly its serial encode (no chunk seams), so this is bit-identical to
encoding them one-by-one — the right tool for batch/many-stream workloads
(and for short streams too small to split internally with
encode_parallel).