OPUS Decoder Memory Usage

Hello,

I'm evaluating using the opus library included as a of the "nRFready Smart Remote 3 nRF52" as a part of our zephyr based application. We only need to decode stored opus voice files and don't do any encoding. Our application is quite limited on RAM, so we'd like to reduce the stack sizes used by opus as much as possible. I've been able to integrate it properly and things to seem to work, but am wondering how to set the stack sizes accordingly. Currently we're using 8kHz Sampling Frequency, CELT, 16K constant bitrate, 10mS Frame Size, 1 Channel. This leads to  9224 for the OpusDecoder structure, and our stack size is set at 10k bytes for the dynamically allocated ALLOCs throughout the opus code. 

I wanted to ask for recommendations on the recommended minimum stack size for opus decoding?

Also, would you modify any of the parameters to reduce the RAM usage?

Thanks,

Francisco 

  • Hello,

    we did gather some metrics related to Opus decoding, but it was all for 48 kHz stereo decoding, so the following numbers are likely on the higher end compared to your configuration.

    Edit: these numbers were gathered using nRF5 SDK, which does not use any OS. There might be other factors that affects stack usage in Zephyr.

    The stack usage, not counting any frame buffers or state struct, was ~7 KiB for 10 ms frame length. Reducing frame length to 5 ms also reduced stack usage, to a total of ~5.5 KiB.

    The encoder complexity setting had no real effect on stack usage. Constant vs variable bitrate also did not affect stack usage. However, I don't have any data at hand that compares various bit rate streams with regards to stack usage.

    I also recommend following the stack analysis recommendation by Susheel. For example, use a nRF chip with more RAM, set the stack size of the decoding thread quite high, and run various audio test scenarios with their resulting stack usage watermarks.

    To answer your question directly, I believe you could reduce stack usage by reducing the frame length. Reducing frame length can lead to somewhat increased CPU usage. I don't know if it will impact audio quality.

    Best regards,

    Audun

Related