Remove TODOs
This commit is contained in:
parent
132f8925f4
commit
aaf1e99ce8
|
@ -2,13 +2,14 @@ use bitflags::bitflags;
|
|||
use tool_helper::{raw::RawConversion, Error};
|
||||
|
||||
#[repr(packed)]
|
||||
#[derive(Clone)]
|
||||
// TODO: Move logic of fixed values into the raw function, including the BE/LE stuff?
|
||||
pub struct VAGHeader {
|
||||
_id: [u8; 4],
|
||||
_version: u32,
|
||||
version: u32,
|
||||
_reserved: u32,
|
||||
_data_size: u32,
|
||||
_sampling_frequency: u32,
|
||||
data_size: u32,
|
||||
sampling_frequency: u32,
|
||||
_reserved2: [u8; 12],
|
||||
_name: [u8; 16]
|
||||
}
|
||||
|
@ -40,10 +41,10 @@ impl VAGHeader {
|
|||
|
||||
Ok(VAGHeader{
|
||||
_id: VAGHeader::ID,
|
||||
_version: VAGHeader::VERSION.to_be(),
|
||||
version: VAGHeader::VERSION,
|
||||
_reserved: VAGHeader::RESERVED,
|
||||
_data_size: data_size.to_be(),
|
||||
_sampling_frequency: sampling_frequency.to_be(),
|
||||
data_size: data_size,
|
||||
sampling_frequency: sampling_frequency,
|
||||
_reserved2: VAGHeader::RESERVED2,
|
||||
_name: name
|
||||
})
|
||||
|
@ -53,7 +54,13 @@ impl VAGHeader {
|
|||
impl RawConversion<{VAGHeader::SIZE}> for VAGHeader {
|
||||
fn convert_to_raw(&self) -> [u8; VAGHeader::SIZE] {
|
||||
unsafe {
|
||||
let data: [u8; VAGHeader::SIZE] = std::mem::transmute_copy(&self as &VAGHeader);
|
||||
let mut vag_header = self.clone();
|
||||
|
||||
vag_header.version = self.version.to_be();
|
||||
vag_header.data_size = self.data_size.to_be();
|
||||
vag_header.sampling_frequency = self.sampling_frequency.to_be();
|
||||
|
||||
let data: [u8; VAGHeader::SIZE] = std::mem::transmute(vag_header);
|
||||
data
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,21 +218,6 @@ fn resample(input: InternalAudioSamples, target_frequency: u32) -> Result<Intern
|
|||
let end = start + new_sample_len;
|
||||
*channel = channel[start..end].into();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
let spec = hound::WavSpec {
|
||||
channels: 1,
|
||||
sample_rate: 37_800,
|
||||
bits_per_sample: 32,
|
||||
sample_format: hound::SampleFormat::Float,
|
||||
};
|
||||
|
||||
let mut file = hound::WavWriter::create("planschi.wav", spec).unwrap();
|
||||
for sample in &planar_output[0] {
|
||||
file.write_sample(*sample)?;
|
||||
}
|
||||
file.finalize()?;
|
||||
|
||||
InternalAudioSamples::new(planar_output, target_frequency)
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,6 @@ impl<'a> Encoder<'a> {
|
|||
out_channel_state.mse = 0;
|
||||
|
||||
for i in 0..28 {
|
||||
// TODO: Code duplication with `find_min_shift`?
|
||||
let sample = (if i >= sample_limit {0} else {samples[(i*pitch) as usize] as i32}) + out_channel_state.qerr;
|
||||
let previous_value = (k1*out_channel_state.prev1 + k2*out_channel_state.prev2 + (1 << 5)) >> 6;
|
||||
|
||||
|
@ -155,10 +154,9 @@ impl<'a> Encoder<'a> {
|
|||
sample_enc += 1 << (shift_range - 1);
|
||||
sample_enc >>= shift_range;
|
||||
|
||||
// TODO: And this?
|
||||
if sample_enc < (std::i16::MIN as i32 >> shift_range) {sample_enc = std::i16::MIN as i32 >> shift_range}
|
||||
if sample_enc > (std::i16::MAX as i32 >> shift_range) {sample_enc = std::i16::MAX as i32 >> shift_range}
|
||||
sample_enc &= sample_mask as i32; //< v TODO: Redundant!
|
||||
sample_enc &= sample_mask as i32;
|
||||
|
||||
let mut sample_dec = (((sample_enc & sample_mask as i32) << shift_range) as i16) as i32;
|
||||
sample_dec >>= min_shift;
|
||||
|
|
Loading…
Reference in New Issue