aac: support Program Config Element a bit
[nihav.git] / nihav-mpeg / src / codecs / aac / mod.rs
index 7233f52ebbb361b2305c23b14ee2d72267e526fd..de9fbe5e1882f901d8b917bc43545c89870bba83 100644 (file)
@@ -11,6 +11,7 @@ mod coeff_read;
 use coeff_read::*;
 mod info;
 use info::*;
+#[allow(clippy::excessive_precision)]
 mod tables;
 use tables::*;
 mod tools;
@@ -201,6 +202,13 @@ impl ICS {
         self.coeffs = [0.0; 1024];
         decode_spectrum(br, &mut self.coeffs, &self.scales, &self.info, &self.sbinfo, &self.sfb_cb, codebooks)
     }
+    fn iquant(val: f32) -> f32 {
+        if val < 0.0 {
+            -((-val).powf(4.0 / 3.0))
+        } else {
+            val.powf(4.0 / 3.0)
+        }
+    }
     fn place_pulses(&mut self) {
         if let Some(ref pdata) = self.pulse_data {
             if pdata.pulse_start_sfb >= self.sbinfo.long_bands.len() - 1 { return; }
@@ -220,7 +228,7 @@ impl ICS {
                 } else {
                     base -= f32::from(pdata.pulse_amp[pno]);
                 }
-                self.coeffs[k] = iquant(base) * scale;
+                self.coeffs[k] = Self::iquant(base) * scale;
             }
         }
     }
@@ -562,7 +570,7 @@ impl AACDecoder {
                                                           br.skip(count * 8)?; // no SBR payload or such
                     },
                 5 => { // ID_PCE
-                        unimplemented!("program config");
+                        skimp_through_program_config_element(br)?;
                     },
                 6 => { // ID_FIL
                         let mut count                   = br.read(4)? as usize;