Skip to content

Commit 2a0eb19

Browse files
committed
SILK-ONLY mode released
1 parent d8a09df commit 2a0eb19

File tree

3 files changed

+39
-279
lines changed

3 files changed

+39
-279
lines changed

src/opus_decoder/opus_decoder.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* based on Xiph.Org Foundation celt decoder
44
*
55
* Created on: 26.01.2023
6-
* Updated on: 18.12.2024
6+
* Updated on: 20.12.2024
77
*/
88
//----------------------------------------------------------------------------------------------------------------------
99
// O G G / O P U S I M P L.
@@ -14,6 +14,10 @@
1414
#include "Arduino.h"
1515
#include <vector>
1616

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)
1721

1822
// global vars
1923
const uint32_t CELT_SET_END_BAND_REQUEST = 10012;
@@ -65,9 +69,9 @@ float s_opusCompressionRatio = 0;
6569
std::vector <uint32_t>s_opusBlockPicItem;
6670

6771
bool OPUSDecoder_AllocateBuffers(){
68-
s_opusChbuf = (char*)malloc(512);
72+
s_opusChbuf = (char*)__malloc_heap_psram(512);
6973
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));
7175
if(!s_opusSegmentTable) {log_e("CELT not init"); return false;}
7276
CELTDecoder_ClearBuffer();
7377
OPUSDecoder_ClearBuffers();
@@ -365,11 +369,6 @@ int32_t opus_decode_frame(uint8_t *inbuf, int16_t *outbuf, int32_t packetLen, ui
365369
}
366370

367371
if(s_mode == MODE_SILK_ONLY) {
368-
log_w("Silk mode not yet supported");
369-
return samplesPerFrame;
370-
371-
372-
373372
int decodedSamples = 0;
374373
int32_t silk_frame_size;
375374
uint16_t payloadSize_ms = max(10, 1000 * samplesPerFrame / 48000);

0 commit comments

Comments
 (0)