From 28054d0589c55e94c15c4947cda51c262a9d6097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 21:07:56 +0300 Subject: [PATCH] feat(opus): EC_OPUS_ALIGN=1 turns the libopus input alignment on process-wide The knob is otherwise API-only, so the gate could not sweep it; this is how the rows recorded at set_libopus_input_alignment were produced. --- crates/ec-opus/src/encoder.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ec-opus/src/encoder.rs b/crates/ec-opus/src/encoder.rs index 1b1d3c70..2a1edcd3 100644 --- a/crates/ec-opus/src/encoder.rs +++ b/crates/ec-opus/src/encoder.rs @@ -158,7 +158,7 @@ impl Encoder { "one stream carries at most two channels; use MultistreamEncoder", )); } - Ok(Encoder { + let mut enc = Encoder { celt: CeltEncoder::new(channels, upsample), range: RangeEncoder::new(), sample_rate, @@ -182,7 +182,13 @@ impl Encoder { align_input: false, hp_mem: [0.0; 2], hp_buf: Vec::new(), - }) + }; + // `EC_OPUS_ALIGN=1` turns the alignment on for a whole process — how + // the gate rows at `set_libopus_input_alignment` were produced. + if std::env::var_os("EC_OPUS_ALIGN").is_some() { + enc.set_libopus_input_alignment(true); + } + Ok(enc) } /// Overrides the automatic SILK/Hybrid/CELT choice `wants_silk` and