Skip to content

Commit d009666

Browse files
committed
commit ID: [eafbde44]
esp_audio_codec: 1. Added support for SBC codec 2. Added support for LC3 codec 3. Added compatibility with `esp_audio_codec` on `ESP32-H4` 4. Added `esp_xxx_enc_get_frame_info_by_cfg` APIs to get frame information by configuration before creating encoder handle 5. Added `esp_xxx_enc_set_bitrate` APIs to set bitrate for encoder 6. Added `esp_audio_dec_check_audio_type`, `esp_audio_enc_check_audio_type`, `esp_audio_simple_check_audio_type` APIs to check whether the audio type is supported by the codec 7. Use `esp_fourcc.h` to define audio codec type 8. Added CO64 atom parsing support for `M4A` format 9. Standardized bitrate units in `AAC` and `Opus` encoder headers 10. Added `ALAC` decoder to the simple decoder module 11. Added `frame_duration` configuration support to `G711` and `PCM` encoders 12. Fixed crash in `AMR-NB` encoder when DTX is enabled 13. Fixed crash in `AAC` encoder when recommended output buffer size is insufficient 14. Fixed `M4A` parsing error when extra boxes are present under the mdat atom esp_audio_effects: 1. Supported `esp-audio-effects` for `esp32-h4` 2. Supported mixer outbuf is one of inbuf
1 parent bddefe4 commit d009666

File tree

70 files changed

+3249
-549
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3249
-549
lines changed

esp_audio_codec/CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## v2.3.0
4+
5+
### Features
6+
7+
- Added support for SBC codec
8+
- Added support for LC3 codec
9+
- Added compatibility with `esp_audio_codec` on `ESP32-H4`
10+
- Added `esp_xxx_enc_get_frame_info_by_cfg` APIs to get frame information by configuration before creating encoder handle
11+
- Added `esp_xxx_enc_set_bitrate` APIs to set bitrate for encoder
12+
- Added `esp_audio_dec_check_audio_type`, `esp_audio_enc_check_audio_type`, `esp_audio_simple_check_audio_type` APIs to check whether the audio type is supported by the codec
13+
- Use `esp_fourcc.h` to define audio codec type
14+
- Added CO64 atom parsing support for `M4A` format
15+
- Standardized bitrate units in `AAC` and `Opus` encoder headers
16+
- Added `ALAC` decoder to the simple decoder module
17+
- Added `frame_duration` configuration support to `G711` and `PCM` encoders
18+
19+
### Bug Fixes
20+
- Fixed crash in `AMR-NB` encoder when DTX is enabled
21+
- Fixed crash in `AAC` encoder when recommended output buffer size is insufficient
22+
- Fixed `M4A` parsing error when extra boxes are present under the mdat atom
23+
324
## v2.2.1
425

526
### Bug Fixes

esp_audio_codec/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ menu "Audio Codec Configuration"
6363
default y
6464
help
6565
Enable this option to register PCM decoder
66+
config AUDIO_DECODER_SBC_SUPPORT
67+
bool "Support SBC Decoder"
68+
default y
69+
help
70+
Enable this option to register SBC decoder
71+
config AUDIO_DECODER_LC3_SUPPORT
72+
bool "Support LC3 Decoder"
73+
default y
74+
help
75+
Enable this option to register LC3 decoder
6676
endmenu
6777

6878
menu "Audio Simple Decoder Configuration"
@@ -131,6 +141,16 @@ menu "Audio Codec Configuration"
131141
default y
132142
help
133143
Enable this option to register PCM encoder
144+
config AUDIO_ENCODER_SBC_SUPPORT
145+
bool "Support SBC Encoder"
146+
default y
147+
help
148+
Enable this option to register SBC encoder
149+
config AUDIO_ENCODER_LC3_SUPPORT
150+
bool "Support LC3 Encoder"
151+
default y
152+
help
153+
Enable this option to register LC3 encoder
134154
endmenu
135155

136156
endmenu

esp_audio_codec/LICENSE

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
ESPRESSIF MIT License
1+
Espressif Modified MIT License
22

3-
Copyright (c) 2024 <ESPRESSIF SYSTEMS (SHANGHAI) CO.LTD>
3+
Copyright (c) 2025 Espressif Systems (Shanghai) CO., LTD
44

5-
Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
6-
it is free of charge, to any person obtaining a copy of this software and associated
7-
documentation files (the "Software"), to deal in the Software without restriction, including
8-
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
9-
and/or sell copies of the Software, and to permit persons to whom the Software is furnished
10-
to do so, subject to the following conditions:
5+
Permission is hereby granted for use EXCLUSIVELY with Espressif Systems products.
6+
This includes the right to use, copy, modify, merge, publish, distribute, and sublicense
7+
the Software, subject to the following conditions:
118

12-
The above copyright notice and this permission notice shall be included in all copies or
13-
substantial portions of the Software.
9+
1. This Software MUST BE USED IN CONJUNCTION WITH ESPRESSIF SYSTEMS PRODUCTS.
10+
2. The above copyright notice and this permission notice shall be included in all copies
11+
or substantial portions of the Software.
12+
3. Redistribution of the Software in source or binary form FOR USE WITH NON-ESPRESSIF PRODUCTS
13+
is strictly prohibited.
1414

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
18+
FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
DEALINGS IN THE SOFTWARE.
21+
22+
SPDX-License-Identifier: LicenseRef-Espressif-Modified-MIT

esp_audio_codec/README.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ The ESP Audio Codec supports the following features:
3838
- PCM
3939
- ALAC
4040
- OPUS
41+
- LC3
42+
- SBC
4143
* Supports operate all encoder through common API see [esp_audio_enc.h](include/encoder/esp_audio_enc.h)
4244
* Supports customized encoder through `esp_audio_enc_register` or overwrite default encoder
4345
* Supports register all supported encoder through `esp_audio_enc_register_default` and manager it by menuconfig
@@ -88,7 +90,25 @@ Details for the supported encoders are as follow:
8890
- Encoding sample rates (Hz): 8000, 12000, 16000, 24000, 48000
8991
- Encoding channel num: mono, dual
9092
- Encoding bits per sample: 16 bits
91-
93+
94+
**SBC**
95+
- Encoding sample rates (Hz): 16000, 32000, 44100, 48000
96+
- Encoding channel mode: mono, dual, stereo, joint stereo
97+
- Encoding bits per sample: 16 bits
98+
- Encoding sbc mode: standard, msbc
99+
- Encoding block length: 4, 8, 12, 16
100+
- Encoding subbands number: 4, 8
101+
- Encoding allocation method: loudness, SNR
102+
- Encoding bitpool range: 2 to 250
103+
104+
**LC3**
105+
- Encoding sample rates (Hz): 8000, 16000, 24000, 32000, 44100, 48000
106+
- Encoding full range of channel
107+
- Encoding bits per sample: 16, 24, 32 bits
108+
- Encoding frame decimilliseconds: 75, 100 dms
109+
- Encoding nbyte range: 20 to 400
110+
- Support 2-byte length prefix before each encoded frame
111+
92112
## Decoder
93113

94114
* Following decoders are supported:
@@ -154,7 +174,23 @@ Details for the supported decoders are as follow:
154174
- Decoding bits per sample: 16 bits
155175
- Supports decode VORBIS frame only, need remove OGG header
156176
- User need provide common header information firstly
157-
177+
178+
**SBC**
179+
- Decoding sample rates (Hz): 16000, 32000, 44100, 48000
180+
- Decoding channel: mono, dual
181+
- Decoding bits per sample: 16 bits
182+
- Decoding sbc mode: standard, msbc
183+
- Packet Loss Concealment (PLC)
184+
185+
**LC3**
186+
- Decoding sample rates (Hz): 8000, 16000, 24000, 32000, 44100, 48000
187+
- Decoding full range of channel
188+
- Decoding bits per sample: 16, 24, 32 bits
189+
- Decoding frame decimilliseconds: 75, 100 dms
190+
- Decoding nbyte range: 20 to 400
191+
- Support decoding of 2-byte length-prefixed frame data
192+
- Packet Loss Concealment (PLC)
193+
158194
## Simple Decoder
159195

160196
* Supports audio frame finding and decoding
@@ -167,14 +203,17 @@ Details for the supported audio containers are as follow:
167203
| Audio Container| Notes |
168204
| -- | -- |
169205
| AAC | Supports AAC-Plus controlled by configuration |
170-
| MP3 | Supports layer 3 only |
206+
| MP3 | Supports layer 1, 2, 3 |
171207
| AMRNB | Supports files with AMRNB file header only |
172208
| AMRWB | Supports files with AMRWB file header only |
173209
| FLAC | Supports files with FLAC file header only |
174210
| ADPCM | Supports IMA-ADPCM only |
175211
| WAV | Supports G711A, G711U, PCM, ADPCM |
176212
| M4A | Supports MP3, AAC, ALAC <br> Supports MDAT after MOOV only |
177213
| TS | Supports MP3, AAC |
214+
| G711 | Supports G711A, G711U |
215+
| SBC | Supports SBC and MSBC |
216+
| LC3 | Supports LC3 |
178217

179218
# Performance
180219

@@ -197,7 +236,9 @@ To get performance under other sample rate, channel or complexity, please change
197236
| AMR-WB | 16000 | 1 | 5.6 | 37.69 |
198237
| ADPCM | 48000 | 2 | 0.01 | 2.69 |
199238
| OPUS | 48000 | 2 | 29.4 | 24.9 |
200-
239+
| SBC | 48000 | 2 | 1.85 | 9.55 |
240+
| LC3 | 48000 | 2 | 3.67 | 46.57 |
241+
201242
**Notes:**
202243
Encoder cpu usage is highly dependent on certain encoding settings (like bitrate or complexity)
203244
1) For AAC encoder, tested under bitrate 90kbps
@@ -217,6 +258,8 @@ Encoder cpu usage is highly dependent on certain encoding settings (like bitrate
217258
| OPUS | 48000 | 2 | 26.6 | 5.86 |
218259
| MP3 | 44100 | 2 | 28 | 8.17 |
219260
| FLAC | 44100 | 2 | 89.4 | 8.0 |
261+
| SBC | 48000 | 2 | 0.21 | 8.14 |
262+
| LC3 | 48000 | 2 | 1.36 | 17.5 |
220263

221264
**Notes:**
222265
1) MP3 and FLAC decoders are tested with real audio data. All other codes are tested with encoded data from sin wav PCM.
@@ -235,6 +278,8 @@ The following table shows the support of ESP_AUDIO_CODEC for Espressif SoCs. The
235278
|ESP32-C6 | &#10004; |
236279
|ESP32-S3 | &#10004; |
237280
|ESP32-P4 | &#10004; |
281+
|ESP32-C4 | &#10004; |
282+
|ESP32-H4 | &#10004; |
238283

239284
# Usage
240285

esp_audio_codec/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ description: Espressif audio encoder and decoder
55
issues: https://github.com/espressif/esp-adf/issues
66
repository: https://github.com/espressif/esp-adf-libs.git
77
url: https://github.com/espressif/esp-adf-libs/tree/master/esp_audio_codec
8-
version: 2.2.1
8+
version: 2.3.0

esp_audio_codec/include/decoder/esp_audio_dec.h

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
/**
2-
* ESPRESSIF MIT License
1+
/*
2+
* Espressif Modified MIT License
33
*
4-
* Copyright (c) 2024 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
4+
* Copyright (c) 2025 Espressif Systems (Shanghai) CO., LTD
55
*
6-
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
7-
* it is free of charge, to any person obtaining a copy of this software and associated
8-
* documentation files (the "Software"), to deal in the Software without restriction, including
9-
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11-
* to do so, subject to the following conditions:
6+
* Permission is hereby granted for use EXCLUSIVELY with Espressif Systems products.
7+
* This includes the right to use, copy, modify, merge, publish, distribute, and sublicense
8+
* the Software, subject to the following conditions:
129
*
13-
* The above copyright notice and this permission notice shall be included in all copies or
14-
* substantial portions of the Software.
10+
* 1. This Software MUST BE USED IN CONJUNCTION WITH ESPRESSIF SYSTEMS PRODUCTS.
11+
* 2. The above copyright notice and this permission notice shall be included in all copies
12+
* or substantial portions of the Software.
13+
* 3. Redistribution of the Software in source or binary form FOR USE WITH NON-ESPRESSIF PRODUCTS
14+
* is strictly prohibited.
1515
*
16-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
19+
* FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
* DEALINGS IN THE SOFTWARE.
2222
*
23+
* SPDX-License-Identifier: LicenseRef-Espressif-Modified-MIT
2324
*/
2425

2526
#pragma once
@@ -33,6 +34,14 @@
3334
extern "C" {
3435
#endif
3536

37+
/**
38+
* @brief Recovery strategy for tht current frame
39+
*/
40+
typedef enum {
41+
ESP_AUDIO_DEC_RECOVERY_NONE = 0, /*!< The current frame is a normal decoded frame */
42+
ESP_AUDIO_DEC_RECOVERY_PLC = 1, /*!< The current frame is recovered through the packet loss concealment (PLC) mechanism */
43+
} esp_audio_dec_recovery_t;
44+
3645
/**
3746
* @brief Audio decoder input frame
3847
*
@@ -55,9 +64,10 @@ extern "C" {
5564
*
5665
*/
5766
typedef struct {
58-
uint8_t *buffer; /*!< Input encoded data buffer */
59-
uint32_t len; /*!< Input data size to be decoded */
60-
uint32_t consumed; /*!< Consumed input data size (output) */
67+
uint8_t *buffer; /*!< Input encoded data buffer */
68+
uint32_t len; /*!< Input data size to be decoded */
69+
uint32_t consumed; /*!< Consumed input data size (output) */
70+
esp_audio_dec_recovery_t frame_recover; /*!< Recovery strategy for current frame */
6171
} esp_audio_dec_in_raw_t;
6272

6373
/**

esp_audio_codec/include/decoder/esp_audio_dec_default.h

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
/**
2-
* ESPRESSIF MIT License
1+
/*
2+
* Espressif Modified MIT License
33
*
4-
* Copyright (c) 2024 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
4+
* Copyright (c) 2025 Espressif Systems (Shanghai) CO., LTD
55
*
6-
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
7-
* it is free of charge, to any person obtaining a copy of this software and associated
8-
* documentation files (the "Software"), to deal in the Software without restriction, including
9-
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11-
* to do so, subject to the following conditions:
6+
* Permission is hereby granted for use EXCLUSIVELY with Espressif Systems products.
7+
* This includes the right to use, copy, modify, merge, publish, distribute, and sublicense
8+
* the Software, subject to the following conditions:
129
*
13-
* The above copyright notice and this permission notice shall be included in all copies or
14-
* substantial portions of the Software.
10+
* 1. This Software MUST BE USED IN CONJUNCTION WITH ESPRESSIF SYSTEMS PRODUCTS.
11+
* 2. The above copyright notice and this permission notice shall be included in all copies
12+
* or substantial portions of the Software.
13+
* 3. Redistribution of the Software in source or binary form FOR USE WITH NON-ESPRESSIF PRODUCTS
14+
* is strictly prohibited.
1515
*
16-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18-
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19-
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20-
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21-
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
19+
* FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
* DEALINGS IN THE SOFTWARE.
2222
*
23+
* SPDX-License-Identifier: LicenseRef-Espressif-Modified-MIT
2324
*/
2425

2526
#pragma once
@@ -36,6 +37,8 @@
3637
#include "esp_opus_dec.h"
3738
#include "esp_vorbis_dec.h"
3839
#include "esp_pcm_dec.h"
40+
#include "esp_sbc_dec.h"
41+
#include "esp_lc3_dec.h"
3942

4043
#ifdef __cplusplus
4144
extern "C" {

0 commit comments

Comments
 (0)