summaryrefslogtreecommitdiff
path: root/apps/codecs/libwma/wmadeci.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libwma/wmadeci.c')
-rw-r--r--apps/codecs/libwma/wmadeci.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/apps/codecs/libwma/wmadeci.c b/apps/codecs/libwma/wmadeci.c
index a9c2ee8929..b09dd0edd2 100644
--- a/apps/codecs/libwma/wmadeci.c
+++ b/apps/codecs/libwma/wmadeci.c
@@ -28,6 +28,7 @@
28#include "wmadec.h" 28#include "wmadec.h"
29#include "wmafixed.h" 29#include "wmafixed.h"
30#include "bitstream.h" 30#include "bitstream.h"
31#include "mdct2.h"
31 32
32 33
33#define VLCBITS 7 /*7 is the lowest without glitching*/ 34#define VLCBITS 7 /*7 is the lowest without glitching*/
@@ -589,12 +590,16 @@ int wma_decode_init(WMADecodeContext* s, asf_waveformatex_t *wfx)
589 } 590 }
590 } 591 }
591 592
592 mdct_init_global(); 593 /*Not using the ffmpeg IMDCT anymore*/
594
595 /* mdct_init_global();
593 596
594 for(i = 0; i < s->nb_block_sizes; ++i) 597 for(i = 0; i < s->nb_block_sizes; ++i)
595 { 598 {
596 ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); 599 ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
600
597 } 601 }
602 */
598 603
599 /*ffmpeg uses malloc to only allocate as many window sizes as needed. However, we're really only interested in the worst case memory usage. 604 /*ffmpeg uses malloc to only allocate as many window sizes as needed. However, we're really only interested in the worst case memory usage.
600 * In the worst case you can have 5 window sizes, 128 doubling up 2048 605 * In the worst case you can have 5 window sizes, 128 doubling up 2048
@@ -1207,8 +1212,10 @@ static int wma_decode_block(WMADecodeContext *s)
1207 n=0; 1212 n=0;
1208 1213
1209 /* 1214 /*
1210 * Previously the IMDCT was run in 17.15 precision to avoid overflow. However rare files could 1215 * The calculation of coefs has a shift right by 2 built in. This prepares samples
1211 * overflow here as well, so switch to 17.15 during coefs calculation. 1216 * for the Tremor IMDCT which uses a slightly different fixed format then the ffmpeg one.
1217 * If the old ffmpeg imdct is used, each shift storing into coefs should be reduced by 1.
1218 * See SVN logs for details.
1212 */ 1219 */
1213 1220
1214 1221
@@ -1223,7 +1230,7 @@ static int wma_decode_block(WMADecodeContext *s)
1223 /* very low freqs : noise */ 1230 /* very low freqs : noise */
1224 for(i = 0;i < s->coefs_start; ++i) 1231 for(i = 0;i < s->coefs_start; ++i)
1225 { 1232 {
1226 *coefs++ = fixmul32( (fixmul32(s->noise_table[s->noise_index],(*exponents++))>>4),Fixed32From64(mult1)) >>1; 1233 *coefs++ = fixmul32( (fixmul32(s->noise_table[s->noise_index],(*exponents++))>>4),Fixed32From64(mult1)) >>2;
1227 s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); 1234 s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
1228 } 1235 }
1229 1236
@@ -1284,7 +1291,7 @@ static int wma_decode_block(WMADecodeContext *s)
1284 { 1291 {
1285 noise = s->noise_table[s->noise_index]; 1292 noise = s->noise_table[s->noise_index];
1286 s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); 1293 s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
1287 *coefs++ = fixmul32((fixmul32(*exponents,noise)>>4),Fixed32From64(mult1)) >>1; 1294 *coefs++ = fixmul32((fixmul32(*exponents,noise)>>4),Fixed32From64(mult1)) >>2;
1288 ++exponents; 1295 ++exponents;
1289 } 1296 }
1290 } 1297 }
@@ -1299,7 +1306,7 @@ static int wma_decode_block(WMADecodeContext *s)
1299 1306
1300 /*don't forget to renormalize the noise*/ 1307 /*don't forget to renormalize the noise*/
1301 temp1 = (((int32_t)*coefs1++)<<16) + (noise>>4); 1308 temp1 = (((int32_t)*coefs1++)<<16) + (noise>>4);
1302 temp2 = fixmul32(*exponents, mult>>17); 1309 temp2 = fixmul32(*exponents, mult>>18);
1303 *coefs++ = fixmul32(temp1, temp2); 1310 *coefs++ = fixmul32(temp1, temp2);
1304 ++exponents; 1311 ++exponents;
1305 } 1312 }
@@ -1311,8 +1318,8 @@ static int wma_decode_block(WMADecodeContext *s)
1311 mult2 = fixmul32(mult>>16,exponents[-1]) ; /*the work around for 32.32 vars are getting stupid*/ 1318 mult2 = fixmul32(mult>>16,exponents[-1]) ; /*the work around for 32.32 vars are getting stupid*/
1312 for (i = 0; i < n; ++i) 1319 for (i = 0; i < n; ++i)
1313 { 1320 {
1314 /*renormalize the noise product and then reduce to 17.15 precison*/ 1321 /*renormalize the noise product and then reduce to 14.18 precison*/
1315 *coefs++ = fixmul32(s->noise_table[s->noise_index],mult2) >>5; 1322 *coefs++ = fixmul32(s->noise_table[s->noise_index],mult2) >>6;
1316 1323
1317 s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); 1324 s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
1318 } 1325 }
@@ -1334,7 +1341,7 @@ static int wma_decode_block(WMADecodeContext *s)
1334 1341
1335 for(i = 0;i < n; ++i) 1342 for(i = 0;i < n; ++i)
1336 { 1343 {
1337 atemp = (coefs1[i] * mult3)>>1; 1344 atemp = (coefs1[i] * mult3)>>2; /*ffmpeg imdct needs 15.17, while tremor 14.18*/
1338 *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]); 1345 *coefs++=fixmul32(atemp,exponents[i<<bsize>>esize]);
1339 } 1346 }
1340 n = s->block_len - s->coefs_end[bsize]; 1347 n = s->block_len - s->coefs_end[bsize];
@@ -1379,9 +1386,13 @@ static int wma_decode_block(WMADecodeContext *s)
1379 n = s->block_len; 1386 n = s->block_len;
1380 n4 = s->block_len >>1; 1387 n4 = s->block_len >>1;
1381 1388
1382 ff_imdct_calc(&s->mdct_ctx[bsize], 1389 /*faster IMDCT from Vorbis*/
1383 output, 1390 mdct_backward( (1 << (12-bsize)), (int*)(*(s->coefs))[ch], (int*)output);
1384 (*(s->coefs))[ch]); 1391
1392 /*slower but more easily understood IMDCT from FFMPEG*/
1393 //ff_imdct_calc(&s->mdct_ctx[bsize],
1394 // output,
1395 // (*(s->coefs))[ch]);
1385 1396
1386 1397
1387 /* add in the frame */ 1398 /* add in the frame */