]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wmadec.c
Ministry of English Composition, reporting for duty (and the word is "skipped", not...
[ffmpeg] / libavcodec / wmadec.c
index 25498c4d28cf80cad58cc64550f99941b92c6097..e0788375fae7ff4b17e016f08216f1d32777bb84 100644 (file)
 /**
  * @file wmadec.c
  * WMA compatible decoder.
+ * This decoder handles Microsoft Windows Media Audio data, versions 1 & 2.
+ * WMA v1 is identified by audio format 0x160 in Microsoft media files 
+ * (ASF/AVI/WAV). WMA v2 is identified by audio format 0x161.
+ *
+ * To use this decoder, a calling application must supply the extra data
+ * bytes provided with the WMA data. These are the extra, codec-specific
+ * bytes at the end of a WAVEFORMATEX data structure. Transmit these bytes 
+ * to the decoder using the extradata[_size] fields in AVCodecContext. There 
+ * should be 4 extra bytes for v1 data and 6 extra bytes for v2 data.
  */
 
 #include "avcodec.h"
+#include "bitstream.h"
 #include "dsputil.h"
 
 /* size of blocks */
@@ -173,7 +183,7 @@ static void init_coef_vlc(VLC *vlc,
     const uint16_t *p;
     int i, l, j, level;
 
-    init_vlc(vlc, 9, n, table_bits, 1, 1, table_codes, 4, 4);
+    init_vlc(vlc, 9, n, table_bits, 1, 1, table_codes, 4, 4, 0);
 
     run_table = av_malloc(n * sizeof(uint16_t));
     level_table = av_malloc(n * sizeof(uint16_t));
@@ -199,7 +209,8 @@ static int wma_decode_init(AVCodecContext * avctx)
     int i, flags1, flags2;
     float *window;
     uint8_t *extradata;
-    float bps1, high_freq, bps;
+    float bps1, high_freq;
+    volatile float bps;
     int sample_rate1;
     int coef_vlc_table;
     
@@ -483,13 +494,13 @@ static int wma_decode_init(AVCodecContext * avctx)
 #endif
         init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits), 
                  hgain_huffbits, 1, 1,
-                 hgain_huffcodes, 2, 2);
+                 hgain_huffcodes, 2, 2, 0);
     }
 
     if (s->use_exp_vlc) {
         init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits), 
                  scale_huffbits, 1, 1,
-                 scale_huffcodes, 4, 4);
+                 scale_huffcodes, 4, 4, 0);
     } else {
         wma_lsp_to_curve_init(s, s->frame_len);
     }
@@ -693,7 +704,12 @@ static int wma_decode_block(WMADecodeContext *s)
     int n, v, a, ch, code, bsize;
     int coef_nb_bits, total_gain, parse_exponents;
     float window[BLOCK_MAX_SIZE * 2];
+// XXX: FIXME!! there's a bug somewhere which makes this mandatory under altivec
+#ifdef HAVE_ALTIVEC
+    volatile int nb_coefs[MAX_CHANNELS] __attribute__((aligned(16)));
+#else
     int nb_coefs[MAX_CHANNELS];
+#endif
     float mdct_norm;
 
 #ifdef TRACE