|
3 | 3 | * based on Xiph.Org Foundation celt decoder |
4 | 4 | * |
5 | 5 | * Created on: 26.01.2023 |
6 | | - * Updated on: 18.12.2024 |
| 6 | + * Updated on: 20.12.2024 |
7 | 7 | */ |
8 | 8 | //---------------------------------------------------------------------------------------------------------------------- |
9 | 9 | // O G G / O P U S I M P L. |
|
14 | 14 | #include "Arduino.h" |
15 | 15 | #include <vector> |
16 | 16 |
|
| 17 | +#define __malloc_heap_psram(size) \ |
| 18 | + heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL) |
| 19 | +#define __calloc_heap_psram(ch, size) \ |
| 20 | + heap_caps_calloc_prefer(ch, size, 2, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL) |
17 | 21 |
|
18 | 22 | // global vars |
19 | 23 | const uint32_t CELT_SET_END_BAND_REQUEST = 10012; |
@@ -65,9 +69,9 @@ float s_opusCompressionRatio = 0; |
65 | 69 | std::vector <uint32_t>s_opusBlockPicItem; |
66 | 70 |
|
67 | 71 | bool OPUSDecoder_AllocateBuffers(){ |
68 | | - s_opusChbuf = (char*)malloc(512); |
| 72 | + s_opusChbuf = (char*)__malloc_heap_psram(512); |
69 | 73 | if(!CELTDecoder_AllocateBuffers()) {log_e("CELT not init"); return false;} |
70 | | - s_opusSegmentTable = (uint16_t*)malloc(256 * sizeof(uint16_t)); |
| 74 | + s_opusSegmentTable = (uint16_t*)__malloc_heap_psram(256 * sizeof(uint16_t)); |
71 | 75 | if(!s_opusSegmentTable) {log_e("CELT not init"); return false;} |
72 | 76 | CELTDecoder_ClearBuffer(); |
73 | 77 | OPUSDecoder_ClearBuffers(); |
@@ -365,11 +369,6 @@ int32_t opus_decode_frame(uint8_t *inbuf, int16_t *outbuf, int32_t packetLen, ui |
365 | 369 | } |
366 | 370 |
|
367 | 371 | if(s_mode == MODE_SILK_ONLY) { |
368 | | - log_w("Silk mode not yet supported"); |
369 | | - return samplesPerFrame; |
370 | | - |
371 | | - |
372 | | - |
373 | 372 | int decodedSamples = 0; |
374 | 373 | int32_t silk_frame_size; |
375 | 374 | uint16_t payloadSize_ms = max(10, 1000 * samplesPerFrame / 48000); |
|
0 commit comments