switch to better FFT interface and more flexible FFT implementation
[nihav.git] / nihav-indeo / src / codecs / imc.rs
index 53ea68600133443ab7a078231ae3d9b0c101fbb7..3bf57f8a36ceb30e892d877a9add102332bf5f9f 100644 (file)
@@ -1,8 +1,6 @@
 use std::mem;
 use std::ptr;
 use std::f32::consts;
-use std::rc::Rc;
-use std::cell::RefCell;
 
 use nihav_core::formats::*;
 use nihav_core::frame::*;
@@ -323,7 +321,7 @@ struct IMCDecoder {
 
     chmap:  NAChannelMap,
     ainfo:  NAAudioInfo,
-    info:   Rc<NACodecInfo>,
+    info:   NACodecInfoRef,
 
     codes:  [[Codebook<u8>; 4]; 4],
     ch_data: [IMCChannel; 2],
@@ -837,7 +835,7 @@ impl IMDCTContext {
             pretwiddle2: pretwiddle2,
             posttwiddle: posttwiddle,
             tmp:         [FFTC_ZERO; COEFFS/2],
-            fft:         FFTBuilder::new_fft(FFTMode::SplitRadix, COEFFS/2),
+            fft:         FFTBuilder::new_fft(COEFFS/2, false),
             window:      window,
         }
     }
@@ -850,7 +848,7 @@ impl IMDCTContext {
             self.tmp[i].re = -(c2 * in1 + c1 * in2);
             self.tmp[i].im =   c1 * in1 - c2 * in2;
         }
-        self.fft.do_fft_inplace(&mut self.tmp, false);
+        self.fft.do_ifft_inplace(&mut self.tmp);
         for i in 0..COEFFS/2 {
             let tmp = !(self.tmp[i] * self.posttwiddle[i]);
             let c1 = self.window[i * 2];
@@ -867,7 +865,7 @@ const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
 const CHMAP_STEREO: [NAChannelType; 2] = [NAChannelType::L, NAChannelType::R];
 
 impl NADecoder for IMCDecoder {
-    fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+    fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
         if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
             self.chmap = NAChannelMap::new();
             match ainfo.get_channels() {
@@ -888,7 +886,7 @@ impl NADecoder for IMCDecoder {
             Err(DecoderError::InvalidData)
         }
     }
-    fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+    fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
         let info = pkt.get_stream().get_info();
         validate!(info.get_properties().is_audio());
         let pktbuf = pkt.get_buffer();
@@ -898,7 +896,7 @@ impl NADecoder for IMCDecoder {
 
         let abuf = alloc_audio_buffer(self.ainfo, duration, self.chmap.clone())?;
         let mut adata = abuf.get_abuf_f32().unwrap();
-        let mut dst = adata.get_data_mut();
+        let dst = adata.get_data_mut().unwrap();
 
         let mut start: usize = 0;
         let channels = self.ainfo.get_channels() as usize;
@@ -922,7 +920,7 @@ impl NADecoder for IMCDecoder {
 
         let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), abuf);
         frm.set_keyframe(true);
-        Ok(Rc::new(RefCell::new(frm)))
+        Ok(frm.into_ref())
     }
 }