Unverified Commit 7dae4196 authored by Wolle's avatar Wolle Committed by GitHub

Add files via upload

parent 7ebd56e7
......@@ -2022,13 +2022,13 @@ int32_t celt_decoder_get_size(int32_t channels){
//----------------------------------------------------------------------------------------------------------------------
int32_t celt_decoder_init(int32_t channels){
// allocate buffers first
if (channels < 0 || channels > 2)
return OPUS_BAD_ARG;
if (cdec == NULL)
return OPUS_ALLOC_FAIL;
int n = celt_decoder_get_size(channels);
memset(cdec, 0, n * sizeof(char));
......@@ -2243,10 +2243,10 @@ void tf_decode(int32_t start, int32_t end, int32_t isTransient, int32_t *tf_res,
//----------------------------------------------------------------------------------------------------------------------
int32_t celt_decode_with_ec(const uint8_t *inbuf, int32_t len, int16_t *outbuf, int32_t frame_size) {
int32_t c, i, N;
int32_t spread_decision;
int32_t bits;
ec_ctx_t _dec;
int32_t *decode_mem[2];
int32_t *out_syn[2];
int16_t *lpc;
......@@ -2280,7 +2280,6 @@ int32_t celt_decode_with_ec(const uint8_t *inbuf, int32_t len, int16_t *outbuf,
const int16_t *eBands;
VALIDATE_CELT_DECODER(st);
nbEBands = m_CELTMode.nbEBands;
overlap = m_CELTMode.overlap;
eBands = eband5ms;
......@@ -2318,7 +2317,6 @@ int32_t celt_decode_with_ec(const uint8_t *inbuf, int32_t len, int16_t *outbuf,
// ec_dec_init((uint8_t *)inbuf, len);
if(C == 1) {
for(i = 0; i < nbEBands; i++) oldBandE[i] = max(oldBandE[i], oldBandE[nbEBands + i]);
}
......
......@@ -18,6 +18,7 @@ uint8_t m_channels = 0;
uint16_t m_samplerate = 0;
uint32_t m_segmentLength = 0;
char* m_chbuf = NULL;
int32_t s_validSamples = 0;
std::vector<uint16_t> m_segmentTable; // contains segment frame lengths
......@@ -25,6 +26,7 @@ std::vector<uint16_t> m_segmentTable; // contains segment frame lengths
bool OPUSDecoder_AllocateBuffers(){
m_chbuf = (char*)malloc(512);
log_i("Allocate Buffers");
CELTDecoder_AllocateBuffers();
return true;
}
void OPUSDecoder_FreeBuffers(){
......@@ -36,11 +38,13 @@ void OPUSDecoder_FreeBuffers(){
int OPUSDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf){
if(f_m_parseOgg){
log_i("parseogg");
// log_i("parseogg");
log_i("highWatermark %i", uxTaskGetStackHighWaterMark(NULL));
int ret = OPUSparseOGG(inbuf, bytesLeft);
return ret;
}
if(f_m_opusFramePacket){
if(m_segmentTable.size() > 0){
int len = m_segmentTable[m_segmentTable.size()-1];
......@@ -51,8 +55,10 @@ int OPUSDecode(uint8_t *inbuf, int *bytesLeft, short *outbuf){
int frame_size = opus_packet_get_samples_per_frame(inbuf, 48000);
inbuf++;
len--;
//int32_t validSamples = celt_decode_with_ec(inbuf, len, outbuf, frame_size);
log_i("len %i, frame_size %i", len, frame_size);
ec_dec_init((uint8_t *)inbuf, len);
celt_decoder_init(2);
s_validSamples = celt_decode_with_ec(inbuf, len, outbuf, frame_size);
if(m_segmentTable.size() == 0){
f_m_opusFramePacket = false;
f_m_parseOgg = true;
......@@ -94,7 +100,7 @@ uint32_t OPUSGetBitRate(){
return 1;
}
uint16_t OPUSGetOutputSamps(){
return 10; // 1024
return s_validSamples; // 1024
}
char* OPUSgetStreamTitle(){
if(f_m_newSt){
......@@ -106,6 +112,8 @@ char* OPUSgetStreamTitle(){
//----------------------------------------------------------------------------------------------------------------------
int parseOpusTOC(uint8_t TOC_Byte){ // https://www.rfc-editor.org/rfc/rfc6716 page 16 ff
uint8_t mode = 0;
static uint8_t oldmode = 0;
uint8_t configNr = 0;
uint8_t s = 0;
uint8_t c = 0; (void)c;
......@@ -113,6 +121,12 @@ int parseOpusTOC(uint8_t TOC_Byte){ // https://www.rfc-editor.org/rfc/rfc6716
configNr = (TOC_Byte & 0b11111000) >> 3;
s = (TOC_Byte & 0b00000100) >> 2;
c = (TOC_Byte & 0b00000011);
if(TOC_Byte & 0x80) mode = 2; else mode = 1;
if(oldmode != mode) {
oldmode = mode;
if(mode == 2) log_i("opus mode is MODE_CELT_ONLY");
}
/* Configuration Mode Bandwidth FrameSizes Audio Bandwidth Sample Rate (Effective)
configNr 16 ... 19 CELT NB (narrowband) 2.5, 5, 10, 20ms 4 kHz 8 kHz
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment