Go to the documentation of this file.
   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;
 
  194         s->decode_flags    = 
AV_RL16(edata_ptr + 14);
 
  195         channel_mask       = 
AV_RL32(edata_ptr +  2);
 
  196         s->bits_per_sample = 
AV_RL16(edata_ptr);
 
  197         if (
s->bits_per_sample == 16)
 
  199         else if (
s->bits_per_sample == 24) {
 
  233     if (channel_mask & 8) {
 
  236             if (channel_mask & 
mask)
 
  255     s->len_prefix  = 
s->decode_flags & 0x40;
 
  264         s->channel[
i].prev_block_len = 
s->samples_per_frame;
 
  267     log2_max_num_subframes  = (
s->decode_flags & 0x38) >> 3;
 
  268     s->max_num_subframes    = 1 << log2_max_num_subframes;
 
  269     s->max_subframe_len_bit = 0;
 
  270     s->subframe_len_bits    = 
av_log2(log2_max_num_subframes) + 1;
 
  272     s->min_samples_per_subframe  = 
s->samples_per_frame / 
s->max_num_subframes;
 
  273     s->dynamic_range_compression = 
s->decode_flags & 0x80;
 
  274     s->bV3RTM                    = 
s->decode_flags & 0x100;
 
  278                s->max_num_subframes);
 
  297     int frame_len_ratio, subframe_len, 
len;
 
  300     if (
offset == 
s->samples_per_frame - 
s->min_samples_per_subframe)
 
  301         return s->min_samples_per_subframe;
 
  305     subframe_len    = 
s->min_samples_per_subframe * (frame_len_ratio + 1);
 
  308     if (subframe_len < s->min_samples_per_subframe ||
 
  309         subframe_len > 
s->samples_per_frame) {
 
  341     int channels_for_cur_subframe = 
s->num_channels;  
 
  342     int fixed_channel_layout = 0;                     
 
  343     int min_channel_len = 0;                          
 
  347     for (
c = 0; 
c < 
s->num_channels; 
c++)
 
  348         s->channel[
c].num_subframes = 0;
 
  351     if (
s->max_num_subframes == 1 || tile_aligned)
 
  352         fixed_channel_layout = 1;
 
  356         int subframe_len, in_use = 0;
 
  359         for (
c = 0; 
c < 
s->num_channels; 
c++) {
 
  360             if (num_samples[
c] == min_channel_len) {
 
  361                 if (fixed_channel_layout || channels_for_cur_subframe == 1 ||
 
  362                    (min_channel_len == 
s->samples_per_frame - 
s->min_samples_per_subframe)) {
 
  363                     contains_subframe[
c] = 1;
 
  367                 in_use |= contains_subframe[
c];
 
  369                 contains_subframe[
c] = 0;
 
  374                    "Found empty subframe\n");
 
  382         min_channel_len += subframe_len;
 
  383         for (
c = 0; 
c < 
s->num_channels; 
c++) {
 
  386             if (contains_subframe[
c]) {
 
  389                            "broken frame: num subframes > 31\n");
 
  393                 num_samples[
c] += subframe_len;
 
  395                 if (num_samples[
c] > 
s->samples_per_frame) {
 
  397                            "channel len(%"PRIu16
") > samples_per_frame(%"PRIu16
")\n",
 
  398                            num_samples[
c], 
s->samples_per_frame);
 
  401             } 
else if (num_samples[
c] <= min_channel_len) {
 
  402                 if (num_samples[
c] < min_channel_len) {
 
  403                     channels_for_cur_subframe = 0;
 
  404                     min_channel_len = num_samples[
c];
 
  406                 ++channels_for_cur_subframe;
 
  409     } 
while (min_channel_len < s->samples_per_frame);
 
  411     for (
c = 0; 
c < 
s->num_channels; 
c++) {
 
  413         for (
i = 0; 
i < 
s->channel[
c].num_subframes; 
i++) {
 
  414             s->channel[
c].subframe_offsets[
i] = 
offset;
 
  428     for (
i = 0; 
i < 
s->acfilter_order; 
i++)
 
  429         s->acfilter_coeffs[
i] = 
get_bitsz(&
s->gb, 
s->acfilter_scaling) + 1;
 
  434     s->mclms_order   = (
get_bits(&
s->gb, 4) + 1) * 2;
 
  437         int i, send_coef_bits;
 
  438         int cbits = 
av_log2(
s->mclms_scaling + 1);
 
  439         if (1 << cbits < s->mclms_scaling + 1)
 
  442         send_coef_bits = 
get_bitsz(&
s->gb, cbits) + 2;
 
  444         for (
i = 0; 
i < 
s->mclms_order * 
s->num_channels * 
s->num_channels; 
i++)
 
  445             s->mclms_coeffs[
i] = 
get_bits(&
s->gb, send_coef_bits);
 
  447         for (
i = 0; 
i < 
s->num_channels; 
i++) {
 
  449             for (
c = 0; 
c < 
i; 
c++)
 
  450                 s->mclms_coeffs_cur[
i * 
s->num_channels + 
c] = 
get_bits(&
s->gb, send_coef_bits);
 
  460     for (
c = 0; 
c < 
s->num_channels; 
c++) {
 
  462         for (
i = 0; 
i < 
s->cdlms_ttl[
c]; 
i++) {
 
  466                        "Order[%d][%d] %d > max (%d), not supported\n",
 
  468                 s->cdlms[0][0].order = 0;
 
  471             if(
s->cdlms[
c][
i].order & 8 && 
s->bits_per_sample == 16) {
 
  475                                           s->cdlms[
c][
i].order);
 
  480         for (
i = 0; 
i < 
s->cdlms_ttl[
c]; 
i++)
 
  483         if (cdlms_send_coef) {
 
  484             for (
i = 0; 
i < 
s->cdlms_ttl[
c]; 
i++) {
 
  485                 int cbits, shift_l, shift_r, j;
 
  487                 if ((1 << cbits) < 
s->cdlms[
c][
i].order)
 
  492                 if ((1 << cbits) < 
s->cdlms[
c][
i].scaling + 1)
 
  496                 shift_l = 32 - 
s->cdlms[
c][
i].bitsend;
 
  497                 shift_r = 32 - 
s->cdlms[
c][
i].scaling - 2;
 
  498                 for (j = 0; j < 
s->cdlms[
c][
i].coefsend; j++)
 
  499                     s->cdlms[
c][
i].coefs[j] =
 
  500                         (
get_bits(&
s->gb, 
s->cdlms[
c][
i].bitsend) << shift_l) >> shift_r;
 
  504         for (
i = 0; 
i < 
s->cdlms_ttl[
c]; 
i++)
 
  505             memset(
s->cdlms[
c][
i].coefs + 
s->cdlms[
c][
i].order,
 
  515     unsigned int ave_mean;
 
  517     if (
s->transient[ch]) {
 
  519         if (
s->transient_pos[ch])
 
  520             s->transient[ch] = 0;
 
  521         s->channel[ch].transient_counter =
 
  522             FFMAX(
s->channel[ch].transient_counter, 
s->samples_per_frame / 2);
 
  523     } 
else if (
s->channel[ch].transient_counter)
 
  524         s->transient[ch] = 1;
 
  526     if (
s->seekable_tile) {
 
  527         ave_mean = 
get_bits(&
s->gb, 
s->bits_per_sample);
 
  528         s->ave_sum[ch] = ave_mean << (
s->movave_scaling + 1);
 
  531     if (
s->seekable_tile) {
 
  532         if (
s->do_inter_ch_decorr)
 
  538     for (; 
i < tile_size; 
i++) {
 
  540         unsigned quo = 0, residue;
 
  549         ave_mean = (
s->ave_sum[ch] + (1 << 
s->movave_scaling)) >> (
s->movave_scaling + 1);
 
  555             residue  = (quo << rem_bits) + rem;
 
  558         s->ave_sum[ch] = residue + 
s->ave_sum[ch] -
 
  559                          (
s->ave_sum[ch] >> 
s->movave_scaling);
 
  561         residue = (residue >> 1) ^ -(residue & 1);
 
  562         s->channel_residues[ch][
i] = residue;
 
  575     cbits = 
s->lpc_scaling + 
s->lpc_intbits;
 
  576     for (ch = 0; ch < 
s->num_channels; ch++)
 
  577         for (
i = 0; 
i < 
s->lpc_order; 
i++)
 
  585     memset(
s->acfilter_coeffs,     0, 
sizeof(
s->acfilter_coeffs));
 
  586     memset(
s->acfilter_prevvalues, 0, 
sizeof(
s->acfilter_prevvalues));
 
  587     memset(
s->lpc_coefs,           0, 
sizeof(
s->lpc_coefs));
 
  589     memset(
s->mclms_coeffs,     0, 
sizeof(
s->mclms_coeffs));
 
  590     memset(
s->mclms_coeffs_cur, 0, 
sizeof(
s->mclms_coeffs_cur));
 
  591     memset(
s->mclms_prevvalues, 0, 
sizeof(
s->mclms_prevvalues));
 
  592     memset(
s->mclms_updates,    0, 
sizeof(
s->mclms_updates));
 
  594     for (ich = 0; ich < 
s->num_channels; ich++) {
 
  595         for (ilms = 0; ilms < 
s->cdlms_ttl[ich]; ilms++) {
 
  596             memset(
s->cdlms[ich][ilms].coefs, 0,
 
  597                    sizeof(
s->cdlms[ich][ilms].coefs));
 
  598             memset(
s->cdlms[ich][ilms].lms_prevvalues, 0,
 
  599                    sizeof(
s->cdlms[ich][ilms].lms_prevvalues));
 
  600             memset(
s->cdlms[ich][ilms].lms_updates, 0,
 
  601                    sizeof(
s->cdlms[ich][ilms].lms_updates));
 
  613     s->mclms_recent = 
s->mclms_order * 
s->num_channels;
 
  614     for (ich = 0; ich < 
s->num_channels; ich++) {
 
  615         for (ilms = 0; ilms < 
s->cdlms_ttl[ich]; ilms++)
 
  616             s->cdlms[ich][ilms].recent = 
s->cdlms[ich][ilms].order;
 
  619         s->channel[ich].transient_counter = 
s->samples_per_frame;
 
  620         s->transient[ich]     = 1;
 
  621         s->transient_pos[ich] = 0;
 
  627     int i, j, ich, pred_error;
 
  628     int order        = 
s->mclms_order;
 
  629     int num_channels = 
s->num_channels;
 
  630     int range        = 1 << (
s->bits_per_sample - 1);
 
  632     for (ich = 0; ich < num_channels; ich++) {
 
  633         pred_error = 
s->channel_residues[ich][icoef] - (unsigned)
pred[ich];
 
  634         if (pred_error > 0) {
 
  635             for (
i = 0; 
i < order * num_channels; 
i++)
 
  636                 s->mclms_coeffs[
i + ich * order * num_channels] +=
 
  637                     s->mclms_updates[
s->mclms_recent + 
i];
 
  638             for (j = 0; j < ich; j++)
 
  639                 s->mclms_coeffs_cur[ich * num_channels + j] += 
WMASIGN(
s->channel_residues[j][icoef]);
 
  640         } 
else if (pred_error < 0) {
 
  641             for (
i = 0; 
i < order * num_channels; 
i++)
 
  642                 s->mclms_coeffs[
i + ich * order * num_channels] -=
 
  643                     s->mclms_updates[
s->mclms_recent + 
i];
 
  644             for (j = 0; j < ich; j++)
 
  645                 s->mclms_coeffs_cur[ich * num_channels + j] -= 
WMASIGN(
s->channel_residues[j][icoef]);
 
  649     for (ich = num_channels - 1; ich >= 0; ich--) {
 
  651         s->mclms_prevvalues[
s->mclms_recent] = 
av_clip(
s->channel_residues[ich][icoef],
 
  653         s->mclms_updates[
s->mclms_recent] = 
WMASIGN(
s->channel_residues[ich][icoef]);
 
  656     if (
s->mclms_recent == 0) {
 
  657         memcpy(&
s->mclms_prevvalues[order * num_channels],
 
  659                sizeof(
int32_t) * order * num_channels);
 
  660         memcpy(&
s->mclms_updates[order * num_channels],
 
  662                sizeof(
int32_t) * order * num_channels);
 
  663         s->mclms_recent = num_channels * order;
 
  670     int order        = 
s->mclms_order;
 
  671     int num_channels = 
s->num_channels;
 
  673     for (ich = 0; ich < num_channels; ich++) {
 
  675         if (!
s->is_channel_coded[ich])
 
  677         for (
i = 0; 
i < order * num_channels; 
i++)
 
  678             pred[ich] += (uint32_t)
s->mclms_prevvalues[
i + 
s->mclms_recent] *
 
  679                          s->mclms_coeffs[
i + order * num_channels * ich];
 
  680         for (
i = 0; 
i < ich; 
i++)
 
  681             pred[ich] += (uint32_t)
s->channel_residues[
i][icoef] *
 
  682                          s->mclms_coeffs_cur[
i + num_channels * ich];
 
  683         pred[ich] += (1
U << 
s->mclms_scaling) >> 1;
 
  684         pred[ich] >>= 
s->mclms_scaling;
 
  685         s->channel_residues[ich][icoef] += (unsigned)
pred[ich];
 
  692     for (icoef = 0; icoef < tile_size; icoef++) {
 
  700     int ilms, recent, icoef;
 
  701     for (ilms = 
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
 
  702         recent = 
s->cdlms[ich][ilms].recent;
 
  703         if (
s->update_speed[ich] == 16)
 
  706             for (icoef = 0; icoef < 
s->cdlms[ich][ilms].order; icoef++)
 
  707                 s->cdlms[ich][ilms].lms_updates[icoef + recent] *= 2;
 
  709             for (icoef = 0; icoef < 
s->cdlms[ich][ilms].order; icoef++)
 
  710                 s->cdlms[ich][ilms].lms_updates[icoef] *= 2;
 
  713     s->update_speed[ich] = 16;
 
  718     int ilms, recent, icoef;
 
  719     for (ilms = 
s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) {
 
  720         recent = 
s->cdlms[ich][ilms].recent;
 
  721         if (
s->update_speed[ich] == 8)
 
  724             for (icoef = 0; icoef < 
s->cdlms[ich][ilms].order; icoef++)
 
  725                 s->cdlms[ich][ilms].lms_updates[icoef + recent] /= 2;
 
  727             for (icoef = 0; icoef < 
s->cdlms[ich][ilms].order; icoef++)
 
  728                 s->cdlms[ich][ilms].lms_updates[icoef] /= 2;
 
  730     s->update_speed[ich] = 8;
 
  733 #define CD_LMS(bits, ROUND) \ 
  734 static void lms_update ## bits (WmallDecodeCtx *s, int ich, int ilms, int input) \ 
  736     int recent = s->cdlms[ich][ilms].recent; \ 
  737     int range  = 1 << s->bits_per_sample - 1; \ 
  738     int order  = s->cdlms[ich][ilms].order; \ 
  739     int ##bits##_t *prev = (int##bits##_t *)s->cdlms[ich][ilms].lms_prevvalues; \ 
  744         memcpy(prev + order, prev, (bits/8) * order); \ 
  745         memcpy(s->cdlms[ich][ilms].lms_updates + order, \ 
  746                s->cdlms[ich][ilms].lms_updates, \ 
  747                sizeof(*s->cdlms[ich][ilms].lms_updates) * order); \ 
  748         recent = order - 1; \ 
  751     prev[recent] = av_clip(input, -range, range - 1); \ 
  752     s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich]; \ 
  754     s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2; \ 
  755     s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1; \ 
  756     s->cdlms[ich][ilms].recent = recent; \ 
  757     memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0, \ 
  758            sizeof(s->cdlms[ich][ilms].lms_updates) - \ 
  759            sizeof(*s->cdlms[ich][ilms].lms_updates)*(recent+order)); \ 
  762 static void revert_cdlms ## bits (WmallDecodeCtx *s, int ch, \ 
  763                                   int coef_begin, int coef_end) \ 
  765     int icoef, ilms, num_lms, residue, input; \ 
  768     num_lms = s->cdlms_ttl[ch]; \ 
  769     for (ilms = num_lms - 1; ilms >= 0; ilms--) { \ 
  770         for (icoef = coef_begin; icoef < coef_end; icoef++) { \ 
  771             int##bits##_t *prevvalues = (int##bits##_t *)s->cdlms[ch][ilms].lms_prevvalues; \ 
  772             pred = (1 << s->cdlms[ch][ilms].scaling) >> 1; \ 
  773             residue = s->channel_residues[ch][icoef]; \ 
  774             pred += s->dsp.scalarproduct_and_madd_int## bits (s->cdlms[ch][ilms].coefs, \ 
  775                                                         prevvalues + s->cdlms[ch][ilms].recent, \ 
  776                                                         s->cdlms[ch][ilms].lms_updates + \ 
  777                                                         s->cdlms[ch][ilms].recent, \ 
  778                                                         FFALIGN(s->cdlms[ch][ilms].order, ROUND), \ 
  780             input = residue + (unsigned)((int)pred >> s->cdlms[ch][ilms].scaling); \ 
  781             lms_update ## bits(s, ch, ilms, input); \ 
  782             s->channel_residues[ch][icoef] = input; \ 
  792     if (
s->num_channels != 2)
 
  794     else if (
s->is_channel_coded[0] || 
s->is_channel_coded[1]) {
 
  796         for (icoef = 0; icoef < tile_size; icoef++) {
 
  797             s->channel_residues[0][icoef] -= (unsigned)(
s->channel_residues[1][icoef] >> 1);
 
  798             s->channel_residues[1][icoef] += (unsigned) 
s->channel_residues[0][icoef];
 
  806     int16_t *filter_coeffs = 
s->acfilter_coeffs;
 
  807     int scaling            = 
s->acfilter_scaling;
 
  808     int order              = 
s->acfilter_order;
 
  810     for (ich = 0; ich < 
s->num_channels; ich++) {
 
  811         int *prevvalues = 
s->acfilter_prevvalues[ich];
 
  812         for (
i = 0; 
i < order; 
i++) {
 
  814             for (j = 0; j < order; j++) {
 
  816                     pred += (uint32_t)filter_coeffs[j] * prevvalues[j - 
i];
 
  818                     pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
 
  821             s->channel_residues[ich][
i] += (unsigned)
pred;
 
  823         for (
i = order; 
i < tile_size; 
i++) {
 
  825             for (j = 0; j < order; j++)
 
  826                 pred += (uint32_t)
s->channel_residues[ich][
i - j - 1] * filter_coeffs[j];
 
  828             s->channel_residues[ich][
i] += (unsigned)
pred;
 
  830         for (j = order - 1; j >= 0; j--)
 
  831             if (tile_size <= j) {
 
  832                 prevvalues[j] = prevvalues[j - tile_size];
 
  834                 prevvalues[j] = 
s->channel_residues[ich][tile_size - j - 1];
 
  840     int offset        = 
s->samples_per_frame;
 
  841     int subframe_len  = 
s->samples_per_frame;
 
  842     int total_samples = 
s->samples_per_frame * 
s->num_channels;
 
  843     int i, j, rawpcm_tile, padding_zeroes, res;
 
  850     for (
i = 0; 
i < 
s->num_channels; 
i++) {
 
  851         if (
offset > 
s->channel[
i].decoded_samples) {
 
  852             offset = 
s->channel[
i].decoded_samples;
 
  854                 s->channel[
i].subframe_len[
s->channel[
i].cur_subframe];
 
  859     s->channels_for_cur_subframe = 0;
 
  860     for (
i = 0; 
i < 
s->num_channels; 
i++) {
 
  861         const int cur_subframe = 
s->channel[
i].cur_subframe;
 
  863         total_samples -= 
s->channel[
i].decoded_samples;
 
  866         if (
offset == 
s->channel[
i].decoded_samples &&
 
  867             subframe_len == 
s->channel[
i].subframe_len[cur_subframe]) {
 
  868             total_samples -= 
s->channel[
i].subframe_len[cur_subframe];
 
  869             s->channel[
i].decoded_samples +=
 
  870                 s->channel[
i].subframe_len[cur_subframe];
 
  871             s->channel_indexes_for_cur_subframe[
s->channels_for_cur_subframe] = 
i;
 
  872             ++
s->channels_for_cur_subframe;
 
  879         s->parsed_all_subframes = 1;
 
  883     if (
s->seekable_tile) {
 
  887         if (
s->do_arith_coding) {
 
  911     if (!rawpcm_tile && !
s->cdlms[0][0].order) {
 
  913                "Waiting for seekable tile\n");
 
  919     for (
i = 0; 
i < 
s->num_channels; 
i++)
 
  920         s->is_channel_coded[
i] = 1;
 
  923         for (
i = 0; 
i < 
s->num_channels; 
i++)
 
  932                                       "inverse LPC filter");
 
  947         int bits = 
s->bits_per_sample - padding_zeroes;
 
  950                    "Invalid number of padding bits in raw PCM tile\n");
 
  953         ff_dlog(
s->avctx, 
"RAWPCM %d bits per sample. " 
  954                 "total %d bits, remain=%d\n", 
bits,
 
  956         for (
i = 0; 
i < 
s->num_channels; 
i++)
 
  957             for (j = 0; j < subframe_len; j++)
 
  960         if (
s->bits_per_sample < padding_zeroes)
 
  962         for (
i = 0; 
i < 
s->num_channels; 
i++) {
 
  963             if (
s->is_channel_coded[
i]) {
 
  965                 if (
s->seekable_tile)
 
  969                 if (
s->bits_per_sample > 16)
 
  970                     revert_cdlms32(
s, 
i, 0, subframe_len);
 
  972                     revert_cdlms16(
s, 
i, 0, subframe_len);
 
  974                 memset(
s->channel_residues[
i], 0, 
sizeof(**
s->channel_residues) * subframe_len);
 
  980         if (
s->do_inter_ch_decorr)
 
  986         if (
s->quant_stepsize != 1)
 
  987             for (
i = 0; 
i < 
s->num_channels; 
i++)
 
  988                 for (j = 0; j < subframe_len; j++)
 
  989                     s->channel_residues[
i][j] *= (
unsigned)
s->quant_stepsize;
 
  993     for (
i = 0; 
i < 
s->channels_for_cur_subframe; 
i++) {
 
  994         int c = 
s->channel_indexes_for_cur_subframe[
i];
 
  995         int subframe_len = 
s->channel[
c].subframe_len[
s->channel[
c].cur_subframe];
 
  997         for (j = 0; j < subframe_len; j++) {
 
  998             if (
s->bits_per_sample == 16) {
 
  999                 *
s->samples_16[
c]++ = (int16_t) 
s->channel_residues[
c][j] * (1 << padding_zeroes);
 
 1001                 *
s->samples_32[
c]++ = 
s->channel_residues[
c][j] * (256
U << padding_zeroes);
 
 1007     for (
i = 0; 
i < 
s->channels_for_cur_subframe; 
i++) {
 
 1008         int c = 
s->channel_indexes_for_cur_subframe[
i];
 
 1009         if (
s->channel[
c].cur_subframe >= 
s->channel[
c].num_subframes) {
 
 1013         ++
s->channel[
c].cur_subframe;
 
 1027     int more_frames = 0, 
len = 0, 
i, 
ret;
 
 1029     s->frame->nb_samples = 
s->samples_per_frame;
 
 1033         s->frame->nb_samples = 0;
 
 1036     for (
i = 0; 
i < 
s->num_channels; 
i++) {
 
 1037         s->samples_16[
i] = (int16_t *)
s->frame->extended_data[
i];
 
 1038         s->samples_32[
i] = (
int32_t *)
s->frame->extended_data[
i];
 
 1053     if (
s->dynamic_range_compression)
 
 1071             s->frame->nb_samples -= 
skip;
 
 1072             if (
s->frame->nb_samples <= 0)
 
 1079     s->parsed_all_subframes = 0;
 
 1080     for (
i = 0; 
i < 
s->num_channels; 
i++) {
 
 1081         s->channel[
i].decoded_samples = 0;
 
 1082         s->channel[
i].cur_subframe    = 0;
 
 1086     while (!
s->parsed_all_subframes) {
 
 1087         int decoded_samples = 
s->channel[0].decoded_samples;
 
 1090             if (
s->frame->nb_samples)
 
 1091                 s->frame->nb_samples = decoded_samples;
 
 1100     if (
s->len_prefix) {
 
 1104                    "frame[%"PRIu32
"] would have to skip %i bits\n",
 
 1151         s->num_saved_bits = 
s->frame_offset;
 
 1155     buflen = (
s->num_saved_bits + 
len + 8) >> 3;
 
 1157     if (len <= 0 || buflen > 
s->max_frame_size) {
 
 1160         s->num_saved_bits = 0;
 
 1164     s->num_saved_bits += 
len;
 
 1185                          int *got_frame_ptr, 
AVPacket* avpkt)
 
 1189     const uint8_t* buf = avpkt->
data;
 
 1190     int buf_size       = avpkt->
size;
 
 1191     int num_bits_prev_frame, packet_sequence_number, spliced_packet;
 
 1193     s->frame->nb_samples = 0;
 
 1200             s->num_saved_bits = 0;
 
 1201     } 
else if (
s->packet_done || 
s->packet_loss) {
 
 1206         s->buf_bit_size      = buf_size << 3;
 
 1210         packet_sequence_number = 
get_bits(gb, 4);
 
 1217         num_bits_prev_frame = 
get_bits(gb, 
s->log2_frame_size);
 
 1220         if (!
s->packet_loss &&
 
 1221             ((
s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) {
 
 1224                    "Packet loss detected! seq %"PRIx8
" vs %x\n",
 
 1225                    s->packet_sequence_number, packet_sequence_number);
 
 1227         s->packet_sequence_number = packet_sequence_number;
 
 1229         if (num_bits_prev_frame > 0) {
 
 1231             if (num_bits_prev_frame >= remaining_packet_bits) {
 
 1232                 num_bits_prev_frame = remaining_packet_bits;
 
 1241             if (num_bits_prev_frame < remaining_packet_bits && !s->packet_loss)
 
 1243         } 
else if (
s->num_saved_bits - 
s->frame_offset) {
 
 1244             ff_dlog(avctx, 
"ignoring %x previously saved bits\n",
 
 1245                     s->num_saved_bits - 
s->frame_offset);
 
 1248         if (
s->packet_loss) {
 
 1251             s->num_saved_bits = 0;
 
 1259         s->buf_bit_size = (avpkt->
size - 
s->next_packet_start) << 3;
 
 1268             if (!
s->packet_loss)
 
 1270         } 
else if (!
s->len_prefix
 
 1289     if (
s->packet_done && !
s->packet_loss &&
 
 1296     *got_frame_ptr   = 
s->frame->nb_samples > 0;
 
 1309     s->num_saved_bits    = 0;
 
 1310     s->frame_offset      = 0;
 
 1311     s->next_packet_start = 0;
 
 1312     s->cdlms[0][0].order = 0;
 
 1313     s->frame->nb_samples = 0;
 
 1328     .
p.
name         = 
"wmalossless",
 
 1338 #if FF_API_SUBFRAMES 
 1339                       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
 
static uint8_t * append(uint8_t *buf, const uint8_t *src, int size)
 
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 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
 
static const uint16_t mask[17]
 
#define FF_CODEC_DECODE_CB(func)
 
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)]
 
FF_ENABLE_DEPRECATION_WARNINGS 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.
 
int(* init)(AVBSFContext *ctx)
 
#define av_assert0(cond)
assert() equivalent, that is always enabled.
 
struct WmallDecodeCtx::@216 cdlms[WMALL_MAX_CHANNELS][9]
 
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.
 
#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?