changeset 9676:f39076e0d605 libavcodec

Use iMDCT output scaling to simplify ffvorbis and make it slightly faster.
author serge
date Wed, 20 May 2009 07:26:09 +0000
parents 2e84b386a8b6
children 592097778fa0
files vorbis_dec.c
diffstat 1 files changed, 3 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/vorbis_dec.c	Wed May 20 07:24:38 2009 +0000
+++ b/vorbis_dec.c	Wed May 20 07:26:09 2009 +0000
@@ -210,11 +210,6 @@
         av_free(vc->mappings[i].mux);
     }
     av_freep(&vc->mappings);
-
-    if(vc->exp_bias){
-        av_freep(&vc->win[0]);
-        av_freep(&vc->win[1]);
-    }
 }
 
 // Parse setup header -------------------------------------------------
@@ -876,16 +871,6 @@
     vc->win[0]=ff_vorbis_vwin[bl0-6];
     vc->win[1]=ff_vorbis_vwin[bl1-6];
 
-    if(vc->exp_bias){
-        int i, j;
-        for(j=0; j<2; j++){
-            float *win = av_malloc(vc->blocksize[j]/2 * sizeof(float));
-            for(i=0; i<vc->blocksize[j]/2; i++)
-                win[i] = vc->win[j][i] * (1<<15);
-            vc->win[j] = win;
-        }
-    }
-
     if ((get_bits1(gb)) == 0) {
         av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (framing flag not set). \n");
         return 2;
@@ -896,8 +881,8 @@
     vc->saved           = av_mallocz((vc->blocksize[1]/4)*vc->audio_channels * sizeof(float));
     vc->previous_window=0;
 
-    ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0);
-    ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0);
+    ff_mdct_init(&vc->mdct[0], bl0, 1, vc->exp_bias ? -(1<<15) : -1.0);
+    ff_mdct_init(&vc->mdct[1], bl1, 1, vc->exp_bias ? -(1<<15) : -1.0);
 
     AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
             vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
@@ -1410,8 +1395,7 @@
 {
     int i;
     if(exp_bias) {
-        for(i=0; i<len; i++)
-            ((uint32_t*)dst)[i] = ((uint32_t*)src)[i] + exp_bias; // dst[k]=src[i]*(1<<bias)
+        memcpy(dst, src, len * sizeof(float));
     } else {
         for(i=0; i<len; i++)
             dst[i] = src[i] + add_bias;