diff options
Diffstat (limited to 'apps/codecs/libwmapro')
-rw-r--r-- | apps/codecs/libwmapro/SOURCES | 3 | ||||
-rw-r--r-- | apps/codecs/libwmapro/wma.c | 56 | ||||
-rw-r--r-- | apps/codecs/libwmapro/wma.h | 6 | ||||
-rw-r--r-- | apps/codecs/libwmapro/wmaprodata.h | 44 | ||||
-rw-r--r-- | apps/codecs/libwmapro/wmaprodec.c | 288 |
5 files changed, 75 insertions, 322 deletions
diff --git a/apps/codecs/libwmapro/SOURCES b/apps/codecs/libwmapro/SOURCES index e173f7cdb7..1d5909bf9a 100644 --- a/apps/codecs/libwmapro/SOURCES +++ b/apps/codecs/libwmapro/SOURCES | |||
@@ -1,9 +1,6 @@ | |||
1 | wmaprodec.c | 1 | wmaprodec.c |
2 | wma.c | 2 | wma.c |
3 | dsputil.c | ||
4 | mdct.c | ||
5 | mdct_tables.c | 3 | mdct_tables.c |
6 | fft.c | ||
7 | bitstream.c | 4 | bitstream.c |
8 | wmapro_mdct.c | 5 | wmapro_mdct.c |
9 | libavutil/log.c | 6 | libavutil/log.c |
diff --git a/apps/codecs/libwmapro/wma.c b/apps/codecs/libwmapro/wma.c index b1b1268eea..b606f59dbf 100644 --- a/apps/codecs/libwmapro/wma.c +++ b/apps/codecs/libwmapro/wma.c | |||
@@ -469,62 +469,6 @@ unsigned int ff_wma_get_large_val(GetBitContext* gb) | |||
469 | */ | 469 | */ |
470 | int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, | 470 | int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, |
471 | VLC *vlc, | 471 | VLC *vlc, |
472 | const float *level_table, const uint16_t *run_table, | ||
473 | int version, WMACoef *ptr, int offset, | ||
474 | int num_coefs, int block_len, int frame_len_bits, | ||
475 | int coef_nb_bits) | ||
476 | { | ||
477 | int code, level, sign; | ||
478 | const uint32_t *ilvl = (const uint32_t*)level_table; | ||
479 | uint32_t *iptr = (uint32_t*)ptr; | ||
480 | const unsigned int coef_mask = block_len - 1; | ||
481 | for (; offset < num_coefs; offset++) { | ||
482 | code = get_vlc2(gb, vlc->table, VLCBITS, VLCMAX); | ||
483 | if (code > 1) { | ||
484 | /** normal code */ | ||
485 | offset += run_table[code]; | ||
486 | sign = get_bits1(gb) - 1; | ||
487 | iptr[offset & coef_mask] = ilvl[code] ^ sign<<31; | ||
488 | } else if (code == 1) { | ||
489 | /** EOB */ | ||
490 | break; | ||
491 | } else { | ||
492 | /** escape */ | ||
493 | if (!version) { | ||
494 | level = get_bits(gb, coef_nb_bits); | ||
495 | /** NOTE: this is rather suboptimal. reading | ||
496 | block_len_bits would be better */ | ||
497 | offset += get_bits(gb, frame_len_bits); | ||
498 | } else { | ||
499 | level = ff_wma_get_large_val(gb); | ||
500 | /** escape decode */ | ||
501 | if (get_bits1(gb)) { | ||
502 | if (get_bits1(gb)) { | ||
503 | if (get_bits1(gb)) { | ||
504 | av_log(avctx,AV_LOG_ERROR, | ||
505 | "broken escape sequence\n"); | ||
506 | return -1; | ||
507 | } else | ||
508 | offset += get_bits(gb, frame_len_bits) + 4; | ||
509 | } else | ||
510 | offset += get_bits(gb, 2) + 1; | ||
511 | } | ||
512 | } | ||
513 | sign = get_bits1(gb) - 1; | ||
514 | ptr[offset & coef_mask] = (level^sign) - sign; | ||
515 | } | ||
516 | } | ||
517 | /** NOTE: EOB can be omitted */ | ||
518 | if (offset > num_coefs) { | ||
519 | av_log(avctx, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n"); | ||
520 | return -1; | ||
521 | } | ||
522 | |||
523 | return 0; | ||
524 | } | ||
525 | |||
526 | int ff_wma_fix_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, | ||
527 | VLC *vlc, | ||
528 | const int32_t *level_table, const uint16_t *run_table, | 472 | const int32_t *level_table, const uint16_t *run_table, |
529 | int version, int32_t *ptr, int offset, | 473 | int version, int32_t *ptr, int offset, |
530 | int num_coefs, int block_len, int frame_len_bits, | 474 | int num_coefs, int block_len, int frame_len_bits, |
diff --git a/apps/codecs/libwmapro/wma.h b/apps/codecs/libwmapro/wma.h index 043b70c509..d23b7ea02f 100644 --- a/apps/codecs/libwmapro/wma.h +++ b/apps/codecs/libwmapro/wma.h | |||
@@ -155,12 +155,6 @@ int ff_wma_end(AVCodecContext *avctx); | |||
155 | unsigned int ff_wma_get_large_val(GetBitContext* gb); | 155 | unsigned int ff_wma_get_large_val(GetBitContext* gb); |
156 | int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, | 156 | int ff_wma_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, |
157 | VLC *vlc, | 157 | VLC *vlc, |
158 | const float *level_table, const uint16_t *run_table, | ||
159 | int version, WMACoef *ptr, int offset, | ||
160 | int num_coefs, int block_len, int frame_len_bits, | ||
161 | int coef_nb_bits); | ||
162 | int ff_wma_fix_run_level_decode(AVCodecContext* avctx, GetBitContext* gb, | ||
163 | VLC *vlc, | ||
164 | const int32_t *level_table, const uint16_t *run_table, | 158 | const int32_t *level_table, const uint16_t *run_table, |
165 | int version, int32_t *ptr, int offset, | 159 | int version, int32_t *ptr, int offset, |
166 | int num_coefs, int block_len, int frame_len_bits, | 160 | int num_coefs, int block_len, int frame_len_bits, |
diff --git a/apps/codecs/libwmapro/wmaprodata.h b/apps/codecs/libwmapro/wmaprodata.h index 7fb784b39b..ba6ca93e5b 100644 --- a/apps/codecs/libwmapro/wmaprodata.h +++ b/apps/codecs/libwmapro/wmaprodata.h | |||
@@ -361,30 +361,7 @@ static const uint16_t coef0_run[HUFF_COEF0_SIZE] = { | |||
361 | 1, 0, 1, 0, 1, 0, | 361 | 1, 0, 1, 0, 1, 0, |
362 | }; | 362 | }; |
363 | 363 | ||
364 | static const float coef0_level[HUFF_COEF0_SIZE] = { | 364 | static const int32_t coef0_level[HUFF_COEF0_SIZE] = { |
365 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
366 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
367 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
368 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
369 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
370 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
371 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
372 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
373 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
374 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
375 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, | ||
376 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
377 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
378 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, | ||
379 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | ||
380 | 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, | ||
381 | 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, | ||
382 | 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, | ||
383 | 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, | ||
384 | 25, 26, 26, 27, 27, 28, | ||
385 | }; | ||
386 | |||
387 | static const int32_t fixcoef0_level[HUFF_COEF0_SIZE] = { | ||
388 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 365 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
389 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 366 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
390 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 367 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
@@ -425,24 +402,7 @@ static const uint16_t coef1_run[HUFF_COEF1_SIZE] = { | |||
425 | 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, | 402 | 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, |
426 | }; | 403 | }; |
427 | 404 | ||
428 | static const float coef1_level[HUFF_COEF1_SIZE] = { | 405 | static const int32_t coef1_level[HUFF_COEF1_SIZE] = { |
429 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
430 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
431 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
432 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
433 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
434 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, | ||
435 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
436 | 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, | ||
437 | 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, | ||
438 | 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, | ||
439 | 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, | ||
440 | 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, | ||
441 | 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, | ||
442 | 46, 47, 47, 48, 48, 49, 49, 50, 51, 52, | ||
443 | }; | ||
444 | |||
445 | static const int32_t fixcoef1_level[HUFF_COEF1_SIZE] = { | ||
446 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 406 | 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
447 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 407 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
448 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 408 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c index 4e89b5a47b..8a8171aeb6 100644 --- a/apps/codecs/libwmapro/wmaprodec.c +++ b/apps/codecs/libwmapro/wmaprodec.c | |||
@@ -91,7 +91,6 @@ | |||
91 | #include "get_bits.h" | 91 | #include "get_bits.h" |
92 | #include "put_bits.h" | 92 | #include "put_bits.h" |
93 | #include "wmaprodata.h" | 93 | #include "wmaprodata.h" |
94 | #include "dsputil.h" | ||
95 | #include "wma.h" | 94 | #include "wma.h" |
96 | #include "wmaprodec.h" | 95 | #include "wmaprodec.h" |
97 | #include "wmapro_mdct.h" | 96 | #include "wmapro_mdct.h" |
@@ -101,6 +100,9 @@ | |||
101 | #include "wmapro_math.h" | 100 | #include "wmapro_math.h" |
102 | #include "codecs.h" | 101 | #include "codecs.h" |
103 | 102 | ||
103 | /* Uncomment the following line to enable some debug output */ | ||
104 | //#define WMAPRO_DUMP_CTX_EN | ||
105 | |||
104 | /* Some defines to make it compile */ | 106 | /* Some defines to make it compile */ |
105 | #define AVERROR_INVALIDDATA -1 | 107 | #define AVERROR_INVALIDDATA -1 |
106 | #define AVERROR_PATCHWELCOME -2 | 108 | #define AVERROR_PATCHWELCOME -2 |
@@ -131,7 +133,7 @@ static VLC vec4_vlc; ///< 4 coefficients per symbol | |||
131 | static VLC vec2_vlc; ///< 2 coefficients per symbol | 133 | static VLC vec2_vlc; ///< 2 coefficients per symbol |
132 | static VLC vec1_vlc; ///< 1 coefficient per symbol | 134 | static VLC vec1_vlc; ///< 1 coefficient per symbol |
133 | static VLC coef_vlc[2]; ///< coefficient run length vlc codes | 135 | static VLC coef_vlc[2]; ///< coefficient run length vlc codes |
134 | static float sin64[33]; ///< sinus table for decorrelation | 136 | //static float sin64[33]; ///< sinus table for decorrelation |
135 | 137 | ||
136 | /** | 138 | /** |
137 | * @brief frame specific decoder context for a single channel | 139 | * @brief frame specific decoder context for a single channel |
@@ -153,10 +155,8 @@ typedef struct { | |||
153 | int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling) | 155 | int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling) |
154 | int* scale_factors; ///< pointer to the scale factor values used for decoding | 156 | int* scale_factors; ///< pointer to the scale factor values used for decoding |
155 | uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block | 157 | uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block |
156 | float* coeffs; ///< pointer to the subframe decode buffer | 158 | FIXED* coeffs; ///< pointer to the subframe decode buffer |
157 | FIXED* fixcoeffs; | 159 | DECLARE_ALIGNED(16, FIXED, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer |
158 | DECLARE_ALIGNED(16, float, out)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer | ||
159 | DECLARE_ALIGNED(16, FIXED, fixout)[WMAPRO_BLOCK_MAX_SIZE + WMAPRO_BLOCK_MAX_SIZE / 2]; ///< output buffer | ||
160 | } WMAProChannelCtx; | 160 | } WMAProChannelCtx; |
161 | 161 | ||
162 | /** | 162 | /** |
@@ -166,10 +166,9 @@ typedef struct { | |||
166 | uint8_t num_channels; ///< number of channels in the group | 166 | uint8_t num_channels; ///< number of channels in the group |
167 | int8_t transform; ///< transform on / off | 167 | int8_t transform; ///< transform on / off |
168 | int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band | 168 | int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band |
169 | float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; | 169 | //float decorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; |
170 | float* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients | 170 | FIXED* channel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients |
171 | FIXED fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; | 171 | FIXED fixdecorrelation_matrix[WMAPRO_MAX_CHANNELS*WMAPRO_MAX_CHANNELS]; |
172 | FIXED* fixchannel_data[WMAPRO_MAX_CHANNELS]; ///< transformation coefficients | ||
173 | } WMAProChannelGrp; | 172 | } WMAProChannelGrp; |
174 | 173 | ||
175 | /** | 174 | /** |
@@ -182,10 +181,7 @@ typedef struct WMAProDecodeCtx { | |||
182 | uint8_t frame_data[MAX_FRAMESIZE + | 181 | uint8_t frame_data[MAX_FRAMESIZE + |
183 | FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data | 182 | FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data |
184 | PutBitContext pb; ///< context for filling the frame_data buffer | 183 | PutBitContext pb; ///< context for filling the frame_data buffer |
185 | FFTContext mdct_ctx[WMAPRO_BLOCK_SIZES]; ///< MDCT context per block size | 184 | DECLARE_ALIGNED(16, FIXED, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT input buffer |
186 | DECLARE_ALIGNED(16, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer | ||
187 | DECLARE_ALIGNED(16, FIXED, fixtmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer | ||
188 | float* windows[WMAPRO_BLOCK_SIZES]; ///< windows for the different block sizes | ||
189 | 185 | ||
190 | /* frame size dependent frame information (set during initialization) */ | 186 | /* frame size dependent frame information (set during initialization) */ |
191 | uint32_t decode_flags; ///< used compression features | 187 | uint32_t decode_flags; ///< used compression features |
@@ -219,7 +215,6 @@ typedef struct WMAProDecodeCtx { | |||
219 | uint32_t frame_num; ///< current frame number (not used for decoding) | 215 | uint32_t frame_num; ///< current frame number (not used for decoding) |
220 | GetBitContext gb; ///< bitstream reader context | 216 | GetBitContext gb; ///< bitstream reader context |
221 | int buf_bit_size; ///< buffer size in bits | 217 | int buf_bit_size; ///< buffer size in bits |
222 | float* samplesf; ///< current samplebuffer pointer | ||
223 | FIXED* samples; | 218 | FIXED* samples; |
224 | FIXED* samples_end; ///< maximum samplebuffer pointer | 219 | FIXED* samples_end; ///< maximum samplebuffer pointer |
225 | uint8_t drc_gain; ///< gain for the DRC tool | 220 | uint8_t drc_gain; ///< gain for the DRC tool |
@@ -246,6 +241,7 @@ typedef struct WMAProDecodeCtx { | |||
246 | *@brief helper function to print the most important members of the context | 241 | *@brief helper function to print the most important members of the context |
247 | *@param s context | 242 | *@param s context |
248 | */ | 243 | */ |
244 | #ifdef WMAPRO_DUMP_CTX_EN | ||
249 | static void av_cold dump_context(WMAProDecodeCtx *s) | 245 | static void av_cold dump_context(WMAProDecodeCtx *s) |
250 | { | 246 | { |
251 | #define PRINT(a, b) printf(" %s = %d\n", a, b); | 247 | #define PRINT(a, b) printf(" %s = %d\n", a, b); |
@@ -259,22 +255,7 @@ static void av_cold dump_context(WMAProDecodeCtx *s) | |||
259 | PRINT("len prefix", s->len_prefix); | 255 | PRINT("len prefix", s->len_prefix); |
260 | PRINT("num channels", s->num_channels); | 256 | PRINT("num channels", s->num_channels); |
261 | } | 257 | } |
262 | 258 | #endif | |
263 | /** | ||
264 | *@brief Uninitialize the decoder and free all resources. | ||
265 | *@param avctx codec context | ||
266 | *@return 0 on success, < 0 otherwise | ||
267 | */ | ||
268 | av_cold int decode_end(AVCodecContext *avctx) | ||
269 | { | ||
270 | WMAProDecodeCtx *s = avctx->priv_data; | ||
271 | int i; | ||
272 | |||
273 | for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) | ||
274 | ff_mdct_end(&s->mdct_ctx[i]); | ||
275 | |||
276 | return 0; | ||
277 | } | ||
278 | 259 | ||
279 | /** | 260 | /** |
280 | *@brief Initialize the decoder. | 261 | *@brief Initialize the decoder. |
@@ -293,7 +274,6 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
293 | int num_possible_block_sizes; | 274 | int num_possible_block_sizes; |
294 | 275 | ||
295 | s->avctx = avctx; | 276 | s->avctx = avctx; |
296 | dsputil_init(&s->dsp, avctx); | ||
297 | init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); | 277 | init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); |
298 | 278 | ||
299 | avctx->sample_fmt = SAMPLE_FMT_FLT; | 279 | avctx->sample_fmt = SAMPLE_FMT_FLT; |
@@ -440,19 +420,6 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
440 | } | 420 | } |
441 | } | 421 | } |
442 | 422 | ||
443 | /** init MDCT, FIXME: only init needed sizes */ | ||
444 | for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) | ||
445 | ff_mdct_init(&s->mdct_ctx[i], BLOCK_MIN_BITS+1+i, 1, | ||
446 | 1.0 / (1 << (BLOCK_MIN_BITS + i - 1)) | ||
447 | / (1 << (s->bits_per_sample - 1))); | ||
448 | |||
449 | /** init MDCT windows: simple sinus window */ | ||
450 | for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) { | ||
451 | const int win_idx = WMAPRO_BLOCK_MAX_BITS - i; | ||
452 | ff_init_ff_sine_windows(win_idx); | ||
453 | s->windows[WMAPRO_BLOCK_SIZES - i - 1] = ff_sine_windows[win_idx]; | ||
454 | } | ||
455 | |||
456 | /** calculate subwoofer cutoff values */ | 423 | /** calculate subwoofer cutoff values */ |
457 | for (i = 0; i < num_possible_block_sizes; i++) { | 424 | for (i = 0; i < num_possible_block_sizes; i++) { |
458 | int block_size = s->samples_per_frame >> i; | 425 | int block_size = s->samples_per_frame >> i; |
@@ -460,12 +427,15 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
460 | / s->avctx->sample_rate; | 427 | / s->avctx->sample_rate; |
461 | s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size); | 428 | s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size); |
462 | } | 429 | } |
463 | 430 | ||
431 | #if 0 | ||
464 | /** calculate sine values for the decorrelation matrix */ | 432 | /** calculate sine values for the decorrelation matrix */ |
465 | for (i = 0; i < 33; i++) | 433 | for (i = 0; i < 33; i++) |
466 | sin64[i] = sin(i*M_PI / 64.0); | 434 | sin64[i] = sin(i*M_PI / 64.0); |
467 | #if 0 | 435 | #endif |
468 | if (avctx->debug & FF_DEBUG_BITSTREAM) | 436 | |
437 | #ifdef WMAPRO_DUMP_CTX_EN | ||
438 | dump_context(s); | ||
469 | #endif | 439 | #endif |
470 | 440 | ||
471 | avctx->channel_layout = channel_mask; | 441 | avctx->channel_layout = channel_mask; |
@@ -614,6 +584,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s) | |||
614 | return 0; | 584 | return 0; |
615 | } | 585 | } |
616 | 586 | ||
587 | #if 0 | ||
617 | /** | 588 | /** |
618 | *@brief Calculate a decorrelation matrix from the bitstream parameters. | 589 | *@brief Calculate a decorrelation matrix from the bitstream parameters. |
619 | *@param s codec context | 590 | *@param s codec context |
@@ -682,6 +653,7 @@ static void decode_decorrelation_matrix(WMAProDecodeCtx *s, | |||
682 | offset += i; | 653 | offset += i; |
683 | } | 654 | } |
684 | } | 655 | } |
656 | #endif | ||
685 | 657 | ||
686 | /** | 658 | /** |
687 | *@brief Decode channel transformation parameters | 659 | *@brief Decode channel transformation parameters |
@@ -710,8 +682,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s) | |||
710 | for (s->num_chgroups = 0; remaining_channels && | 682 | for (s->num_chgroups = 0; remaining_channels && |
711 | s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { | 683 | s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { |
712 | WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; | 684 | WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; |
713 | float** channel_data = chgroup->channel_data; | 685 | FIXED** channel_data = chgroup->channel_data; |
714 | FIXED** fixchdata = chgroup->fixchannel_data; | ||
715 | chgroup->num_channels = 0; | 686 | chgroup->num_channels = 0; |
716 | chgroup->transform = 0; | 687 | chgroup->transform = 0; |
717 | 688 | ||
@@ -723,18 +694,15 @@ static int decode_channel_transform(WMAProDecodeCtx* s) | |||
723 | && get_bits1(&s->gb)) { | 694 | && get_bits1(&s->gb)) { |
724 | ++chgroup->num_channels; | 695 | ++chgroup->num_channels; |
725 | s->channel[channel_idx].grouped = 1; | 696 | s->channel[channel_idx].grouped = 1; |
726 | *channel_data++ = s->channel[channel_idx].coeffs; | 697 | *channel_data++ = s->channel[channel_idx].coeffs; |
727 | *fixchdata++ = s->channel[channel_idx].fixcoeffs; | ||
728 | } | 698 | } |
729 | } | 699 | } |
730 | } else { | 700 | } else { |
731 | chgroup->num_channels = remaining_channels; | 701 | chgroup->num_channels = remaining_channels; |
732 | for (i = 0; i < s->channels_for_cur_subframe; i++) { | 702 | for (i = 0; i < s->channels_for_cur_subframe; i++) { |
733 | int channel_idx = s->channel_indexes_for_cur_subframe[i]; | 703 | int channel_idx = s->channel_indexes_for_cur_subframe[i]; |
734 | if (!s->channel[channel_idx].grouped) { | 704 | if (!s->channel[channel_idx].grouped) |
735 | *channel_data++ = s->channel[channel_idx].coeffs; | 705 | *channel_data++ = s->channel[channel_idx].coeffs; |
736 | *fixchdata++ = s->channel[channel_idx].fixcoeffs; | ||
737 | } | ||
738 | s->channel[channel_idx].grouped = 1; | 706 | s->channel[channel_idx].grouped = 1; |
739 | } | 707 | } |
740 | } | 708 | } |
@@ -749,22 +717,12 @@ static int decode_channel_transform(WMAProDecodeCtx* s) | |||
749 | } else { | 717 | } else { |
750 | chgroup->transform = 1; | 718 | chgroup->transform = 1; |
751 | if (s->num_channels == 2) { | 719 | if (s->num_channels == 2) { |
752 | chgroup->decorrelation_matrix[0] = 1.0; | ||
753 | chgroup->decorrelation_matrix[1] = -1.0; | ||
754 | chgroup->decorrelation_matrix[2] = 1.0; | ||
755 | chgroup->decorrelation_matrix[3] = 1.0; | ||
756 | |||
757 | chgroup->fixdecorrelation_matrix[0] = 0x10000; | 720 | chgroup->fixdecorrelation_matrix[0] = 0x10000; |
758 | chgroup->fixdecorrelation_matrix[1] = -0x10000; | 721 | chgroup->fixdecorrelation_matrix[1] = -0x10000; |
759 | chgroup->fixdecorrelation_matrix[2] = 0x10000; | 722 | chgroup->fixdecorrelation_matrix[2] = 0x10000; |
760 | chgroup->fixdecorrelation_matrix[3] = 0x10000; | 723 | chgroup->fixdecorrelation_matrix[3] = 0x10000; |
761 | } else { | 724 | } else { |
762 | /** cos(pi/4) */ | 725 | /** cos(pi/4) */ |
763 | chgroup->decorrelation_matrix[0] = 0.70703125; | ||
764 | chgroup->decorrelation_matrix[1] = -0.70703125; | ||
765 | chgroup->decorrelation_matrix[2] = 0.70703125; | ||
766 | chgroup->decorrelation_matrix[3] = 0.70703125; | ||
767 | |||
768 | chgroup->fixdecorrelation_matrix[0] = 0xB500; | 726 | chgroup->fixdecorrelation_matrix[0] = 0xB500; |
769 | chgroup->fixdecorrelation_matrix[1] = -0xB500; | 727 | chgroup->fixdecorrelation_matrix[1] = -0xB500; |
770 | chgroup->fixdecorrelation_matrix[2] = 0xB500; | 728 | chgroup->fixdecorrelation_matrix[2] = 0xB500; |
@@ -772,6 +730,9 @@ static int decode_channel_transform(WMAProDecodeCtx* s) | |||
772 | } | 730 | } |
773 | } | 731 | } |
774 | } else if (chgroup->num_channels > 2) { | 732 | } else if (chgroup->num_channels > 2) { |
733 | LOGF("in wmaprodec.c: Multichannel streams still not supported\n"); | ||
734 | return -1; | ||
735 | #if 0 | ||
775 | if (get_bits1(&s->gb)) { | 736 | if (get_bits1(&s->gb)) { |
776 | chgroup->transform = 1; | 737 | chgroup->transform = 1; |
777 | if (get_bits1(&s->gb)) { | 738 | if (get_bits1(&s->gb)) { |
@@ -789,6 +750,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s) | |||
789 | } | 750 | } |
790 | } | 751 | } |
791 | } | 752 | } |
753 | #endif | ||
792 | } | 754 | } |
793 | 755 | ||
794 | /** decode transform on / off */ | 756 | /** decode transform on / off */ |
@@ -816,16 +778,7 @@ static int decode_channel_transform(WMAProDecodeCtx* s) | |||
816 | *@return 0 on success, < 0 in case of bitstream errors | 778 | *@return 0 on success, < 0 in case of bitstream errors |
817 | */ | 779 | */ |
818 | static int decode_coeffs(WMAProDecodeCtx *s, int c) | 780 | static int decode_coeffs(WMAProDecodeCtx *s, int c) |
819 | { | 781 | { |
820 | /* Integers 0..15 as single-precision floats. The table saves a | ||
821 | costly int to float conversion, and storing the values as | ||
822 | integers allows fast sign-flipping. */ | ||
823 | static const int fval_tab[16] = { | ||
824 | 0x00000000, 0x3f800000, 0x40000000, 0x40400000, | ||
825 | 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000, | ||
826 | 0x41000000, 0x41100000, 0x41200000, 0x41300000, | ||
827 | 0x41400000, 0x41500000, 0x41600000, 0x41700000, | ||
828 | }; | ||
829 | int vlctable; | 782 | int vlctable; |
830 | VLC* vlc; | 783 | VLC* vlc; |
831 | WMAProChannelCtx* ci = &s->channel[c]; | 784 | WMAProChannelCtx* ci = &s->channel[c]; |
@@ -833,8 +786,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
833 | int cur_coeff = 0; | 786 | int cur_coeff = 0; |
834 | int num_zeros = 0; | 787 | int num_zeros = 0; |
835 | const uint16_t* run; | 788 | const uint16_t* run; |
836 | const float* level; | 789 | const FIXED* level; |
837 | const FIXED* fixlevel; | ||
838 | 790 | ||
839 | dprintf(s->avctx, "decode coefficients for channel %i\n", c); | 791 | dprintf(s->avctx, "decode coefficients for channel %i\n", c); |
840 | 792 | ||
@@ -844,18 +796,15 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
844 | if (vlctable) { | 796 | if (vlctable) { |
845 | run = coef1_run; | 797 | run = coef1_run; |
846 | level = coef1_level; | 798 | level = coef1_level; |
847 | fixlevel = fixcoef1_level; | ||
848 | } else { | 799 | } else { |
849 | run = coef0_run; | 800 | run = coef0_run; |
850 | level = coef0_level; | 801 | level = coef0_level; |
851 | fixlevel = fixcoef0_level; | ||
852 | } | 802 | } |
853 | 803 | ||
854 | /** decode vector coefficients (consumes up to 167 bits per iteration for | 804 | /** decode vector coefficients (consumes up to 167 bits per iteration for |
855 | 4 vector coded large values) */ | 805 | 4 vector coded large values) */ |
856 | while (!rl_mode && cur_coeff + 3 < s->subframe_len) { | 806 | while (!rl_mode && cur_coeff + 3 < s->subframe_len) { |
857 | int vals[4]; | 807 | int32_t vals[4]; |
858 | int32_t fixvals[4]; | ||
859 | int i; | 808 | int i; |
860 | unsigned int idx; | 809 | unsigned int idx; |
861 | 810 | ||
@@ -872,42 +821,29 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
872 | v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); | 821 | v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); |
873 | if (v1 == HUFF_VEC1_SIZE - 1) | 822 | if (v1 == HUFF_VEC1_SIZE - 1) |
874 | v1 += ff_wma_get_large_val(&s->gb); | 823 | v1 += ff_wma_get_large_val(&s->gb); |
875 | ((float*)vals)[i ] = v0; | 824 | |
876 | ((float*)vals)[i+1] = v1; | 825 | vals[i] = v0; |
877 | fixvals[i] = v0; | 826 | vals[i+1] = v1; |
878 | fixvals[i+1] = v1; | ||
879 | } else { | 827 | } else { |
880 | vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ]; | 828 | vals[i] = symbol_to_vec2[idx] >> 4; |
881 | vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF]; | 829 | vals[i+1] = symbol_to_vec2[idx] & 0xF; |
882 | fixvals[i] = symbol_to_vec2[idx] >> 4; | ||
883 | fixvals[i+1] = symbol_to_vec2[idx] & 0xF; | ||
884 | } | 830 | } |
885 | } | 831 | } |
886 | } else { | 832 | } else { |
887 | vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12 ]; | 833 | vals[0] = symbol_to_vec4[idx] >> 12; |
888 | vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF]; | 834 | vals[1] = (symbol_to_vec4[idx] >> 8) & 0xF; |
889 | vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF]; | 835 | vals[2] = (symbol_to_vec4[idx] >> 4) & 0xF; |
890 | vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF]; | 836 | vals[3] = symbol_to_vec4[idx] & 0xF; |
891 | |||
892 | fixvals[0] = symbol_to_vec4[idx] >> 12; | ||
893 | fixvals[1] = (symbol_to_vec4[idx] >> 8) & 0xF; | ||
894 | fixvals[2] = (symbol_to_vec4[idx] >> 4) & 0xF; | ||
895 | fixvals[3] = symbol_to_vec4[idx] & 0xF; | ||
896 | } | 837 | } |
897 | 838 | ||
898 | /** decode sign */ | 839 | /** decode sign */ |
899 | for (i = 0; i < 4; i++) { | 840 | for (i = 0; i < 4; i++) { |
900 | if (vals[i]) { | 841 | if (vals[i]) { |
901 | int sign = get_bits1(&s->gb) - 1; | 842 | int sign = get_bits1(&s->gb) - 1; |
902 | *(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31; | 843 | ci->coeffs[cur_coeff] = (sign == -1)? -vals[i]<<16 : vals[i]<<16; |
903 | ci->fixcoeffs[cur_coeff] = (sign == -1)? -fixvals[i]<<16 : fixvals[i]<<16; | ||
904 | if(ftofix16(ci->coeffs[cur_coeff]) != ci->fixcoeffs[cur_coeff]) { | ||
905 | printf("coeff = %f, fixcoeff = %f\n", ci->coeffs[cur_coeff], fixtof16(ci->fixcoeffs[cur_coeff]));getchar(); | ||
906 | } | ||
907 | num_zeros = 0; | 844 | num_zeros = 0; |
908 | } else { | 845 | } else { |
909 | ci->coeffs[cur_coeff] = 0; | 846 | ci->coeffs[cur_coeff] = 0; |
910 | ci->fixcoeffs[cur_coeff] = 0; | ||
911 | /** switch to run level mode when subframe_len / 128 zeros | 847 | /** switch to run level mode when subframe_len / 128 zeros |
912 | were found in a row */ | 848 | were found in a row */ |
913 | rl_mode |= (++num_zeros > s->subframe_len >> 8); | 849 | rl_mode |= (++num_zeros > s->subframe_len >> 8); |
@@ -920,20 +856,11 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
920 | if (rl_mode) { | 856 | if (rl_mode) { |
921 | memset(&ci->coeffs[cur_coeff], 0, | 857 | memset(&ci->coeffs[cur_coeff], 0, |
922 | sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); | 858 | sizeof(*ci->coeffs) * (s->subframe_len - cur_coeff)); |
923 | memset(&ci->fixcoeffs[cur_coeff], 0, | 859 | |
924 | sizeof(*ci->fixcoeffs) * (s->subframe_len - cur_coeff)); | 860 | if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc, |
925 | |||
926 | int indx = s->gb.index; | ||
927 | if (ff_wma_run_level_decode(s->avctx, &s->gb, vlc, | ||
928 | level, run, 1, ci->coeffs, | 861 | level, run, 1, ci->coeffs, |
929 | cur_coeff, s->subframe_len, | 862 | cur_coeff, s->subframe_len, |
930 | s->subframe_len, s->esc_len, 0)) | 863 | s->subframe_len, s->esc_len, 0)) |
931 | return AVERROR_INVALIDDATA; | ||
932 | s->gb.index = indx; | ||
933 | if (ff_wma_fix_run_level_decode(s->avctx, &s->gb, vlc, | ||
934 | fixlevel, run, 1, ci->fixcoeffs, | ||
935 | cur_coeff, s->subframe_len, | ||
936 | s->subframe_len, s->esc_len, 0)) | ||
937 | return AVERROR_INVALIDDATA; | 864 | return AVERROR_INVALIDDATA; |
938 | 865 | ||
939 | } | 866 | } |
@@ -1045,13 +972,10 @@ static void inverse_channel_transform(WMAProDecodeCtx *s) | |||
1045 | 972 | ||
1046 | for (i = 0; i < s->num_chgroups; i++) { | 973 | for (i = 0; i < s->num_chgroups; i++) { |
1047 | if (s->chgroup[i].transform) { | 974 | if (s->chgroup[i].transform) { |
1048 | float data[WMAPRO_MAX_CHANNELS]; | ||
1049 | const int num_channels = s->chgroup[i].num_channels; | 975 | const int num_channels = s->chgroup[i].num_channels; |
1050 | float** ch_data = s->chgroup[i].channel_data; | 976 | FIXED data[WMAPRO_MAX_CHANNELS]; |
1051 | float** ch_end = ch_data + num_channels; | 977 | FIXED** ch_data = s->chgroup[i].channel_data; |
1052 | FIXED fixdata[WMAPRO_MAX_CHANNELS]; | 978 | FIXED** ch_end = ch_data + num_channels; |
1053 | FIXED** fixchdata = s->chgroup[i].fixchannel_data; | ||
1054 | FIXED** fixchend = fixchdata + num_channels; | ||
1055 | const int8_t* tb = s->chgroup[i].transform_band; | 979 | const int8_t* tb = s->chgroup[i].transform_band; |
1056 | int16_t* sfb; | 980 | int16_t* sfb; |
1057 | 981 | ||
@@ -1062,51 +986,33 @@ static void inverse_channel_transform(WMAProDecodeCtx *s) | |||
1062 | if (*tb++ == 1) { | 986 | if (*tb++ == 1) { |
1063 | /** multiply values with the decorrelation_matrix */ | 987 | /** multiply values with the decorrelation_matrix */ |
1064 | for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) { | 988 | for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len); y++) { |
1065 | const float* mat = s->chgroup[i].decorrelation_matrix; | 989 | const FIXED* mat = s->chgroup[i].fixdecorrelation_matrix; |
1066 | const float* data_end = data + num_channels; | 990 | const FIXED* data_end = data + num_channels; |
1067 | float* data_ptr = data; | 991 | FIXED* data_ptr = data; |
1068 | float** ch; | 992 | FIXED** ch; |
1069 | const FIXED* fixmat = s->chgroup[i].fixdecorrelation_matrix; | ||
1070 | const FIXED* fixdata_end = fixdata + num_channels; | ||
1071 | FIXED* fixdata_ptr = fixdata; | ||
1072 | FIXED** fixch; | ||
1073 | 993 | ||
1074 | for (ch = ch_data, fixch = fixchdata; ch < ch_end && fixch < fixchend; ch++, fixch++) { | 994 | for (ch = ch_data; ch < ch_end; ch++) |
1075 | *data_ptr++ = (*ch)[y]; | 995 | *data_ptr++ = (*ch)[y]; |
1076 | *fixdata_ptr++ = (*fixch)[y]; | ||
1077 | } | ||
1078 | 996 | ||
1079 | for (ch = ch_data, fixch = fixchdata; ch < ch_end && fixch < fixchend; ch++, fixch++) { | 997 | for (ch = ch_data; ch < ch_end; ch++) { |
1080 | float sum = 0; | 998 | FIXED sum = 0; |
1081 | FIXED fixsum = 0; | ||
1082 | data_ptr = data; | 999 | data_ptr = data; |
1083 | fixdata_ptr = fixdata; | ||
1084 | |||
1085 | while (data_ptr < data_end) | ||
1086 | sum += *data_ptr++ * *mat++; | ||
1087 | 1000 | ||
1088 | while (fixdata_ptr < fixdata_end) | 1001 | while (data_ptr < data_end) |
1089 | fixsum += fixmulshift(*fixdata_ptr++, *fixmat++, 16); | 1002 | sum += fixmulshift(*data_ptr++, *mat++, 16); |
1090 | 1003 | ||
1091 | (*ch)[y] = sum; | 1004 | (*ch)[y] = sum; |
1092 | (*fixch)[y] = fixsum; | ||
1093 | } | 1005 | } |
1094 | } | 1006 | } |
1095 | } else if (s->num_channels == 2) { | 1007 | } else if (s->num_channels == 2) { |
1096 | 1008 | ||
1097 | int len = FFMIN(sfb[1], s->subframe_len) - sfb[0]; | 1009 | int len = FFMIN(sfb[1], s->subframe_len) - sfb[0]; |
1098 | s->dsp.vector_fmul_scalar(ch_data[0] + sfb[0], | 1010 | vector_fixmul_scalar(ch_data[0] + sfb[0], |
1099 | ch_data[0] + sfb[0], | 1011 | ch_data[0] + sfb[0], |
1100 | 181.0 / 128, len); | 1012 | 0x00016A00, len,16); |
1101 | s->dsp.vector_fmul_scalar(ch_data[1] + sfb[0], | 1013 | vector_fixmul_scalar(ch_data[1] + sfb[0], |
1102 | ch_data[1] + sfb[0], | 1014 | ch_data[1] + sfb[0], |
1103 | 181.0 / 128, len); | 1015 | 0x00016A00, len,16); |
1104 | vector_fixmul_scalar(fixchdata[0] + sfb[0], | ||
1105 | fixchdata[0] + sfb[0], | ||
1106 | 0x00016A00, len, 16); | ||
1107 | vector_fixmul_scalar(fixchdata[1] + sfb[0], | ||
1108 | fixchdata[1] + sfb[0], | ||
1109 | 0x00016A00, len,16); | ||
1110 | 1016 | ||
1111 | } | 1017 | } |
1112 | } | 1018 | } |
@@ -1124,26 +1030,19 @@ static void wmapro_window(WMAProDecodeCtx *s) | |||
1124 | 1030 | ||
1125 | for (i = 0; i < s->channels_for_cur_subframe; i++) { | 1031 | for (i = 0; i < s->channels_for_cur_subframe; i++) { |
1126 | int c = s->channel_indexes_for_cur_subframe[i]; | 1032 | int c = s->channel_indexes_for_cur_subframe[i]; |
1127 | FIXED* window; | 1033 | const FIXED* window; |
1128 | float* win2; | ||
1129 | int winlen = s->channel[c].prev_block_len; | 1034 | int winlen = s->channel[c].prev_block_len; |
1130 | float* start = s->channel[c].coeffs - (winlen >> 1); | 1035 | FIXED *xstart= s->channel[c].coeffs - (winlen >> 1); |
1131 | FIXED *xstart= s->channel[c].fixcoeffs - (winlen >> 1); | ||
1132 | int j; | ||
1133 | 1036 | ||
1134 | if (s->subframe_len < winlen) { | 1037 | if (s->subframe_len < winlen) { |
1135 | start += (winlen - s->subframe_len) >> 1; | ||
1136 | xstart += (winlen - s->subframe_len) >> 1; | 1038 | xstart += (winlen - s->subframe_len) >> 1; |
1137 | winlen = s->subframe_len; | 1039 | winlen = s->subframe_len; |
1138 | } | 1040 | } |
1139 | 1041 | ||
1140 | window = sine_windows[av_log2(winlen) - BLOCK_MIN_BITS]; | 1042 | window = sine_windows[av_log2(winlen) - BLOCK_MIN_BITS]; |
1141 | win2 = s->windows[av_log2(winlen) - BLOCK_MIN_BITS]; | ||
1142 | 1043 | ||
1143 | winlen >>= 1; | 1044 | winlen >>= 1; |
1144 | 1045 | ||
1145 | s->dsp.vector_fmul_window(start, start, start + winlen, | ||
1146 | win2, 0, winlen); | ||
1147 | vector_fixmul_window(xstart, xstart, xstart + winlen, | 1046 | vector_fixmul_window(xstart, xstart, xstart + winlen, |
1148 | window, 0, winlen); | 1047 | window, 0, winlen); |
1149 | 1048 | ||
@@ -1223,8 +1122,6 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1223 | 1122 | ||
1224 | s->channel[c].coeffs = &s->channel[c].out[(s->samples_per_frame >> 1) | 1123 | s->channel[c].coeffs = &s->channel[c].out[(s->samples_per_frame >> 1) |
1225 | + offset]; | 1124 | + offset]; |
1226 | s->channel[c].fixcoeffs = &s->channel[c].fixout[(s->samples_per_frame >> 1) | ||
1227 | + offset]; | ||
1228 | } | 1125 | } |
1229 | 1126 | ||
1230 | s->subframe_len = subframe_len; | 1127 | s->subframe_len = subframe_len; |
@@ -1322,8 +1219,6 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1322 | } else { | 1219 | } else { |
1323 | memset(s->channel[c].coeffs, 0, | 1220 | memset(s->channel[c].coeffs, 0, |
1324 | sizeof(*s->channel[c].coeffs) * subframe_len); | 1221 | sizeof(*s->channel[c].coeffs) * subframe_len); |
1325 | memset(s->channel[c].fixcoeffs, 0, | ||
1326 | sizeof(*s->channel[c].fixcoeffs) * subframe_len); | ||
1327 | } | 1222 | } |
1328 | } | 1223 | } |
1329 | 1224 | ||
@@ -1338,42 +1233,34 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1338 | const int* sf = s->channel[c].scale_factors; | 1233 | const int* sf = s->channel[c].scale_factors; |
1339 | int b; | 1234 | int b; |
1340 | 1235 | ||
1341 | if (c == s->lfe_channel){ | 1236 | if (c == s->lfe_channel) |
1342 | memset(&s->tmp[cur_subwoofer_cutoff], 0, sizeof(*s->tmp) * | 1237 | memset(&s->tmp[cur_subwoofer_cutoff], 0, sizeof(*s->tmp) * |
1343 | (subframe_len - cur_subwoofer_cutoff)); | 1238 | (subframe_len - cur_subwoofer_cutoff)); |
1344 | memset(&s->fixtmp[cur_subwoofer_cutoff], 0, sizeof(*s->fixtmp) * | 1239 | |
1345 | (subframe_len - cur_subwoofer_cutoff)); | ||
1346 | } | ||
1347 | /** inverse quantization and rescaling */ | 1240 | /** inverse quantization and rescaling */ |
1348 | for (b = 0; b < s->num_bands; b++) { | 1241 | for (b = 0; b < s->num_bands; b++) { |
1349 | const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len); | 1242 | const int end = FFMIN(s->cur_sfb_offsets[b+1], s->subframe_len); |
1350 | const int exp = s->channel[c].quant_step - | 1243 | const int exp = s->channel[c].quant_step - |
1351 | (s->channel[c].max_scale_factor - *sf++) * | 1244 | (s->channel[c].max_scale_factor - *sf++) * |
1352 | s->channel[c].scale_factor_step; | 1245 | s->channel[c].scale_factor_step; |
1353 | const float quant = pow(10.0, exp / 20.0); | ||
1354 | 1246 | ||
1355 | if(exp < EXP_MIN || exp > EXP_MAX) { | 1247 | if(exp < EXP_MIN || exp > EXP_MAX) { |
1356 | LOGF("in wmaprodec.c : unhandled value for exp, please report sample.\n"); | 1248 | LOGF("in wmaprodec.c : unhandled value for exp, please report sample.\n"); |
1357 | return -1; | 1249 | return -1; |
1358 | } | 1250 | } |
1359 | const FIXED fixquant = QUANT(exp); | 1251 | const FIXED quant = QUANT(exp); |
1360 | int start = s->cur_sfb_offsets[b]; | 1252 | int start = s->cur_sfb_offsets[b]; |
1361 | 1253 | ||
1362 | s->dsp.vector_fmul_scalar(s->tmp + start, | 1254 | vector_fixmul_scalar(s->tmp+start, |
1363 | s->channel[c].coeffs + start, | 1255 | s->channel[c].coeffs + start, |
1364 | quant, end - start); | 1256 | quant, end-start, 24); |
1365 | vector_fixmul_scalar(s->fixtmp+start, | ||
1366 | s->channel[c].fixcoeffs + start, | ||
1367 | fixquant, end-start, 24); | ||
1368 | 1257 | ||
1369 | 1258 | ||
1370 | } | 1259 | } |
1371 | 1260 | ||
1372 | /** apply imdct (ff_imdct_half == DCTIV with reverse) */ | 1261 | /** apply imdct (ff_imdct_half == DCTIV with reverse) */ |
1373 | fff_imdct_half(&s->mdct_ctx[av_log2(subframe_len) - BLOCK_MIN_BITS], | 1262 | imdct_half(av_log2(subframe_len)+1, |
1374 | s->channel[c].coeffs, s->tmp); | 1263 | s->channel[c].coeffs, s->tmp); |
1375 | imdct_half((s->mdct_ctx[av_log2(subframe_len) - BLOCK_MIN_BITS]).mdct_bits, | ||
1376 | s->channel[c].fixcoeffs, s->fixtmp); | ||
1377 | 1264 | ||
1378 | } | 1265 | } |
1379 | } | 1266 | } |
@@ -1482,13 +1369,9 @@ static int decode_frame(WMAProDecodeCtx *s) | |||
1482 | /** interleave samples and write them to the output buffer */ | 1369 | /** interleave samples and write them to the output buffer */ |
1483 | for (i = 0; i < s->num_channels; i++) { | 1370 | for (i = 0; i < s->num_channels; i++) { |
1484 | FIXED* ptr = s->samples + i; | 1371 | FIXED* ptr = s->samples + i; |
1485 | float* fptr = s->samplesf + i; | ||
1486 | int incr = s->num_channels; | 1372 | int incr = s->num_channels; |
1487 | FIXED* iptr = s->channel[i].fixout; | 1373 | FIXED* iptr = s->channel[i].out; |
1488 | float* fiptr = s->channel[i].out; | ||
1489 | FIXED* iend = iptr + s->samples_per_frame; | 1374 | FIXED* iend = iptr + s->samples_per_frame; |
1490 | float* fiend = fiptr + s->samples_per_frame; | ||
1491 | int j; | ||
1492 | 1375 | ||
1493 | while (iptr < iend) { | 1376 | while (iptr < iend) { |
1494 | *ptr = *iptr++ << 1; | 1377 | *ptr = *iptr++ << 1; |
@@ -1499,18 +1382,12 @@ static int decode_frame(WMAProDecodeCtx *s) | |||
1499 | memcpy(&s->channel[i].out[0], | 1382 | memcpy(&s->channel[i].out[0], |
1500 | &s->channel[i].out[s->samples_per_frame], | 1383 | &s->channel[i].out[s->samples_per_frame], |
1501 | s->samples_per_frame * sizeof(*s->channel[i].out) >> 1); | 1384 | s->samples_per_frame * sizeof(*s->channel[i].out) >> 1); |
1502 | |||
1503 | memcpy(&s->channel[i].fixout[0], | ||
1504 | &s->channel[i].fixout[s->samples_per_frame], | ||
1505 | s->samples_per_frame * sizeof(*s->channel[i].fixout) >> 1); | ||
1506 | } | 1385 | } |
1507 | 1386 | ||
1508 | if (s->skip_frame) { | 1387 | if (s->skip_frame) { |
1509 | s->skip_frame = 0; | 1388 | s->skip_frame = 0; |
1510 | } else { | 1389 | } else |
1511 | s->samples += s->num_channels * s->samples_per_frame; | 1390 | s->samples += s->num_channels * s->samples_per_frame; |
1512 | s->samplesf += s->num_channels * s->samples_per_frame; | ||
1513 | } | ||
1514 | 1391 | ||
1515 | if (len != (get_bits_count(gb) - s->frame_offset) + 2) { | 1392 | if (len != (get_bits_count(gb) - s->frame_offset) + 2) { |
1516 | /** FIXME: not sure if this is always an error */ | 1393 | /** FIXME: not sure if this is always an error */ |
@@ -1688,25 +1565,6 @@ int decode_packet(AVCodecContext *avctx, | |||
1688 | return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; | 1565 | return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; |
1689 | } | 1566 | } |
1690 | 1567 | ||
1691 | /** | ||
1692 | *@brief Clear decoder buffers (for seeking). | ||
1693 | *@param avctx codec context | ||
1694 | */ | ||
1695 | static void flush(AVCodecContext *avctx) | ||
1696 | { | ||
1697 | WMAProDecodeCtx *s = avctx->priv_data; | ||
1698 | int i; | ||
1699 | /** reset output buffer as a part of it is used during the windowing of a | ||
1700 | new frame */ | ||
1701 | for (i = 0; i < s->num_channels; i++) { | ||
1702 | memset(s->channel[i].out, 0, s->samples_per_frame * | ||
1703 | sizeof(*s->channel[i].out)); | ||
1704 | memset(s->channel[i].out, 0, s->samples_per_frame * | ||
1705 | sizeof(*s->channel[i].fixout)); | ||
1706 | } | ||
1707 | s->packet_loss = 1; | ||
1708 | } | ||
1709 | |||
1710 | #if 0 | 1568 | #if 0 |
1711 | /** | 1569 | /** |
1712 | *@brief wmapro decoder | 1570 | *@brief wmapro decoder |