Loading system/bta/le_audio/broadcaster/broadcaster.cc +2 −1 Original line number Diff line number Diff line Loading @@ -561,7 +561,8 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks { int initial_channel_offset, int pitch_samples, int num_channels) { auto encoder_status = lc3_encode(encoder, (int16_t*)(data.data() + initial_channel_offset), lc3_encode(encoder, LC3_PCM_FORMAT_S16, (int16_t*)(data.data() + initial_channel_offset), pitch_samples, out_buffer.size(), out_buffer.data()); if (encoder_status != 0) { LOG(ERROR) << "Error while encoding" Loading system/bta/le_audio/client.cc +22 −15 Original line number Diff line number Diff line Loading @@ -1912,22 +1912,26 @@ class LeAudioClientImpl : public LeAudioClient { LOG(INFO) << __func__ << " data size: " << (int)data.size() << " byte count: " << byte_count << " mono: " << mono; if (!mono) { lc3_encode(lc3_encoder_left, (const int16_t*)data.data(), 2, chan_left_enc.size(), chan_left_enc.data()); lc3_encode(lc3_encoder_right, ((const int16_t*)data.data()) + 1, 2, chan_right_enc.size(), chan_right_enc.data()); lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)data.data(), 2, chan_left_enc.size(), chan_left_enc.data()); lc3_encode(lc3_encoder_right, LC3_PCM_FORMAT_S16, ((const int16_t*)data.data()) + 1, 2, chan_right_enc.size(), chan_right_enc.data()); } else { std::vector<int16_t> chan_mono; get_mono_stream(data, chan_mono); if (left_cis_handle) { lc3_encode(lc3_encoder_left, (const int16_t*)chan_mono.data(), 1, chan_left_enc.size(), chan_left_enc.data()); lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)chan_mono.data(), 1, chan_left_enc.size(), chan_left_enc.data()); } if (right_cis_handle) { lc3_encode(lc3_encoder_right, (const int16_t*)chan_mono.data(), 1, chan_right_enc.size(), chan_right_enc.data()); lc3_encode(lc3_encoder_right, LC3_PCM_FORMAT_S16, (const int16_t*)chan_mono.data(), 1, chan_right_enc.size(), chan_right_enc.data()); } } Loading Loading @@ -1968,17 +1972,20 @@ class LeAudioClientImpl : public LeAudioClient { std::vector<int16_t> chan_mono; get_mono_stream(data, chan_mono); auto err = lc3_encode(lc3_encoder_left, (const int16_t*)chan_mono.data(), 1, byte_count, chan_encoded.data()); auto err = lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)chan_mono.data(), 1, byte_count, chan_encoded.data()); if (err < 0) { LOG(ERROR) << " error while encoding, error code: " << +err; } } else { lc3_encode(lc3_encoder_left, (const int16_t*)data.data(), 2, byte_count, lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)data.data(), 2, byte_count, chan_encoded.data()); lc3_encode(lc3_encoder_right, (const int16_t*)data.data() + 1, 2, byte_count, chan_encoded.data() + byte_count); lc3_encode(lc3_encoder_right, LC3_PCM_FORMAT_S16, (const int16_t*)data.data() + 1, 2, byte_count, chan_encoded.data() + byte_count); } /* Send data to the controller */ Loading Loading @@ -2202,8 +2209,8 @@ class LeAudioClientImpl : public LeAudioClient { lc3_decoder_t decoder_to_use = is_left ? lc3_decoder_left : lc3_decoder_right; err = lc3_decode(decoder_to_use, data, size, pcm_data_decoded.data(), 1 /* pitch */); err = lc3_decode(decoder_to_use, data, size, LC3_PCM_FORMAT_S16, pcm_data_decoded.data(), 1 /* pitch */); if (err < 0) { LOG(ERROR) << " bad decoding parameters: " << static_cast<int>(err); Loading system/embdrv/lc3/fuzzer/liblc3_fuzzer.cpp +9 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include "include/lc3.h" void TestEncoder(FuzzedDataProvider& fdp) { enum lc3_pcm_format pcm_format = fdp.PickValueInArray({LC3_PCM_FORMAT_S16, LC3_PCM_FORMAT_S24}); int dt_us = fdp.PickValueInArray({10000, 7500}); int sr_hz = fdp.PickValueInArray({8000, 16000, 24000, 32000, /*44100,*/ 48000}); Loading @@ -39,8 +41,8 @@ void TestEncoder(FuzzedDataProvider& fdp) { lc3_setup_encoder(dt_us, sr_hz, 0, lc3_encoder_mem); std::vector<uint8_t> output(output_byte_count); lc3_encode(lc3_encoder, (const int16_t*)input_frames.data(), 1, output.size(), output.data()); lc3_encode(lc3_encoder, pcm_format, (const int16_t*)input_frames.data(), 1, output.size(), output.data()); free(lc3_encoder_mem); lc3_encoder_mem = nullptr; Loading @@ -48,6 +50,8 @@ void TestEncoder(FuzzedDataProvider& fdp) { } void TestDecoder(FuzzedDataProvider& fdp) { enum lc3_pcm_format pcm_format = fdp.PickValueInArray({LC3_PCM_FORMAT_S16, LC3_PCM_FORMAT_S24}); int dt_us = fdp.PickValueInArray({10000, 7500}); int sr_hz = fdp.PickValueInArray({8000, 16000, 24000, 32000, /*44100,*/ 48000}); Loading @@ -68,11 +72,11 @@ void TestDecoder(FuzzedDataProvider& fdp) { lc3_setup_decoder(dt_us, sr_hz, 0, lc3_decoder_mem); std::vector<uint16_t> output(num_frames); lc3_decode(lc3_decoder, input.data(), input.size(), (int16_t*)output.data(), 1); lc3_decode(lc3_decoder, input.data(), input.size(), pcm_format, (int16_t*)output.data(), 1); /* Empty input performs PLC (packet loss concealment) */ lc3_decode(lc3_decoder, nullptr, 0, (int16_t*)output.data(), 1); lc3_decode(lc3_decoder, nullptr, 0, pcm_format, (int16_t*)output.data(), 1); free(lc3_decoder_mem); lc3_decoder_mem = nullptr; Loading Loading
system/bta/le_audio/broadcaster/broadcaster.cc +2 −1 Original line number Diff line number Diff line Loading @@ -561,7 +561,8 @@ class LeAudioBroadcasterImpl : public LeAudioBroadcaster, public BigCallbacks { int initial_channel_offset, int pitch_samples, int num_channels) { auto encoder_status = lc3_encode(encoder, (int16_t*)(data.data() + initial_channel_offset), lc3_encode(encoder, LC3_PCM_FORMAT_S16, (int16_t*)(data.data() + initial_channel_offset), pitch_samples, out_buffer.size(), out_buffer.data()); if (encoder_status != 0) { LOG(ERROR) << "Error while encoding" Loading
system/bta/le_audio/client.cc +22 −15 Original line number Diff line number Diff line Loading @@ -1912,22 +1912,26 @@ class LeAudioClientImpl : public LeAudioClient { LOG(INFO) << __func__ << " data size: " << (int)data.size() << " byte count: " << byte_count << " mono: " << mono; if (!mono) { lc3_encode(lc3_encoder_left, (const int16_t*)data.data(), 2, chan_left_enc.size(), chan_left_enc.data()); lc3_encode(lc3_encoder_right, ((const int16_t*)data.data()) + 1, 2, chan_right_enc.size(), chan_right_enc.data()); lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)data.data(), 2, chan_left_enc.size(), chan_left_enc.data()); lc3_encode(lc3_encoder_right, LC3_PCM_FORMAT_S16, ((const int16_t*)data.data()) + 1, 2, chan_right_enc.size(), chan_right_enc.data()); } else { std::vector<int16_t> chan_mono; get_mono_stream(data, chan_mono); if (left_cis_handle) { lc3_encode(lc3_encoder_left, (const int16_t*)chan_mono.data(), 1, chan_left_enc.size(), chan_left_enc.data()); lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)chan_mono.data(), 1, chan_left_enc.size(), chan_left_enc.data()); } if (right_cis_handle) { lc3_encode(lc3_encoder_right, (const int16_t*)chan_mono.data(), 1, chan_right_enc.size(), chan_right_enc.data()); lc3_encode(lc3_encoder_right, LC3_PCM_FORMAT_S16, (const int16_t*)chan_mono.data(), 1, chan_right_enc.size(), chan_right_enc.data()); } } Loading Loading @@ -1968,17 +1972,20 @@ class LeAudioClientImpl : public LeAudioClient { std::vector<int16_t> chan_mono; get_mono_stream(data, chan_mono); auto err = lc3_encode(lc3_encoder_left, (const int16_t*)chan_mono.data(), 1, byte_count, chan_encoded.data()); auto err = lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)chan_mono.data(), 1, byte_count, chan_encoded.data()); if (err < 0) { LOG(ERROR) << " error while encoding, error code: " << +err; } } else { lc3_encode(lc3_encoder_left, (const int16_t*)data.data(), 2, byte_count, lc3_encode(lc3_encoder_left, LC3_PCM_FORMAT_S16, (const int16_t*)data.data(), 2, byte_count, chan_encoded.data()); lc3_encode(lc3_encoder_right, (const int16_t*)data.data() + 1, 2, byte_count, chan_encoded.data() + byte_count); lc3_encode(lc3_encoder_right, LC3_PCM_FORMAT_S16, (const int16_t*)data.data() + 1, 2, byte_count, chan_encoded.data() + byte_count); } /* Send data to the controller */ Loading Loading @@ -2202,8 +2209,8 @@ class LeAudioClientImpl : public LeAudioClient { lc3_decoder_t decoder_to_use = is_left ? lc3_decoder_left : lc3_decoder_right; err = lc3_decode(decoder_to_use, data, size, pcm_data_decoded.data(), 1 /* pitch */); err = lc3_decode(decoder_to_use, data, size, LC3_PCM_FORMAT_S16, pcm_data_decoded.data(), 1 /* pitch */); if (err < 0) { LOG(ERROR) << " bad decoding parameters: " << static_cast<int>(err); Loading
system/embdrv/lc3/fuzzer/liblc3_fuzzer.cpp +9 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include "include/lc3.h" void TestEncoder(FuzzedDataProvider& fdp) { enum lc3_pcm_format pcm_format = fdp.PickValueInArray({LC3_PCM_FORMAT_S16, LC3_PCM_FORMAT_S24}); int dt_us = fdp.PickValueInArray({10000, 7500}); int sr_hz = fdp.PickValueInArray({8000, 16000, 24000, 32000, /*44100,*/ 48000}); Loading @@ -39,8 +41,8 @@ void TestEncoder(FuzzedDataProvider& fdp) { lc3_setup_encoder(dt_us, sr_hz, 0, lc3_encoder_mem); std::vector<uint8_t> output(output_byte_count); lc3_encode(lc3_encoder, (const int16_t*)input_frames.data(), 1, output.size(), output.data()); lc3_encode(lc3_encoder, pcm_format, (const int16_t*)input_frames.data(), 1, output.size(), output.data()); free(lc3_encoder_mem); lc3_encoder_mem = nullptr; Loading @@ -48,6 +50,8 @@ void TestEncoder(FuzzedDataProvider& fdp) { } void TestDecoder(FuzzedDataProvider& fdp) { enum lc3_pcm_format pcm_format = fdp.PickValueInArray({LC3_PCM_FORMAT_S16, LC3_PCM_FORMAT_S24}); int dt_us = fdp.PickValueInArray({10000, 7500}); int sr_hz = fdp.PickValueInArray({8000, 16000, 24000, 32000, /*44100,*/ 48000}); Loading @@ -68,11 +72,11 @@ void TestDecoder(FuzzedDataProvider& fdp) { lc3_setup_decoder(dt_us, sr_hz, 0, lc3_decoder_mem); std::vector<uint16_t> output(num_frames); lc3_decode(lc3_decoder, input.data(), input.size(), (int16_t*)output.data(), 1); lc3_decode(lc3_decoder, input.data(), input.size(), pcm_format, (int16_t*)output.data(), 1); /* Empty input performs PLC (packet loss concealment) */ lc3_decode(lc3_decoder, nullptr, 0, (int16_t*)output.data(), 1); lc3_decode(lc3_decoder, nullptr, 0, pcm_format, (int16_t*)output.data(), 1); free(lc3_decoder_mem); lc3_decoder_mem = nullptr; Loading