<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div>Hi everybody</div>
<div><br>
</div>
<div>I wrote a couple of months ago about implementing the opus codec on a DK52 from Nordic (nrf52832 MCU, Cortex M4). In the meantime I got a bit further and would again like to ask some questions.</div>
<div><br>
</div>
<div>My settings:</div>
<div>I included all the opus files into my project (opus-1.2.1)</div>
<div>Defined: FIXED POINT, VAR_ARRAYS, DISABLE FLOAT API, OPUS_BUILD, CELT_MODE_ONLY<br>
</div>
<div><br>
</div>
<div>I am able to allocate enough memory for the encoder as well as decoder state and they both return with OPUS_OK.</div>
<div><br>
</div>
<div><i> uint32_t error;<br>
opus_int32 Fs = 8000;<br>
int channels = 1;<br>
<br>
OpusEncoder *enc;<br>
enc = opus_encoder_create(Fs, channels, OPUS_APPLICATION_RESTRICTED_LOWDELAY, &error);<br>
<br>
OpusDecoder *dec;<br>
dec = opus_decoder_create(Fs, channels, &error);</i><br>
</div>
<div><br>
</div>
<div>However, If I try to make a simple example of opus_encode followed by and immediate opus_decode I do not get reasonable values compared to the input.</div>
<div>I'm wondering if I'm somehow misunderstanding how the codec works.</div>
<div>Could somebody tell me if my approach could work? <br>
</div>
<div><br>
</div>
<div><i> int frame_size = 160;<br>
opus_int16 test_data_size = frame_size*channels*sizeof(opus_int16);<br>
opus_int32 max_data_bytes = 100;<br>
<br>
opus_int16 test_data[test_data_size];<br>
opus_int16 *p_test_data = test_data;<br>
unsigned char encoded_buffer[max_data_bytes];<br>
unsigned char *p_encoded_buffer = encoded_buffer;<br>
opus_int16 decoded_buffer[test_data_size];<br>
opus_int16 *p_decoded_buffer = decoded_buffer;<br>
<br>
for(uint16_t i = 0; i < test_data_size; i++)<br>
{<br>
test_data[i] = 100;<br>
}<br>
<br>
opus_int32 encoded_size = opus_encode(enc, p_test_data, test_data_size, p_encoded_buffer, max_data_bytes);<br>
NRF_LOG_INFO("encoded size is %d", encoded_size);</i></div>
<div><i><br>
</i></div>
<div><i> opus_int32 decoded_size = opus_decode(dec, p_encoded_buffer, encoded_size, p_decoded_buffer, test_data_size, 0);<br>
NRF_LOG_INFO("decoded size is %d", decoded_size);</i></div>
<div><i><br>
</i></div>
<div>Opus_encode returns 55 as encoded length, which seems reasonable to me. Opus_decode returns 320.</div>
<div>The decoded values start out at 0, go to -16 up, then up to 135 and then slowly down to the 17 (see attached file).</div>
<div>Furthermore, I do not see much of a change if I increase the complexity.<br>
</div>
<div><br>
<i></i></div>
<div>I really think that I'm close to getting it working, but I'm definitely still missing something.<br>
</div>
<div>I would really be glad for any input.</div>
<div><br>
</div>
<div>Best,</div>
<div>Nick<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</body>
</html>