forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-opusdocs' (01744b26): ec-opus's 21 missing-docs warnings (SilkDecIndices + SilkFrameDiag fields) documented with real semantics -- edith's build is warning-free again through the path dep

Browse files at this commit

da2b9288a7cfd75f1554cdff4ae1cd805165b86bAhmet Kaan GümüşParent: 3a3d412b423eae
crates/ec-opus/src/celt_enc.rsmodified+2 -4
@@ -384,7 +384,7 @@ struct EncBand {
384384 }
385385
386386 /// Per-frame encoder diagnostics for the dropout investigation. Captured at
387-/// the end of [`CeltEncoder::encode`]; read via [`CeltEncoder::last_diag`].
387+/// the end of `CeltEncoder::encode`; read via [`CeltEncoder::last_diag`].
388388 #[derive(Clone, Debug)]
389389 pub struct CeltFrameDiag {
390390 /// Transient flag as coded into the bitstream.
@@ -603,9 +603,7 @@ impl CeltEncoder {
603603 self.channels
604604 }
605605
606- /// Diagnostics captured at the end of the most recent [`encode`] call.
607- ///
608- /// [`encode`]: CeltEncoder::encode
606+ /// Diagnostics captured at the end of the most recent `encode` call.
609607 pub fn last_diag(&self) -> &CeltFrameDiag {
610608 &self.last_diag
611609 }
crates/ec-opus/src/encoder.rsmodified+7 -7
@@ -108,7 +108,7 @@ pub struct Encoder {
108108 /// Scratch space for the SILK packet payload, sized once so the steady-state
109109 /// loop (`steady_state_encode_loop_zero_alloc`) doesn't allocate.
110110 silk_buf: [u8; MAX_SILK_PACKET_BYTES],
111- /// Hybrid: the last [`Encoder::hybrid_silk_delay_48k`] samples of SILK-layer input.
111+ /// Hybrid: the last `Encoder::hybrid_silk_delay_48k` samples of SILK-layer input.
112112 silk_delay: Vec<f32>,
113113 /// Scratch space for the zero-stuffed SILK/hybrid input, sized once so
114114 /// the steady-state loop doesn't allocate a `Vec` per frame.
@@ -241,11 +241,11 @@ impl Encoder {
241241 /// delay compensation, 312 samples at 48 kHz.
242242 /// SILK (10, 20, 40 or 60 ms frames, when the application/bitrate or an
243243 /// explicit [`Encoder::set_mode`] select it — the same
244- /// [`Encoder::silk_choice`] predicate `encode_toc_and_payload` dispatches
244+ /// `Encoder::silk_choice` predicate `encode_toc_and_payload` dispatches
245245 /// on, so this always matches which layer actually codes the frame):
246- /// [`SILK_LOOK_AHEAD_48K_NB`], [`SILK_LOOK_AHEAD_48K_MB`] or
247- /// [`SILK_LOOK_AHEAD_48K_WB`]. Hybrid: CELT's 120, the SILK layer being
248- /// delayed to meet it ([`Encoder::hybrid_silk_delay_48k`]). Any other frame size
246+ /// `SILK_LOOK_AHEAD_48K_NB`, `SILK_LOOK_AHEAD_48K_MB` or
247+ /// `SILK_LOOK_AHEAD_48K_WB`. Hybrid: CELT's 120, the SILK layer being
248+ /// delayed to meet it (`Encoder::hybrid_silk_delay_48k`). Any other frame size
249249 /// falls back to CELT here exactly as `encode_toc_and_payload` does.
250250 pub fn look_ahead(&self, frame_size: usize) -> usize {
251251 let frame_48k = frame_size * self.upsample;
@@ -499,7 +499,7 @@ impl Encoder {
499499
500500 /// Zero-stuffs a mono, `frame_size`-sample native-rate frame up to
501501 /// `frame_size * upsample` samples at 48 kHz, the rate [`SilkEncoder`]
502- /// takes — the same technique [`CeltEncoder::encode`] uses, scaled by
502+ /// takes — the same technique `CeltEncoder::encode` uses, scaled by
503503 /// `upsample` so the passband gain survives the stuffing. Writes into
504504 /// `out` (an `Encoder` scratch field, not a fresh `Vec` per call) rather
505505 /// than returning one, so the caller doesn't allocate every frame; the
@@ -958,7 +958,7 @@ impl Encoder {
958958 /// One hybrid frame (10 or 20 ms, mono or stereo, `bandwidth` SWB or FB)
959959 /// into the internal range coder, returning its byte length: the SILK
960960 /// layer's symbols (WB, 16 kHz internal, fed the input delayed by
961- /// [`Encoder::hybrid_silk_delay_48k`]), the no-redundancy flag under the decoder's
961+ /// `Encoder::hybrid_silk_delay_48k`), the no-redundancy flag under the decoder's
962962 /// exact presence rule, then the CELT layer from band 17 in the same
963963 /// coder. CBR: the packet is the bitrate's size unless SILK alone needs
964964 /// more, in which case CELT keeps [`HYBRID_CELT_MIN_BYTES`] on top.
crates/ec-opus/src/silk.rsmodified+18 -0
@@ -250,17 +250,35 @@ struct Indices {
250250 /// packets against ffmpeg-libopus's.
251251 #[derive(Clone, Debug, Default)]
252252 pub struct SilkDecIndices {
253+ /// 0 = inactive/unvoiced, 1 = unvoiced, 2 = voiced (SILK `SignalType`).
253254 pub signal_type: i32,
255+ /// Quantization offset flavor: 0 = low-bitrate offset, 1 = default offset.
254256 pub quant_offset_type: i32,
257+ /// Per-subframe coded excitation gains; each is an index into the gain
258+ /// dequantization table, not a linear gain.
255259 pub gains: [i8; 4],
260+ /// Quantized normalized LSF coefficients; 17 entries (`MAX_LPC_ORDER + 1`),
261+ /// the last being the interpolated residual-energy weight.
256262 pub nlsf: [i8; 17],
263+ /// Interpolation weight between the previous and current frame's NLSFs,
264+ /// Q2 in [0, 4] (4 = no interpolation).
257265 pub nlsf_interp_coef_q2: i32,
266+ /// Raw pitch lag index; the lag in samples is derived from this plus the
267+ /// frame's lag range and minimum lag.
258268 pub lag_index: i32,
269+ /// Index into the pitch-contour codebook for the current bandwidth and
270+ /// subframe count.
259271 pub contour_index: i32,
272+ /// Periodicity index selecting the LTP filter scaling per subframe.
260273 pub per_index: usize,
274+ /// Per-subframe LTP codebook indices; `usize::MAX` means LTP is off for
275+ /// that subframe.
261276 pub ltp_index: [usize; 4],
277+ /// Index of the LTP gain scaling factor applied to all subframes.
262278 pub ltp_scale_index: usize,
279+ /// Pseudorandom seed for excitation sign/pulse decoding.
263280 pub seed: i32,
281+ /// Diagnostic-only counter of SILK frames this state has decoded.
264282 pub frames_decoded: usize,
265283 }
266284
crates/ec-opus/src/silk_enc_write.rsmodified+12 -1
@@ -1,4 +1,4 @@
1-//! SILK payload writer (subtask D2a): turns the analysis in [`crate::silk_enc`]
1+//! SILK payload writer (subtask D2a): turns the analysis in `crate::silk_enc`
22 //! into decodable SILK packets, NB (8 kHz), MB (12 kHz) or WB (16 kHz).
33 //!
44 //! Symbol order is exactly `silk::decode()`'s, and every decision is made
@@ -42,14 +42,25 @@ const MAX_PULSE: i32 = 1023;
4242 /// call, for the speech-quality diagnostic lane.
4343 #[derive(Clone, Debug, Default)]
4444 pub struct SilkFrameDiag {
45+ /// Whether the VAD classified the input frame as voiced.
4546 pub voiced: bool,
47+ /// SILK signal type chosen by the encoder (0 inactive, 1 unvoiced,
48+ /// 2 voiced).
4649 pub signal_type: i32,
50+ /// Per-subframe gain codebook indices as written to the bitstream.
4751 pub gain_idx: [i8; MAX_NB_SUBFR],
52+ /// Number of subframes in the frame (2 for 10 ms, 4 for 20 ms).
4853 pub nb_subfr: usize,
54+ /// Raw pitch lag index written to the bitstream (first subframe's).
4955 pub lag_index: i32,
56+ /// Pitch lag in samples per subframe as used by the LTP analysis.
5057 pub pitch_l: [i32; MAX_NB_SUBFR],
58+ /// NLSF interpolation coefficient (Q2, 0..4) encoded for this frame.
5159 pub nlsf_interp: i32,
60+ /// Number of payload bytes the frame's encode produced.
5261 pub bytes: usize,
62+ /// Total LTP excitation gain across subframes (linear scale, 0 if the
63+ /// frame had no LTP).
5364 pub ltp_gain: f32,
5465 }
5566