Go to the documentation of this file.
41 #define WMALL_MAX_CHANNELS 8
42 #define MAX_SUBFRAMES 32
44 #define MAX_FRAMESIZE 32768
47 #define WMALL_BLOCK_MIN_BITS 6
48 #define WMALL_BLOCK_MAX_BITS 14
49 #define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS)
50 #define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1)
52 #define WMALL_COEFF_PAD_SIZE 16
180 #define WMASIGN(x) (((x) > 0) - ((x) < 0))
186 unsigned int channel_mask;
187 int i, log2_max_num_subframes;
195 s->decode_flags =
AV_RL16(edata_ptr + 14);
196 channel_mask =
AV_RL32(edata_ptr + 2);
197 s->bits_per_sample =
AV_RL16(edata_ptr);
198 if (
s->bits_per_sample == 16)
200 else if (
s->bits_per_sample == 24) {
234 if (channel_mask & 8) {
237 if (channel_mask &
mask)
256 s->len_prefix =
s->decode_flags & 0x40;
265 s->channel[
i].prev_block_len =
s->samples_per_frame;
268 log2_max_num_subframes = (
s->decode_flags & 0x38) >> 3;
269 s->max_num_subframes = 1 << log2_max_num_subframes;
270 s->max_subframe_len_bit = 0;
271 s->subframe_len_bits =
av_log2(log2_max_num_subframes) + 1;
273 s->min_samples_per_subframe =
s->samples_per_frame /
s->max_num_subframes;
274 s->dynamic_range_compression =
s->decode_flags & 0x80;
275 s->bV3RTM =
s->decode_flags & 0x100;
279 s->max_num_subframes);
298 int frame_len_ratio, subframe_len,
len;
301 if (
offset ==
s->samples_per_frame -
s->min_samples_per_subframe)
302 return s->min_samples_per_subframe;
306 subframe_len =
s->min_samples_per_subframe * (frame_len_ratio + 1);
309 if (subframe_len < s->min_samples_per_subframe ||
310 subframe_len >
s->samples_per_frame) {
342 int channels_for_cur_subframe =
s->num_channels;
343 int fixed_channel_layout = 0;
344 int min_channel_len = 0;
348 for (
c = 0;
c <
s->num_channels;
c++)
349 s->channel[
c].num_subframes = 0;
352 if (
s->max_num_subframes == 1 || tile_aligned)
353 fixed_channel_layout = 1;
357 int subframe_len, in_use = 0;
360 for (
c = 0;
c <
s->num_channels;
c++) {
361 if (num_samples[
c] == min_channel_len) {
362 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
363 (min_channel_len ==
s->samples_per_frame -
s->min_samples_per_subframe)) {
364 contains_subframe[
c] = 1;
368 in_use |= contains_subframe[
c];
370 contains_subframe[
c] = 0;
375 "Found empty subframe\n");
383 min_channel_len += subframe_len;
384 for (
c = 0;
c <
s->num_channels;
c++) {
387 if (contains_subframe[
c]) {
390 "broken frame: num subframes > 31\n");
394 num_samples[
c] += subframe_len;
396 if (num_samples[
c] >
s->samples_per_frame) {
398 "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
399 num_samples[
c],
s->samples_per_frame);
402 }
else if (num_samples[
c] <= min_channel_len) {
403 if (num_samples[
c] < min_channel_len) {
404 channels_for_cur_subframe = 0;
405 min_channel_len = num_samples[
c];
407 ++channels_for_cur_subframe;
410 }
while (min_channel_len < s->samples_per_frame);
412 for (
c = 0;
c <
s->num_channels;
c++) {
414 for (
i = 0;
i <
s->channel[
c].num_subframes;
i++) {
415 s->channel[
c].subframe_offsets[
i] =
offset;
429 for (
i = 0;
i <
s->acfilter_order;
i++)
430 s->acfilter_coeffs[
i] =
get_bitsz(&
s->gb,
s->acfilter_scaling) + 1;
435 s->mclms_order = (
get_bits(&
s->gb, 4) + 1) * 2;
438 int i, send_coef_bits;
439 int cbits =
av_log2(
s->mclms_scaling + 1);
440 if (1 << cbits < s->mclms_scaling + 1)
443 send_coef_bits =
get_bitsz(&
s->gb, cbits) + 2;
445 for (
i = 0;
i <
s->mclms_order *
s->num_channels *
s->num_channels;
i++)
446 s->mclms_coeffs[
i] =
get_bits(&
s->gb, send_coef_bits);
448 for (
i = 0;
i <
s->num_channels;
i++) {
450 for (
c = 0;
c <
i;
c++)
451 s->mclms_coeffs_cur[
i *
s->num_channels +
c] =
get_bits(&
s->gb, send_coef_bits);
461 for (
c = 0;
c <
s->num_channels;
c++) {
463 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++) {
467 "Order[%d][%d] %d > max (%d), not supported\n",
469 s->cdlms[0][0].order = 0;
472 if(
s->cdlms[
c][
i].order & 8 &&
s->bits_per_sample == 16) {
476 s->cdlms[
c][
i].order);
481 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++)
484 if (cdlms_send_coef) {
485 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++) {
486 int cbits, shift_l, shift_r, j;
488 if ((1 << cbits) <
s->cdlms[
c][
i].order)
493 if ((1 << cbits) <
s->cdlms[
c][
i].scaling + 1)
497 shift_l = 32 -
s->cdlms[
c][
i].bitsend;
498 shift_r = 32 -
s->cdlms[
c][
i].scaling - 2;
499 for (j = 0; j <
s->cdlms[
c][
i].coefsend; j++)
500 s->cdlms[
c][
i].coefs[j] =
501 (
get_bits(&
s->gb,
s->cdlms[
c][
i].bitsend) << shift_l) >> shift_r;
505 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++)
506 memset(
s->cdlms[
c][
i].coefs +
s->cdlms[
c][
i].order,
516 unsigned int ave_mean;
518 if (
s->transient[ch]) {
520 if (
s->transient_pos[ch])
521 s->transient[ch] = 0;
522 s->channel[ch].transient_counter =
523 FFMAX(
s->channel[ch].transient_counter,
s->samples_per_frame / 2);
524 }
else if (
s->channel[ch].transient_counter)
525 s->transient[ch] = 1;
527 if (
s->seekable_tile) {
528 ave_mean =
get_bits(&
s->gb,
s->bits_per_sample);
529 s->ave_sum[ch] = ave_mean << (
s->movave_scaling + 1);
532 if (
s->seekable_tile) {
533 if (
s->do_inter_ch_decorr)
539 for (;
i < tile_size;
i++) {
541 unsigned quo = 0, residue;
550 ave_mean = (
s->ave_sum[ch] + (1 <<
s->movave_scaling)) >> (
s->movave_scaling + 1);
556 residue = (quo << rem_bits) + rem;
559 s->ave_sum[ch] = residue +
s->ave_sum[ch] -
560 (
s->ave_sum[ch] >>
s->movave_scaling);
562 residue = (residue >> 1) ^ -(residue & 1);
563 s->channel_residues[ch][
i] = residue;
576 cbits =
s->lpc_scaling +
s->lpc_intbits;
577 for (ch = 0; ch <
s->num_channels; ch++)
578 for (
i = 0;
i <
s->lpc_order;
i++)
586 memset(
s->acfilter_coeffs, 0,
sizeof(
s->acfilter_coeffs));
587 memset(
s->acfilter_prevvalues, 0,
sizeof(
s->acfilter_prevvalues));
588 memset(
s->lpc_coefs, 0,
sizeof(
s->lpc_coefs));
590 memset(
s->mclms_coeffs, 0,
sizeof(
s->mclms_coeffs));
591 memset(
s->mclms_coeffs_cur, 0,
sizeof(
s->mclms_coeffs_cur));
592 memset(
s->mclms_prevvalues, 0,
sizeof(
s->mclms_prevvalues));
593 memset(
s->mclms_updates, 0,
sizeof(
s->mclms_updates));
595 for (ich = 0; ich <
s->num_channels; ich++) {
596 for (ilms = 0; ilms <
s->cdlms_ttl[ich]; ilms++) {
597 memset(
s->cdlms[ich][ilms].coefs, 0,
598 sizeof(
s->cdlms[ich][ilms].coefs));
599 memset(
s->cdlms[ich][ilms].lms_prevvalues, 0,
600 sizeof(
s->cdlms[ich][ilms].lms_prevvalues));
601 memset(
s->cdlms[ich][ilms].lms_updates, 0,
602 sizeof(
s->cdlms[ich][ilms].lms_updates));
614 s->mclms_recent =
s->mclms_order *
s->num_channels;
615 for (ich = 0; ich <
s->num_channels; ich++) {
616 for (ilms = 0; ilms <
s->cdlms_ttl[ich]; ilms++)
617 s->cdlms[ich][ilms].recent =
s->cdlms[ich][ilms].order;
620 s->channel[ich].transient_counter =
s->samples_per_frame;
621 s->transient[ich] = 1;
622 s->transient_pos[ich] = 0;
628 int i, j, ich, pred_error;
629 int order =
s->mclms_order;
630 int num_channels =
s->num_channels;
631 int range = 1 << (
s->bits_per_sample - 1);
633 for (ich = 0; ich < num_channels; ich++) {
634 pred_error =
s->channel_residues[ich][icoef] - (unsigned)
pred[ich];
635 if (pred_error > 0) {
636 for (
i = 0;
i < order * num_channels;
i++)
637 s->mclms_coeffs[
i + ich * order * num_channels] +=
638 s->mclms_updates[
s->mclms_recent +
i];
639 for (j = 0; j < ich; j++)
640 s->mclms_coeffs_cur[ich * num_channels + j] +=
WMASIGN(
s->channel_residues[j][icoef]);
641 }
else if (pred_error < 0) {
642 for (
i = 0;
i < order * num_channels;
i++)
643 s->mclms_coeffs[
i + ich * order * num_channels] -=
644 s->mclms_updates[
s->mclms_recent +
i];
645 for (j = 0; j < ich; j++)
646 s->mclms_coeffs_cur[ich * num_channels + j] -=
WMASIGN(
s->channel_residues[j][icoef]);
650 for (ich = num_channels - 1; ich >= 0; ich--) {
652 s->mclms_prevvalues[
s->mclms_recent] =
av_clip(
s->channel_residues[ich][icoef],
654 s->mclms_updates[
s->mclms_recent] =
WMASIGN(
s->channel_residues[ich][icoef]);
657 if (
s->mclms_recent == 0) {
658 memcpy(&
s->mclms_prevvalues[order * num_channels],
660 sizeof(
int32_t) * order * num_channels);
661 memcpy(&
s->mclms_updates[order * num_channels],
663 sizeof(
int32_t) * order * num_channels);
664 s->mclms_recent = num_channels * order;
671 int order =
s->mclms_order;
672 int num_channels =
s->num_channels;
674 for (ich = 0; ich < num_channels; ich++) {
676 if (!
s->is_channel_coded[ich])
678 for (
i = 0;
i < order * num_channels;
i++)
679 pred[ich] += (uint32_t)
s->mclms_prevvalues[
i +
s->mclms_recent] *
680 s->mclms_coeffs[
i + order * num_channels * ich];
681 for (
i = 0;
i < ich;
i++)
682 pred[ich] += (uint32_t)
s->channel_residues[
i][icoef] *
683 s->mclms_coeffs_cur[
i + num_channels * ich];
684 pred[ich] += (1
U <<
s->mclms_scaling) >> 1;
685 pred[ich] >>=
s->mclms_scaling;
686 s->channel_residues[ich][icoef] += (unsigned)
pred[ich];
693 for (icoef = 0; icoef < tile_size; icoef++) {
701 int ilms, recent, icoef;
702 for (ilms =
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
703 recent =
s->cdlms[ich][ilms].recent;
704 if (
s->update_speed[ich] == 16)
707 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
708 s->cdlms[ich][ilms].lms_updates[icoef + recent] *= 2;
710 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
711 s->cdlms[ich][ilms].lms_updates[icoef] *= 2;
714 s->update_speed[ich] = 16;
719 int ilms, recent, icoef;
720 for (ilms =
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
721 recent =
s->cdlms[ich][ilms].recent;
722 if (
s->update_speed[ich] == 8)
725 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
726 s->cdlms[ich][ilms].lms_updates[icoef + recent] /= 2;
728 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
729 s->cdlms[ich][ilms].lms_updates[icoef] /= 2;
731 s->update_speed[ich] = 8;
734 #define CD_LMS(bits, ROUND) \
735 static void lms_update ## bits (WmallDecodeCtx *s, int ich, int ilms, int input) \
737 int recent = s->cdlms[ich][ilms].recent; \
738 int range = 1 << s->bits_per_sample - 1; \
739 int order = s->cdlms[ich][ilms].order; \
740 int ##bits##_t *prev = (int##bits##_t *)s->cdlms[ich][ilms].lms_prevvalues; \
745 memcpy(prev + order, prev, (bits/8) * order); \
746 memcpy(s->cdlms[ich][ilms].lms_updates + order, \
747 s->cdlms[ich][ilms].lms_updates, \
748 sizeof(*s->cdlms[ich][ilms].lms_updates) * order); \
749 recent = order - 1; \
752 prev[recent] = av_clip(input, -range, range - 1); \
753 s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich]; \
755 s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2; \
756 s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1; \
757 s->cdlms[ich][ilms].recent = recent; \
758 memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0, \
759 sizeof(s->cdlms[ich][ilms].lms_updates) - \
760 sizeof(*s->cdlms[ich][ilms].lms_updates)*(recent+order)); \
763 static void revert_cdlms ## bits (WmallDecodeCtx *s, int ch, \
764 int coef_begin, int coef_end) \
766 int icoef, ilms, num_lms, residue, input; \
769 num_lms = s->cdlms_ttl[ch]; \
770 for (ilms = num_lms - 1; ilms >= 0; ilms--) { \
771 for (icoef = coef_begin; icoef < coef_end; icoef++) { \
772 int##bits##_t *prevvalues = (int##bits##_t *)s->cdlms[ch][ilms].lms_prevvalues; \
773 pred = (1 << s->cdlms[ch][ilms].scaling) >> 1; \
774 residue = s->channel_residues[ch][icoef]; \
775 pred += s->dsp.scalarproduct_and_madd_int## bits (s->cdlms[ch][ilms].coefs, \
776 prevvalues + s->cdlms[ch][ilms].recent, \
777 s->cdlms[ch][ilms].lms_updates + \
778 s->cdlms[ch][ilms].recent, \
779 FFALIGN(s->cdlms[ch][ilms].order, ROUND), \
781 input = residue + (unsigned)((int)pred >> s->cdlms[ch][ilms].scaling); \
782 lms_update ## bits(s, ch, ilms, input); \
783 s->channel_residues[ch][icoef] = input; \
793 if (
s->num_channels != 2)
795 else if (
s->is_channel_coded[0] ||
s->is_channel_coded[1]) {
797 for (icoef = 0; icoef < tile_size; icoef++) {
798 s->channel_residues[0][icoef] -= (unsigned)(
s->channel_residues[1][icoef] >> 1);
799 s->channel_residues[1][icoef] += (unsigned)
s->channel_residues[0][icoef];
807 int16_t *filter_coeffs =
s->acfilter_coeffs;
808 int scaling =
s->acfilter_scaling;
809 int order =
s->acfilter_order;
811 for (ich = 0; ich <
s->num_channels; ich++) {
812 int *prevvalues =
s->acfilter_prevvalues[ich];
813 for (
i = 0;
i < order;
i++) {
815 for (j = 0; j < order; j++) {
817 pred += (uint32_t)filter_coeffs[j] * prevvalues[j -
i];
819 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
822 s->channel_residues[ich][
i] += (unsigned)
pred;
824 for (
i = order;
i < tile_size;
i++) {
826 for (j = 0; j < order; j++)
827 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
829 s->channel_residues[ich][
i] += (unsigned)
pred;
831 for (j = order - 1; j >= 0; j--)
832 if (tile_size <= j) {
833 prevvalues[j] = prevvalues[j - tile_size];
835 prevvalues[j] =
s->channel_residues[ich][tile_size - j - 1];
841 int offset =
s->samples_per_frame;
842 int subframe_len =
s->samples_per_frame;
843 int total_samples =
s->samples_per_frame *
s->num_channels;
844 int i, j, rawpcm_tile, padding_zeroes, res;
851 for (
i = 0;
i <
s->num_channels;
i++) {
852 if (
offset >
s->channel[
i].decoded_samples) {
853 offset =
s->channel[
i].decoded_samples;
855 s->channel[
i].subframe_len[
s->channel[
i].cur_subframe];
860 s->channels_for_cur_subframe = 0;
861 for (
i = 0;
i <
s->num_channels;
i++) {
862 const int cur_subframe =
s->channel[
i].cur_subframe;
864 total_samples -=
s->channel[
i].decoded_samples;
867 if (
offset ==
s->channel[
i].decoded_samples &&
868 subframe_len ==
s->channel[
i].subframe_len[cur_subframe]) {
869 total_samples -=
s->channel[
i].subframe_len[cur_subframe];
870 s->channel[
i].decoded_samples +=
871 s->channel[
i].subframe_len[cur_subframe];
872 s->channel_indexes_for_cur_subframe[
s->channels_for_cur_subframe] =
i;
873 ++
s->channels_for_cur_subframe;
880 s->parsed_all_subframes = 1;
884 if (
s->seekable_tile) {
888 if (
s->do_arith_coding) {
912 if (!rawpcm_tile && !
s->cdlms[0][0].order) {
914 "Waiting for seekable tile\n");
920 for (
i = 0;
i <
s->num_channels;
i++)
921 s->is_channel_coded[
i] = 1;
924 for (
i = 0;
i <
s->num_channels;
i++)
933 "inverse LPC filter");
948 int bits =
s->bits_per_sample - padding_zeroes;
951 "Invalid number of padding bits in raw PCM tile\n");
954 ff_dlog(
s->avctx,
"RAWPCM %d bits per sample. "
955 "total %d bits, remain=%d\n",
bits,
957 for (
i = 0;
i <
s->num_channels;
i++)
958 for (j = 0; j < subframe_len; j++)
961 if (
s->bits_per_sample < padding_zeroes)
963 for (
i = 0;
i <
s->num_channels;
i++) {
964 if (
s->is_channel_coded[
i]) {
966 if (
s->seekable_tile)
970 if (
s->bits_per_sample > 16)
971 revert_cdlms32(
s,
i, 0, subframe_len);
973 revert_cdlms16(
s,
i, 0, subframe_len);
975 memset(
s->channel_residues[
i], 0,
sizeof(**
s->channel_residues) * subframe_len);
981 if (
s->do_inter_ch_decorr)
987 if (
s->quant_stepsize != 1)
988 for (
i = 0;
i <
s->num_channels;
i++)
989 for (j = 0; j < subframe_len; j++)
990 s->channel_residues[
i][j] *= (
unsigned)
s->quant_stepsize;
994 for (
i = 0;
i <
s->channels_for_cur_subframe;
i++) {
995 int c =
s->channel_indexes_for_cur_subframe[
i];
996 int subframe_len =
s->channel[
c].subframe_len[
s->channel[
c].cur_subframe];
998 for (j = 0; j < subframe_len; j++) {
999 if (
s->bits_per_sample == 16) {
1000 *
s->samples_16[
c]++ = (int16_t)
s->channel_residues[
c][j] * (1 << padding_zeroes);
1002 *
s->samples_32[
c]++ =
s->channel_residues[
c][j] * (256
U << padding_zeroes);
1008 for (
i = 0;
i <
s->channels_for_cur_subframe;
i++) {
1009 int c =
s->channel_indexes_for_cur_subframe[
i];
1010 if (
s->channel[
c].cur_subframe >=
s->channel[
c].num_subframes) {
1014 ++
s->channel[
c].cur_subframe;
1028 int more_frames = 0,
len = 0,
i,
ret;
1030 s->frame->nb_samples =
s->samples_per_frame;
1034 s->frame->nb_samples = 0;
1037 for (
i = 0;
i <
s->num_channels;
i++) {
1038 s->samples_16[
i] = (int16_t *)
s->frame->extended_data[
i];
1039 s->samples_32[
i] = (
int32_t *)
s->frame->extended_data[
i];
1054 if (
s->dynamic_range_compression)
1072 s->frame->nb_samples -=
skip;
1073 if (
s->frame->nb_samples <= 0)
1080 s->parsed_all_subframes = 0;
1081 for (
i = 0;
i <
s->num_channels;
i++) {
1082 s->channel[
i].decoded_samples = 0;
1083 s->channel[
i].cur_subframe = 0;
1087 while (!
s->parsed_all_subframes) {
1088 int decoded_samples =
s->channel[0].decoded_samples;
1091 if (
s->frame->nb_samples)
1092 s->frame->nb_samples = decoded_samples;
1101 if (
s->len_prefix) {
1105 "frame[%"PRIu32
"] would have to skip %i bits\n",
1152 s->num_saved_bits =
s->frame_offset;
1156 buflen = (
s->num_saved_bits +
len + 8) >> 3;
1158 if (len <= 0 || buflen >
s->max_frame_size) {
1161 s->num_saved_bits = 0;
1165 s->num_saved_bits +=
len;
1186 int *got_frame_ptr,
AVPacket* avpkt)
1190 const uint8_t* buf = avpkt->
data;
1191 int buf_size = avpkt->
size;
1192 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1194 s->frame->nb_samples = 0;
1201 s->num_saved_bits = 0;
1202 }
else if (
s->packet_done ||
s->packet_loss) {
1207 s->buf_bit_size = buf_size << 3;
1211 packet_sequence_number =
get_bits(gb, 4);
1218 num_bits_prev_frame =
get_bits(gb,
s->log2_frame_size);
1221 if (!
s->packet_loss &&
1222 ((
s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
1225 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1226 s->packet_sequence_number, packet_sequence_number);
1228 s->packet_sequence_number = packet_sequence_number;
1230 if (num_bits_prev_frame > 0) {
1232 if (num_bits_prev_frame >= remaining_packet_bits) {
1233 num_bits_prev_frame = remaining_packet_bits;
1242 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1244 }
else if (
s->num_saved_bits -
s->frame_offset) {
1245 ff_dlog(avctx,
"ignoring %x previously saved bits\n",
1246 s->num_saved_bits -
s->frame_offset);
1249 if (
s->packet_loss) {
1252 s->num_saved_bits = 0;
1260 s->buf_bit_size = (avpkt->
size -
s->next_packet_start) << 3;
1269 if (!
s->packet_loss)
1271 }
else if (!
s->len_prefix
1290 if (
s->packet_done && !
s->packet_loss &&
1297 *got_frame_ptr =
s->frame->nb_samples > 0;
1310 s->num_saved_bits = 0;
1311 s->frame_offset = 0;
1312 s->next_packet_start = 0;
1313 s->cdlms[0][0].order = 0;
1314 s->frame->nb_samples = 0;
1329 .
p.
name =
"wmalossless",
1339 #if FF_API_SUBFRAMES
1340 AV_CODEC_CAP_SUBFRAMES |
#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)
#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 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
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
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 uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
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
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
int8_t channel_indexes_for_cur_subframe[WMALL_MAX_CHANNELS]
static int decode_cdlms(WmallDecodeCtx *s)
static av_cold int decode_close(AVCodecContext *avctx)
const FFCodec ff_wmalossless_decoder
static void mclms_predict(WmallDecodeCtx *s, int icoef, int *pred)
int update_speed[WMALL_MAX_CHANNELS]
int nb_channels
Number of channels in this layout.
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
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
static void clear_codec_buffers(WmallDecodeCtx *s)
AVCodec p
The public AVCodec.
int max_frame_size
max bitstream size
AVChannelLayout ch_layout
Audio channel layout.
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
#define FF_CODEC_DECODE_CB(func)
struct WmallDecodeCtx::@295 cdlms[WMALL_MAX_CHANNELS][9]
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)]
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#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]
#define CODEC_LONG_NAME(str)
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
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.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define DECLARE_ALIGNED(n, t, v)
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)
static const uint8_t *BS_FUNC() align(BSCTX *bc)
Skip bits to a byte boundary.
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
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.
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)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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.
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.
static int decode_packet(AVCodecContext *avctx, AVFrame *rframe, int *got_frame_ptr, AVPacket *avpkt)
#define WMASIGN(x)
Get sign of integer (1 for positive, -1 for negative and 0 for zero)
#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
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
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?