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 13
109 #define WMAPRO_BLOCK_MIN_SIZE (1 << WMAPRO_BLOCK_MIN_BITS)
110 #define WMAPRO_BLOCK_MAX_SIZE (1 << WMAPRO_BLOCK_MAX_BITS)
111 #define WMAPRO_BLOCK_SIZES (WMAPRO_BLOCK_MAX_BITS - WMAPRO_BLOCK_MIN_BITS + 1)
115 #define SCALEVLCBITS 8
116 #define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS)
117 #define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS)
118 #define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS)
119 #define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS)
120 #define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS)
239 #define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b);
240 #define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b);
276 unsigned int channel_mask;
278 int log2_max_num_subframes;
279 int num_possible_block_sizes;
295 channel_mask =
AV_RL32(edata_ptr+2);
328 log2_max_num_subframes = ((s->
decode_flags & 0x38) >> 3);
334 num_possible_block_sizes = log2_max_num_subframes + 1;
366 for (i = 0; i < avctx->
channels; i++)
372 if (channel_mask & 8) {
374 for (mask = 1; mask < 16; mask <<= 1) {
375 if (channel_mask & mask)
410 for (i = 0; i < num_possible_block_sizes; i++) {
438 for (i = 0; i < num_possible_block_sizes; i++) {
440 for (b = 0; b < s->
num_sfb[i]; b++) {
444 for (x = 0; x < num_possible_block_sizes; x++) {
469 for (i = 0; i < num_possible_block_sizes; i++) {
477 for (i = 0; i < 33; i++)
496 int frame_len_shift = 0;
516 if (subframe_len < s->min_samples_per_subframe ||
550 int fixed_channel_layout = 0;
551 int min_channel_len = 0;
565 fixed_channel_layout = 1;
573 if (num_samples[c] == min_channel_len) {
574 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
576 contains_subframe[
c] = 1;
580 contains_subframe[
c] = 0;
588 min_channel_len += subframe_len;
592 if (contains_subframe[c]) {
595 "broken frame: num subframes > 31\n");
599 num_samples[
c] += subframe_len;
603 "channel len > samples_per_frame\n");
606 }
else if (num_samples[c] <= min_channel_len) {
607 if (num_samples[c] < min_channel_len) {
608 channels_for_cur_subframe = 0;
609 min_channel_len = num_samples[
c];
611 ++channels_for_cur_subframe;
614 }
while (min_channel_len < s->samples_per_frame);
654 for (x = 0; x < i; x++) {
656 for (y = 0; y < i + 1; y++) {
659 int n = rotation_offset[offset + x];
668 cosv = -
sin64[n - 32];
672 (v1 * sinv) - (v2 * cosv);
674 (v1 * cosv) + (v2 * sinv);
701 "Channel transform bit");
713 if (remaining_channels > 2) {
738 "Unknown channel transform type");
765 "Coupled channels > 6");
805 static const uint32_t fval_tab[16] = {
806 0x00000000, 0x3f800000, 0x40000000, 0x40400000,
807 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000,
808 0x41000000, 0x41100000, 0x41200000, 0x41300000,
809 0x41400000, 0x41500000, 0x41600000, 0x41700000,
820 av_dlog(s->
avctx,
"decode coefficients for channel %i\n", c);
823 vlc = &coef_vlc[vlctable];
844 for (i = 0; i < 4; i += 2) {
858 vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF];
863 vals[1] = fval_tab[(symbol_to_vec4[idx] >> 8) & 0xF];
864 vals[2] = fval_tab[(symbol_to_vec4[idx] >> 4) & 0xF];
865 vals[3] = fval_tab[ symbol_to_vec4[idx] & 0xF];
869 for (i = 0; i < 4; i++) {
875 ci->
coeffs[cur_coeff] = 0;
885 if (cur_coeff < s->subframe_len) {
886 memset(&ci->
coeffs[cur_coeff], 0,
889 level, run, 1, ci->
coeffs,
956 sign = (code & 1) - 1;
957 skip = (code & 0x3f) >> 1;
958 }
else if (idx == 1) {
969 "invalid scale factor coding\n");
1005 float** ch_end = ch_data + num_channels;
1011 sfb < s->cur_sfb_offsets + s->
num_bands; sfb++) {
1017 const float* data_end = data + num_channels;
1018 float* data_ptr =
data;
1021 for (ch = ch_data; ch < ch_end; ch++)
1022 *data_ptr++ = (*ch)[
y];
1024 for (ch = ch_data; ch < ch_end; ch++) {
1027 while (data_ptr < data_end)
1028 sum += *data_ptr++ * *mat++;
1036 ch_data[0] + sfb[0],
1039 ch_data[1] + sfb[0],
1087 int transmit_coeffs = 0;
1088 int cur_subwoofer_cutoff;
1106 "processing subframe with offset %i len %i\n", offset, subframe_len);
1156 if (!(num_fill_bits =
get_bits(&s->
gb, 2))) {
1158 num_fill_bits = (len ?
get_bits(&s->
gb, len) : 0) + 1;
1161 if (num_fill_bits >= 0) {
1185 transmit_coeffs = 1;
1189 if (transmit_coeffs) {
1198 int num_vec_coeffs =
get_bits(&s->
gb, num_bits) << 2;
1215 if (step == -32 || step == 31) {
1216 const int sign = (step == 31) - 1;
1222 quant_step += ((quant + step) ^ sign) - sign;
1224 if (quant_step < 0) {
1251 av_dlog(s->
avctx,
"BITSTREAM: subframe header length was %i\n",
1265 av_dlog(s->
avctx,
"BITSTREAM: subframe length was %i\n",
1268 if (transmit_coeffs) {
1278 memset(&s->
tmp[cur_subwoofer_cutoff], 0,
sizeof(*s->
tmp) *
1279 (subframe_len - cur_subwoofer_cutoff));
1287 const float quant = pow(10.0, exp / 20.0);
1291 quant, end - start);
1325 int more_frames = 0;
1333 av_dlog(s->
avctx,
"decoding frame with length %x\n", len);
1374 av_dlog(s->
avctx,
"BITSTREAM: frame header length was %i\n",
1379 for (i = 0; i < avctx->
channels; i++) {
1401 for (i = 0; i < avctx->
channels; i++)
1405 for (i = 0; i < avctx->
channels; i++) {
1424 "frame[%i] would have to skip %i bits\n", s->
frame_num,
1493 align =
FFMIN(align, len);
1517 int *got_frame_ptr,
AVPacket* avpkt)
1522 int buf_size = avpkt->
size;
1523 int num_bits_prev_frame;
1524 int packet_sequence_number;
1532 if (buf_size < avctx->block_align) {
1544 packet_sequence_number =
get_bits(gb, 4);
1550 num_bits_prev_frame);
1561 if (num_bits_prev_frame > 0) {
1563 if (num_bits_prev_frame >= remaining_packet_bits) {
1564 num_bits_prev_frame = remaining_packet_bits;
1570 save_bits(s, gb, num_bits_prev_frame, 1);
1571 av_dlog(avctx,
"accumulated %x bits of frame data\n",
1578 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1639 for (i = 0; i < avctx->
channels; i++)