mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-31 10:20:58 +00:00
test/lc3: fix build
This commit is contained in:
parent
65113a0c45
commit
12154a1a9a
@ -131,6 +131,8 @@ int main (int argc, const char * argv[]){
|
|||||||
return -10;
|
return -10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t number_samples_per_frame = btstack_lc3_samples_per_frame(sample_rate_hz, duration2);
|
||||||
|
|
||||||
// init decoder
|
// init decoder
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
btstack_lc3_decoder_google_t decoder_contexts[MAX_NUM_CHANNELS];
|
btstack_lc3_decoder_google_t decoder_contexts[MAX_NUM_CHANNELS];
|
||||||
@ -138,12 +140,11 @@ int main (int argc, const char * argv[]){
|
|||||||
for (channel = 0 ; channel < num_channels ; channel++){
|
for (channel = 0 ; channel < num_channels ; channel++){
|
||||||
btstack_lc3_decoder_google_t * decoder_context = &decoder_contexts[channel];
|
btstack_lc3_decoder_google_t * decoder_context = &decoder_contexts[channel];
|
||||||
lc3_decoder = btstack_lc3_decoder_google_init_instance(decoder_context);
|
lc3_decoder = btstack_lc3_decoder_google_init_instance(decoder_context);
|
||||||
lc3_decoder->configure(decoder_context, sample_rate_hz, duration2);
|
lc3_decoder->configure(decoder_context, sample_rate_hz, duration2, number_samples_per_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t bitrate_per_channel = bitrate / num_channels;
|
uint32_t bitrate_per_channel = bitrate / num_channels;
|
||||||
uint16_t bytes_per_frame = lc3_decoder->get_number_octets_for_bitrate(&decoder_contexts[0], bitrate_per_channel);
|
uint16_t bytes_per_frame = lc3_decoder->get_number_octets_for_bitrate(&decoder_contexts[0], bitrate_per_channel);
|
||||||
uint16_t number_samples_per_frame = lc3_decoder->get_number_samples_per_frame(&decoder_contexts[0]);
|
|
||||||
|
|
||||||
// fix bitrate for 8_1
|
// fix bitrate for 8_1
|
||||||
if ((sample_rate_hz == 8000) && (bitrate_per_channel == 27700)){
|
if ((sample_rate_hz == 8000) && (bitrate_per_channel == 27700)){
|
||||||
@ -212,7 +213,7 @@ int main (int argc, const char * argv[]){
|
|||||||
uint8_t tmp_BEC_detect;
|
uint8_t tmp_BEC_detect;
|
||||||
uint8_t BFI = 0;
|
uint8_t BFI = 0;
|
||||||
|
|
||||||
uint8_t status = lc3_decoder->decode_signed_16(&decoder_contexts[channel], read_buffer, bytes_per_frame, BFI, &pcm[channel], num_channels, &tmp_BEC_detect);
|
uint8_t status = lc3_decoder->decode_signed_16(&decoder_contexts[channel], read_buffer, BFI, &pcm[channel], num_channels, &tmp_BEC_detect);
|
||||||
if (status != ERROR_CODE_SUCCESS){
|
if (status != ERROR_CODE_SUCCESS){
|
||||||
printf("Error %u\n", status);
|
printf("Error %u\n", status);
|
||||||
done = true;
|
done = true;
|
||||||
|
@ -106,6 +106,7 @@ int main (int argc, const char * argv[]){
|
|||||||
// get wav config
|
// get wav config
|
||||||
uint32_t sampling_frequency_hz = wav_reader_get_sampling_rate();
|
uint32_t sampling_frequency_hz = wav_reader_get_sampling_rate();
|
||||||
uint8_t num_channels = wav_reader_get_num_channels();
|
uint8_t num_channels = wav_reader_get_num_channels();
|
||||||
|
uint16_t number_samples_per_frame = btstack_lc3_samples_per_frame(sampling_frequency_hz, frame_duration);
|
||||||
|
|
||||||
// init decoder
|
// init decoder
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
@ -114,11 +115,10 @@ int main (int argc, const char * argv[]){
|
|||||||
for (channel = 0 ; channel < num_channels ; channel++){
|
for (channel = 0 ; channel < num_channels ; channel++){
|
||||||
btstack_lc3_encoder_google_t * encoder_context = &encoder_contexts[channel];
|
btstack_lc3_encoder_google_t * encoder_context = &encoder_contexts[channel];
|
||||||
lc3_encoder = btstack_lc3_encoder_google_init_instance(encoder_context);
|
lc3_encoder = btstack_lc3_encoder_google_init_instance(encoder_context);
|
||||||
lc3_encoder->configure(encoder_context, sampling_frequency_hz, frame_duration);
|
lc3_encoder->configure(encoder_context, sampling_frequency_hz, frame_duration, number_samples_per_frame);
|
||||||
}
|
}
|
||||||
uint32_t bitrate_per_channel = lc3_encoder->get_bitrate_for_number_of_octets(&encoder_contexts[0], bytes_per_frame);
|
uint32_t bitrate_per_channel = lc3_encoder->get_bitrate_for_number_of_octets(&encoder_contexts[0], bytes_per_frame);
|
||||||
uint32_t bitrate = bitrate_per_channel * num_channels;
|
uint32_t bitrate = bitrate_per_channel * num_channels;
|
||||||
uint16_t number_samples_per_frame = lc3_encoder->get_number_samples_per_frame(&encoder_contexts[0]);
|
|
||||||
|
|
||||||
if (number_samples_per_frame > MAX_SAMPLES_PER_FRAME) return -10;
|
if (number_samples_per_frame > MAX_SAMPLES_PER_FRAME) return -10;
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ int main (int argc, const char * argv[]){
|
|||||||
|
|
||||||
// encode frame by frame
|
// encode frame by frame
|
||||||
for (channel = 0; channel < num_channels ; channel++){
|
for (channel = 0; channel < num_channels ; channel++){
|
||||||
status = lc3_encoder->encode_signed_16(&encoder_contexts[channel], &samples_buffer[channel], num_channels, write_buffer, bytes_per_frame);
|
status = lc3_encoder->encode_signed_16(&encoder_contexts[channel], &samples_buffer[channel], num_channels, write_buffer);
|
||||||
if (status != ERROR_CODE_SUCCESS){
|
if (status != ERROR_CODE_SUCCESS){
|
||||||
printf("Error %u\n", status);
|
printf("Error %u\n", status);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user