lc3-codec
lc3-codec copied to clipboard
Support encoding 8KHz source
Currently encoders crashes for 8 KHz with the following:
---- lc3::test::lc3_encode stdout ----
thread 'lc3::test::lc3_encode' panicked at /home/kayo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lc3-codec-0.2.0/src/encoder/bandwidth_detector.rs:36:34:
attempt to subtract with overflow
stack backtrace:
0: rust_begin_unwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
2: core::panicking::panic
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:145:5
3: lc3_codec::encoder::bandwidth_detector::BandwidthDetector::new
at /home/kayo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lc3-codec-0.2.0/src/encoder/bandwidth_detector.rs:36:34
4: lc3_codec::encoder::lc3_encoder::Lc3Encoder::new
at /home/kayo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lc3-codec-0.2.0/src/encoder/lc3_encoder.rs:134:38
Seems it happened because fs_idx for 8KHz is 0: https://github.com/ninjasource/lc3-codec/blob/c912899e0ebbf8c2c4c79eaadb89966a48db0609/src/common/config.rs#L44
Hi, thanks for reporting this. I can see the issue there but I'm going to have to figure out what start and stop bandwidth number to use for 8k sampling frequency and why originally chose the ones I did. Therefore I'm not going to be able to fix this immediately since I need to test the other cases for breakages.