Hi Nicholas - this is all very interesting. I have a similar need to remove the dynamic memory allocation with static allocations for my application. Please keep us in the loop on your explorations!<br><br>Also, if some of the more experienced Tremor users/developers could chime in here on maximum allocations for various parts of the codec I would really appreciate it. I only need to worry about signals up to 2 channels which seems like it will simplify some of the allocations and let them easily resolve to a reasonable fixed value but other allocations it's not quite so clear what the limit is. Nicholas, are you planning on limiting your system to mono or stereo Ogg Vorbis files?<br>
<br>Lastly on memory usage, can someone comment on the "LIMIT_TO_64kHz" #define in a few places of the code? It removes the largest window which saves some memory, but this causes the codec to fail on decodes of highly compressed audio files right? What are the circumstances it is safe to enable this switch?<br>
<br>Ethan<br><br><div class="gmail_quote">On Sun, Nov 23, 2008 at 11:36 AM, Nicholas Vinen <span dir="ltr"><<a href="mailto:hb@x256.org">hb@x256.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Replying to myself again.<br>
<br>
Well, I've done some further investigations into Tremor's memory<br>
allocation. I have redirected each different call to<br>
malloc/calloc/realloc/free into a separate function. I've also set it up<br>
so that I can just change one #define and it will redirect them all back<br>
to the standard allocation functions. Thus this could possibly become a<br>
standard part of Tremor (if people feel it's worthwhile). The idea is<br>
that I can (a) see what's being allocated where and how much and (b)<br>
theoretically write different allocation functions for each type of<br>
buffer required.<br>
<br>
The more I think about this the more I think that I will be able to get<br>
away with dedicating a certain portion of memory to certain things (data<br>
buffers, "dectable", code books, etc.) and just split up this memory<br>
into chunks as required by Tremor. i.e. it will allocate them all in one<br>
go, then probably free them all when playback is finished, so there's no<br>
need for any kind of intelligent allocation. Some other things may be<br>
more dynamic but this could be handled by giving them "large enough"<br>
chunks (possibly more than they ask for) in order to cover the maximum<br>
that will be asked for.<br>
<br>
If/when I come up with a sensible static memory allocation strategy I'll<br>
report on it. For now here is what the allocations look like for playing<br>
back what I would consider a fairly ordinary Ogg Vorbis file. I note<br>
that it seems to be allocating an awfully large numer of buffers - I<br>
wonder if this could be reduced somewhat?<br>
<br>
_ogg_calloc_sync 28<br>
_ogg_calloc_bufstate 16<br>
_ogg_calloc_stream 76<br>
_ogg_malloc_buffer 16<br>
_ogg_malloc_bufdata 1024<br>
_ogg_malloc_ref 16<br>
_ogg_malloc_ref 16<br>
_ogg_malloc_ref 16<br>
_ogg_calloc_info 52<br>
_ogg_malloc_buffer 16<br>
_ogg_malloc_bufdata 1024<br>
_ogg_malloc_buffer 16<br>
_ogg_malloc_bufdata 1024<br>
_ogg_malloc_buffer 16<br>
_ogg_malloc_bufdata 1024<br>
_ogg_malloc_ref 16<br>
_ogg_malloc_ref 16<br>
_ogg_malloc_ref 16<br>
_ogg_malloc_ref 16<br>
_ogg_calloc_vendor 30<br>
_ogg_calloc_comments 20<br>
_ogg_calloc_commentlens 20<br>
_ogg_calloc_comments2 12<br>
_ogg_calloc_comments2 12<br>
_ogg_calloc_comments2 28<br>
_ogg_calloc_comments2 15<br>
_ogg_calloc_bookparam 2816<br>
_ogg_malloc_dectable 14<br>
_ogg_malloc_dectable 126<br>
_ogg_malloc_dectable 126<br>
_ogg_malloc_dectable 508<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 380<br>
_ogg_malloc_dectable 32<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 308<br>
_ogg_malloc_dectable 32<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 308<br>
_ogg_malloc_dectable 30<br>
_ogg_malloc_dectable 14<br>
_ogg_malloc_dectable 1020<br>
_ogg_malloc_dectable 126<br>
_ogg_malloc_dectable 508<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 380<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 380<br>
_ogg_malloc_dectable 32<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 308<br>
_ogg_malloc_dectable 32<br>
_ogg_malloc_dectable 62<br>
_ogg_malloc_dectable 308<br>
_ogg_malloc_dectable 198<br>
_ogg_malloc_dectable 192<br>
_ogg_malloc_dectable 1440<br>
_ogg_malloc_dectable 200<br>
_ogg_malloc_dectable 528<br>
_ogg_malloc_dectable 320<br>
_ogg_malloc_dectable 480<br>
_ogg_malloc_dectable 344<br>
_ogg_malloc_dectable 48<br>
_ogg_malloc_dectable 672<br>
_ogg_malloc_dectable 480<br>
_ogg_malloc_dectable 896<br>
_ogg_malloc_dectable 1760<br>
_ogg_malloc_dectable 672<br>
_ogg_malloc_dectable 672<br>
_ogg_malloc_dectable 96<br>
_ogg_malloc_dectable 198<br>
_ogg_malloc_floorparam 8<br>
_ogg_malloc_floortype 2<br>
_ogg_calloc_floor1 36<br>
_ogg_malloc_partition 6<br>
_ogg_malloc_class 44<br>
_ogg_malloc_postlist 38<br>
_ogg_malloc_fwdindex 19<br>
_ogg_malloc_loneighbor 17<br>
_ogg_malloc_hineighbor 17<br>
_ogg_malloc_fwdindex 19<br>
_ogg_free_fwdindex<br>
_ogg_calloc_floor1 36<br>
_ogg_malloc_partition 8<br>
_ogg_malloc_class 55<br>
_ogg_malloc_postlist 58<br>
_ogg_malloc_fwdindex 29<br>
_ogg_malloc_loneighbor 27<br>
_ogg_malloc_hineighbor 27<br>
_ogg_malloc_fwdindex 29<br>
_ogg_free_fwdindex<br>
_ogg_malloc_residueparam 56<br>
_ogg_malloc_stagemasks 10<br>
_ogg_malloc_stagebooks 80<br>
_ogg_malloc_stagemasks 10<br>
_ogg_malloc_stagebooks 80<br>
_ogg_malloc_mapparam 40<br>
_ogg_malloc_coupling 2<br>
_ogg_malloc_submaplist 2<br>
_ogg_malloc_coupling 2<br>
_ogg_malloc_submaplist 2<br>
_ogg_malloc_modeparam 4<br>
_ogg_malloc_offsets 16<br>
_ogg_malloc_serialnos 4<br>
_ogg_malloc_dataoffsets 8<br>
_ogg_malloc_pcmlens 16<br>
_ogg_malloc_buffer 16<br>
_ogg_malloc_bufdata 1024<br>
_ogg_malloc_ref 16<br>
_ogg_calloc_stream 76<br>
_ogg_free_stream<br>
title=Donna<br>
artist=10cc<br>
album=The Very Best of 10cc<br>
tracknumber=01<br>
<br>
Bitstream is 2 channel, 44100Hz<br>
<br>
Decoded length: 7776300 samples<br>
Encoded by: Xiph.Org libVorbis I 20050304<br>
<br>
_ogg_calloc_dspstate 76<br>
_ogg_malloc_dsp_work 8<br>
_ogg_malloc_dsp_mdct 8<br>
_ogg_calloc_dsp_work2 4096<br>
_ogg_calloc_dsp_mdct2 2048<br>
_ogg_calloc_dsp_work2 4096<br>
_ogg_calloc_dsp_mdct2 2048<br>
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz,<br>
Stereo<br>
_ogg_malloc_buffer 16<br>
_ogg_malloc_bufdata 1024<br>
_ogg_malloc_ref 16<br>
_ogg_malloc_ref 16<br>
<br>
Aborted by signal Interrupt...<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
_______________________________________________<br>
Tremor mailing list<br>
<a href="mailto:Tremor@xiph.org">Tremor@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/tremor" target="_blank">http://lists.xiph.org/mailman/listinfo/tremor</a><br>
</div></div></blockquote></div><br>