comparison Plugins/Input/wma/libffwma/wmadec.c @ 276:28b73b5595d1 trunk

[svn] Raise MAX_CODED_SUPERFRAME_SIZE to 16384 in accordance with ffmpeg CVS.
author chainsaw
date Sat, 10 Dec 2005 08:42:49 -0800
parents 0bea7509d6ba
children b13e87374f73
comparison
equal deleted inserted replaced
275:9cc81c92496e 276:28b73b5595d1
1 /* 1 /*
2 * WMA compatible decoder 2 * WMA compatible decoder
3 * Copyright (c) 2002 The FFmpeg Project. 3 * Copyright (c) 2002 The FFmpeg Project.
4 * This decoder handles Microsoft Windows Media Audio data, versions 1 & 2.
5 * WMA v1 is identified by audio format 0x160 in Microsoft media files
6 * (ASF/AVI/WAV). WMA v2 is identified by audio format 0x161.
4 * 7 *
5 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
36 #define HIGH_BAND_MAX_SIZE 16 39 #define HIGH_BAND_MAX_SIZE 16
37 40
38 #define NB_LSP_COEFS 10 41 #define NB_LSP_COEFS 10
39 42
40 /* XXX: is it a suitable value ? */ 43 /* XXX: is it a suitable value ? */
41 #define MAX_CODED_SUPERFRAME_SIZE 4096 44 #define MAX_CODED_SUPERFRAME_SIZE 16384
42 45
43 #define MAX_CHANNELS 2 46 #define MAX_CHANNELS 2
44 47
45 #define NOISE_TAB_SIZE 8192 48 #define NOISE_TAB_SIZE 8192
46 49
197 { 200 {
198 WMADecodeContext *s = avctx->priv_data; 201 WMADecodeContext *s = avctx->priv_data;
199 int i, flags1, flags2; 202 int i, flags1, flags2;
200 float *window; 203 float *window;
201 uint8_t *extradata; 204 uint8_t *extradata;
202 float bps1, high_freq, bps; 205 float bps1, high_freq;
206 volatile float bps;
203 int sample_rate1; 207 int sample_rate1;
204 int coef_vlc_table; 208 int coef_vlc_table;
205 209
206 210
207 s->sample_rate = avctx->sample_rate; 211 s->sample_rate = avctx->sample_rate;
692 static int wma_decode_block(WMADecodeContext *s) 696 static int wma_decode_block(WMADecodeContext *s)
693 { 697 {
694 int n, v, a, ch, code, bsize; 698 int n, v, a, ch, code, bsize;
695 int coef_nb_bits, total_gain, parse_exponents; 699 int coef_nb_bits, total_gain, parse_exponents;
696 float window[BLOCK_MAX_SIZE * 2]; 700 float window[BLOCK_MAX_SIZE * 2];
701 // XXX: FIXME!! there's a bug somewhere which makes this mandatory under altivec
702 #ifdef HAVE_ALTIVEC
703 volatile int nb_coefs[MAX_CHANNELS] __attribute__((aligned(16)));
704 #else
697 int nb_coefs[MAX_CHANNELS]; 705 int nb_coefs[MAX_CHANNELS];
706 #endif
698 float mdct_norm; 707 float mdct_norm;
699 708
700 #ifdef TRACE 709 #ifdef TRACE
701 tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num); 710 tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
702 #endif 711 #endif
1153 for(ch = 0; ch < s->nb_channels; ch++) { 1162 for(ch = 0; ch < s->nb_channels; ch++) {
1154 ptr = samples + ch; 1163 ptr = samples + ch;
1155 iptr = s->frame_out[ch]; 1164 iptr = s->frame_out[ch];
1156 1165
1157 for(i=0;i<n;i++) { 1166 for(i=0;i<n;i++) {
1158 a = rintf(*iptr++); 1167 a = lrintf(*iptr++);
1159 if (a > 32767) 1168 if (a > 32767)
1160 a = 32767; 1169 a = 32767;
1161 else if (a < -32768) 1170 else if (a < -32768)
1162 a = -32768; 1171 a = -32768;
1163 *ptr = a; 1172 *ptr = a;
1270 return -1; 1279 return -1;
1271 } 1280 }
1272 1281
1273 static int wma_decode_end(AVCodecContext *avctx) 1282 static int wma_decode_end(AVCodecContext *avctx)
1274 { 1283 {
1275 WMADecodeContext *s = avctx->priv_data; 1284 WMADecodeContext *s = avctx->priv_data;
1276 int i; 1285 int i;
1277 1286
1278 for (i = 0; i < s->nb_block_sizes; i++) 1287 for (i = 0; i < s->nb_block_sizes; i++)
1279 ff_mdct_end(&s->mdct_ctx[i]); 1288 ff_mdct_end(&s->mdct_ctx[i]);
1280 1289
1281 for (i = 0; i < s->nb_block_sizes; i++) 1290 for (i = 0; i < s->nb_block_sizes; i++)
1282 free(s->windows[i]); 1291 free(s->windows[i]);
1283 1292
1284 if (s->use_exp_vlc) { 1293 if (s->use_exp_vlc) {
1285 free_vlc(&s->exp_vlc); 1294 free_vlc(&s->exp_vlc);
1286 } 1295 }
1287 1296
1288 if (s->use_noise_coding) { 1297 if (s->use_noise_coding) {
1289 free_vlc(&s->hgain_vlc); 1298 free_vlc(&s->hgain_vlc);
1290 } 1299 }
1291 1300
1292 for (i = 0; i < 2; i++) { 1301 for (i = 0; i < 2; i++) {
1293 free_vlc(&s->coef_vlc[i]); 1302 free_vlc(&s->coef_vlc[i]);
1294 free(s->run_table[i]); 1303 free(s->run_table[i]);
1295 free(s->level_table[i]); 1304 free(s->level_table[i]);
1296 } 1305 }
1297 1306
1298 return 0; 1307 return 0;
1299 } 1308 }
1300 1309
1301 AVCodec wmav1_decoder = 1310 AVCodec wmav1_decoder =
1302 { 1311 {
1303 "wmav1", 1312 "wmav1",
1304 CODEC_TYPE_AUDIO, 1313 CODEC_TYPE_AUDIO,
1305 CODEC_ID_WMAV1, 1314 CODEC_ID_WMAV1,
1306 sizeof(WMADecodeContext), 1315 sizeof(WMADecodeContext),
1307 wma_decode_init, 1316 wma_decode_init,
1308 NULL, 1317 NULL,
1309 wma_decode_end, 1318 wma_decode_end,
1310 wma_decode_superframe, 1319 wma_decode_superframe,
1311 }; 1320 };
1312 1321
1313 AVCodec wmav2_decoder = 1322 AVCodec wmav2_decoder =
1314 { 1323 {
1315 "wmav2", 1324 "wmav2",
1316 CODEC_TYPE_AUDIO, 1325 CODEC_TYPE_AUDIO,
1317 CODEC_ID_WMAV2, 1326 CODEC_ID_WMAV2,
1318 sizeof(WMADecodeContext), 1327 sizeof(WMADecodeContext),
1319 wma_decode_init, 1328 wma_decode_init,
1320 NULL, 1329 NULL,
1321 wma_decode_end, 1330 wma_decode_end,
1322 wma_decode_superframe, 1331 wma_decode_superframe,
1323 }; 1332 };