36 #define WMALL_MAX_CHANNELS 8
37 #define MAX_SUBFRAMES 32
39 #define MAX_FRAMESIZE 32768
42 #define WMALL_BLOCK_MIN_BITS 6
43 #define WMALL_BLOCK_MAX_BITS 14
44 #define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS)
45 #define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1)
178 unsigned int channel_mask;
179 int i, log2_max_num_subframes;
186 channel_mask =
AV_RL32(edata_ptr + 2);
223 for (i = 0; i < avctx->
channels; i++)
247 if (channel_mask & 8) {
249 for (mask = 1; mask < 16; mask <<= 1)
250 if (channel_mask & mask)
280 int frame_len_ratio, subframe_len,
len;
291 if (subframe_len < s->min_samples_per_subframe ||
325 int fixed_channel_layout = 0;
326 int min_channel_len = 0;
335 fixed_channel_layout = 1;
339 int subframe_len, in_use = 0;
343 if (num_samples[c] == min_channel_len) {
344 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
346 contains_subframe[c] = in_use = 1;
349 contains_subframe[c] = in_use = 1;
352 contains_subframe[c] = 0;
357 "Found empty subframe\n");
365 min_channel_len += subframe_len;
369 if (contains_subframe[c]) {
372 "broken frame: num subframes > 31\n");
376 num_samples[c] += subframe_len;
380 "channel len(%d) > samples_per_frame(%d)\n",
384 }
else if (num_samples[c] <= min_channel_len) {
385 if (num_samples[c] < min_channel_len) {
386 channels_for_cur_subframe = 0;
387 min_channel_len = num_samples[c];
389 ++channels_for_cur_subframe;
392 }
while (min_channel_len < s->samples_per_frame);
421 int i, send_coef_bits;
423 if (1 << cbits < s->mclms_scaling + 1)
426 send_coef_bits = (cbits ?
get_bits(&s->
gb, cbits) : 0) + 2;
433 for (c = 0; c < i; c++)
450 "Order[%d][%d] %d > max (%d), not supported\n",
460 if (cdlms_send_coef) {
462 int cbits, shift_l, shift_r, j;
488 unsigned int ave_mean;
511 for (; i < tile_size; i++) {
512 int quo = 0, rem, rem_bits, residue;
525 rem_bits = av_ceil_log2(ave_mean);
527 residue = (quo << rem_bits) + rem;
534 residue = -(residue >> 1) - 1;
536 residue = residue >> 1;
570 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
590 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
602 int i, j, ich, pred_error;
607 for (ich = 0; ich < num_channels; ich++) {
609 if (pred_error > 0) {
610 for (i = 0; i < order * num_channels; i++)
613 for (j = 0; j < ich; j++) {
619 }
else if (pred_error < 0) {
620 for (i = 0; i < order * num_channels; i++)
623 for (j = 0; j < ich; j++) {
632 for (ich = num_channels - 1; ich >= 0; ich--) {
650 2 * order * num_channels);
653 2 * order * num_channels);
664 for (ich = 0; ich < num_channels; ich++) {
668 for (i = 0; i < order * num_channels; i++)
671 for (i = 0; i < ich; i++)
683 for (icoef = 0; icoef < tile_size; icoef++) {
694 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
702 int input,
int residue)
709 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
712 }
else if (residue > 0) {
713 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
745 int ilms, recent, icoef;
746 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
751 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
754 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
763 int ilms, recent, icoef;
764 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
769 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
779 int coef_begin,
int coef_end)
781 int icoef,
pred, ilms, num_lms, residue, input;
784 for (ilms = num_lms - 1; ilms >= 0; ilms--) {
785 for (icoef = coef_begin; icoef < coef_end; icoef++) {
802 for (icoef = 0; icoef < tile_size; icoef++) {
818 for (i = 0; i < order; i++) {
820 for (j = 0; j < order; j++) {
822 pred += filter_coeffs[j] * prevvalues[j - i];
829 for (i = order; i < tile_size; i++) {
831 for (j = 0; j < order; j++)
836 for (j = 0; j < order; j++)
846 int i, j, rawpcm_tile, padding_zeroes, res;
912 "Waiting for seekable tile\n");
932 "inverse LPC filter");
948 "Invalid number of padding bits in raw PCM tile\n");
952 "total %d bits, remain=%d\n", bits,
955 for (j = 0; j < subframe_len; j++)
980 for (j = 0; j < subframe_len; j++)
988 for (j = 0; j < subframe_len; j++) {
1018 int more_frames = 0,
len = 0, i, ret;
1024 "not enough space for the output samples\n");
1090 "frame[%i] would have to skip %i bits\n", s->
frame_num,
1154 align =
FFMIN(align, len);
1174 int buf_size = avpkt->
size;
1175 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1183 if (buf_size < avctx->block_align)
1192 packet_sequence_number =
get_bits(gb, 4);
1210 if (num_bits_prev_frame > 0) {
1212 if (num_bits_prev_frame >= remaining_packet_bits) {
1213 num_bits_prev_frame = remaining_packet_bits;
1219 save_bits(s, gb, num_bits_prev_frame, 1);
1222 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1225 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1301 .
name =
"wmalossless",