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)
277 int frame_len_ratio, subframe_len,
len;
288 if (subframe_len < s->min_samples_per_subframe ||
322 int fixed_channel_layout = 0;
323 int min_channel_len = 0;
332 fixed_channel_layout = 1;
336 int subframe_len, in_use = 0;
340 if (num_samples[c] == min_channel_len) {
341 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
343 contains_subframe[
c] = in_use = 1;
346 contains_subframe[
c] = in_use = 1;
349 contains_subframe[
c] = 0;
354 "Found empty subframe\n");
362 min_channel_len += subframe_len;
366 if (contains_subframe[c]) {
369 "broken frame: num subframes > 31\n");
373 num_samples[
c] += subframe_len;
377 "channel len(%d) > samples_per_frame(%d)\n",
381 }
else if (num_samples[c] <= min_channel_len) {
382 if (num_samples[c] < min_channel_len) {
383 channels_for_cur_subframe = 0;
384 min_channel_len = num_samples[
c];
386 ++channels_for_cur_subframe;
389 }
while (min_channel_len < s->samples_per_frame);
418 int i, send_coef_bits;
420 if (1 << cbits < s->mclms_scaling + 1)
423 send_coef_bits = (cbits ?
get_bits(&s->
gb, cbits) : 0) + 2;
430 for (c = 0; c < i; c++)
447 "Order[%d][%d] %d > max (%d), not supported\n",
457 if (cdlms_send_coef) {
459 int cbits, shift_l, shift_r, j;
485 unsigned int ave_mean;
508 for (; i < tile_size; i++) {
509 int quo = 0, rem, rem_bits, residue;
522 rem_bits = av_ceil_log2(ave_mean);
524 residue = (quo << rem_bits) + rem;
531 residue = -(residue >> 1) - 1;
533 residue = residue >> 1;
567 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
587 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
599 int i, j, ich, pred_error;
604 for (ich = 0; ich < num_channels; ich++) {
606 if (pred_error > 0) {
607 for (i = 0; i < order * num_channels; i++)
610 for (j = 0; j < ich; j++) {
616 }
else if (pred_error < 0) {
617 for (i = 0; i < order * num_channels; i++)
620 for (j = 0; j < ich; j++) {
629 for (ich = num_channels - 1; ich >= 0; ich--) {
647 2 * order * num_channels);
650 2 * order * num_channels);
661 for (ich = 0; ich < num_channels; ich++) {
665 for (i = 0; i < order * num_channels; i++)
668 for (i = 0; i < ich; i++)
680 for (icoef = 0; icoef < tile_size; icoef++) {
691 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
699 int input,
int residue)
706 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
709 }
else if (residue > 0) {
710 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
742 int ilms, recent, icoef;
743 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
748 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
751 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
760 int ilms, recent, icoef;
761 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
766 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
776 int coef_begin,
int coef_end)
778 int icoef,
pred, ilms, num_lms, residue, input;
781 for (ilms = num_lms - 1; ilms >= 0; ilms--) {
782 for (icoef = coef_begin; icoef < coef_end; icoef++) {
799 for (icoef = 0; icoef < tile_size; icoef++) {
815 for (i = 0; i < order; i++) {
817 for (j = 0; j < order; j++) {
819 pred += filter_coeffs[j] * prevvalues[j - i];
826 for (i = order; i < tile_size; i++) {
828 for (j = 0; j < order; j++)
833 for (j = 0; j < order; j++)
843 int i, j, rawpcm_tile, padding_zeroes, res;
909 "Waiting for seekable tile\n");
929 "implemented. Expect wrong output.\n");
945 "Invalid number of padding bits in raw PCM tile\n");
949 "total %d bits, remain=%d\n", bits,
952 for (j = 0; j < subframe_len; j++)
977 for (j = 0; j < subframe_len; j++)
985 for (j = 0; j < subframe_len; j++) {
1015 int more_frames = 0,
len = 0, i, ret;
1021 "not enough space for the output samples\n");
1087 "frame[%i] would have to skip %i bits\n", s->
frame_num,
1151 align =
FFMIN(align, len);
1171 int buf_size = avpkt->
size;
1172 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1180 if (buf_size < avctx->block_align)
1189 packet_sequence_number =
get_bits(gb, 4);
1207 if (num_bits_prev_frame > 0) {
1209 if (num_bits_prev_frame >= remaining_packet_bits) {
1210 num_bits_prev_frame = remaining_packet_bits;
1216 save_bits(s, gb, num_bits_prev_frame, 1);
1219 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1222 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1288 .
name =
"wmalossless",