diff options
-rw-r--r-- | apps/codecs/libwma/wmadeci.c | 84 |
1 files changed, 25 insertions, 59 deletions
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c index 4b16acd038..118b17126f 100644 --- a/apps/codecs/libwma/wmadeci.c +++ b/apps/codecs/libwma/wmadeci.c | |||
@@ -150,58 +150,6 @@ static VLC_TYPE vlcbuf3[1536][2] IBSS_ATTR; //small so lets try iram | |||
150 | 150 | ||
151 | #include "wmadata.h" // PJJ | 151 | #include "wmadata.h" // PJJ |
152 | 152 | ||
153 | /** | ||
154 | * The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is | ||
155 | * done | ||
156 | */ | ||
157 | int fft_inits(FFTContext *s, int nbits, int inverse) | ||
158 | { | ||
159 | int i, n; | ||
160 | fixed32 c1, s1; | ||
161 | int s2; | ||
162 | |||
163 | s->nbits = nbits; | ||
164 | n = 1 << nbits; | ||
165 | |||
166 | s->inverse = inverse; | ||
167 | |||
168 | s2 = inverse ? 1 : -1; | ||
169 | |||
170 | if(nbits == 10){ //we folded all these stupid tables into the nbits==10 table, so don't make it for the others! | ||
171 | //should probably just remove exptab building out of this function and do it higher up for neatness | ||
172 | for(i=0;i<(n/2);++i) | ||
173 | { | ||
174 | //we're going to redo this in CORDIC fixed format! Hold onto your butts | ||
175 | |||
176 | /* | ||
177 | input to cordic is from 0 ->2pi with 0->0 and 2^32-1 ->2pi | ||
178 | output, which is what we'll store the variables as is | ||
179 | -1->-2^31 and 1->2^31-1 | ||
180 | |||
181 | */ | ||
182 | |||
183 | fixed32 ifix = itofix32(i); | ||
184 | fixed32 nfix = itofix32(n); | ||
185 | fixed32 res = fixdiv32(ifix,nfix); //this is really bad here since nfix can be as large as 1024 ! | ||
186 | //also, make this a shift, since its a fucking power of two divide | ||
187 | //alpha = fixmul32(TWO_M_PI_F, res); | ||
188 | //ct = fixcos32(alpha); //need to correct alpha for 0->2pi scale | ||
189 | //st = fixsin32(alpha);// * s2; | ||
190 | |||
191 | s1 = fsincos(res<<16, &c1); //does sin and cos in one pass! | ||
192 | |||
193 | //I really have my doubts about the correctness of the alpha to cordic mapping here, but it seems to work well enough | ||
194 | //double check this later! | ||
195 | |||
196 | exptab0[i].re = c1; | ||
197 | exptab0[i].im = s1*s2; | ||
198 | } | ||
199 | } | ||
200 | // s->fft_calc = fft_calc; | ||
201 | s->exptab1 = NULL; | ||
202 | |||
203 | return 0; | ||
204 | } | ||
205 | 153 | ||
206 | /* butter fly op */ | 154 | /* butter fly op */ |
207 | #define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \ | 155 | #define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \ |
@@ -338,14 +286,13 @@ int ff_mdct_init(MDCTContext *s, int nbits, int inverse) | |||
338 | s->tsin[i] = - fsincos(ip<<16, &(s->tcos[i])); //I can't remember why this works, but it seems to agree for ~24 bits, maybe more! | 286 | s->tsin[i] = - fsincos(ip<<16, &(s->tcos[i])); //I can't remember why this works, but it seems to agree for ~24 bits, maybe more! |
339 | s->tcos[i] *=-1; | 287 | s->tcos[i] *=-1; |
340 | } | 288 | } |
341 | if (fft_inits(&s->fft, s->nbits - 2, inverse) < 0) | 289 | s->fft.nbits = s->nbits - 2; |
342 | goto fail; | 290 | |
291 | |||
292 | s->fft.inverse = inverse; | ||
343 | 293 | ||
344 | return 0; | 294 | return 0; |
345 | fail: | 295 | |
346 | // av_freep(&s->tcos); | ||
347 | // av_freep(&s->tsin); | ||
348 | return -1; | ||
349 | } | 296 | } |
350 | 297 | ||
351 | /** | 298 | /** |
@@ -824,12 +771,31 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx) | |||
824 | exparray[0] = exptab0; //exparray[1] = exptab1; exparray[2] = exptab2; exparray[3] = exptab3; exparray[4] = exptab4; | 771 | exparray[0] = exptab0; //exparray[1] = exptab1; exparray[2] = exptab2; exparray[3] = exptab3; exparray[4] = exptab4; |
825 | revarray[0]=revtab0; //revarray[1]=revtab1; revarray[2]=revtab2; revarray[3]=revtab3; revarray[4]=revtab4; | 772 | revarray[0]=revtab0; //revarray[1]=revtab1; revarray[2]=revtab2; revarray[3]=revtab3; revarray[4]=revtab4; |
826 | 773 | ||
827 | s->mdct_tmp = mdct_tmp; /* temporary storage for imdct */ | 774 | s->mdct_tmp = mdct_tmp; /* temporary storage for imdct */ |
828 | for(i = 0; i < s->nb_block_sizes; ++i) | 775 | for(i = 0; i < s->nb_block_sizes; ++i) |
829 | { | 776 | { |
830 | ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); | 777 | ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); |
831 | } | 778 | } |
832 | 779 | ||
780 | { | ||
781 | int i, n; | ||
782 | fixed32 c1, s1, s2; | ||
783 | |||
784 | n=1<<10; | ||
785 | s2 = 1 ? 1 : -1; | ||
786 | for(i=0;i<(n/2);++i) | ||
787 | { | ||
788 | fixed32 ifix = itofix32(i); | ||
789 | fixed32 nfix = itofix32(n); | ||
790 | fixed32 res = fixdiv32(ifix,nfix); | ||
791 | |||
792 | s1 = fsincos(res<<16, &c1); | ||
793 | |||
794 | exptab0[i].re = c1; | ||
795 | exptab0[i].im = s1*s2; | ||
796 | } | ||
797 | } | ||
798 | |||
833 | /* init the MDCT bit reverse table here rather then in fft_init */ | 799 | /* init the MDCT bit reverse table here rather then in fft_init */ |
834 | 800 | ||
835 | for(i=0;i<1024;i++) /*hard coded to a 2048 bit rotation*/ | 801 | for(i=0;i<1024;i++) /*hard coded to a 2048 bit rotation*/ |