~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/wmadec.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * WMA compatible decoder
3
3
 * Copyright (c) 2002 The FFmpeg Project.
4
4
 *
5
 
 * This library is free software; you can redistribute it and/or
 
5
 * This file is part of FFmpeg.
 
6
 *
 
7
 * FFmpeg is free software; you can redistribute it and/or
6
8
 * modify it under the terms of the GNU Lesser General Public
7
9
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
10
 * version 2.1 of the License, or (at your option) any later version.
9
11
 *
10
 
 * This library is distributed in the hope that it will be useful,
 
12
 * FFmpeg is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
15
 * Lesser General Public License for more details.
14
16
 *
15
17
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
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
18
20
 */
19
21
 
20
22
/**
21
23
 * @file wmadec.c
22
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.
23
34
 */
24
35
 
25
36
#include "avcodec.h"
26
 
#include "dsputil.h"
27
 
 
28
 
/* size of blocks */
29
 
#define BLOCK_MIN_BITS 7
30
 
#define BLOCK_MAX_BITS 11
31
 
#define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
32
 
 
33
 
#define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
34
 
 
35
 
/* XXX: find exact max size */
36
 
#define HIGH_BAND_MAX_SIZE 16
37
 
 
38
 
#define NB_LSP_COEFS 10
39
 
 
40
 
/* XXX: is it a suitable value ? */
41
 
#define MAX_CODED_SUPERFRAME_SIZE 4096
42
 
 
43
 
#define MAX_CHANNELS 2
44
 
 
45
 
#define NOISE_TAB_SIZE 8192
46
 
 
47
 
#define LSP_POW_BITS 7
48
 
 
49
 
typedef struct WMADecodeContext {
50
 
    GetBitContext gb;
51
 
    int sample_rate;
52
 
    int nb_channels;
53
 
    int bit_rate;
54
 
    int version; /* 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) */
55
 
    int block_align;
56
 
    int use_bit_reservoir;
57
 
    int use_variable_block_len;
58
 
    int use_exp_vlc;  /* exponent coding: 0 = lsp, 1 = vlc + delta */
59
 
    int use_noise_coding; /* true if perceptual noise is added */
60
 
    int byte_offset_bits;
61
 
    VLC exp_vlc;
62
 
    int exponent_sizes[BLOCK_NB_SIZES];
63
 
    uint16_t exponent_bands[BLOCK_NB_SIZES][25];
64
 
    int high_band_start[BLOCK_NB_SIZES]; /* index of first coef in high band */
65
 
    int coefs_start;               /* first coded coef */
66
 
    int coefs_end[BLOCK_NB_SIZES]; /* max number of coded coefficients */
67
 
    int exponent_high_sizes[BLOCK_NB_SIZES];
68
 
    int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE]; 
69
 
    VLC hgain_vlc;
70
 
    
71
 
    /* coded values in high bands */
72
 
    int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
73
 
    int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
74
 
 
75
 
    /* there are two possible tables for spectral coefficients */
76
 
    VLC coef_vlc[2];
77
 
    uint16_t *run_table[2];
78
 
    uint16_t *level_table[2];
79
 
    /* frame info */
80
 
    int frame_len;       /* frame length in samples */
81
 
    int frame_len_bits;  /* frame_len = 1 << frame_len_bits */
82
 
    int nb_block_sizes;  /* number of block sizes */
83
 
    /* block info */
84
 
    int reset_block_lengths;
85
 
    int block_len_bits; /* log2 of current block length */
86
 
    int next_block_len_bits; /* log2 of next block length */
87
 
    int prev_block_len_bits; /* log2 of prev block length */
88
 
    int block_len; /* block length in samples */
89
 
    int block_num; /* block number in current frame */
90
 
    int block_pos; /* current position in frame */
91
 
    uint8_t ms_stereo; /* true if mid/side stereo mode */
92
 
    uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */
93
 
    float exponents[MAX_CHANNELS][BLOCK_MAX_SIZE] __attribute__((aligned(16)));
94
 
    float max_exponent[MAX_CHANNELS];
95
 
    int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
96
 
    float coefs[MAX_CHANNELS][BLOCK_MAX_SIZE] __attribute__((aligned(16)));
97
 
    MDCTContext mdct_ctx[BLOCK_NB_SIZES];
98
 
    float *windows[BLOCK_NB_SIZES];
99
 
    FFTSample mdct_tmp[BLOCK_MAX_SIZE] __attribute__((aligned(16))); /* temporary storage for imdct */
100
 
    /* output buffer for one frame and the last for IMDCT windowing */
101
 
    float frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2] __attribute__((aligned(16)));
102
 
    /* last frame info */
103
 
    uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
104
 
    int last_bitoffset;
105
 
    int last_superframe_len;
106
 
    float noise_table[NOISE_TAB_SIZE];
107
 
    int noise_index;
108
 
    float noise_mult; /* XXX: suppress that and integrate it in the noise array */
109
 
    /* lsp_to_curve tables */
110
 
    float lsp_cos_table[BLOCK_MAX_SIZE];
111
 
    float lsp_pow_e_table[256];
112
 
    float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
113
 
    float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
114
 
 
115
 
#ifdef TRACE
116
 
    int frame_count;
117
 
#endif
118
 
} WMADecodeContext;
119
 
 
120
 
typedef struct CoefVLCTable {
121
 
    int n; /* total number of codes */
122
 
    const uint32_t *huffcodes; /* VLC bit values */
123
 
    const uint8_t *huffbits;   /* VLC bit size */
124
 
    const uint16_t *levels; /* table to build run/level tables */
125
 
} CoefVLCTable;
126
 
 
127
 
static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len);
128
 
 
129
 
#include "wmadata.h"
130
 
 
131
 
#ifdef TRACE
132
 
static void dump_shorts(const char *name, const short *tab, int n)
 
37
#include "wma.h"
 
38
 
 
39
#undef NDEBUG
 
40
#include <assert.h>
 
41
 
 
42
#define EXPVLCBITS 8
 
43
#define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS)
 
44
 
 
45
#define HGAINVLCBITS 9
 
46
#define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS)
 
47
 
 
48
static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len);
 
49
 
 
50
#ifdef TRACE
 
51
static void dump_shorts(WMADecodeContext *s, const char *name, const short *tab, int n)
133
52
{
134
53
    int i;
135
54
 
136
 
    tprintf("%s[%d]:\n", name, n);
 
55
    tprintf(s->avctx, "%s[%d]:\n", name, n);
137
56
    for(i=0;i<n;i++) {
138
57
        if ((i & 7) == 0)
139
 
            tprintf("%4d: ", i);
140
 
        tprintf(" %5d.0", tab[i]);
 
58
            tprintf(s->avctx, "%4d: ", i);
 
59
        tprintf(s->avctx, " %5d.0", tab[i]);
141
60
        if ((i & 7) == 7)
142
 
            tprintf("\n");
 
61
            tprintf(s->avctx, "\n");
143
62
    }
144
63
}
145
64
 
146
 
static void dump_floats(const char *name, int prec, const float *tab, int n)
 
65
static void dump_floats(WMADecodeContext *s, const char *name, int prec, const float *tab, int n)
147
66
{
148
67
    int i;
149
68
 
150
 
    tprintf("%s[%d]:\n", name, n);
 
69
    tprintf(s->avctx, "%s[%d]:\n", name, n);
151
70
    for(i=0;i<n;i++) {
152
71
        if ((i & 7) == 0)
153
 
            tprintf("%4d: ", i);
154
 
        tprintf(" %8.*f", prec, tab[i]);
 
72
            tprintf(s->avctx, "%4d: ", i);
 
73
        tprintf(s->avctx, " %8.*f", prec, tab[i]);
155
74
        if ((i & 7) == 7)
156
 
            tprintf("\n");
 
75
            tprintf(s->avctx, "\n");
157
76
    }
158
77
    if ((i & 7) != 0)
159
 
        tprintf("\n");
 
78
        tprintf(s->avctx, "\n");
160
79
}
161
80
#endif
162
81
 
163
 
/* XXX: use same run/length optimization as mpeg decoders */
164
 
static void init_coef_vlc(VLC *vlc, 
165
 
                          uint16_t **prun_table, uint16_t **plevel_table,
166
 
                          const CoefVLCTable *vlc_table)
167
 
{
168
 
    int n = vlc_table->n;
169
 
    const uint8_t *table_bits = vlc_table->huffbits;
170
 
    const uint32_t *table_codes = vlc_table->huffcodes;
171
 
    const uint16_t *levels_table = vlc_table->levels;
172
 
    uint16_t *run_table, *level_table;
173
 
    const uint16_t *p;
174
 
    int i, l, j, level;
175
 
 
176
 
    init_vlc(vlc, 9, n, table_bits, 1, 1, table_codes, 4, 4);
177
 
 
178
 
    run_table = av_malloc(n * sizeof(uint16_t));
179
 
    level_table = av_malloc(n * sizeof(uint16_t));
180
 
    p = levels_table;
181
 
    i = 2;
182
 
    level = 1;
183
 
    while (i < n) {
184
 
        l = *p++;
185
 
        for(j=0;j<l;j++) {
186
 
            run_table[i] = j;
187
 
            level_table[i] = level;
188
 
            i++;
189
 
        }
190
 
        level++;
191
 
    }
192
 
    *prun_table = run_table;
193
 
    *plevel_table = level_table;
194
 
}
195
 
 
196
82
static int wma_decode_init(AVCodecContext * avctx)
197
83
{
198
 
    WMADecodeContext *s = avctx->priv_data;
 
84
    WMACodecContext *s = avctx->priv_data;
199
85
    int i, flags1, flags2;
200
 
    float *window;
201
86
    uint8_t *extradata;
202
 
    float bps1, high_freq, bps;
203
 
    int sample_rate1;
204
 
    int coef_vlc_table;
205
 
    
206
 
    s->sample_rate = avctx->sample_rate;
207
 
    s->nb_channels = avctx->channels;
208
 
    s->bit_rate = avctx->bit_rate;
209
 
    s->block_align = avctx->block_align;
210
 
 
211
 
    if (avctx->codec->id == CODEC_ID_WMAV1) {
212
 
        s->version = 1;
213
 
    } else {
214
 
        s->version = 2;
215
 
    }
216
 
    
 
87
 
 
88
    s->avctx = avctx;
 
89
 
217
90
    /* extract flag infos */
218
91
    flags1 = 0;
219
92
    flags2 = 0;
220
93
    extradata = avctx->extradata;
221
 
    if (s->version == 1 && avctx->extradata_size >= 4) {
 
94
    if (avctx->codec->id == CODEC_ID_WMAV1 && avctx->extradata_size >= 4) {
222
95
        flags1 = extradata[0] | (extradata[1] << 8);
223
96
        flags2 = extradata[2] | (extradata[3] << 8);
224
 
    } else if (s->version == 2 && avctx->extradata_size >= 6) {
225
 
        flags1 = extradata[0] | (extradata[1] << 8) | 
 
97
    } else if (avctx->codec->id == CODEC_ID_WMAV2 && avctx->extradata_size >= 6) {
 
98
        flags1 = extradata[0] | (extradata[1] << 8) |
226
99
            (extradata[2] << 16) | (extradata[3] << 24);
227
100
        flags2 = extradata[4] | (extradata[5] << 8);
228
101
    }
 
102
// for(i=0; i<avctx->extradata_size; i++)
 
103
//     av_log(NULL, AV_LOG_ERROR, "%02X ", extradata[i]);
 
104
 
229
105
    s->use_exp_vlc = flags2 & 0x0001;
230
106
    s->use_bit_reservoir = flags2 & 0x0002;
231
107
    s->use_variable_block_len = flags2 & 0x0004;
232
108
 
233
 
    /* compute MDCT block size */
234
 
    if (s->sample_rate <= 16000) {
235
 
        s->frame_len_bits = 9;
236
 
    } else if (s->sample_rate <= 22050 || 
237
 
               (s->sample_rate <= 32000 && s->version == 1)) {
238
 
        s->frame_len_bits = 10;
239
 
    } else {
240
 
        s->frame_len_bits = 11;
241
 
    }
242
 
    s->frame_len = 1 << s->frame_len_bits;
243
 
    if (s->use_variable_block_len) {
244
 
        int nb_max, nb;
245
 
        nb = ((flags2 >> 3) & 3) + 1;
246
 
        if ((s->bit_rate / s->nb_channels) >= 32000)
247
 
            nb += 2;
248
 
        nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
249
 
        if (nb > nb_max)
250
 
            nb = nb_max;
251
 
        s->nb_block_sizes = nb + 1;
252
 
    } else {
253
 
        s->nb_block_sizes = 1;
254
 
    }
255
 
 
256
 
    /* init rate dependant parameters */
257
 
    s->use_noise_coding = 1;
258
 
    high_freq = s->sample_rate * 0.5;
259
 
 
260
 
    /* if version 2, then the rates are normalized */
261
 
    sample_rate1 = s->sample_rate;
262
 
    if (s->version == 2) {
263
 
        if (sample_rate1 >= 44100) 
264
 
            sample_rate1 = 44100;
265
 
        else if (sample_rate1 >= 22050) 
266
 
            sample_rate1 = 22050;
267
 
        else if (sample_rate1 >= 16000) 
268
 
            sample_rate1 = 16000;
269
 
        else if (sample_rate1 >= 11025) 
270
 
            sample_rate1 = 11025;
271
 
        else if (sample_rate1 >= 8000) 
272
 
            sample_rate1 = 8000;
273
 
    }
274
 
 
275
 
    bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
276
 
    s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0)) + 2;
277
 
 
278
 
    /* compute high frequency value and choose if noise coding should
279
 
       be activated */
280
 
    bps1 = bps;
281
 
    if (s->nb_channels == 2)
282
 
        bps1 = bps * 1.6;
283
 
    if (sample_rate1 == 44100) {
284
 
        if (bps1 >= 0.61)
285
 
            s->use_noise_coding = 0;
286
 
        else
287
 
            high_freq = high_freq * 0.4;
288
 
    } else if (sample_rate1 == 22050) {
289
 
        if (bps1 >= 1.16)
290
 
            s->use_noise_coding = 0;
291
 
        else if (bps1 >= 0.72) 
292
 
            high_freq = high_freq * 0.7;
293
 
        else
294
 
            high_freq = high_freq * 0.6;
295
 
    } else if (sample_rate1 == 16000) {
296
 
        if (bps > 0.5)
297
 
            high_freq = high_freq * 0.5;
298
 
        else
299
 
            high_freq = high_freq * 0.3;
300
 
    } else if (sample_rate1 == 11025) {
301
 
        high_freq = high_freq * 0.7;
302
 
    } else if (sample_rate1 == 8000) {
303
 
        if (bps <= 0.625) {
304
 
            high_freq = high_freq * 0.5;
305
 
        } else if (bps > 0.75) {
306
 
            s->use_noise_coding = 0;
307
 
        } else {
308
 
            high_freq = high_freq * 0.65;
309
 
        }
310
 
    } else {
311
 
        if (bps >= 0.8) {
312
 
            high_freq = high_freq * 0.75;
313
 
        } else if (bps >= 0.6) {
314
 
            high_freq = high_freq * 0.6;
315
 
        } else {
316
 
            high_freq = high_freq * 0.5;
317
 
        }
318
 
    }
319
 
    dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
320
 
    dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
321
 
           s->version, s->nb_channels, s->sample_rate, s->bit_rate, 
322
 
           s->block_align);
323
 
    dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n", 
324
 
           bps, bps1, high_freq, s->byte_offset_bits);
325
 
    dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
326
 
           s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
327
 
 
328
 
    /* compute the scale factor band sizes for each MDCT block size */
329
 
    {
330
 
        int a, b, pos, lpos, k, block_len, i, j, n;
331
 
        const uint8_t *table;
332
 
        
333
 
        if (s->version == 1) {
334
 
            s->coefs_start = 3;
335
 
        } else {
336
 
            s->coefs_start = 0;
337
 
        }
338
 
        for(k = 0; k < s->nb_block_sizes; k++) {
339
 
            block_len = s->frame_len >> k;
340
 
 
341
 
            if (s->version == 1) {
342
 
                lpos = 0;
343
 
                for(i=0;i<25;i++) {
344
 
                    a = wma_critical_freqs[i];
345
 
                    b = s->sample_rate;
346
 
                    pos = ((block_len * 2 * a)  + (b >> 1)) / b;
347
 
                    if (pos > block_len) 
348
 
                        pos = block_len;
349
 
                    s->exponent_bands[0][i] = pos - lpos;
350
 
                    if (pos >= block_len) {
351
 
                        i++;
352
 
                        break;
353
 
                    }
354
 
                    lpos = pos;
355
 
                }
356
 
                s->exponent_sizes[0] = i;
357
 
            } else {
358
 
                /* hardcoded tables */
359
 
                table = NULL;
360
 
                a = s->frame_len_bits - BLOCK_MIN_BITS - k;
361
 
                if (a < 3) {
362
 
                    if (s->sample_rate >= 44100)
363
 
                        table = exponent_band_44100[a];
364
 
                    else if (s->sample_rate >= 32000)
365
 
                        table = exponent_band_32000[a];
366
 
                    else if (s->sample_rate >= 22050)
367
 
                        table = exponent_band_22050[a];
368
 
                }
369
 
                if (table) {
370
 
                    n = *table++;
371
 
                    for(i=0;i<n;i++)
372
 
                        s->exponent_bands[k][i] = table[i];
373
 
                    s->exponent_sizes[k] = n;
374
 
                } else {
375
 
                    j = 0;
376
 
                    lpos = 0;
377
 
                    for(i=0;i<25;i++) {
378
 
                        a = wma_critical_freqs[i];
379
 
                        b = s->sample_rate;
380
 
                        pos = ((block_len * 2 * a)  + (b << 1)) / (4 * b);
381
 
                        pos <<= 2;
382
 
                        if (pos > block_len) 
383
 
                            pos = block_len;
384
 
                        if (pos > lpos)
385
 
                            s->exponent_bands[k][j++] = pos - lpos;
386
 
                        if (pos >= block_len)
387
 
                            break;
388
 
                        lpos = pos;
389
 
                    }
390
 
                    s->exponent_sizes[k] = j;
391
 
                }
392
 
            }
393
 
 
394
 
            /* max number of coefs */
395
 
            s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
396
 
            /* high freq computation */
397
 
            s->high_band_start[k] = (int)((block_len * 2 * high_freq) / 
398
 
                                          s->sample_rate + 0.5);
399
 
            n = s->exponent_sizes[k];
400
 
            j = 0;
401
 
            pos = 0;
402
 
            for(i=0;i<n;i++) {
403
 
                int start, end;
404
 
                start = pos;
405
 
                pos += s->exponent_bands[k][i];
406
 
                end = pos;
407
 
                if (start < s->high_band_start[k])
408
 
                    start = s->high_band_start[k];
409
 
                if (end > s->coefs_end[k])
410
 
                    end = s->coefs_end[k];
411
 
                if (end > start)
412
 
                    s->exponent_high_bands[k][j++] = end - start;
413
 
            }
414
 
            s->exponent_high_sizes[k] = j;
415
 
#if 0
416
 
            tprintf("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
417
 
                  s->frame_len >> k, 
418
 
                  s->coefs_end[k],
419
 
                  s->high_band_start[k],
420
 
                  s->exponent_high_sizes[k]);
421
 
            for(j=0;j<s->exponent_high_sizes[k];j++)
422
 
                tprintf(" %d", s->exponent_high_bands[k][j]);
423
 
            tprintf("\n");
424
 
#endif
425
 
        }
426
 
    }
427
 
 
428
 
#ifdef TRACE
429
 
    {
430
 
        int i, j;
431
 
        for(i = 0; i < s->nb_block_sizes; i++) {
432
 
            tprintf("%5d: n=%2d:", 
433
 
                   s->frame_len >> i, 
434
 
                   s->exponent_sizes[i]);
435
 
            for(j=0;j<s->exponent_sizes[i];j++)
436
 
                tprintf(" %d", s->exponent_bands[i][j]);
437
 
            tprintf("\n");
438
 
        }
439
 
    }
440
 
#endif
 
109
    ff_wma_init(avctx, flags2);
441
110
 
442
111
    /* init MDCT */
443
112
    for(i = 0; i < s->nb_block_sizes; i++)
444
113
        ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
445
 
    
446
 
    /* init MDCT windows : simple sinus window */
447
 
    for(i = 0; i < s->nb_block_sizes; i++) {
448
 
        int n, j;
449
 
        float alpha;
450
 
        n = 1 << (s->frame_len_bits - i);
451
 
        window = av_malloc(sizeof(float) * n);
452
 
        alpha = M_PI / (2.0 * n);
453
 
        for(j=0;j<n;j++) {
454
 
            window[n - j - 1] = sin((j + 0.5) * alpha);
455
 
        }
456
 
        s->windows[i] = window;
457
 
    }
458
114
 
459
 
    s->reset_block_lengths = 1;
460
 
    
461
115
    if (s->use_noise_coding) {
462
 
 
463
 
        /* init the noise generator */
464
 
        if (s->use_exp_vlc)
465
 
            s->noise_mult = 0.02;
466
 
        else
467
 
            s->noise_mult = 0.04;
468
 
               
469
 
#ifdef TRACE
470
 
        for(i=0;i<NOISE_TAB_SIZE;i++)
471
 
            s->noise_table[i] = 1.0 * s->noise_mult;
472
 
#else
473
 
        {
474
 
            unsigned int seed;
475
 
            float norm;
476
 
            seed = 1;
477
 
            norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
478
 
            for(i=0;i<NOISE_TAB_SIZE;i++) {
479
 
                seed = seed * 314159 + 1;
480
 
                s->noise_table[i] = (float)((int)seed) * norm;
481
 
            }
482
 
        }
483
 
#endif
484
 
        init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits), 
485
 
                 hgain_huffbits, 1, 1,
486
 
                 hgain_huffcodes, 2, 2);
 
116
        init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits),
 
117
                 ff_wma_hgain_huffbits, 1, 1,
 
118
                 ff_wma_hgain_huffcodes, 2, 2, 0);
487
119
    }
488
120
 
489
121
    if (s->use_exp_vlc) {
490
 
        init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits), 
491
 
                 scale_huffbits, 1, 1,
492
 
                 scale_huffcodes, 4, 4);
 
122
        init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(ff_wma_scale_huffbits), //FIXME move out of context
 
123
                 ff_wma_scale_huffbits, 1, 1,
 
124
                 ff_wma_scale_huffcodes, 4, 4, 0);
493
125
    } else {
494
126
        wma_lsp_to_curve_init(s, s->frame_len);
495
127
    }
496
128
 
497
 
    /* choose the VLC tables for the coefficients */
498
 
    coef_vlc_table = 2;
499
 
    if (s->sample_rate >= 32000) {
500
 
        if (bps1 < 0.72)
501
 
            coef_vlc_table = 0;
502
 
        else if (bps1 < 1.16)
503
 
            coef_vlc_table = 1;
504
 
    }
505
 
 
506
 
    init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
507
 
                  &coef_vlcs[coef_vlc_table * 2]);
508
 
    init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
509
 
                  &coef_vlcs[coef_vlc_table * 2 + 1]);
510
129
    return 0;
511
130
}
512
131
 
513
 
/* interpolate values for a bigger or smaller block. The block must
514
 
   have multiple sizes */
 
132
/**
 
133
 * interpolate values for a bigger or smaller block. The block must
 
134
 * have multiple sizes
 
135
 */
515
136
static void interpolate_array(float *scale, int old_size, int new_size)
516
137
{
517
138
    int i, j, jincr, k;
537
158
    }
538
159
}
539
160
 
540
 
/* compute x^-0.25 with an exponent and mantissa table. We use linear
541
 
   interpolation to reduce the mantissa table size at a small speed
542
 
   expense (linear interpolation approximately doubles the number of
543
 
   bits of precision). */
544
 
static inline float pow_m1_4(WMADecodeContext *s, float x)
 
161
/**
 
162
 * compute x^-0.25 with an exponent and mantissa table. We use linear
 
163
 * interpolation to reduce the mantissa table size at a small speed
 
164
 * expense (linear interpolation approximately doubles the number of
 
165
 * bits of precision).
 
166
 */
 
167
static inline float pow_m1_4(WMACodecContext *s, float x)
545
168
{
546
169
    union {
547
170
        float f;
560
183
    return s->lsp_pow_e_table[e] * (a + b * t.f);
561
184
}
562
185
 
563
 
static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len)
564
 
{  
 
186
static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len)
 
187
{
565
188
    float wdel, a, b;
566
189
    int i, e, m;
567
190
 
597
220
#endif
598
221
}
599
222
 
600
 
/* NOTE: We use the same code as Vorbis here */
601
 
/* XXX: optimize it further with SSE/3Dnow */
602
 
static void wma_lsp_to_curve(WMADecodeContext *s, 
603
 
                             float *out, float *val_max_ptr, 
 
223
/**
 
224
 * NOTE: We use the same code as Vorbis here
 
225
 * @todo optimize it further with SSE/3Dnow
 
226
 */
 
227
static void wma_lsp_to_curve(WMACodecContext *s,
 
228
                             float *out, float *val_max_ptr,
604
229
                             int n, float *lsp)
605
230
{
606
231
    int i, j;
626
251
    *val_max_ptr = val_max;
627
252
}
628
253
 
629
 
/* decode exponents coded with LSP coefficients (same idea as Vorbis) */
630
 
static void decode_exp_lsp(WMADecodeContext *s, int ch)
 
254
/**
 
255
 * decode exponents coded with LSP coefficients (same idea as Vorbis)
 
256
 */
 
257
static void decode_exp_lsp(WMACodecContext *s, int ch)
631
258
{
632
259
    float lsp_coefs[NB_LSP_COEFS];
633
260
    int val, i;
637
264
            val = get_bits(&s->gb, 3);
638
265
        else
639
266
            val = get_bits(&s->gb, 4);
640
 
        lsp_coefs[i] = lsp_codebook[i][val];
 
267
        lsp_coefs[i] = ff_wma_lsp_codebook[i][val];
641
268
    }
642
269
 
643
270
    wma_lsp_to_curve(s, s->exponents[ch], &s->max_exponent[ch],
644
271
                     s->block_len, lsp_coefs);
645
272
}
646
273
 
647
 
/* decode exponents coded with VLC codes */
648
 
static int decode_exp_vlc(WMADecodeContext *s, int ch)
 
274
/**
 
275
 * decode exponents coded with VLC codes
 
276
 */
 
277
static int decode_exp_vlc(WMACodecContext *s, int ch)
649
278
{
650
279
    int last_exp, n, code;
651
280
    const uint16_t *ptr, *band_ptr;
652
281
    float v, *q, max_scale, *q_end;
653
 
    
 
282
 
654
283
    band_ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
655
284
    ptr = band_ptr;
656
285
    q = s->exponents[ch];
665
294
        do {
666
295
            *q++ = v;
667
296
        } while (--n);
668
 
    }
669
 
    last_exp = 36;
 
297
    }else
 
298
        last_exp = 36;
 
299
 
670
300
    while (q < q_end) {
671
 
        code = get_vlc(&s->gb, &s->exp_vlc);
 
301
        code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX);
672
302
        if (code < 0)
673
303
            return -1;
674
304
        /* NOTE: this offset is the same as MPEG4 AAC ! */
686
316
    return 0;
687
317
}
688
318
 
689
 
/* return 0 if OK. return 1 if last block of frame. return -1 if
690
 
   unrecorrable error. */
691
 
static int wma_decode_block(WMADecodeContext *s)
 
319
/**
 
320
 * @return 0 if OK. 1 if last block of frame. return -1 if
 
321
 * unrecorrable error.
 
322
 */
 
323
static int wma_decode_block(WMACodecContext *s)
692
324
{
693
325
    int n, v, a, ch, code, bsize;
694
326
    int coef_nb_bits, total_gain, parse_exponents;
695
 
    float window[BLOCK_MAX_SIZE * 2];
696
327
    int nb_coefs[MAX_CHANNELS];
697
328
    float mdct_norm;
698
329
 
699
330
#ifdef TRACE
700
 
    tprintf("***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
 
331
    tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num);
701
332
#endif
702
333
 
703
334
    /* compute current block length */
704
335
    if (s->use_variable_block_len) {
705
336
        n = av_log2(s->nb_block_sizes - 1) + 1;
706
 
    
 
337
 
707
338
        if (s->reset_block_lengths) {
708
339
            s->reset_block_lengths = 0;
709
340
            v = get_bits(&s->gb, n);
760
391
        if (a != 127)
761
392
            break;
762
393
    }
763
 
    
764
 
    if (total_gain < 15)
765
 
        coef_nb_bits = 13;
766
 
    else if (total_gain < 32)
767
 
        coef_nb_bits = 12;
768
 
    else if (total_gain < 40)
769
 
        coef_nb_bits = 11;
770
 
    else if (total_gain < 45)
771
 
        coef_nb_bits = 10;
772
 
    else
773
 
        coef_nb_bits = 9;
 
394
 
 
395
    coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
774
396
 
775
397
    /* compute number of coefficients */
776
398
    n = s->coefs_end[bsize] - s->coefs_start;
804
426
                        if (val == (int)0x80000000) {
805
427
                            val = get_bits(&s->gb, 7) - 19;
806
428
                        } else {
807
 
                            code = get_vlc(&s->gb, &s->hgain_vlc);
 
429
                            code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX);
808
430
                            if (code < 0)
809
431
                                return -1;
810
432
                            val += code - 18;
815
437
            }
816
438
        }
817
439
    }
818
 
           
 
440
 
819
441
    /* exposant can be interpolated in short blocks. */
820
442
    parse_exponents = 1;
821
443
    if (s->block_len_bits != s->frame_len_bits) {
822
444
        parse_exponents = get_bits(&s->gb, 1);
823
445
    }
824
 
    
 
446
 
825
447
    if (parse_exponents) {
826
448
        for(ch = 0; ch < s->nb_channels; ch++) {
827
449
            if (s->channel_coded[ch]) {
836
458
    } else {
837
459
        for(ch = 0; ch < s->nb_channels; ch++) {
838
460
            if (s->channel_coded[ch]) {
839
 
                interpolate_array(s->exponents[ch], 1 << s->prev_block_len_bits, 
 
461
                interpolate_array(s->exponents[ch], 1 << s->prev_block_len_bits,
840
462
                                  s->block_len);
841
463
            }
842
464
        }
848
470
            VLC *coef_vlc;
849
471
            int level, run, sign, tindex;
850
472
            int16_t *ptr, *eptr;
851
 
            const int16_t *level_table, *run_table;
 
473
            const uint16_t *level_table, *run_table;
852
474
 
853
475
            /* special VLC tables are used for ms stereo because
854
476
               there is potentially less energy there */
861
483
            eptr = ptr + nb_coefs[ch];
862
484
            memset(ptr, 0, s->block_len * sizeof(int16_t));
863
485
            for(;;) {
864
 
                code = get_vlc(&s->gb, coef_vlc);
 
486
                code = get_vlc2(&s->gb, coef_vlc->table, VLCBITS, VLCMAX);
865
487
                if (code < 0)
866
488
                    return -1;
867
489
                if (code == 1) {
883
505
                    level = -level;
884
506
                ptr += run;
885
507
                if (ptr >= eptr)
886
 
                    return -1;
 
508
                {
 
509
                    av_log(NULL, AV_LOG_ERROR, "overflow in spectral RLE, ignoring\n");
 
510
                    break;
 
511
                }
887
512
                *ptr++ = level;
888
513
                /* NOTE: EOB can be omitted */
889
514
                if (ptr >= eptr)
894
519
            align_get_bits(&s->gb);
895
520
        }
896
521
    }
897
 
     
 
522
 
898
523
    /* normalize */
899
524
    {
900
525
        int n4 = s->block_len / 2;
924
549
                    *coefs++ = s->noise_table[s->noise_index] * (*exponents++) * mult1;
925
550
                    s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
926
551
                }
927
 
                
 
552
 
928
553
                n1 = s->exponent_high_sizes[bsize];
929
554
 
930
555
                /* compute power of high bands */
931
 
                exp_ptr = exponents + 
932
 
                    s->high_band_start[bsize] - 
 
556
                exp_ptr = exponents +
 
557
                    s->high_band_start[bsize] -
933
558
                    s->coefs_start;
934
559
                last_high_band = 0; /* avoid warning */
935
560
                for(j=0;j<n1;j++) {
936
 
                    n = s->exponent_high_bands[s->frame_len_bits - 
 
561
                    n = s->exponent_high_bands[s->frame_len_bits -
937
562
                                              s->block_len_bits][j];
938
563
                    if (s->high_band_coded[ch][j]) {
939
564
                        float e2, v;
944
569
                        }
945
570
                        exp_power[j] = e2 / n;
946
571
                        last_high_band = j;
947
 
                        tprintf("%d: power=%f (%d)\n", j, exp_power[j], n);
 
572
                        tprintf(s->avctx, "%d: power=%f (%d)\n", j, exp_power[j], n);
948
573
                    }
949
574
                    exp_ptr += n;
950
575
                }
952
577
                /* main freqs and high freqs */
953
578
                for(j=-1;j<n1;j++) {
954
579
                    if (j < 0) {
955
 
                        n = s->high_band_start[bsize] - 
 
580
                        n = s->high_band_start[bsize] -
956
581
                            s->coefs_start;
957
582
                    } else {
958
 
                        n = s->exponent_high_bands[s->frame_len_bits - 
 
583
                        n = s->exponent_high_bands[s->frame_len_bits -
959
584
                                                  s->block_len_bits][j];
960
585
                    }
961
586
                    if (j >= 0 && s->high_band_coded[ch][j]) {
1005
630
#ifdef TRACE
1006
631
    for(ch = 0; ch < s->nb_channels; ch++) {
1007
632
        if (s->channel_coded[ch]) {
1008
 
            dump_floats("exponents", 3, s->exponents[ch], s->block_len);
1009
 
            dump_floats("coefs", 1, s->coefs[ch], s->block_len);
 
633
            dump_floats(s, "exponents", 3, s->exponents[ch], s->block_len);
 
634
            dump_floats(s, "coefs", 1, s->coefs[ch], s->block_len);
1010
635
        }
1011
636
    }
1012
637
#endif
1013
 
    
 
638
 
1014
639
    if (s->ms_stereo && s->channel_coded[1]) {
1015
640
        float a, b;
1016
641
        int i;
1019
644
        /* no need to optimize this case because it should almost
1020
645
           never happen */
1021
646
        if (!s->channel_coded[0]) {
1022
 
            tprintf("rare ms-stereo case happened\n");
 
647
            tprintf(s->avctx, "rare ms-stereo case happened\n");
1023
648
            memset(s->coefs[0], 0, sizeof(float) * s->block_len);
1024
649
            s->channel_coded[0] = 1;
1025
650
        }
1026
 
        
 
651
 
1027
652
        for(i = 0; i < s->block_len; i++) {
1028
653
            a = s->coefs[0][i];
1029
654
            b = s->coefs[1][i];
1044
669
        next_block_len = 1 << s->next_block_len_bits;
1045
670
 
1046
671
        /* right part */
1047
 
        wptr = window + block_len;
 
672
        wptr = s->window + block_len;
1048
673
        if (block_len <= next_block_len) {
1049
674
            for(i=0;i<block_len;i++)
1050
675
                *wptr++ = s->windows[bsize][i];
1060
685
        }
1061
686
 
1062
687
        /* left part */
1063
 
        wptr = window + block_len;
 
688
        wptr = s->window + block_len;
1064
689
        if (block_len <= prev_block_len) {
1065
690
            for(i=0;i<block_len;i++)
1066
691
                *--wptr = s->windows[bsize][i];
1076
701
        }
1077
702
    }
1078
703
 
1079
 
    
 
704
 
1080
705
    for(ch = 0; ch < s->nb_channels; ch++) {
1081
706
        if (s->channel_coded[ch]) {
1082
 
            FFTSample output[BLOCK_MAX_SIZE * 2] __attribute__((aligned(16)));
1083
707
            float *ptr;
1084
 
            int i, n4, index, n;
 
708
            int n4, index, n;
1085
709
 
1086
710
            n = s->block_len;
1087
711
            n4 = s->block_len / 2;
1088
 
            ff_imdct_calc(&s->mdct_ctx[bsize], 
1089
 
                          output, s->coefs[ch], s->mdct_tmp);
 
712
            s->mdct_ctx[bsize].fft.imdct_calc(&s->mdct_ctx[bsize],
 
713
                          s->output, s->coefs[ch], s->mdct_tmp);
1090
714
 
1091
715
            /* XXX: optimize all that by build the window and
1092
716
               multipying/adding at the same time */
1093
 
            /* multiply by the window */
1094
 
            for(i=0;i<n * 2;i++) {
1095
 
                output[i] *= window[i];
1096
 
            }
1097
717
 
1098
 
            /* add in the frame */
 
718
            /* multiply by the window and add in the frame */
1099
719
            index = (s->frame_len / 2) + s->block_pos - n4;
1100
720
            ptr = &s->frame_out[ch][index];
1101
 
            for(i=0;i<n * 2;i++) {
1102
 
                *ptr += output[i];
1103
 
                ptr++;
1104
 
            }
 
721
            s->dsp.vector_fmul_add_add(ptr,s->window,s->output,ptr,0,2*n,1);
1105
722
 
1106
723
            /* specific fast case for ms-stereo : add to second
1107
724
               channel if it is not coded */
1108
725
            if (s->ms_stereo && !s->channel_coded[1]) {
1109
726
                ptr = &s->frame_out[1][index];
1110
 
                for(i=0;i<n * 2;i++) {
1111
 
                    *ptr += output[i];
1112
 
                    ptr++;
1113
 
                }
 
727
                s->dsp.vector_fmul_add_add(ptr,s->window,s->output,ptr,0,2*n,1);
1114
728
            }
1115
729
        }
1116
730
    }
1125
739
}
1126
740
 
1127
741
/* decode a frame of frame_len samples */
1128
 
static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
 
742
static int wma_decode_frame(WMACodecContext *s, int16_t *samples)
1129
743
{
1130
744
    int ret, i, n, a, ch, incr;
1131
745
    int16_t *ptr;
1132
746
    float *iptr;
1133
747
 
1134
748
#ifdef TRACE
1135
 
    tprintf("***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
 
749
    tprintf(s->avctx, "***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len);
1136
750
#endif
1137
751
 
1138
752
    /* read each block */
1140
754
    s->block_pos = 0;
1141
755
    for(;;) {
1142
756
        ret = wma_decode_block(s);
1143
 
        if (ret < 0) 
 
757
        if (ret < 0)
1144
758
            return -1;
1145
759
        if (ret)
1146
760
            break;
1166
780
        memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
1167
781
                s->frame_len * sizeof(float));
1168
782
        /* XXX: suppress this */
1169
 
        memset(&s->frame_out[ch][s->frame_len], 0, 
 
783
        memset(&s->frame_out[ch][s->frame_len], 0,
1170
784
               s->frame_len * sizeof(float));
1171
785
    }
1172
786
 
1173
787
#ifdef TRACE
1174
 
    dump_shorts("samples", samples, n * s->nb_channels);
 
788
    dump_shorts(s, "samples", samples, n * s->nb_channels);
1175
789
#endif
1176
790
    return 0;
1177
791
}
1178
792
 
1179
 
static int wma_decode_superframe(AVCodecContext *avctx, 
 
793
static int wma_decode_superframe(AVCodecContext *avctx,
1180
794
                                 void *data, int *data_size,
1181
795
                                 uint8_t *buf, int buf_size)
1182
796
{
1183
 
    WMADecodeContext *s = avctx->priv_data;
 
797
    WMACodecContext *s = avctx->priv_data;
1184
798
    int nb_frames, bit_offset, i, pos, len;
1185
799
    uint8_t *q;
1186
800
    int16_t *samples;
1187
 
    
1188
 
    tprintf("***decode_superframe:\n");
 
801
 
 
802
    tprintf(avctx, "***decode_superframe:\n");
 
803
 
 
804
    if(buf_size==0){
 
805
        s->last_superframe_len = 0;
 
806
        return 0;
 
807
    }
1189
808
 
1190
809
    samples = data;
1191
810
 
1192
811
    init_get_bits(&s->gb, buf, buf_size*8);
1193
 
    
 
812
 
1194
813
    if (s->use_bit_reservoir) {
1195
814
        /* read super frame header */
1196
815
        get_bits(&s->gb, 4); /* super frame index */
1201
820
        if (s->last_superframe_len > 0) {
1202
821
            //        printf("skip=%d\n", s->last_bitoffset);
1203
822
            /* add bit_offset bits to last frame */
1204
 
            if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) > 
 
823
            if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) >
1205
824
                MAX_CODED_SUPERFRAME_SIZE)
1206
825
                goto fail;
1207
826
            q = s->last_superframe + s->last_superframe_len;
1208
827
            len = bit_offset;
1209
 
            while (len > 0) {
 
828
            while (len > 7) {
1210
829
                *q++ = (get_bits)(&s->gb, 8);
1211
830
                len -= 8;
1212
831
            }
1213
832
            if (len > 0) {
1214
833
                *q++ = (get_bits)(&s->gb, len) << (8 - len);
1215
834
            }
1216
 
            
 
835
 
1217
836
            /* XXX: bit_offset bits into last frame */
1218
837
            init_get_bits(&s->gb, s->last_superframe, MAX_CODED_SUPERFRAME_SIZE*8);
1219
838
            /* skip unused bits */
1232
851
        len = pos & 7;
1233
852
        if (len > 0)
1234
853
            skip_bits(&s->gb, len);
1235
 
    
 
854
 
1236
855
        s->reset_block_lengths = 1;
1237
856
        for(i=0;i<nb_frames;i++) {
1238
857
            if (wma_decode_frame(s, samples) < 0)
1256
875
            goto fail;
1257
876
        samples += s->nb_channels * s->frame_len;
1258
877
    }
 
878
 
 
879
//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d outbytes:%d eaten:%d\n", s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len,        (int8_t *)samples - (int8_t *)data, s->block_align);
 
880
 
1259
881
    *data_size = (int8_t *)samples - (int8_t *)data;
1260
882
    return s->block_align;
1261
883
 fail:
1264
886
    return -1;
1265
887
}
1266
888
 
1267
 
static int wma_decode_end(AVCodecContext *avctx)
1268
 
{
1269
 
    WMADecodeContext *s = avctx->priv_data;
1270
 
    int i;
1271
 
 
1272
 
    for(i = 0; i < s->nb_block_sizes; i++)
1273
 
        ff_mdct_end(&s->mdct_ctx[i]);
1274
 
    for(i = 0; i < s->nb_block_sizes; i++)
1275
 
        av_free(s->windows[i]);
1276
 
 
1277
 
    if (s->use_exp_vlc) {
1278
 
        free_vlc(&s->exp_vlc);
1279
 
    }
1280
 
    if (s->use_noise_coding) {
1281
 
        free_vlc(&s->hgain_vlc);
1282
 
    }
1283
 
    for(i = 0;i < 2; i++) {
1284
 
        free_vlc(&s->coef_vlc[i]);
1285
 
        av_free(s->run_table[i]);
1286
 
        av_free(s->level_table[i]);
1287
 
    }
1288
 
    
1289
 
    return 0;
1290
 
}
1291
 
 
1292
889
AVCodec wmav1_decoder =
1293
890
{
1294
891
    "wmav1",
1295
892
    CODEC_TYPE_AUDIO,
1296
893
    CODEC_ID_WMAV1,
1297
 
    sizeof(WMADecodeContext),
 
894
    sizeof(WMACodecContext),
1298
895
    wma_decode_init,
1299
896
    NULL,
1300
 
    wma_decode_end,
 
897
    ff_wma_end,
1301
898
    wma_decode_superframe,
1302
899
};
1303
900
 
1306
903
    "wmav2",
1307
904
    CODEC_TYPE_AUDIO,
1308
905
    CODEC_ID_WMAV2,
1309
 
    sizeof(WMADecodeContext),
 
906
    sizeof(WMACodecContext),
1310
907
    wma_decode_init,
1311
908
    NULL,
1312
 
    wma_decode_end,
 
909
    ff_wma_end,
1313
910
    wma_decode_superframe,
1314
911
};