diff options
author | Dave Hooper <dave@beermex.com> | 2009-04-25 11:25:13 +0000 |
---|---|---|
committer | Dave Hooper <dave@beermex.com> | 2009-04-25 11:25:13 +0000 |
commit | 67fb5415f78a3198030a6285d1ccc641044f149b (patch) | |
tree | 1af65f6512f42361a5e83207d4b76b00265776cd /apps/codecs/libtremor/oggmalloc.c | |
parent | 738824ccdd327da7d9d13fe9d2a48e74c40ad62f (diff) |
Commit FS#9882 - make better use of iram at different quality encodings, remove redundant memsets, implement doublebuffer if it will fit in iram to save a mempcy each frame, and some alignment fixes for coldfire
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20783 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libtremor/oggmalloc.c')
-rw-r--r-- | apps/codecs/libtremor/oggmalloc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/codecs/libtremor/oggmalloc.c b/apps/codecs/libtremor/oggmalloc.c index 4aa2760629..6da7cfcedc 100644 --- a/apps/codecs/libtremor/oggmalloc.c +++ b/apps/codecs/libtremor/oggmalloc.c @@ -81,3 +81,27 @@ void ogg_tmpmalloc_free(long pos) { tmp_ptr = pos; } + +/* Allocate IRAM buffer */ +static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR __attribute__ ((aligned (16))); +static size_t iram_remain; + +void iram_malloc_init(void){ + iram_remain=IRAM_IBSS_SIZE; +} + +void *iram_malloc(size_t size){ + void* x; + + /* always ensure 16-byte aligned */ + if(size&0x0f) + size=(size-(size&0x0f))+16; + + if(size>iram_remain) + return NULL; + + x = &iram_buff[IRAM_IBSS_SIZE-iram_remain]; + iram_remain-=size; + + return x; +} |