<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92932/opus-decoder-memory-usage</link><description>Hello, 
 I&amp;#39;m evaluating using the opus library included as a of the &amp;quot;nRFready Smart Remote 3 nRF52&amp;quot; as a part of our zephyr based application. We only need to decode stored opus voice files and don&amp;#39;t do any encoding. Our application is quite limited on</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 20 Oct 2022 09:55:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92932/opus-decoder-memory-usage" /><item><title>RE: OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/thread/391601?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 09:55:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a512fee-5e2c-41c6-99ce-46bef785f473</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;The encoder complexity setting had no real effect on stack usage. Constant vs variable bitrate also did not affect stack usage. However, I don&amp;#39;t have any data at hand that compares various bit rate streams with regards to stack usage.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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&amp;#39;t know if it will impact audio quality.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Audun&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/thread/391421?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 12:23:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2edc8d45-5b9f-4d03-84f9-e2b657ff73fe</guid><dc:creator>FranLovera</dc:creator><description>&lt;p&gt;I&amp;nbsp;also used this to determine the high water mark. This gave me a good idea, but all I know through this is the max use of the code paths I tested with. I don&amp;#39;t know if there are potential worse code paths which I haven&amp;#39;t been able to test.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/thread/391420?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 12:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:102ea987-671c-4596-b69b-329f712841c1</guid><dc:creator>FranLovera</dc:creator><description>&lt;p&gt;Hi, Yes I ran puncover to determine the worse case stack size, but because of the use of ALLOCs inside the OPUS code, we end up having a lot of dynamic stack allocations which puncover cannot calculate since the size of the variable is set at run time. For example OPUS uses these ALLOC calls throughout their code which dynamically allocate to the stack size:&lt;br /&gt;&lt;span&gt;&lt;br /&gt;#&lt;/span&gt;&lt;span class="pl-k"&gt;define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span class="pl-en"&gt;ALLOC&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class="pl-v"&gt;var, size, type&lt;/span&gt;&lt;span&gt;) type var[size]&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I could moved these to be in&amp;nbsp; the heap, but then I wouldn&amp;#39;t know how big my heap should be.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/thread/391336?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 07:23:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6be067fa-8d96-46c4-95de-fda4472b7e7e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Also take a look at the &lt;a href="https://github.com/HBehrens/puncover"&gt;PunCover&lt;/a&gt;&amp;nbsp;which seems to be used by few other customers we have.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/thread/391328?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 06:25:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6059d1c-738b-4703-8dc0-ed5167f62133</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user=""]Also, would you modify any of the parameters to reduce the RAM usage?[/quote]
&lt;p&gt;This seems to be a bit more technical then I can handle, I will ask the team if they have any recommendation on this one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: OPUS Decoder Memory Usage</title><link>https://devzone.nordicsemi.com/thread/391327?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 06:24:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:786587fc-e566-40f0-9040-a9ccc9b0349d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You should be able to figure this out in the application using &lt;a href="https://lists.zephyrproject.org/g/devel/topic/how_to_figure_out_the_stack/16760536?p="&gt;STACK_ANALYZE()&lt;/a&gt;&amp;nbsp;after you enable &lt;a href="https://docs.zephyrproject.org/3.0.0/reference/kconfig/CONFIG_STACK_USAGE.html"&gt;CONFIG_STACK_USAGE&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>