]> git.nihav.org Git - nihav.git/blobdiff - src/codecs/real/cook.rs
Rust2018: use new addressing scheme
[nihav.git] / src / codecs / real / cook.rs
index d8e63ce200caf340596cab8e8c27af9776b703fd..2fcff98f6dc312a7c92a8b5782339d0a550e85d3 100644 (file)
@@ -1,12 +1,12 @@
-use formats::*;
-use frame::*;
+use crate::formats::*;
+use crate::frame::*;
 use super::super::*;
-use dsp::fft::FFTMode;
-use dsp::mdct::IMDCT;
-use io::bitreader::*;
-use io::byteio::{ByteReader, MemoryReader};
-use io::codebook::*;
-use io::intcode::*;
+use crate::dsp::fft::FFTMode;
+use crate::dsp::mdct::IMDCT;
+use crate::io::bitreader::*;
+use crate::io::byteio::{ByteReader, MemoryReader};
+use crate::io::codebook::*;
+use crate::io::intcode::*;
 use std::f32::consts;
 use std::mem::swap;
 
@@ -112,7 +112,7 @@ impl CookDSP {
             gain_tab[i] = pow_tab[i + 53].powf(8.0 / fsamples);
         }
         let size = samples;
-        CookDSP { imdct: IMDCT::new(FFTMode::SplitRadix, samples*2), window: window, out: [0.0; 2048], size, pow_tab, hpow_tab, gain_tab }
+        CookDSP { imdct: IMDCT::new(FFTMode::SplitRadix, samples*2, false), window: window, out: [0.0; 2048], size, pow_tab, hpow_tab, gain_tab }
     }
 }
 
@@ -143,7 +143,7 @@ struct CookChannelPair {
     decouple:       [u8; BAND_SIZE],
     category:       [u8; MAX_SUBBANDS * 2],
 
-    block:          [[f32; MAX_SAMPLES]; 2],
+    block:          [[f32; MAX_SAMPLES * 2]; 2],
     delay:          [[f32; MAX_SAMPLES]; 2],
     gains:          [[i32; 9]; 2],
     prev_gains:     [[i32; 9]; 2],
@@ -164,7 +164,7 @@ impl CookChannelPair {
             decouple:       [0; BAND_SIZE],
             category:       [0; MAX_SUBBANDS * 2],
 
-            block:          [[0.0; MAX_SAMPLES]; 2],
+            block:          [[0.0; MAX_SAMPLES * 2]; 2],
             delay:          [[0.0; MAX_SAMPLES]; 2],
             gains:          [[0; 9]; 2],
             prev_gains:     [[0; 9]; 2],
@@ -309,7 +309,7 @@ impl CookChannelPair {
         validate!(num_gains <= 8);
 
         swap(&mut self.gains[channel], &mut self.prev_gains[channel]);
-        self.block[channel] = [0.0; MAX_SAMPLES];
+        self.block[channel] = [0.0; MAX_SAMPLES * 2];
 
         // gains
         let mut ipos = 0;
@@ -367,7 +367,7 @@ impl CookChannelPair {
         self.bitalloc(num_vectors, br.left() as usize);
 
         // coefficients
-        self.block[channel] = [0.0; MAX_SAMPLES];
+        self.block[channel] = [0.0; MAX_SAMPLES * 2];
         let mut off = 0;
         for sb in 0..tot_subbands {
             let mut coef_index: [u8; BAND_SIZE] = [0; BAND_SIZE];
@@ -568,6 +568,7 @@ impl NADecoder for CookDecoder {
                         self.pairs[0].read_hdr_v1(&mut br)?;
                         self.channels = self.pairs[0].mode.get_channels();
                         if ainfo.get_channels() == 1 { // forced mono
+                            self.pairs[0].mode = Mode::Mono;
                             self.channels       = 1;
                             chmap = 0x4;
                         } else {
@@ -677,7 +678,7 @@ pub fn get_decoder() -> Box<NADecoder> {
 
 #[cfg(test)]
 mod test {
-    use test::dec_video::*;
+    use crate::test::dec_video::*;
     #[test]
     fn test_cook() {
 //        let file = "assets/RV/rv30_weighted_mc.rm";