[opus] OPUS on cortex M4

Ehrenberg Nicolas enicolas at student.ethz.ch
Fri Jun 29 18:48:18 UTC 2018


Hi everybody

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.

My settings:
I included all the opus files into my project (opus-1.2.1)
Defined: FIXED POINT, VAR_ARRAYS, DISABLE FLOAT API, OPUS_BUILD, CELT_MODE_ONLY

I am able to allocate enough memory for the encoder as well as decoder state and they both return with OPUS_OK.

    uint32_t error;
    opus_int32 Fs = 8000;
    int channels = 1;

    OpusEncoder *enc;
    enc = opus_encoder_create(Fs, channels, OPUS_APPLICATION_RESTRICTED_LOWDELAY, &error);

    OpusDecoder *dec;
    dec = opus_decoder_create(Fs, channels, &error);

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.
I'm wondering if I'm somehow misunderstanding how the codec works.
Could somebody tell me if my approach could work?

    int frame_size = 160;
    opus_int16 test_data_size = frame_size*channels*sizeof(opus_int16);
    opus_int32 max_data_bytes = 100;

    opus_int16 test_data[test_data_size];
    opus_int16 *p_test_data = test_data;
    unsigned char encoded_buffer[max_data_bytes];
    unsigned char *p_encoded_buffer = encoded_buffer;
    opus_int16 decoded_buffer[test_data_size];
    opus_int16 *p_decoded_buffer = decoded_buffer;

    for(uint16_t i = 0; i < test_data_size; i++)
    {
    test_data[i] = 100;
    }

    opus_int32 encoded_size = opus_encode(enc, p_test_data, test_data_size, p_encoded_buffer, max_data_bytes);
    NRF_LOG_INFO("encoded size is %d", encoded_size);

    opus_int32 decoded_size = opus_decode(dec, p_encoded_buffer, encoded_size, p_decoded_buffer, test_data_size, 0);
    NRF_LOG_INFO("decoded size is %d", decoded_size);

Opus_encode returns 55 as encoded length, which seems reasonable to me. Opus_decode returns 320.
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).
Furthermore, I do not see much of a change if I increase the complexity.

I really think that I'm close to getting it working, but I'm definitely still missing something.
I would really be glad for any input.

Best,
Nick



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/opus/attachments/20180629/5a28d662/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opus_sample_results.pdf
Type: application/pdf
Size: 47381 bytes
Desc: opus_sample_results.pdf
URL: <http://lists.xiph.org/pipermail/opus/attachments/20180629/5a28d662/attachment-0001.pdf>


More information about the opus mailing list