Index: apps/codecs/atrac3_rm.c =================================================================== --- apps/codecs/atrac3_rm.c (revision 22549) +++ apps/codecs/atrac3_rm.c (working copy) @@ -41,7 +41,6 @@ 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, elapsed = 0; @@ -62,9 +61,9 @@ init_rm(&rmctx); ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); - ci->configure(DSP_SET_SAMPLE_DEPTH, 16); + ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */ 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; @@ -145,7 +144,7 @@ ci->seek_complete(); } if(pkt.length) - res = atrac3_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i], rmctx.block_align); + res = atrac3_decode_frame(&rmctx, &q, &datasize, pkt.frames[i], rmctx.block_align); else /* indicates that there are no remaining frames */ goto done; @@ -155,7 +154,7 @@ } if(datasize) - ci->pcmbuf_insert(outbuf, NULL, q.samples_per_frame / rmctx.nb_channels); + ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, q.samples_per_frame / rmctx.nb_channels); elapsed = rmctx.audiotimestamp+(1000*8*sps/rmctx.bit_rate)*i; ci->set_elapsed(elapsed); rmctx.frame_number++; Index: apps/codecs/libatrac/atrac3.h =================================================================== --- apps/codecs/libatrac/atrac3.h (revision 22549) +++ apps/codecs/libatrac/atrac3.h (working copy) @@ -1,6 +1,14 @@ #include "ffmpeg_bitstream.h" #include "../librm/rm.h" +#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) +/* PP5022/24 and MCF5250 have larger IRAM */ +#define IBSS_ATTR_LARGE_IRAM IBSS_ATTR +#else +/* other CPUs IRAM is not large enough */ +#define IBSS_ATTR_LARGE_IRAM +#endif + /* These structures are needed to store the parsed gain control data. */ typedef struct { int num_gain_data; @@ -75,6 +83,5 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx); int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, - void *data, int *data_size, - const uint8_t *buf, int buf_size); + int *data_size, const uint8_t *buf, int buf_size); Index: apps/codecs/libatrac/atrac3.c =================================================================== --- apps/codecs/libatrac/atrac3.c (revision 22549) +++ apps/codecs/libatrac/atrac3.c (working copy) @@ -55,18 +55,9 @@ #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) -/** - * Clips a signed integer value into the -32768,32767 range. - */ -static inline int16_t av_clip_int16(int a) -{ - if ((a+32768) & ~65535) return (a>>31) ^ 32767; - else return a; -} - static int32_t qmf_window[48] IBSS_ATTR; static VLC spectral_coeff_tab[7]; -static channel_unit channel_units[2]; +static channel_unit channel_units[2] IBSS_ATTR_LARGE_IRAM; /** * Matrixing within quadrature mirror synthesis filter. @@ -375,7 +366,8 @@ /* Inverse quantize the coefficients. */ for (pIn=mantissas ; firstnum_gain_data == 0) gain1 = ONE_16; else @@ -580,7 +571,8 @@ pOut = &(pSpectrum[pComponent[cnt].pos]); for (i=0 ; iblock_align) return buf_size; @@ -887,19 +877,10 @@ return -1; } - if (q->channels == 1) { - /* mono */ - for (i = 0; i<1024; i++) - samples[i] = av_clip_int16(q->outSamples[i]); - *data_size = 1024 * sizeof(int16_t); - } else { - /* stereo */ - for (i = 0; i < 1024; i++) { - samples[i*2] = av_clip_int16(q->outSamples[i]); - samples[i*2+1] = av_clip_int16(q->outSamples[1024+i]); - } - *data_size = 2048 * sizeof(int16_t); - } + if (q->channels == 1) + *data_size = 1024 * sizeof(int32_t); + else + *data_size = 2048 * sizeof(int32_t); return rmctx->block_align; }