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);
234 for (i = 0; i < avctx->
channels; i++)
258 if (channel_mask & 8) {
260 for (mask = 1; mask < 16; mask <<= 1)
261 if (channel_mask & mask)
291 int frame_len_ratio, subframe_len,
len;
302 if (subframe_len < s->min_samples_per_subframe ||
336 int fixed_channel_layout = 0;
337 int min_channel_len = 0;
346 fixed_channel_layout = 1;
350 int subframe_len, in_use = 0;
354 if (num_samples[c] == min_channel_len) {
355 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
357 contains_subframe[
c] = 1;
361 in_use |= contains_subframe[
c];
363 contains_subframe[
c] = 0;
368 "Found empty subframe\n");
376 min_channel_len += subframe_len;
380 if (contains_subframe[c]) {
383 "broken frame: num subframes > 31\n");
387 num_samples[
c] += subframe_len;
391 "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
395 }
else if (num_samples[c] <= min_channel_len) {
396 if (num_samples[c] < min_channel_len) {
397 channels_for_cur_subframe = 0;
398 min_channel_len = num_samples[
c];
400 ++channels_for_cur_subframe;
403 }
while (min_channel_len < s->samples_per_frame);
432 int i, send_coef_bits;
434 if (1 << cbits < s->mclms_scaling + 1)
437 send_coef_bits = (cbits ?
get_bits(&s->
gb, cbits) : 0) + 2;
444 for (c = 0; c < i; c++)
461 "Order[%d][%d] %d > max (%d), not supported\n",
478 if (cdlms_send_coef) {
480 int cbits, shift_l, shift_r, j;
510 unsigned int ave_mean;
533 for (; i < tile_size; i++) {
534 int quo = 0, rem, rem_bits, residue;
547 rem_bits = av_ceil_log2(ave_mean);
549 residue = (quo << rem_bits) + rem;
556 residue = -(residue >> 1) - 1;
558 residue = residue >> 1;
592 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++) {
612 for (ilms = 0; ilms < s->
cdlms_ttl[ich]; ilms++)
624 int i, j, ich, pred_error;
629 for (ich = 0; ich < num_channels; ich++) {
631 if (pred_error > 0) {
632 for (i = 0; i < order * num_channels; i++)
635 for (j = 0; j < ich; j++) {
641 }
else if (pred_error < 0) {
642 for (i = 0; i < order * num_channels; i++)
645 for (j = 0; j < ich; j++) {
654 for (ich = num_channels - 1; ich >= 0; ich--) {
672 sizeof(int16_t) * order * num_channels);
675 sizeof(int16_t) * order * num_channels);
686 for (ich = 0; ich < num_channels; ich++) {
690 for (i = 0; i < order * num_channels; i++)
693 for (i = 0; i < ich; i++)
705 for (icoef = 0; icoef < tile_size; 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 #define WMASIGN(x) ((x > 0) - (x < 0))
780 int coef_begin,
int coef_end)
782 int icoef,
pred, ilms, num_lms, residue, input;
785 for (ilms = num_lms - 1; ilms >= 0; ilms--) {
786 for (icoef = coef_begin; icoef < coef_end; icoef++) {
810 for (icoef = 0; icoef < tile_size; icoef++) {
826 for (i = 0; i < order; i++) {
828 for (j = 0; j < order; j++) {
830 pred += filter_coeffs[j] * prevvalues[j - i];
837 for (i = order; i < tile_size; i++) {
839 for (j = 0; j < order; j++)
844 for (j = 0; j < order; j++)
854 int i, j, rawpcm_tile, padding_zeroes, res;
920 "Waiting for seekable tile\n");
940 "inverse LPC filter");
956 "Invalid number of padding bits in raw PCM tile\n");
960 "total %d bits, remain=%d\n", bits,
963 for (j = 0; j < subframe_len; j++)
988 for (j = 0; j < subframe_len; j++)
996 for (j = 0; j < subframe_len; j++) {
1026 int more_frames = 0,
len = 0, i,
ret;
1100 "frame[%"PRIu32
"] would have to skip %i bits\n",
1165 align =
FFMIN(align, len);
1185 int buf_size = avpkt->
size;
1186 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1196 if (buf_size < avctx->block_align) {
1207 packet_sequence_number =
get_bits(gb, 4);
1221 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1226 if (num_bits_prev_frame > 0) {
1228 if (num_bits_prev_frame >= remaining_packet_bits) {
1229 num_bits_prev_frame = remaining_packet_bits;
1235 save_bits(s, gb, num_bits_prev_frame, 1);
1238 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1241 av_dlog(avctx,
"ignoring %x previously saved bits\n",
1317 .
name =
"wmalossless",