lc3-codec icon indicating copy to clipboard operation
lc3-codec copied to clipboard

Support encoding 8KHz source

Open katyo opened this issue 1 year ago • 1 comments

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

katyo avatar Jun 21 '24 07:06 katyo

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.

ninjasource avatar Jun 21 '24 09:06 ninjasource