feat: DRED (Deep REDundancy) per-channel toggle

Adds Opus 1.6 DRED support end-to-end: encoder embeds 20 ms of ML
redundancy in every packet when enabled; decoder recovers lost frames
from the next buffered packet's DRED extension rather than falling back
to PLC comfort noise.

Protocol: bool dred = 11 added to AudioConfig (backward-compatible,
defaults false). C ABI: int dred added to vc_audio_config. Encoder:
OPUS_SET_DRED_DURATION(2) when dred=true. Decoder: OpusDREDDecoder +
per-stream OpusDRED scratch pre-allocated off the RT thread;
JitterBuffer::try_copy_front_payload peeks at the next packet without
popping on every PLC step; opus_decoder_dred_decode reconstructs the
lost frame if DRED data is present, otherwise falls back to PLC.

New test: test_dred_toggle (22/22 ctest green).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 13:40:47 +02:00
parent de2c253199
commit fdcd8d1427
13 changed files with 412 additions and 7 deletions

View File

@@ -111,9 +111,14 @@ Layered, all configurable per channel:
unrecovered loss; always on, free.
3. **DTX** — sender stops transmitting during silence and sends sparse comfort-noise
updates; cuts bandwidth and is bandwidth-friendly on busy channels.
4. **DRED (Deep REDundancy, optional/feature-gated)** — Opus 1.6's ML redundancy carries
acoustic features so the decoder can reconstruct longer loss bursts. Heavier CPU; gate
behind a `features` flag and per-channel toggle, off by default.
4. **DRED (Deep REDundancy, per-channel toggle)** — Opus 1.6's ML redundancy: the encoder
embeds 20 ms of acoustic features in every packet (`bool dred` in `AudioConfig`, off by
default). When a packet is lost, the receiver peeks at the next already-buffered packet,
parses its DRED extension (`opus_dred_parse`), and reconstructs the lost frame with
`opus_decoder_dred_decode` — producing significantly better audio than PLC comfort noise
for single-frame gaps. Falls back silently to PLC if the next packet has not arrived yet
or if the sender did not embed DRED. Heavier CPU on the encoder (~510 % at 24 kbps);
minimal overhead on the decoder (parse is a fast header check on non-DRED packets).
## 5. Jitter buffer