summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-06 19:20:55 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-07-06 19:20:55 +0000
commit5ac35458436cc6eee5a411c45ca11e782cb3c5af (patch)
treecd3c28c62661f238a543666f3ba6f615bc519a69
parent39e252019f55dab3e6119cba92caf451c29aa92b (diff)
downloadrockbox-5ac35458436cc6eee5a411c45ca11e782cb3c5af.tar.gz
rockbox-5ac35458436cc6eee5a411c45ca11e782cb3c5af.zip
Integrate FS#11445 to raac. In addition remove faad specific pcm conversion and use rockbox' optimized dsp routines. On a 192kbps file and PP5022 the decoding speeds up by 17%.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27319 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/raac.c56
1 files changed, 46 insertions, 10 deletions
diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c
index 2f3635a8ac..93972f557b 100644
--- a/apps/codecs/raac.c
+++ b/apps/codecs/raac.c
@@ -28,6 +28,13 @@
28 28
29CODEC_HEADER 29CODEC_HEADER
30 30
31/* Global buffers to be used in the mdct synthesis. This way the arrays can
32 * be moved to IRAM for some targets */
33#define GB_BUF_SIZE 1024
34ALIGN real_t gb_time_buffer[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM;
35ALIGN real_t gb_fb_intermed[2][GB_BUF_SIZE] IBSS_ATTR_FAAD_LARGE_IRAM;
36
37
31static void init_rm(RMContext *rmctx) 38static void init_rm(RMContext *rmctx)
32{ 39{
33 memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext)); 40 memcpy(rmctx, (void*)(( (intptr_t)ci->id3->id3v2buf + 3 ) &~ 3), sizeof(RMContext));
@@ -40,8 +47,9 @@ enum codec_status codec_main(void)
40{ 47{
41 static NeAACDecFrameInfo frame_info; 48 static NeAACDecFrameInfo frame_info;
42 NeAACDecHandle decoder; 49 NeAACDecHandle decoder;
43 size_t n; 50 size_t n;
44 int32_t *output; 51 void *ret;
52 int needed_bufsize;
45 unsigned int i; 53 unsigned int i;
46 unsigned char* buffer; 54 unsigned char* buffer;
47 int err, consumed, pkt_offset, skipped = 0; 55 int err, consumed, pkt_offset, skipped = 0;
@@ -51,8 +59,8 @@ enum codec_status codec_main(void)
51 size_t resume_offset = ci->id3->offset; 59 size_t resume_offset = ci->id3->offset;
52 60
53 /* Generic codec initialisation */ 61 /* Generic codec initialisation */
54 ci->configure(DSP_SET_STEREO_MODE, STEREO_INTERLEAVED); 62 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
55 ci->configure(DSP_SET_SAMPLE_DEPTH, 16); 63 ci->configure(DSP_SET_SAMPLE_DEPTH, 29);
56 64
57next_track: 65next_track:
58 err = CODEC_OK; 66 err = CODEC_OK;
@@ -80,7 +88,7 @@ next_track:
80 goto done; 88 goto done;
81 } 89 }
82 NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(decoder); 90 NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(decoder);
83 conf->outputFormat = FAAD_FMT_16BIT; 91 conf->outputFormat = FAAD_FMT_16BIT; /* irrelevant, we don't convert */
84 NeAACDecSetConfiguration(decoder, conf); 92 NeAACDecSetConfiguration(decoder, conf);
85 93
86 decoder->config.defObjectType = rmctx.codec_extradata[0]; 94 decoder->config.defObjectType = rmctx.codec_extradata[0];
@@ -91,7 +99,35 @@ next_track:
91 DEBUGF("FAAD: DecInit: %d, %d\n", err, decoder->object_type); 99 DEBUGF("FAAD: DecInit: %d, %d\n", err, decoder->object_type);
92 err = CODEC_ERROR; 100 err = CODEC_ERROR;
93 goto done; 101 goto done;
94 } 102 }
103
104 /* Set pointer to be able to use IRAM an to avoid alloc in decoder. Must
105 * be called after NeAACDecOpen(). */
106 /* A buffer of framelength or 2*frameLenght size must be allocated for
107 * time_out. If frameLength is too big or SBR/forceUpSampling is active,
108 * we do not use the IRAM buffer and keep faad's internal allocation (see
109 * specrec.c). */
110 needed_bufsize = decoder->frameLength;
111#ifdef SBR_DEC
112 if ((decoder->sbr_present_flag == 1) || (decoder->forceUpSampling == 1))
113 {
114 needed_bufsize *= 2;
115 }
116#endif
117 if (needed_bufsize <= GB_BUF_SIZE)
118 {
119 decoder->time_out[0] = &gb_time_buffer[0][0];
120 decoder->time_out[1] = &gb_time_buffer[1][0];
121 }
122 /* A buffer of with frameLength elements must be allocated for fb_intermed.
123 * If frameLength is too big, we do not use the IRAM buffer and keep faad's
124 * internal allocation (see specrec.c). */
125 needed_bufsize = decoder->frameLength;
126 if (needed_bufsize <= GB_BUF_SIZE)
127 {
128 decoder->fb_intermed[0] = &gb_fb_intermed[0][0];
129 decoder->fb_intermed[1] = &gb_fb_intermed[1][0];
130 }
95 131
96 /* check for a mid-track resume and force a seek time accordingly */ 132 /* check for a mid-track resume and force a seek time accordingly */
97 if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { 133 if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) {
@@ -172,16 +208,16 @@ seek_start:
172 goto done; 208 goto done;
173 /* Decode one block - returned samples will be host-endian */ 209 /* Decode one block - returned samples will be host-endian */
174 for(i = 0; i < rmctx.sub_packet_cnt; i++) { 210 for(i = 0; i < rmctx.sub_packet_cnt; i++) {
175 output = (int32_t *)NeAACDecDecode(decoder, &frame_info, buffer, rmctx.sub_packet_lengths[i]); 211 ret = NeAACDecDecode(decoder, &frame_info, buffer, rmctx.sub_packet_lengths[i]);
176 buffer += rmctx.sub_packet_lengths[i]; 212 buffer += rmctx.sub_packet_lengths[i];
177 if (frame_info.error > 0) { 213 if (frame_info.error > 0) {
178 DEBUGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error)); 214 DEBUGF("FAAD: decode error '%s'\n", NeAACDecGetErrorMessage(frame_info.error));
179 err = CODEC_ERROR; 215 err = CODEC_ERROR;
180 goto exit; 216 goto exit;
181 } 217 }
182 output = (int32_t *) output_to_PCM(decoder, decoder->time_out, output, 218 ci->pcmbuf_insert(decoder->time_out[0],
183 rmctx.nb_channels, decoder->frameLength, decoder->config.outputFormat); 219 decoder->time_out[1],
184 ci->pcmbuf_insert(output, NULL, frame_info.samples/rmctx.nb_channels); 220 decoder->frameLength);
185 ci->set_elapsed(pkt.timestamp); 221 ci->set_elapsed(pkt.timestamp);
186 } 222 }
187 223