7#ifndef _SW_CODEC_SELECT_H_
8#define _SW_CODEC_SELECT_H_
10#include <zephyr/kernel.h>
13#if (CONFIG_SW_CODEC_LC3)
14#define LC3_MAX_FRAME_SIZE_MS 10
15#define LC3_ENC_MONO_FRAME_SIZE (CONFIG_LC3_BITRATE_MAX * LC3_MAX_FRAME_SIZE_MS / (8 * 1000))
17#define LC3_PCM_NUM_BYTES_MONO \
18 (CONFIG_AUDIO_SAMPLE_RATE_HZ * CONFIG_AUDIO_BIT_DEPTH_OCTETS * LC3_MAX_FRAME_SIZE_MS / 1000)
19#define LC3_ENC_TIME_US 3000
20#define LC3_DEC_TIME_US 1500
22#define LC3_ENC_MONO_FRAME_SIZE 0
23#define LC3_PCM_NUM_BYTES_MONO 0
24#define LC3_ENC_TIME_US 0
25#define LC3_DEC_TIME_US 0
29#define ENC_MAX_FRAME_SIZE MAX(LC3_ENC_MONO_FRAME_SIZE, 0)
30#define ENC_TIME_US MAX(LC3_ENC_TIME_US, 0)
31#define DEC_TIME_US MAX(LC3_DEC_TIME_US, 0)
32#define PCM_NUM_BYTES_MONO MAX(LC3_PCM_NUM_BYTES_MONO, 0)
33#define PCM_NUM_BYTES_STEREO (PCM_NUM_BYTES_MONO * 2)
93int sw_codec_encode(
void *pcm_data,
size_t pcm_size, uint8_t **encoded_data,
size_t *encoded_size);
106int sw_codec_decode(uint8_t
const *
const encoded_data,
size_t encoded_size,
bool bad_frame,
107 void **pcm_data,
size_t *pcm_size);
audio_channel
Audio channel assignment values.
Definition audio_defines.h:20
Audio channel assignment.
struct sw_codec_decoder decoder
Definition sw_codec_select.h:67
struct sw_codec_encoder encoder
Definition sw_codec_select.h:68
enum sw_codec_select sw_codec
Definition sw_codec_select.h:66
bool initialized
Definition sw_codec_select.h:69
Sw_codec configuration structure.
Definition sw_codec_select.h:65
uint8_t num_ch
Definition sw_codec_select.h:57
enum audio_channel audio_ch
Definition sw_codec_select.h:58
bool enabled
Definition sw_codec_select.h:55
enum sw_codec_channel_mode channel_mode
Definition sw_codec_select.h:56
uint32_t sample_rate_hz
Definition sw_codec_select.h:59
Definition sw_codec_select.h:54
uint8_t num_ch
Definition sw_codec_select.h:49
int bitrate
Definition sw_codec_select.h:47
bool enabled
Definition sw_codec_select.h:46
uint32_t sample_rate_hz
Definition sw_codec_select.h:51
enum sw_codec_channel_mode channel_mode
Definition sw_codec_select.h:48
enum audio_channel audio_ch
Definition sw_codec_select.h:50
Definition sw_codec_select.h:45
int sw_codec_init(struct sw_codec_config sw_codec_cfg)
Initialize the software codec and statically or dynamically allocate memory to be used,...
sw_codec_channel_mode
Definition sw_codec_select.h:40
@ SW_CODEC_STEREO
Definition sw_codec_select.h:42
@ SW_CODEC_MONO
Definition sw_codec_select.h:41
int sw_codec_decode(uint8_t const *const encoded_data, size_t encoded_size, bool bad_frame, void **pcm_data, size_t *pcm_size)
Decode encoded data and output PCM data.
bool sw_codec_is_initialized(void)
Check if the software codec is initialized.
int sw_codec_uninit(struct sw_codec_config sw_codec_cfg)
Uninitialize the software codec and free the allocated space.
sw_codec_select
Definition sw_codec_select.h:35
@ SW_CODEC_LC3
Definition sw_codec_select.h:37
@ SW_CODEC_NONE
Definition sw_codec_select.h:36
int sw_codec_encode(void *pcm_data, size_t pcm_size, uint8_t **encoded_data, size_t *encoded_size)
Encode PCM data and output encoded data.