40 #define WMALL_MAX_CHANNELS 8
41 #define MAX_SUBFRAMES 32
43 #define MAX_FRAMESIZE 32768
46 #define WMALL_BLOCK_MIN_BITS 6
47 #define WMALL_BLOCK_MAX_BITS 14
48 #define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS)
49 #define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1)
51 #define WMALL_COEFF_PAD_SIZE 16
179 #define WMASIGN(x) (((x) > 0) - ((x) < 0))
185 unsigned int channel_mask;
186 int i, log2_max_num_subframes;
210 s->decode_flags =
AV_RL16(edata_ptr + 14);
211 channel_mask =
AV_RL32(edata_ptr + 2);
212 s->bits_per_sample =
AV_RL16(edata_ptr);
213 if (
s->bits_per_sample == 16)
215 else if (
s->bits_per_sample == 24) {
239 s->len_prefix =
s->decode_flags & 0x40;
248 s->channel[
i].prev_block_len =
s->samples_per_frame;
251 log2_max_num_subframes = (
s->decode_flags & 0x38) >> 3;
252 s->max_num_subframes = 1 << log2_max_num_subframes;
253 s->max_subframe_len_bit = 0;
254 s->subframe_len_bits =
av_log2(log2_max_num_subframes) + 1;
256 s->min_samples_per_subframe =
s->samples_per_frame /
s->max_num_subframes;
257 s->dynamic_range_compression =
s->decode_flags & 0x80;
258 s->bV3RTM =
s->decode_flags & 0x100;
262 s->max_num_subframes);
271 if (channel_mask & 8) {
274 if (channel_mask &
mask)
294 int frame_len_ratio, subframe_len,
len;
297 if (
offset ==
s->samples_per_frame -
s->min_samples_per_subframe)
298 return s->min_samples_per_subframe;
302 subframe_len =
s->min_samples_per_subframe * (frame_len_ratio + 1);
305 if (subframe_len < s->min_samples_per_subframe ||
306 subframe_len >
s->samples_per_frame) {
338 int channels_for_cur_subframe =
s->num_channels;
339 int fixed_channel_layout = 0;
340 int min_channel_len = 0;
344 for (
c = 0;
c <
s->num_channels;
c++)
345 s->channel[
c].num_subframes = 0;
348 if (
s->max_num_subframes == 1 || tile_aligned)
349 fixed_channel_layout = 1;
353 int subframe_len, in_use = 0;
356 for (
c = 0;
c <
s->num_channels;
c++) {
357 if (num_samples[
c] == min_channel_len) {
358 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
359 (min_channel_len ==
s->samples_per_frame -
s->min_samples_per_subframe)) {
360 contains_subframe[
c] = 1;
364 in_use |= contains_subframe[
c];
366 contains_subframe[
c] = 0;
371 "Found empty subframe\n");
379 min_channel_len += subframe_len;
380 for (
c = 0;
c <
s->num_channels;
c++) {
383 if (contains_subframe[
c]) {
386 "broken frame: num subframes > 31\n");
390 num_samples[
c] += subframe_len;
392 if (num_samples[
c] >
s->samples_per_frame) {
394 "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
395 num_samples[
c],
s->samples_per_frame);
398 }
else if (num_samples[
c] <= min_channel_len) {
399 if (num_samples[
c] < min_channel_len) {
400 channels_for_cur_subframe = 0;
401 min_channel_len = num_samples[
c];
403 ++channels_for_cur_subframe;
406 }
while (min_channel_len < s->samples_per_frame);
408 for (
c = 0;
c <
s->num_channels;
c++) {
410 for (
i = 0;
i <
s->channel[
c].num_subframes;
i++) {
411 s->channel[
c].subframe_offsets[
i] =
offset;
425 for (
i = 0;
i <
s->acfilter_order;
i++)
426 s->acfilter_coeffs[
i] =
get_bitsz(&
s->gb,
s->acfilter_scaling) + 1;
431 s->mclms_order = (
get_bits(&
s->gb, 4) + 1) * 2;
434 int i, send_coef_bits;
435 int cbits =
av_log2(
s->mclms_scaling + 1);
436 if (1 << cbits < s->mclms_scaling + 1)
439 send_coef_bits =
get_bitsz(&
s->gb, cbits) + 2;
441 for (
i = 0;
i <
s->mclms_order *
s->num_channels *
s->num_channels;
i++)
442 s->mclms_coeffs[
i] =
get_bits(&
s->gb, send_coef_bits);
444 for (
i = 0;
i <
s->num_channels;
i++) {
446 for (
c = 0;
c <
i;
c++)
447 s->mclms_coeffs_cur[
i *
s->num_channels +
c] =
get_bits(&
s->gb, send_coef_bits);
457 for (
c = 0;
c <
s->num_channels;
c++) {
459 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++) {
463 "Order[%d][%d] %d > max (%d), not supported\n",
465 s->cdlms[0][0].order = 0;
468 if(
s->cdlms[
c][
i].order & 8 &&
s->bits_per_sample == 16) {
472 s->cdlms[
c][
i].order);
477 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++)
480 if (cdlms_send_coef) {
481 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++) {
482 int cbits, shift_l, shift_r, j;
484 if ((1 << cbits) <
s->cdlms[
c][
i].order)
489 if ((1 << cbits) <
s->cdlms[
c][
i].scaling + 1)
493 shift_l = 32 -
s->cdlms[
c][
i].bitsend;
494 shift_r = 32 -
s->cdlms[
c][
i].scaling - 2;
495 for (j = 0; j <
s->cdlms[
c][
i].coefsend; j++)
496 s->cdlms[
c][
i].coefs[j] =
497 (
get_bits(&
s->gb,
s->cdlms[
c][
i].bitsend) << shift_l) >> shift_r;
501 for (
i = 0;
i <
s->cdlms_ttl[
c];
i++)
502 memset(
s->cdlms[
c][
i].coefs +
s->cdlms[
c][
i].order,
512 unsigned int ave_mean;
514 if (
s->transient[ch]) {
516 if (
s->transient_pos[ch])
517 s->transient[ch] = 0;
518 s->channel[ch].transient_counter =
519 FFMAX(
s->channel[ch].transient_counter,
s->samples_per_frame / 2);
520 }
else if (
s->channel[ch].transient_counter)
521 s->transient[ch] = 1;
523 if (
s->seekable_tile) {
524 ave_mean =
get_bits(&
s->gb,
s->bits_per_sample);
525 s->ave_sum[ch] = ave_mean << (
s->movave_scaling + 1);
528 if (
s->seekable_tile) {
529 if (
s->do_inter_ch_decorr)
535 for (;
i < tile_size;
i++) {
537 unsigned quo = 0, residue;
546 ave_mean = (
s->ave_sum[ch] + (1 <<
s->movave_scaling)) >> (
s->movave_scaling + 1);
552 residue = (quo << rem_bits) + rem;
555 s->ave_sum[ch] = residue +
s->ave_sum[ch] -
556 (
s->ave_sum[ch] >>
s->movave_scaling);
558 residue = (residue >> 1) ^ -(residue & 1);
559 s->channel_residues[ch][
i] = residue;
572 cbits =
s->lpc_scaling +
s->lpc_intbits;
573 for (ch = 0; ch <
s->num_channels; ch++)
574 for (
i = 0;
i <
s->lpc_order;
i++)
582 memset(
s->acfilter_coeffs, 0,
sizeof(
s->acfilter_coeffs));
583 memset(
s->acfilter_prevvalues, 0,
sizeof(
s->acfilter_prevvalues));
584 memset(
s->lpc_coefs, 0,
sizeof(
s->lpc_coefs));
586 memset(
s->mclms_coeffs, 0,
sizeof(
s->mclms_coeffs));
587 memset(
s->mclms_coeffs_cur, 0,
sizeof(
s->mclms_coeffs_cur));
588 memset(
s->mclms_prevvalues, 0,
sizeof(
s->mclms_prevvalues));
589 memset(
s->mclms_updates, 0,
sizeof(
s->mclms_updates));
591 for (ich = 0; ich <
s->num_channels; ich++) {
592 for (ilms = 0; ilms <
s->cdlms_ttl[ich]; ilms++) {
593 memset(
s->cdlms[ich][ilms].coefs, 0,
594 sizeof(
s->cdlms[ich][ilms].coefs));
595 memset(
s->cdlms[ich][ilms].lms_prevvalues, 0,
596 sizeof(
s->cdlms[ich][ilms].lms_prevvalues));
597 memset(
s->cdlms[ich][ilms].lms_updates, 0,
598 sizeof(
s->cdlms[ich][ilms].lms_updates));
610 s->mclms_recent =
s->mclms_order *
s->num_channels;
611 for (ich = 0; ich <
s->num_channels; ich++) {
612 for (ilms = 0; ilms <
s->cdlms_ttl[ich]; ilms++)
613 s->cdlms[ich][ilms].recent =
s->cdlms[ich][ilms].order;
616 s->channel[ich].transient_counter =
s->samples_per_frame;
617 s->transient[ich] = 1;
618 s->transient_pos[ich] = 0;
624 int i, j, ich, pred_error;
625 int order =
s->mclms_order;
626 int num_channels =
s->num_channels;
627 int range = 1 << (
s->bits_per_sample - 1);
629 for (ich = 0; ich < num_channels; ich++) {
630 pred_error =
s->channel_residues[ich][icoef] - (unsigned)
pred[ich];
631 if (pred_error > 0) {
632 for (
i = 0;
i < order * num_channels;
i++)
633 s->mclms_coeffs[
i + ich * order * num_channels] +=
634 s->mclms_updates[
s->mclms_recent +
i];
635 for (j = 0; j < ich; j++)
636 s->mclms_coeffs_cur[ich * num_channels + j] +=
WMASIGN(
s->channel_residues[j][icoef]);
637 }
else if (pred_error < 0) {
638 for (
i = 0;
i < order * num_channels;
i++)
639 s->mclms_coeffs[
i + ich * order * num_channels] -=
640 s->mclms_updates[
s->mclms_recent +
i];
641 for (j = 0; j < ich; j++)
642 s->mclms_coeffs_cur[ich * num_channels + j] -=
WMASIGN(
s->channel_residues[j][icoef]);
646 for (ich = num_channels - 1; ich >= 0; ich--) {
648 s->mclms_prevvalues[
s->mclms_recent] =
av_clip(
s->channel_residues[ich][icoef],
650 s->mclms_updates[
s->mclms_recent] =
WMASIGN(
s->channel_residues[ich][icoef]);
653 if (
s->mclms_recent == 0) {
654 memcpy(&
s->mclms_prevvalues[order * num_channels],
656 sizeof(
int32_t) * order * num_channels);
657 memcpy(&
s->mclms_updates[order * num_channels],
659 sizeof(
int32_t) * order * num_channels);
660 s->mclms_recent = num_channels * order;
667 int order =
s->mclms_order;
668 int num_channels =
s->num_channels;
670 for (ich = 0; ich < num_channels; ich++) {
672 if (!
s->is_channel_coded[ich])
674 for (
i = 0;
i < order * num_channels;
i++)
675 pred[ich] += (uint32_t)
s->mclms_prevvalues[
i +
s->mclms_recent] *
676 s->mclms_coeffs[
i + order * num_channels * ich];
677 for (
i = 0;
i < ich;
i++)
678 pred[ich] += (uint32_t)
s->channel_residues[
i][icoef] *
679 s->mclms_coeffs_cur[
i + num_channels * ich];
680 pred[ich] += (1U <<
s->mclms_scaling) >> 1;
681 pred[ich] >>=
s->mclms_scaling;
682 s->channel_residues[ich][icoef] += (unsigned)
pred[ich];
689 for (icoef = 0; icoef < tile_size; icoef++) {
697 int ilms, recent, icoef;
698 for (ilms =
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
699 recent =
s->cdlms[ich][ilms].recent;
700 if (
s->update_speed[ich] == 16)
703 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
704 s->cdlms[ich][ilms].lms_updates[icoef + recent] *= 2;
706 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
707 s->cdlms[ich][ilms].lms_updates[icoef] *= 2;
710 s->update_speed[ich] = 16;
715 int ilms, recent, icoef;
716 for (ilms =
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
717 recent =
s->cdlms[ich][ilms].recent;
718 if (
s->update_speed[ich] == 8)
721 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
722 s->cdlms[ich][ilms].lms_updates[icoef + recent] /= 2;
724 for (icoef = 0; icoef <
s->cdlms[ich][ilms].order; icoef++)
725 s->cdlms[ich][ilms].lms_updates[icoef] /= 2;
727 s->update_speed[ich] = 8;
730 #define CD_LMS(bits, ROUND) \
731 static void lms_update ## bits (WmallDecodeCtx *s, int ich, int ilms, int input) \
733 int recent = s->cdlms[ich][ilms].recent; \
734 int range = 1 << s->bits_per_sample - 1; \
735 int order = s->cdlms[ich][ilms].order; \
736 int ##bits##_t *prev = (int##bits##_t *)s->cdlms[ich][ilms].lms_prevvalues; \
741 memcpy(prev + order, prev, (bits/8) * order); \
742 memcpy(s->cdlms[ich][ilms].lms_updates + order, \
743 s->cdlms[ich][ilms].lms_updates, \
744 sizeof(*s->cdlms[ich][ilms].lms_updates) * order); \
745 recent = order - 1; \
748 prev[recent] = av_clip(input, -range, range - 1); \
749 s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich]; \
751 s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2; \
752 s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1; \
753 s->cdlms[ich][ilms].recent = recent; \
754 memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0, \
755 sizeof(s->cdlms[ich][ilms].lms_updates) - \
756 sizeof(*s->cdlms[ich][ilms].lms_updates)*(recent+order)); \
759 static void revert_cdlms ## bits (WmallDecodeCtx *s, int ch, \
760 int coef_begin, int coef_end) \
762 int icoef, ilms, num_lms, residue, input; \
765 num_lms = s->cdlms_ttl[ch]; \
766 for (ilms = num_lms - 1; ilms >= 0; ilms--) { \
767 for (icoef = coef_begin; icoef < coef_end; icoef++) { \
768 int##bits##_t *prevvalues = (int##bits##_t *)s->cdlms[ch][ilms].lms_prevvalues; \
769 pred = (1 << s->cdlms[ch][ilms].scaling) >> 1; \
770 residue = s->channel_residues[ch][icoef]; \
771 pred += s->dsp.scalarproduct_and_madd_int## bits (s->cdlms[ch][ilms].coefs, \
772 prevvalues + s->cdlms[ch][ilms].recent, \
773 s->cdlms[ch][ilms].lms_updates + \
774 s->cdlms[ch][ilms].recent, \
775 FFALIGN(s->cdlms[ch][ilms].order, ROUND), \
777 input = residue + (unsigned)((int)pred >> s->cdlms[ch][ilms].scaling); \
778 lms_update ## bits(s, ch, ilms, input); \
779 s->channel_residues[ch][icoef] = input; \
782 if (bits <= 16) emms_c(); \
790 if (
s->num_channels != 2)
792 else if (
s->is_channel_coded[0] ||
s->is_channel_coded[1]) {
794 for (icoef = 0; icoef < tile_size; icoef++) {
795 s->channel_residues[0][icoef] -= (unsigned)(
s->channel_residues[1][icoef] >> 1);
796 s->channel_residues[1][icoef] += (unsigned)
s->channel_residues[0][icoef];
804 int16_t *filter_coeffs =
s->acfilter_coeffs;
805 int scaling =
s->acfilter_scaling;
806 int order =
s->acfilter_order;
808 for (ich = 0; ich <
s->num_channels; ich++) {
809 int *prevvalues =
s->acfilter_prevvalues[ich];
810 for (
i = 0;
i < order;
i++) {
812 for (j = 0; j < order; j++) {
814 pred += (uint32_t)filter_coeffs[j] * prevvalues[j -
i];
816 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
819 s->channel_residues[ich][
i] += (unsigned)
pred;
821 for (
i = order;
i < tile_size;
i++) {
823 for (j = 0; j < order; j++)
824 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
826 s->channel_residues[ich][
i] += (unsigned)
pred;
828 for (j = order - 1; j >= 0; j--)
829 if (tile_size <= j) {
830 prevvalues[j] = prevvalues[j - tile_size];
832 prevvalues[j] =
s->channel_residues[ich][tile_size - j - 1];
838 int offset =
s->samples_per_frame;
839 int subframe_len =
s->samples_per_frame;
840 int total_samples =
s->samples_per_frame *
s->num_channels;
841 int i, j, rawpcm_tile, padding_zeroes, res;
848 for (
i = 0;
i <
s->num_channels;
i++) {
849 if (
offset >
s->channel[
i].decoded_samples) {
850 offset =
s->channel[
i].decoded_samples;
852 s->channel[
i].subframe_len[
s->channel[
i].cur_subframe];
857 s->channels_for_cur_subframe = 0;
858 for (
i = 0;
i <
s->num_channels;
i++) {
859 const int cur_subframe =
s->channel[
i].cur_subframe;
861 total_samples -=
s->channel[
i].decoded_samples;
864 if (
offset ==
s->channel[
i].decoded_samples &&
865 subframe_len ==
s->channel[
i].subframe_len[cur_subframe]) {
866 total_samples -=
s->channel[
i].subframe_len[cur_subframe];
867 s->channel[
i].decoded_samples +=
868 s->channel[
i].subframe_len[cur_subframe];
869 s->channel_indexes_for_cur_subframe[
s->channels_for_cur_subframe] =
i;
870 ++
s->channels_for_cur_subframe;
877 s->parsed_all_subframes = 1;
881 if (
s->seekable_tile) {
885 if (
s->do_arith_coding) {
909 if (!rawpcm_tile && !
s->cdlms[0][0].order) {
911 "Waiting for seekable tile\n");
917 for (
i = 0;
i <
s->num_channels;
i++)
918 s->is_channel_coded[
i] = 1;
921 for (
i = 0;
i <
s->num_channels;
i++)
930 "inverse LPC filter");
945 int bits =
s->bits_per_sample - padding_zeroes;
948 "Invalid number of padding bits in raw PCM tile\n");
951 ff_dlog(
s->avctx,
"RAWPCM %d bits per sample. "
952 "total %d bits, remain=%d\n",
bits,
954 for (
i = 0;
i <
s->num_channels;
i++)
955 for (j = 0; j < subframe_len; j++)
958 if (
s->bits_per_sample < padding_zeroes)
960 for (
i = 0;
i <
s->num_channels;
i++) {
961 if (
s->is_channel_coded[
i]) {
963 if (
s->seekable_tile)
967 if (
s->bits_per_sample > 16)
968 revert_cdlms32(
s,
i, 0, subframe_len);
970 revert_cdlms16(
s,
i, 0, subframe_len);
972 memset(
s->channel_residues[
i], 0,
sizeof(**
s->channel_residues) * subframe_len);
978 if (
s->do_inter_ch_decorr)
984 if (
s->quant_stepsize != 1)
985 for (
i = 0;
i <
s->num_channels;
i++)
986 for (j = 0; j < subframe_len; j++)
987 s->channel_residues[
i][j] *= (
unsigned)
s->quant_stepsize;
991 for (
i = 0;
i <
s->channels_for_cur_subframe;
i++) {
992 int c =
s->channel_indexes_for_cur_subframe[
i];
993 int subframe_len =
s->channel[
c].subframe_len[
s->channel[
c].cur_subframe];
995 for (j = 0; j < subframe_len; j++) {
996 if (
s->bits_per_sample == 16) {
997 *
s->samples_16[
c]++ = (int16_t)
s->channel_residues[
c][j] * (1 << padding_zeroes);
999 *
s->samples_32[
c]++ =
s->channel_residues[
c][j] * (256U << padding_zeroes);
1005 for (
i = 0;
i <
s->channels_for_cur_subframe;
i++) {
1006 int c =
s->channel_indexes_for_cur_subframe[
i];
1007 if (
s->channel[
c].cur_subframe >=
s->channel[
c].num_subframes) {
1011 ++
s->channel[
c].cur_subframe;
1025 int more_frames = 0,
len = 0,
i, ret;
1027 s->frame->nb_samples =
s->samples_per_frame;
1031 s->frame->nb_samples = 0;
1034 for (
i = 0;
i <
s->num_channels;
i++) {
1035 s->samples_16[
i] = (int16_t *)
s->frame->extended_data[
i];
1036 s->samples_32[
i] = (
int32_t *)
s->frame->extended_data[
i];
1051 if (
s->dynamic_range_compression)
1062 ff_dlog(
s->avctx,
"start skip: %i\n", skip);
1068 ff_dlog(
s->avctx,
"end skip: %i\n", skip);
1069 s->frame->nb_samples -= skip;
1070 if (
s->frame->nb_samples <= 0)
1077 s->parsed_all_subframes = 0;
1078 for (
i = 0;
i <
s->num_channels;
i++) {
1079 s->channel[
i].decoded_samples = 0;
1080 s->channel[
i].cur_subframe = 0;
1084 while (!
s->parsed_all_subframes) {
1085 int decoded_samples =
s->channel[0].decoded_samples;
1088 if (
s->frame->nb_samples)
1089 s->frame->nb_samples = decoded_samples;
1098 if (
s->len_prefix) {
1102 "frame[%"PRIu32
"] would have to skip %i bits\n",
1149 s->num_saved_bits =
s->frame_offset;
1153 buflen = (
s->num_saved_bits +
len + 8) >> 3;
1155 if (len <= 0 || buflen >
s->max_frame_size) {
1158 s->num_saved_bits = 0;
1162 s->num_saved_bits +=
len;
1188 int buf_size = avpkt->
size;
1189 int num_bits_prev_frame, packet_sequence_number, spliced_packet;
1191 s->frame->nb_samples = 0;
1196 s->num_saved_bits = 0;
1197 }
else if (
s->packet_done ||
s->packet_loss) {
1205 s->buf_bit_size = buf_size << 3;
1209 packet_sequence_number =
get_bits(gb, 4);
1216 num_bits_prev_frame =
get_bits(gb,
s->log2_frame_size);
1219 if (!
s->packet_loss &&
1220 ((
s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
1223 "Packet loss detected! seq %"PRIx8
" vs %x\n",
1224 s->packet_sequence_number, packet_sequence_number);
1226 s->packet_sequence_number = packet_sequence_number;
1228 if (num_bits_prev_frame > 0) {
1230 if (num_bits_prev_frame >= remaining_packet_bits) {
1231 num_bits_prev_frame = remaining_packet_bits;
1240 if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
1242 }
else if (
s->num_saved_bits -
s->frame_offset) {
1243 ff_dlog(avctx,
"ignoring %x previously saved bits\n",
1244 s->num_saved_bits -
s->frame_offset);
1247 if (
s->packet_loss) {
1250 s->num_saved_bits = 0;
1258 s->buf_bit_size = (avpkt->
size -
s->next_packet_start) << 3;
1267 if (!
s->packet_loss)
1269 }
else if (!
s->len_prefix
1288 if (
s->packet_done && !
s->packet_loss &&
1295 *got_frame_ptr =
s->frame->nb_samples > 0;
1308 s->num_saved_bits = 0;
1309 s->frame_offset = 0;
1310 s->next_packet_start = 0;
1311 s->cdlms[0][0].order = 0;
1312 s->frame->nb_samples = 0;
1327 .
name =
"wmalossless",
static enum AVSampleFormat sample_fmts[]
Macro definitions for various function/variable attributes.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
channel
Use these values when setting the channel map with ebur128_set_channel().
bitstream reader API header.
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_sbits(GetBitContext *s, int n)
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
@ AV_CODEC_ID_WMALOSSLESS
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
av_cold void ff_llauddsp_init(LLAudDSPContext *c)
static const uint16_t mask[17]
static uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static const float pred[4]
main external API structure.
enum AVSampleFormat sample_fmt
audio sample format
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int sample_rate
samples per second
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int channels
number of audio channels
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
uint64_t channel_layout
Audio channel layout.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
frame-specific decoder context for a single channel
int16_t prev_block_len
length of the previous block
uint16_t decoded_samples
number of already processed samples
uint16_t subframe_offsets[MAX_SUBFRAMES]
subframe positions in the current frame
int quant_step
quantization step for the current subframe
uint8_t cur_subframe
current subframe number
int transient_counter
number of transient samples from the beginning of the transient zone
uint16_t subframe_len[MAX_SUBFRAMES]
subframe length in samples
LLAudDSPContext dsp
accelerated DSP functions
uint8_t packet_offset
offset to the frame in the packet
int acfilter_prevvalues[WMALL_MAX_CHANNELS][16]
uint8_t do_inter_ch_decorr
int8_t channel_indexes_for_cur_subframe[WMALL_MAX_CHANNELS]
uint8_t max_subframe_len_bit
flag indicating that the subframe is of maximum size when the first subframe length bit is 1
PutBitContext pb
context for filling the frame_data buffer
int dynamic_range_compression
frame contains DRC data
uint8_t subframe_len_bits
number of bits used for the subframe length
GetBitContext pgb
bitstream reader context for the packet
int lpc_coefs[WMALL_MAX_CHANNELS][40]
int len_prefix
frame is prefixed with its length
int num_saved_bits
saved number of bits
uint16_t min_samples_per_subframe
int next_packet_start
start offset of the next WMA packet in the demuxer packet
uint8_t bits_per_sample
integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1....
int subframe_offset
subframe offset in the bit reservoir
int32_t mclms_updates[WMALL_MAX_CHANNELS *2 *32]
uint8_t drc_gain
gain for the DRC tool
GetBitContext gb
bitstream reader context
uint8_t packet_loss
set in case of bitstream error
int32_t mclms_prevvalues[WMALL_MAX_CHANNELS *2 *32]
int16_t mclms_coeffs_cur[WMALL_MAX_CHANNELS *WMALL_MAX_CHANNELS]
int32_t * samples_32[WMALL_MAX_CHANNELS]
current sample buffer pointer (24-bit)
uint8_t packet_sequence_number
current packet number
uint8_t max_num_subframes
int16_t lms_updates[MAX_ORDER *2+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
int8_t channels_for_cur_subframe
number of channels that contain the subframe
int8_t lfe_channel
lfe channel index
int8_t num_channels
number of channels in the stream (same as AVCodecContext.num_channels)
int channel_residues[WMALL_MAX_CHANNELS][WMALL_BLOCK_MAX_SIZE]
uint8_t * frame_data
compressed frame data
int frame_offset
frame offset in the bit reservoir
int is_channel_coded[WMALL_MAX_CHANNELS]
int max_frame_size
max bitstream size
uint16_t samples_per_frame
number of samples to output
int8_t parsed_all_subframes
all subframes decoded?
int update_speed[WMALL_MAX_CHANNELS]
int16_t subframe_len
current subframe length
struct WmallDecodeCtx::@189 cdlms[WMALL_MAX_CHANNELS][9]
int16_t mclms_coeffs[WMALL_MAX_CHANNELS *WMALL_MAX_CHANNELS *32]
int16_t coefs[MAX_ORDER+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
int32_t lms_prevvalues[MAX_ORDER *2+WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]
uint8_t packet_done
set when a packet is fully decoded
uint32_t frame_num
current frame number (not used for decoding)
int16_t * samples_16[WMALL_MAX_CHANNELS]
current sample buffer pointer (16-bit)
int transient_pos[WMALL_MAX_CHANNELS]
int16_t acfilter_coeffs[16]
int cdlms_ttl[WMALL_MAX_CHANNELS]
int buf_bit_size
buffer size in bits
int8_t skip_frame
skip output step
uint32_t decode_flags
used compression features
unsigned ave_sum[WMALL_MAX_CHANNELS]
#define avpriv_request_sample(...)
static const uint8_t offset[127][2]
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 int decode_subframe(WmallDecodeCtx *s)
#define CD_LMS(bits, ROUND)
static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
static void clear_codec_buffers(WmallDecodeCtx *s)
static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
static void decode_ac_filter(WmallDecodeCtx *s)
static int decode_cdlms(WmallDecodeCtx *s)
#define WMALL_MAX_CHANNELS
current decoder limitations
static av_cold int decode_close(AVCodecContext *avctx)
static av_cold int decode_init(AVCodecContext *avctx)
static void save_bits(WmallDecodeCtx *s, GetBitContext *gb, int len, int append)
Fill the bit reservoir with a (partial) frame.
static void revert_acfilter(WmallDecodeCtx *s, int tile_size)
static void mclms_predict(WmallDecodeCtx *s, int icoef, int *pred)
#define WMALL_BLOCK_MAX_SIZE
maximum block size
static int decode_packet(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static int decode_subframe_length(WmallDecodeCtx *s, int offset)
Decode the subframe length.
#define MAX_SUBFRAMES
max number of subframes per channel
static int decode_frame(WmallDecodeCtx *s)
Decode one WMA frame.
static void decode_mclms(WmallDecodeCtx *s)
#define WMASIGN(x)
Get sign of integer (1 for positive, -1 for negative and 0 for zero)
static void use_high_update_speed(WmallDecodeCtx *s, int ich)
static void reset_codec(WmallDecodeCtx *s)
Reset filter parameters and transient area at new seekable tile.
static int remaining_bits(WmallDecodeCtx *s, GetBitContext *gb)
Calculate remaining input buffer length.
#define MAX_FRAMESIZE
maximum compressed frame size
#define WMALL_COEFF_PAD_SIZE
pad coef buffers with 0 for use with SIMD
AVCodec ff_wmalossless_decoder
static int decode_tilehdr(WmallDecodeCtx *s)
Decode how the data in the frame is split into subframes.
static void decode_lpc(WmallDecodeCtx *s)
static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
static void flush(AVCodecContext *avctx)
static void revert_inter_ch_decorr(WmallDecodeCtx *s, int tile_size)