[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase2 r308198 - in /team/dvossel/fixthew...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 16 17:29:50 CST 2011


Author: dvossel
Date: Wed Feb 16 17:29:46 2011
New Revision: 308198

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=308198
Log:
Merging hd_confbridge_ftw branch into phase2 branch

Added:
    team/dvossel/fixtheworld_phase2/codecs/speex/
    team/dvossel/fixtheworld_phase2/codecs/speex/arch.h   (with props)
    team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h   (with props)
    team/dvossel/fixtheworld_phase2/codecs/speex/resample.c   (with props)
    team/dvossel/fixtheworld_phase2/codecs/speex/resample_sse.h   (with props)
    team/dvossel/fixtheworld_phase2/codecs/speex/speex_resampler.h   (with props)
    team/dvossel/fixtheworld_phase2/codecs/speex/stack_alloc.h   (with props)
Modified:
    team/dvossel/fixtheworld_phase2/addons/ooh323c/src/ooSocket.c
    team/dvossel/fixtheworld_phase2/apps/app_chanspy.c
    team/dvossel/fixtheworld_phase2/apps/app_jack.c
    team/dvossel/fixtheworld_phase2/apps/app_mixmonitor.c
    team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c
    team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c
    team/dvossel/fixtheworld_phase2/codecs/Makefile
    team/dvossel/fixtheworld_phase2/codecs/codec_resample.c
    team/dvossel/fixtheworld_phase2/funcs/func_pitchshift.c
    team/dvossel/fixtheworld_phase2/funcs/func_speex.c
    team/dvossel/fixtheworld_phase2/funcs/func_volume.c
    team/dvossel/fixtheworld_phase2/include/asterisk/audiohook.h
    team/dvossel/fixtheworld_phase2/include/asterisk/format.h
    team/dvossel/fixtheworld_phase2/include/asterisk/slinfactory.h
    team/dvossel/fixtheworld_phase2/main/audiohook.c
    team/dvossel/fixtheworld_phase2/main/frame.c
    team/dvossel/fixtheworld_phase2/main/slinfactory.c
    team/dvossel/fixtheworld_phase2/res/res_mutestream.c

Modified: team/dvossel/fixtheworld_phase2/addons/ooh323c/src/ooSocket.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/addons/ooh323c/src/ooSocket.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/addons/ooh323c/src/ooSocket.c (original)
+++ team/dvossel/fixtheworld_phase2/addons/ooh323c/src/ooSocket.c Wed Feb 16 17:29:46 2011
@@ -191,9 +191,8 @@
 int ooSocketCreate (OOSOCKET* psocket) 
 {
    int on;
-   int keepalive = 1;
 #ifdef __linux__
-   int keepcnt = 24, keepidle = 120, keepintvl = 30;
+   int keepalive = 1, keepcnt = 24, keepidle = 120, keepintvl = 30;
 #endif
    struct linger linger;
    OOSOCKET sock = socket (AF_INET,

Modified: team/dvossel/fixtheworld_phase2/apps/app_chanspy.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/apps/app_chanspy.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/apps/app_chanspy.c (original)
+++ team/dvossel/fixtheworld_phase2/apps/app_chanspy.c Wed Feb 16 17:29:46 2011
@@ -541,15 +541,15 @@
 	memset(&csth, 0, sizeof(csth));
 	ast_copy_flags(&csth.spy_audiohook, flags, AST_FLAGS_ALL);
 
-	ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
+	ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy", 0);
 
 	if (start_spying(spyee_autochan, spyer_name, &csth.spy_audiohook)) {
 		ast_audiohook_destroy(&csth.spy_audiohook);
 		return 0;
 	}
 
-	ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
-	ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy");
+	ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy", 0);
+	ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy", 0);
 	if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
 		ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
 	}

Modified: team/dvossel/fixtheworld_phase2/apps/app_jack.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/apps/app_jack.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/apps/app_jack.c (original)
+++ team/dvossel/fixtheworld_phase2/apps/app_jack.c Wed Feb 16 17:29:46 2011
@@ -885,7 +885,7 @@
 		goto return_error;
 
 	jack_data->has_audiohook = 1;
-	ast_audiohook_init(&jack_data->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "JACK_HOOK");
+	ast_audiohook_init(&jack_data->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "JACK_HOOK", 0);
 	jack_data->audiohook.manipulate_callback = jack_hook_callback;
 
 	datastore->data = jack_data;

Modified: team/dvossel/fixtheworld_phase2/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/apps/app_mixmonitor.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/apps/app_mixmonitor.c (original)
+++ team/dvossel/fixtheworld_phase2/apps/app_mixmonitor.c Wed Feb 16 17:29:46 2011
@@ -426,7 +426,7 @@
 	}
 
 	/* Setup the actual spy before creating our thread */
-	if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
+	if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type, 0)) {
 		mixmonitor_free(mixmonitor);
 		return;
 	}

Modified: team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c (original)
+++ team/dvossel/fixtheworld_phase2/bridges/bridge_multiplexed.c Wed Feb 16 17:29:46 2011
@@ -219,6 +219,9 @@
 		winner = ast_waitfor_nandfds(multiplexed_thread->chans, multiplexed_thread->service_count, &fds, 1, NULL, &outfd, &to);
 		multiplexed_thread->waiting = 0;
 		ao2_lock(multiplexed_thread);
+		if (multiplexed_thread->thread == AST_PTHREADT_STOP) {
+			break;
+		}
 
 		if (outfd > -1) {
 			int nudge;
@@ -230,7 +233,21 @@
 			}
 		}
 		if (winner && winner->bridge) {
-			ast_bridge_handle_trip(winner->bridge, NULL, winner, -1);
+			struct ast_bridge *bridge = winner->bridge;
+			int stop = 0;
+			ao2_unlock(multiplexed_thread);
+			while ((bridge = winner->bridge) && ao2_trylock(bridge)) {
+				sched_yield();
+				if (multiplexed_thread->thread == AST_PTHREADT_STOP) {
+					stop = 1;
+					break;
+				}
+			}
+			if (!stop && bridge) {
+				ast_bridge_handle_trip(bridge, NULL, winner, -1);
+				ao2_unlock(winner->bridge);
+			}
+			ao2_lock(multiplexed_thread);
 		}
 	}
 

Modified: team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c (original)
+++ team/dvossel/fixtheworld_phase2/bridges/bridge_softmix.c Wed Feb 16 17:29:46 2011
@@ -52,14 +52,19 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/timing.h"
 
+/*! Max sample rate */
+#define MAX_RATE 96000
+
+#define MAX_DATALEN 1920
+
 /*! \brief Interval at which mixing will take place. Valid options are 10, 20, and 40. */
 #define SOFTMIX_INTERVAL 20
 
 /*! \brief Size of the buffer used for sample manipulation */
-#define SOFTMIX_DATALEN (160 * (SOFTMIX_INTERVAL / 10))
+#define SOFTMIX_DATALEN(rate) ((rate/50) * (SOFTMIX_INTERVAL / 10))
 
 /*! \brief Number of samples we are dealing with */
-#define SOFTMIX_SAMPLES (SOFTMIX_DATALEN / 2)
+#define SOFTMIX_SAMPLES(rate) (SOFTMIX_DATALEN(rate) / 2)
 
 /*! \brief Define used to turn on 16 kHz audio support */
 /* #define SOFTMIX_16_SUPPORT */
@@ -77,40 +82,74 @@
 	/*! Bit used to indicate that a frame is available to be written out to the channel */
 	int have_frame:1;
 	/*! Buffer containing final mixed audio from all sources */
-	short final_buf[SOFTMIX_DATALEN];
+	short final_buf[MAX_DATALEN];
 	/*! Buffer containing only the audio from the channel */
-	short our_buf[SOFTMIX_DATALEN];
+	short our_buf[MAX_DATALEN];
+};
+
+struct softmix_bridge_data {
+	struct ast_timer *timer;
+	int internal_rate;
 };
 
 /*! \brief Function called when a bridge is created */
 static int softmix_bridge_create(struct ast_bridge *bridge)
 {
-	struct ast_timer *timer;
-
-	if (!(timer = ast_timer_open())) {
+	struct softmix_bridge_data *bridge_data;
+
+	if (!(bridge_data = ast_calloc(1, sizeof(struct softmix_bridge_data)))) {
 		return -1;
 	}
-
-	bridge->bridge_pvt = timer;
-
+	if (!(bridge_data->timer = ast_timer_open())) {
+		ast_free(bridge_data);
+		return -1;
+	}
+
+	/* start at 8khz, let it grow from there */
+	bridge_data->internal_rate = 8000;
+
+	bridge->bridge_pvt = bridge_data;
 	return 0;
 }
 
 /*! \brief Function called when a bridge is destroyed */
 static int softmix_bridge_destroy(struct ast_bridge *bridge)
 {
+	struct softmix_bridge_data *bridge_data = bridge->bridge_pvt;
 	if (!bridge->bridge_pvt) {
 		return -1;
 	}
-	ast_timer_close((struct ast_timer *) bridge->bridge_pvt);
-
-	return 0;
+	ast_timer_close(bridge_data->timer);
+	ast_free(bridge_data);
+	return 0;
+}
+
+static void set_softmix_bridge_data(int rate, struct ast_bridge_channel *bridge_channel, int reset)
+{
+	struct softmix_channel *sc = bridge_channel->bridge_pvt;
+	if (reset) {
+		ast_slinfactory_destroy(&sc->factory);
+	}
+	/* Setup frame parameters */
+	sc->frame.frametype = AST_FRAME_VOICE;
+
+	ast_format_set(&sc->frame.subclass.format, ast_format_slin_by_rate(rate), 0);
+	sc->frame.data.ptr = sc->final_buf;
+	sc->frame.datalen = SOFTMIX_DATALEN(rate);
+	sc->frame.samples = SOFTMIX_SAMPLES(rate);
+
+	/* Setup smoother */
+	ast_slinfactory_init_with_format(&sc->factory, &sc->frame.subclass.format);
+
+	ast_set_read_format(bridge_channel->chan, &sc->frame.subclass.format);
+	ast_set_write_format(bridge_channel->chan, &sc->frame.subclass.format);
 }
 
 /*! \brief Function called when a channel is joined into the bridge */
 static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 {
 	struct softmix_channel *sc = NULL;
+	struct softmix_bridge_data *bridge_data = bridge->bridge_pvt;
 
 	/* Create a new softmix_channel structure and allocate various things on it */
 	if (!(sc = ast_calloc(1, sizeof(*sc)))) {
@@ -120,22 +159,10 @@
 	/* Can't forget the lock */
 	ast_mutex_init(&sc->lock);
 
-	/* Setup smoother */
-	ast_slinfactory_init(&sc->factory);
-
-	/* Setup frame parameters */
-	sc->frame.frametype = AST_FRAME_VOICE;
-#ifdef SOFTMIX_16_SUPPORT
-	ast_format_set(&sc->frame.subclass.format, AST_FORMAT_SLINEAR16, 0);
-#else
-	ast_format_set(&sc->frame.subclass.format, AST_FORMAT_SLINEAR, 0);
-#endif
-	sc->frame.data.ptr = sc->final_buf;
-	sc->frame.datalen = SOFTMIX_DATALEN;
-	sc->frame.samples = SOFTMIX_SAMPLES;
-
 	/* Can't forget to record our pvt structure within the bridged channel structure */
 	bridge_channel->bridge_pvt = sc;
+
+	set_softmix_bridge_data(bridge_data->internal_rate, bridge_channel, 0);
 
 	return 0;
 }
@@ -170,11 +197,7 @@
 	ast_mutex_lock(&sc->lock);
 
 	/* If a frame was provided add it to the smoother */
-#ifdef SOFTMIX_16_SUPPORT
-	if (frame->frametype == AST_FRAME_VOICE && frame->subclass.format.id == AST_FORMAT_SLINEAR16) {
-#else
-	if (frame->frametype == AST_FRAME_VOICE && frame->subclass.format.id == AST_FORMAT_SLINEAR) {
-#endif
+	if (frame->frametype == AST_FRAME_VOICE && ast_format_is_slinear(&frame->subclass.format)) {
 		ast_slinfactory_feed(&sc->factory, frame);
 	}
 
@@ -210,29 +233,43 @@
 /*! \brief Function which acts as the mixing thread */
 static int softmix_bridge_thread(struct ast_bridge *bridge)
 {
-	struct ast_timer *timer = (struct ast_timer *) bridge->bridge_pvt;
+	struct softmix_bridge_data *bridge_data = bridge->bridge_pvt;
+	struct ast_timer *timer = bridge_data->timer;
 	int timingfd = ast_timer_fd(timer);
+	int update_all_rates = 0; /* set this when the internal sample rate has changed */
 
 	ast_timer_set_rate(timer, (1000 / SOFTMIX_INTERVAL));
 
 	while (!bridge->stop && !bridge->refresh && bridge->array_num) {
 		struct ast_bridge_channel *bridge_channel = NULL;
-		short buf[SOFTMIX_DATALEN] = {0, };
+		short buf[MAX_DATALEN] = {0, };
 		int timeout = -1;
+
+		/* these variables help determine if a rate change is required */
+		int highest_supported_rate = 8000;
+		int num_above_internal_rate = 0;
+		int num_below_internal_rate = 0;
+		int num_at_internal_rate = 0;
 
 		/* Go through pulling audio from each factory that has it available */
 		AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
 			struct softmix_channel *sc = bridge_channel->bridge_pvt;
+			int channel_native_rate;
 
 			ast_mutex_lock(&sc->lock);
 
+			if (update_all_rates) {
+				set_softmix_bridge_data(bridge_data->internal_rate, bridge_channel, 1);
+			}
+
 			/* Try to get audio from the factory if available */
-			if (ast_slinfactory_available(&sc->factory) >= SOFTMIX_SAMPLES && ast_slinfactory_read(&sc->factory, sc->our_buf, SOFTMIX_SAMPLES)) {
+			if (ast_slinfactory_available(&sc->factory) >= SOFTMIX_SAMPLES(bridge_data->internal_rate) &&
+				ast_slinfactory_read(&sc->factory, sc->our_buf, SOFTMIX_SAMPLES(bridge_data->internal_rate))) {
 				short *data1, *data2;
 				int i;
 
 				/* Put into the local final buffer */
-				for (i = 0, data1 = buf, data2 = sc->our_buf; i < SOFTMIX_DATALEN; i++, data1++, data2++)
+				for (i = 0, data1 = buf, data2 = sc->our_buf; i < SOFTMIX_DATALEN(bridge_data->internal_rate); i++, data1++, data2++)
 					ast_slinear_saturated_add(data1, data2);
 				/* Yay we have our own audio */
 				sc->have_audio = 1;
@@ -240,6 +277,21 @@
 				/* Awww we don't have audio ;( */
 				sc->have_audio = 0;
 			}
+
+			/* Gather stats about channel sample rates.  */
+			channel_native_rate = MAX(ast_format_rate(&bridge_channel->chan->rawwriteformat),
+				ast_format_rate(&bridge_channel->chan->rawreadformat));
+			if (channel_native_rate > highest_supported_rate) {
+				highest_supported_rate = channel_native_rate;
+			}
+			if (channel_native_rate > bridge_data->internal_rate) {
+				num_above_internal_rate++;
+			} else if (channel_native_rate == bridge_data->internal_rate) {
+				num_at_internal_rate++;
+			} else if (channel_native_rate < bridge_data->internal_rate) {
+				num_below_internal_rate++;
+			}
+
 			ast_mutex_unlock(&sc->lock);
 		}
 
@@ -253,7 +305,7 @@
 
 			/* If we provided audio then take it out */
 			if (sc->have_audio) {
-				for (i = 0; i < SOFTMIX_DATALEN; i++) {
+				for (i = 0; i < SOFTMIX_DATALEN(bridge_data->internal_rate); i++) {
 					ast_slinear_saturated_subtract(&sc->final_buf[i], &sc->our_buf[i]);
 				}
 			}
@@ -265,6 +317,18 @@
 			pthread_kill(bridge_channel->thread, SIGURG);
 		}
 
+		/* Re-adjust the internal bridge sample rate if
+		 * 1. two or more channels support a higher sample rate
+		 * 2. no channels support the current sample rate or a higher rate
+		 */
+		if ((num_above_internal_rate >= 2) ||
+			(!num_at_internal_rate && !num_above_internal_rate)) {
+			update_all_rates = 1;
+			ast_log(LOG_NOTICE, " UPDATED FROM %d to %d\n", bridge_data->internal_rate, highest_supported_rate);
+			bridge_data->internal_rate = highest_supported_rate;
+		} else {
+			update_all_rates = 0;
+		}
 		ao2_unlock(bridge);
 
 		/* Wait for the timing source to tell us to wake up and get things done */

Modified: team/dvossel/fixtheworld_phase2/codecs/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/Makefile?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/Makefile (original)
+++ team/dvossel/fixtheworld_phase2/codecs/Makefile Wed Feb 16 17:29:46 2011
@@ -29,11 +29,13 @@
 $(if $(filter codec_gsm,$(EMBEDDED_MODS)),modules.link,codec_gsm.so): gsm/lib/libgsm.a
 endif
 
+
 clean::
 	$(MAKE) -C gsm clean
 	$(MAKE) -C lpc10 clean
 	$(MAKE) -C ilbc clean
 	rm -f g722/*.[oa]
+	rm -f speex/*.[oa]
 
 gsm/lib/libgsm.a:
 	@mkdir -p gsm/lib
@@ -47,7 +49,17 @@
 $(LIBILBC):
 	@$(MAKE) -C ilbc all _ASTCFLAGS="$(filter-out -Wmissing-prototypes -Wmissing-declarations -Wshadow,$(_ASTCFLAGS)) $(AST_NO_STRICT_OVERFLOW)"
 
+
 $(if $(filter codec_ilbc,$(EMBEDDED_MODS)),modules.link,codec_ilbc.so): $(LIBILBC)
 
 $(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): g722/g722_encode.o g722/g722_decode.o
 g722/g722_encode.o g722/g722_decode.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_g722)
+
+ifeq ($(BUILD_CPU),x86_64)
+SPEEX_RESAMPLE_CFLAGS:=-fPIC
+else
+SPEEX_RESAMPLE_CFLAGS:=
+endif
+
+$(if $(filter codec_resample,$(EMBEDDED_MODS)),modules.link,codec_resample.so): speex/resample.o
+speex/resample.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_resample) $(SPEEX_RESAMPLE_CFLAGS)

Modified: team/dvossel/fixtheworld_phase2/codecs/codec_resample.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/codec_resample.c?view=diff&rev=308198&r1=308197&r2=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/codec_resample.c (original)
+++ team/dvossel/fixtheworld_phase2/codecs/codec_resample.c Wed Feb 16 17:29:46 2011
@@ -1,9 +1,10 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2007, Digium, Inc.
+ * Copyright (C) 2011, Digium, Inc.
  *
  * Russell Bryant <russell at digium.com>
+ * David Vossel <dvossel at digium.com>
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -21,9 +22,6 @@
  *
  * \brief Resample slinear audio
  * 
- * \note To install libresample, check it out of the following repository:
- * <code>$ svn co http://svn.digium.com/svn/thirdparty/libresample/trunk</code>
- *
  * \ingroup codecs
  */
 
@@ -32,26 +30,13 @@
  ***/
 
 #include "asterisk.h"
+#include "speex/speex_resampler.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-/* These are for SHRT_MAX and FLT_MAX -- { */
-#if defined(__Darwin__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
-#include <float.h>
-#else
-#include <values.h>
-#endif
-#include <limits.h>
-/* } */
-
-#include <libresample.h>
-
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
-
 #include "asterisk/slin.h"
-
-#define RESAMPLER_QUALITY 1
 
 #define OUTBUF_SIZE   8096
 
@@ -70,18 +55,15 @@
 };
 
 struct resamp_pvt {
-	void *resampler;
-	float resample_factor;
+	SpeexResamplerState *resampler;
 };
 
 static int resamp_new(struct ast_trans_pvt *pvt)
 {
 	struct resamp_pvt *resamp_pvt = pvt->pvt;
+	int err;
 
-	resamp_pvt->resample_factor = (float) ast_format_rate(&pvt->t->dst_format) / ast_format_rate(&pvt->t->src_format);
-
-	if (!(resamp_pvt->resampler = resample_open(RESAMPLER_QUALITY, resamp_pvt->resample_factor, resamp_pvt->resample_factor))) {
-		ast_log(LOG_WARNING, "Failed to create resample translator from %d to %d resamp factor %f\n", ast_format_rate(&pvt->t->dst_format), ast_format_rate(&pvt->t->src_format), resamp_pvt->resample_factor);
+	if (!(resamp_pvt->resampler = speex_resampler_init(1, ast_format_rate(&pvt->t->src_format), ast_format_rate(&pvt->t->dst_format), 5, &err))) {
 		return -1;
 	}
 
@@ -91,63 +73,27 @@
 static void resamp_destroy(struct ast_trans_pvt *pvt)
 {
 	struct resamp_pvt *resamp_pvt = pvt->pvt;
+	speex_resampler_destroy(resamp_pvt->resampler);
 
-	if (resamp_pvt->resampler)
-		resample_close(resamp_pvt->resampler);
-}
-
-static int resample_frame(struct ast_trans_pvt *pvt,
-	void *resampler, float resample_factor, struct ast_frame *f)
-{
-	int total_in_buf_used = 0;
-	int total_out_buf_used = 0;
-	int16_t *in_buf = (int16_t *) f->data.ptr;
-	int16_t *out_buf = pvt->outbuf.i16 + pvt->samples;
-	float in_buf_f[f->samples];
-	float out_buf_f[2048];
-	int res = 0;
-	int i;
-
-	for (i = 0; i < f->samples; i++)
-		in_buf_f[i] = in_buf[i] * (FLT_MAX / SHRT_MAX);
-
-	while (total_in_buf_used < f->samples) {
-		int in_buf_used, out_buf_used;
-
-		out_buf_used = resample_process(resampler, resample_factor,
-			&in_buf_f[total_in_buf_used], f->samples - total_in_buf_used,
-			0, &in_buf_used,
-			&out_buf_f[total_out_buf_used], ARRAY_LEN(out_buf_f) - total_out_buf_used);
-
-		if (out_buf_used < 0)
-			break;
-
-		total_out_buf_used += out_buf_used;
-		total_in_buf_used += in_buf_used;
-
-		if (total_out_buf_used == ARRAY_LEN(out_buf_f)) {
-			ast_log(LOG_ERROR, "Output buffer filled ... need to increase its size\n");
-			res = -1;
-			break;
-		}
-	}
-
-	for (i = 0; i < total_out_buf_used; i++)
-		out_buf[i] = out_buf_f[i] * (SHRT_MAX / FLT_MAX);	
-
-	pvt->samples += total_out_buf_used;
-	pvt->datalen += (total_out_buf_used * sizeof(int16_t));
-
-	return res;
 }
 
 static int resamp_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
 	struct resamp_pvt *resamp_pvt = pvt->pvt;
-	void *resampler = resamp_pvt->resampler;
-	float resample_factor = resamp_pvt->resample_factor;
+	unsigned int out_samples = (OUTBUF_SIZE / sizeof(int16_t)) - pvt->samples;
+	unsigned int in_samples = f->samples;
 
-	return resample_frame(pvt, resampler, resample_factor, f);
+	speex_resampler_process_int(resamp_pvt->resampler,
+		0,
+		f->data.ptr,
+		&in_samples,
+		pvt->outbuf.i16 + pvt->samples,
+		&out_samples);
+
+	pvt->samples += out_samples;
+	pvt->datalen += out_samples * 2;
+
+	return 0;
 }
 
 static int unload_module(void)
@@ -155,7 +101,7 @@
 	int res = 0;
 	int idx;
 
-	for (idx = 0; idx < ARRAY_LEN(translators); idx++) {
+	for (idx = 0; idx < trans_size; idx++) {
 		res |= ast_unregister_translator(&translators[idx]);
 	}
 	ast_free(translators);

Added: team/dvossel/fixtheworld_phase2/codecs/speex/arch.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/speex/arch.h?view=auto&rev=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/speex/arch.h (added)
+++ team/dvossel/fixtheworld_phase2/codecs/speex/arch.h Wed Feb 16 17:29:46 2011
@@ -1,0 +1,241 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+   @file arch.h
+   @brief Various architecture definitions Speex
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef ARCH_H
+#define ARCH_H
+
+#ifndef SPEEX_VERSION
+#define SPEEX_MAJOR_VERSION 1         /**< Major Speex version. */
+#define SPEEX_MINOR_VERSION 1         /**< Minor Speex version. */
+#define SPEEX_MICRO_VERSION 15        /**< Micro Speex version. */
+#define SPEEX_EXTRA_VERSION ""        /**< Extra Speex version. */
+#define SPEEX_VERSION "speex-1.2beta3"  /**< Speex version string. */
+#endif
+
+#define FIXED_POINT
+
+/* A couple test to catch stupid option combinations */
+#ifdef FIXED_POINT
+
+#ifdef FLOATING_POINT
+#error You cannot compile as floating point and fixed point at the same time
+#endif
+#ifdef _USE_SSE
+#error SSE is only for floating-point
+#endif
+#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
+#error Make up your mind. What CPU do you have?
+#endif
+#ifdef VORBIS_PSYCHO
+#error Vorbis-psy model currently not implemented in fixed-point
+#endif
+
+#else
+
+#ifndef FLOATING_POINT
+#error You now need to define either FIXED_POINT or FLOATING_POINT
+#endif
+#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
+#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
+#endif
+#ifdef FIXED_POINT_DEBUG
+#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
+#endif
+
+
+#endif
+
+#ifndef OUTSIDE_SPEEX
+#include "speex/speex_types.h"
+#endif
+
+#define ABS(x) ((x) < 0 ? (-(x)) : (x))      /**< Absolute integer value. */
+#define ABS16(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 16-bit value.  */
+#define MIN16(a,b) ((a) < (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
+#define MAX16(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 16-bit value.   */
+#define ABS32(x) ((x) < 0 ? (-(x)) : (x))    /**< Absolute 32-bit value.  */
+#define MIN32(a,b) ((a) < (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
+#define MAX32(a,b) ((a) > (b) ? (a) : (b))   /**< Maximum 32-bit value.   */
+
+#ifdef FIXED_POINT
+
+typedef spx_int16_t spx_word16_t;
+typedef spx_int32_t   spx_word32_t;
+typedef spx_word32_t spx_mem_t;
+typedef spx_word16_t spx_coef_t;
+typedef spx_word16_t spx_lsp_t;
+typedef spx_word32_t spx_sig_t;
+
+#define Q15ONE 32767
+
+#define LPC_SCALING  8192
+#define SIG_SCALING  16384
+#define LSP_SCALING  8192.
+#define GAMMA_SCALING 32768.
+#define GAIN_SCALING 64
+#define GAIN_SCALING_1 0.015625
+
+#define LPC_SHIFT    13
+#define LSP_SHIFT    13
+#define SIG_SHIFT    14
+#define GAIN_SHIFT   6
+
+#define VERY_SMALL 0
+#define VERY_LARGE32 ((spx_word32_t)2147483647)
+#define VERY_LARGE16 ((spx_word16_t)32767)
+#define Q15_ONE ((spx_word16_t)32767)
+
+
+#ifdef FIXED_DEBUG
+#include "fixed_debug.h"
+#else
+
+#include "fixed_generic.h"
+
+#ifdef ARM5E_ASM
+#include "fixed_arm5e.h"
+#elif defined (ARM4_ASM)
+#include "fixed_arm4.h"
+#elif defined (BFIN_ASM)
+#include "fixed_bfin.h"
+#endif
+
+#endif
+
+
+#else
+
+typedef float spx_mem_t;
+typedef float spx_coef_t;
+typedef float spx_lsp_t;
+typedef float spx_sig_t;
+typedef float spx_word16_t;
+typedef float spx_word32_t;
+
+#define Q15ONE 1.0f
+#define LPC_SCALING  1.f
+#define SIG_SCALING  1.f
+#define LSP_SCALING  1.f
+#define GAMMA_SCALING 1.f
+#define GAIN_SCALING 1.f
+#define GAIN_SCALING_1 1.f
+
+
+#define VERY_SMALL 1e-15f
+#define VERY_LARGE32 1e15f
+#define VERY_LARGE16 1e15f
+#define Q15_ONE ((spx_word16_t)1.f)
+
+#define QCONST16(x,bits) (x)
+#define QCONST32(x,bits) (x)
+
+#define NEG16(x) (-(x))
+#define NEG32(x) (-(x))
+#define EXTRACT16(x) (x)
+#define EXTEND32(x) (x)
+#define SHR16(a,shift) (a)
+#define SHL16(a,shift) (a)
+#define SHR32(a,shift) (a)
+#define SHL32(a,shift) (a)
+#define PSHR16(a,shift) (a)
+#define PSHR32(a,shift) (a)
+#define VSHR32(a,shift) (a)
+#define SATURATE16(x,a) (x)
+#define SATURATE32(x,a) (x)
+
+#define PSHR(a,shift)       (a)
+#define SHR(a,shift)       (a)
+#define SHL(a,shift)       (a)
+#define SATURATE(x,a) (x)
+
+#define ADD16(a,b) ((a)+(b))
+#define SUB16(a,b) ((a)-(b))
+#define ADD32(a,b) ((a)+(b))
+#define SUB32(a,b) ((a)-(b))
+#define MULT16_16_16(a,b)     ((a)*(b))
+#define MULT16_16(a,b)     ((spx_word32_t)(a)*(spx_word32_t)(b))
+#define MAC16_16(c,a,b)     ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
+
+#define MULT16_32_Q11(a,b)     ((a)*(b))
+#define MULT16_32_Q13(a,b)     ((a)*(b))
+#define MULT16_32_Q14(a,b)     ((a)*(b))
+#define MULT16_32_Q15(a,b)     ((a)*(b))
+#define MULT16_32_P15(a,b)     ((a)*(b))
+
+#define MAC16_32_Q11(c,a,b)     ((c)+(a)*(b))
+#define MAC16_32_Q15(c,a,b)     ((c)+(a)*(b))
+
+#define MAC16_16_Q11(c,a,b)     ((c)+(a)*(b))
+#define MAC16_16_Q13(c,a,b)     ((c)+(a)*(b))
+#define MAC16_16_P13(c,a,b)     ((c)+(a)*(b))
+#define MULT16_16_Q11_32(a,b)     ((a)*(b))
+#define MULT16_16_Q13(a,b)     ((a)*(b))
+#define MULT16_16_Q14(a,b)     ((a)*(b))
+#define MULT16_16_Q15(a,b)     ((a)*(b))
+#define MULT16_16_P15(a,b)     ((a)*(b))
+#define MULT16_16_P13(a,b)     ((a)*(b))
+#define MULT16_16_P14(a,b)     ((a)*(b))
+
+#define DIV32_16(a,b)     (((spx_word32_t)(a))/(spx_word16_t)(b))
+#define PDIV32_16(a,b)     (((spx_word32_t)(a))/(spx_word16_t)(b))
+#define DIV32(a,b)     (((spx_word32_t)(a))/(spx_word32_t)(b))
+#define PDIV32(a,b)     (((spx_word32_t)(a))/(spx_word32_t)(b))
+
+
+#endif
+
+
+#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
+
+/* 2 on TI C5x DSP */
+#define BYTES_PER_CHAR 2 
+#define BITS_PER_CHAR 16
+#define LOG2_BITS_PER_CHAR 4
+
+#else 
+
+#define BYTES_PER_CHAR 1
+#define BITS_PER_CHAR 8
+#define LOG2_BITS_PER_CHAR 3
+
+#endif
+
+
+
+#ifdef FIXED_DEBUG
+extern long long spx_mips;
+#endif
+
+
+#endif

Propchange: team/dvossel/fixtheworld_phase2/codecs/speex/arch.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dvossel/fixtheworld_phase2/codecs/speex/arch.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dvossel/fixtheworld_phase2/codecs/speex/arch.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h?view=auto&rev=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h (added)
+++ team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h Wed Feb 16 17:29:46 2011
@@ -1,0 +1,106 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+   @file fixed_generic.h
+   @brief Generic fixed-point operations
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef FIXED_GENERIC_H
+#define FIXED_GENERIC_H
+
+#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
+#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
+
+#define NEG16(x) (-(x))
+#define NEG32(x) (-(x))
+#define EXTRACT16(x) ((spx_word16_t)(x))
+#define EXTEND32(x) ((spx_word32_t)(x))
+#define SHR16(a,shift) ((a) >> (shift))
+#define SHL16(a,shift) ((a) << (shift))
+#define SHR32(a,shift) ((a) >> (shift))
+#define SHL32(a,shift) ((a) << (shift))
+#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift))
+#define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift))
+#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
+#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+
+#define SHR(a,shift) ((a) >> (shift))
+#define SHL(a,shift) ((spx_word32_t)(a) << (shift))
+#define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
+#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+
+
+#define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))
+#define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b))
+#define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b))
+#define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b))
+
+
+/* result fits in 16 bits */
+#define MULT16_16_16(a,b)     ((((spx_word16_t)(a))*((spx_word16_t)(b))))
+
+/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */
+#define MULT16_16(a,b)     (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
+
+#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
+#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
+#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
+#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
+
+#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
+#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
+
+#define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
+#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
+#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
+
+
+#define MAC16_16_Q11(c,a,b)     (ADD32((c),SHR(MULT16_16((a),(b)),11)))
+#define MAC16_16_Q13(c,a,b)     (ADD32((c),SHR(MULT16_16((a),(b)),13)))
+#define MAC16_16_P13(c,a,b)     (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13)))
+
+#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
+#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
+#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
+#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
+
+#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
+#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
+#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
+
+#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
+
+#define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b))))
+#define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b))))
+#define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b)))
+#define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b)))
+
+#endif

Propchange: team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dvossel/fixtheworld_phase2/codecs/speex/fixed_generic.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/dvossel/fixtheworld_phase2/codecs/speex/resample.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/speex/resample.c?view=auto&rev=308198
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/speex/resample.c (added)
+++ team/dvossel/fixtheworld_phase2/codecs/speex/resample.c Wed Feb 16 17:29:46 2011
@@ -1,0 +1,1124 @@
+/* Copyright (C) 2007-2008 Jean-Marc Valin
+   Copyright (C) 2008      Thorvald Natvig
+      
+   File: resample.c
+   Arbitrary resampling code
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+   The design goals of this code are:
+      - Very fast algorithm
+      - SIMD-friendly algorithm
+      - Low memory requirement
+      - Good *perceptual* quality (and not best SNR)
+
+   Warning: This resampler is relatively new. Although I think I got rid of 
+   all the major bugs and I don't expect the API to change anymore, there
+   may be something I've missed. So use with caution.
+
+   This algorithm is based on this original resampling algorithm:
+   Smith, Julius O. Digital Audio Resampling Home Page
+   Center for Computer Research in Music and Acoustics (CCRMA), 
+   Stanford University, 2007.
+   Web published at http://www-ccrma.stanford.edu/~jos/resample/.
+
+   There is one main difference, though. This resampler uses cubic 
+   interpolation instead of linear interpolation in the above paper. This
+   makes the table much smaller and makes it possible to compute that table
+   on a per-stream basis. In turn, being able to tweak the table for each 
+   stream makes it possible to both reduce complexity on simple ratios 
+   (e.g. 2/3), and get rid of the rounding operations in the inner loop. 
+   The latter both reduces CPU time and makes the algorithm more SIMD-friendly.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+static void *speex_alloc (int size) {return calloc(size,1);}

[... 2436 lines stripped ...]



More information about the asterisk-commits mailing list