102 #define WMAPRO_MAX_CHANNELS 8
103 #define MAX_SUBFRAMES 32
105 #define MAX_FRAMESIZE 32768
107 #define WMAPRO_BLOCK_MIN_BITS 6
108 #define WMAPRO_BLOCK_MAX_BITS 12
109 #define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS)
110 #define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1)
114 #define SCALEVLCBITS 8
115 #define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS)
116 #define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS)
117 #define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS)
118 #define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS)
119 #define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS)
241 #define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b);
242 #define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b);
278 unsigned int channel_mask;
280 int log2_max_num_subframes;
281 int num_possible_block_sizes;
292 channel_mask =
AV_RL32(edata_ptr+2);
317 log2_max_num_subframes = ((s->
decode_flags & 0x38) >> 3);
323 num_possible_block_sizes = log2_max_num_subframes + 1;
355 if (channel_mask & 8) {
357 for (mask = 1; mask < 16; mask <<= 1) {
358 if (channel_mask & mask)
393 for (i = 0; i < num_possible_block_sizes; i++) {
417 for (i = 0; i < num_possible_block_sizes; i++) {
419 for (b = 0; b < s->
num_sfb[i]; b++) {
423 for (x = 0; x < num_possible_block_sizes; x++) {
446 for (i = 0; i < num_possible_block_sizes; i++) {
454 for (i = 0; i < 33; i++)
476 int frame_len_shift = 0;
493 if (subframe_len < s->min_samples_per_subframe ||
527 int fixed_channel_layout = 0;
528 int min_channel_len = 0;
541 memset(num_samples, 0,
sizeof(num_samples));
544 fixed_channel_layout = 1;
552 if (num_samples[c] == min_channel_len) {
553 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
555 contains_subframe[c] = 1;
559 contains_subframe[c] = 0;
567 min_channel_len += subframe_len;
571 if (contains_subframe[c]) {
574 "broken frame: num subframes > 31\n");
578 num_samples[c] += subframe_len;
582 "channel len > samples_per_frame\n");
585 }
else if (num_samples[c] <= min_channel_len) {
586 if (num_samples[c] < min_channel_len) {
587 channels_for_cur_subframe = 0;
588 min_channel_len = num_samples[c];
590 ++channels_for_cur_subframe;
593 }
while (min_channel_len < s->samples_per_frame);
633 for (x = 0; x < i; x++) {
635 for (y = 0; y < i + 1; y++) {
638 int n = rotation_offset[offset + x];
644 cosv =
sin64[32 - n];
646 sinv =
sin64[64 - n];
647 cosv = -
sin64[n - 32];
651 (v1 * sinv) - (v2 * cosv);
653 (v1 * cosv) + (v2 * sinv);
680 "unsupported channel transform bit\n");
692 if (remaining_channels > 2) {
717 "unsupported channel transform type\n");
743 "coupled channels > 6\n");
783 static const uint32_t fval_tab[16] = {
784 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
785 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
786 0x41000000, 0x41100000, 0x41200000, 0x41300000,
787 0x41400000, 0x41500000, 0x41600000, 0x41700000,
798 av_dlog(s->
avctx,
"decode coefficients for channel %i\n", c);
801 vlc = &coef_vlc[vlctable];
822 for (i = 0; i < 4; i += 2) {
836 vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
841 vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
842 vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
843 vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
847 for (i = 0; i < 4; i++) {
853 ci->
coeffs[cur_coeff] = 0;
863 if (cur_coeff < s->subframe_len) {
864 memset(&ci->
coeffs[cur_coeff], 0,
867 level, run, 1, ci->
coeffs,
934 sign = (code & 1) - 1;
935 skip = (code & 0x3f) >> 1;
936 }
else if (idx == 1) {
947 "invalid scale factor coding\n");
983 float** ch_end = ch_data + num_channels;
989 sfb < s->cur_sfb_offsets + s->
num_bands; sfb++) {
995 const float* data_end = data + num_channels;
996 float* data_ptr =
data;
999 for (ch = ch_data; ch < ch_end; ch++)
1000 *data_ptr++ = (*ch)[y];
1002 for (ch = ch_data; ch < ch_end; ch++) {
1005 while (data_ptr < data_end)
1006 sum += *data_ptr++ * *mat++;
1014 ch_data[0] + sfb[0],
1017 ch_data[1] + sfb[0],
1065 int transmit_coeffs = 0;
1066 int cur_subwoofer_cutoff;
1084 "processing subframe with offset %i len %i\n", offset, subframe_len);
1133 if (!(num_fill_bits =
get_bits(&s->
gb, 2))) {
1138 if (num_fill_bits >= 0) {
1162 transmit_coeffs = 1;
1165 if (transmit_coeffs) {
1174 int num_vec_coeffs =
get_bits(&s->
gb, num_bits) << 2;
1190 if (step == -32 || step == 31) {
1191 const int sign = (step == 31) - 1;
1197 quant_step += ((quant +
step) ^ sign) - sign;
1199 if (quant_step < 0) {
1226 av_dlog(s->
avctx,
"BITSTREAM: subframe header length was %i\n",
1240 av_dlog(s->
avctx,
"BITSTREAM: subframe length was %i\n",
1243 if (transmit_coeffs) {
1253 memset(&s->
tmp[cur_subwoofer_cutoff], 0,
sizeof(*s->
tmp) *
1254 (subframe_len - cur_subwoofer_cutoff));
1262 const float quant = pow(10.0, exp / 20.0);
1266 quant, end - start);
1300 int more_frames = 0;
1310 av_dlog(s->
avctx,
"decoding frame with length %x\n", len);
1351 av_dlog(s->
avctx,
"BITSTREAM: frame header length was %i\n",
1403 "frame[%i] would have to skip %i bits\n", s->
frame_num,
1470 align =
FFMIN(align, len);
1495 int *got_frame_ptr,
AVPacket* avpkt)
1499 const uint8_t* buf = avpkt->
data;
1500 int buf_size = avpkt->
size;
1501 int num_bits_prev_frame;
1502 int packet_sequence_number;
1510 if (buf_size < avctx->block_align)
1519 packet_sequence_number =
get_bits(gb, 4);
1525 num_bits_prev_frame);
1536 if (num_bits_prev_frame > 0) {
1538 if (num_bits_prev_frame >= remaining_packet_bits) {
1539 num_bits_prev_frame = remaining_packet_bits;
1545 save_bits(s, gb, num_bits_prev_frame, 1);
1546 av_dlog(avctx,
"accumulated %x bits of frame data\n",
1553 av_dlog(avctx,
"ignoring %x previously saved bits\n",