summaryrefslogtreecommitdiff
path: root/apps/codecs/libtremor/synthesis.c
diff options
context:
space:
mode:
authorDave Hooper <dave@beermex.com>2009-04-25 11:25:13 +0000
committerDave Hooper <dave@beermex.com>2009-04-25 11:25:13 +0000
commit67fb5415f78a3198030a6285d1ccc641044f149b (patch)
tree1af65f6512f42361a5e83207d4b76b00265776cd /apps/codecs/libtremor/synthesis.c
parent738824ccdd327da7d9d13fe9d2a48e74c40ad62f (diff)
downloadrockbox-67fb5415f78a3198030a6285d1ccc641044f149b.tar.gz
rockbox-67fb5415f78a3198030a6285d1ccc641044f149b.zip
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/synthesis.c')
-rw-r--r--apps/codecs/libtremor/synthesis.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/apps/codecs/libtremor/synthesis.c b/apps/codecs/libtremor/synthesis.c
index cef240e796..b1c5eeccef 100644
--- a/apps/codecs/libtremor/synthesis.c
+++ b/apps/codecs/libtremor/synthesis.c
@@ -25,15 +25,7 @@
25#include "os.h" 25#include "os.h"
26 26
27 27
28/* IRAM buffer keep the block pcm data; only for windows size upto 2048
29 for space restrictions.
30 libVorbis 1.1 Oggenc doesn't use larger windows anyway. */
31/* max 2 channels on the ihp-1xx (stereo), 2048 samples (2*2048*4=16Kb) */
32#define IRAM_PCM_END 2048
33#define CHANNELS 2
34
35static ogg_int32_t *ipcm_vect[CHANNELS] IBSS_ATTR; 28static ogg_int32_t *ipcm_vect[CHANNELS] IBSS_ATTR;
36static ogg_int32_t ipcm_buff[CHANNELS*IRAM_PCM_END] IBSS_ATTR LINE_ATTR;
37 29
38int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep) 30int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep)
39 ICODE_ATTR_TREMOR_NOT_MDCT; 31 ICODE_ATTR_TREMOR_NOT_MDCT;
@@ -76,23 +68,33 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){
76 vb->eofflag=op->e_o_s; 68 vb->eofflag=op->e_o_s;
77 69
78 if(decodep && vi->channels<=CHANNELS){ 70 if(decodep && vi->channels<=CHANNELS){
71 vb->pcm = ipcm_vect;
72
79 /* alloc pcm passback storage */ 73 /* alloc pcm passback storage */
80 vb->pcmend=ci->blocksizes[vb->W]; 74 vb->pcmend=ci->blocksizes[vb->W];
81 if (vb->pcmend<=IRAM_PCM_END) { 75 if (vd->iram_pcm_storage >= vb->pcmend) {
82 /* use statically allocated iram buffer */ 76 /* use statically allocated iram buffer */
83 vb->pcm = ipcm_vect; 77 if(vd->reset_pcmb || vb->pcm[0]==NULL)
84 for(i=0; i<CHANNELS; i++) 78 {
85 vb->pcm[i] = &ipcm_buff[i*IRAM_PCM_END]; 79 /* one-time initialisation at codec start
80 NOT for every block synthesis start
81 allows us to flip between buffers once initialised
82 by simply flipping pointers */
83 for(i=0; i<vi->channels; i++)
84 vb->pcm[i] = &vd->iram_pcm[i*vd->iram_pcm_storage];
85 }
86 } else { 86 } else {
87 /* dynamic allocation (slower) */ 87 if(vd->reset_pcmb || vb->pcm[0]==NULL)
88 vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); 88 {
89 for(i=0;i<vi->channels;i++) 89 /* dynamic allocation (slower) */
90 vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); 90 for(i=0;i<vi->channels;i++)
91 vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
92 }
91 } 93 }
94 vd->reset_pcmb = false;
92 95
93 /* unpack_header enforces range checking */ 96 /* unpack_header enforces range checking */
94 type=ci->map_type[ci->mode_param[mode]->mapping]; 97 type=ci->map_type[ci->mode_param[mode]->mapping];
95
96 return(_mapping_P[type]->inverse(vb,b->mode[mode])); 98 return(_mapping_P[type]->inverse(vb,b->mode[mode]));
97 }else{ 99 }else{
98 /* no pcm */ 100 /* no pcm */