diff options
| author | Yuval Adam <_@yuv.al> | 2022-07-24 00:00:25 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2022-07-24 00:00:25 +0300 |
| commit | 56635c5677a85c10f83e25553dc7a3a9cd2e8c24 (patch) | |
| tree | aee6ae18cdf28d120421fbeebe1f18a7aa3179ba /c2enc/src | |
| parent | 348dce1f556318ec96bf4de02795628c7a5eb829 (diff) | |
Remove redundant buffer
Diffstat (limited to 'c2enc/src')
| -rw-r--r-- | c2enc/src/main.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/c2enc/src/main.rs b/c2enc/src/main.rs index b20f133..adbd787 100644 --- a/c2enc/src/main.rs +++ b/c2enc/src/main.rs @@ -32,17 +32,16 @@ fn main() { speech.push(i); } - let mut allbits = Vec::new(); let c = libcodec2::Codec2::new(); let nsam = c.samples_per_frame(); let nbits = c.bytes_per_frame(); + let mut file = File::create(&args.out_path).unwrap(); + for samples in speech.chunks(nsam) { let mut bits = vec![0u8; nbits]; c.encode(&samples, &mut bits); - allbits.extend(bits); + file.write(&bits).unwrap(); } - - let mut file = File::create(&args.out_path).unwrap(); - file.write_all(&allbits).unwrap(); + file.flush().unwrap(); } |
