39 #define WMALL_MAX_CHANNELS 8
40 #define MAX_SUBFRAMES 32
42 #define MAX_FRAMESIZE 32768
45 #define WMALL_BLOCK_MIN_BITS 6
46 #define WMALL_BLOCK_MAX_BITS 14
47 #define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS)
48 #define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1)
50 #define WMALL_COEFF_PAD_SIZE 16
183 unsigned int channel_mask;
184 int i, log2_max_num_subframes;
197 channel_mask =
AV_RL32(edata_ptr + 2);
233 for (i = 0; i < avctx->
channels; i++)
257 if (channel_mask & 8) {
259 for (mask = 1; mask < 16; mask <<= 1)
260 if (channel_mask & mask)
290 int frame_len_ratio, subframe_len,
len;
301 if (subframe_len < s->min_samples_per_subframe ||
335 int fixed_channel_layout = 0;
336 int min_channel_len = 0;
345 fixed_channel_layout = 1;
349 int subframe_len, in_use = 0;
353 if (num_samples[c] == min_channel_len) {
354 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
356 contains_subframe[
c] = 1;
360 in_use |= contains_subframe[
c];
362 contains_subframe[
c] = 0;
367 "Found empty subframe\n");
375 min_channel_len += subframe_len;
379 if (contains_subframe[c]) {
382 "broken frame: num subframes > 31\n");
386 num_samples[
c] += subframe_len;
390 "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
394 }
else if (num_samples[c] <= min_channel_len) {
395 if (num_samples[c] < min_channel_len) {
396 channels_for_cur_subframe = 0;
397 min_channel_len = num_samples[
c];
399 ++channels_for_cur_subframe;
402 }
while (min_channel_len < s->samples_per_frame);
431 int i, send_coef_bits;
433 if (1 << cbits < s->mclms_scaling + 1)
436 send_coef_bits = (cbits ?
get_bits(&s->
gb, cbits) : 0) + 2;
443 for (c = 0; c < i; c++)
460 "Order[%d][%d] %d > max (%d), not supported\n",
477 if (cdlms_send_coef) {
479 int cbits, shift_l, shift_r, j;
509 unsigned int ave_mean;
532 for (; i < tile_size; i++) {
533 int quo = 0, rem, rem_bits, residue;
546 rem_bits = av_ceil_log2(ave_mean);
548 residue = (quo << rem_bits) + rem;
555 residue = -(residue >> 1) - 1;
557 residue = residue >> 1;
591 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
611 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
623 int i, j, ich, pred_error;
628 for (ich = 0; ich < num_channels; ich++) {
630 if (pred_error > 0) {
631 for (i = 0; i < order * num_channels; i++)
634 for (j = 0; j < ich; j++) {
640 }
else if (pred_error < 0) {
641 for (i = 0; i < order * num_channels; i++)
644 for (j = 0; j < ich; j++) {
653 for (ich = num_channels - 1; ich >= 0; ich--) {
671 sizeof(int16_t) * order * num_channels);
674 sizeof(int16_t) * order * num_channels);
685 for (ich = 0; ich < num_channels; ich++) {
689 for (i = 0; i < order * num_channels; i++)
692 for (i = 0; i < ich; i++)
704 for (icoef = 0; icoef < tile_size; 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 #define WMASIGN(x) ((x > 0) - (x < 0))
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++) {
809 for (icoef = 0; icoef < tile_size; icoef++) {
825 for (i = 0; i < order; i++) {
827 for (j = 0; j < order; j++) {
829 pred += filter_coeffs[j] * prevvalues[j - i];
836 for (i = order; i < tile_size; i++) {
838 for (j = 0; j < order; j++)
843 for (j = 0; j < order; j++)
853 int i, j, rawpcm_tile, padding_zeroes, res;
919 "Waiting for seekable tile\n");
939 "inverse LPC filter");
955 "Invalid number of padding bits in raw PCM tile\n");
959 "total %d bits, remain=%d\n", bits,
962 for (j = 0; j < subframe_len; j++)
987 for (j = 0; j < subframe_len; j++)
995 for (j = 0; j < subframe_len; j++) {
1025 int more_frames = 0,
len = 0, i,
ret;
1099 "frame[%"PRIu32
"] would have to skip %i bits\n",
1164 align =
FFMIN(align, len);
1184 int buf_size = avpkt->
size;
1185 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1195 if (buf_size < avctx->block_align) {
1206 packet_sequence_number =
get_bits(gb, 4);
1220 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1225 if (num_bits_prev_frame > 0) {
1227 if (num_bits_prev_frame >= remaining_packet_bits) {
1228 num_bits_prev_frame = remaining_packet_bits;
1234 save_bits(s, gb, num_bits_prev_frame, 1);
1237 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1240 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1316 .
name =
"wmalossless",