From 3d6faa08bf95da6e0f65a070a11f014e78c0b682 Mon Sep 17 00:00:00 2001 From: Andree Buschmann Date: Sun, 21 Feb 2010 19:47:05 +0000 Subject: Optimization for cook codec. Rework sample output to be able to use highly optimized dsp routines. Moved some functions to iram. Speeds up codec by 1.3 MHz on PP5022. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24815 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/cook.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'apps/codecs/cook.c') diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c index 4214d30f38..30255d4fd7 100644 --- a/apps/codecs/cook.c +++ b/apps/codecs/cook.c @@ -31,6 +31,7 @@ CODEC_HEADER RMContext rmctx; RMPacket pkt; COOKContext q IBSS_ATTR; +int32_t rm_outbuf[2048]; static void init_rm(RMContext *rmctx) { @@ -43,7 +44,6 @@ enum codec_status codec_main(void) static size_t buff_size; int datasize, res, consumed, i, time_offset; uint8_t *bit_buffer; - int16_t outbuf[2048] __attribute__((aligned(32))); uint16_t fs,sps,h; uint32_t packet_count; int scrambling_unit_size, num_units; @@ -65,9 +65,11 @@ next_track: init_rm(&rmctx); ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + /* cook's sample representation is 21.11 + * DSP_SET_SAMPLE_DEPTH = 11 (FRACT) + 16 (NATIVE) - 1 (SIGN) = 26 */ + ci->configure(DSP_SET_SAMPLE_DEPTH, 26); ci->configure(DSP_SET_STEREO_MODE, rmctx.nb_channels == 1 ? - STEREO_MONO : STEREO_INTERLEAVED); + STEREO_MONO : STEREO_NONINTERLEAVED); packet_count = rmctx.nb_packets; rmctx.audio_framesize = rmctx.block_align; @@ -155,7 +157,7 @@ seek_start : ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i); ci->seek_complete(); } - res = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i], rmctx.block_align); + res = cook_decode_frame(&rmctx,&q, rm_outbuf, &datasize, pkt.frames[i], rmctx.block_align); rmctx.frame_number++; /* skip the first two frames; no valid audio */ @@ -166,7 +168,9 @@ seek_start : return CODEC_ERROR; } - ci->pcmbuf_insert(outbuf, NULL, q.samples_per_frame / rmctx.nb_channels); + ci->pcmbuf_insert(rm_outbuf, + rm_outbuf+q.samples_per_channel, + q.samples_per_channel); ci->set_elapsed(rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i); } packet_count -= rmctx.audio_pkt_cnt; -- cgit v1.2.3