]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wma.c
Make the Kaiser-Bessel window generator a common function
[ffmpeg] / libavcodec / wma.c
index 76f04def74af4be28d0a24c805db95443de59f08..e257aed319322ee0c15fd71db20c96f67e60d116 100644 (file)
@@ -72,6 +72,11 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
     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;
@@ -302,7 +307,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
         window = av_malloc(sizeof(float) * n);
         alpha = M_PI / (2.0 * n);
         for(j=0;j<n;j++) {
-            window[n - j - 1] = sin((j + 0.5) * alpha);
+            window[j] = sin((j + 0.5) * alpha);
         }
         s->windows[i] = window;
     }
@@ -380,6 +385,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;