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;
191 channel_mask =
AV_RL32(edata_ptr + 2);
228 for (i = 0; i < avctx->
channels; i++)
252 if (channel_mask & 8) {
254 for (mask = 1; mask < 16; mask <<= 1)
255 if (channel_mask & mask)
285 int frame_len_ratio, subframe_len,
len;
296 if (subframe_len < s->min_samples_per_subframe ||
330 int fixed_channel_layout = 0;
331 int min_channel_len = 0;
340 fixed_channel_layout = 1;
344 int subframe_len, in_use = 0;
348 if (num_samples[c] == min_channel_len) {
349 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
351 contains_subframe[
c] = 1;
355 in_use |= contains_subframe[
c];
357 contains_subframe[
c] = 0;
362 "Found empty subframe\n");
370 min_channel_len += subframe_len;
374 if (contains_subframe[c]) {
377 "broken frame: num subframes > 31\n");
381 num_samples[
c] += subframe_len;
385 "channel len(%d) > samples_per_frame(%d)\n",
389 }
else if (num_samples[c] <= min_channel_len) {
390 if (num_samples[c] < min_channel_len) {
391 channels_for_cur_subframe = 0;
392 min_channel_len = num_samples[
c];
394 ++channels_for_cur_subframe;
397 }
while (min_channel_len < s->samples_per_frame);
426 int i, send_coef_bits;
428 if (1 << cbits < s->mclms_scaling + 1)
431 send_coef_bits = (cbits ?
get_bits(&s->
gb, cbits) : 0) + 2;
438 for (c = 0; c < i; c++)
455 "Order[%d][%d] %d > max (%d), not supported\n",
465 if (cdlms_send_coef) {
467 int cbits, shift_l, shift_r, j;
493 unsigned int ave_mean;
516 for (; i < tile_size; i++) {
517 int quo = 0, rem, rem_bits, residue;
530 rem_bits = av_ceil_log2(ave_mean);
532 residue = (quo << rem_bits) + rem;
539 residue = -(residue >> 1) - 1;
541 residue = residue >> 1;
575 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
595 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
607 int i, j, ich, pred_error;
612 for (ich = 0; ich < num_channels; ich++) {
614 if (pred_error > 0) {
615 for (i = 0; i < order * num_channels; i++)
618 for (j = 0; j < ich; j++) {
624 }
else if (pred_error < 0) {
625 for (i = 0; i < order * num_channels; i++)
628 for (j = 0; j < ich; j++) {
637 for (ich = num_channels - 1; ich >= 0; ich--) {
655 sizeof(int16_t) * order * num_channels);
658 sizeof(int16_t) * order * num_channels);
669 for (ich = 0; ich < num_channels; ich++) {
673 for (i = 0; i < order * num_channels; i++)
676 for (i = 0; i < ich; i++)
688 for (icoef = 0; icoef < tile_size; icoef++) {
699 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
707 int input,
int residue)
714 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
717 }
else if (residue > 0) {
718 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
750 int ilms, recent, icoef;
751 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
756 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
759 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
768 int ilms, recent, icoef;
769 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
774 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
784 int coef_begin,
int coef_end)
786 int icoef,
pred, ilms, num_lms, residue, input;
789 for (ilms = num_lms - 1; ilms >= 0; ilms--) {
790 for (icoef = coef_begin; icoef < coef_end; icoef++) {
807 for (icoef = 0; icoef < tile_size; icoef++) {
823 for (i = 0; i < order; i++) {
825 for (j = 0; j < order; j++) {
827 pred += filter_coeffs[j] * prevvalues[j - i];
834 for (i = order; i < tile_size; i++) {
836 for (j = 0; j < order; j++)
841 for (j = 0; j < order; j++)
851 int i, j, rawpcm_tile, padding_zeroes,
res;
917 "Waiting for seekable tile\n");
937 "inverse LPC filter");
953 "Invalid number of padding bits in raw PCM tile\n");
957 "total %d bits, remain=%d\n", bits,
960 for (j = 0; j < subframe_len; j++)
985 for (j = 0; j < subframe_len; j++)
993 for (j = 0; j < subframe_len; j++) {
1023 int more_frames = 0,
len = 0, i,
ret;
1097 "frame[%i] would have to skip %i bits\n", s->
frame_num,
1161 align =
FFMIN(align, len);
1181 int buf_size = avpkt->
size;
1182 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1192 if (buf_size < avctx->block_align) {
1203 packet_sequence_number =
get_bits(gb, 4);
1221 if (num_bits_prev_frame > 0) {
1223 if (num_bits_prev_frame >= remaining_packet_bits) {
1224 num_bits_prev_frame = remaining_packet_bits;
1230 save_bits(s, gb, num_bits_prev_frame, 1);
1233 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1236 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1312 .
name =
"wmalossless",