[xiph-commits] r14231 - in trunk/speex: include/speex libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Sun Nov 25 14:52:15 PST 2007
Author: jm
Date: 2007-11-25 14:52:15 -0800 (Sun, 25 Nov 2007)
New Revision: 14231
Modified:
trunk/speex/include/speex/speex_resampler.h
trunk/speex/libspeex/resample.c
Log:
Resampler: patch by Sebastian Droge that implements speex_resampler_get_input_latency() and speex_resampler_get_output_latency().
Modified: trunk/speex/include/speex/speex_resampler.h
===================================================================
--- trunk/speex/include/speex/speex_resampler.h 2007-11-25 22:51:59 UTC (rev 14230)
+++ trunk/speex/include/speex/speex_resampler.h 2007-11-25 22:52:15 UTC (rev 14231)
@@ -71,6 +71,8 @@
#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
#define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
#define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
+#define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
+#define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
@@ -300,6 +302,16 @@
void speex_resampler_get_output_stride(SpeexResamplerState *st,
spx_uint32_t *stride);
+/** Get the latency in input samples introduced by the resampler.
+ * @param st Resampler state
+ */
+int speex_resampler_get_input_latency(SpeexResamplerState *st);
+
+/** Get the latency in output samples introduced by the resampler.
+ * @param st Resampler state
+ */
+int speex_resampler_get_output_latency(SpeexResamplerState *st);
+
/** Make sure that the first samples to go out of the resamplers don't have
* leading zeros. This is only useful before starting to use a newly created
* resampler. It is recommended to use that when resampling an audio file, as
Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c 2007-11-25 22:51:59 UTC (rev 14230)
+++ trunk/speex/libspeex/resample.c 2007-11-25 22:52:15 UTC (rev 14231)
@@ -1133,6 +1133,16 @@
*stride = st->out_stride;
}
+int speex_resampler_get_input_latency(SpeexResamplerState *st)
+{
+ return st->filt_len / 2;
+}
+
+int speex_resampler_get_output_latency(SpeexResamplerState *st)
+{
+ return ((st->filt_len / 2) * st->den_rate + (st->num_rate >> 1)) / st->num_rate;
+}
+
int speex_resampler_skip_zeros(SpeexResamplerState *st)
{
spx_uint32_t i;
More information about the commits
mailing list