test: switch to Google LC3 codec

This commit is contained in:
Matthias Ringwald 2022-04-21 16:34:44 +02:00
parent 9a19cd7860
commit e40ee29a88
10 changed files with 32 additions and 57 deletions

View File

@ -17,26 +17,14 @@ endif()
# local dir for btstack_config.h after build dir to avoid using .h from Makefile
include_directories(.)
include_directories(../../3rd-party/kissfft)
include_directories(../../3rd-party/liblc3codec)
include_directories(../../3rd-party/lc3-google/include)
include_directories(../../3rd-party/tinydir)
include_directories(../../src)
include_directories(../../platform/posix)
include_directories(../../3rd-party/liblc3codec/Api)
include_directories(../../3rd-party/liblc3codec/Common)
include_directories(../../3rd-party/liblc3codec/Common/KissFft)
include_directories(../../3rd-party/liblc3codec/Common/Tables)
include_directories(../../3rd-party/liblc3codec/TestSupport)
include_directories(../../src)
file(GLOB SOURCES_POSIX "../../platform/posix/*.c")
file(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.cpp")
file(GLOB LC3_COMMON "../../3rd-party/liblc3codec/Common/*.cpp")
file(GLOB LC3_TABLES "../../3rd-party/liblc3codec/Common/Tables/*.cpp")
file(GLOB LC3_DECODER "../../3rd-party/liblc3codec/Decoder/*.cpp")
file(GLOB LC3_ENCODER "../../3rd-party/liblc3codec/Encoder/*.cpp")
set (SOURCES_LC3 ${LC3_COMMON} ${LC3_TABLES} ${LC3_DECODER} ${LC3_ENCODER} ${LC3_TESTSUPPORT})
file(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
# Enable ASAN
add_compile_options( -g -fsanitize=address)
@ -46,7 +34,7 @@ add_link_options( -fsanitize=address)
file(GLOB EXAMPLES "lc3_*.c")
foreach(EXAMPLE_FILE ${EXAMPLES})
get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE)
set (SOURCE_FILES ${SOURCES_POSIX} ${SOURCES_SRC} ${SOURCES_LC3} ${EXAMPLE_FILE})
set (SOURCE_FILES ${SOURCES_POSIX} ${SOURCES_SRC} ${SOURCES_LC3_GOOGLE} ${EXAMPLE_FILE})
message("Tool: ${EXAMPLE}")
add_executable(${EXAMPLE} ${SOURCE_FILES} )
endforeach(EXAMPLE_FILE)

View File

@ -10,7 +10,6 @@
#define HAVE_MALLOC
#define HAVE_POSIX_FILE_IO
#define HAVE_POSIX_TIME
#define HAVE_LC3_EHIMA
// BTstack features that can be enabled
#define ENABLE_BLE

View File

@ -37,7 +37,7 @@
// *****************************************************************************
//
// LC3 decoder EHIMA
// LC3 decoder Google
//
// *****************************************************************************
@ -53,7 +53,7 @@
#include "btstack_debug.h"
#include "btstack_lc3.h"
#include "btstack_lc3_ehima.h"
#include "btstack_lc3_google.h"
#define MAX_NUM_CHANNELS 2
#define MAX_SAMPLES_PER_FRAME 480
@ -133,11 +133,11 @@ int main (int argc, const char * argv[]){
// init decoder
uint8_t channel;
lc3_decoder_ehima_t decoder_contexts[MAX_NUM_CHANNELS];
btstack_lc3_decoder_google_t decoder_contexts[MAX_NUM_CHANNELS];
const btstack_lc3_decoder_t * lc3_decoder;
for (channel = 0 ; channel < num_channels ; channel++){
lc3_decoder_ehima_t * decoder_context = &decoder_contexts[channel];
lc3_decoder = lc3_decoder_ehima_init_instance(decoder_context);
btstack_lc3_decoder_google_t * decoder_context = &decoder_contexts[channel];
lc3_decoder = btstack_lc3_decoder_google_init_instance(decoder_context);
lc3_decoder->configure(decoder_context, sample_rate_hz, duration2);
}

View File

@ -53,7 +53,7 @@
#include "btstack_debug.h"
#include "btstack_lc3.h"
#include "btstack_lc3_ehima.h"
#include "btstack_lc3_google.h"
#define MAX_NUM_CHANNELS 2
#define MAX_SAMPLES_PER_FRAME 480
@ -110,11 +110,11 @@ int main (int argc, const char * argv[]){
// init decoder
uint8_t channel;
lc3_encoder_ehima_t encoder_contexts[MAX_NUM_CHANNELS];
btstack_lc3_encoder_google_t encoder_contexts[MAX_NUM_CHANNELS];
const btstack_lc3_encoder_t * lc3_encoder;
for (channel = 0 ; channel < num_channels ; channel++){
lc3_encoder_ehima_t * encoder_context = &encoder_contexts[channel];
lc3_encoder = lc3_encoder_ehima_init_instance(encoder_context);
btstack_lc3_encoder_google_t * encoder_context = &encoder_contexts[channel];
lc3_encoder = btstack_lc3_encoder_google_init_instance(encoder_context);
lc3_encoder->configure(encoder_context, sampling_frequency_hz, frame_duration);
}
uint32_t bitrate_per_channel = lc3_encoder->get_bitrate_for_number_of_octets(&encoder_contexts[0], bytes_per_frame);

View File

@ -75,12 +75,7 @@ include_directories(../../3rd-party/bluedroid/encoder/include)
include_directories(../../3rd-party/md5)
include_directories(../../3rd-party/hxcmod-player)
include_directories(../../3rd-party/hxcmod-player/mod)
include_directories(../../3rd-party/kissfft)
include_directories(../../3rd-party/liblc3codec/Api)
include_directories(../../3rd-party/liblc3codec/Common)
include_directories(../../3rd-party/liblc3codec/Common/KissFft)
include_directories(../../3rd-party/liblc3codec/Common/Tables)
include_directories(../../3rd-party/liblc3codec/TestSupport)
include_directories(../../3rd-party/lc3-google/include)
include_directories(../../3rd-party/lwip/core/src/include)
include_directories(../../3rd-party/lwip/dhcp-server)
include_directories(../../3rd-party/rijndael)
@ -107,13 +102,7 @@ file(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c")
file(GLOB SOURCES_POSIX "../../platform/posix/*.c")
file(GLOB SOURCES_MAIN "main.c")
file(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c")
file(GLOB LC3_COMMON "../../3rd-party/liblc3codec/Common/*.cpp")
file(GLOB LC3_TABLES "../../3rd-party/liblc3codec/Common/Tables/*.cpp")
file(GLOB LC3_DECODER "../../3rd-party/liblc3codec/Decoder/*.cpp")
file(GLOB LC3_ENCODER "../../3rd-party/liblc3codec/Encoder/*.cpp")
set (SOURCES_LC3 ${LC3_COMMON} ${LC3_TABLES} ${LC3_DECODER} ${LC3_ENCODER} ${LC3_TESTSUPPORT})
file(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
file(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
list(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF})
@ -124,7 +113,7 @@ list(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF})
set(SOURCES
${SOURCES_MD5}
${SOURCES_YXML}
${SOURCES_LC3}
${SOURCES_LC3_GOOGLE}
${SOURCES_POSIX}
${SOURCES_MAIN}
${SOURCES_RIJNDAEL}

View File

@ -11,7 +11,6 @@
#define HAVE_MALLOC
#define HAVE_POSIX_FILE_IO
#define HAVE_POSIX_TIME
#define HAVE_LC3_EHIMA
// BTstack features that can be enabled
#define ENABLE_ATT_DELAYED_RESPONSE

View File

@ -67,7 +67,7 @@
#include "hci.h"
#include "hci_cmd.h"
#include "btstack_lc3.h"
#include "btstack_lc3_ehima.h"
#include "btstack_lc3_google.h"
#include "wav_util.h"
// max config
@ -152,7 +152,7 @@ static uint8_t num_bis;
// lc3 decoder
static const btstack_lc3_decoder_t * lc3_decoder;
static lc3_decoder_ehima_t decoder_contexts[MAX_NUM_BIS];
static btstack_lc3_decoder_google_t decoder_contexts[MAX_NUM_BIS];
static int16_t pcm[MAX_NUM_BIS * MAX_SAMPLES_PER_FRAME];
// playback
@ -216,8 +216,8 @@ static void open_lc3_file(void) {
static void setup_lc3_decoder(void){
uint8_t channel;
for (channel = 0 ; channel < num_bis ; channel++){
lc3_decoder_ehima_t * decoder_context = &decoder_contexts[channel];
lc3_decoder = lc3_decoder_ehima_init_instance(decoder_context);
btstack_lc3_decoder_google_t * decoder_context = &decoder_contexts[channel];
lc3_decoder = btstack_lc3_decoder_google_init_instance(decoder_context);
lc3_decoder->configure(decoder_context, sampling_frequency_hz, frame_duration);
}
number_samples_per_frame = lc3_decoder->get_number_samples_per_frame(&decoder_contexts[0]);

View File

@ -55,7 +55,7 @@
#include "hci_cmd.h"
#include "hci_dump.h"
#include "btstack_lc3.h"
#include "btstack_lc3_ehima.h"
#include "btstack_lc3_google.h"
#include "hxcmod.h"
#include "mods/mod.h"
@ -241,7 +241,7 @@ static uint8_t num_bis = 1;
// lc3 encoder
static const btstack_lc3_encoder_t * lc3_encoder;
static lc3_encoder_ehima_t encoder_contexts[MAX_NUM_BIS];
static btstack_lc3_encoder_google_t encoder_contexts[MAX_NUM_BIS];
static int16_t pcm[MAX_NUM_BIS * MAX_SAMPLES_PER_FRAME];
static uint32_t time_generation_ms;
@ -348,8 +348,8 @@ static void print_config(void) {
static void setup_lc3_encoder(void){
uint8_t channel;
for (channel = 0 ; channel < num_bis ; channel++){
lc3_encoder_ehima_t * context = &encoder_contexts[channel];
lc3_encoder = lc3_encoder_ehima_init_instance(context);
btstack_lc3_encoder_google_t * context = &encoder_contexts[channel];
lc3_encoder = btstack_lc3_encoder_google_init_instance(context);
lc3_encoder->configure(context, sampling_frequency_hz, frame_duration);
}
number_samples_per_frame = lc3_encoder->get_number_samples_per_frame(&encoder_contexts[0]);

View File

@ -69,7 +69,7 @@
#include "hci.h"
#include "hci_cmd.h"
#include "btstack_lc3.h"
#include "btstack_lc3_ehima.h"
#include "btstack_lc3_google.h"
#include "wav_util.h"
// max config
@ -155,7 +155,7 @@ static uint8_t num_channels;
// lc3 decoder
static const btstack_lc3_decoder_t * lc3_decoder;
static lc3_decoder_ehima_t decoder_contexts[MAX_CHANNELS];
static btstack_lc3_decoder_google_t decoder_contexts[MAX_CHANNELS];
static int16_t pcm[MAX_CHANNELS * MAX_SAMPLES_PER_FRAME];
// playback
@ -219,8 +219,8 @@ static void open_lc3_file(void) {
static void setup_lc3_decoder(void){
uint8_t channel;
for (channel = 0 ; channel < num_channels ; channel++){
lc3_decoder_ehima_t * decoder_context = &decoder_contexts[channel];
lc3_decoder = lc3_decoder_ehima_init_instance(decoder_context);
btstack_lc3_decoder_google_t * decoder_context = &decoder_contexts[channel];
lc3_decoder = btstack_lc3_decoder_google_init_instance(decoder_context);
lc3_decoder->configure(decoder_context, sampling_frequency_hz, frame_duration);
}
number_samples_per_frame = lc3_decoder->get_number_samples_per_frame(&decoder_contexts[0]);

View File

@ -57,7 +57,7 @@
#include "hci_cmd.h"
#include "hci_dump.h"
#include "btstack_lc3.h"
#include "btstack_lc3_ehima.h"
#include "btstack_lc3_google.h"
#include "hxcmod.h"
#include "mods/mod.h"
@ -158,7 +158,7 @@ static uint8_t num_channels = 1;
// lc3 encoder
static const btstack_lc3_encoder_t * lc3_encoder;
static lc3_encoder_ehima_t encoder_contexts[MAX_CHANNELS];
static btstack_lc3_encoder_google_t encoder_contexts[MAX_CHANNELS];
static int16_t pcm[MAX_CHANNELS * MAX_SAMPLES_PER_FRAME];
static uint32_t time_generation_ms;
@ -265,8 +265,8 @@ static void print_config(void) {
static void setup_lc3_encoder(void){
uint8_t channel;
for (channel = 0 ; channel < num_channels ; channel++){
lc3_encoder_ehima_t * context = &encoder_contexts[channel];
lc3_encoder = lc3_encoder_ehima_init_instance(context);
btstack_lc3_encoder_google_t * context = &encoder_contexts[channel];
lc3_encoder = btstack_lc3_encoder_google_init_instance(context);
lc3_encoder->configure(context, sampling_frequency_hz, frame_duration);
}
number_samples_per_frame = lc3_encoder->get_number_samples_per_frame(&encoder_contexts[0]);