Ulisses Piassa
2017-Jun-05 12:28 UTC
[opus] Trying to use Opus in an STM32F429IIT6 embedded project
Hi everyone, I'm trying to use Opus in an Embedded Project which I'm developing in a STM32F429IIT6 microcontroller. Currently, I'm playing wav files in it. I ported all the files from OpusLib 1.1.4 needed to compile the project, but when I try to create and OpusDecode state, it returns the error -7 (OPUS_ALLOC_FAIL). I'm compiling it with the USE_ALLOCA flag. I also tried to compile it with the flags OVERRIDE_OPUS_ALLOC OVERRIDE_OPUS_FREE 'opus_alloc(x)=NULL' and 'opus_free(x)=NULL', but still having no success. The code I wrote is: int size; int error; OpusDecoder* dec; size = opus_decoder_get_size(1); dec = (OpusDecoder *) malloc(size); error = opus_decoder_init(dec, 8000, 1); I also tried this code: int error; OpusDecoder *dec; dec = opus_decoder_create(8000, 1, &error); In this particular case, I got an error and the firmware crashes. Once I'm totally new to embedded systems, I'd like to ask some help from you. Can anyone shed some light on it? Thx a lot. Regards, Ulisses -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/opus/attachments/20170605/5a0142bb/attachment.html>
Jean-Marc Valin
2017-Jun-05 16:05 UTC
[opus] Trying to use Opus in an STM32F429IIT6 embedded project
On 05/06/17 08:28 AM, Ulisses Piassa wrote:> I ported all the files from OpusLib 1.1.4 needed to compile the project, > but when I try to create and OpusDecode state, it returns the error -7 > (OPUS_ALLOC_FAIL).Are you getting OPUS_ALLOC_FAIL on the opus_decoder_init() too or just on opus_decoder_create()?> I'm compiling it with the USE_ALLOCA flag. I also tried to compile it > with the flags OVERRIDE_OPUS_ALLOC OVERRIDE_OPUS_FREE > 'opus_alloc(x)=NULL' and 'opus_free(x)=NULL', but still having no success.when you use OVERRIDE_OPUS_ALLOC and opus_alloc(x)=NULL you're essentially saying "I don't have a working malloc()", so none of the calls to the *_create() functions can work, it's normal that you're seeing those fail with OPUS_ALLOC_FAIL because there's no way the library is able to allocate memory.> The code I wrote is: > > int size; > int error; > OpusDecoder* dec; > > size = opus_decoder_get_size(1); > dec = (OpusDecoder *) malloc(size); > error = opus_decoder_init(dec, 8000, 1);This version should actually work and I don't see how opus_decoder_init() could return OPUS_ALLOC_FAIL since it's not allocating anything. Are you sure that's what it returns? Jean-Marc
Mirko Divac
2017-Jun-06 10:07 UTC
[opus] Trying to use Opus in an STM32F429IIT6 embedded project
What about heap size? Do you have enough free space there? I've had same problem on SAMS70N21, and I've solved it with freeing more space for dynamic allocation. Best regards. Mirko On 5.6.2017 18:05, Jean-Marc Valin wrote:> On 05/06/17 08:28 AM, Ulisses Piassa wrote: >> I ported all the files from OpusLib 1.1.4 needed to compile the project, >> but when I try to create and OpusDecode state, it returns the error -7 >> (OPUS_ALLOC_FAIL). > Are you getting OPUS_ALLOC_FAIL on the opus_decoder_init() too or just > on opus_decoder_create()? > >> I'm compiling it with the USE_ALLOCA flag. I also tried to compile it >> with the flags OVERRIDE_OPUS_ALLOC OVERRIDE_OPUS_FREE >> 'opus_alloc(x)=NULL' and 'opus_free(x)=NULL', but still having no success. > when you use OVERRIDE_OPUS_ALLOC and opus_alloc(x)=NULL you're > essentially saying "I don't have a working malloc()", so none of the > calls to the *_create() functions can work, it's normal that you're > seeing those fail with OPUS_ALLOC_FAIL because there's no way the > library is able to allocate memory. > >> The code I wrote is: >> >> int size; >> int error; >> OpusDecoder* dec; >> >> size = opus_decoder_get_size(1); >> dec = (OpusDecoder *) malloc(size); >> error = opus_decoder_init(dec, 8000, 1); > This version should actually work and I don't see how > opus_decoder_init() could return OPUS_ALLOC_FAIL since it's not > allocating anything. Are you sure that's what it returns? > > Jean-Marc > _______________________________________________ > opus mailing list > opus at xiph.org > http://lists.xiph.org/mailman/listinfo/opus-- Mirko Divac Research and Development Engineer, ARS Embedded Systems LLC p: +381 62 471 534 a: Jovana Subotića 9, 21000, Novi Sad, Serbia w: www.engineering.ars-es.com <http://www.engineering.ars-es.com> e: mirko.divac at ars-es.com <mailto:mirko.divac at ars-es.com> --- Ovaj email je proveren na maliciozne programe od strane Avast antivirus softvera. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/opus/attachments/20170606/fb8df409/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: logo_ARS.jpg Type: image/jpeg Size: 9788 bytes Desc: not available URL: <http://lists.xiph.org/pipermail/opus/attachments/20170606/fb8df409/attachment.jpg>
Ulisses Piassa
2017-Jun-07 11:42 UTC
[opus] Trying to use Opus in an STM32F429IIT6 embedded project
Hi everybody, I tried the solutions proposed and some more things, but afterall, I still could not figure out whats going wrong... Some developers told me to try using the "opusfile" library, but it seems really complicated to port to my project. So I'm back to the mark zero. Here's an screenshot of the files I ported to my project: [image: Inline image 1] [image: Inline image 2] [image: Inline image 3] When I say "port", I mean "I put all the files that the compiler looked for and generated an error for not finding them". If I want to use the "decode" function, I put all the files which this function depends on. Absolutely ANY help would be useful. If anyone can give me any clue, I'll be really thankful! Thanks a lot! Best Regards, Ulisses P.S.: I'm sorry Jean-Marc, I'd just realized that I replied for you only, and not for the opus list. My apologies. On Mon, Jun 5, 2017 at 1:05 PM, Jean-Marc Valin <jmvalin at jmvalin.ca> wrote:> On 05/06/17 08:28 AM, Ulisses Piassa wrote: > > I ported all the files from OpusLib 1.1.4 needed to compile the project, > > but when I try to create and OpusDecode state, it returns the error -7 > > (OPUS_ALLOC_FAIL). > > Are you getting OPUS_ALLOC_FAIL on the opus_decoder_init() too or just > on opus_decoder_create()? > > > I'm compiling it with the USE_ALLOCA flag. I also tried to compile it > > with the flags OVERRIDE_OPUS_ALLOC OVERRIDE_OPUS_FREE > > 'opus_alloc(x)=NULL' and 'opus_free(x)=NULL', but still having no > success. > > when you use OVERRIDE_OPUS_ALLOC and opus_alloc(x)=NULL you're > essentially saying "I don't have a working malloc()", so none of the > calls to the *_create() functions can work, it's normal that you're > seeing those fail with OPUS_ALLOC_FAIL because there's no way the > library is able to allocate memory. > > > The code I wrote is: > > > > int size; > > int error; > > OpusDecoder* dec; > > > > size = opus_decoder_get_size(1); > > dec = (OpusDecoder *) malloc(size); > > error = opus_decoder_init(dec, 8000, 1); > > This version should actually work and I don't see how > opus_decoder_init() could return OPUS_ALLOC_FAIL since it's not > allocating anything. Are you sure that's what it returns? > > Jean-Marc >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/opus/attachments/20170607/d4fae27c/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 31210 bytes Desc: not available URL: <http://lists.xiph.org/pipermail/opus/attachments/20170607/d4fae27c/attachment-0003.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 33964 bytes Desc: not available URL: <http://lists.xiph.org/pipermail/opus/attachments/20170607/d4fae27c/attachment-0004.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 32168 bytes Desc: not available URL: <http://lists.xiph.org/pipermail/opus/attachments/20170607/d4fae27c/attachment-0005.png>