more variable quality stuff
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 1 Feb 2007 22:44:51 +0000 (22:44 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Thu, 1 Feb 2007 22:44:51 +0000 (22:44 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@12412 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/resample.c

index 5325cb8..0d3b254 100644 (file)
@@ -142,9 +142,20 @@ static void update_filter(SpeexResamplerState *st)
    int i;
    
    st->oversample = OVERSAMPLE;
-
+   if (st->quality > 7)
+      st->oversample *= 2;
    st->filt_len = 8 + 12*st->quality;
    
+   if (st->num_rate > st->den_rate)
+   {
+      /* down-sampling */
+      st->cutoff = .92f * st->den_rate / st->num_rate;
+      st->filt_len *= st->num_rate / st->den_rate;
+   } else {
+      /* up-sampling */
+      st->cutoff = .97f;
+   }
+
    /* Choose the resampling type that requires the least amount of memory */
    if (st->den_rate <= st->oversample)
    {
@@ -390,16 +401,7 @@ void speex_resample_set_rate(SpeexResamplerState *st, int ratio_num, int ratio_d
          st->den_rate /= fact;
       }
    }
-   
-   if (ratio_num > ratio_den)
-   {
-      /* down-sampling */
-      st->cutoff = .92f * ratio_den / ratio_num;
-   } else {
-      /* up-sampling */
-      st->cutoff = .97f;
-   }
-   
+      
    if (st->initialised)
       update_filter(st);
 }