[xiph-commits] r12455 - in trunk/speex: include/speex libspeex

jm at svn.xiph.org jm at svn.xiph.org
Mon Feb 12 06:50:10 PST 2007


Author: jm
Date: 2007-02-12 06:50:06 -0800 (Mon, 12 Feb 2007)
New Revision: 12455

Modified:
   trunk/speex/include/speex/speex_resampler.h
   trunk/speex/libspeex/resample.c
Log:
Separated the normal (integer frequency) calls from the fractional frequency
calls.


Modified: trunk/speex/include/speex/speex_resampler.h
===================================================================
--- trunk/speex/include/speex/speex_resampler.h	2007-02-12 14:37:55 UTC (rev 12454)
+++ trunk/speex/include/speex/speex_resampler.h	2007-02-12 14:50:06 UTC (rev 12455)
@@ -71,9 +71,18 @@
 struct SpeexResamplerState_;
 typedef struct SpeexResamplerState_ SpeexResamplerState;
 
-/** Create a new resampler. The sampling rate ratio is an arbitrary rational number 
- * with both the numerator and denominator being 32-bit integers.
+/** Create a new resampler with integer input and output rates.
  * @param nb_channels Number of channels to be processed
+ * @param in_rate Nominal input sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
+ * @param out_rate Nominal output sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
+ * @param quality Resampling quality between 0 and 10, where 0 has poor quality and 10 has very high quality.
+ * @return Newly created resampler state
+ */
+SpeexResamplerState *speex_resampler_init(int nb_channels, int in_rate, int out_rate, int quality);
+
+/** Create a new resampler with fractional input/output rates. The sampling rate ratio is 
+ * an arbitrary rational number with both the numerator and denominator being 32-bit integers.
+ * @param nb_channels Number of channels to be processed
  * @param ratio_num Numerator of the sampling rate ratio
  * @param ratio_den Denominator of the sampling rate ratio
  * @param in_rate Nominal input sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
@@ -81,7 +90,7 @@
  * @param quality Resampling quality between 0 and 10, where 0 has poor quality and 10 has very high quality.
  * @return Newly created resampler state
  */
-SpeexResamplerState *speex_resampler_init(int nb_channels, int ratio_num, int ratio_den, int in_rate, int out_rate, int quality);
+SpeexResamplerState *speex_resampler_init_frac(int nb_channels, int ratio_num, int ratio_den, int in_rate, int out_rate, int quality);
 
 /** Destroy a resampler state.
  * @param st Resampler state
@@ -126,14 +135,21 @@
  */
 void speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, int *in_len, spx_int16_t *out, int *out_len);
 
-/** Set (change) the input/output sampling rates and resampling ratio.
+/** Set (change) the input/output sampling rates (integer value).
  * @param st Resampler state
+ * @param in_rate Nominal input sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
+ * @param out_rate Nominal output sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
+ */
+void speex_resampler_set_rate(SpeexResamplerState *st, int in_rate, int out_rate);
+
+/** Set (change) the input/output sampling rates and resampling ratio (fractional values in Hz supported).
+ * @param st Resampler state
  * @param ratio_num Numerator of the sampling rate ratio
  * @param ratio_den Denominator of the sampling rate ratio
  * @param in_rate Nominal input sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
  * @param out_rate Nominal output sampling rate rounded to the nearest integer (in Hz). This does not need to be accurate.
  */
-void speex_resampler_set_rate(SpeexResamplerState *st, int ratio_num, int ratio_den, int in_rate, int out_rate);
+void speex_resampler_set_rate_frac(SpeexResamplerState *st, int ratio_num, int ratio_den, int in_rate, int out_rate);
 
 /** Set (change) the conversion quality.
  * @param st Resampler state

Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c	2007-02-12 14:37:55 UTC (rev 12454)
+++ trunk/speex/libspeex/resample.c	2007-02-12 14:50:06 UTC (rev 12455)
@@ -487,8 +487,12 @@
 
 }
 
+SpeexResamplerState *speex_resampler_init(int nb_channels, int in_rate, int out_rate, int quality)
+{
+   return speex_resampler_init_frac(nb_channels, in_rate, out_rate, in_rate, out_rate, quality);
+}
 
-SpeexResamplerState *speex_resampler_init(int nb_channels, int ratio_num, int ratio_den, int in_rate, int out_rate, int quality)
+SpeexResamplerState *speex_resampler_init_frac(int nb_channels, int ratio_num, int ratio_den, int in_rate, int out_rate, int quality)
 {
    int i;
    SpeexResamplerState *st = (SpeexResamplerState *)speex_alloc(sizeof(SpeexResamplerState));
@@ -522,7 +526,7 @@
    }
 
    speex_resampler_set_quality(st, quality);
-   speex_resampler_set_rate(st, ratio_num, ratio_den, in_rate, out_rate);
+   speex_resampler_set_rate_frac(st, ratio_num, ratio_den, in_rate, out_rate);
 
    
    update_filter(st);
@@ -658,8 +662,13 @@
    st->out_stride = ostride_save;
 }
 
-void speex_resampler_set_rate(SpeexResamplerState *st, int ratio_num, int ratio_den, int in_rate, int out_rate)
+void speex_resampler_set_rate(SpeexResamplerState *st, int in_rate, int out_rate)
 {
+   speex_resampler_set_rate_frac(st, in_rate, out_rate, in_rate, out_rate);
+}
+
+void speex_resampler_set_rate_frac(SpeexResamplerState *st, int ratio_num, int ratio_den, int in_rate, int out_rate)
+{
    int fact;
    if (st->in_rate == in_rate && st->out_rate == out_rate && st->num_rate == ratio_num && st->den_rate == ratio_den)
       return;



More information about the commits mailing list