#define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels
#define MAX_SUBFRAMES 32 ///< max number of subframes per channel
#define MAX_BANDS 29 ///< max number of scale factor bands
-#define MAX_FRAMESIZE 16384 ///< maximum compressed frame size
+#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size
#define WMAPRO_BLOCK_MAX_BITS 12 ///< log2 of max block size
#define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS) ///< maximum block size
/** init MDCT windows: simple sinus window */
for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) {
- const int n = 1 << (WMAPRO_BLOCK_MAX_BITS - i);
const int win_idx = WMAPRO_BLOCK_MAX_BITS - i;
- ff_sine_window_init(ff_sine_windows[win_idx], n);
+ ff_init_ff_sine_windows(win_idx);
s->windows[WMAPRO_BLOCK_SIZES - i - 1] = ff_sine_windows[win_idx];
}
*/
static int decode_coeffs(WMAProDecodeCtx *s, int c)
{
+ /* Integers 0..15 as single-precision floats. The table saves a
+ costly int to float conversion, and storing the values as
+ integers allows fast sign-flipping. */
+ static const int fval_tab[16] = {
+ 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
+ 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
+ 0x41000000, 0x41100000, 0x41200000, 0x41300000,
+ 0x41400000, 0x41500000, 0x41600000, 0x41700000,
+ };
int vlctable;
VLC* vlc;
WMAProChannelCtx* ci = &s->channel[c];
for (i = 0; i < 4; i += 2) {
idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH);
if (idx == HUFF_VEC2_SIZE - 1) {
- vals[i] = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
- if (vals[i] == HUFF_VEC1_SIZE - 1)
- vals[i] += ff_wma_get_large_val(&s->gb);
- vals[i+1] = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
- if (vals[i+1] == HUFF_VEC1_SIZE - 1)
- vals[i+1] += ff_wma_get_large_val(&s->gb);
+ int v0, v1;
+ v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
+ if (v0 == HUFF_VEC1_SIZE - 1)
+ v0 += ff_wma_get_large_val(&s->gb);
+ v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH);
+ if (v1 == HUFF_VEC1_SIZE - 1)
+ v1 += ff_wma_get_large_val(&s->gb);
+ ((float*)vals)[i ] = v0;
+ ((float*)vals)[i+1] = v1;
} else {
- vals[i] = symbol_to_vec2[idx] >> 4;
- vals[i+1] = symbol_to_vec2[idx] & 0xF;
+ vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ];
+ vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
}
}
} else {
- vals[0] = symbol_to_vec4[idx] >> 12;
- vals[1] = (symbol_to_vec4[idx] >> 8) & 0xF;
- vals[2] = (symbol_to_vec4[idx] >> 4) & 0xF;
- vals[3] = symbol_to_vec4[idx] & 0xF;
+ vals[0] = fval_tab[ symbol_to_vec4[idx] >> 12 ];
+ vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
+ vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
+ vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
}
/** decode sign */
for (i = 0; i < 4; i++) {
if (vals[i]) {
int sign = get_bits1(&s->gb) - 1;
- ci->coeffs[cur_coeff] = (vals[i] ^ sign) - sign;
+ *(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31;
num_zeros = 0;
} else {
ci->coeffs[cur_coeff] = 0;
*data_size = (int8_t *)s->samples - (int8_t *)data;
s->packet_offset = get_bits_count(gb) & 7;
- return get_bits_count(gb) >> 3;
+ return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3;
}
/**