]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wma.c
Add expected const qualifier on 'buf' to match AVCodec.decode's declaration.
[ffmpeg] / libavcodec / wma.c
index 2241a07a0ec91c3cfaf30d16ce94d3f9a1d460ad..2bbb0994cc9157e882d189b301b8833ae325013d 100644 (file)
@@ -66,12 +66,16 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
 {
     WMACodecContext *s = avctx->priv_data;
     int i;
-    float *window;
     float bps1, high_freq;
     volatile float bps;
     int sample_rate1;
     int coef_vlc_table;
 
+    if(   avctx->sample_rate<=0 || avctx->sample_rate>50000
+       || avctx->channels<=0 || avctx->channels>8
+       || avctx->bit_rate<=0)
+        return -1;
+
     s->sample_rate = avctx->sample_rate;
     s->nb_channels = avctx->channels;
     s->bit_rate = avctx->bit_rate;
@@ -296,15 +300,10 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
 
     /* init MDCT windows : simple sinus window */
     for(i = 0; i < s->nb_block_sizes; i++) {
-        int n, j;
-        float alpha;
+        int n;
         n = 1 << (s->frame_len_bits - i);
-        window = av_malloc(sizeof(float) * n);
-        alpha = M_PI / (2.0 * n);
-        for(j=0;j<n;j++) {
-            window[j] = sin((j + 0.5) * alpha);
-        }
-        s->windows[i] = window;
+        ff_sine_window_init(ff_sine_windows[s->frame_len_bits - i - 7], n);
+        s->windows[i] = ff_sine_windows[s->frame_len_bits - i - 7];
     }
 
     s->reset_block_lengths = 1;
@@ -367,8 +366,6 @@ int ff_wma_end(AVCodecContext *avctx)
 
     for(i = 0; i < s->nb_block_sizes; i++)
         ff_mdct_end(&s->mdct_ctx[i]);
-    for(i = 0; i < s->nb_block_sizes; i++)
-        av_free(s->windows[i]);
 
     if (s->use_exp_vlc) {
         free_vlc(&s->exp_vlc);
@@ -380,6 +377,7 @@ int ff_wma_end(AVCodecContext *avctx)
         free_vlc(&s->coef_vlc[i]);
         av_free(s->run_table[i]);
         av_free(s->level_table[i]);
+        av_free(s->int_table[i]);
     }
 
     return 0;