LCOV - code coverage report
Current view: top level - libavcodec - wmadec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 211 446 47.3 %
Date: 2017-12-11 04:34:20 Functions: 7 11 63.6 %

          Line data    Source code
       1             : /*
       2             :  * WMA compatible decoder
       3             :  * Copyright (c) 2002 The FFmpeg Project
       4             :  *
       5             :  * This file is part of FFmpeg.
       6             :  *
       7             :  * FFmpeg is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  *
      12             :  * FFmpeg is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  *
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with FFmpeg; if not, write to the Free Software
      19             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      20             :  */
      21             : 
      22             : /**
      23             :  * @file
      24             :  * WMA compatible decoder.
      25             :  * This decoder handles Microsoft Windows Media Audio data, versions 1 & 2.
      26             :  * WMA v1 is identified by audio format 0x160 in Microsoft media files
      27             :  * (ASF/AVI/WAV). WMA v2 is identified by audio format 0x161.
      28             :  *
      29             :  * To use this decoder, a calling application must supply the extra data
      30             :  * bytes provided with the WMA data. These are the extra, codec-specific
      31             :  * bytes at the end of a WAVEFORMATEX data structure. Transmit these bytes
      32             :  * to the decoder using the extradata[_size] fields in AVCodecContext. There
      33             :  * should be 4 extra bytes for v1 data and 6 extra bytes for v2 data.
      34             :  */
      35             : 
      36             : #include "libavutil/attributes.h"
      37             : #include "libavutil/ffmath.h"
      38             : 
      39             : #include "avcodec.h"
      40             : #include "internal.h"
      41             : #include "wma.h"
      42             : 
      43             : #define EXPVLCBITS 8
      44             : #define EXPMAX     ((19 + EXPVLCBITS - 1) / EXPVLCBITS)
      45             : 
      46             : #define HGAINVLCBITS 9
      47             : #define HGAINMAX     ((13 + HGAINVLCBITS - 1) / HGAINVLCBITS)
      48             : 
      49             : static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len);
      50             : 
      51             : #ifdef TRACE
      52             : static void dump_floats(WMACodecContext *s, const char *name,
      53             :                         int prec, const float *tab, int n)
      54             : {
      55             :     int i;
      56             : 
      57             :     ff_tlog(s->avctx, "%s[%d]:\n", name, n);
      58             :     for (i = 0; i < n; i++) {
      59             :         if ((i & 7) == 0)
      60             :             ff_tlog(s->avctx, "%4d: ", i);
      61             :         ff_tlog(s->avctx, " %8.*f", prec, tab[i]);
      62             :         if ((i & 7) == 7)
      63             :             ff_tlog(s->avctx, "\n");
      64             :     }
      65             :     if ((i & 7) != 0)
      66             :         ff_tlog(s->avctx, "\n");
      67             : }
      68             : #endif /* TRACE */
      69             : 
      70          14 : static av_cold int wma_decode_init(AVCodecContext *avctx)
      71             : {
      72          14 :     WMACodecContext *s = avctx->priv_data;
      73             :     int i, flags2;
      74             :     uint8_t *extradata;
      75             : 
      76          14 :     if (!avctx->block_align) {
      77           0 :         av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
      78           0 :         return AVERROR(EINVAL);
      79             :     }
      80             : 
      81          14 :     s->avctx = avctx;
      82             : 
      83             :     /* extract flag info */
      84          14 :     flags2    = 0;
      85          14 :     extradata = avctx->extradata;
      86          14 :     if (avctx->codec->id == AV_CODEC_ID_WMAV1 && avctx->extradata_size >= 4)
      87           2 :         flags2 = AV_RL16(extradata + 2);
      88          12 :     else if (avctx->codec->id == AV_CODEC_ID_WMAV2 && avctx->extradata_size >= 6)
      89          12 :         flags2 = AV_RL16(extradata + 4);
      90             : 
      91          14 :     s->use_exp_vlc            = flags2 & 0x0001;
      92          14 :     s->use_bit_reservoir      = flags2 & 0x0002;
      93          14 :     s->use_variable_block_len = flags2 & 0x0004;
      94             : 
      95          14 :     if (avctx->codec->id == AV_CODEC_ID_WMAV2 && avctx->extradata_size >= 8){
      96          11 :         if (AV_RL16(extradata+4)==0xd && s->use_variable_block_len){
      97           0 :             av_log(avctx, AV_LOG_WARNING, "Disabling use_variable_block_len, if this fails contact the ffmpeg developers and send us the file\n");
      98           0 :             s->use_variable_block_len= 0; // this fixes issue1503
      99             :         }
     100             :     }
     101             : 
     102          42 :     for (i=0; i<MAX_CHANNELS; i++)
     103          28 :         s->max_exponent[i] = 1.0;
     104             : 
     105          14 :     if (ff_wma_init(avctx, flags2) < 0)
     106           0 :         return -1;
     107             : 
     108             :     /* init MDCT */
     109          51 :     for (i = 0; i < s->nb_block_sizes; i++)
     110          37 :         ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0);
     111             : 
     112          14 :     if (s->use_noise_coding) {
     113           2 :         init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits),
     114             :                  ff_wma_hgain_huffbits, 1, 1,
     115             :                  ff_wma_hgain_huffcodes, 2, 2, 0);
     116             :     }
     117             : 
     118          14 :     if (s->use_exp_vlc)
     119          11 :         init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_aac_scalefactor_bits), // FIXME move out of context
     120             :                  ff_aac_scalefactor_bits, 1, 1,
     121             :                  ff_aac_scalefactor_code, 4, 4, 0);
     122             :     else
     123           3 :         wma_lsp_to_curve_init(s, s->frame_len);
     124             : 
     125          14 :     avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
     126             : 
     127          14 :     return 0;
     128             : }
     129             : 
     130             : /**
     131             :  * compute x^-0.25 with an exponent and mantissa table. We use linear
     132             :  * interpolation to reduce the mantissa table size at a small speed
     133             :  * expense (linear interpolation approximately doubles the number of
     134             :  * bits of precision).
     135             :  */
     136           0 : static inline float pow_m1_4(WMACodecContext *s, float x)
     137             : {
     138             :     union {
     139             :         float f;
     140             :         unsigned int v;
     141             :     } u, t;
     142             :     unsigned int e, m;
     143             :     float a, b;
     144             : 
     145           0 :     u.f = x;
     146           0 :     e   =  u.v >>  23;
     147           0 :     m   = (u.v >> (23 - LSP_POW_BITS)) & ((1 << LSP_POW_BITS) - 1);
     148             :     /* build interpolation scale: 1 <= t < 2. */
     149           0 :     t.v = ((u.v << LSP_POW_BITS) & ((1 << 23) - 1)) | (127 << 23);
     150           0 :     a   = s->lsp_pow_m_table1[m];
     151           0 :     b   = s->lsp_pow_m_table2[m];
     152           0 :     return s->lsp_pow_e_table[e] * (a + b * t.f);
     153             : }
     154             : 
     155           3 : static av_cold void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len)
     156             : {
     157             :     float wdel, a, b;
     158             :     int i, e, m;
     159             : 
     160           3 :     wdel = M_PI / frame_len;
     161        1539 :     for (i = 0; i < frame_len; i++)
     162        1536 :         s->lsp_cos_table[i] = 2.0f * cos(wdel * i);
     163             : 
     164             :     /* tables for x^-0.25 computation */
     165         771 :     for (i = 0; i < 256; i++) {
     166         768 :         e                     = i - 126;
     167         768 :         s->lsp_pow_e_table[i] = exp2f(e * -0.25);
     168             :     }
     169             : 
     170             :     /* NOTE: these two tables are needed to avoid two operations in
     171             :      * pow_m1_4 */
     172           3 :     b = 1.0;
     173         387 :     for (i = (1 << LSP_POW_BITS) - 1; i >= 0; i--) {
     174         384 :         m                      = (1 << LSP_POW_BITS) + i;
     175         384 :         a                      = (float) m * (0.5 / (1 << LSP_POW_BITS));
     176         384 :         a                      = 1/sqrt(sqrt(a));
     177         384 :         s->lsp_pow_m_table1[i] = 2 * a - b;
     178         384 :         s->lsp_pow_m_table2[i] = b - a;
     179         384 :         b                      = a;
     180             :     }
     181           3 : }
     182             : 
     183             : /**
     184             :  * NOTE: We use the same code as Vorbis here
     185             :  * @todo optimize it further with SSE/3Dnow
     186             :  */
     187           0 : static void wma_lsp_to_curve(WMACodecContext *s, float *out, float *val_max_ptr,
     188             :                              int n, float *lsp)
     189             : {
     190             :     int i, j;
     191             :     float p, q, w, v, val_max;
     192             : 
     193           0 :     val_max = 0;
     194           0 :     for (i = 0; i < n; i++) {
     195           0 :         p = 0.5f;
     196           0 :         q = 0.5f;
     197           0 :         w = s->lsp_cos_table[i];
     198           0 :         for (j = 1; j < NB_LSP_COEFS; j += 2) {
     199           0 :             q *= w - lsp[j - 1];
     200           0 :             p *= w - lsp[j];
     201             :         }
     202           0 :         p *= p * (2.0f - w);
     203           0 :         q *= q * (2.0f + w);
     204           0 :         v  = p + q;
     205           0 :         v  = pow_m1_4(s, v);
     206           0 :         if (v > val_max)
     207           0 :             val_max = v;
     208           0 :         out[i] = v;
     209             :     }
     210           0 :     *val_max_ptr = val_max;
     211           0 : }
     212             : 
     213             : /**
     214             :  * decode exponents coded with LSP coefficients (same idea as Vorbis)
     215             :  */
     216           0 : static void decode_exp_lsp(WMACodecContext *s, int ch)
     217             : {
     218             :     float lsp_coefs[NB_LSP_COEFS];
     219             :     int val, i;
     220             : 
     221           0 :     for (i = 0; i < NB_LSP_COEFS; i++) {
     222           0 :         if (i == 0 || i >= 8)
     223           0 :             val = get_bits(&s->gb, 3);
     224             :         else
     225           0 :             val = get_bits(&s->gb, 4);
     226           0 :         lsp_coefs[i] = ff_wma_lsp_codebook[i][val];
     227             :     }
     228             : 
     229           0 :     wma_lsp_to_curve(s, s->exponents[ch], &s->max_exponent[ch],
     230             :                      s->block_len, lsp_coefs);
     231           0 : }
     232             : 
     233             : /** pow(10, i / 16.0) for i in -60..95 */
     234             : static const float pow_tab[] = {
     235             :     1.7782794100389e-04, 2.0535250264571e-04,
     236             :     2.3713737056617e-04, 2.7384196342644e-04,
     237             :     3.1622776601684e-04, 3.6517412725484e-04,
     238             :     4.2169650342858e-04, 4.8696752516586e-04,
     239             :     5.6234132519035e-04, 6.4938163157621e-04,
     240             :     7.4989420933246e-04, 8.6596432336006e-04,
     241             :     1.0000000000000e-03, 1.1547819846895e-03,
     242             :     1.3335214321633e-03, 1.5399265260595e-03,
     243             :     1.7782794100389e-03, 2.0535250264571e-03,
     244             :     2.3713737056617e-03, 2.7384196342644e-03,
     245             :     3.1622776601684e-03, 3.6517412725484e-03,
     246             :     4.2169650342858e-03, 4.8696752516586e-03,
     247             :     5.6234132519035e-03, 6.4938163157621e-03,
     248             :     7.4989420933246e-03, 8.6596432336006e-03,
     249             :     1.0000000000000e-02, 1.1547819846895e-02,
     250             :     1.3335214321633e-02, 1.5399265260595e-02,
     251             :     1.7782794100389e-02, 2.0535250264571e-02,
     252             :     2.3713737056617e-02, 2.7384196342644e-02,
     253             :     3.1622776601684e-02, 3.6517412725484e-02,
     254             :     4.2169650342858e-02, 4.8696752516586e-02,
     255             :     5.6234132519035e-02, 6.4938163157621e-02,
     256             :     7.4989420933246e-02, 8.6596432336007e-02,
     257             :     1.0000000000000e-01, 1.1547819846895e-01,
     258             :     1.3335214321633e-01, 1.5399265260595e-01,
     259             :     1.7782794100389e-01, 2.0535250264571e-01,
     260             :     2.3713737056617e-01, 2.7384196342644e-01,
     261             :     3.1622776601684e-01, 3.6517412725484e-01,
     262             :     4.2169650342858e-01, 4.8696752516586e-01,
     263             :     5.6234132519035e-01, 6.4938163157621e-01,
     264             :     7.4989420933246e-01, 8.6596432336007e-01,
     265             :     1.0000000000000e+00, 1.1547819846895e+00,
     266             :     1.3335214321633e+00, 1.5399265260595e+00,
     267             :     1.7782794100389e+00, 2.0535250264571e+00,
     268             :     2.3713737056617e+00, 2.7384196342644e+00,
     269             :     3.1622776601684e+00, 3.6517412725484e+00,
     270             :     4.2169650342858e+00, 4.8696752516586e+00,
     271             :     5.6234132519035e+00, 6.4938163157621e+00,
     272             :     7.4989420933246e+00, 8.6596432336007e+00,
     273             :     1.0000000000000e+01, 1.1547819846895e+01,
     274             :     1.3335214321633e+01, 1.5399265260595e+01,
     275             :     1.7782794100389e+01, 2.0535250264571e+01,
     276             :     2.3713737056617e+01, 2.7384196342644e+01,
     277             :     3.1622776601684e+01, 3.6517412725484e+01,
     278             :     4.2169650342858e+01, 4.8696752516586e+01,
     279             :     5.6234132519035e+01, 6.4938163157621e+01,
     280             :     7.4989420933246e+01, 8.6596432336007e+01,
     281             :     1.0000000000000e+02, 1.1547819846895e+02,
     282             :     1.3335214321633e+02, 1.5399265260595e+02,
     283             :     1.7782794100389e+02, 2.0535250264571e+02,
     284             :     2.3713737056617e+02, 2.7384196342644e+02,
     285             :     3.1622776601684e+02, 3.6517412725484e+02,
     286             :     4.2169650342858e+02, 4.8696752516586e+02,
     287             :     5.6234132519035e+02, 6.4938163157621e+02,
     288             :     7.4989420933246e+02, 8.6596432336007e+02,
     289             :     1.0000000000000e+03, 1.1547819846895e+03,
     290             :     1.3335214321633e+03, 1.5399265260595e+03,
     291             :     1.7782794100389e+03, 2.0535250264571e+03,
     292             :     2.3713737056617e+03, 2.7384196342644e+03,
     293             :     3.1622776601684e+03, 3.6517412725484e+03,
     294             :     4.2169650342858e+03, 4.8696752516586e+03,
     295             :     5.6234132519035e+03, 6.4938163157621e+03,
     296             :     7.4989420933246e+03, 8.6596432336007e+03,
     297             :     1.0000000000000e+04, 1.1547819846895e+04,
     298             :     1.3335214321633e+04, 1.5399265260595e+04,
     299             :     1.7782794100389e+04, 2.0535250264571e+04,
     300             :     2.3713737056617e+04, 2.7384196342644e+04,
     301             :     3.1622776601684e+04, 3.6517412725484e+04,
     302             :     4.2169650342858e+04, 4.8696752516586e+04,
     303             :     5.6234132519035e+04, 6.4938163157621e+04,
     304             :     7.4989420933246e+04, 8.6596432336007e+04,
     305             :     1.0000000000000e+05, 1.1547819846895e+05,
     306             :     1.3335214321633e+05, 1.5399265260595e+05,
     307             :     1.7782794100389e+05, 2.0535250264571e+05,
     308             :     2.3713737056617e+05, 2.7384196342644e+05,
     309             :     3.1622776601684e+05, 3.6517412725484e+05,
     310             :     4.2169650342858e+05, 4.8696752516586e+05,
     311             :     5.6234132519035e+05, 6.4938163157621e+05,
     312             :     7.4989420933246e+05, 8.6596432336007e+05,
     313             : };
     314             : 
     315             : /**
     316             :  * decode exponents coded with VLC codes
     317             :  */
     318        1136 : static int decode_exp_vlc(WMACodecContext *s, int ch)
     319             : {
     320             :     int last_exp, n, code;
     321             :     const uint16_t *ptr;
     322             :     float v, max_scale;
     323             :     uint32_t *q, *q_end, iv;
     324        1136 :     const float *ptab = pow_tab + 60;
     325        1136 :     const uint32_t *iptab = (const uint32_t *) ptab;
     326             : 
     327        1136 :     ptr       = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
     328        1136 :     q         = (uint32_t *) s->exponents[ch];
     329        1136 :     q_end     = q + s->block_len;
     330        1136 :     max_scale = 0;
     331        1136 :     if (s->version == 1) {
     332         410 :         last_exp  = get_bits(&s->gb, 5) + 10;
     333         410 :         v         = ptab[last_exp];
     334         410 :         iv        = iptab[last_exp];
     335         410 :         max_scale = v;
     336         410 :         n         = *ptr++;
     337         410 :         switch (n & 3) do {
     338         820 :         case 0: *q++ = iv;
     339         820 :         case 3: *q++ = iv;
     340         820 :         case 2: *q++ = iv;
     341        1230 :         case 1: *q++ = iv;
     342        1230 :         } while ((n -= 4) > 0);
     343             :     } else
     344         726 :         last_exp = 36;
     345             : 
     346       30262 :     while (q < q_end) {
     347       27990 :         code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX);
     348       27990 :         if (code < 0) {
     349           0 :             av_log(s->avctx, AV_LOG_ERROR, "Exponent vlc invalid\n");
     350           0 :             return -1;
     351             :         }
     352             :         /* NOTE: this offset is the same as MPEG-4 AAC! */
     353       27990 :         last_exp += code - 60;
     354       27990 :         if ((unsigned) last_exp + 60 >= FF_ARRAY_ELEMS(pow_tab)) {
     355           0 :             av_log(s->avctx, AV_LOG_ERROR, "Exponent out of range: %d\n",
     356             :                    last_exp);
     357           0 :             return -1;
     358             :         }
     359       27990 :         v  = ptab[last_exp];
     360       27990 :         iv = iptab[last_exp];
     361       27990 :         if (v > max_scale)
     362        1141 :             max_scale = v;
     363       27990 :         n = *ptr++;
     364       27990 :         switch (n & 3) do {
     365      576712 :         case 0: *q++ = iv;
     366      579172 :         case 3: *q++ = iv;
     367      581632 :         case 2: *q++ = iv;
     368      585322 :         case 1: *q++ = iv;
     369      585322 :         } while ((n -= 4) > 0);
     370             :     }
     371        1136 :     s->max_exponent[ch] = max_scale;
     372        1136 :     return 0;
     373             : }
     374             : 
     375             : /**
     376             :  * Apply MDCT window and add into output.
     377             :  *
     378             :  * We ensure that when the windows overlap their squared sum
     379             :  * is always 1 (MDCT reconstruction rule).
     380             :  */
     381        1172 : static void wma_window(WMACodecContext *s, float *out)
     382             : {
     383        1172 :     float *in = s->output;
     384             :     int block_len, bsize, n;
     385             : 
     386             :     /* left part */
     387        1172 :     if (s->block_len_bits <= s->prev_block_len_bits) {
     388        1172 :         block_len = s->block_len;
     389        1172 :         bsize     = s->frame_len_bits - s->block_len_bits;
     390             : 
     391        1172 :         s->fdsp->vector_fmul_add(out, in, s->windows[bsize],
     392             :                                 out, block_len);
     393             :     } else {
     394           0 :         block_len = 1 << s->prev_block_len_bits;
     395           0 :         n         = (s->block_len - block_len) / 2;
     396           0 :         bsize     = s->frame_len_bits - s->prev_block_len_bits;
     397             : 
     398           0 :         s->fdsp->vector_fmul_add(out + n, in + n, s->windows[bsize],
     399           0 :                                 out + n, block_len);
     400             : 
     401           0 :         memcpy(out + n + block_len, in + n + block_len, n * sizeof(float));
     402             :     }
     403             : 
     404        1172 :     out += s->block_len;
     405        1172 :     in  += s->block_len;
     406             : 
     407             :     /* right part */
     408        1172 :     if (s->block_len_bits <= s->next_block_len_bits) {
     409        1172 :         block_len = s->block_len;
     410        1172 :         bsize     = s->frame_len_bits - s->block_len_bits;
     411             : 
     412        1172 :         s->fdsp->vector_fmul_reverse(out, in, s->windows[bsize], block_len);
     413             :     } else {
     414           0 :         block_len = 1 << s->next_block_len_bits;
     415           0 :         n         = (s->block_len - block_len) / 2;
     416           0 :         bsize     = s->frame_len_bits - s->next_block_len_bits;
     417             : 
     418           0 :         memcpy(out, in, n * sizeof(float));
     419             : 
     420           0 :         s->fdsp->vector_fmul_reverse(out + n, in + n, s->windows[bsize],
     421             :                                     block_len);
     422             : 
     423           0 :         memset(out + n + block_len, 0, n * sizeof(float));
     424             :     }
     425        1172 : }
     426             : 
     427             : /**
     428             :  * @return 0 if OK. 1 if last block of frame. return -1 if
     429             :  * unrecoverable error.
     430             :  */
     431         586 : static int wma_decode_block(WMACodecContext *s)
     432             : {
     433             :     int n, v, a, ch, bsize;
     434             :     int coef_nb_bits, total_gain;
     435             :     int nb_coefs[MAX_CHANNELS];
     436             :     float mdct_norm;
     437             :     FFTContext *mdct;
     438             : 
     439             : #ifdef TRACE
     440             :     ff_tlog(s->avctx, "***decode_block: %d:%d\n",
     441             :             s->frame_count - 1, s->block_num);
     442             : #endif /* TRACE */
     443             : 
     444             :     /* compute current block length */
     445         586 :     if (s->use_variable_block_len) {
     446           0 :         n = av_log2(s->nb_block_sizes - 1) + 1;
     447             : 
     448           0 :         if (s->reset_block_lengths) {
     449           0 :             s->reset_block_lengths = 0;
     450           0 :             v                      = get_bits(&s->gb, n);
     451           0 :             if (v >= s->nb_block_sizes) {
     452           0 :                 av_log(s->avctx, AV_LOG_ERROR,
     453             :                        "prev_block_len_bits %d out of range\n",
     454           0 :                        s->frame_len_bits - v);
     455           0 :                 return -1;
     456             :             }
     457           0 :             s->prev_block_len_bits = s->frame_len_bits - v;
     458           0 :             v                      = get_bits(&s->gb, n);
     459           0 :             if (v >= s->nb_block_sizes) {
     460           0 :                 av_log(s->avctx, AV_LOG_ERROR,
     461             :                        "block_len_bits %d out of range\n",
     462           0 :                        s->frame_len_bits - v);
     463           0 :                 return -1;
     464             :             }
     465           0 :             s->block_len_bits = s->frame_len_bits - v;
     466             :         } else {
     467             :             /* update block lengths */
     468           0 :             s->prev_block_len_bits = s->block_len_bits;
     469           0 :             s->block_len_bits      = s->next_block_len_bits;
     470             :         }
     471           0 :         v = get_bits(&s->gb, n);
     472           0 :         if (v >= s->nb_block_sizes) {
     473           0 :             av_log(s->avctx, AV_LOG_ERROR,
     474             :                    "next_block_len_bits %d out of range\n",
     475           0 :                    s->frame_len_bits - v);
     476           0 :             return -1;
     477             :         }
     478           0 :         s->next_block_len_bits = s->frame_len_bits - v;
     479             :     } else {
     480             :         /* fixed block len */
     481         586 :         s->next_block_len_bits = s->frame_len_bits;
     482         586 :         s->prev_block_len_bits = s->frame_len_bits;
     483         586 :         s->block_len_bits      = s->frame_len_bits;
     484             :     }
     485             : 
     486         586 :     if (s->frame_len_bits - s->block_len_bits >= s->nb_block_sizes){
     487           0 :         av_log(s->avctx, AV_LOG_ERROR, "block_len_bits not initialized to a valid value\n");
     488           0 :         return -1;
     489             :     }
     490             : 
     491             :     /* now check if the block length is coherent with the frame length */
     492         586 :     s->block_len = 1 << s->block_len_bits;
     493         586 :     if ((s->block_pos + s->block_len) > s->frame_len) {
     494           0 :         av_log(s->avctx, AV_LOG_ERROR, "frame_len overflow\n");
     495           0 :         return -1;
     496             :     }
     497             : 
     498         586 :     if (s->avctx->channels == 2)
     499         586 :         s->ms_stereo = get_bits1(&s->gb);
     500         586 :     v = 0;
     501        1758 :     for (ch = 0; ch < s->avctx->channels; ch++) {
     502        1172 :         a                    = get_bits1(&s->gb);
     503        1172 :         s->channel_coded[ch] = a;
     504        1172 :         v                   |= a;
     505             :     }
     506             : 
     507         586 :     bsize = s->frame_len_bits - s->block_len_bits;
     508             : 
     509             :     /* if no channel coded, no need to go further */
     510             :     /* XXX: fix potential framing problems */
     511         586 :     if (!v)
     512           0 :         goto next;
     513             : 
     514             :     /* read total gain and extract corresponding number of bits for
     515             :      * coef escape coding */
     516         586 :     total_gain = 1;
     517             :     for (;;) {
     518         586 :         if (get_bits_left(&s->gb) < 7) {
     519           0 :             av_log(s->avctx, AV_LOG_ERROR, "total_gain overread\n");
     520           0 :             return AVERROR_INVALIDDATA;
     521             :         }
     522         586 :         a           = get_bits(&s->gb, 7);
     523         586 :         total_gain += a;
     524         586 :         if (a != 127)
     525         586 :             break;
     526             :     }
     527             : 
     528         586 :     coef_nb_bits = ff_wma_total_gain_to_bits(total_gain);
     529             : 
     530             :     /* compute number of coefficients */
     531         586 :     n = s->coefs_end[bsize] - s->coefs_start;
     532        1758 :     for (ch = 0; ch < s->avctx->channels; ch++)
     533        1172 :         nb_coefs[ch] = n;
     534             : 
     535             :     /* complex coding */
     536         586 :     if (s->use_noise_coding) {
     537           0 :         for (ch = 0; ch < s->avctx->channels; ch++) {
     538           0 :             if (s->channel_coded[ch]) {
     539             :                 int i, n, a;
     540           0 :                 n = s->exponent_high_sizes[bsize];
     541           0 :                 for (i = 0; i < n; i++) {
     542           0 :                     a                         = get_bits1(&s->gb);
     543           0 :                     s->high_band_coded[ch][i] = a;
     544             :                     /* if noise coding, the coefficients are not transmitted */
     545           0 :                     if (a)
     546           0 :                         nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
     547             :                 }
     548             :             }
     549             :         }
     550           0 :         for (ch = 0; ch < s->avctx->channels; ch++) {
     551           0 :             if (s->channel_coded[ch]) {
     552             :                 int i, n, val, code;
     553             : 
     554           0 :                 n   = s->exponent_high_sizes[bsize];
     555           0 :                 val = (int) 0x80000000;
     556           0 :                 for (i = 0; i < n; i++) {
     557           0 :                     if (s->high_band_coded[ch][i]) {
     558           0 :                         if (val == (int) 0x80000000) {
     559           0 :                             val = get_bits(&s->gb, 7) - 19;
     560             :                         } else {
     561           0 :                             code = get_vlc2(&s->gb, s->hgain_vlc.table,
     562             :                                             HGAINVLCBITS, HGAINMAX);
     563           0 :                             if (code < 0) {
     564           0 :                                 av_log(s->avctx, AV_LOG_ERROR,
     565             :                                        "hgain vlc invalid\n");
     566           0 :                                 return -1;
     567             :                             }
     568           0 :                             val += code - 18;
     569             :                         }
     570           0 :                         s->high_band_values[ch][i] = val;
     571             :                     }
     572             :                 }
     573             :             }
     574             :         }
     575             :     }
     576             : 
     577             :     /* exponents can be reused in short blocks. */
     578         586 :     if ((s->block_len_bits == s->frame_len_bits) || get_bits1(&s->gb)) {
     579        1758 :         for (ch = 0; ch < s->avctx->channels; ch++) {
     580        1172 :             if (s->channel_coded[ch]) {
     581        1136 :                 if (s->use_exp_vlc) {
     582        1136 :                     if (decode_exp_vlc(s, ch) < 0)
     583           0 :                         return -1;
     584             :                 } else {
     585           0 :                     decode_exp_lsp(s, ch);
     586             :                 }
     587        1136 :                 s->exponents_bsize[ch] = bsize;
     588             :             }
     589             :         }
     590             :     }
     591             : 
     592             :     /* parse spectral coefficients : just RLE encoding */
     593        1758 :     for (ch = 0; ch < s->avctx->channels; ch++) {
     594        1172 :         if (s->channel_coded[ch]) {
     595             :             int tindex;
     596        1136 :             WMACoef *ptr = &s->coefs1[ch][0];
     597             : 
     598             :             /* special VLC tables are used for ms stereo because
     599             :              * there is potentially less energy there */
     600        1136 :             tindex = (ch == 1 && s->ms_stereo);
     601        1136 :             memset(ptr, 0, s->block_len * sizeof(WMACoef));
     602        2272 :             ff_wma_run_level_decode(s->avctx, &s->gb, &s->coef_vlc[tindex],
     603        1136 :                                     s->level_table[tindex], s->run_table[tindex],
     604             :                                     0, ptr, 0, nb_coefs[ch],
     605             :                                     s->block_len, s->frame_len_bits, coef_nb_bits);
     606             :         }
     607        1172 :         if (s->version == 1 && s->avctx->channels >= 2)
     608         410 :             align_get_bits(&s->gb);
     609             :     }
     610             : 
     611             :     /* normalize */
     612             :     {
     613         586 :         int n4 = s->block_len / 2;
     614         586 :         mdct_norm = 1.0 / (float) n4;
     615         586 :         if (s->version == 1)
     616         205 :             mdct_norm *= sqrt(n4);
     617             :     }
     618             : 
     619             :     /* finally compute the MDCT coefficients */
     620        1758 :     for (ch = 0; ch < s->avctx->channels; ch++) {
     621        1172 :         if (s->channel_coded[ch]) {
     622             :             WMACoef *coefs1;
     623             :             float *coefs, *exponents, mult, mult1, noise;
     624             :             int i, j, n, n1, last_high_band, esize;
     625             :             float exp_power[HIGH_BAND_MAX_SIZE];
     626             : 
     627        1136 :             coefs1    = s->coefs1[ch];
     628        1136 :             exponents = s->exponents[ch];
     629        1136 :             esize     = s->exponents_bsize[ch];
     630        1136 :             mult      = ff_exp10(total_gain * 0.05) / s->max_exponent[ch];
     631        1136 :             mult     *= mdct_norm;
     632        1136 :             coefs     = s->coefs[ch];
     633        1136 :             if (s->use_noise_coding) {
     634           0 :                 mult1 = mult;
     635             :                 /* very low freqs : noise */
     636           0 :                 for (i = 0; i < s->coefs_start; i++) {
     637           0 :                     *coefs++ = s->noise_table[s->noise_index] *
     638           0 :                                exponents[i << bsize >> esize] * mult1;
     639           0 :                     s->noise_index = (s->noise_index + 1) &
     640             :                                      (NOISE_TAB_SIZE - 1);
     641             :                 }
     642             : 
     643           0 :                 n1 = s->exponent_high_sizes[bsize];
     644             : 
     645             :                 /* compute power of high bands */
     646           0 :                 exponents = s->exponents[ch] +
     647           0 :                             (s->high_band_start[bsize] << bsize >> esize);
     648           0 :                 last_high_band = 0; /* avoid warning */
     649           0 :                 for (j = 0; j < n1; j++) {
     650           0 :                     n = s->exponent_high_bands[s->frame_len_bits -
     651           0 :                                                s->block_len_bits][j];
     652           0 :                     if (s->high_band_coded[ch][j]) {
     653             :                         float e2, v;
     654           0 :                         e2 = 0;
     655           0 :                         for (i = 0; i < n; i++) {
     656           0 :                             v   = exponents[i << bsize >> esize];
     657           0 :                             e2 += v * v;
     658             :                         }
     659           0 :                         exp_power[j]   = e2 / n;
     660           0 :                         last_high_band = j;
     661             :                         ff_tlog(s->avctx, "%d: power=%f (%d)\n", j, exp_power[j], n);
     662             :                     }
     663           0 :                     exponents += n << bsize >> esize;
     664             :                 }
     665             : 
     666             :                 /* main freqs and high freqs */
     667           0 :                 exponents = s->exponents[ch] + (s->coefs_start << bsize >> esize);
     668           0 :                 for (j = -1; j < n1; j++) {
     669           0 :                     if (j < 0)
     670           0 :                         n = s->high_band_start[bsize] - s->coefs_start;
     671             :                     else
     672           0 :                         n = s->exponent_high_bands[s->frame_len_bits -
     673           0 :                                                    s->block_len_bits][j];
     674           0 :                     if (j >= 0 && s->high_band_coded[ch][j]) {
     675             :                         /* use noise with specified power */
     676           0 :                         mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
     677             :                         /* XXX: use a table */
     678           0 :                         mult1  = mult1 * ff_exp10(s->high_band_values[ch][j] * 0.05);
     679           0 :                         mult1  = mult1 / (s->max_exponent[ch] * s->noise_mult);
     680           0 :                         mult1 *= mdct_norm;
     681           0 :                         for (i = 0; i < n; i++) {
     682           0 :                             noise          = s->noise_table[s->noise_index];
     683           0 :                             s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
     684           0 :                             *coefs++       = noise * exponents[i << bsize >> esize] * mult1;
     685             :                         }
     686           0 :                         exponents += n << bsize >> esize;
     687             :                     } else {
     688             :                         /* coded values + small noise */
     689           0 :                         for (i = 0; i < n; i++) {
     690           0 :                             noise          = s->noise_table[s->noise_index];
     691           0 :                             s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
     692           0 :                             *coefs++       = ((*coefs1++) + noise) *
     693           0 :                                              exponents[i << bsize >> esize] * mult;
     694             :                         }
     695           0 :                         exponents += n << bsize >> esize;
     696             :                     }
     697             :                 }
     698             : 
     699             :                 /* very high freqs : noise */
     700           0 :                 n     = s->block_len - s->coefs_end[bsize];
     701           0 :                 mult1 = mult * exponents[(-(1 << bsize)) >> esize];
     702           0 :                 for (i = 0; i < n; i++) {
     703           0 :                     *coefs++       = s->noise_table[s->noise_index] * mult1;
     704           0 :                     s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
     705             :                 }
     706             :             } else {
     707             :                 /* XXX: optimize more */
     708        2366 :                 for (i = 0; i < s->coefs_start; i++)
     709        1230 :                     *coefs++ = 0.0;
     710        1136 :                 n = nb_coefs[ch];
     711     2117410 :                 for (i = 0; i < n; i++)
     712     2116274 :                     *coefs++ = coefs1[i] * exponents[i << bsize >> esize] * mult;
     713        1136 :                 n = s->block_len - s->coefs_end[bsize];
     714      210160 :                 for (i = 0; i < n; i++)
     715      209024 :                     *coefs++ = 0.0;
     716             :             }
     717             :         }
     718             :     }
     719             : 
     720             : #ifdef TRACE
     721             :     for (ch = 0; ch < s->avctx->channels; ch++) {
     722             :         if (s->channel_coded[ch]) {
     723             :             dump_floats(s, "exponents", 3, s->exponents[ch], s->block_len);
     724             :             dump_floats(s, "coefs", 1, s->coefs[ch], s->block_len);
     725             :         }
     726             :     }
     727             : #endif /* TRACE */
     728             : 
     729        1067 :     if (s->ms_stereo && s->channel_coded[1]) {
     730             :         /* nominal case for ms stereo: we do it before mdct */
     731             :         /* no need to optimize this case because it should almost
     732             :          * never happen */
     733         480 :         if (!s->channel_coded[0]) {
     734             :             ff_tlog(s->avctx, "rare ms-stereo case happened\n");
     735           0 :             memset(s->coefs[0], 0, sizeof(float) * s->block_len);
     736           0 :             s->channel_coded[0] = 1;
     737             :         }
     738             : 
     739         480 :         s->fdsp->butterflies_float(s->coefs[0], s->coefs[1], s->block_len);
     740             :     }
     741             : 
     742         692 : next:
     743         586 :     mdct = &s->mdct_ctx[bsize];
     744             : 
     745        1758 :     for (ch = 0; ch < s->avctx->channels; ch++) {
     746             :         int n4, index;
     747             : 
     748        1172 :         n4 = s->block_len / 2;
     749        1172 :         if (s->channel_coded[ch])
     750        1136 :             mdct->imdct_calc(mdct, s->output, s->coefs[ch]);
     751          36 :         else if (!(s->ms_stereo && ch == 1))
     752          35 :             memset(s->output, 0, sizeof(s->output));
     753             : 
     754             :         /* multiply by the window and add in the frame */
     755        1172 :         index = (s->frame_len / 2) + s->block_pos - n4;
     756        1172 :         wma_window(s, &s->frame_out[ch][index]);
     757             :     }
     758             : 
     759             :     /* update block number */
     760         586 :     s->block_num++;
     761         586 :     s->block_pos += s->block_len;
     762         586 :     if (s->block_pos >= s->frame_len)
     763         586 :         return 1;
     764             :     else
     765           0 :         return 0;
     766             : }
     767             : 
     768             : /* decode a frame of frame_len samples */
     769         586 : static int wma_decode_frame(WMACodecContext *s, float **samples,
     770             :                             int samples_offset)
     771             : {
     772             :     int ret, ch;
     773             : 
     774             : #ifdef TRACE
     775             :     ff_tlog(s->avctx, "***decode_frame: %d size=%d\n",
     776             :             s->frame_count++, s->frame_len);
     777             : #endif /* TRACE */
     778             : 
     779             :     /* read each block */
     780         586 :     s->block_num = 0;
     781         586 :     s->block_pos = 0;
     782             :     for (;;) {
     783         586 :         ret = wma_decode_block(s);
     784         586 :         if (ret < 0)
     785           0 :             return -1;
     786         586 :         if (ret)
     787         586 :             break;
     788             :     }
     789             : 
     790        1758 :     for (ch = 0; ch < s->avctx->channels; ch++) {
     791             :         /* copy current block to output */
     792        1172 :         memcpy(samples[ch] + samples_offset, s->frame_out[ch],
     793        1172 :                s->frame_len * sizeof(*s->frame_out[ch]));
     794             :         /* prepare for next block */
     795        1172 :         memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
     796        1172 :                 s->frame_len * sizeof(*s->frame_out[ch]));
     797             : 
     798             : #ifdef TRACE
     799             :         dump_floats(s, "samples", 6, samples[ch] + samples_offset,
     800             :                     s->frame_len);
     801             : #endif /* TRACE */
     802             :     }
     803             : 
     804         586 :     return 0;
     805             : }
     806             : 
     807         587 : static int wma_decode_superframe(AVCodecContext *avctx, void *data,
     808             :                                  int *got_frame_ptr, AVPacket *avpkt)
     809             : {
     810         587 :     AVFrame *frame = data;
     811         587 :     const uint8_t *buf = avpkt->data;
     812         587 :     int buf_size       = avpkt->size;
     813         587 :     WMACodecContext *s = avctx->priv_data;
     814             :     int nb_frames, bit_offset, i, pos, len, ret;
     815             :     uint8_t *q;
     816             :     float **samples;
     817             :     int samples_offset;
     818             : 
     819             :     ff_tlog(avctx, "***decode_superframe:\n");
     820             : 
     821         587 :     if (buf_size == 0) {
     822           0 :         s->last_superframe_len = 0;
     823           0 :         return 0;
     824             :     }
     825         587 :     if (buf_size < avctx->block_align) {
     826           1 :         av_log(avctx, AV_LOG_ERROR,
     827             :                "Input packet size too small (%d < %d)\n",
     828             :                buf_size, avctx->block_align);
     829           1 :         return AVERROR_INVALIDDATA;
     830             :     }
     831         586 :     if (avctx->block_align)
     832         586 :         buf_size = avctx->block_align;
     833             : 
     834         586 :     init_get_bits(&s->gb, buf, buf_size * 8);
     835             : 
     836         586 :     if (s->use_bit_reservoir) {
     837             :         /* read super frame header */
     838           0 :         skip_bits(&s->gb, 4); /* super frame index */
     839           0 :         nb_frames = get_bits(&s->gb, 4) - (s->last_superframe_len <= 0);
     840           0 :         if (nb_frames <= 0) {
     841           0 :             int is_error = nb_frames < 0 || get_bits_left(&s->gb) <= 8;
     842           0 :             av_log(avctx, is_error ? AV_LOG_ERROR : AV_LOG_WARNING,
     843             :                    "nb_frames is %d bits left %d\n",
     844             :                    nb_frames, get_bits_left(&s->gb));
     845           0 :             if (is_error)
     846           0 :                 return AVERROR_INVALIDDATA;
     847             : 
     848           0 :             if ((s->last_superframe_len + buf_size - 1) >
     849             :                 MAX_CODED_SUPERFRAME_SIZE)
     850           0 :                 goto fail;
     851             : 
     852           0 :             q   = s->last_superframe + s->last_superframe_len;
     853           0 :             len = buf_size - 1;
     854           0 :             while (len > 0) {
     855           0 :                 *q++ = get_bits (&s->gb, 8);
     856           0 :                 len --;
     857             :             }
     858           0 :             memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE);
     859             : 
     860           0 :             s->last_superframe_len += 8*buf_size - 8;
     861             : //             s->reset_block_lengths = 1; //XXX is this needed ?
     862           0 :             *got_frame_ptr = 0;
     863           0 :             return buf_size;
     864             :         }
     865             :     } else
     866         586 :         nb_frames = 1;
     867             : 
     868             :     /* get output buffer */
     869         586 :     frame->nb_samples = nb_frames * s->frame_len;
     870         586 :     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
     871           0 :         return ret;
     872         586 :     samples        = (float **) frame->extended_data;
     873         586 :     samples_offset = 0;
     874             : 
     875         586 :     if (s->use_bit_reservoir) {
     876           0 :         bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3);
     877           0 :         if (bit_offset > get_bits_left(&s->gb)) {
     878           0 :             av_log(avctx, AV_LOG_ERROR,
     879             :                    "Invalid last frame bit offset %d > buf size %d (%d)\n",
     880             :                    bit_offset, get_bits_left(&s->gb), buf_size);
     881           0 :             goto fail;
     882             :         }
     883             : 
     884           0 :         if (s->last_superframe_len > 0) {
     885             :             /* add bit_offset bits to last frame */
     886           0 :             if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) >
     887             :                 MAX_CODED_SUPERFRAME_SIZE)
     888           0 :                 goto fail;
     889           0 :             q   = s->last_superframe + s->last_superframe_len;
     890           0 :             len = bit_offset;
     891           0 :             while (len > 7) {
     892           0 :                 *q++ = (get_bits) (&s->gb, 8);
     893           0 :                 len -= 8;
     894             :             }
     895           0 :             if (len > 0)
     896           0 :                 *q++ = (get_bits) (&s->gb, len) << (8 - len);
     897           0 :             memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE);
     898             : 
     899             :             /* XXX: bit_offset bits into last frame */
     900           0 :             init_get_bits(&s->gb, s->last_superframe,
     901           0 :                           s->last_superframe_len * 8 + bit_offset);
     902             :             /* skip unused bits */
     903           0 :             if (s->last_bitoffset > 0)
     904           0 :                 skip_bits(&s->gb, s->last_bitoffset);
     905             :             /* this frame is stored in the last superframe and in the
     906             :              * current one */
     907           0 :             if (wma_decode_frame(s, samples, samples_offset) < 0)
     908           0 :                 goto fail;
     909           0 :             samples_offset += s->frame_len;
     910           0 :             nb_frames--;
     911             :         }
     912             : 
     913             :         /* read each frame starting from bit_offset */
     914           0 :         pos = bit_offset + 4 + 4 + s->byte_offset_bits + 3;
     915           0 :         if (pos >= MAX_CODED_SUPERFRAME_SIZE * 8 || pos > buf_size * 8)
     916           0 :             return AVERROR_INVALIDDATA;
     917           0 :         init_get_bits(&s->gb, buf + (pos >> 3), (buf_size - (pos >> 3)) * 8);
     918           0 :         len = pos & 7;
     919           0 :         if (len > 0)
     920           0 :             skip_bits(&s->gb, len);
     921             : 
     922           0 :         s->reset_block_lengths = 1;
     923           0 :         for (i = 0; i < nb_frames; i++) {
     924           0 :             if (wma_decode_frame(s, samples, samples_offset) < 0)
     925           0 :                 goto fail;
     926           0 :             samples_offset += s->frame_len;
     927             :         }
     928             : 
     929             :         /* we copy the end of the frame in the last frame buffer */
     930           0 :         pos               = get_bits_count(&s->gb) +
     931           0 :                             ((bit_offset + 4 + 4 + s->byte_offset_bits + 3) & ~7);
     932           0 :         s->last_bitoffset = pos & 7;
     933           0 :         pos             >>= 3;
     934           0 :         len               = buf_size - pos;
     935           0 :         if (len > MAX_CODED_SUPERFRAME_SIZE || len < 0) {
     936           0 :             av_log(s->avctx, AV_LOG_ERROR, "len %d invalid\n", len);
     937           0 :             goto fail;
     938             :         }
     939           0 :         s->last_superframe_len = len;
     940           0 :         memcpy(s->last_superframe, buf + pos, len);
     941             :     } else {
     942             :         /* single frame decode */
     943         586 :         if (wma_decode_frame(s, samples, samples_offset) < 0)
     944           0 :             goto fail;
     945         586 :         samples_offset += s->frame_len;
     946             :     }
     947             : 
     948             :     ff_dlog(s->avctx, "%d %d %d %d outbytes:%"PTRDIFF_SPECIFIER" eaten:%d\n",
     949             :             s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len,
     950             :             (int8_t *) samples - (int8_t *) data, avctx->block_align);
     951             : 
     952         586 :     *got_frame_ptr = 1;
     953             : 
     954         586 :     return buf_size;
     955             : 
     956           0 : fail:
     957             :     /* when error, we reset the bit reservoir */
     958           0 :     s->last_superframe_len = 0;
     959           0 :     return -1;
     960             : }
     961             : 
     962           0 : static av_cold void flush(AVCodecContext *avctx)
     963             : {
     964           0 :     WMACodecContext *s = avctx->priv_data;
     965             : 
     966           0 :     s->last_bitoffset      =
     967           0 :     s->last_superframe_len = 0;
     968           0 : }
     969             : 
     970             : #if CONFIG_WMAV1_DECODER
     971             : AVCodec ff_wmav1_decoder = {
     972             :     .name           = "wmav1",
     973             :     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
     974             :     .type           = AVMEDIA_TYPE_AUDIO,
     975             :     .id             = AV_CODEC_ID_WMAV1,
     976             :     .priv_data_size = sizeof(WMACodecContext),
     977             :     .init           = wma_decode_init,
     978             :     .close          = ff_wma_end,
     979             :     .decode         = wma_decode_superframe,
     980             :     .flush          = flush,
     981             :     .capabilities   = AV_CODEC_CAP_DR1,
     982             :     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
     983             :                                                       AV_SAMPLE_FMT_NONE },
     984             : };
     985             : #endif
     986             : #if CONFIG_WMAV2_DECODER
     987             : AVCodec ff_wmav2_decoder = {
     988             :     .name           = "wmav2",
     989             :     .long_name      = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
     990             :     .type           = AVMEDIA_TYPE_AUDIO,
     991             :     .id             = AV_CODEC_ID_WMAV2,
     992             :     .priv_data_size = sizeof(WMACodecContext),
     993             :     .init           = wma_decode_init,
     994             :     .close          = ff_wma_end,
     995             :     .decode         = wma_decode_superframe,
     996             :     .flush          = flush,
     997             :     .capabilities   = AV_CODEC_CAP_DR1,
     998             :     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
     999             :                                                       AV_SAMPLE_FMT_NONE },
    1000             : };
    1001             : #endif

Generated by: LCOV version 1.13