Go to the documentation of this file.
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
178 #define WMASIGN(x) (((x) > 0) - ((x) < 0))
184 unsigned int channel_mask;
185 int i, log2_max_num_subframes;
209 s->decode_flags =
AV_RL16(edata_ptr + 14);
210 channel_mask =
AV_RL32(edata_ptr + 2);
211 s->bits_per_sample =
AV_RL16(edata_ptr);
212 if (
s->bits_per_sample == 16)
214 else if (
s->bits_per_sample == 24) {
238 s->len_prefix =
s->decode_flags & 0x40;
247 s->channel[
i].prev_block_len =
s->samples_per_frame;
250 log2_max_num_subframes = (
s->decode_flags & 0x38) >> 3;
251 s->max_num_subframes = 1 << log2_max_num_subframes;
252 s->max_subframe_len_bit = 0;
253 s->subframe_len_bits =
av_log2(log2_max_num_subframes) + 1;
255 s->min_samples_per_subframe =
s->samples_per_frame /
s->max_num_subframes;
256 s->dynamic_range_compression =
s->decode_flags & 0x80;
257 s->bV3RTM =
s->decode_flags & 0x100;
261 s->max_num_subframes);
270 if (channel_mask & 8) {
273 if (channel_mask &
mask)
293 int frame_len_ratio, subframe_len,
len;
296 if (
offset ==
s->samples_per_frame -
s->min_samples_per_subframe)
297 return s->min_samples_per_subframe;
301 subframe_len =
s->min_samples_per_subframe * (frame_len_ratio + 1);
304 if (subframe_len < s->min_samples_per_subframe ||
305 subframe_len >
s->samples_per_frame) {
337 int channels_for_cur_subframe =
s->num_channels;
338 int fixed_channel_layout = 0;
339 int min_channel_len = 0;
343 for (
c = 0;
c <
s->num_channels;
c++)
344 s->channel[
c].num_subframes = 0;
347 if (
s->max_num_subframes == 1 || tile_aligned)
348 fixed_channel_layout = 1;
352 int subframe_len, in_use = 0;
355 for (
c = 0;
c <
s->num_channels;
c++) {
356 if (num_samples[
c] == min_channel_len) {
357 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
358 (min_channel_len ==
s->samples_per_frame -
s->min_samples_per_subframe)) {
359 contains_subframe[
c] = 1;
363 in_use |= contains_subframe[
c];
365 contains_subframe[
c] = 0;
370 "Found empty subframe\n");
378 min_channel_len += subframe_len;
379 for (
c = 0;
c <
s->num_channels;
c++) {
382 if (contains_subframe[
c]) {
385 "broken frame: num subframes > 31\n");
389 num_samples[
c] += subframe_len;
391 if (num_samples[
c] >
s->samples_per_frame) {
393 "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
394 num_samples[
c],
s->samples_per_frame);
397 }
else if (num_samples[
c] <= min_channel_len) {
398 if (num_samples[
c] < min_channel_len) {
399 channels_for_cur_subframe = 0;
400 min_channel_len = num_samples[
c];
402 ++channels_for_cur_subframe;
405 }
while (min_channel_len < s->samples_per_frame);
407 for (
c = 0;
c <
s->num_channels;
c++) {
409 for (
i = 0;
i <
s->channel[
c].num_subframes;
i++) {
410 s->channel[
c].subframe_offsets[
i] =
offset;
424 for (
i = 0;
i <
s->acfilter_order;
i++)
425 s->acfilter_coeffs[
i] =
get_bitsz(&
s->gb,
s->acfilter_scaling) + 1;
430 s->mclms_order = (
get_bits(&
s->gb, 4) + 1) * 2;
433 int i, send_coef_bits;
434 int cbits =
av_log2(
s->mclms_scaling + 1);
435 if (1 << cbits < s->mclms_scaling + 1)
438 send_coef_bits =
get_bitsz(&
s->gb, cbits) + 2;
440 for (
i = 0;
i <
s->mclms_order *
s->num_channels *
s->num_channels;
i++)
441 s->mclms_coeffs[
i] =
get_bits(&
s->gb, send_coef_bits);
443 for (
i = 0;
i <
s->num_channels;
i++) {
445 for (
c = 0;
c <
i;
c++)
446 s->mclms_coeffs_cur[
i *
s->num_channels +
c] =
get_bits(&
s->gb, send_coef_bits);
456 for (
c = 0;
c <
s->num_channels;
c++) {
458 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++) {
462 "Order[%d][%d] %d > max (%d), not supported\n",
464 s->cdlms[0][0].order = 0;
467 if(
s->cdlms[
c][
i].order & 8 &&
s->bits_per_sample == 16) {
471 s->cdlms[
c][
i].order);
476 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++)
479 if (cdlms_send_coef) {
480 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++) {
481 int cbits, shift_l, shift_r, j;
483 if ((1 << cbits) <
s->cdlms[
c][
i].order)
488 if ((1 << cbits) <
s->cdlms[
c][
i].scaling + 1)
492 shift_l = 32 -
s->cdlms[
c][
i].bitsend;
493 shift_r = 32 -
s->cdlms[
c][
i].scaling - 2;
494 for (j = 0; j <
s->cdlms[
c][
i].coefsend; j++)
495 s->cdlms[
c][
i].coefs[j] =
496 (
get_bits(&
s->gb,
s->cdlms[
c][
i].bitsend) << shift_l) >> shift_r;
500 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++)
501 memset(
s->cdlms[
c][
i].coefs +
s->cdlms[
c][
i].order,
511 unsigned int ave_mean;
513 if (
s->transient[ch]) {
515 if (
s->transient_pos[ch])
516 s->transient[ch] = 0;
517 s->channel[ch].transient_counter =
518 FFMAX(
s->channel[ch].transient_counter,
s->samples_per_frame / 2);
519 }
else if (
s->channel[ch].transient_counter)
520 s->transient[ch] = 1;
522 if (
s->seekable_tile) {
523 ave_mean =
get_bits(&
s->gb,
s->bits_per_sample);
524 s->ave_sum[ch] = ave_mean << (
s->movave_scaling + 1);
527 if (
s->seekable_tile) {
528 if (
s->do_inter_ch_decorr)
534 for (;
i < tile_size;
i++) {
536 unsigned quo = 0, residue;
545 ave_mean = (
s->ave_sum[ch] + (1 <<
s->movave_scaling)) >> (
s->movave_scaling + 1);
549 rem_bits = av_ceil_log2(ave_mean);
551 residue = (quo << rem_bits) + rem;
554 s->ave_sum[ch] = residue +
s->ave_sum[ch] -
555 (
s->ave_sum[ch] >>
s->movave_scaling);
557 residue = (residue >> 1) ^ -(residue & 1);
558 s->channel_residues[ch][
i] = residue;
571 cbits =
s->lpc_scaling +
s->lpc_intbits;
572 for (ch = 0; ch <
s->num_channels; ch++)
573 for (
i = 0;
i <
s->lpc_order;
i++)
581 memset(
s->acfilter_coeffs, 0,
sizeof(
s->acfilter_coeffs));
582 memset(
s->acfilter_prevvalues, 0,
sizeof(
s->acfilter_prevvalues));
583 memset(
s->lpc_coefs, 0,
sizeof(
s->lpc_coefs));
585 memset(
s->mclms_coeffs, 0,
sizeof(
s->mclms_coeffs));
586 memset(
s->mclms_coeffs_cur, 0,
sizeof(
s->mclms_coeffs_cur));
587 memset(
s->mclms_prevvalues, 0,
sizeof(
s->mclms_prevvalues));
588 memset(
s->mclms_updates, 0,
sizeof(
s->mclms_updates));
590 for (ich = 0; ich <
s->num_channels; ich++) {
591 for (ilms = 0; ilms <
s->cdlms_ttl[ich]; ilms++) {
592 memset(
s->cdlms[ich][ilms].coefs, 0,
593 sizeof(
s->cdlms[ich][ilms].coefs));
594 memset(
s->cdlms[ich][ilms].lms_prevvalues, 0,
595 sizeof(
s->cdlms[ich][ilms].lms_prevvalues));
596 memset(
s->cdlms[ich][ilms].lms_updates, 0,
597 sizeof(
s->cdlms[ich][ilms].lms_updates));
609 s->mclms_recent =
s->mclms_order *
s->num_channels;
610 for (ich = 0; ich <
s->num_channels; ich++) {
611 for (ilms = 0; ilms <
s->cdlms_ttl[ich]; ilms++)
612 s->cdlms[ich][ilms].recent =
s->cdlms[ich][ilms].order;
615 s->channel[ich].transient_counter =
s->samples_per_frame;
616 s->transient[ich] = 1;
617 s->transient_pos[ich] = 0;
623 int i, j, ich, pred_error;
624 int order =
s->mclms_order;
625 int num_channels =
s->num_channels;
626 int range = 1 << (
s->bits_per_sample - 1);
628 for (ich = 0; ich < num_channels; ich++) {
629 pred_error =
s->channel_residues[ich][icoef] - (unsigned)
pred[ich];
630 if (pred_error > 0) {
631 for (
i = 0;
i < order * num_channels;
i++)
632 s->mclms_coeffs[
i + ich * order * num_channels] +=
633 s->mclms_updates[
s->mclms_recent +
i];
634 for (j = 0; j < ich; j++)
635 s->mclms_coeffs_cur[ich * num_channels + j] +=
WMASIGN(
s->channel_residues[j][icoef]);
636 }
else if (pred_error < 0) {
637 for (
i = 0;
i < order * num_channels;
i++)
638 s->mclms_coeffs[
i + ich * order * num_channels] -=
639 s->mclms_updates[
s->mclms_recent +
i];
640 for (j = 0; j < ich; j++)
641 s->mclms_coeffs_cur[ich * num_channels + j] -=
WMASIGN(
s->channel_residues[j][icoef]);
645 for (ich = num_channels - 1; ich >= 0; ich--) {
647 s->mclms_prevvalues[
s->mclms_recent] = av_clip(
s->channel_residues[ich][icoef],
649 s->mclms_updates[
s->mclms_recent] =
WMASIGN(
s->channel_residues[ich][icoef]);
652 if (
s->mclms_recent == 0) {
653 memcpy(&
s->mclms_prevvalues[order * num_channels],
655 sizeof(
int32_t) * order * num_channels);
656 memcpy(&
s->mclms_updates[order * num_channels],
658 sizeof(
int32_t) * order * num_channels);
659 s->mclms_recent = num_channels * order;
666 int order =
s->mclms_order;
667 int num_channels =
s->num_channels;
669 for (ich = 0; ich < num_channels; ich++) {
671 if (!
s->is_channel_coded[ich])
673 for (
i = 0;
i < order * num_channels;
i++)
674 pred[ich] += (uint32_t)
s->mclms_prevvalues[
i +
s->mclms_recent] *
675 s->mclms_coeffs[
i + order * num_channels * ich];
676 for (
i = 0;
i < ich;
i++)
677 pred[ich] += (uint32_t)
s->channel_residues[
i][icoef] *
678 s->mclms_coeffs_cur[
i + num_channels * ich];
679 pred[ich] += (1
U <<
s->mclms_scaling) >> 1;
680 pred[ich] >>=
s->mclms_scaling;
681 s->channel_residues[ich][icoef] += (unsigned)
pred[ich];
688 for (icoef = 0; icoef < tile_size; icoef++) {
696 int ilms, recent, icoef;
697 for (ilms =
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
698 recent =
s->cdlms[ich][ilms].recent;
699 if (
s->update_speed[ich] == 16)
702 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
703 s->cdlms[ich][ilms].lms_updates[icoef + recent] *= 2;
705 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
706 s->cdlms[ich][ilms].lms_updates[icoef] *= 2;
709 s->update_speed[ich] = 16;
714 int ilms, recent, icoef;
715 for (ilms =
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
716 recent =
s->cdlms[ich][ilms].recent;
717 if (
s->update_speed[ich] == 8)
720 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
721 s->cdlms[ich][ilms].lms_updates[icoef + recent] /= 2;
723 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
724 s->cdlms[ich][ilms].lms_updates[icoef] /= 2;
726 s->update_speed[ich] = 8;
729 #define CD_LMS(bits, ROUND) \
730 static void lms_update ## bits (WmallDecodeCtx *s, int ich, int ilms, int input) \
732 int recent = s->cdlms[ich][ilms].recent; \
733 int range = 1 << s->bits_per_sample - 1; \
734 int order = s->cdlms[ich][ilms].order; \
735 int ##bits##_t *prev = (int##bits##_t *)s->cdlms[ich][ilms].lms_prevvalues; \
740 memcpy(prev + order, prev, (bits/8) * order); \
741 memcpy(s->cdlms[ich][ilms].lms_updates + order, \
742 s->cdlms[ich][ilms].lms_updates, \
743 sizeof(*s->cdlms[ich][ilms].lms_updates) * order); \
744 recent = order - 1; \
747 prev[recent] = av_clip(input, -range, range - 1); \
748 s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich]; \
750 s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2; \
751 s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1; \
752 s->cdlms[ich][ilms].recent = recent; \
753 memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0, \
754 sizeof(s->cdlms[ich][ilms].lms_updates) - \
755 sizeof(*s->cdlms[ich][ilms].lms_updates)*(recent+order)); \
758 static void revert_cdlms ## bits (WmallDecodeCtx *s, int ch, \
759 int coef_begin, int coef_end) \
761 int icoef, ilms, num_lms, residue, input; \
764 num_lms = s->cdlms_ttl[ch]; \
765 for (ilms = num_lms - 1; ilms >= 0; ilms--) { \
766 for (icoef = coef_begin; icoef < coef_end; icoef++) { \
767 int##bits##_t *prevvalues = (int##bits##_t *)s->cdlms[ch][ilms].lms_prevvalues; \
768 pred = (1 << s->cdlms[ch][ilms].scaling) >> 1; \
769 residue = s->channel_residues[ch][icoef]; \
770 pred += s->dsp.scalarproduct_and_madd_int## bits (s->cdlms[ch][ilms].coefs, \
771 prevvalues + s->cdlms[ch][ilms].recent, \
772 s->cdlms[ch][ilms].lms_updates + \
773 s->cdlms[ch][ilms].recent, \
774 FFALIGN(s->cdlms[ch][ilms].order, ROUND), \
776 input = residue + (unsigned)((int)pred >> s->cdlms[ch][ilms].scaling); \
777 lms_update ## bits(s, ch, ilms, input); \
778 s->channel_residues[ch][icoef] = input; \
781 if (bits <= 16) emms_c(); \
789 if (
s->num_channels != 2)
791 else if (
s->is_channel_coded[0] ||
s->is_channel_coded[1]) {
793 for (icoef = 0; icoef < tile_size; icoef++) {
794 s->channel_residues[0][icoef] -= (unsigned)(
s->channel_residues[1][icoef] >> 1);
795 s->channel_residues[1][icoef] += (unsigned)
s->channel_residues[0][icoef];
803 int16_t *filter_coeffs =
s->acfilter_coeffs;
804 int scaling =
s->acfilter_scaling;
805 int order =
s->acfilter_order;
807 for (ich = 0; ich <
s->num_channels; ich++) {
808 int *prevvalues =
s->acfilter_prevvalues[ich];
809 for (
i = 0;
i < order;
i++) {
811 for (j = 0; j < order; j++) {
813 pred += (uint32_t)filter_coeffs[j] * prevvalues[j -
i];
815 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
818 s->channel_residues[ich][
i] += (unsigned)
pred;
820 for (
i = order;
i < tile_size;
i++) {
822 for (j = 0; j < order; j++)
823 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
825 s->channel_residues[ich][
i] += (unsigned)
pred;
827 for (j = order - 1; j >= 0; j--)
828 if (tile_size <= j) {
829 prevvalues[j] = prevvalues[j - tile_size];
831 prevvalues[j] =
s->channel_residues[ich][tile_size - j - 1];
837 int offset =
s->samples_per_frame;
838 int subframe_len =
s->samples_per_frame;
839 int total_samples =
s->samples_per_frame *
s->num_channels;
840 int i, j, rawpcm_tile, padding_zeroes, res;
847 for (
i = 0;
i <
s->num_channels;
i++) {
848 if (
offset >
s->channel[
i].decoded_samples) {
849 offset =
s->channel[
i].decoded_samples;
851 s->channel[
i].subframe_len[
s->channel[
i].cur_subframe];
856 s->channels_for_cur_subframe = 0;
857 for (
i = 0;
i <
s->num_channels;
i++) {
858 const int cur_subframe =
s->channel[
i].cur_subframe;
860 total_samples -=
s->channel[
i].decoded_samples;
863 if (
offset ==
s->channel[
i].decoded_samples &&
864 subframe_len ==
s->channel[
i].subframe_len[cur_subframe]) {
865 total_samples -=
s->channel[
i].subframe_len[cur_subframe];
866 s->channel[
i].decoded_samples +=
867 s->channel[
i].subframe_len[cur_subframe];
868 s->channel_indexes_for_cur_subframe[
s->channels_for_cur_subframe] =
i;
869 ++
s->channels_for_cur_subframe;
876 s->parsed_all_subframes = 1;
880 if (
s->seekable_tile) {
884 if (
s->do_arith_coding) {
908 if (!rawpcm_tile && !
s->cdlms[0][0].order) {
910 "Waiting for seekable tile\n");
916 for (
i = 0;
i <
s->num_channels;
i++)
917 s->is_channel_coded[
i] = 1;
920 for (
i = 0;
i <
s->num_channels;
i++)
929 "inverse LPC filter");
944 int bits =
s->bits_per_sample - padding_zeroes;
947 "Invalid number of padding bits in raw PCM tile\n");
950 ff_dlog(
s->avctx,
"RAWPCM %d bits per sample. "
951 "total %d bits, remain=%d\n",
bits,
953 for (
i = 0;
i <
s->num_channels;
i++)
954 for (j = 0; j < subframe_len; j++)
957 if (
s->bits_per_sample < padding_zeroes)
959 for (
i = 0;
i <
s->num_channels;
i++) {
960 if (
s->is_channel_coded[
i]) {
962 if (
s->seekable_tile)
966 if (
s->bits_per_sample > 16)
967 revert_cdlms32(
s,
i, 0, subframe_len);
969 revert_cdlms16(
s,
i, 0, subframe_len);
971 memset(
s->channel_residues[
i], 0,
sizeof(**
s->channel_residues) * subframe_len);
977 if (
s->do_inter_ch_decorr)
983 if (
s->quant_stepsize != 1)
984 for (
i = 0;
i <
s->num_channels;
i++)
985 for (j = 0; j < subframe_len; j++)
986 s->channel_residues[
i][j] *= (
unsigned)
s->quant_stepsize;
990 for (
i = 0;
i <
s->channels_for_cur_subframe;
i++) {
991 int c =
s->channel_indexes_for_cur_subframe[
i];
992 int subframe_len =
s->channel[
c].subframe_len[
s->channel[
c].cur_subframe];
994 for (j = 0; j < subframe_len; j++) {
995 if (
s->bits_per_sample == 16) {
996 *
s->samples_16[
c]++ = (int16_t)
s->channel_residues[
c][j] * (1 << padding_zeroes);
998 *
s->samples_32[
c]++ =
s->channel_residues[
c][j] * (256
U << padding_zeroes);
1004 for (
i = 0;
i <
s->channels_for_cur_subframe;
i++) {
1005 int c =
s->channel_indexes_for_cur_subframe[
i];
1006 if (
s->channel[
c].cur_subframe >=
s->channel[
c].num_subframes) {
1010 ++
s->channel[
c].cur_subframe;
1024 int more_frames = 0,
len = 0,
i,
ret;
1026 s->frame->nb_samples =
s->samples_per_frame;
1030 s->frame->nb_samples = 0;
1033 for (
i = 0;
i <
s->num_channels;
i++) {
1034 s->samples_16[
i] = (int16_t *)
s->frame->extended_data[
i];
1035 s->samples_32[
i] = (
int32_t *)
s->frame->extended_data[
i];
1050 if (
s->dynamic_range_compression)
1061 ff_dlog(
s->avctx,
"start skip: %i\n", skip);
1067 ff_dlog(
s->avctx,
"end skip: %i\n", skip);
1068 s->frame->nb_samples -= skip;
1069 if (
s->frame->nb_samples <= 0)
1076 s->parsed_all_subframes = 0;
1077 for (
i = 0;
i <
s->num_channels;
i++) {
1078 s->channel[
i].decoded_samples = 0;
1079 s->channel[
i].cur_subframe = 0;
1083 while (!
s->parsed_all_subframes) {
1084 int decoded_samples =
s->channel[0].decoded_samples;
1087 if (
s->frame->nb_samples)
1088 s->frame->nb_samples = decoded_samples;
1097 if (
s->len_prefix) {
1101 "frame[%"PRIu32
"] would have to skip %i bits\n",
1148 s->num_saved_bits =
s->frame_offset;
1152 buflen = (
s->num_saved_bits +
len + 8) >> 3;
1154 if (len <= 0 || buflen >
s->max_frame_size) {
1157 s->num_saved_bits = 0;
1161 s->num_saved_bits +=
len;
1187 int buf_size = avpkt->
size;
1188 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1190 s->frame->nb_samples = 0;
1195 s->num_saved_bits = 0;
1196 }
else if (
s->packet_done ||
s->packet_loss) {
1204 s->buf_bit_size = buf_size << 3;
1208 packet_sequence_number =
get_bits(gb, 4);
1215 num_bits_prev_frame =
get_bits(gb,
s->log2_frame_size);
1218 if (!
s->packet_loss &&
1219 ((
s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
1222 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1223 s->packet_sequence_number, packet_sequence_number);
1225 s->packet_sequence_number = packet_sequence_number;
1227 if (num_bits_prev_frame > 0) {
1229 if (num_bits_prev_frame >= remaining_packet_bits) {
1230 num_bits_prev_frame = remaining_packet_bits;
1239 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1241 }
else if (
s->num_saved_bits -
s->frame_offset) {
1242 ff_dlog(avctx,
"ignoring %x previously saved bits\n",
1243 s->num_saved_bits -
s->frame_offset);
1246 if (
s->packet_loss) {
1249 s->num_saved_bits = 0;
1257 s->buf_bit_size = (avpkt->
size -
s->next_packet_start) << 3;
1266 if (!
s->packet_loss)
1268 }
else if (!
s->len_prefix
1287 if (
s->packet_done && !
s->packet_loss &&
1294 *got_frame_ptr =
s->frame->nb_samples > 0;
1307 s->num_saved_bits = 0;
1308 s->frame_offset = 0;
1309 s->next_packet_start = 0;
1310 s->cdlms[0][0].order = 0;
1311 s->frame->nb_samples = 0;
1326 .
name =
"wmalossless",
#define MAX_SUBFRAMES
max number of subframes per channel
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
uint32_t frame_num
current frame number (not used for decoding)
static av_cold int init(AVCodecContext *avctx)
uint8_t cur_subframe
current subframe number
uint16_t subframe_len[MAX_SUBFRAMES]
subframe length in samples
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
uint64_t channel_layout
Audio channel layout.
uint16_t subframe_offsets[MAX_SUBFRAMES]
subframe positions in the current frame
uint8_t packet_done
set when a packet is fully decoded
int sample_rate
samples per second
int next_packet_start
start offset of the next WMA packet in the demuxer packet
static enum AVSampleFormat sample_fmts[]
int subframe_offset
subframe offset in the bit reservoir
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int frame_offset
frame offset in the bit reservoir
uint8_t packet_loss
set in case of bitstream error
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int decode_frame(WmallDecodeCtx *s)
Decode one WMA frame.
static int get_bits_count(const GetBitContext *s)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int decode_subframe(WmallDecodeCtx *s)
int cdlms_ttl[WMALL_MAX_CHANNELS]
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define WMALL_BLOCK_MAX_SIZE
maximum block size
AVCodec ff_wmalossless_decoder
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
struct WmallDecodeCtx::@189 cdlms[WMALL_MAX_CHANNELS][9]
int8_t channel_indexes_for_cur_subframe[WMALL_MAX_CHANNELS]
static int decode_cdlms(WmallDecodeCtx *s)
static av_cold int decode_close(AVCodecContext *avctx)
static void mclms_predict(WmallDecodeCtx *s, int icoef, int *pred)
int update_speed[WMALL_MAX_CHANNELS]
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int num_saved_bits
saved number of bits
static void decode_mclms(WmallDecodeCtx *s)
av_cold void ff_llauddsp_init(LLAudDSPContext *c)
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define WMALL_COEFF_PAD_SIZE
pad coef buffers with 0 for use with SIMD
static void clear_codec_buffers(WmallDecodeCtx *s)
int max_frame_size
max bitstream size
uint16_t samples_per_frame
number of samples to output
static void reset_codec(WmallDecodeCtx *s)
Reset filter parameters and transient area at new seekable tile.
uint16_t min_samples_per_subframe
uint16_t decoded_samples
number of already processed samples
int16_t lms_updates[MAX_ORDER *2+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
uint8_t do_inter_ch_decorr
static void save_bits(WmallDecodeCtx *s, GetBitContext *gb, int len, int append)
Fill the bit reservoir with a (partial) frame.
static int remaining_bits(WmallDecodeCtx *s, GetBitContext *gb)
Calculate remaining input buffer length.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int len_prefix
frame is prefixed with its length
static const uint16_t mask[17]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int channel_residues[WMALL_MAX_CHANNELS][WMALL_BLOCK_MAX_SIZE]
static int decode_subframe_length(WmallDecodeCtx *s, int offset)
Decode the subframe length.
int32_t lms_prevvalues[MAX_ORDER *2+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int get_sbits(GetBitContext *s, int n)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int lpc_coefs[WMALL_MAX_CHANNELS][40]
static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
int32_t mclms_prevvalues[WMALL_MAX_CHANNELS *2 *32]
#define MAX_FRAMESIZE
maximum compressed frame size
int buf_bit_size
buffer size in bits
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int transient_counter
number of transient samples from the beginning of the transient zone
@ AV_CODEC_ID_WMALOSSLESS
static unsigned int get_bits1(GetBitContext *s)
int32_t * samples_32[WMALL_MAX_CHANNELS]
current sample buffer pointer (24-bit)
int quant_step
quantization step for the current subframe
int32_t mclms_updates[WMALL_MAX_CHANNELS *2 *32]
#define WMALL_MAX_CHANNELS
current decoder limitations
uint8_t bits_per_sample
integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1....
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
uint8_t packet_offset
offset to the frame in the packet
int16_t acfilter_coeffs[16]
static int decode_tilehdr(WmallDecodeCtx *s)
Decode how the data in the frame is split into subframes.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int8_t channels_for_cur_subframe
number of channels that contain the subframe
int16_t mclms_coeffs[WMALL_MAX_CHANNELS *WMALL_MAX_CHANNELS *32]
GetBitContext gb
bitstream reader context
enum AVSampleFormat sample_fmt
audio sample format
int acfilter_prevvalues[WMALL_MAX_CHANNELS][16]
frame-specific decoder context for a single channel
uint8_t packet_sequence_number
current packet number
static void use_high_update_speed(WmallDecodeCtx *s, int ich)
int16_t * samples_16[WMALL_MAX_CHANNELS]
current sample buffer pointer (16-bit)
static void decode_ac_filter(WmallDecodeCtx *s)
int8_t num_channels
number of channels in the stream (same as AVCodecContext.num_channels)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
uint32_t decode_flags
used compression features
int channels
number of audio channels
#define DECLARE_ALIGNED(n, t, v)
static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
static void revert_inter_ch_decorr(WmallDecodeCtx *s, int tile_size)
#define i(width, name, range_min, range_max)
int16_t subframe_len
current subframe length
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
uint8_t max_subframe_len_bit
flag indicating that the subframe is of maximum size when the first subframe length bit is 1
int is_channel_coded[WMALL_MAX_CHANNELS]
AVSampleFormat
Audio sample formats.
uint8_t drc_gain
gain for the DRC tool
static void revert_acfilter(WmallDecodeCtx *s, int tile_size)
GetBitContext pgb
bitstream reader context for the packet
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
uint8_t max_num_subframes
LLAudDSPContext dsp
accelerated DSP functions
int8_t skip_frame
skip output step
static const float pred[4]
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
#define AV_INPUT_BUFFER_PADDING_SIZE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int16_t coefs[MAX_ORDER+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
main external API structure.
int transient_pos[WMALL_MAX_CHANNELS]
av_cold int ff_wma_get_frame_len_bits(int sample_rate, int version, unsigned int decode_flags)
Get the samples per frame for this stream.
static void revert_mclms(WmallDecodeCtx *s, int tile_size)
static av_cold int decode_init(AVCodecContext *avctx)
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static void decode_lpc(WmallDecodeCtx *s)
static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
int16_t mclms_coeffs_cur[WMALL_MAX_CHANNELS *WMALL_MAX_CHANNELS]
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
PutBitContext pb
context for filling the frame_data buffer
#define avpriv_request_sample(...)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
int16_t prev_block_len
length of the previous block
This structure stores compressed data.
#define WMASIGN(x)
Get sign of integer (1 for positive, -1 for negative and 0 for zero)
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int8_t lfe_channel
lfe channel index
unsigned ave_sum[WMALL_MAX_CHANNELS]
#define CD_LMS(bits, ROUND)
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
uint8_t subframe_len_bits
number of bits used for the subframe length
int dynamic_range_compression
frame contains DRC data
static void flush(AVCodecContext *avctx)
uint8_t * frame_data
compressed frame data
int8_t parsed_all_subframes
all subframes decoded?