]> git.nihav.org Git - nihav.git/commitdiff
core/dsp: add imdct_half
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 8 Nov 2019 17:15:27 +0000 (18:15 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 8 Nov 2019 17:15:27 +0000 (18:15 +0100)
nihav-core/src/dsp/mdct.rs

index 1a29942f9af092ad681bb00a441fabde55abbe90..f883c7f42e148e536b863c23b89acbd62b189cf7 100644 (file)
@@ -54,4 +54,23 @@ impl IMDCT {
             dst[3 * size4 + 2 * n + 1] = -self.z[size4 - n - 1].re;
         }
     }
+    pub fn imdct_half(&mut self, src: &[f32], dst: &mut [f32]) {
+        let size2 = self.size / 2;
+        let size4 = self.size / 4;
+        let size8 = self.size / 8;
+        for k in 0..size4 {
+            let c = FFTComplex { re: src[size2 - 2 * k - 1], im: src[        2 * k] };
+            self.z[k] = c * self.twiddle[k];
+        }
+        self.fft.do_ifft_inplace(&mut self.z);
+        for k in 0..size4 {
+            self.z[k] *= self.twiddle[k];
+        }
+        for n in 0..size8 {
+            dst[        2 * n]     = -self.z[        n]    .re;
+            dst[        2 * n + 1] =  self.z[size4 - n - 1].im;
+            dst[size4 + 2 * n]     = -self.z[size8 + n]    .re;
+            dst[size4 + 2 * n + 1] =  self.z[size8 - n - 1].im;
+        }
+    }
 }