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)
278 int frame_len_ratio, subframe_len,
len;
289 if (subframe_len < s->min_samples_per_subframe ||
323 int fixed_channel_layout = 0;
324 int min_channel_len = 0;
333 fixed_channel_layout = 1;
337 int subframe_len, in_use = 0;
341 if (num_samples[c] == min_channel_len) {
342 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
344 contains_subframe[
c] = in_use = 1;
347 contains_subframe[
c] = in_use = 1;
350 contains_subframe[
c] = 0;
355 "Found empty subframe\n");
363 min_channel_len += subframe_len;
367 if (contains_subframe[c]) {
370 "broken frame: num subframes > 31\n");
374 num_samples[
c] += subframe_len;
378 "channel len(%d) > samples_per_frame(%d)\n",
382 }
else if (num_samples[c] <= min_channel_len) {
383 if (num_samples[c] < min_channel_len) {
384 channels_for_cur_subframe = 0;
385 min_channel_len = num_samples[
c];
387 ++channels_for_cur_subframe;
390 }
while (min_channel_len < s->samples_per_frame);
419 int i, send_coef_bits;
421 if (1 << cbits < s->mclms_scaling + 1)
424 send_coef_bits = (cbits ?
get_bits(&s->
gb, cbits) : 0) + 2;
431 for (c = 0; c < i; c++)
448 "Order[%d][%d] %d > max (%d), not supported\n",
458 if (cdlms_send_coef) {
460 int cbits, shift_l, shift_r, j;
486 unsigned int ave_mean;
509 for (; i < tile_size; i++) {
510 int quo = 0, rem, rem_bits, residue;
523 rem_bits = av_ceil_log2(ave_mean);
525 residue = (quo << rem_bits) + rem;
532 residue = -(residue >> 1) - 1;
534 residue = residue >> 1;
568 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
588 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
600 int i, j, ich, pred_error;
605 for (ich = 0; ich < num_channels; ich++) {
607 if (pred_error > 0) {
608 for (i = 0; i < order * num_channels; i++)
611 for (j = 0; j < ich; j++) {
617 }
else if (pred_error < 0) {
618 for (i = 0; i < order * num_channels; i++)
621 for (j = 0; j < ich; j++) {
630 for (ich = num_channels - 1; ich >= 0; ich--) {
648 2 * order * num_channels);
651 2 * order * num_channels);
662 for (ich = 0; ich < num_channels; ich++) {
666 for (i = 0; i < order * num_channels; i++)
669 for (i = 0; i < ich; i++)
681 for (icoef = 0; icoef < tile_size; icoef++) {
692 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
700 int input,
int residue)
707 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
710 }
else if (residue > 0) {
711 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
743 int ilms, recent, icoef;
744 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
749 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
752 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
761 int ilms, recent, icoef;
762 for (ilms = s->
cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
767 for (icoef = 0; icoef < s->
cdlms[ich][ilms].
order; icoef++)
777 int coef_begin,
int coef_end)
779 int icoef,
pred, ilms, num_lms, residue, input;
782 for (ilms = num_lms - 1; ilms >= 0; ilms--) {
783 for (icoef = coef_begin; icoef < coef_end; icoef++) {
800 for (icoef = 0; icoef < tile_size; icoef++) {
816 for (i = 0; i < order; i++) {
818 for (j = 0; j < order; j++) {
820 pred += filter_coeffs[j] * prevvalues[j - i];
827 for (i = order; i < tile_size; i++) {
829 for (j = 0; j < order; j++)
834 for (j = 0; j < order; j++)
844 int i, j, rawpcm_tile, padding_zeroes,
res;
910 "Waiting for seekable tile\n");
930 "inverse LPC filter");
946 "Invalid number of padding bits in raw PCM tile\n");
950 "total %d bits, remain=%d\n", bits,
953 for (j = 0; j < subframe_len; j++)
978 for (j = 0; j < subframe_len; j++)
986 for (j = 0; j < subframe_len; j++) {
1016 int more_frames = 0,
len = 0, i,
ret;
1086 "frame[%i] would have to skip %i bits\n", s->
frame_num,
1150 align =
FFMIN(align, len);
1170 int buf_size = avpkt->
size;
1171 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1179 if (buf_size < avctx->block_align)
1188 packet_sequence_number =
get_bits(gb, 4);
1206 if (num_bits_prev_frame > 0) {
1208 if (num_bits_prev_frame >= remaining_packet_bits) {
1209 num_bits_prev_frame = remaining_packet_bits;
1215 save_bits(s, gb, num_bits_prev_frame, 1);
1218 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1221 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1288 .
name =
"wmalossless",