summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2007-07-08 05:16:24 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2007-07-08 05:16:24 +0000
commitf5114daa730c05c6967bb4d908c934d0e3a8f994 (patch)
tree441a631837abe3a603f82298e77968a861587ddd /apps/codecs
parent68d70b35d8b8208bf4894825e65bdb8f110c9150 (diff)
downloadrockbox-f5114daa730c05c6967bb4d908c934d0e3a8f994.tar.gz
rockbox-f5114daa730c05c6967bb4d908c934d0e3a8f994.zip
Move MDCT reconstruction window code over to new trig function. Improves accuracy significantly and slightly reduces code size. Codec SNR now appears to be limited by truncation to 16 bit. Comparison to MS decoder gives > 91 dB of agreement, and a lower RMS error verses the source wav then MS. Additionally, move one commonly accessed table into IRAM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13813 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libwma/wmadec.h2
-rw-r--r--apps/codecs/libwma/wmadeci.c51
-rw-r--r--apps/codecs/libwma/wmafixed.c8
3 files changed, 16 insertions, 45 deletions
diff --git a/apps/codecs/libwma/wmadec.h b/apps/codecs/libwma/wmadec.h
index 0de50795c4..e3e5d389ae 100644
--- a/apps/codecs/libwma/wmadec.h
+++ b/apps/codecs/libwma/wmadec.h
@@ -131,7 +131,7 @@ typedef struct WMADecodeContext
131 fixed32 coefs[MAX_CHANNELS][BLOCK_MAX_SIZE]; 131 fixed32 coefs[MAX_CHANNELS][BLOCK_MAX_SIZE];
132 MDCTContext mdct_ctx[BLOCK_NB_SIZES]; 132 MDCTContext mdct_ctx[BLOCK_NB_SIZES];
133 fixed32 *windows[BLOCK_NB_SIZES]; 133 fixed32 *windows[BLOCK_NB_SIZES];
134 FFTComplex mdct_tmp[BLOCK_MAX_SIZE]; /* temporary storage for imdct */ 134 FFTComplex *mdct_tmp; /* temporary storage for imdct */
135 /* output buffer for one frame and the last for IMDCT windowing */ 135 /* output buffer for one frame and the last for IMDCT windowing */
136 fixed32 frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2]; 136 fixed32 frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
137 /* last frame info */ 137 /* last frame info */
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c
index 1857e6a70d..bb9b96abe0 100644
--- a/apps/codecs/libwma/wmadeci.c
+++ b/apps/codecs/libwma/wmadeci.c
@@ -114,7 +114,9 @@ fixed32 tcos0[1024], tcos1[512], tcos2[256], tcos3[128], tcos4[64]; //the
114fixed32 tsin0[1024], tsin1[512], tsin2[256], tsin3[128], tsin4[64]; 114fixed32 tsin0[1024], tsin1[512], tsin2[256], tsin3[128], tsin4[64];
115 115
116FFTComplex *exparray[5]; //these are the fft lookup tables 116FFTComplex *exparray[5]; //these are the fft lookup tables
117
117uint16_t *revarray[5]; 118uint16_t *revarray[5];
119
118FFTComplex exptab0[512] IBSS_ATTR;//, exptab1[256], exptab2[128], exptab3[64], exptab4[32]; //folded these in! 120FFTComplex exptab0[512] IBSS_ATTR;//, exptab1[256], exptab2[128], exptab3[64], exptab4[32]; //folded these in!
119uint16_t revtab0[1024], revtab1[512], revtab2[256], revtab3[128], revtab4[64]; 121uint16_t revtab0[1024], revtab1[512], revtab2[256], revtab3[128], revtab4[64];
120 122
@@ -122,6 +124,7 @@ uint16_t *runtabarray[2], *levtabarray[2];
122 124
123uint16_t runtab0[1336], runtab1[1336], levtab0[1336], levtab1[1336]; //these could be made smaller since only one can be 1336 125uint16_t runtab0[1336], runtab1[1336], levtab0[1336], levtab1[1336]; //these could be made smaller since only one can be 1336
124 126
127FFTComplex mdct_tmp[BLOCK_MAX_SIZE] IBSS_ATTR; /* temporary storage for imdct */
125 128
126//may also be too large by ~ 1KB each? 129//may also be too large by ~ 1KB each?
127static VLC_TYPE vlcbuf1[6144][2]; 130static VLC_TYPE vlcbuf1[6144][2];
@@ -1080,6 +1083,7 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx)
1080 exparray[0] = exptab0; //exparray[1] = exptab1; exparray[2] = exptab2; exparray[3] = exptab3; exparray[4] = exptab4; 1083 exparray[0] = exptab0; //exparray[1] = exptab1; exparray[2] = exptab2; exparray[3] = exptab3; exparray[4] = exptab4;
1081 revarray[0]=revtab0; revarray[1]=revtab1; revarray[2]=revtab2; revarray[3]=revtab3; revarray[4]=revtab4; 1084 revarray[0]=revtab0; revarray[1]=revtab1; revarray[2]=revtab2; revarray[3]=revtab3; revarray[4]=revtab4;
1082 1085
1086 s->mdct_tmp = mdct_tmp; /* temporary storage for imdct */
1083 for(i = 0; i < s->nb_block_sizes; ++i) 1087 for(i = 0; i < s->nb_block_sizes; ++i)
1084 { 1088 {
1085 ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); 1089 ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
@@ -1108,12 +1112,13 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx)
1108 1112
1109 //fixed32 n2 = itofix32(n<<1); //2x the window length 1113 //fixed32 n2 = itofix32(n<<1); //2x the window length
1110 //alpha = fixdiv32(M_PI_F, n2); //PI / (2x Window length) == PI<<(s->frame_len_bits - i+1) 1114 //alpha = fixdiv32(M_PI_F, n2); //PI / (2x Window length) == PI<<(s->frame_len_bits - i+1)
1111 //printf("two values of alpha %16.10lf %16.10lf\n", fixtof64(alpha), fixtof64(M_PI_F>>(s->frame_len_bits - i+1))); 1115
1112 alpha = M_PI_F>>(s->frame_len_bits - i+1); 1116 //alpha = M_PI_F>>(s->frame_len_bits - i+1);
1117 alpha = (1<<15)>>(s->frame_len_bits - i+1); /* this calculates 0.5/(2*n) */
1113 for(j=0;j<n;++j) 1118 for(j=0;j<n;++j)
1114 { 1119 {
1115 fixed32 j2 = itofix32(j) + 0x8000; 1120 fixed32 j2 = itofix32(j) + 0x8000;
1116 window[j] = fixsin32(fixmul32(j2,alpha)); //alpha between 0 and pi/2 1121 window[j] = fsincos(fixmul32(j2,alpha)<<16, 0); //alpha between 0 and pi/2
1117 1122
1118 } 1123 }
1119 //printf("created window\n"); 1124 //printf("created window\n");
@@ -1192,43 +1197,7 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx)
1192 return 0; 1197 return 0;
1193} 1198}
1194 1199
1195#if 0
1196/* interpolate values for a bigger or smaller block. The block must
1197 have multiple sizes */
1198static void interpolate_array(fixed32 *scale, int old_size, int new_size)
1199{
1200 int i, j, jincr, k;
1201 fixed32 v;
1202
1203 1200
1204
1205 if (new_size > old_size)
1206 {
1207 jincr = new_size / old_size;
1208 j = new_size;
1209 for(i = old_size - 1; i >=0; --i)
1210 {
1211 v = scale[i];
1212 k = jincr;
1213 do
1214 {
1215 scale[--j] = v;
1216 }
1217 while (--k);
1218 }
1219 }
1220 else if (new_size < old_size)
1221 {
1222 j = 0;
1223 jincr = old_size / new_size;
1224 for(i = 0; i < new_size; ++i)
1225 {
1226 scale[i] = scale[j];
1227 j += jincr;
1228 }
1229 }
1230}
1231#endif
1232/* compute x^-0.25 with an exponent and mantissa table. We use linear 1201/* compute x^-0.25 with an exponent and mantissa table. We use linear
1233 interpolation to reduce the mantissa table size at a small speed 1202 interpolation to reduce the mantissa table size at a small speed
1234 expense (linear interpolation approximately doubles the number of 1203 expense (linear interpolation approximately doubles the number of
@@ -1958,9 +1927,9 @@ static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
1958} 1927}
1959 1928
1960int wma_decode_superframe(WMADecodeContext* s, 1929int wma_decode_superframe(WMADecodeContext* s,
1961 void *data, 1930 void *data, /*output*/
1962 int *data_size, 1931 int *data_size,
1963 uint8_t *buf, 1932 uint8_t *buf, /*input*/
1964 int buf_size) 1933 int buf_size)
1965{ 1934{
1966 //WMADecodeContext *s = avctx->priv_data; 1935 //WMADecodeContext *s = avctx->priv_data;
diff --git a/apps/codecs/libwma/wmafixed.c b/apps/codecs/libwma/wmafixed.c
index 7c38009754..3a902dd9ef 100644
--- a/apps/codecs/libwma/wmafixed.c
+++ b/apps/codecs/libwma/wmafixed.c
@@ -68,7 +68,7 @@ fixed32 fixmul32(fixed32 x, fixed32 y)
68 return (fixed32)temp; 68 return (fixed32)temp;
69} 69}
70 70
71 71#endif
72/* 72/*
73 Special fixmul32 that does a 16.16 x 1.31 multiply that returns a 16.16 value. 73 Special fixmul32 that does a 16.16 x 1.31 multiply that returns a 16.16 value.
74 this is needed because the fft constants are all normalized to be less then 1 74 this is needed because the fft constants are all normalized to be less then 1
@@ -76,7 +76,7 @@ fixed32 fixmul32(fixed32 x, fixed32 y)
76 76
77 77
78*/ 78*/
79 79#ifndef CPU_ARM
80fixed32 fixmul32b(fixed32 x, fixed32 y) 80fixed32 fixmul32b(fixed32 x, fixed32 y)
81{ 81{
82 fixed64 temp; 82 fixed64 temp;
@@ -88,10 +88,10 @@ fixed32 fixmul32b(fixed32 x, fixed32 y)
88 88
89 return (fixed32)temp; 89 return (fixed32)temp;
90} 90}
91
92#endif 91#endif
93 92
94 93
94
95/* 95/*
96 Not performance senstitive code here 96 Not performance senstitive code here
97 97
@@ -275,6 +275,7 @@ long fsincos(unsigned long phase, fixed32 *cos)
275 275
276*/ 276*/
277 277
278#if 0
278fixed32 fixsin32(fixed32 x) 279fixed32 fixsin32(fixed32 x)
279{ 280{
280 281
@@ -325,3 +326,4 @@ fixed32 fixcos32(fixed32 x)
325{ 326{
326 return fixsin32(x - (M_PI_F>>1))*-1; 327 return fixsin32(x - (M_PI_F>>1))*-1;
327} 328}
329#endif