switch to better FFT interface and more flexible FFT implementation
[nihav.git] / nihav-commonfmt / src / codecs / ts102366.rs
index a82624d205a129e292c9ff3fe0318f51c564ec5d..4858eaa05b00c4044587c62adea07e8e456e4bcc 100644 (file)
@@ -1,5 +1,3 @@
-use std::rc::Rc;
-use std::cell::RefCell;
 use nihav_core::formats::*;
 use nihav_core::frame::*;
 use nihav_core::codecs::*;
@@ -44,7 +42,7 @@ impl IMDCTContext {
             xsincos[k].re = -factor.cos();
             xsincos[k].im = -factor.sin();
         }
-        let fft = FFTBuilder::new_fft(FFTMode::SplitRadix, size/4);
+        let fft = FFTBuilder::new_fft(size/4, false);
         IMDCTContext { xsincos: xsincos, size: size, fft: fft }
     }
     #[allow(non_snake_case)]
@@ -109,14 +107,14 @@ fn do_imdct_core(fft: &mut FFT, xsc: &[FFTComplex; BLOCK_LEN/2], size: usize, il
         let c = FFTComplex { re: c0, im: c1 };
         z[k] = c * xsc[k];
     }
-    fft.do_fft_inplace(z, false);
+    fft.do_ifft_inplace(z);
     for k in 0..N4 {
         y[k] = z[k] * xsc[k];
     }
 }
 
 struct AudioDecoder {
-    info:       Rc<NACodecInfo>,
+    info:       NACodecInfoRef,
     ablk:       AudioBlock,
     imdct512:   IMDCTContext,
     imdct256:   IMDCTContext,
@@ -1159,7 +1157,7 @@ impl AudioBlock {
 }
 
 impl NADecoder for AudioDecoder {
-    fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+    fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
         if let NACodecTypeInfo::Audio(_) = info.get_properties() {
             self.info = info.clone();
             Ok(())
@@ -1167,7 +1165,7 @@ impl NADecoder for AudioDecoder {
             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();
@@ -1201,7 +1199,7 @@ impl NADecoder for AudioDecoder {
 
         let abuf = alloc_audio_buffer(ainfo, duration, bsi.acmod.get_channel_map(bsi.lfeon))?;
         let mut adata = abuf.get_abuf_f32().unwrap();
-        let mut output = adata.get_data_mut();
+        let output = adata.get_data_mut().unwrap();
 
         self.ablk = AudioBlock::new();
         for blk in 0..NBLOCKS {
@@ -1237,7 +1235,7 @@ impl NADecoder for AudioDecoder {
 
         let mut frm = NAFrame::new_from_pkt(pkt, self.info.replace_info(NACodecTypeInfo::Audio(ainfo)), abuf);
         frm.set_keyframe(true);
-        Ok(Rc::new(RefCell::new(frm)))
+        Ok(frm.into_ref())
     }
 }