FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/wmadec.c
Date: 2021-09-24 20:55:06
Exec Total Coverage
Lines: 229 461 49.7%
Branches: 127 276 46.0%

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