Index: apps/codecs/libcook/cook.h =================================================================== --- apps/codecs/libcook/cook.h (revision 29899) +++ apps/codecs/libcook/cook.h (working copy) @@ -27,6 +27,31 @@ #include "../librm/rm.h" #include "cookdata_fixpoint.h" +#include "codeclib.h" + +#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) +/* PP5022/24, MCF5250 have large IRAM */ +#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_COOK_VLCBUF + +#elif defined(CPU_S5L870X) +/* S5L870X have even larger IRAM */ +#define IBSS_ATTR_COOK_LARGE_IRAM IBSS_ATTR +#define ICODE_ATTR_COOK_LARGE_IRAM ICODE_ATTR +#define ICONST_ATTR_COOK_LARGE_IRAM ICONST_ATTR +#define IBSS_ATTR_COOK_VLCBUF IBSS_ATTR + +#else +/* other CPUs IRAM is not large enough */ +#define IBSS_ATTR_COOK_LARGE_IRAM +#define ICODE_ATTR_COOK_LARGE_IRAM +#define ICONST_ATTR_COOK_LARGE_IRAM +#define IBSS_ATTR_COOK_VLCBUF + +#endif + typedef struct { int *now; int *previous; @@ -86,13 +111,14 @@ /* data buffers */ - uint8_t decoded_bytes_buffer[1024]; - REAL_T mono_mdct_output[2048] __attribute__ ((aligned(16))); - REAL_T mono_previous_buffer1[1024]; - REAL_T mono_previous_buffer2[1024]; - REAL_T decode_buffer_1[1024]; - REAL_T decode_buffer_2[1024]; - REAL_T decode_buffer_0[1060]; /* static allocation for joint decode */ + uint8_t decoded_bytes_buffer[1024] MEM_ALIGN_ATTR; + REAL_T mono_mdct_output[2048] MEM_ALIGN_ATTR; + REAL_T mono_previous_buffer1[1024] MEM_ALIGN_ATTR; + REAL_T mono_previous_buffer2[1024] MEM_ALIGN_ATTR; + REAL_T decode_buffer_1[1024] MEM_ALIGN_ATTR; + REAL_T decode_buffer_2[1024] MEM_ALIGN_ATTR; + /* static allocation for joint decode */ + REAL_T decode_buffer_0[1060] MEM_ALIGN_ATTR; } COOKContext; int cook_decode_init(RMContext *rmctx, COOKContext *q); Index: apps/codecs/libcook/cookdata_fixpoint.h =================================================================== --- apps/codecs/libcook/cookdata_fixpoint.h (revision 29899) +++ apps/codecs/libcook/cookdata_fixpoint.h (working copy) @@ -39,7 +39,7 @@ typedef struct { } realvars_t; -static const FIXPU pow128_tab[128] = { +static const FIXPU pow128_tab[128] ICONST_ATTR = { /* x_i = 2^(15+i/128) */ 0x8000, 0x80b2, 0x8165, 0x8219, 0x82ce, 0x8383, 0x843a, 0x84f2, 0x85ab, 0x8665, 0x871f, 0x87db, 0x8898, 0x8956, 0x8a15, 0x8ad5, 0x8b96, 0x8c58, @@ -131,27 +131,27 @@ 0x00000000, 0x00000000 }}}; -static const FIXPU cplscale2[3] = { +static const FIXPU cplscale2[3] ICONST_ATTR = { /* 2^16 C_ij */ 0xf3f9, 0xb505, 0x4d8b }; -static const FIXPU cplscale3[7] = { +static const FIXPU cplscale3[7] ICONST_ATTR = { /* 2^16 C_ij */ 0xfb35, 0xefdf, 0xe03d, 0xb505, 0x7b81, 0x596e, 0x314d }; -static const FIXPU cplscale4[15] = { +static const FIXPU cplscale4[15] ICONST_ATTR = { /* 2^16 C_ij */ 0xfdd2, 0xf927, 0xf3f9, 0xee1d, 0xe749, 0xdee9, 0xd381, 0xb505, 0x903b, 0x7de2, 0x6dbe, 0x5e02, 0x4d8b, 0x3ad1, 0x2155 }; -static const FIXPU cplscale5[31] = { +static const FIXPU cplscale5[31] ICONST_ATTR = { /* 2^16 C_ij */ 0xfef5, 0xfcce, 0xfa8e, 0xf832, 0xf5b5, 0xf314, 0xf049, 0xed4c, 0xea12, 0xe68e, 0xe2ab, 0xde4b, 0xd938, 0xd30b, 0xcab6, 0xb505, 0x9c59, 0x90e8, 0x8778, 0x7ef9, 0x76fc, 0x6f45, 0x67ab, 0x600e, 0x5850, 0x504d, 0x47db, 0x3ebd, 0x3486, 0x2853, 0x1715 }; -static const FIXPU cplscale6[63] = { +static const FIXPU cplscale6[63] ICONST_ATTR = { /* 2^16 C_ij */ 0xff7d, 0xfe74, 0xfd65, 0xfc50, 0xfb35, 0xfa14, 0xf8eb, 0xf7bb, 0xf683, 0xf543, 0xf3f9, 0xf2a6, 0xf148, 0xefdf, 0xee6a, 0xece6, 0xeb54, 0xe9b2, Index: apps/codecs/libcook/cook.c =================================================================== --- apps/codecs/libcook/cook.c (revision 29899) +++ apps/codecs/libcook/cook.c (working copy) @@ -102,31 +102,47 @@ #endif /*************** init functions ***************/ -#define VLCBUFSIZE 1500 -VLC_TYPE vlcbuf[21][VLCBUFSIZE][2]; +#define VLCBUFSIZE 1456 +VLC_TYPE vlcbuf1[4][VLCBUFSIZE][2] IBSS_ATTR_COOK_LARGE_IRAM; /* 23296 byte */ +VLC_TYPE vlcbuf2[8][VLCBUFSIZE][2] IBSS_ATTR_COOK_VLCBUF; /* 46592 byte */ +VLC_TYPE vlcbuf3[9][VLCBUFSIZE][2]; /* 52416 byte */ static int init_cook_vlc_tables(COOKContext *q) { - int i, result; + int i, result = 0; + + /* Set buffer pointers */ + for (i=0; i<21; ++i) + { + if (i<4) + q->sqvh[i].table = vlcbuf1[i]; + else if (i>=4 && i<7) + q->sqvh[i].table = vlcbuf2[i-4]; + else if (i>=7 && i<12) + q->envelope_quant_index[i-7].table = vlcbuf2[i-4]; + else if (i>=12 && i<20) + q->envelope_quant_index[i-7].table = vlcbuf3[i-12]; + else /* i==20 */ + q->ccpl.table = vlcbuf3[8]; + } - result = 0; + /* Init envelope VLC (13 books) */ for (i=0 ; i<13 ; i++) { - q->envelope_quant_index[i].table = vlcbuf[i]; q->envelope_quant_index[i].table_allocated = VLCBUFSIZE; result |= init_vlc (&q->envelope_quant_index[i], 9, 24, envelope_quant_index_huffbits[i], 1, 1, envelope_quant_index_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); } - DEBUGF("sqvh VLC init\n"); + + /* Init subband VLC (7 books) */ for (i=0 ; i<7 ; i++) { - q->sqvh[i].table = vlcbuf[i+13]; q->sqvh[i].table_allocated = VLCBUFSIZE; result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i], cvh_huffbits[i], 1, 1, cvh_huffcodes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); } + /* Init Joint-Stereo VLC (1 book) */ if (q->nb_channels==2 && q->joint_stereo==1){ - q->ccpl.table = vlcbuf[20]; q->ccpl.table_allocated = VLCBUFSIZE; result |= init_vlc (&q->ccpl, 6, (1<js_vlc_bits)-1, ccpl_huffbits[q->js_vlc_bits-2], 1, 1, @@ -414,15 +430,14 @@ * @param mlt_buffer pointer to mlt coefficients */ - static void decode_vectors(COOKContext* q, int* category, int *quant_index_table, REAL_T* mlt_buffer){ /* A zero in this table means that the subband coefficient is random noise coded. */ - int subband_coef_index[SUBBAND_SIZE]; + static int subband_coef_index[SUBBAND_SIZE] IBSS_ATTR; /* A zero in this table means that the subband coefficient is a positive multiplicator. */ - int subband_coef_sign[SUBBAND_SIZE]; + static int subband_coef_sign[SUBBAND_SIZE] IBSS_ATTR; int band, j; int index=0; @@ -459,7 +474,7 @@ static void mono_decode(COOKContext *q, REAL_T* mlt_buffer) { int category_index[128]; - int quant_index_table[102]; + static int quant_index_table[102] IBSS_ATTR; int category[128]; memset(&category, 0, 128*sizeof(int)); Index: apps/codecs/cook.c =================================================================== --- apps/codecs/cook.c (revision 29899) +++ apps/codecs/cook.c (working copy) @@ -28,10 +28,10 @@ CODEC_HEADER -static RMContext rmctx; -static RMPacket pkt; -static COOKContext q IBSS_ATTR; -static int32_t rm_outbuf[2048]; +static RMContext rmctx IBSS_ATTR_COOK_LARGE_IRAM; +static RMPacket pkt IBSS_ATTR_COOK_LARGE_IRAM; +static COOKContext q IBSS_ATTR; +static int32_t rm_outbuf[2048] IBSS_ATTR_COOK_LARGE_IRAM MEM_ALIGN_ATTR; static void init_rm(RMContext *rmctx) {