EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge pull request #2402 from vangel76/opusenc-pvq-search
BFlat4a060dbb5a55
diff --cc crates/opusenc/src/bands.rsindex cf3c590e8,3e011a5af..f90a554c4--- a/crates/opusenc/src/bands.rs+++ b/crates/opusenc/src/bands.rs@@@ -295,22 -365,29 +366,22 @@@ impl BandEnc<'_, '_>}}-/// Codes all band shapes (`quant_all_bands`, encoder side, long blocks). `x` holds `c` channels-/// of `n` normalised MDCT coefficients each.-#[allow(clippy::too_many_arguments)]-pub fn quant_all_bands(- m: &Mode,- start: usize,- end: usize,- x: &[f32],- n_total: usize,- c: usize,- pulses: &[i32; NB_EBANDS],- spread: usize,- dual_stereo: bool,- intensity: usize,- total_bits: i32,- mut balance: i32,- enc: &mut RangeEncoder,- lm: usize,- coded_bands: usize,-) {+/// Shape-coding controls, independent of the selected band allocation.+pub struct BandCoding {+ pub spread: usize,+ pub total_bits: i32,+}++/// Codes all band shapes (`quant_all_bands`, encoder side, long blocks). `x` holds+/// `frame.channels` channels of `n_total` normalised MDCT coefficients each.+pub fn quant_all_bands(m: &Mode, frame: CeltFrame, x: &[f32], n_total: usize, allocation: &Allocation, coding: BandCoding, enc: &mut RangeEncoder) {+ let CeltFrame { start, end, channels: c, lm } = frame;+ let Allocation { pulses, dual_stereo, intensity, coded_bands, balance, .. } = allocation;+ let (dual_stereo, intensity, coded_bands, mut balance) = (*dual_stereo, *intensity, *coded_bands, *balance);+ let BandCoding { spread, total_bits } = coding;let mm = 1usize << lm;debug_assert!(c == 1 || dual_stereo || intensity <= start, "stereo frames are coded as dual stereo");- let mut ctx = BandEnc { m, enc, i: 0, spread, remaining_bits: 0, pvq_v: Vec::new(), iy: Vec::new(), tmp: Vec::new() };+ let mut ctx = BandEnc { m, enc, i: 0, spread, remaining_bits: 0, iy: Vec::new(), tmp: Vec::new() };for i in start..end {ctx.i = i;let xo = mm * EBANDS[i] as usize;