You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1340 lines
41KB

  1. /*
  2. * WMA compatible decoder
  3. * Copyright (c) 2002 The FFmpeg Project.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * 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. */
  19. #include "avcodec.h"
  20. #include "dsputil.h"
  21. //#define DEBUG_PARAMS
  22. //#define DEBUG_TRACE
  23. /* size of blocks */
  24. #define BLOCK_MIN_BITS 7
  25. #define BLOCK_MAX_BITS 11
  26. #define BLOCK_MAX_SIZE (1 << BLOCK_MAX_BITS)
  27. #define BLOCK_NB_SIZES (BLOCK_MAX_BITS - BLOCK_MIN_BITS + 1)
  28. /* XXX: find exact max size */
  29. #define HIGH_BAND_MAX_SIZE 16
  30. #define NB_LSP_COEFS 10
  31. /* XXX: is it a suitable value ? */
  32. #define MAX_CODED_SUPERFRAME_SIZE 4096
  33. #define MAX_CHANNELS 2
  34. #define NOISE_TAB_SIZE 8192
  35. #define LSP_POW_BITS 7
  36. typedef struct WMADecodeContext {
  37. GetBitContext gb;
  38. int sample_rate;
  39. int nb_channels;
  40. int bit_rate;
  41. int version; /* 1 = 0x160 (WMAV1), 2 = 0x161 (WMAV2) */
  42. int block_align;
  43. int use_bit_reservoir;
  44. int use_variable_block_len;
  45. int use_exp_vlc; /* exponent coding: 0 = lsp, 1 = vlc + delta */
  46. int use_noise_coding; /* true if perceptual noise is added */
  47. int byte_offset_bits;
  48. VLC exp_vlc;
  49. int exponent_sizes[BLOCK_NB_SIZES];
  50. uint16_t exponent_bands[BLOCK_NB_SIZES][25];
  51. int high_band_start[BLOCK_NB_SIZES]; /* index of first coef in high band */
  52. int coefs_start; /* first coded coef */
  53. int coefs_end[BLOCK_NB_SIZES]; /* max number of coded coefficients */
  54. int exponent_high_sizes[BLOCK_NB_SIZES];
  55. int exponent_high_bands[BLOCK_NB_SIZES][HIGH_BAND_MAX_SIZE];
  56. VLC hgain_vlc;
  57. /* coded values in high bands */
  58. int high_band_coded[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
  59. int high_band_values[MAX_CHANNELS][HIGH_BAND_MAX_SIZE];
  60. /* there are two possible tables for spectral coefficients */
  61. VLC coef_vlc[2];
  62. uint16_t *run_table[2];
  63. uint16_t *level_table[2];
  64. /* frame info */
  65. int frame_len; /* frame length in samples */
  66. int frame_len_bits; /* frame_len = 1 << frame_len_bits */
  67. int nb_block_sizes; /* number of block sizes */
  68. /* block info */
  69. int reset_block_lengths;
  70. int block_len_bits; /* log2 of current block length */
  71. int next_block_len_bits; /* log2 of next block length */
  72. int prev_block_len_bits; /* log2 of prev block length */
  73. int block_len; /* block length in samples */
  74. int block_num; /* block number in current frame */
  75. int block_pos; /* current position in frame */
  76. uint8_t ms_stereo; /* true if mid/side stereo mode */
  77. uint8_t channel_coded[MAX_CHANNELS]; /* true if channel is coded */
  78. float exponents[MAX_CHANNELS][BLOCK_MAX_SIZE];
  79. float max_exponent[MAX_CHANNELS];
  80. int16_t coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
  81. float coefs[MAX_CHANNELS][BLOCK_MAX_SIZE];
  82. MDCTContext mdct_ctx[BLOCK_NB_SIZES];
  83. float *windows[BLOCK_NB_SIZES];
  84. FFTSample mdct_tmp[BLOCK_MAX_SIZE]; /* temporary storage for imdct */
  85. /* output buffer for one frame and the last for IMDCT windowing */
  86. float frame_out[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
  87. /* last frame info */
  88. uint8_t last_superframe[MAX_CODED_SUPERFRAME_SIZE + 4]; /* padding added */
  89. int last_bitoffset;
  90. int last_superframe_len;
  91. float noise_table[NOISE_TAB_SIZE];
  92. int noise_index;
  93. float noise_mult; /* XXX: suppress that and integrate it in the noise array */
  94. /* lsp_to_curve tables */
  95. float lsp_cos_table[BLOCK_MAX_SIZE];
  96. float lsp_pow_e_table[256];
  97. float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
  98. float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
  99. } WMADecodeContext;
  100. typedef struct CoefVLCTable {
  101. int n; /* total number of codes */
  102. const uint32_t *huffcodes; /* VLC bit values */
  103. const uint8_t *huffbits; /* VLC bit size */
  104. const uint16_t *levels; /* table to build run/level tables */
  105. } CoefVLCTable;
  106. static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len);
  107. #include "wmadata.h"
  108. #ifdef DEBUG_TRACE
  109. int frame_count;
  110. static FILE *flog;
  111. void trace(const char *fmt, ...)
  112. {
  113. va_list ap;
  114. if (!flog) {
  115. flog = fopen("/tmp/out.log", "w");
  116. setlinebuf(flog);
  117. }
  118. va_start(ap, fmt);
  119. vfprintf(flog, fmt, ap);
  120. va_end(ap);
  121. }
  122. #define get_bits(s, n) get_bits_trace(s, n)
  123. #define get_vlc(s, vlc) get_vlc_trace(s, vlc)
  124. unsigned int get_bits_trace(GetBitContext *s, int n)
  125. {
  126. unsigned int val;
  127. val = (get_bits)(s, n);
  128. trace("get_bits(%d) : 0x%x\n", n, val);
  129. return val;
  130. }
  131. static int get_vlc_trace(GetBitContext *s, VLC *vlc)
  132. {
  133. int code;
  134. code = (get_vlc)(s, vlc);
  135. trace("get_vlc() : %d\n", code);
  136. return code;
  137. }
  138. static void dump_shorts(const char *name, const short *tab, int n)
  139. {
  140. int i;
  141. trace("%s[%d]:\n", name, n);
  142. for(i=0;i<n;i++) {
  143. if ((i & 7) == 0)
  144. trace("%4d: ", i);
  145. trace(" %5d.0", tab[i]);
  146. if ((i & 7) == 7)
  147. trace("\n");
  148. }
  149. }
  150. static void dump_floats(const char *name, int prec, const float *tab, int n)
  151. {
  152. int i;
  153. trace("%s[%d]:\n", name, n);
  154. for(i=0;i<n;i++) {
  155. if ((i & 7) == 0)
  156. trace("%4d: ", i);
  157. trace(" %8.*f", prec, tab[i]);
  158. if ((i & 7) == 7)
  159. trace("\n");
  160. }
  161. if ((i & 7) != 0)
  162. trace("\n");
  163. }
  164. #else
  165. #define trace(fmt, ...)
  166. #endif
  167. /* XXX: use same run/length optimization as mpeg decoders */
  168. static void init_coef_vlc(VLC *vlc,
  169. uint16_t **prun_table, uint16_t **plevel_table,
  170. const CoefVLCTable *vlc_table)
  171. {
  172. int n = vlc_table->n;
  173. const uint8_t *table_bits = vlc_table->huffbits;
  174. const uint32_t *table_codes = vlc_table->huffcodes;
  175. const uint16_t *levels_table = vlc_table->levels;
  176. uint16_t *run_table, *level_table;
  177. const uint16_t *p;
  178. int i, l, j, level;
  179. init_vlc(vlc, 9, n, table_bits, 1, 1, table_codes, 4, 4);
  180. run_table = malloc(n * sizeof(uint16_t));
  181. level_table = malloc(n * sizeof(uint16_t));
  182. p = levels_table;
  183. i = 2;
  184. level = 1;
  185. while (i < n) {
  186. l = *p++;
  187. for(j=0;j<l;j++) {
  188. run_table[i] = j;
  189. level_table[i] = level;
  190. i++;
  191. }
  192. level++;
  193. }
  194. *prun_table = run_table;
  195. *plevel_table = level_table;
  196. }
  197. static int wma_decode_init(AVCodecContext * avctx)
  198. {
  199. WMADecodeContext *s = avctx->priv_data;
  200. int i, flags1, flags2;
  201. float *window;
  202. uint8_t *extradata;
  203. float bps1, high_freq, bps;
  204. int sample_rate1;
  205. int coef_vlc_table;
  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. if (avctx->codec_id == CODEC_ID_WMAV1) {
  211. s->version = 1;
  212. } else {
  213. s->version = 2;
  214. }
  215. /* extract flag infos */
  216. flags1 = 0;
  217. flags2 = 0;
  218. extradata = avctx->extradata;
  219. if (s->version == 1 && avctx->extradata_size >= 4) {
  220. flags1 = extradata[0] | (extradata[1] << 8);
  221. flags2 = extradata[2] | (extradata[3] << 8);
  222. } else if (s->version == 2 && avctx->extradata_size >= 6) {
  223. flags1 = extradata[0] | (extradata[1] << 8) |
  224. (extradata[2] << 16) | (extradata[3] << 24);
  225. flags2 = extradata[4] | (extradata[5] << 8);
  226. }
  227. s->use_exp_vlc = flags2 & 0x0001;
  228. s->use_bit_reservoir = flags2 & 0x0002;
  229. s->use_variable_block_len = flags2 & 0x0004;
  230. /* compute MDCT block size */
  231. if (s->sample_rate <= 16000) {
  232. s->frame_len_bits = 9;
  233. } else if (s->sample_rate <= 32000 && s->version == 1) {
  234. s->frame_len_bits = 10;
  235. } else {
  236. s->frame_len_bits = 11;
  237. }
  238. s->frame_len = 1 << s->frame_len_bits;
  239. if (s->use_variable_block_len) {
  240. s->nb_block_sizes = s->frame_len_bits - BLOCK_MIN_BITS + 1;
  241. } else {
  242. s->nb_block_sizes = 1;
  243. }
  244. /* init rate dependant parameters */
  245. s->use_noise_coding = 1;
  246. high_freq = s->sample_rate * 0.5;
  247. /* if version 2, then the rates are normalized */
  248. sample_rate1 = s->sample_rate;
  249. if (s->version == 2) {
  250. if (sample_rate1 >= 44100)
  251. sample_rate1 = 44100;
  252. else if (sample_rate1 >= 22050)
  253. sample_rate1 = 22050;
  254. else if (sample_rate1 >= 16000)
  255. sample_rate1 = 16000;
  256. else if (sample_rate1 >= 11025)
  257. sample_rate1 = 11025;
  258. else if (sample_rate1 >= 8000)
  259. sample_rate1 = 8000;
  260. }
  261. bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
  262. s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0)) + 2;
  263. /* compute high frequency value and choose if noise coding should
  264. be activated */
  265. bps1 = bps;
  266. if (s->nb_channels == 2)
  267. bps1 = bps * 1.6;
  268. if (sample_rate1 == 44100) {
  269. if (bps1 >= 0.61)
  270. s->use_noise_coding = 0;
  271. else
  272. high_freq = high_freq * 0.4;
  273. } else if (sample_rate1 == 22050) {
  274. if (bps1 >= 1.16)
  275. s->use_noise_coding = 0;
  276. else if (bps1 >= 0.72)
  277. high_freq = high_freq * 0.7;
  278. else
  279. high_freq = high_freq * 0.6;
  280. } else if (sample_rate1 == 16000) {
  281. if (bps > 0.5)
  282. high_freq = high_freq * 0.5;
  283. else
  284. high_freq = high_freq * 0.3;
  285. } else if (sample_rate1 == 11025) {
  286. high_freq = high_freq * 0.7;
  287. } else if (sample_rate1 == 8000) {
  288. if (bps <= 0.625) {
  289. high_freq = high_freq * 0.5;
  290. } else if (bps > 0.75) {
  291. s->use_noise_coding = 0;
  292. } else {
  293. high_freq = high_freq * 0.65;
  294. }
  295. } else {
  296. if (bps >= 0.8) {
  297. high_freq = high_freq * 0.75;
  298. } else if (bps >= 0.6) {
  299. high_freq = high_freq * 0.6;
  300. } else {
  301. high_freq = high_freq * 0.5;
  302. }
  303. }
  304. #ifdef DEBUG_PARAMS
  305. printf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
  306. printf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
  307. s->version, s->nb_channels, s->sample_rate, s->bit_rate,
  308. s->block_align);
  309. printf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
  310. bps, bps1, high_freq, s->byte_offset_bits);
  311. printf("use_noise_coding=%d use_exp_vlc=%d\n",
  312. s->use_noise_coding, s->use_exp_vlc);
  313. #endif
  314. /* compute the scale factor band sizes for each MDCT block size */
  315. {
  316. int a, b, pos, lpos, k, block_len, i, j, n;
  317. const uint8_t *table;
  318. if (s->version == 1) {
  319. s->coefs_start = 3;
  320. } else {
  321. s->coefs_start = 0;
  322. }
  323. for(k = 0; k < s->nb_block_sizes; k++) {
  324. block_len = s->frame_len >> k;
  325. if (s->version == 1) {
  326. lpos = 0;
  327. for(i=0;i<25;i++) {
  328. a = wma_critical_freqs[i];
  329. b = s->sample_rate;
  330. pos = ((block_len * 2 * a) + (b >> 1)) / b;
  331. if (pos > block_len)
  332. pos = block_len;
  333. s->exponent_bands[0][i] = pos - lpos;
  334. if (pos >= block_len) {
  335. i++;
  336. break;
  337. }
  338. lpos = pos;
  339. }
  340. s->exponent_sizes[0] = i;
  341. } else {
  342. /* hardcoded tables */
  343. table = NULL;
  344. a = s->frame_len_bits - BLOCK_MIN_BITS - k;
  345. if (a < 3) {
  346. if (s->sample_rate >= 44100)
  347. table = exponent_band_44100[a];
  348. else if (s->sample_rate >= 32000)
  349. table = exponent_band_32000[a];
  350. else if (s->sample_rate >= 22050)
  351. table = exponent_band_22050[a];
  352. }
  353. if (table) {
  354. n = *table++;
  355. for(i=0;i<n;i++)
  356. s->exponent_bands[k][i] = table[i];
  357. s->exponent_sizes[k] = n;
  358. } else {
  359. j = 0;
  360. lpos = 0;
  361. for(i=0;i<25;i++) {
  362. a = wma_critical_freqs[i];
  363. b = s->sample_rate;
  364. pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
  365. pos <<= 2;
  366. if (pos > block_len)
  367. pos = block_len;
  368. if (pos > lpos)
  369. s->exponent_bands[k][j++] = pos - lpos;
  370. if (pos >= block_len)
  371. break;
  372. lpos = pos;
  373. }
  374. s->exponent_sizes[k] = j;
  375. }
  376. }
  377. /* max number of coefs */
  378. s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
  379. /* high freq computation */
  380. s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
  381. s->sample_rate + 0.5);
  382. n = s->exponent_sizes[k];
  383. j = 0;
  384. pos = 0;
  385. for(i=0;i<n;i++) {
  386. int start, end;
  387. start = pos;
  388. pos += s->exponent_bands[k][i];
  389. end = pos;
  390. if (start < s->high_band_start[k])
  391. start = s->high_band_start[k];
  392. if (end > s->coefs_end[k])
  393. end = s->coefs_end[k];
  394. if (end > start)
  395. s->exponent_high_bands[k][j++] = end - start;
  396. }
  397. s->exponent_high_sizes[k] = j;
  398. #if 0
  399. trace("%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
  400. s->frame_len >> k,
  401. s->coefs_end[k],
  402. s->high_band_start[k],
  403. s->exponent_high_sizes[k]);
  404. for(j=0;j<s->exponent_high_sizes[k];j++)
  405. trace(" %d", s->exponent_high_bands[k][j]);
  406. trace("\n");
  407. #endif
  408. }
  409. }
  410. #ifdef DEBUG_TRACE
  411. {
  412. int i, j;
  413. for(i = 0; i < s->nb_block_sizes; i++) {
  414. trace("%5d: n=%2d:",
  415. s->frame_len >> i,
  416. s->exponent_sizes[i]);
  417. for(j=0;j<s->exponent_sizes[i];j++)
  418. trace(" %d", s->exponent_bands[i][j]);
  419. trace("\n");
  420. }
  421. }
  422. #endif
  423. /* init MDCT */
  424. for(i = 0; i < s->nb_block_sizes; i++)
  425. mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1);
  426. /* init MDCT windows : simple sinus window */
  427. for(i = 0; i < s->nb_block_sizes; i++) {
  428. int n, j;
  429. float alpha;
  430. n = 1 << (s->frame_len_bits - i);
  431. window = av_malloc(sizeof(float) * n);
  432. alpha = M_PI / (2.0 * n);
  433. for(j=0;j<n;j++) {
  434. window[n - j - 1] = sin((j + 0.5) * alpha);
  435. }
  436. s->windows[i] = window;
  437. }
  438. s->reset_block_lengths = 1;
  439. if (s->use_noise_coding) {
  440. /* init the noise generator */
  441. if (s->use_exp_vlc)
  442. s->noise_mult = 0.02;
  443. else
  444. s->noise_mult = 0.04;
  445. #if defined(DEBUG_TRACE)
  446. for(i=0;i<NOISE_TAB_SIZE;i++)
  447. s->noise_table[i] = 1.0 * s->noise_mult;
  448. #else
  449. {
  450. unsigned int seed;
  451. float norm;
  452. seed = 1;
  453. norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
  454. for(i=0;i<NOISE_TAB_SIZE;i++) {
  455. seed = seed * 314159 + 1;
  456. s->noise_table[i] = (float)((int)seed) * norm;
  457. }
  458. }
  459. #endif
  460. init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits),
  461. hgain_huffbits, 1, 1,
  462. hgain_huffcodes, 2, 2);
  463. }
  464. if (s->use_exp_vlc) {
  465. init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits),
  466. scale_huffbits, 1, 1,
  467. scale_huffcodes, 4, 4);
  468. } else {
  469. wma_lsp_to_curve_init(s, s->frame_len);
  470. }
  471. /* choose the VLC tables for the coefficients */
  472. coef_vlc_table = 2;
  473. if (s->sample_rate >= 32000) {
  474. if (bps1 < 0.72)
  475. coef_vlc_table = 0;
  476. else if (bps1 < 1.16)
  477. coef_vlc_table = 1;
  478. }
  479. init_coef_vlc(&s->coef_vlc[0], &s->run_table[0], &s->level_table[0],
  480. &coef_vlcs[coef_vlc_table * 2]);
  481. init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
  482. &coef_vlcs[coef_vlc_table * 2 + 1]);
  483. return 0;
  484. }
  485. /* interpolate values for a bigger or smaller block. The block must
  486. have multiple sizes */
  487. static void interpolate_array(float *scale, int old_size, int new_size)
  488. {
  489. int i, j, jincr, k;
  490. float v;
  491. if (new_size > old_size) {
  492. jincr = new_size / old_size;
  493. j = new_size;
  494. for(i = old_size - 1; i >=0; i--) {
  495. v = scale[i];
  496. k = jincr;
  497. do {
  498. scale[--j] = v;
  499. } while (--k);
  500. }
  501. } else if (new_size < old_size) {
  502. j = 0;
  503. jincr = old_size / new_size;
  504. for(i = 0; i < new_size; i++) {
  505. scale[i] = scale[j];
  506. j += jincr;
  507. }
  508. }
  509. }
  510. /* compute x^-0.25 with an exponent and mantissa table. We use linear
  511. interpolation to reduce the mantissa table size at a small speed
  512. expense (linear interpolation approximately doubles the number of
  513. bits of precision). */
  514. static inline float pow_m1_4(WMADecodeContext *s, float x)
  515. {
  516. union {
  517. float f;
  518. unsigned int v;
  519. } u, t;
  520. unsigned int e, m;
  521. float a, b;
  522. u.f = x;
  523. e = u.v >> 23;
  524. m = (u.v >> (23 - LSP_POW_BITS)) & ((1 << LSP_POW_BITS) - 1);
  525. /* build interpolation scale: 1 <= t < 2. */
  526. t.v = ((u.v << LSP_POW_BITS) & ((1 << 23) - 1)) | (127 << 23);
  527. a = s->lsp_pow_m_table1[m];
  528. b = s->lsp_pow_m_table2[m];
  529. return s->lsp_pow_e_table[e] * (a + b * t.f);
  530. }
  531. static void wma_lsp_to_curve_init(WMADecodeContext *s, int frame_len)
  532. {
  533. float wdel, a, b;
  534. int i, e, m;
  535. wdel = M_PI / frame_len;
  536. for(i=0;i<frame_len;i++)
  537. s->lsp_cos_table[i] = 2.0f * cos(wdel * i);
  538. /* tables for x^-0.25 computation */
  539. for(i=0;i<256;i++) {
  540. e = i - 126;
  541. s->lsp_pow_e_table[i] = pow(2.0, e * -0.25);
  542. }
  543. /* NOTE: these two tables are needed to avoid two operations in
  544. pow_m1_4 */
  545. b = 1.0;
  546. for(i=(1 << LSP_POW_BITS) - 1;i>=0;i--) {
  547. m = (1 << LSP_POW_BITS) + i;
  548. a = (float)m * (0.5 / (1 << LSP_POW_BITS));
  549. a = pow(a, -0.25);
  550. s->lsp_pow_m_table1[i] = 2 * a - b;
  551. s->lsp_pow_m_table2[i] = b - a;
  552. b = a;
  553. }
  554. #if 0
  555. for(i=1;i<20;i++) {
  556. float v, r1, r2;
  557. v = 5.0 / i;
  558. r1 = pow_m1_4(s, v);
  559. r2 = pow(v,-0.25);
  560. printf("%f^-0.25=%f e=%f\n", v, r1, r2 - r1);
  561. }
  562. #endif
  563. }
  564. /* NOTE: We use the same code as Vorbis here */
  565. /* XXX: optimize it further with SSE/3Dnow */
  566. static void wma_lsp_to_curve(WMADecodeContext *s,
  567. float *out, float *val_max_ptr,
  568. int n, float *lsp)
  569. {
  570. int i, j;
  571. float p, q, w, v, val_max;
  572. val_max = 0;
  573. for(i=0;i<n;i++) {
  574. p = 0.5f;
  575. q = 0.5f;
  576. w = s->lsp_cos_table[i];
  577. for(j=1;j<NB_LSP_COEFS;j+=2){
  578. q *= w - lsp[j - 1];
  579. p *= w - lsp[j];
  580. }
  581. p *= p * (2.0f - w);
  582. q *= q * (2.0f + w);
  583. v = p + q;
  584. v = pow_m1_4(s, v);
  585. if (v > val_max)
  586. val_max = v;
  587. out[i] = v;
  588. }
  589. *val_max_ptr = val_max;
  590. }
  591. /* decode exponents coded with LSP coefficients (same idea as Vorbis) */
  592. static void decode_exp_lsp(WMADecodeContext *s, int ch)
  593. {
  594. float lsp_coefs[NB_LSP_COEFS];
  595. int val, i;
  596. for(i = 0; i < NB_LSP_COEFS; i++) {
  597. if (i == 0 || i >= 8)
  598. val = get_bits(&s->gb, 3);
  599. else
  600. val = get_bits(&s->gb, 4);
  601. lsp_coefs[i] = lsp_codebook[i][val];
  602. }
  603. wma_lsp_to_curve(s, s->exponents[ch], &s->max_exponent[ch],
  604. s->block_len, lsp_coefs);
  605. }
  606. /* decode exponents coded with VLC codes */
  607. static int decode_exp_vlc(WMADecodeContext *s, int ch)
  608. {
  609. int last_exp, n, code;
  610. const uint16_t *ptr, *band_ptr;
  611. float v, *q, max_scale, *q_end;
  612. band_ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
  613. ptr = band_ptr;
  614. q = s->exponents[ch];
  615. q_end = q + s->block_len;
  616. max_scale = 0;
  617. if (s->version == 1) {
  618. last_exp = get_bits(&s->gb, 5) + 10;
  619. /* XXX: use a table */
  620. v = pow(10, last_exp * (1.0 / 16.0));
  621. max_scale = v;
  622. n = *ptr++;
  623. do {
  624. *q++ = v;
  625. } while (--n);
  626. }
  627. last_exp = 36;
  628. while (q < q_end) {
  629. code = get_vlc(&s->gb, &s->exp_vlc);
  630. if (code < 0)
  631. return -1;
  632. /* NOTE: this offset is the same as MPEG4 AAC ! */
  633. last_exp += code - 60;
  634. /* XXX: use a table */
  635. v = pow(10, last_exp * (1.0 / 16.0));
  636. if (v > max_scale)
  637. max_scale = v;
  638. n = *ptr++;
  639. do {
  640. *q++ = v;
  641. } while (--n);
  642. }
  643. s->max_exponent[ch] = max_scale;
  644. return 0;
  645. }
  646. /* return 0 if OK. return 1 if last block of frame. return -1 if
  647. unrecorrable error. */
  648. static int wma_decode_block(WMADecodeContext *s)
  649. {
  650. int n, v, a, ch, code, bsize;
  651. int coef_nb_bits, total_gain, parse_exponents;
  652. float window[BLOCK_MAX_SIZE * 2];
  653. int nb_coefs[MAX_CHANNELS];
  654. float mdct_norm;
  655. trace("***decode_block: %d:%d\n", frame_count - 1, s->block_num);
  656. /* compute current block length */
  657. if (s->use_variable_block_len) {
  658. n = av_log2(s->nb_block_sizes - 1) + 1;
  659. if (s->reset_block_lengths) {
  660. s->reset_block_lengths = 0;
  661. v = get_bits(&s->gb, n);
  662. if (v >= s->nb_block_sizes)
  663. return -1;
  664. s->prev_block_len_bits = s->frame_len_bits - v;
  665. v = get_bits(&s->gb, n);
  666. if (v >= s->nb_block_sizes)
  667. return -1;
  668. s->block_len_bits = s->frame_len_bits - v;
  669. } else {
  670. /* update block lengths */
  671. s->prev_block_len_bits = s->block_len_bits;
  672. s->block_len_bits = s->next_block_len_bits;
  673. }
  674. v = get_bits(&s->gb, n);
  675. if (v >= s->nb_block_sizes)
  676. return -1;
  677. s->next_block_len_bits = s->frame_len_bits - v;
  678. } else {
  679. /* fixed block len */
  680. s->next_block_len_bits = s->frame_len_bits;
  681. s->prev_block_len_bits = s->frame_len_bits;
  682. s->block_len_bits = s->frame_len_bits;
  683. }
  684. /* now check if the block length is coherent with the frame length */
  685. s->block_len = 1 << s->block_len_bits;
  686. if ((s->block_pos + s->block_len) > s->frame_len)
  687. return -1;
  688. if (s->nb_channels == 2) {
  689. s->ms_stereo = get_bits(&s->gb, 1);
  690. }
  691. v = 0;
  692. for(ch = 0; ch < s->nb_channels; ch++) {
  693. a = get_bits(&s->gb, 1);
  694. s->channel_coded[ch] = a;
  695. v |= a;
  696. }
  697. /* if no channel coded, no need to go further */
  698. /* XXX: fix potential framing problems */
  699. if (!v)
  700. goto next;
  701. bsize = s->frame_len_bits - s->block_len_bits;
  702. /* read total gain and extract corresponding number of bits for
  703. coef escape coding */
  704. total_gain = 1;
  705. for(;;) {
  706. a = get_bits(&s->gb, 7);
  707. total_gain += a;
  708. if (a != 127)
  709. break;
  710. }
  711. if (total_gain < 15)
  712. coef_nb_bits = 13;
  713. else if (total_gain < 32)
  714. coef_nb_bits = 12;
  715. else if (total_gain < 40)
  716. coef_nb_bits = 11;
  717. else if (total_gain < 45)
  718. coef_nb_bits = 10;
  719. else
  720. coef_nb_bits = 9;
  721. /* compute number of coefficients */
  722. n = s->coefs_end[bsize] - s->coefs_start;
  723. for(ch = 0; ch < s->nb_channels; ch++)
  724. nb_coefs[ch] = n;
  725. /* complex coding */
  726. if (s->use_noise_coding) {
  727. for(ch = 0; ch < s->nb_channels; ch++) {
  728. if (s->channel_coded[ch]) {
  729. int i, n, a;
  730. n = s->exponent_high_sizes[bsize];
  731. for(i=0;i<n;i++) {
  732. a = get_bits(&s->gb, 1);
  733. s->high_band_coded[ch][i] = a;
  734. /* if noise coding, the coefficients are not transmitted */
  735. if (a)
  736. nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
  737. }
  738. }
  739. }
  740. for(ch = 0; ch < s->nb_channels; ch++) {
  741. if (s->channel_coded[ch]) {
  742. int i, n, val, code;
  743. n = s->exponent_high_sizes[bsize];
  744. val = (int)0x80000000;
  745. for(i=0;i<n;i++) {
  746. if (s->high_band_coded[ch][i]) {
  747. if (val == (int)0x80000000) {
  748. val = get_bits(&s->gb, 7) - 19;
  749. } else {
  750. code = get_vlc(&s->gb, &s->hgain_vlc);
  751. if (code < 0)
  752. return -1;
  753. val += code - 18;
  754. }
  755. s->high_band_values[ch][i] = val;
  756. }
  757. }
  758. }
  759. }
  760. }
  761. /* exposant can be interpolated in short blocks. */
  762. parse_exponents = 1;
  763. if (s->block_len_bits != s->frame_len_bits) {
  764. parse_exponents = get_bits(&s->gb, 1);
  765. }
  766. if (parse_exponents) {
  767. for(ch = 0; ch < s->nb_channels; ch++) {
  768. if (s->channel_coded[ch]) {
  769. if (s->use_exp_vlc) {
  770. if (decode_exp_vlc(s, ch) < 0)
  771. return -1;
  772. } else {
  773. decode_exp_lsp(s, ch);
  774. }
  775. }
  776. }
  777. } else {
  778. for(ch = 0; ch < s->nb_channels; ch++) {
  779. if (s->channel_coded[ch]) {
  780. interpolate_array(s->exponents[ch], 1 << s->prev_block_len_bits,
  781. s->block_len);
  782. }
  783. }
  784. }
  785. /* parse spectral coefficients : just RLE encoding */
  786. for(ch = 0; ch < s->nb_channels; ch++) {
  787. if (s->channel_coded[ch]) {
  788. VLC *coef_vlc;
  789. int level, run, sign, tindex;
  790. int16_t *ptr, *eptr;
  791. const int16_t *level_table, *run_table;
  792. /* special VLC tables are used for ms stereo because
  793. there is potentially less energy there */
  794. tindex = (ch == 1 && s->ms_stereo);
  795. coef_vlc = &s->coef_vlc[tindex];
  796. run_table = s->run_table[tindex];
  797. level_table = s->level_table[tindex];
  798. /* XXX: optimize */
  799. ptr = &s->coefs1[ch][0];
  800. eptr = ptr + nb_coefs[ch];
  801. memset(ptr, 0, s->block_len * sizeof(int16_t));
  802. for(;;) {
  803. code = get_vlc(&s->gb, coef_vlc);
  804. if (code < 0)
  805. return -1;
  806. if (code == 1) {
  807. /* EOB */
  808. break;
  809. } else if (code == 0) {
  810. /* escape */
  811. level = get_bits(&s->gb, coef_nb_bits);
  812. /* NOTE: this is rather suboptimal. reading
  813. block_len_bits would be better */
  814. run = get_bits(&s->gb, s->frame_len_bits);
  815. } else {
  816. /* normal code */
  817. run = run_table[code];
  818. level = level_table[code];
  819. }
  820. sign = get_bits(&s->gb, 1);
  821. if (!sign)
  822. level = -level;
  823. ptr += run;
  824. if (ptr >= eptr)
  825. return -1;
  826. *ptr++ = level;
  827. /* NOTE: EOB can be omitted */
  828. if (ptr >= eptr)
  829. break;
  830. }
  831. }
  832. if (s->version == 1 && s->nb_channels >= 2) {
  833. align_get_bits(&s->gb);
  834. }
  835. }
  836. /* normalize */
  837. {
  838. int n4 = s->block_len / 2;
  839. mdct_norm = 1.0 / (float)n4;
  840. if (s->version == 1) {
  841. mdct_norm *= sqrt(n4);
  842. }
  843. }
  844. /* finally compute the MDCT coefficients */
  845. for(ch = 0; ch < s->nb_channels; ch++) {
  846. if (s->channel_coded[ch]) {
  847. int16_t *coefs1;
  848. float *coefs, *exponents, mult, mult1, noise, *exp_ptr;
  849. int i, j, n, n1, last_high_band;
  850. float exp_power[HIGH_BAND_MAX_SIZE];
  851. coefs1 = s->coefs1[ch];
  852. exponents = s->exponents[ch];
  853. mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
  854. mult *= mdct_norm;
  855. coefs = s->coefs[ch];
  856. if (s->use_noise_coding) {
  857. mult1 = mult;
  858. /* very low freqs : noise */
  859. for(i = 0;i < s->coefs_start; i++) {
  860. *coefs++ = s->noise_table[s->noise_index] * (*exponents++) * mult1;
  861. s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
  862. }
  863. n1 = s->exponent_high_sizes[bsize];
  864. /* compute power of high bands */
  865. exp_ptr = exponents +
  866. s->high_band_start[bsize] -
  867. s->coefs_start;
  868. last_high_band = 0; /* avoid warning */
  869. for(j=0;j<n1;j++) {
  870. n = s->exponent_high_bands[s->frame_len_bits -
  871. s->block_len_bits][j];
  872. if (s->high_band_coded[ch][j]) {
  873. float e2, v;
  874. e2 = 0;
  875. for(i = 0;i < n; i++) {
  876. v = exp_ptr[i];
  877. e2 += v * v;
  878. }
  879. exp_power[j] = e2 / n;
  880. last_high_band = j;
  881. trace("%d: power=%f (%d)\n", j, exp_power[j], n);
  882. }
  883. exp_ptr += n;
  884. }
  885. /* main freqs and high freqs */
  886. for(j=-1;j<n1;j++) {
  887. if (j < 0) {
  888. n = s->high_band_start[bsize] -
  889. s->coefs_start;
  890. } else {
  891. n = s->exponent_high_bands[s->frame_len_bits -
  892. s->block_len_bits][j];
  893. }
  894. if (j >= 0 && s->high_band_coded[ch][j]) {
  895. /* use noise with specified power */
  896. mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
  897. /* XXX: use a table */
  898. mult1 = mult1 * pow(10, s->high_band_values[ch][j] * 0.05);
  899. mult1 = mult1 / (s->max_exponent[ch] * s->noise_mult);
  900. mult1 *= mdct_norm;
  901. for(i = 0;i < n; i++) {
  902. noise = s->noise_table[s->noise_index];
  903. s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
  904. *coefs++ = (*exponents++) * noise * mult1;
  905. }
  906. } else {
  907. /* coded values + small noise */
  908. for(i = 0;i < n; i++) {
  909. noise = s->noise_table[s->noise_index];
  910. s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
  911. *coefs++ = ((*coefs1++) + noise) * (*exponents++) * mult;
  912. }
  913. }
  914. }
  915. /* very high freqs : noise */
  916. n = s->block_len - s->coefs_end[bsize];
  917. mult1 = mult * exponents[-1];
  918. for(i = 0; i < n; i++) {
  919. *coefs++ = s->noise_table[s->noise_index] * mult1;
  920. s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1);
  921. }
  922. } else {
  923. /* XXX: optimize more */
  924. for(i = 0;i < s->coefs_start; i++)
  925. *coefs++ = 0.0;
  926. n = nb_coefs[ch];
  927. for(i = 0;i < n; i++) {
  928. *coefs++ = coefs1[i] * exponents[i] * mult;
  929. }
  930. n = s->block_len - s->coefs_end[bsize];
  931. for(i = 0;i < n; i++)
  932. *coefs++ = 0.0;
  933. }
  934. }
  935. }
  936. #ifdef DEBUG_TRACE
  937. for(ch = 0; ch < s->nb_channels; ch++) {
  938. if (s->channel_coded[ch]) {
  939. dump_floats("exponents", 3, s->exponents[ch], s->block_len);
  940. dump_floats("coefs", 1, s->coefs[ch], s->block_len);
  941. }
  942. }
  943. #endif
  944. if (s->ms_stereo && s->channel_coded[1]) {
  945. float a, b;
  946. int i;
  947. /* nominal case for ms stereo: we do it before mdct */
  948. /* no need to optimize this case because it should almost
  949. never happen */
  950. if (!s->channel_coded[0]) {
  951. #ifdef DEBUG_TRACE
  952. trace("rare ms-stereo case happened\n");
  953. #endif
  954. memset(s->coefs[0], 0, sizeof(float) * s->block_len);
  955. s->channel_coded[0] = 1;
  956. }
  957. for(i = 0; i < s->block_len; i++) {
  958. a = s->coefs[0][i];
  959. b = s->coefs[1][i];
  960. s->coefs[0][i] = a + b;
  961. s->coefs[1][i] = a - b;
  962. }
  963. }
  964. /* build the window : we ensure that when the windows overlap
  965. their squared sum is always 1 (MDCT reconstruction rule) */
  966. /* XXX: merge with output */
  967. {
  968. int i, next_block_len, block_len, prev_block_len, n;
  969. float *wptr;
  970. block_len = s->block_len;
  971. prev_block_len = 1 << s->prev_block_len_bits;
  972. next_block_len = 1 << s->next_block_len_bits;
  973. /* right part */
  974. wptr = window + block_len;
  975. if (block_len <= next_block_len) {
  976. for(i=0;i<block_len;i++)
  977. *wptr++ = s->windows[bsize][i];
  978. } else {
  979. /* overlap */
  980. n = (block_len / 2) - (next_block_len / 2);
  981. for(i=0;i<n;i++)
  982. *wptr++ = 1.0;
  983. for(i=0;i<next_block_len;i++)
  984. *wptr++ = s->windows[s->frame_len_bits - s->next_block_len_bits][i];
  985. for(i=0;i<n;i++)
  986. *wptr++ = 0.0;
  987. }
  988. /* left part */
  989. wptr = window + block_len;
  990. if (block_len <= prev_block_len) {
  991. for(i=0;i<block_len;i++)
  992. *--wptr = s->windows[bsize][i];
  993. } else {
  994. /* overlap */
  995. n = (block_len / 2) - (prev_block_len / 2);
  996. for(i=0;i<n;i++)
  997. *--wptr = 1.0;
  998. for(i=0;i<prev_block_len;i++)
  999. *--wptr = s->windows[s->frame_len_bits - s->prev_block_len_bits][i];
  1000. for(i=0;i<n;i++)
  1001. *--wptr = 0.0;
  1002. }
  1003. }
  1004. for(ch = 0; ch < s->nb_channels; ch++) {
  1005. if (s->channel_coded[ch]) {
  1006. FFTSample output[BLOCK_MAX_SIZE * 2];
  1007. float *ptr;
  1008. int i, n4, index, n;
  1009. n = s->block_len;
  1010. n4 = s->block_len / 2;
  1011. imdct_calc(&s->mdct_ctx[bsize],
  1012. output, s->coefs[ch], s->mdct_tmp);
  1013. /* XXX: optimize all that by build the window and
  1014. multipying/adding at the same time */
  1015. /* multiply by the window */
  1016. for(i=0;i<n * 2;i++) {
  1017. output[i] *= window[i];
  1018. }
  1019. /* add in the frame */
  1020. index = (s->frame_len / 2) + s->block_pos - n4;
  1021. ptr = &s->frame_out[ch][index];
  1022. for(i=0;i<n * 2;i++) {
  1023. *ptr += output[i];
  1024. ptr++;
  1025. }
  1026. /* specific fast case for ms-stereo : add to second
  1027. channel if it is not coded */
  1028. if (s->ms_stereo && !s->channel_coded[1]) {
  1029. ptr = &s->frame_out[1][index];
  1030. for(i=0;i<n * 2;i++) {
  1031. *ptr += output[i];
  1032. ptr++;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. next:
  1038. /* update block number */
  1039. s->block_num++;
  1040. s->block_pos += s->block_len;
  1041. if (s->block_pos >= s->frame_len)
  1042. return 1;
  1043. else
  1044. return 0;
  1045. }
  1046. /* decode a frame of frame_len samples */
  1047. static int wma_decode_frame(WMADecodeContext *s, int16_t *samples)
  1048. {
  1049. int ret, i, n, a, ch, incr;
  1050. int16_t *ptr;
  1051. float *iptr;
  1052. trace("***decode_frame: %d size=%d\n", frame_count++, s->frame_len);
  1053. /* read each block */
  1054. s->block_num = 0;
  1055. s->block_pos = 0;
  1056. for(;;) {
  1057. ret = wma_decode_block(s);
  1058. if (ret < 0)
  1059. return -1;
  1060. if (ret)
  1061. break;
  1062. }
  1063. /* convert frame to integer */
  1064. n = s->frame_len;
  1065. incr = s->nb_channels;
  1066. for(ch = 0; ch < s->nb_channels; ch++) {
  1067. ptr = samples + ch;
  1068. iptr = s->frame_out[ch];
  1069. for(i=0;i<n;i++) {
  1070. a = lrint(*iptr++);
  1071. if (a > 32767)
  1072. a = 32767;
  1073. else if (a < -32768)
  1074. a = -32768;
  1075. *ptr = a;
  1076. ptr += incr;
  1077. }
  1078. /* prepare for next block */
  1079. memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len],
  1080. s->frame_len * sizeof(float));
  1081. /* XXX: suppress this */
  1082. memset(&s->frame_out[ch][s->frame_len], 0,
  1083. s->frame_len * sizeof(float));
  1084. }
  1085. #ifdef DEBUG_TRACE
  1086. dump_shorts("samples", samples, n * s->nb_channels);
  1087. #endif
  1088. return 0;
  1089. }
  1090. static int wma_decode_superframe(AVCodecContext *avctx,
  1091. void *data, int *data_size,
  1092. UINT8 *buf, int buf_size)
  1093. {
  1094. WMADecodeContext *s = avctx->priv_data;
  1095. int nb_frames, bit_offset, i, pos, len;
  1096. uint8_t *q;
  1097. int16_t *samples;
  1098. trace("***decode_superframe:\n");
  1099. samples = data;
  1100. init_get_bits(&s->gb, buf, buf_size);
  1101. if (s->use_bit_reservoir) {
  1102. /* read super frame header */
  1103. get_bits(&s->gb, 4); /* super frame index */
  1104. nb_frames = get_bits(&s->gb, 4) - 1;
  1105. bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3);
  1106. if (s->last_superframe_len > 0) {
  1107. // printf("skip=%d\n", s->last_bitoffset);
  1108. /* add bit_offset bits to last frame */
  1109. if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) >
  1110. MAX_CODED_SUPERFRAME_SIZE)
  1111. return -1;
  1112. q = s->last_superframe + s->last_superframe_len;
  1113. len = bit_offset;
  1114. while (len > 0) {
  1115. *q++ = (get_bits)(&s->gb, 8);
  1116. len -= 8;
  1117. }
  1118. if (len > 0) {
  1119. *q++ = (get_bits)(&s->gb, len) << (8 - len);
  1120. }
  1121. /* XXX: bit_offset bits into last frame */
  1122. init_get_bits(&s->gb, s->last_superframe, MAX_CODED_SUPERFRAME_SIZE);
  1123. /* skip unused bits */
  1124. if (s->last_bitoffset > 0)
  1125. skip_bits(&s->gb, s->last_bitoffset);
  1126. /* this frame is stored in the last superframe and in the
  1127. current one */
  1128. if (wma_decode_frame(s, samples) < 0)
  1129. return -1;
  1130. samples += s->nb_channels * s->frame_len;
  1131. }
  1132. /* read each frame starting from bit_offset */
  1133. pos = bit_offset + 4 + 4 + s->byte_offset_bits + 3;
  1134. init_get_bits(&s->gb, buf + (pos >> 3), MAX_CODED_SUPERFRAME_SIZE - (pos >> 3));
  1135. len = pos & 7;
  1136. if (len > 0)
  1137. skip_bits(&s->gb, len);
  1138. s->reset_block_lengths = 1;
  1139. for(i=0;i<nb_frames;i++) {
  1140. if (wma_decode_frame(s, samples) < 0)
  1141. return -1;
  1142. samples += s->nb_channels * s->frame_len;
  1143. }
  1144. /* we copy the end of the frame in the last frame buffer */
  1145. pos = get_bits_count(&s->gb) + ((bit_offset + 4 + 4 + s->byte_offset_bits + 3) & ~7);
  1146. s->last_bitoffset = pos & 7;
  1147. pos >>= 3;
  1148. len = buf_size - pos;
  1149. if (len > MAX_CODED_SUPERFRAME_SIZE) {
  1150. return -1;
  1151. }
  1152. s->last_superframe_len = len;
  1153. memcpy(s->last_superframe, buf + pos, len);
  1154. } else {
  1155. /* single frame decode */
  1156. if (wma_decode_frame(s, samples) < 0)
  1157. return -1;
  1158. samples += s->nb_channels * s->frame_len;
  1159. }
  1160. *data_size = (int8_t *)samples - (int8_t *)data;
  1161. return s->block_align;
  1162. }
  1163. static int wma_decode_end(AVCodecContext *avctx)
  1164. {
  1165. WMADecodeContext *s = avctx->priv_data;
  1166. int i;
  1167. for(i = 0; i < s->nb_block_sizes; i++)
  1168. mdct_end(&s->mdct_ctx[i]);
  1169. for(i = 0; i < s->nb_block_sizes; i++)
  1170. av_free(s->windows[i]);
  1171. if (s->use_exp_vlc) {
  1172. free_vlc(&s->exp_vlc);
  1173. }
  1174. if (s->use_noise_coding) {
  1175. free_vlc(&s->hgain_vlc);
  1176. }
  1177. for(i = 0;i < 2; i++) {
  1178. free_vlc(&s->coef_vlc[i]);
  1179. av_free(s->run_table[i]);
  1180. av_free(s->level_table[i]);
  1181. }
  1182. return 0;
  1183. }
  1184. AVCodec wmav1_decoder =
  1185. {
  1186. "wmav1",
  1187. CODEC_TYPE_AUDIO,
  1188. CODEC_ID_WMAV1,
  1189. sizeof(WMADecodeContext),
  1190. wma_decode_init,
  1191. NULL,
  1192. wma_decode_end,
  1193. wma_decode_superframe,
  1194. };
  1195. AVCodec wmav2_decoder =
  1196. {
  1197. "wmav2",
  1198. CODEC_TYPE_AUDIO,
  1199. CODEC_ID_WMAV2,
  1200. sizeof(WMADecodeContext),
  1201. wma_decode_init,
  1202. NULL,
  1203. wma_decode_end,
  1204. wma_decode_superframe,
  1205. };