Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Tiny Decoder *read_stream implementation (Read 9844 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Tiny Decoder *read_stream implementation

Hi there,

I'm trying to implement a WavPack decoder on embedded hardware using a ARM Cortex-M3 hardware.
The code I use is from the Tiny Decoder package from the downloads page, version is 4.40. I'm using the C-version, no assembler code is used.

The wavpack file is on a FAT formatted SD-Card, I'm able to read both the SD card blockwise, as well as the FAT-system blockwise. Blocks are 512 bytes wide.
My implementation is incompatible to the format of the read_stream, so I try to implement a "translator" function.

I'm not sure, if I get it right:
Code: [Select]
typedef int32_t (*read_stream)(void *, int32_t);
This implements the stream access - I assume, my function has to return a int32-value of how many bytes it could read and write the bytes to a buffer, void* points to (should it be a char*), the number of bytes that should be read is passed to the function as int32_t?

Has anyone tried to get the decoder running on an ARM processor?
Is there a port of the assembler part to thumb2-instructions?

Thanks in advance!

Best regards
TinyTron

Tiny Decoder *read_stream implementation

Reply #1
I'm trying to implement a WavPack decoder on embedded hardware using a ARM Cortex-M3 hardware.


Thats an interesting choice.  Why such an odd ARM processor?


The wavpack file is on a FAT formatted SD-Card, I'm able to read both the SD card blockwise, as well as the FAT-system blockwise. Blocks are 512 bytes wide.
My implementation is incompatible to the format of the read_stream, so I try to implement a "translator" function.


So you want to do something like we do in rockbox, where the file is streamed a few KB at a time from storage, decode it, then do the next few KB?  Heres our code: 

http://svn.rockbox.org/viewvc.cgi/trunk/ap...amp;view=markup
http://svn.rockbox.org/viewvc.cgi/trunk/ap...ecs/libwavpack/

Has anyone tried to get the decoder running on an ARM processor?
Is there a port of the assembler part to thumb2-instructions?


I've never heard of someone using the Thumb2 processors for audio, but I think its not too different from standard ARMv4, so you could probably adapt our assembly.

Tiny Decoder *read_stream implementation

Reply #2
Hi there,

thanks for your reply! The Rockbox code looks good, have to go through it yet.

Thats an interesting choice.  Why such an odd ARM processor?


It's not that odd for me . We're using it for several projects, so it was the processor of choice, because of tools and experience with it.

I've never heard of someone using the Thumb2 processors for audio, but I think its not too different from standard ARMv4, so you could probably adapt our assembly.


Well, I'm programming using C, so assembler needs extra effort. Because Thumb doesn't work on the Cortex-M3-cores, it has to be rewritten. I'll test the performance using the C code, than adapt the assembly.

Best regards
TinyTron

Tiny Decoder *read_stream implementation

Reply #3
Code: [Select]
typedef int32_t (*read_stream)(void *, int32_t);
This implements the stream access - I assume, my function has to return a int32-value of how many bytes it could read and write the bytes to a buffer, void* points to (should it be a char*), the number of bytes that should be read is passed to the function as int32_t?
Yes, I think your understanding is correct. The only thing is that the stream reader function MUST read the number of bytes requested (and return that number) unless the stream is exhausted (i.e., EOF). If your "translator" function can only read 512 bytes from the filesystem at a time, then it will need to maintain a 512 byte buffer to hold any leftover bytes between calls from the tiny decoder.

BTW, the read_stream() function is almost identical to the standard Posix read() except that no file descriptor is passed in.

The ARM assembly routines provide some improvement in performance, but it's not huge (maybe 30% faster) and so it's quite likely that the C version will work fine for you unless you have some unfortunate combination of very high sampling rate and low CPU clock speed.

Please feel free to let me know if you run into any trouble or have other questions! 

David


Tiny Decoder *read_stream implementation

Reply #4
Hello guys
I am trying to port vorbis on cortex m4 but i couldn't find any descriptive guideline for same.
I am a newbie in this field but after i came across this post, i felt like you guys have pretty good knowledge in same.
Any help would be appreciable.

THANKS ALOT.