Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
October 2008
- 10 participants
- 372 discussions
Author: anthm
Date: Wed Oct 1 14:02:46 2008
New Revision: 9778
Modified:
freeswitch/trunk/src/switch_rtp.c
Log:
clean up rtp a little and tolerate polycom cng bug
Modified: freeswitch/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/trunk/src/switch_rtp.c (original)
+++ freeswitch/trunk/src/switch_rtp.c Wed Oct 1 14:02:46 2008
@@ -197,6 +197,7 @@
char *stun_ip;
switch_port_t stun_port;
int from_auto;
+ uint32_t cng_count;
};
static int global_init = 0;
@@ -1232,6 +1233,8 @@
}
}
+#define return_cng_frame() do_cng = 1; goto timer_check
+
static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
{
switch_size_t bytes = 0;
@@ -1240,7 +1243,7 @@
stfu_frame_t *jb_frame;
int ret = -1;
int sleep_mss = 1000;
-
+
if (!switch_rtp_ready(rtp_session)) {
return -1;
}
@@ -1294,14 +1297,22 @@
if (bytes) {
rtp_session->missed_count = 0;
+
+ if ((rtp_session->recv_msg.header.pt == rtp_session->cng_pt || rtp_session->recv_msg.header.pt == 13)) {
+ if (++rtp_session->cng_count == 1) {
+ return_cng_frame();
+ }
+ continue;
+ } else {
+ rtp_session->cng_count = 0;
+ }
}
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) {
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
do_2833(rtp_session);
bytes = 0;
- do_cng = 1;
- goto cng;
+ return_cng_frame();
}
if (bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
@@ -1312,8 +1323,7 @@
}
if (!bytes && (io_flags & SWITCH_IO_FLAG_NOBLOCK)) {
- do_cng = 1;
- goto cng;
+ return_cng_frame();
}
@@ -1363,8 +1373,6 @@
goto end;
}
-
-
if (rtp_session->jb && ((bytes && rtp_session->recv_msg.header.pt == rtp_session->payload) || check)) {
if (bytes) {
if (rtp_session->recv_msg.header.m) {
@@ -1384,7 +1392,7 @@
rtp_session->recv_msg.header.ts = htonl(jb_frame->ts);
rtp_session->recv_msg.header.pt = rtp_session->payload;
} else {
- goto cng;
+ goto timer_check;
}
}
@@ -1484,14 +1492,15 @@
do_cng = 1;
}
- cng:
+ timer_check:
+
if (do_cng) {
- memset(&rtp_session->recv_msg.body, 0, 2);
- rtp_session->recv_msg.body[0] = 127;
- rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
+ uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
+ memset(data, 0, 2);
+ data[0] = 65;
+ rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG;
- /* Return a CNG frame */
- *payload_type = SWITCH_RTP_CNG_PAYLOAD;
+ *payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
ret = 2 + rtp_header_len;
goto end;
}
@@ -1512,21 +1521,14 @@
bytes = jb_frame->dlen + rtp_header_len;
rtp_session->recv_msg.header.ts = htonl(jb_frame->ts);
} else if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) { /* We're late! We're Late! */
- uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
-
+
+
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {
switch_yield(1000);
continue;
}
-
- memset(data, 0, 2);
- data[0] = 65;
-
- rtp_session->recv_msg.header.pt = (uint32_t) rtp_session->cng_pt ? rtp_session->cng_pt : SWITCH_RTP_CNG_PAYLOAD;
- *flags |= SFF_CNG;
- *payload_type = (switch_payload_t) rtp_session->recv_msg.header.pt;
- ret = 2 + rtp_header_len;
- goto end;
+
+ return_cng_frame();
}
}
@@ -1538,10 +1540,6 @@
goto end;
}
- if (bytes && rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) {
- goto do_continue;
- }
-
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->recv_msg.header.pt == 102) {
rtp_session->recv_msg.header.pt = 97;
}
@@ -1552,11 +1550,8 @@
do_continue:
- if (sleep_mss) {
- switch_yield(sleep_mss);
- } else {
- switch_yield(1000);
- }
+ switch_yield(sleep_mss);
+
}
if (switch_rtp_ready(rtp_session)) {
1
0
[commit] r9777 - in freeswitch/trunk: conf/autoload_configs src src/include
by Freeswitch SVN 01 Oct '08
by Freeswitch SVN 01 Oct '08
01 Oct '08
Author: anthm
Date: Wed Oct 1 13:31:59 2008
New Revision: 9777
Modified:
freeswitch/trunk/conf/autoload_configs/ivr.conf.xml
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/switch_cpp.cpp
freeswitch/trunk/src/switch_ivr_menu.c
Log:
Commit FSCORE-183, tested by me but others test also.
Modified: freeswitch/trunk/conf/autoload_configs/ivr.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/ivr.conf.xml (original)
+++ freeswitch/trunk/conf/autoload_configs/ivr.conf.xml Wed Oct 1 13:31:59 2008
@@ -10,6 +10,7 @@
timeout ="10000"
inter-digit-timeout="2000"
max-failures="3"
+ max-timeouts="3"
digit-len="4">
<entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888(a)conference.freeswitch.org"/>
<entry action="menu-exec-app" digits="2" param="transfer 9996 XML default"/> <!-- FS echo -->
@@ -26,7 +27,8 @@
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
timeout="15000"
- max-failures="3">
+ max-failures="3"
+ max-timeouts="3">
<entry action="menu-top" digits="*"/>
</menu>
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Wed Oct 1 13:31:59 2008
@@ -92,7 +92,8 @@
const char *exit_sound,
const char *confirm_macro,
const char *confirm_key,
- int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures);
+ int confirm_attempts, int inter_timeout, int digit_len,
+ int timeout, int max_failures, int max_timeouts);
virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu();
SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
SWITCH_DECLARE(void) execute(CoreSession * session, const char *name);
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Wed Oct 1 13:31:59 2008
@@ -680,7 +680,8 @@
const char *confirm_macro,
const char *confirm_key,
int confirm_attempts,
- int inter_timeout, int digit_len, int timeout, int max_failures, switch_memory_pool_t *pool);
+ int inter_timeout, int digit_len, int timeout, int max_failures,
+ int max_timeouts, switch_memory_pool_t *pool);
/*!
*\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Wed Oct 1 13:31:59 2008
@@ -112,7 +112,8 @@
int inter_timeout,
int digit_len,
int timeout,
- int max_failures)
+ int max_failures,
+ int max_timeouts)
{
menu = NULL;
switch_core_new_memory_pool(&pool);
@@ -122,7 +123,7 @@
}
switch_ivr_menu_init(&menu, main ? main->menu : NULL, name, greeting_sound, short_greeting_sound, invalid_sound,
- exit_sound, confirm_macro, confirm_key, confirm_attempts, inter_timeout, digit_len, timeout, max_failures, pool);
+ exit_sound, confirm_macro, confirm_key, confirm_attempts, inter_timeout, digit_len, timeout, max_failures, max_timeouts, pool);
}
Modified: freeswitch/trunk/src/switch_ivr_menu.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_menu.c (original)
+++ freeswitch/trunk/src/switch_ivr_menu.c Wed Oct 1 13:31:59 2008
@@ -47,6 +47,7 @@
int confirm_attempts;
int digit_len;
int max_failures;
+ int max_timeouts;
int timeout;
int inter_timeout;
switch_size_t inlen;
@@ -102,6 +103,7 @@
int inter_timeout,
int digit_len,
int timeout, int max_failures,
+ int max_timeouts,
switch_memory_pool_t *pool)
{
switch_ivr_menu_t *menu;
@@ -167,6 +169,8 @@
menu->max_failures = max_failures;
+ menu->max_timeouts = max_timeouts;
+
menu->timeout = timeout;
menu->inter_timeout = inter_timeout;
@@ -345,7 +349,7 @@
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t * stack, char *name, void *obj)
{
- int reps = 0, errs = 0, match = 0, running = 1;
+ int reps = 0, errs = 0, timeouts = 0, match = 0, running = 1;
char *greeting_sound = NULL, *aptr = NULL;
char arg[512];
switch_ivr_action_t todo = SWITCH_IVR_ACTION_DIE;
@@ -372,11 +376,22 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing IVR menu %s\n", menu->name);
+ switch_channel_set_variable(channel, "ivr_menu_status", "success");
- for (reps = 0; (running && status == SWITCH_STATUS_SUCCESS && errs < menu->max_failures); reps++) {
+ for (reps = 0; running && status == SWITCH_STATUS_SUCCESS; reps++) {
if (!switch_channel_ready(channel)) {
break;
}
+ if (errs == menu->max_failures) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Maximum failures\n");
+ switch_channel_set_variable(channel, "ivr_menu_status", "failure");
+ break;
+ }
+ if (timeouts == menu->max_timeouts) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Maximum timeouts\n");
+ switch_channel_set_variable(channel, "ivr_menu_status", "timeout");
+ break;
+ }
if (reps > 0 && menu->short_greeting_sound) {
greeting_sound = menu->short_greeting_sound;
@@ -390,7 +405,11 @@
memset(arg, 0, sizeof(arg));
memset(menu->buf, 0, menu->inlen + 1);
- status = play_and_collect(session, menu, greeting_sound, menu->inlen);
+
+ if (play_and_collect(session, menu, greeting_sound, menu->inlen) == SWITCH_STATUS_TIMEOUT && *menu->buf == '\0') {
+ timeouts++;
+ continue;
+ }
if (*menu->buf != '\0') {
@@ -494,17 +513,12 @@
if (*menu->buf) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name, menu->buf);
if (menu->invalid_sound) {
- status = play_and_collect(session, menu, menu->invalid_sound, 0);
+ play_and_collect(session, menu, menu->invalid_sound, 0);
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' no input detected\n", menu->name);
}
errs++;
-
- if (status == SWITCH_STATUS_TIMEOUT) {
- status = SWITCH_STATUS_SUCCESS;
- }
-
if (status == SWITCH_STATUS_SUCCESS) {
status = switch_ivr_sleep(session, 1000, NULL);
}
@@ -693,6 +707,7 @@
const char *exit_sound = switch_xml_attr(xml_menu, "exit-sound"); /* if the attr doesn't exist, return NULL */
const char *timeout = switch_xml_attr_soft(xml_menu, "timeout"); /* if the attr doesn't exist, return "" */
const char *max_failures = switch_xml_attr_soft(xml_menu, "max-failures"); /* if the attr doesn't exist, return "" */
+ const char *max_timeouts = switch_xml_attr_soft(xml_menu, "max-timeouts");
const char *confirm_macro= switch_xml_attr(xml_menu, "confirm-macro");
const char *confirm_key= switch_xml_attr(xml_menu, "confirm-key");
const char *confirm_attempts = switch_xml_attr_soft(xml_menu, "confirm-attempts");
@@ -701,6 +716,10 @@
switch_ivr_menu_t *menu = NULL;
+ if (switch_strlen_zero(max_timeouts)) {
+ max_timeouts = max_failures;
+ }
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "building menu '%s'\n", menu_name);
status = switch_ivr_menu_init(&menu,
@@ -716,7 +735,8 @@
atoi(inter_timeout),
atoi(digit_len),
atoi(timeout),
- atoi(max_failures),
+ strlen(max_failures)? atoi(max_failures): 1,
+ strlen(max_timeouts)? atoi(max_timeouts): 1,
xml_menu_ctx->pool);
/* set the menu_stack for the caller */
if (status == SWITCH_STATUS_SUCCESS && *menu_stack == NULL) {
1
0
Author: stkn
Date: Wed Oct 1 09:30:38 2008
New Revision: 9776
Modified:
freeswitch/trunk/src/switch_core.c
Log:
Style police strikes
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Oct 1 09:30:38 2008
@@ -1466,15 +1466,13 @@
int ret = 0;
struct system_thread_handle *sth;
switch_memory_pool_t *pool;
-#ifndef __FreeBSD__
-#ifdef HAVE_SETRLIMIT
+#if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
struct rlimit rlim;
rlim.rlim_cur = SWITCH_SYSTEM_THREAD_STACKSIZE;
- rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;;
+ rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
setrlimit(RLIMIT_STACK, &rlim);
#endif
-#endif
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
1
0
[commit] r9775 - in freeswitch/trunk: conf/autoload_configs src/mod/applications/mod_voicemail
by Freeswitch SVN 01 Oct '08
by Freeswitch SVN 01 Oct '08
01 Oct '08
Author: anthm
Date: Wed Oct 1 09:06:59 2008
New Revision: 9775
Modified:
freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
Log:
add patch from MODAPP-150 with mods
Modified: freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml (original)
+++ freeswitch/trunk/conf/autoload_configs/voicemail.conf.xml Wed Oct 1 09:06:59 2008
@@ -42,6 +42,8 @@
<param name="operator-key" value="9"/>
<param name="vmain-extension" value="vmain XML default"/>
<param name="vmain-key" value="*"/>
+ <!-- playback created files as soon as they were recorded by default -->
+ <!--<param name="auto-playback-recordings" value="true"/>-->
<email>
<param name="template-file" value="voicemail.tpl"/>
<param name="notify-template-file" value="notify-voicemail.tpl"/>
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Wed Oct 1 09:06:59 2008
@@ -123,6 +123,7 @@
uint32_t record_silence_hits;
uint32_t record_sample_rate;
switch_odbc_handle_t *master_odbc;
+ switch_bool_t auto_playback_recordings;
};
typedef struct vm_profile vm_profile_t;
@@ -314,6 +315,8 @@
char *record_comment = "FreeSWITCH Voicemail";
char *record_copyright = "http://www.freeswitch.org";
+ switch_bool_t auto_playback_recordings = SWITCH_TRUE;
+
switch_core_db_t *db;
uint32_t timeout = 10000, max_login_attempts = 3, max_record_len = 300, min_record_len = 3;
@@ -570,7 +573,7 @@
if (tmp > 0 && tmp < 10000) {
min_record_len = tmp;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid record length [%s] must be between 1 and 10000s\n", val);
}
} else if (!strcasecmp(var, "max-record-len")) {
int tmp = 0;
@@ -580,7 +583,7 @@
if (tmp > 0 && tmp < 10000) {
max_record_len = tmp;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid attempts [%s] must be between 1 and 10000s\n", val);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid record length [%s] must be between 1 and 10000s\n", val);
}
} else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
#ifdef SWITCH_HAVE_ODBC
@@ -594,6 +597,8 @@
#else
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif
+ } else if (!strcasecmp(var, "auto-playback-recordings")){
+ auto_playback_recordings = switch_true(val);
}
}
@@ -736,6 +741,7 @@
profile->record_silence_hits = record_silence_hits;
profile->record_sample_rate = record_sample_rate;
+ profile->auto_playback_recordings = auto_playback_recordings;
profile->operator_ext = switch_core_strdup(globals.pool, operator_ext);
profile->vmain_ext = switch_core_strdup(globals.pool, vmain_ext);
profile->storage_dir = switch_core_strdup(globals.pool, storage_dir);
@@ -1061,14 +1067,15 @@
status = SWITCH_STATUS_SUCCESS;
}
play_file:
- memset(&fh, 0, sizeof(fh));
- args.input_callback = control_playback;
- memset(&cc, 0, sizeof(cc));
- cc.profile = profile;
- cc.fh = &fh;
- args.buf = &cc;
- switch_ivr_play_file(session, &fh, file_path, &args);
-
+ if (profile->auto_playback_recordings) {
+ memset(&fh, 0, sizeof(fh));
+ args.input_callback = control_playback;
+ memset(&cc, 0, sizeof(cc));
+ cc.profile = profile;
+ cc.fh = &fh;
+ args.buf = &cc;
+ switch_ivr_play_file(session, &fh, file_path, &args);
+ }
while (switch_channel_ready(channel)) {
*input = '\0';
1
0
Author: anthm
Date: Wed Oct 1 08:55:41 2008
New Revision: 9774
Modified:
freeswitch/trunk/src/switch_core.c
Log:
add patch from FSCORE-196
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Oct 1 08:55:41 2008
@@ -1466,6 +1466,7 @@
int ret = 0;
struct system_thread_handle *sth;
switch_memory_pool_t *pool;
+#ifndef __FreeBSD__
#ifdef HAVE_SETRLIMIT
struct rlimit rlim;
@@ -1473,6 +1474,7 @@
rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;;
setrlimit(RLIMIT_STACK, &rlim);
#endif
+#endif
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
1
0
01 Oct '08
Author: anthm
Date: Wed Oct 1 00:10:45 2008
New Revision: 9773
Added:
freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h
Modified:
freeswitch/trunk/libs/spandsp/src/Makefile.am
freeswitch/trunk/libs/spandsp/src/libspandsp.dsp
freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj
freeswitch/trunk/libs/spandsp/src/spandsp/version.h
Log:
update to snapshot spandsp-20081001.tar.gz
Modified: freeswitch/trunk/libs/spandsp/src/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/src/Makefile.am Wed Oct 1 00:10:45 2008
@@ -16,7 +16,7 @@
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.104 2008/09/20 15:44:40 steveu Exp $
+## $Id: Makefile.am,v 1.105 2008/09/30 18:12:42 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@@ -162,6 +162,7 @@
spandsp/plc.h \
spandsp/power_meter.h \
spandsp/queue.h \
+ spandsp/saturated.h \
spandsp/schedule.h \
spandsp/sig_tone.h \
spandsp/silence_gen.h \
Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.dsp
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/libspandsp.dsp (original)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.dsp Wed Oct 1 00:10:45 2008
@@ -563,6 +563,10 @@
# End Source File
# Begin Source File
+SOURCE=.\spandsp/saturated.h
+# End Source File
+# Begin Source File
+
SOURCE=.\spandsp/schedule.h
# End Source File
# Begin Source File
Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj (original)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj Wed Oct 1 00:10:45 2008
@@ -296,6 +296,7 @@
<File RelativePath="spandsp/plc.h"></File>
<File RelativePath="spandsp/power_meter.h"></File>
<File RelativePath="spandsp/queue.h"></File>
+<File RelativePath="spandsp/saturated.h"></File>
<File RelativePath="spandsp/schedule.h"></File>
<File RelativePath="spandsp/sig_tone.h"></File>
<File RelativePath="spandsp/silence_gen.h"></File>
Added: freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h Wed Oct 1 00:10:45 2008
@@ -0,0 +1,199 @@
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * saturated.h - General saturated arithmetic routines.
+ *
+ * Written by Steve Underwood <steveu(a)coppice.org>
+ *
+ * Copyright (C) 2001, 2008 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: saturated.h,v 1.1 2008/09/19 14:02:05 steveu Exp $
+ */
+
+/*! \file */
+
+#if !defined(_SPANDSP_SATURATED_H_)
+#define _SPANDSP_SATURATED_H_
+
+/*! \page saturated_page Saturated arithmetic
+
+\section saturated_page_sec_1 What does it do?
+
+
+\section saturated_page_sec_2 How does it work?
+
+*/
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+static __inline__ int16_t saturate(int32_t amp)
+{
+ int16_t amp16;
+
+ /* Hopefully this is optimised for the common case - not clipping */
+ amp16 = (int16_t) amp;
+ if (amp == amp16)
+ return amp16;
+ if (amp > INT16_MAX)
+ return INT16_MAX;
+ return INT16_MIN;
+}
+/*- End of function --------------------------------------------------------*/
+
+/*! Saturate to 15 bits, rather than the usual 16 bits. This is often a useful function. */
+static __inline__ int16_t saturate15(int32_t amp)
+{
+ if (amp > 16383)
+ return 16383;
+ if (amp < -16384)
+ return -16384;
+ return (int16_t) amp;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int16_t fsaturatef(float famp)
+{
+ if (famp > (float) INT16_MAX)
+ return INT16_MAX;
+ if (famp < (float) INT16_MIN)
+ return INT16_MIN;
+ return (int16_t) rintf(famp);
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int16_t fsaturate(double damp)
+{
+ if (damp > (double) INT16_MAX)
+ return INT16_MAX;
+ if (damp < (double) INT16_MIN)
+ return INT16_MIN;
+ return (int16_t) rint(damp);
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ float ffsaturatef(float famp)
+{
+ if (famp > (float) INT16_MAX)
+ return (float) INT16_MAX;
+ if (famp < (float) INT16_MIN)
+ return (float) INT16_MIN;
+ return famp;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ double ffsaturate(double famp)
+{
+ if (famp > (double) INT16_MAX)
+ return (double) INT16_MAX;
+ if (famp < (double) INT16_MIN)
+ return (double) INT16_MIN;
+ return famp;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int16_t saturated_add16(int16_t a, int16_t b)
+{
+#if defined(__GNUC__) && defined(__i386__)
+ __asm__ __volatile__(
+ " addw %2,%0;\n"
+ " jno 0f;\n"
+ " movw $0x7fff,%0;\n"
+ " adcw $0,%0;\n"
+ "0:"
+ : "=r" (a)
+ : "0" (a), "ir" (b)
+ : "cc"
+ );
+ return a;
+#else
+ return saturate((int32_t) a + (int32_t) b);
+#endif
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int32_t saturated_add32(int32_t a, int32_t b)
+{
+#if defined(__GNUC__) && defined(__i386__)
+ __asm__ __volatile__(
+ " addl %2,%0;\n"
+ " jno 0f;\n"
+ " movl $0x7fffffff,%0;\n"
+ " adcl $0,%0;\n"
+ "0:"
+ : "=r" (a)
+ : "0" (a), "ir" (b)
+ : "cc"
+ );
+ return a;
+#else
+ uint32_t A;
+
+ if (a < 0)
+ {
+ if (b >= 0)
+ return a + b;
+ /*endif*/
+ A = (uint32_t) -(a + 1) + (uint32_t) -(b + 1);
+ return (A >= INT32_MAX) ? INT32_MIN : -(int32_t) A - 2;
+ }
+ /*endif*/
+ if (b <= 0)
+ return a + b;
+ /*endif*/
+ A = (uint32_t) a + (uint32_t) b;
+ return (A > INT32_MAX) ? INT32_MAX : A;
+#endif
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int16_t saturated_sub16(int16_t a, int16_t b)
+{
+ return saturate((int32_t) a - (int32_t) b);
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int16_t saturated_mul16(int16_t a, int16_t b)
+{
+ if (a == INT16_MIN && b == INT16_MIN)
+ return INT16_MAX;
+ /*endif*/
+ return (int16_t) (((int32_t) a*(int32_t) b) >> 15);
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int32_t saturated_mul_16_32(int16_t a, int16_t b)
+{
+ return ((int32_t) a*(int32_t) b) << 1;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int16_t saturated_abs16(int16_t a)
+{
+ return (a == INT16_MIN) ? INT16_MAX : (int16_t) abs(a);
+}
+/*- End of function --------------------------------------------------------*/
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Wed Oct 1 00:10:45 2008
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20080928
-#define SPANDSP_RELEASE_TIME 144338
+#define SPANDSP_RELEASE_DATE 20080930
+#define SPANDSP_RELEASE_TIME 181513
#endif
/*- End of file ------------------------------------------------------------*/
1
0
01 Oct '08
Author: anthm
Date: Wed Oct 1 00:08:43 2008
New Revision: 9772
Modified:
freeswitch/trunk/libs/spandsp/.update
freeswitch/trunk/libs/spandsp/Makefile.am
freeswitch/trunk/libs/spandsp/spandsp.spec
freeswitch/trunk/libs/spandsp/spandsp.spec.in
freeswitch/trunk/libs/spandsp/src/spandsp/version.h
freeswitch/trunk/libs/spandsp/tests/g726_tests.c
Log:
update to snapshot spandsp-20080928.tar.gz
Modified: freeswitch/trunk/libs/spandsp/.update
==============================================================================
--- freeswitch/trunk/libs/spandsp/.update (original)
+++ freeswitch/trunk/libs/spandsp/.update Wed Oct 1 00:08:43 2008
@@ -1 +1 @@
-Wed Oct 1 00:06:28 EDT 2008
+Wed Oct 1 00:08:32 EDT 2008
Modified: freeswitch/trunk/libs/spandsp/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/Makefile.am Wed Oct 1 00:08:43 2008
@@ -16,7 +16,7 @@
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.43 2008/09/20 15:44:40 steveu Exp $
+## $Id: Makefile.am,v 1.44 2008/09/28 14:36:25 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@@ -73,7 +73,7 @@
rm -f rpm/SOURCES/*
rm -f rpm/SPECS/*
rm -f rpm/SRPMS/*
- rpm -ta --sign @PACKAGE@-@VERSION@.tar.gz
+ rpmbuild -ta --sign @PACKAGE@-@VERSION@.tar.gz
bump.rpm.release: spandsp.spec
VERSION="x"; \
Modified: freeswitch/trunk/libs/spandsp/spandsp.spec
==============================================================================
--- freeswitch/trunk/libs/spandsp/spandsp.spec (original)
+++ freeswitch/trunk/libs/spandsp/spandsp.spec Wed Oct 1 00:08:43 2008
@@ -2,18 +2,18 @@
Name: spandsp
Version: 0.0.5
Release: 1
-License: GPL
+License: LGPL
Group: System Environment/Libraries
URL: http://www.soft-switch.org/spandsp
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Source: http://www.soft-switch.org/downloads/spandsp/spandsp-0.0.5.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Docdir: %{_prefix}/doc
-
BuildRequires: libtiff-devel
BuildRequires: audiofile-devel
BuildRequires: doxygen
+# for xsltproc:
+BuildRequires: libxslt
%description
SpanDSP is a library of DSP functions for telephony, in the 8000
@@ -56,8 +56,6 @@
%{_libdir}/libspandsp.so.*
-%{_datadir}/spandsp
-
%files devel
%defattr(-,root,root,-)
%doc doc/api
@@ -70,6 +68,10 @@
%postun -p /sbin/ldconfig
%changelog
+* Wed Sep 24 2008 Tzafrir Cohen <tzafrir.cohen(a)xorcom.com> 0.0.5-1
+- Preparing for 0.0.5pre4 release
+- License: LGPL
+
* Mon 23 Jun 2008 Steve Underwood <steveu(a)coppice.org> 0.0.5-1
- Cleared out the dependency on libxml2
Modified: freeswitch/trunk/libs/spandsp/spandsp.spec.in
==============================================================================
--- freeswitch/trunk/libs/spandsp/spandsp.spec.in (original)
+++ freeswitch/trunk/libs/spandsp/spandsp.spec.in Wed Oct 1 00:08:43 2008
@@ -2,18 +2,18 @@
Name: @PACKAGE@
Version: @VERSION@
Release: 1
-License: GPL
+License: LGPL
Group: System Environment/Libraries
URL: http://www.soft-switch.org/spandsp
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Source: http://www.soft-switch.org/downloads/spandsp/@PACKAGE@-@VERSION@.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Docdir: %{_prefix}/doc
-
BuildRequires: libtiff-devel
BuildRequires: audiofile-devel
BuildRequires: doxygen
+# for xsltproc:
+BuildRequires: libxslt
%description
SpanDSP is a library of DSP functions for telephony, in the 8000
@@ -56,8 +56,6 @@
%{_libdir}/libspandsp.so.*
-%{_datadir}/spandsp
-
%files devel
%defattr(-,root,root,-)
%doc doc/api
@@ -70,6 +68,10 @@
%postun -p /sbin/ldconfig
%changelog
+* Wed Sep 24 2008 Tzafrir Cohen <tzafrir.cohen(a)xorcom.com> 0.0.5-1
+- Preparing for 0.0.5pre4 release
+- License: LGPL
+
* Mon 23 Jun 2008 Steve Underwood <steveu(a)coppice.org> 0.0.5-1
- Cleared out the dependency on libxml2
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Wed Oct 1 00:08:43 2008
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20080920
-#define SPANDSP_RELEASE_TIME 154737
+#define SPANDSP_RELEASE_DATE 20080928
+#define SPANDSP_RELEASE_TIME 144338
#endif
/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/tests/g726_tests.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/g726_tests.c (original)
+++ freeswitch/trunk/libs/spandsp/tests/g726_tests.c Wed Oct 1 00:08:43 2008
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: g726_tests.c,v 1.27 2008/08/29 09:28:13 steveu Exp $
+ * $Id: g726_tests.c,v 1.28 2008/09/28 14:36:25 steveu Exp $
*/
/*! \file */
@@ -1279,6 +1279,8 @@
}
printf("ADPCM packing is %d\n", packing);
+ //g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, G726_PACKING_LEFT);
+ //g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, G726_PACKING_RIGHT);
g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, packing);
g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, packing);
1
0
[commit] r9771 - in freeswitch/trunk/libs/spandsp: . doc src src/spandsp tests
by Freeswitch SVN 01 Oct '08
by Freeswitch SVN 01 Oct '08
01 Oct '08
Author: anthm
Date: Wed Oct 1 00:06:53 2008
New Revision: 9771
Added:
freeswitch/trunk/libs/spandsp/src/complex_vector_int.c
freeswitch/trunk/libs/spandsp/src/g722.c
freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj
freeswitch/trunk/libs/spandsp/tests/complex_tests.c
freeswitch/trunk/libs/spandsp/tests/complex_vector_float_tests.c
freeswitch/trunk/libs/spandsp/tests/complex_vector_int_tests.c
Modified:
freeswitch/trunk/libs/spandsp/.update
freeswitch/trunk/libs/spandsp/Makefile.am
freeswitch/trunk/libs/spandsp/doc/Makefile.am
freeswitch/trunk/libs/spandsp/src/Makefile.am
freeswitch/trunk/libs/spandsp/src/spandsp/g722.h
freeswitch/trunk/libs/spandsp/src/spandsp/version.h
Log:
update to snapshot spandsp-20080920.tar.gz
Modified: freeswitch/trunk/libs/spandsp/.update
==============================================================================
--- freeswitch/trunk/libs/spandsp/.update (original)
+++ freeswitch/trunk/libs/spandsp/.update Wed Oct 1 00:06:53 2008
@@ -1 +1 @@
-Tue Sep 30 23:59:24 EDT 2008
+Wed Oct 1 00:06:28 EDT 2008
Modified: freeswitch/trunk/libs/spandsp/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/Makefile.am Wed Oct 1 00:06:53 2008
@@ -16,7 +16,7 @@
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.40 2008/07/15 14:28:20 steveu Exp $
+## $Id: Makefile.am,v 1.43 2008/09/20 15:44:40 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@@ -30,26 +30,10 @@
README.testdata \
spandsp.spec \
wrapper.xsl \
- libspandsp.vcproj \
unpack_g722_data.sh \
unpack_g726_data.sh \
unpack_gsm0610_data.sh \
unpack_v56ter_data.sh \
- doc/doxygen.in \
- src/floating_fudge.h \
- src/spandsp/version.h.in \
- src/libspandsp.dsp \
- src/libspandsp.sln \
- src/msvc/gettimeofday.c \
- src/msvc/inttypes.h \
- src/msvc/tgmath.h \
- src/msvc/unistd.h \
- src/msvc/sys/time.h \
- src/msvc/spandsp.def \
- src/msvc/msvcproj.head \
- src/msvc/msvcproj.foot \
- src/msvc/vc8proj.head \
- src/msvc/vc8proj.foot \
spandsp/global-tones.xml \
spandsp/tones.dtd \
spandsp/tsb85.xml \
Modified: freeswitch/trunk/libs/spandsp/doc/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/doc/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/doc/Makefile.am Wed Oct 1 00:06:53 2008
@@ -16,11 +16,12 @@
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.11 2008/06/21 10:28:34 steveu Exp $
+## $Id: Makefile.am,v 1.12 2008/09/20 15:44:40 steveu Exp $
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = css.css \
+ doxygen.in \
t38-gateway.dia \
t38-terminal.dia \
t38_manual.xml \
Modified: freeswitch/trunk/libs/spandsp/src/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/src/Makefile.am Wed Oct 1 00:06:53 2008
@@ -16,13 +16,29 @@
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.103 2008/09/19 14:02:05 steveu Exp $
+## $Id: Makefile.am,v 1.104 2008/09/20 15:44:40 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
MAINTAINERCLEANFILES = Makefile.in
+EXTRA_DIST = floating_fudge.h \
+ spandsp/version.h.in \
+ libspandsp.dsp \
+ libspandsp.sln \
+ libspandsp.vcproj \
+ msvc/gettimeofday.c \
+ msvc/inttypes.h \
+ msvc/tgmath.h \
+ msvc/unistd.h \
+ msvc/sys/time.h \
+ msvc/spandsp.def \
+ msvc/msvcproj.head \
+ msvc/msvcproj.foot \
+ msvc/vc8proj.head \
+ msvc/vc8proj.foot
+
INCLUDES = -I$(top_builddir)
lib_LTLIBRARIES = libspandsp.la
Added: freeswitch/trunk/libs/spandsp/src/complex_vector_int.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/src/complex_vector_int.c Wed Oct 1 00:06:53 2008
@@ -0,0 +1,113 @@
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * complex_vector_int.c - Integer complex vector arithmetic routines.
+ *
+ * Written by Steve Underwood <steveu(a)coppice.org>
+ *
+ * Copyright (C) 2006 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: complex_vector_int.c,v 1.3 2008/09/18 13:54:32 steveu Exp $
+ */
+
+/*! \file */
+
+#if defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "floating_fudge.h"
+#if defined(HAVE_TGMATH_H)
+#include <tgmath.h>
+#endif
+#if defined(HAVE_MATH_H)
+#include <math.h>
+#endif
+#include <assert.h>
+
+#include "spandsp/telephony.h"
+#include "spandsp/logging.h"
+#include "spandsp/complex.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
+
+complexi32_t cvec_dot_prodi16(const complexi16_t x[], const complexi16_t y[], int n)
+{
+ int i;
+ complexi32_t z;
+
+ z = complex_seti32(0, 0);
+ for (i = 0; i < n; i++)
+ {
+ z.re += ((int32_t) x[i].re*(int32_t) y[i].re - (int32_t) x[i].im*(int32_t) y[i].im);
+ z.im += ((int32_t) x[i].re*(int32_t) y[i].im + (int32_t) x[i].im*(int32_t) y[i].re);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+complexi32_t cvec_dot_prodi32(const complexi32_t x[], const complexi32_t y[], int n)
+{
+ int i;
+ complexi32_t z;
+
+ z = complex_seti32(0, 0);
+ for (i = 0; i < n; i++)
+ {
+ z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
+ z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+complexi32_t cvec_circular_dot_prodi16(const complexi16_t x[], const complexi16_t y[], int n, int pos)
+{
+ complexi32_t z;
+ complexi32_t z1;
+
+ z = cvec_dot_prodi16(&x[pos], &y[0], n - pos);
+ z1 = cvec_dot_prodi16(&x[0], &y[n - pos], pos);
+ z = complex_addi32(&z, &z1);
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+void cvec_lmsi16(const complexi16_t x[], complexi16_t y[], int n, const complexi16_t *error)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ y[i].re += ((int32_t) x[i].im*(int32_t) error->im + (int32_t) x[i].re*(int32_t) error->re) >> 12;
+ y[i].im += ((int32_t) x[i].re*(int32_t) error->im - (int32_t) x[i].im*(int32_t) error->re) >> 12;
+ }
+}
+/*- End of function --------------------------------------------------------*/
+
+void cvec_circular_lmsi16(const complexi16_t x[], complexi16_t y[], int n, int pos, const complexi16_t *error)
+{
+ cvec_lmsi16(&x[pos], &y[0], n - pos, error);
+ cvec_lmsi16(&x[0], &y[n - pos], pos, error);
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
Added: freeswitch/trunk/libs/spandsp/src/g722.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/src/g722.c Wed Oct 1 00:06:53 2008
@@ -0,0 +1,609 @@
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * g722.c - The ITU G.722 codec.
+ *
+ * Written by Steve Underwood <steveu(a)coppice.org>
+ *
+ * Copyright (C) 2005 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Based in part on a single channel G.722 codec which is:
+ *
+ * Copyright (c) CMU 1993
+ * Computer Science, Speech Group
+ * Chengxiang Lu and Alex Hauptmann
+ *
+ * $Id: g722.c,v 1.2 2008/09/19 16:24:25 steveu Exp $
+ */
+
+/*! \file */
+
+#if defined(HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <inttypes.h>
+#include <memory.h>
+#include <stdlib.h>
+#include "floating_fudge.h"
+#if defined(HAVE_TGMATH_H)
+#include <tgmath.h>
+#endif
+#if defined(HAVE_MATH_H)
+#include <math.h>
+#endif
+
+#include "spandsp/telephony.h"
+#include "spandsp/saturated.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/g722.h"
+
+static const int16_t qmf_coeffs_fwd[12] =
+{
+ 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
+};
+
+static const int16_t qmf_coeffs_rev[12] =
+{
+ -11, 53, -156, 362, -805, 3876, 951, -210, 32, 12, -11, 3
+};
+
+static const int16_t qm2[4] =
+{
+ -7408, -1616, 7408, 1616
+};
+
+static const int16_t qm4[16] =
+{
+ 0, -20456, -12896, -8968,
+ -6288, -4240, -2584, -1200,
+ 20456, 12896, 8968, 6288,
+ 4240, 2584, 1200, 0
+};
+
+static const int16_t qm5[32] =
+{
+ -280, -280, -23352, -17560,
+ -14120, -11664, -9752, -8184,
+ -6864, -5712, -4696, -3784,
+ -2960, -2208, -1520, -880,
+ 23352, 17560, 14120, 11664,
+ 9752, 8184, 6864, 5712,
+ 4696, 3784, 2960, 2208,
+ 1520, 880, 280, -280
+};
+
+static const int16_t qm6[64] =
+{
+ -136, -136, -136, -136,
+ -24808, -21904, -19008, -16704,
+ -14984, -13512, -12280, -11192,
+ -10232, -9360, -8576, -7856,
+ -7192, -6576, -6000, -5456,
+ -4944, -4464, -4008, -3576,
+ -3168, -2776, -2400, -2032,
+ -1688, -1360, -1040, -728,
+ 24808, 21904, 19008, 16704,
+ 14984, 13512, 12280, 11192,
+ 10232, 9360, 8576, 7856,
+ 7192, 6576, 6000, 5456,
+ 4944, 4464, 4008, 3576,
+ 3168, 2776, 2400, 2032,
+ 1688, 1360, 1040, 728,
+ 432, 136, -432, -136
+};
+
+static const int16_t q6[32] =
+{
+ 0, 35, 72, 110,
+ 150, 190, 233, 276,
+ 323, 370, 422, 473,
+ 530, 587, 650, 714,
+ 786, 858, 940, 1023,
+ 1121, 1219, 1339, 1458,
+ 1612, 1765, 1980, 2195,
+ 2557, 2919, 0, 0
+};
+
+static const int16_t ilb[32] =
+{
+ 2048, 2093, 2139, 2186,
+ 2233, 2282, 2332, 2383,
+ 2435, 2489, 2543, 2599,
+ 2656, 2714, 2774, 2834,
+ 2896, 2960, 3025, 3091,
+ 3158, 3228, 3298, 3371,
+ 3444, 3520, 3597, 3676,
+ 3756, 3838, 3922, 4008
+};
+
+static const int16_t iln[32] =
+{
+ 0, 63, 62, 31, 30, 29, 28, 27,
+ 26, 25, 24, 23, 22, 21, 20, 19,
+ 18, 17, 16, 15, 14, 13, 12, 11,
+ 10, 9, 8, 7, 6, 5, 4, 0
+};
+
+static const int16_t ilp[32] =
+{
+ 0, 61, 60, 59, 58, 57, 56, 55,
+ 54, 53, 52, 51, 50, 49, 48, 47,
+ 46, 45, 44, 43, 42, 41, 40, 39,
+ 38, 37, 36, 35, 34, 33, 32, 0
+};
+
+static const int16_t ihn[3] =
+{
+ 0, 1, 0
+};
+
+static const int16_t ihp[3] =
+{
+ 0, 3, 2
+};
+
+static const int16_t wl[8] =
+{
+ -60, -30, 58, 172, 334, 538, 1198, 3042
+};
+
+static const int16_t rl42[16] =
+{
+ 0, 7, 6, 5, 4, 3, 2, 1,
+ 7, 6, 5, 4, 3, 2, 1, 0
+};
+
+static const int16_t wh[3] =
+{
+ 0, -214, 798
+};
+
+static const int16_t rh2[4] =
+{
+ 2, 1, 2, 1
+};
+
+static void block4(g722_band_t *s, int16_t dx)
+{
+ int16_t wd1;
+ int16_t wd2;
+ int16_t wd3;
+ int16_t sp;
+ int16_t r;
+ int16_t p;
+ int16_t ap[2];
+ int32_t wd32;
+ int32_t sz;
+ int i;
+
+ /* RECONS */
+ r = saturated_add16(s->s, dx);
+ /* PARREC */
+ p = saturated_add16(s->sz, dx);
+
+ /* UPPOL2 */
+ wd1 = saturate((int32_t) s->a[0] << 2);
+ wd32 = ((p ^ s->p[0]) & 0x8000) ? wd1 : -wd1;
+ if (wd32 > 32767)
+ wd32 = 32767;
+ wd3 = (((p ^ s->p[1]) & 0x8000) ? -128 : 128)
+ + (wd32 >> 7)
+ + (((int32_t) s->a[1]*(int32_t) 32512) >> 15);
+ if (abs(wd3) > 12288)
+ wd3 = (wd3 < 0) ? -12288 : 12288;
+ ap[1] = wd3;
+
+ /* UPPOL1 */
+ wd1 = ((p ^ s->p[0]) & 0x8000) ? -192 : 192;
+ wd2 = ((int32_t) s->a[0]*(int32_t) 32640) >> 15;
+ ap[0] = saturated_add16(wd1, wd2);
+
+ wd3 = saturated_sub16(15360, ap[1]);
+ if (abs(ap[0]) > wd3)
+ ap[0] = (ap[0] < 0) ? -wd3 : wd3;
+
+ /* FILTEP */
+ wd1 = saturated_add16(r, r);
+ wd1 = ((int32_t) ap[0]*(int32_t) wd1) >> 15;
+ wd2 = saturated_add16(s->r, s->r);
+ wd2 = ((int32_t) ap[1]*(int32_t) wd2) >> 15;
+ sp = saturated_add16(wd1, wd2);
+ s->r = r;
+ s->a[1] = ap[1];
+ s->a[0] = ap[0];
+ s->p[1] = s->p[0];
+ s->p[0] = p;
+
+ /* UPZERO */
+ /* DELAYA */
+ /* FILTEZ */
+ wd1 = (dx == 0) ? 0 : 128;
+ s->d[0] = dx;
+ sz = 0;
+ for (i = 5; i >= 0; i--)
+ {
+ wd2 = ((s->d[i + 1] ^ dx) & 0x8000) ? -wd1 : wd1;
+ wd3 = ((int32_t) s->b[i]*(int32_t) 32640) >> 15;
+ s->b[i] = saturated_add16(wd2, wd3);
+ wd3 = saturated_add16(s->d[i], s->d[i]);
+ sz += ((int32_t) s->b[i]*(int32_t) wd3) >> 15;
+ s->d[i + 1] = s->d[i];
+ }
+ s->sz = saturate(sz);
+
+ /* PREDIC */
+ s->s = saturated_add16(sp, s->sz);
+}
+/*- End of function --------------------------------------------------------*/
+
+g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options)
+{
+ if (s == NULL)
+ {
+ if ((s = (g722_decode_state_t *) malloc(sizeof(*s))) == NULL)
+ return NULL;
+ }
+ memset(s, 0, sizeof(*s));
+ if (rate == 48000)
+ s->bits_per_sample = 6;
+ else if (rate == 56000)
+ s->bits_per_sample = 7;
+ else
+ s->bits_per_sample = 8;
+ if ((options & G722_SAMPLE_RATE_8000))
+ s->eight_k = TRUE;
+ if ((options & G722_PACKED) && s->bits_per_sample != 8)
+ s->packed = TRUE;
+ else
+ s->packed = FALSE;
+ s->band[0].det = 32;
+ s->band[1].det = 8;
+ return s;
+}
+/*- End of function --------------------------------------------------------*/
+
+int g722_decode_release(g722_decode_state_t *s)
+{
+ free(s);
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len)
+{
+ int rlow;
+ int ihigh;
+ int16_t dlow;
+ int16_t dhigh;
+ int rhigh;
+ int wd1;
+ int wd2;
+ int wd3;
+ int code;
+ int outlen;
+ int j;
+
+ outlen = 0;
+ rhigh = 0;
+ for (j = 0; j < len; )
+ {
+ if (s->packed)
+ {
+ /* Unpack the code bits */
+ if (s->in_bits < s->bits_per_sample)
+ {
+ s->in_buffer |= (g722_data[j++] << s->in_bits);
+ s->in_bits += 8;
+ }
+ code = s->in_buffer & ((1 << s->bits_per_sample) - 1);
+ s->in_buffer >>= s->bits_per_sample;
+ s->in_bits -= s->bits_per_sample;
+ }
+ else
+ {
+ code = g722_data[j++];
+ }
+
+ switch (s->bits_per_sample)
+ {
+ default:
+ case 8:
+ wd1 = code & 0x3F;
+ ihigh = (code >> 6) & 0x03;
+ wd2 = qm6[wd1];
+ wd1 >>= 2;
+ break;
+ case 7:
+ wd1 = code & 0x1F;
+ ihigh = (code >> 5) & 0x03;
+ wd2 = qm5[wd1];
+ wd1 >>= 1;
+ break;
+ case 6:
+ wd1 = code & 0x0F;
+ ihigh = (code >> 4) & 0x03;
+ wd2 = qm4[wd1];
+ break;
+ }
+ /* Block 5L, LOW BAND INVQBL */
+ wd2 = ((int32_t) s->band[0].det*(int32_t) wd2) >> 15;
+ /* Block 5L, RECONS */
+ /* Block 6L, LIMIT */
+ rlow = saturate15(s->band[0].s + wd2);
+
+ /* Block 2L, INVQAL */
+ wd2 = qm4[wd1];
+ dlow = ((int32_t) s->band[0].det*(int32_t) wd2) >> 15;
+
+ /* Block 3L, LOGSCL */
+ wd2 = rl42[wd1];
+ wd1 = ((int32_t) s->band[0].nb*(int32_t) 127) >> 7;
+ wd1 += wl[wd2];
+ if (wd1 < 0)
+ wd1 = 0;
+ else if (wd1 > 18432)
+ wd1 = 18432;
+ s->band[0].nb = wd1;
+
+ /* Block 3L, SCALEL */
+ wd1 = (s->band[0].nb >> 6) & 31;
+ wd2 = 8 - (s->band[0].nb >> 11);
+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
+ s->band[0].det = wd3 << 2;
+
+ block4(&s->band[0], dlow);
+
+ if (!s->eight_k)
+ {
+ /* Block 2H, INVQAH */
+ wd2 = qm2[ihigh];
+ dhigh = ((int32_t) s->band[1].det*(int32_t) wd2) >> 15;
+ /* Block 5H, RECONS */
+ /* Block 6H, LIMIT */
+ rhigh = saturate15(dhigh + s->band[1].s);
+
+ /* Block 2H, INVQAH */
+ wd2 = rh2[ihigh];
+ wd1 = ((int32_t) s->band[1].nb*(int32_t) 127) >> 7;
+ wd1 += wh[wd2];
+ if (wd1 < 0)
+ wd1 = 0;
+ else if (wd1 > 22528)
+ wd1 = 22528;
+ s->band[1].nb = wd1;
+
+ /* Block 3H, SCALEH */
+ wd1 = (s->band[1].nb >> 6) & 31;
+ wd2 = 10 - (s->band[1].nb >> 11);
+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
+ s->band[1].det = wd3 << 2;
+
+ block4(&s->band[1], dhigh);
+ }
+
+ if (s->itu_test_mode)
+ {
+ amp[outlen++] = (int16_t) (rlow << 1);
+ amp[outlen++] = (int16_t) (rhigh << 1);
+ }
+ else
+ {
+ if (s->eight_k)
+ {
+ amp[outlen++] = (int16_t) rlow;
+ }
+ else
+ {
+ /* Apply the QMF to build the final signal */
+ s->x[s->ptr] = rlow + rhigh;
+ s->y[s->ptr] = rlow - rhigh;
+ if (++s->ptr >= 12)
+ s->ptr = 0;
+ amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr) >> 12);
+ amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr) >> 12);
+ }
+ }
+ }
+ return outlen;
+}
+/*- End of function --------------------------------------------------------*/
+
+g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options)
+{
+ if (s == NULL)
+ {
+ if ((s = (g722_encode_state_t *) malloc(sizeof(*s))) == NULL)
+ return NULL;
+ }
+ memset(s, 0, sizeof(*s));
+ if (rate == 48000)
+ s->bits_per_sample = 6;
+ else if (rate == 56000)
+ s->bits_per_sample = 7;
+ else
+ s->bits_per_sample = 8;
+ if ((options & G722_SAMPLE_RATE_8000))
+ s->eight_k = TRUE;
+ if ((options & G722_PACKED) && s->bits_per_sample != 8)
+ s->packed = TRUE;
+ else
+ s->packed = FALSE;
+ s->band[0].det = 32;
+ s->band[1].det = 8;
+ return s;
+}
+/*- End of function --------------------------------------------------------*/
+
+int g722_encode_release(g722_encode_state_t *s)
+{
+ free(s);
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len)
+{
+ int16_t dlow;
+ int16_t dhigh;
+ int el;
+ int wd;
+ int wd1;
+ int ril;
+ int wd2;
+ int il4;
+ int ih2;
+ int wd3;
+ int eh;
+ int g722_bytes;
+ int ihigh;
+ int ilow;
+ int code;
+ /* Low and high band PCM from the QMF */
+ int16_t xlow;
+ int16_t xhigh;
+ int32_t sumeven;
+ int32_t sumodd;
+ int mih;
+ int i;
+ int j;
+
+ g722_bytes = 0;
+ xhigh = 0;
+ for (j = 0; j < len; )
+ {
+ if (s->itu_test_mode)
+ {
+ xlow =
+ xhigh = amp[j++] >> 1;
+ }
+ else
+ {
+ if (s->eight_k)
+ {
+ xlow = amp[j++];
+ }
+ else
+ {
+ /* Apply the transmit QMF */
+ s->x[s->ptr] = amp[j++];
+ s->y[s->ptr] = amp[j++];
+ if (++s->ptr >= 12)
+ s->ptr = 0;
+ sumodd = vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr);
+ sumeven = vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr);
+ xlow = (sumeven + sumodd) >> 13;
+ xhigh = (sumeven - sumodd) >> 13;
+ }
+ }
+ /* Block 1L, SUBTRA */
+ el = saturated_sub16(xlow, s->band[0].s);
+
+ /* Block 1L, QUANTL */
+ wd = (el >= 0) ? el : ~el;
+
+ for (i = 1; i < 30; i++)
+ {
+ wd1 = ((int32_t) q6[i]*(int32_t) s->band[0].det) >> 12;
+ if (wd < wd1)
+ break;
+ }
+ ilow = (el < 0) ? iln[i] : ilp[i];
+
+ /* Block 2L, INVQAL */
+ ril = ilow >> 2;
+ wd2 = qm4[ril];
+ dlow = ((int32_t) s->band[0].det*(int32_t) wd2) >> 15;
+
+ /* Block 3L, LOGSCL */
+ il4 = rl42[ril];
+ wd = ((int32_t) s->band[0].nb*(int32_t) 127) >> 7;
+ s->band[0].nb = wd + wl[il4];
+ if (s->band[0].nb < 0)
+ s->band[0].nb = 0;
+ else if (s->band[0].nb > 18432)
+ s->band[0].nb = 18432;
+
+ /* Block 3L, SCALEL */
+ wd1 = (s->band[0].nb >> 6) & 31;
+ wd2 = 8 - (s->band[0].nb >> 11);
+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
+ s->band[0].det = wd3 << 2;
+
+ block4(&s->band[0], dlow);
+
+ if (s->eight_k)
+ {
+ /* Just leave the high bits as zero */
+ code = (0xC0 | ilow) >> (8 - s->bits_per_sample);
+ }
+ else
+ {
+ /* Block 1H, SUBTRA */
+ eh = saturated_sub16(xhigh, s->band[1].s);
+
+ /* Block 1H, QUANTH */
+ wd = (eh >= 0) ? eh : ~eh;
+ wd1 = (564*s->band[1].det) >> 12;
+ mih = (wd >= wd1) ? 2 : 1;
+ ihigh = (eh < 0) ? ihn[mih] : ihp[mih];
+
+ /* Block 2H, INVQAH */
+ wd2 = qm2[ihigh];
+ dhigh = ((int32_t) s->band[1].det*(int32_t) wd2) >> 15;
+
+ /* Block 3H, LOGSCH */
+ ih2 = rh2[ihigh];
+ wd = ((int32_t) s->band[1].nb*(int32_t) 127) >> 7;
+ s->band[1].nb = wd + wh[ih2];
+ if (s->band[1].nb < 0)
+ s->band[1].nb = 0;
+ else if (s->band[1].nb > 22528)
+ s->band[1].nb = 22528;
+
+ /* Block 3H, SCALEH */
+ wd1 = (s->band[1].nb >> 6) & 31;
+ wd2 = 10 - (s->band[1].nb >> 11);
+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
+ s->band[1].det = wd3 << 2;
+
+ block4(&s->band[1], dhigh);
+ code = ((ihigh << 6) | ilow) >> (8 - s->bits_per_sample);
+ }
+
+ if (s->packed)
+ {
+ /* Pack the code bits */
+ s->out_buffer |= (code << s->out_bits);
+ s->out_bits += s->bits_per_sample;
+ if (s->out_bits >= 8)
+ {
+ g722_data[g722_bytes++] = (uint8_t) (s->out_buffer & 0xFF);
+ s->out_bits -= 8;
+ s->out_buffer >>= 8;
+ }
+ }
+ else
+ {
+ g722_data[g722_bytes++] = (uint8_t) code;
+ }
+ }
+ return g722_bytes;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
Added: freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj Wed Oct 1 00:06:53 2008
@@ -0,0 +1,348 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C"
+ Version="9.00"
+ Name="libspandsp"
+ ProjectGUID="{CF70F278-3364-4395-A2E1-23501C9B8AD2}"
+ RootNamespace="libspandsp"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="src; src\spandsp; src\msvc;..\libtiff\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_MATH_H;HAVE_TGMATH_H"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ ModuleDefinitionFile="src/msvc/spandsp.def"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="src; src\spandsp; src\msvc;..\libtiff\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_MATH_H;HAVE_TGMATH_H"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ ModuleDefinitionFile="src/msvc/spandsp.def"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+<File RelativePath="adsi.c"></File>
+<File RelativePath="async.c"></File>
+<File RelativePath="at_interpreter.c"></File>
+<File RelativePath="awgn.c"></File>
+<File RelativePath="bell_r2_mf.c"></File>
+<File RelativePath="bert.c"></File>
+<File RelativePath="bit_operations.c"></File>
+<File RelativePath="bitstream.c"></File>
+<File RelativePath="complex_filters.c"></File>
+<File RelativePath="complex_vector_float.c"></File>
+<File RelativePath="complex_vector_int.c"></File>
+<File RelativePath="crc.c"></File>
+<File RelativePath="dds_float.c"></File>
+<File RelativePath="dds_int.c"></File>
+<File RelativePath="dtmf.c"></File>
+<File RelativePath="echo.c"></File>
+<File RelativePath="fax.c"></File>
+<File RelativePath="fsk.c"></File>
+<File RelativePath="g711.c"></File>
+<File RelativePath="g722.c"></File>
+<File RelativePath="g726.c"></File>
+<File RelativePath="gsm0610_decode.c"></File>
+<File RelativePath="gsm0610_encode.c"></File>
+<File RelativePath="gsm0610_long_term.c"></File>
+<File RelativePath="gsm0610_lpc.c"></File>
+<File RelativePath="gsm0610_preprocess.c"></File>
+<File RelativePath="gsm0610_rpe.c"></File>
+<File RelativePath="gsm0610_short_term.c"></File>
+<File RelativePath="hdlc.c"></File>
+<File RelativePath="ima_adpcm.c"></File>
+<File RelativePath="logging.c"></File>
+<File RelativePath="lpc10_analyse.c"></File>
+<File RelativePath="lpc10_decode.c"></File>
+<File RelativePath="lpc10_encode.c"></File>
+<File RelativePath="lpc10_placev.c"></File>
+<File RelativePath="lpc10_voicing.c"></File>
+<File RelativePath="modem_echo.c"></File>
+<File RelativePath="modem_connect_tones.c"></File>
+<File RelativePath="noise.c"></File>
+<File RelativePath="oki_adpcm.c"></File>
+<File RelativePath="playout.c"></File>
+<File RelativePath="plc.c"></File>
+<File RelativePath="power_meter.c"></File>
+<File RelativePath="queue.c"></File>
+<File RelativePath="schedule.c"></File>
+<File RelativePath="sig_tone.c"></File>
+<File RelativePath="silence_gen.c"></File>
+<File RelativePath="super_tone_rx.c"></File>
+<File RelativePath="super_tone_tx.c"></File>
+<File RelativePath="t4.c"></File>
+<File RelativePath="t30.c"></File>
+<File RelativePath="t30_api.c"></File>
+<File RelativePath="t30_logging.c"></File>
+<File RelativePath="t31.c"></File>
+<File RelativePath="t35.c"></File>
+<File RelativePath="t38_core.c"></File>
+<File RelativePath="t38_gateway.c"></File>
+<File RelativePath="t38_non_ecm_buffer.c"></File>
+<File RelativePath="t38_terminal.c"></File>
+<File RelativePath="testcpuid.c"></File>
+<File RelativePath="time_scale.c"></File>
+<File RelativePath="tone_detect.c"></File>
+<File RelativePath="tone_generate.c"></File>
+<File RelativePath="v17rx.c"></File>
+<File RelativePath="v17tx.c"></File>
+<File RelativePath="v22bis_rx.c"></File>
+<File RelativePath="v22bis_tx.c"></File>
+<File RelativePath="v27ter_rx.c"></File>
+<File RelativePath="v27ter_tx.c"></File>
+<File RelativePath="v29rx.c"></File>
+<File RelativePath="v29tx.c"></File>
+<File RelativePath="v42.c"></File>
+<File RelativePath="v42bis.c"></File>
+<File RelativePath="v8.c"></File>
+<File RelativePath="vector_float.c"></File>
+<File RelativePath="vector_int.c"></File>
+<File RelativePath="msvc/gettimeofday.c"></File>
+</Filter><Filter Name="Header Files">
+<File RelativePath="spandsp/adsi.h"></File>
+<File RelativePath="spandsp/async.h"></File>
+<File RelativePath="spandsp/arctan2.h"></File>
+<File RelativePath="spandsp/at_interpreter.h"></File>
+<File RelativePath="spandsp/awgn.h"></File>
+<File RelativePath="spandsp/bell_r2_mf.h"></File>
+<File RelativePath="spandsp/bert.h"></File>
+<File RelativePath="spandsp/biquad.h"></File>
+<File RelativePath="spandsp/bit_operations.h"></File>
+<File RelativePath="spandsp/bitstream.h"></File>
+<File RelativePath="spandsp/crc.h"></File>
+<File RelativePath="spandsp/complex.h"></File>
+<File RelativePath="spandsp/complex_filters.h"></File>
+<File RelativePath="spandsp/complex_vector_float.h"></File>
+<File RelativePath="spandsp/complex_vector_int.h"></File>
+<File RelativePath="spandsp/dc_restore.h"></File>
+<File RelativePath="spandsp/dds.h"></File>
+<File RelativePath="spandsp/dtmf.h"></File>
+<File RelativePath="spandsp/echo.h"></File>
+<File RelativePath="spandsp/fax.h"></File>
+<File RelativePath="spandsp/fax_modems.h"></File>
+<File RelativePath="spandsp/fir.h"></File>
+<File RelativePath="spandsp/fsk.h"></File>
+<File RelativePath="spandsp/g168models.h"></File>
+<File RelativePath="spandsp/g711.h"></File>
+<File RelativePath="spandsp/g722.h"></File>
+<File RelativePath="spandsp/g726.h"></File>
+<File RelativePath="spandsp/gsm0610.h"></File>
+<File RelativePath="spandsp/hdlc.h"></File>
+<File RelativePath="spandsp/ima_adpcm.h"></File>
+<File RelativePath="spandsp/logging.h"></File>
+<File RelativePath="spandsp/lpc10.h"></File>
+<File RelativePath="spandsp/modem_echo.h"></File>
+<File RelativePath="spandsp/modem_connect_tones.h"></File>
+<File RelativePath="spandsp/noise.h"></File>
+<File RelativePath="spandsp/oki_adpcm.h"></File>
+<File RelativePath="spandsp/playout.h"></File>
+<File RelativePath="spandsp/plc.h"></File>
+<File RelativePath="spandsp/power_meter.h"></File>
+<File RelativePath="spandsp/queue.h"></File>
+<File RelativePath="spandsp/schedule.h"></File>
+<File RelativePath="spandsp/sig_tone.h"></File>
+<File RelativePath="spandsp/silence_gen.h"></File>
+<File RelativePath="spandsp/super_tone_rx.h"></File>
+<File RelativePath="spandsp/super_tone_tx.h"></File>
+<File RelativePath="spandsp/t4.h"></File>
+<File RelativePath="spandsp/t30.h"></File>
+<File RelativePath="spandsp/t30_api.h"></File>
+<File RelativePath="spandsp/t30_fcf.h"></File>
+<File RelativePath="spandsp/t30_logging.h"></File>
+<File RelativePath="spandsp/t31.h"></File>
+<File RelativePath="spandsp/t35.h"></File>
+<File RelativePath="spandsp/t38_core.h"></File>
+<File RelativePath="spandsp/t38_gateway.h"></File>
+<File RelativePath="spandsp/t38_non_ecm_buffer.h"></File>
+<File RelativePath="spandsp/t38_terminal.h"></File>
+<File RelativePath="spandsp/telephony.h"></File>
+<File RelativePath="spandsp/time_scale.h"></File>
+<File RelativePath="spandsp/timing.h"></File>
+<File RelativePath="spandsp/tone_detect.h"></File>
+<File RelativePath="spandsp/tone_generate.h"></File>
+<File RelativePath="spandsp/v17rx.h"></File>
+<File RelativePath="spandsp/v17tx.h"></File>
+<File RelativePath="spandsp/v22bis.h"></File>
+<File RelativePath="spandsp/v27ter_rx.h"></File>
+<File RelativePath="spandsp/v27ter_tx.h"></File>
+<File RelativePath="spandsp/v29rx.h"></File>
+<File RelativePath="spandsp/v29tx.h"></File>
+<File RelativePath="spandsp/v42.h"></File>
+<File RelativePath="spandsp/v42bis.h"></File>
+<File RelativePath="spandsp/v8.h"></File>
+<File RelativePath="spandsp/vector_float.h"></File>
+<File RelativePath="spandsp/vector_int.h"></File>
+<File RelativePath="spandsp/version.h"></File>
+<File RelativePath="spandsp.h"></File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\src\msvc\spandsp.def"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/g722.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/g722.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/g722.h Wed Oct 1 00:06:53 2008
@@ -28,7 +28,7 @@
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
*
- * $Id: g722.h,v 1.20 2008/09/19 14:02:05 steveu Exp $
+ * $Id: g722.h,v 1.21 2008/09/19 16:24:25 steveu Exp $
*/
@@ -59,15 +59,15 @@
/*! The per band parameters for both encoding and decoding G.722 */
typedef struct
{
+ int16_t nb;
+ int16_t det;
int16_t s;
int16_t sz;
- int16_t r[3];
- int16_t a[3];
- int16_t p[3];
+ int16_t r;
+ int16_t p[2];
+ int16_t a[2];
+ int16_t b[6];
int16_t d[7];
- int16_t b[7];
- int16_t nb;
- int16_t det;
} g722_band_t;
typedef struct
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Wed Oct 1 00:06:53 2008
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20080919
-#define SPANDSP_RELEASE_TIME 142905
+#define SPANDSP_RELEASE_DATE 20080920
+#define SPANDSP_RELEASE_TIME 154737
#endif
/*- End of file ------------------------------------------------------------*/
Added: freeswitch/trunk/libs/spandsp/tests/complex_tests.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/tests/complex_tests.c Wed Oct 1 00:06:53 2008
@@ -0,0 +1,81 @@
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * complex.c
+ *
+ * Written by Steve Underwood <steveu(a)coppice.org>
+ *
+ * Copyright (C) 2008 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: complex_tests.c,v 1.1 2008/09/18 12:09:51 steveu Exp $
+ */
+
+/*! \page complex_tests_page Complex arithmetic tests
+\section complex_tests_page_sec_1 What does it do?
+
+\section complex_tests_page_sec_2 How is it used?
+*/
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include "floating_fudge.h"
+#if defined(HAVE_TGMATH_H)
+#include <tgmath.h>
+#endif
+#if defined(HAVE_MATH_H)
+#include <math.h>
+#endif
+#include <assert.h>
+
+#include "spandsp.h"
+
+int main(int argc, char *argv[])
+{
+ complexf_t fa;
+ complexf_t fb;
+ complexf_t fz;
+ complexi16_t i16a;
+ complexi16_t i16b;
+ complexi16_t i16z;
+#if 0
+ complexi32_t i32a;
+ complexi32_t i32b;
+ complexi32_t i32z;
+#endif
+
+ fa = complex_setf(0.5f, 0.25f);
+ fb = complex_setf(0.25f, 0.5f);
+ fz = complex_mulf(&fa, &fb);
+ printf("(%f, %f) * (%f, %f) => (%f, %f)\n", fa.re, fa.im, fb.re, fb.im, fz.re, fz.im);
+
+ i16a = complex_seti16(16383, 8191);
+ i16b = complex_seti16(8191, 16383);
+ i16z = complex_mul_q1_15(&i16a, &i16b);
+ printf("(%f, %f) * (%f, %f) => (%f, %f)\n", i16a.re/32768.0, i16a.im/32768.0, i16b.re/32768.0, i16b.im/32768.0, i16z.re/32768.0, i16z.im/32768.0);
+
+ printf("Tests passed.\n");
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
Added: freeswitch/trunk/libs/spandsp/tests/complex_vector_float_tests.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/tests/complex_vector_float_tests.c Wed Oct 1 00:06:53 2008
@@ -0,0 +1,99 @@
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * complex_vector_float_tests.c
+ *
+ * Written by Steve Underwood <steveu(a)coppice.org>
+ *
+ * Copyright (C) 2006,2008 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: complex_vector_float_tests.c,v 1.1 2008/09/18 12:05:35 steveu Exp $
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <audiofile.h>
+
+#include "spandsp.h"
+
+static complexf_t cvec_dot_prodf_dumb(const complexf_t x[], const complexf_t y[], int n)
+{
+ int i;
+ complexf_t z;
+ complexf_t z1;
+
+ z = complex_setf(0.0f, 0.0f);
+ for (i = 0; i < n; i++)
+ {
+ z1 = complex_mulf(&x[i], &y[i]);
+ z = complex_addf(&z, &z1);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_cvec_dot_prodf(void)
+{
+ int i;
+ complexf_t x[100];
+ complexf_t y[100];
+ complexf_t zsa;
+ complexf_t zsb;
+ complexf_t ratio;
+
+ for (i = 0; i < 99; i++)
+ {
+ x[i].re = rand();
+ x[i].im = rand();
+ y[i].re = rand();
+ y[i].im = rand();
+ }
+ for (i = 1; i < 99; i++)
+ {
+ zsa = cvec_dot_prodf(x, y, i);
+ zsb = cvec_dot_prodf_dumb(x, y, i);
+ ratio.re = zsa.re/zsb.re;
+ ratio.im = zsa.im/zsb.im;
+ if ((ratio.re < 0.9999 || ratio.re > 1.0001)
+ ||
+ (ratio.im < 0.9999 || ratio.im > 1.0001))
+ {
+ printf("vec_dot_prod() - (%f,%f) (%f,%f)\n", zsa.re, zsa.im, zsb.re, zsb.im);
+ printf("Tests failed\n");
+ exit(2);
+ }
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ test_cvec_dot_prodf();
+
+ printf("Tests passed.\n");
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
Added: freeswitch/trunk/libs/spandsp/tests/complex_vector_int_tests.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/spandsp/tests/complex_vector_int_tests.c Wed Oct 1 00:06:53 2008
@@ -0,0 +1,137 @@
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * complex_vector_int_tests.c
+ *
+ * Written by Steve Underwood <steveu(a)coppice.org>
+ *
+ * Copyright (C) 2006 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: complex_vector_int_tests.c,v 1.1 2008/09/18 12:05:35 steveu Exp $
+ */
+
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <audiofile.h>
+
+#include "spandsp.h"
+
+static complexi32_t cvec_dot_prodi16_dumb(const complexi16_t x[], const complexi16_t y[], int n)
+{
+ complexi32_t z;
+ int i;
+
+ z = complex_seti32(0, 0);
+ for (i = 0; i < n; i++)
+ {
+ z.re += ((int32_t) x[i].re*(int32_t) y[i].re - (int32_t) x[i].im*(int32_t) y[i].im);
+ z.im += ((int32_t) x[i].re*(int32_t) y[i].im + (int32_t) x[i].im*(int32_t) y[i].re);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_cvec_dot_prodi16(void)
+{
+ int i;
+ complexi32_t za;
+ complexi32_t zb;
+ complexi16_t x[99];
+ complexi16_t y[99];
+
+ for (i = 0; i < 99; i++)
+ {
+ x[i].re = rand();
+ x[i].im = rand();
+ y[i].re = rand();
+ y[i].im = rand();
+ }
+
+ for (i = 1; i < 99; i++)
+ {
+ za = cvec_dot_prodi16(x, y, i);
+ zb = cvec_dot_prodi16_dumb(x, y, i);
+ if (za.re != zb.re || za.im != zb.im)
+ {
+ printf("Tests failed\n");
+ exit(2);
+ }
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_cvec_circular_dot_prodi16(void)
+{
+ int i;
+ int j;
+ int pos;
+ int len;
+ complexi32_t za;
+ complexi32_t zb;
+ complexi16_t x[99];
+ complexi16_t y[99];
+
+ /* Verify that we can do circular sample buffer "dot" linear coefficient buffer
+ operations properly, by doing two sub-dot products. */
+ for (i = 0; i < 99; i++)
+ {
+ x[i].re = rand();
+ x[i].im = rand();
+ y[i].re = rand();
+ y[i].im = rand();
+ }
+
+ len = 95;
+ for (pos = 0; pos < len; pos++)
+ {
+ za = cvec_circular_dot_prodi16(x, y, len, pos);
+ zb = complex_seti32(0, 0);
+ for (i = 0; i < len; i++)
+ {
+ j = (pos + i) % len;
+ zb.re += ((int32_t) x[j].re*(int32_t) y[i].re - (int32_t) x[j].im*(int32_t) y[i].im);
+ zb.im += ((int32_t) x[j].re*(int32_t) y[i].im + (int32_t) x[j].im*(int32_t) y[i].re);
+ }
+
+ if (za.re != zb.re || za.im != zb.im)
+ {
+ printf("Tests failed\n");
+ exit(2);
+ }
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ test_cvec_dot_prodi16();
+ test_cvec_circular_dot_prodi16();
+
+ printf("Tests passed.\n");
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
1
0
[commit] r9770 - in freeswitch/trunk/libs/spandsp: . src src/spandsp tests
by Freeswitch SVN 01 Oct '08
by Freeswitch SVN 01 Oct '08
01 Oct '08
Author: anthm
Date: Tue Sep 30 23:59:45 2008
New Revision: 9770
Modified:
freeswitch/trunk/libs/spandsp/.update
freeswitch/trunk/libs/spandsp/src/Makefile.am
freeswitch/trunk/libs/spandsp/src/awgn.c
freeswitch/trunk/libs/spandsp/src/complex_vector_float.c
freeswitch/trunk/libs/spandsp/src/echo.c
freeswitch/trunk/libs/spandsp/src/gsm0610_decode.c
freeswitch/trunk/libs/spandsp/src/gsm0610_encode.c
freeswitch/trunk/libs/spandsp/src/gsm0610_long_term.c
freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c
freeswitch/trunk/libs/spandsp/src/gsm0610_preprocess.c
freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c
freeswitch/trunk/libs/spandsp/src/gsm0610_short_term.c
freeswitch/trunk/libs/spandsp/src/ima_adpcm.c
freeswitch/trunk/libs/spandsp/src/libspandsp.dsp
freeswitch/trunk/libs/spandsp/src/make_modem_filter.c
freeswitch/trunk/libs/spandsp/src/noise.c
freeswitch/trunk/libs/spandsp/src/plc.c
freeswitch/trunk/libs/spandsp/src/sig_tone.c
freeswitch/trunk/libs/spandsp/src/spandsp.h.in
freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h
freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_int.h
freeswitch/trunk/libs/spandsp/src/spandsp/dc_restore.h
freeswitch/trunk/libs/spandsp/src/spandsp/g722.h
freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h
freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h
freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h
freeswitch/trunk/libs/spandsp/src/spandsp/vector_float.h
freeswitch/trunk/libs/spandsp/src/spandsp/vector_int.h
freeswitch/trunk/libs/spandsp/src/spandsp/version.h
freeswitch/trunk/libs/spandsp/src/time_scale.c
freeswitch/trunk/libs/spandsp/src/v17rx.c
freeswitch/trunk/libs/spandsp/src/v22bis_rx.c
freeswitch/trunk/libs/spandsp/src/v27ter_rx.c
freeswitch/trunk/libs/spandsp/src/v29rx.c
freeswitch/trunk/libs/spandsp/src/vector_float.c
freeswitch/trunk/libs/spandsp/src/vector_int.c
freeswitch/trunk/libs/spandsp/tests/Makefile.am
freeswitch/trunk/libs/spandsp/tests/g722_tests.c
freeswitch/trunk/libs/spandsp/tests/regression_tests.sh
freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c
Log:
update to snapshot spandsp-20080919.tar.gz
Modified: freeswitch/trunk/libs/spandsp/.update
==============================================================================
--- freeswitch/trunk/libs/spandsp/.update (original)
+++ freeswitch/trunk/libs/spandsp/.update Tue Sep 30 23:59:45 2008
@@ -1 +1 @@
-Tue Sep 30 23:55:26 EDT 2008
+Tue Sep 30 23:59:24 EDT 2008
Modified: freeswitch/trunk/libs/spandsp/src/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/src/Makefile.am Tue Sep 30 23:59:45 2008
@@ -16,7 +16,7 @@
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.101 2008/09/08 12:45:02 steveu Exp $
+## $Id: Makefile.am,v 1.103 2008/09/19 14:02:05 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@@ -37,6 +37,7 @@
bitstream.c \
complex_filters.c \
complex_vector_float.c \
+ complex_vector_int.c \
crc.c \
dds_float.c \
dds_int.c \
@@ -45,8 +46,7 @@
fax.c \
fsk.c \
g711.c \
- g722_encode.c \
- g722_decode.c \
+ g722.c \
g726.c \
gsm0610_decode.c \
gsm0610_encode.c \
Modified: freeswitch/trunk/libs/spandsp/src/awgn.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/awgn.c (original)
+++ freeswitch/trunk/libs/spandsp/src/awgn.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: awgn.c,v 1.16 2008/07/02 14:48:25 steveu Exp $
+ * $Id: awgn.c,v 1.17 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -57,7 +57,7 @@
#endif
#include "spandsp/telephony.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/awgn.h"
/* Gaussian noise generator constants */
Modified: freeswitch/trunk/libs/spandsp/src/complex_vector_float.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/complex_vector_float.c (original)
+++ freeswitch/trunk/libs/spandsp/src/complex_vector_float.c Tue Sep 30 23:59:45 2008
@@ -1,7 +1,7 @@
/*
* SpanDSP - a series of DSP components for telephony
*
- * vector_float.c - Floating vector arithmetic routines.
+ * complex_vector_float.c - Floating complex vector arithmetic routines.
*
* Written by Steve Underwood <steveu(a)coppice.org>
*
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: complex_vector_float.c,v 1.8 2008/07/02 14:48:25 steveu Exp $
+ * $Id: complex_vector_float.c,v 1.10 2008/09/18 13:16:49 steveu Exp $
*/
/*! \file */
@@ -50,4 +50,84 @@
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+complexf_t cvec_dot_prodf(const complexf_t x[], const complexf_t y[], int n)
+{
+ int i;
+ complexf_t z;
+
+ z = complex_setf(0.0f, 0.0f);
+ for (i = 0; i < n; i++)
+ {
+ z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
+ z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+complex_t cvec_dot_prod(const complex_t x[], const complex_t y[], int n)
+{
+ int i;
+ complex_t z;
+
+ z = complex_set(0.0, 0.0);
+ for (i = 0; i < n; i++)
+ {
+ z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
+ z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+#if defined(HAVE_LONG_DOUBLE)
+complexl_t cvec_dot_prodl(const complexl_t x[], const complexl_t y[], int n)
+{
+ int i;
+ complexl_t z;
+
+ z = complex_setl(0.0L, 0.0L);
+ for (i = 0; i < n; i++)
+ {
+ z.re += (x[i].re*y[i].re - x[i].im*y[i].im);
+ z.im += (x[i].re*y[i].im + x[i].im*y[i].re);
+ }
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
+complexf_t cvec_circular_dot_prodf(const complexf_t x[], const complexf_t y[], int n, int pos)
+{
+ complexf_t z;
+ complexf_t z1;
+
+ z = cvec_dot_prodf(&x[pos], &y[0], n - pos);
+ z1 = cvec_dot_prodf(&x[0], &y[n - pos], pos);
+ z = complex_addf(&z, &z1);
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+void cvec_lmsf(const complexf_t x[], complexf_t y[], int n, const complexf_t *error)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ y[i].re += (x[i].im*error->im + x[i].re*error->re);
+ y[i].im += (x[i].re*error->im - x[i].im*error->re);
+ /* Leak a little to tame uncontrolled wandering */
+ y[i].re *= 0.9999f;
+ y[i].im *= 0.9999f;
+ }
+}
+/*- End of function --------------------------------------------------------*/
+
+void cvec_circular_lmsf(const complexf_t x[], complexf_t y[], int n, int pos, const complexf_t *error)
+{
+ cvec_lmsf(&x[pos], &y[0], n - pos, error);
+ cvec_lmsf(&x[0], &y[n - pos], pos, error);
+}
+/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/echo.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/echo.c (original)
+++ freeswitch/trunk/libs/spandsp/src/echo.c Tue Sep 30 23:59:45 2008
@@ -27,7 +27,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: echo.c,v 1.27 2008/08/29 09:28:13 steveu Exp $
+ * $Id: echo.c,v 1.28 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -96,6 +96,7 @@
#include "spandsp/telephony.h"
#include "spandsp/logging.h"
+#include "spandsp/saturated.h"
#include "spandsp/dc_restore.h"
#include "spandsp/bit_operations.h"
#include "spandsp/echo.h"
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_decode.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_decode.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_decode.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_decode.c,v 1.21 2008/07/02 14:48:25 steveu Exp $
+ * $Id: gsm0610_decode.c,v 1.22 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -48,7 +48,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/gsm0610.h"
#include "gsm0610_local.h"
@@ -66,9 +66,9 @@
{
tmp = gsm_mult_r(msr, 28180);
/* De-emphasis */
- msr = gsm_add(amp[k], tmp);
+ msr = saturated_add16(amp[k], tmp);
/* Truncation & upscaling */
- amp[k] = (int16_t) (gsm_add(msr, msr) & 0xFFF8);
+ amp[k] = (int16_t) (saturated_add16(msr, msr) & 0xFFF8);
}
/*endfor*/
s->msr = msr;
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_encode.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_encode.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_encode.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_encode.c,v 1.25 2008/07/02 14:48:25 steveu Exp $
+ * $Id: gsm0610_encode.c,v 1.26 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -48,7 +48,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/gsm0610.h"
#include "gsm0610_local.h"
@@ -93,7 +93,7 @@
gsm0610_rpe_encoding(s, s->e + 5, &f->xmaxc[k], &f->Mc[k], f->xMc[k]);
for (i = 0; i < 40; i++)
- dp[i] = gsm_add(s->e[5 + i], dpp[i]);
+ dp[i] = saturated_add16(s->e[5 + i], dpp[i]);
/*endfor*/
dp += 40;
dpp += 40;
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_long_term.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_long_term.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_long_term.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_long_term.c,v 1.16 2008/07/02 14:48:25 steveu Exp $
+ * $Id: gsm0610_long_term.c,v 1.17 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -47,7 +47,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/gsm0610.h"
#include "gsm0610_local.h"
@@ -185,7 +185,7 @@
for (k = 0; k < 40; k++)
{
temp = d[k];
- temp = gsm_abs(temp);
+ temp = saturated_abs16(temp);
if (temp > dmax)
dmax = temp;
/*endif*/
@@ -314,12 +314,12 @@
quantization of the LTP gain b to get the coded version bc. */
for (bc = 0; bc <= 2; bc++)
{
- if (R <= gsm_mult(S, gsm_DLB[bc]))
+ if (R <= saturated_mul16(S, gsm_DLB[bc]))
break;
/*endif*/
}
/*endfor*/
- return bc;
+ return bc;
}
/*- End of function --------------------------------------------------------*/
@@ -340,7 +340,7 @@
for (k = 0; k < 40; k++)
{
dpp[k] = gsm_mult_r(gsm_QLB[bc], dp[k - Nc]);
- e[k] = gsm_sub(d[k], dpp[k]);
+ e[k] = saturated_sub16(d[k], dpp[k]);
}
/*endfor*/
}
@@ -398,7 +398,7 @@
for (k = 0; k < 40; k++)
{
drpp = gsm_mult_r(brp, drp[k - Nr]);
- drp[k] = gsm_add(erp[k], drpp);
+ drp[k] = saturated_add16(erp[k], drpp);
}
/*endfor*/
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_lpc.c,v 1.21 2008/09/04 14:40:05 steveu Exp $
+ * $Id: gsm0610_lpc.c,v 1.22 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -49,7 +49,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
#include "spandsp/bit_operations.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/vector_int.h"
#include "spandsp/gsm0610.h"
@@ -230,7 +230,7 @@
#else
for (smax = 0, k = 0; k < GSM0610_FRAME_LEN; k++)
{
- temp = gsm_abs(amp[k]);
+ temp = saturated_abs16(amp[k]);
if (temp > smax)
smax = (int16_t) temp;
/*endif*/
@@ -398,7 +398,7 @@
for (n = 1; n <= 8; n++, r++)
{
temp = P[1];
- temp = gsm_abs (temp);
+ temp = saturated_abs16(temp);
if (P[0] < temp)
{
for (i = n; i <= 8; i++)
@@ -421,15 +421,15 @@
/* Schur recursion */
temp = gsm_mult_r(P[1], *r);
- P[0] = gsm_add(P[0], temp);
+ P[0] = saturated_add16(P[0], temp);
for (m = 1; m <= 8 - n; m++)
{
temp = gsm_mult_r(K[m], *r);
- P[m] = gsm_add(P[m + 1], temp);
+ P[m] = saturated_add16(P[m + 1], temp);
temp = gsm_mult_r(P[m + 1], *r);
- K[m] = gsm_add(K[m], temp);
+ K[m] = saturated_add16(K[m], temp);
}
/*endfor*/
}
@@ -453,8 +453,7 @@
/* Computation of the LAR[0..7] from the r[0..7] */
for (i = 1; i <= 8; i++, r++)
{
- temp = *r;
- temp = gsm_abs(temp);
+ temp = saturated_abs16(*r);
assert(temp >= 0);
if (temp < 22118)
@@ -496,9 +495,9 @@
#undef STEP
#define STEP(A,B,MAC,MIC) \
- temp = gsm_mult(A, *LAR); \
- temp = gsm_add(temp, B); \
- temp = gsm_add(temp, 256); \
+ temp = saturated_mul16(A, *LAR); \
+ temp = saturated_add16(temp, B); \
+ temp = saturated_add16(temp, 256); \
temp >>= 9; \
*LAR = (int16_t) ((temp > MAC) \
? \
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_preprocess.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_preprocess.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_preprocess.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_preprocess.c,v 1.13 2008/07/02 14:48:25 steveu Exp $
+ * $Id: gsm0610_preprocess.c,v 1.14 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -47,7 +47,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/gsm0610.h"
#include "gsm0610_local.h"
@@ -121,7 +121,7 @@
* L_temp = (++L_temp) >> 1;
* L_z2 = L_z2 - L_temp;
*/
- L_z2 = gsm_l_add(L_z2, L_s2);
+ L_z2 = saturated_add32(L_z2, L_s2);
#else
/* This does L_z2 = L_z2 * 0x7FD5/0x8000 + L_s2 */
msp = (int16_t) (L_z2 >> 15);
@@ -129,16 +129,16 @@
L_s2 += gsm_mult_r(lsp, 32735);
L_temp = (int32_t) msp*32735;
- L_z2 = gsm_l_add(L_temp, L_s2);
+ L_z2 = saturated_add32(L_temp, L_s2);
#endif
/* Compute sof[k] with rounding */
- L_temp = gsm_l_add(L_z2, 16384);
+ L_temp = saturated_add32(L_z2, 16384);
/* 4.2.3 Preemphasis */
msp = gsm_mult_r(mp, -28180);
mp = (int16_t) (L_temp >> 15);
- so[k] = gsm_add(mp, msp);
+ so[k] = saturated_add16(mp, msp);
}
/*endfor*/
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_rpe.c,v 1.21 2008/07/02 14:48:25 steveu Exp $
+ * $Id: gsm0610_rpe.c,v 1.22 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -47,7 +47,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/gsm0610.h"
#include "gsm0610_local.h"
@@ -139,8 +139,8 @@
/* for (i = 0; i <= 10; i++)
* {
- * L_temp = gsm_l_mult(wt[k + i], gsm_H[i]);
- * L_result = gsm_l_add(L_result, L_temp);
+ * L_temp = saturated_mul_16_32(wt[k + i], gsm_H[i]);
+ * L_result = saturated_add32(L_result, L_temp);
* }
*/
@@ -351,7 +351,7 @@
for (i = 0; i < 13; i++)
{
temp = xM[i];
- temp = gsm_abs(temp);
+ temp = saturated_abs16(temp);
if (temp > xmax)
xmax = temp;
/*endif*/
@@ -379,7 +379,7 @@
temp = (int16_t) (exp + 5);
assert(temp <= 11 && temp >= 0);
- xmaxc = gsm_add((xmax >> temp), exp << 3);
+ xmaxc = saturated_add16((xmax >> temp), exp << 3);
/* Quantizing and coding of the xM[0..12] RPE sequence
to get the xMc[0..12] */
@@ -406,7 +406,7 @@
assert(temp1 >= 0 && temp1 < 16);
temp = xM[i] << temp1;
- temp = gsm_mult(temp, temp2);
+ temp = saturated_mul16(temp, temp2);
temp >>= 12;
xMc[i] = (int16_t) (temp + 4); /* See note below */
}
@@ -444,9 +444,9 @@
assert(mant >= 0 && mant <= 7);
#endif
- temp1 = gsm_FAC[mant]; /* See 4.2-15 for mant */
- temp2 = gsm_sub(6, exp); /* See 4.2-15 for exp */
- temp3 = gsm_asl(1, gsm_sub (temp2, 1));
+ temp1 = gsm_FAC[mant]; /* See 4.2-15 for mant */
+ temp2 = saturated_sub16(6, exp); /* See 4.2-15 for exp */
+ temp3 = gsm_asl(1, saturated_sub16(temp2, 1));
for (i = 0; i < 13; i++)
{
@@ -457,7 +457,7 @@
temp <<= 12; /* 16 bit signed */
temp = gsm_mult_r(temp1, temp);
- temp = gsm_add(temp, temp3);
+ temp = saturated_add16(temp, temp3);
xMp[i] = gsm_asr(temp, temp2);
}
/*endfor*/
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_short_term.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_short_term.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_short_term.c Tue Sep 30 23:59:45 2008
@@ -25,7 +25,7 @@
* This code is based on the widely used GSM 06.10 code available from
* http://kbs.cs.tu-berlin.de/~jutta/toast.html
*
- * $Id: gsm0610_short_term.c,v 1.15 2008/07/02 14:48:25 steveu Exp $
+ * $Id: gsm0610_short_term.c,v 1.16 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -47,7 +47,7 @@
#include "spandsp/telephony.h"
#include "spandsp/bitstream.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/gsm0610.h"
#include "gsm0610_local.h"
@@ -68,11 +68,11 @@
/* Compute the LARpp[1..8] */
#undef STEP
-#define STEP(B,MIC,INVA) \
- temp1 = gsm_add(*LARc++, MIC) << 10; \
- temp1 = gsm_sub(temp1, B << 1); \
- temp1 = gsm_mult_r (INVA, temp1); \
- *LARpp++ = gsm_add(temp1, temp1);
+#define STEP(B,MIC,INVA) \
+ temp1 = saturated_add16(*LARc++, MIC) << 10; \
+ temp1 = saturated_sub16(temp1, B << 1); \
+ temp1 = gsm_mult_r(INVA, temp1); \
+ *LARpp++ = saturated_add16(temp1, temp1);
STEP( 0, -32, 13107);
STEP( 0, -32, 13107);
@@ -110,8 +110,8 @@
for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++)
{
- *LARp = gsm_add(*LARpp_j_1 >> 2, *LARpp_j >> 2);
- *LARp = gsm_add(*LARp, *LARpp_j_1 >> 1);
+ *LARp = saturated_add16(*LARpp_j_1 >> 2, *LARpp_j >> 2);
+ *LARp = saturated_add16(*LARp, *LARpp_j_1 >> 1);
}
/*endfor*/
}
@@ -124,7 +124,7 @@
int i;
for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++)
- *LARp = gsm_add(*LARpp_j_1 >> 1, *LARpp_j >> 1);
+ *LARp = saturated_add16(*LARpp_j_1 >> 1, *LARpp_j >> 1);
/*endfor*/
}
/*- End of function --------------------------------------------------------*/
@@ -137,8 +137,8 @@
for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++)
{
- *LARp = gsm_add(*LARpp_j_1 >> 2, *LARpp_j >> 2);
- *LARp = gsm_add(*LARp, *LARpp_j >> 1);
+ *LARp = saturated_add16(*LARpp_j_1 >> 2, *LARpp_j >> 2);
+ *LARp = saturated_add16(*LARp, *LARpp_j >> 1);
}
/*endfor*/
}
@@ -182,7 +182,7 @@
else if (temp < 20070)
temp += 11059;
else
- temp = gsm_add(temp >> 2, 26112);
+ temp = saturated_add16(temp >> 2, 26112);
/*endif*/
*LARpx = -temp;
}
@@ -193,7 +193,7 @@
else if (temp < 20070)
temp += 11059;
else
- temp = gsm_add(temp >> 2, 26112);
+ temp = saturated_add16(temp >> 2, 26112);
/*endif*/
*LARpx = temp;
}
@@ -279,7 +279,7 @@
:
(int16_t) (((int32_t) tmp1*(int32_t) tmp2 + 16384) >> 15) & 0xFFFF);
- sri = gsm_sub(sri, tmp2);
+ sri = saturated_sub16(sri, tmp2);
tmp1 = ((tmp1 == INT16_MIN && sri == INT16_MIN)
?
@@ -287,7 +287,7 @@
:
(int16_t) (((int32_t) tmp1*(int32_t) sri + 16384) >> 15) & 0xFFFF);
- v[i + 1] = gsm_add(v[i], tmp1);
+ v[i + 1] = saturated_add16(v[i], tmp1);
}
/*endfor*/
*sr++ =
Modified: freeswitch/trunk/libs/spandsp/src/ima_adpcm.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/ima_adpcm.c (original)
+++ freeswitch/trunk/libs/spandsp/src/ima_adpcm.c Tue Sep 30 23:59:45 2008
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: ima_adpcm.c,v 1.28 2008/07/02 14:48:25 steveu Exp $
+ * $Id: ima_adpcm.c,v 1.29 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -44,7 +44,7 @@
#endif
#include "spandsp/telephony.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/ima_adpcm.h"
/*
Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.dsp
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/libspandsp.dsp (original)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.dsp Tue Sep 30 23:59:45 2008
@@ -133,6 +133,10 @@
# End Source File
# Begin Source File
+SOURCE=.\complex_vector_int.c
+# End Source File
+# Begin Source File
+
SOURCE=.\crc.c
# End Source File
# Begin Source File
@@ -165,11 +169,7 @@
# End Source File
# Begin Source File
-SOURCE=.\g722_encode.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\g722_decode.c
+SOURCE=.\g722.c
# End Source File
# Begin Source File
Modified: freeswitch/trunk/libs/spandsp/src/make_modem_filter.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/make_modem_filter.c (original)
+++ freeswitch/trunk/libs/spandsp/src/make_modem_filter.c Tue Sep 30 23:59:45 2008
@@ -23,7 +23,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: make_modem_filter.c,v 1.11 2008/07/02 14:48:25 steveu Exp $
+ * $Id: make_modem_filter.c,v 1.12 2008/09/18 14:59:30 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
@@ -158,6 +158,7 @@
{
int i;
int j;
+ int k;
int m;
int x;
int total_coeffs;
@@ -166,7 +167,11 @@
double gain;
double peak;
double coeffs[MAX_COEFF_SETS*MAX_COEFFS_PER_FILTER + 1];
+#if 0
complex_t co[MAX_COEFFS_PER_FILTER];
+#else
+ double cox[MAX_COEFFS_PER_FILTER];
+#endif
total_coeffs = coeff_sets*coeffs_per_filter + 1;
alpha = baud_rate/(2.0*(double) (coeff_sets*SAMPLE_RATE));
@@ -203,6 +208,7 @@
modem code. */
printf("#define RX_PULSESHAPER%s_GAIN %ff\n", tag, gain);
printf("#define RX_PULSESHAPER%s_COEFF_SETS %d\n", tag, coeff_sets);
+#if 0
printf("static const %s rx_pulseshaper%s[RX_PULSESHAPER%s_COEFF_SETS][%d] =\n",
(fixed_point) ? "complexi16_t" : "complexf_t",
tag,
@@ -244,6 +250,55 @@
printf(" }\n");
}
printf("};\n");
+#else
+ for (k = 0; k < 2; k++)
+ {
+ printf("static const %s rx_pulseshaper%s_%s[RX_PULSESHAPER%s_COEFF_SETS][%d] =\n",
+ (fixed_point) ? "int16_t" : "float",
+ tag,
+ (k == 0) ? "re" : "im",
+ tag,
+ coeffs_per_filter);
+ printf("{\n");
+ for (j = 0; j < coeff_sets; j++)
+ {
+ /* Complex modulate the filter, to make it a complex pulse shaping bandpass filter
+ centred at the nominal carrier frequency. Use the same phase for all the coefficient
+ sets. This means the modem can step the carrier in whole samples, and not worry about
+ the fractional sample shift caused by selecting amongst the various coefficient sets. */
+ for (i = 0; i < coeffs_per_filter; i++)
+ {
+ m = i - (coeffs_per_filter >> 1);
+ x = i*coeff_sets + j;
+ if (k == 0)
+ cox[i] = coeffs[x]*cos(carrier*m);
+ else
+ cox[i] = coeffs[x]*sin(carrier*m);
+ }
+ printf(" {\n");
+ if (fixed_point)
+ printf(" %8d, /* Filter %d */\n", (int) cox[0], j);
+ else
+ printf(" %15.10ff, /* Filter %d */\n", cox[0], j);
+ for (i = 1; i < coeffs_per_filter - 1; i++)
+ {
+ if (fixed_point)
+ printf(" %8d,\n", (int) cox[i]);
+ else
+ printf(" %15.10ff,\n", cox[i]);
+ }
+ if (fixed_point)
+ printf(" %8d\n", (int) cox[i]);
+ else
+ printf(" %15.10ff\n", cox[i]);
+ if (j < coeff_sets - 1)
+ printf(" },\n");
+ else
+ printf(" }\n");
+ }
+ printf("};\n");
+ }
+#endif
}
/*- End of function --------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/noise.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/noise.c (original)
+++ freeswitch/trunk/libs/spandsp/src/noise.c Tue Sep 30 23:59:45 2008
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: noise.c,v 1.24 2008/08/17 14:18:11 steveu Exp $
+ * $Id: noise.c,v 1.25 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -45,7 +45,7 @@
#endif
#include "spandsp/telephony.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/noise.h"
int16_t noise(noise_state_t *s)
Modified: freeswitch/trunk/libs/spandsp/src/plc.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/plc.c (original)
+++ freeswitch/trunk/libs/spandsp/src/plc.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: plc.c,v 1.22 2008/07/02 14:48:25 steveu Exp $
+ * $Id: plc.c,v 1.23 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -45,7 +45,7 @@
#include <limits.h>
#include "spandsp/telephony.h"
-#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/plc.h"
/* We do a straight line fade to zero volume in 50ms when we are filling in for missing data. */
Modified: freeswitch/trunk/libs/spandsp/src/sig_tone.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/sig_tone.c (original)
+++ freeswitch/trunk/libs/spandsp/src/sig_tone.c Tue Sep 30 23:59:45 2008
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: sig_tone.c,v 1.24 2008/08/17 16:25:52 steveu Exp $
+ * $Id: sig_tone.c,v 1.25 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -48,6 +48,7 @@
#undef SPANDSP_USE_FIXED_POINT
#include "spandsp/telephony.h"
#include "spandsp/dc_restore.h"
+#include "spandsp/saturated.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
#include "spandsp/sig_tone.h"
Modified: freeswitch/trunk/libs/spandsp/src/spandsp.h.in
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp.h.in (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp.h.in Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: spandsp.h.in,v 1.10 2008/09/01 16:07:34 steveu Exp $
+ * $Id: spandsp.h.in,v 1.11 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -69,6 +69,7 @@
#include <spandsp/hdlc.h>
#include <spandsp/async.h>
#include <spandsp/noise.h>
+#include <spandsp/saturated.h>
#include <spandsp/time_scale.h>
#include <spandsp/tone_detect.h>
#include <spandsp/tone_generate.h>
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: complex_vector_float.h,v 1.8 2008/04/17 14:27:00 steveu Exp $
+ * $Id: complex_vector_float.h,v 1.10 2008/09/18 13:16:49 steveu Exp $
*/
#if !defined(_SPANDSP_COMPLEX_VECTOR_FLOAT_H_)
@@ -120,6 +120,42 @@
/*- End of function --------------------------------------------------------*/
#endif
+/*! \brief Find the dot product of two complex float vectors.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \return The dot product of the two vectors. */
+complexf_t cvec_dot_prodf(const complexf_t x[], const complexf_t y[], int n);
+
+/*! \brief Find the dot product of two complex double vectors.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \return The dot product of the two vectors. */
+complex_t cvec_dot_prod(const complex_t x[], const complex_t y[], int n);
+
+#if defined(HAVE_LONG_DOUBLE)
+/*! \brief Find the dot product of two complex long double vectors.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \return The dot product of the two vectors. */
+complexl_t cvec_dot_prodl(const complexl_t x[], const complexl_t y[], int n);
+#endif
+
+/*! \brief Find the dot product of two complex float vectors, where the first is a circular buffer
+ with an offset for the starting position.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \param pos The starting position in the x vector.
+ \return The dot product of the two vectors. */
+complexf_t cvec_circular_dot_prodf(const complexf_t x[], const complexf_t y[], int n, int pos);
+
+void cvec_lmsf(const complexf_t x[], complexf_t y[], int n, const complexf_t *error);
+
+void cvec_circular_lmsf(const complexf_t x[], complexf_t y[], int n, int pos, const complexf_t *error);
+
#if defined(__cplusplus)
}
#endif
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_int.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_int.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_int.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: complex_vector_int.h,v 1.1 2008/09/01 16:07:34 steveu Exp $
+ * $Id: complex_vector_int.h,v 1.3 2008/09/18 13:16:49 steveu Exp $
*/
#if !defined(_SPANDSP_COMPLEX_VECTOR_INT_H_)
@@ -96,6 +96,33 @@
}
/*- End of function --------------------------------------------------------*/
+/*! \brief Find the dot product of two complex int16_t vectors.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \return The dot product of the two vectors. */
+complexi32_t cvec_dot_prodi16(const complexi16_t x[], const complexi16_t y[], int n);
+
+/*! \brief Find the dot product of two complex int32_t vectors.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \return The dot product of the two vectors. */
+complexi32_t cvec_dot_prodi32(const complexi32_t x[], const complexi32_t y[], int n);
+
+/*! \brief Find the dot product of two complex int16_t vectors, where the first is a circular buffer
+ with an offset for the starting position.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \param pos The starting position in the x vector.
+ \return The dot product of the two vectors. */
+complexi32_t cvec_circular_dot_prodi16(const complexi16_t x[], const complexi16_t y[], int n, int pos);
+
+void cvec_lmsi16(const complexi16_t x[], complexi16_t y[], int n, const complexi16_t *error);
+
+void cvec_circular_lmsi16(const complexi16_t x[], complexi16_t y[], int n, int pos, const complexi16_t *error);
+
#if defined(__cplusplus)
}
#endif
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/dc_restore.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/dc_restore.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/dc_restore.h Tue Sep 30 23:59:45 2008
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: dc_restore.h,v 1.23 2008/08/16 14:59:50 steveu Exp $
+ * $Id: dc_restore.h,v 1.24 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -85,60 +85,6 @@
}
/*- End of function --------------------------------------------------------*/
-static __inline__ int16_t saturate(int32_t amp)
-{
- int16_t amp16;
-
- /* Hopefully this is optimised for the common case - not clipping */
- amp16 = (int16_t) amp;
- if (amp == amp16)
- return amp16;
- if (amp > INT16_MAX)
- return INT16_MAX;
- return INT16_MIN;
-}
-/*- End of function --------------------------------------------------------*/
-
-static __inline__ int16_t fsaturatef(float famp)
-{
- if (famp > 32767.0f)
- return INT16_MAX;
- if (famp < -32768.0f)
- return INT16_MIN;
- return (int16_t) rintf(famp);
-}
-/*- End of function --------------------------------------------------------*/
-
-static __inline__ int16_t fsaturate(double damp)
-{
- if (damp > 32767.0)
- return INT16_MAX;
- if (damp < -32768.0)
- return INT16_MIN;
- return (int16_t) rint(damp);
-}
-/*- End of function --------------------------------------------------------*/
-
-static __inline__ float ffsaturatef(float famp)
-{
- if (famp > 32767.0f)
- return (float) INT16_MAX;
- if (famp < -32768.0f)
- return (float) INT16_MIN;
- return famp;
-}
-/*- End of function --------------------------------------------------------*/
-
-static __inline__ double ffsaturate(double famp)
-{
- if (famp > 32767.0)
- return (double) INT16_MAX;
- if (famp < -32768.0)
- return (double) INT16_MIN;
- return famp;
-}
-/*- End of function --------------------------------------------------------*/
-
#if defined(__cplusplus)
}
#endif
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/g722.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/g722.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/g722.h Tue Sep 30 23:59:45 2008
@@ -28,7 +28,7 @@
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
*
- * $Id: g722.h,v 1.19 2008/04/17 14:27:00 steveu Exp $
+ * $Id: g722.h,v 1.20 2008/09/19 14:02:05 steveu Exp $
*/
@@ -56,6 +56,20 @@
G722_PACKED = 0x0002
};
+/*! The per band parameters for both encoding and decoding G.722 */
+typedef struct
+{
+ int16_t s;
+ int16_t sz;
+ int16_t r[3];
+ int16_t a[3];
+ int16_t p[3];
+ int16_t d[7];
+ int16_t b[7];
+ int16_t nb;
+ int16_t det;
+} g722_band_t;
+
typedef struct
{
/*! TRUE if the operating in the special ITU test mode, with the band split filters
@@ -69,28 +83,15 @@
int bits_per_sample;
/*! Signal history for the QMF */
- int x[24];
+ int16_t x[12];
+ int16_t y[12];
+ int ptr;
- struct
- {
- int s;
- int sp;
- int sz;
- int r[3];
- int a[3];
- int ap[3];
- int p[3];
- int d[7];
- int b[7];
- int bp[7];
- int sg[7];
- int nb;
- int det;
- } band[2];
+ g722_band_t band[2];
- unsigned int in_buffer;
+ uint32_t in_buffer;
int in_bits;
- unsigned int out_buffer;
+ uint32_t out_buffer;
int out_bits;
} g722_encode_state_t;
@@ -107,28 +108,15 @@
int bits_per_sample;
/*! Signal history for the QMF */
- int x[24];
+ int16_t x[12];
+ int16_t y[12];
+ int ptr;
- struct
- {
- int s;
- int sp;
- int sz;
- int r[3];
- int a[3];
- int ap[3];
- int p[3];
- int d[7];
- int b[7];
- int bp[7];
- int sg[7];
- int nb;
- int det;
- } band[2];
+ g722_band_t band[2];
- unsigned int in_buffer;
+ uint32_t in_buffer;
int in_bits;
- unsigned int out_buffer;
+ uint32_t out_buffer;
int out_bits;
} g722_decode_state_t;
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v17rx.h,v 1.54 2008/09/16 13:02:05 steveu Exp $
+ * $Id: v17rx.h,v 1.57 2008/09/18 14:59:30 steveu Exp $
*/
/*! \file */
@@ -213,9 +213,8 @@
/* Target length for the equalizer is about 63 taps, to deal with the worst stuff
in V.56bis. */
-#define V17_EQUALIZER_PRE_LEN 7 /* this much before the real event */
-#define V17_EQUALIZER_POST_LEN 7 /* this much after the real event */
-#define V17_EQUALIZER_MASK 63 /* one less than a power of 2 >= (V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN) */
+#define V17_EQUALIZER_PRE_LEN 8 /* This much before the real event */
+#define V17_EQUALIZER_POST_LEN 8 /* This much after the real event (must be even) */
#define V17_RX_FILTER_STEPS 27
@@ -253,9 +252,9 @@
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
#if defined(SPANDSP_USE_FIXED_POINT)
- int16_t rrc_filter[2*V17_RX_FILTER_STEPS];
+ int16_t rrc_filter[V17_RX_FILTER_STEPS];
#else
- float rrc_filter[2*V17_RX_FILTER_STEPS];
+ float rrc_filter[V17_RX_FILTER_STEPS];
#endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step;
@@ -332,7 +331,7 @@
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
complexi16_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- complexi16_t eq_buf[V17_EQUALIZER_MASK + 1];
+ complexi16_t eq_buf[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN];
/*! Low band edge filter for symbol sync. */
int32_t symbol_sync_low[2];
@@ -355,7 +354,7 @@
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
complexf_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- complexf_t eq_buf[V17_EQUALIZER_MASK + 1];
+ complexf_t eq_buf[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN];
/*! Low band edge filter for symbol sync. */
float symbol_sync_low[2];
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v27ter_rx.h,v 1.51 2008/09/16 14:12:23 steveu Exp $
+ * $Id: v27ter_rx.h,v 1.53 2008/09/18 14:59:30 steveu Exp $
*/
/*! \file */
@@ -48,9 +48,8 @@
/* Target length for the equalizer is about 43 taps for 4800bps and 32 taps for 2400bps
to deal with the worst stuff in V.56bis. */
-#define V27TER_EQUALIZER_PRE_LEN 15 /* this much before the real event */
-#define V27TER_EQUALIZER_POST_LEN 15 /* this much after the real event */
-#define V27TER_EQUALIZER_MASK 63 /* one less than a power of 2 >= (V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN) */
+#define V27TER_EQUALIZER_PRE_LEN 16 /* This much before the real event */
+#define V27TER_EQUALIZER_POST_LEN 14 /* This much after the real event (must be even) */
#define V27TER_RX_4800_FILTER_STEPS 27
#define V27TER_RX_2400_FILTER_STEPS 27
@@ -88,9 +87,9 @@
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
#if defined(SPANDSP_USE_FIXED_POINT)
- int16_t rrc_filter[2*V27TER_RX_FILTER_STEPS];
+ int16_t rrc_filter[V27TER_RX_FILTER_STEPS];
#else
- float rrc_filter[2*V27TER_RX_FILTER_STEPS];
+ float rrc_filter[V27TER_RX_FILTER_STEPS];
#endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step;
@@ -174,7 +173,7 @@
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
/*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_MASK + 1];
+ /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
#else
/*! \brief The scaling factor accessed by the AGC algorithm. */
float agc_scaling;
@@ -188,7 +187,7 @@
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- complexf_t eq_buf[V27TER_EQUALIZER_MASK + 1];
+ complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
#endif
/*! \brief Integration variable for damping the Gardner algorithm tests. */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v29rx.h,v 1.62 2008/09/16 14:12:23 steveu Exp $
+ * $Id: v29rx.h,v 1.64 2008/09/18 14:59:30 steveu Exp $
*/
/*! \file */
@@ -122,9 +122,8 @@
/* Target length for the equalizer is about 63 taps, to deal with the worst stuff
in V.56bis. */
-#define V29_EQUALIZER_PRE_LEN 15 /* this much before the real event */
-#define V29_EQUALIZER_POST_LEN 15 /* this much after the real event */
-#define V29_EQUALIZER_MASK 63 /* one less than a power of 2 >= (2*V29_EQUALIZER_LEN + 1) */
+#define V29_EQUALIZER_PRE_LEN 16 /* This much before the real event */
+#define V29_EQUALIZER_POST_LEN 14 /* This much after the real event (must be even) */
#define V29_RX_FILTER_STEPS 27
@@ -157,9 +156,9 @@
/*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
#if defined(SPANDSP_USE_FIXED_POINT)
- int16_t rrc_filter[2*V29_RX_FILTER_STEPS];
+ int16_t rrc_filter[V29_RX_FILTER_STEPS];
#else
- float rrc_filter[2*V29_RX_FILTER_STEPS];
+ float rrc_filter[V29_RX_FILTER_STEPS];
#endif
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
int rrc_filter_step;
@@ -242,7 +241,7 @@
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
complexi16_t eq_coeff_save[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- complexi16_t eq_buf[V29_EQUALIZER_MASK + 1];
+ complexi16_t eq_buf[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
/*! Low band edge filter for symbol sync. */
int32_t symbol_sync_low[2];
@@ -265,7 +264,7 @@
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
complexf_t eq_coeff_save[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- complexf_t eq_buf[V29_EQUALIZER_MASK + 1];
+ complexf_t eq_buf[V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN];
/*! Low band edge filter for symbol sync. */
float symbol_sync_low[2];
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/vector_float.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/vector_float.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/vector_float.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_float.h,v 1.11 2008/09/01 16:07:34 steveu Exp $
+ * $Id: vector_float.h,v 1.13 2008/09/18 13:54:32 steveu Exp $
*/
#if !defined(_SPANDSP_VECTOR_FLOAT_H_)
@@ -128,6 +128,19 @@
long double vec_dot_prodl(const long double x[], const long double y[], int n);
#endif
+/*! \brief Find the dot product of two float vectors, where the first is a circular buffer
+ with an offset for the starting position.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \param pos The starting position in the x vector.
+ \return The dot product of the two vectors. */
+float vec_circular_dot_prodf(const float x[], const float y[], int n, int pos);
+
+void vec_lmsf(const float x[], float y[], int n, float error);
+
+void vec_circular_lmsf(const float x[], float y[], int n, int pos, float error);
+
#if defined(__cplusplus)
}
#endif
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/vector_int.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/vector_int.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/vector_int.h Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_int.h,v 1.11 2008/09/01 16:07:34 steveu Exp $
+ * $Id: vector_int.h,v 1.13 2008/09/18 13:54:32 steveu Exp $
*/
#if !defined(_SPANDSP_VECTOR_INT_H_)
@@ -103,6 +103,19 @@
\return The dot product of the two vectors. */
int32_t vec_dot_prodi16(const int16_t x[], const int16_t y[], int n);
+/*! \brief Find the dot product of two int16_t vectors, where the first is a circular buffer
+ with an offset for the starting position.
+ \param x The first vector.
+ \param y The first vector.
+ \param n The number of elements in the vectors.
+ \param pos The starting position in the x vector.
+ \return The dot product of the two vectors. */
+int32_t vec_circular_dot_prodi16(const int16_t x[], const int16_t y[], int n, int pos);
+
+void vec_lmsi16(const int16_t x[], int16_t y[], int n, int16_t error);
+
+void vec_circular_lmsi16(const int16_t x[], int16_t y[], int n, int pos, int16_t error);
+
/*! \brief Find the minimum and maximum values in an int16_t vector.
\param x The vector to be searched.
\param n The number of elements in the vector.
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Tue Sep 30 23:59:45 2008
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20080916
-#define SPANDSP_RELEASE_TIME 152844
+#define SPANDSP_RELEASE_DATE 20080919
+#define SPANDSP_RELEASE_TIME 142905
#endif
/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/time_scale.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/time_scale.c (original)
+++ freeswitch/trunk/libs/spandsp/src/time_scale.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: time_scale.c,v 1.23 2008/07/28 15:14:30 steveu Exp $
+ * $Id: time_scale.c,v 1.24 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -48,6 +48,7 @@
#include "spandsp/telephony.h"
#include "spandsp/time_scale.h"
+#include "spandsp/saturated.h"
/*
Time scaling for speech, based on the Pointer Interval Controlled
Modified: freeswitch/trunk/libs/spandsp/src/v17rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v17rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v17rx.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v17rx.c,v 1.118 2008/09/16 14:12:23 steveu Exp $
+ * $Id: v17rx.c,v 1.123 2008/09/18 15:59:55 steveu Exp $
*/
/*! \file */
@@ -48,6 +48,8 @@
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
+#include "spandsp/vector_int.h"
+#include "spandsp/complex_vector_int.h"
#include "spandsp/async.h"
#include "spandsp/power_meter.h"
#include "spandsp/arctan2.h"
@@ -81,6 +83,8 @@
#define V17_BRIDGE_WORD 0x8880
+#define V17_EQUALIZER_LEN (V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN)
+
enum
{
TRAINING_STAGE_NORMAL_OPERATION = 0,
@@ -149,16 +153,16 @@
#endif
{
*coeffs = s->eq_coeff;
- return V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN;
+ return V17_EQUALIZER_LEN;
}
/*- End of function --------------------------------------------------------*/
static void equalizer_save(v17_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
- cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V17_EQUALIZER_LEN);
#else
- cvec_copyf(s->eq_coeff_save, s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_copyf(s->eq_coeff_save, s->eq_coeff, V17_EQUALIZER_LEN);
#endif
}
/*- End of function --------------------------------------------------------*/
@@ -166,13 +170,13 @@
static void equalizer_restore(v17_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
- cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
- cvec_zeroi16(s->eq_buf, V17_EQUALIZER_MASK);
- s->eq_delta = 32768.0f*EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
-#else
- cvec_copyf(s->eq_coeff, s->eq_coeff_save, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
- cvec_zerof(s->eq_buf, V17_EQUALIZER_MASK);
- s->eq_delta = EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V17_EQUALIZER_LEN);
+ cvec_zeroi16(s->eq_buf, V17_EQUALIZER_LEN);
+ s->eq_delta = 32768.0f*EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/V17_EQUALIZER_LEN;
+#else
+ cvec_copyf(s->eq_coeff, s->eq_coeff_save, V17_EQUALIZER_LEN);
+ cvec_zerof(s->eq_buf, V17_EQUALIZER_LEN);
+ s->eq_delta = EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/V17_EQUALIZER_LEN;
#endif
s->eq_put_step = RX_PULSESHAPER_COEFF_SETS*10/(3*2) - 1;
@@ -184,15 +188,15 @@
{
/* Start with an equalizer based on everything being perfect */
#if defined(SPANDSP_USE_FIXED_POINTx)
- cvec_zeroi16(s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_zeroi16(s->eq_coeff, V17_EQUALIZER_LEN);
s->eq_coeff[V17_EQUALIZER_PRE_LEN] = complex_seti16(3*FP_FACTOR, 0);
- cvec_zeroi16(s->eq_buf, V17_EQUALIZER_MASK);
- s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_zeroi16(s->eq_buf, V17_EQUALIZER_LEN);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/V17_EQUALIZER_LEN;
#else
- cvec_zerof(s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_zerof(s->eq_coeff, V17_EQUALIZER_LEN);
s->eq_coeff[V17_EQUALIZER_PRE_LEN] = complex_setf(3.0f, 0.0f);
- cvec_zerof(s->eq_buf, V17_EQUALIZER_MASK);
- s->eq_delta = EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_zerof(s->eq_buf, V17_EQUALIZER_LEN);
+ s->eq_delta = EQUALIZER_DELTA/V17_EQUALIZER_LEN;
#endif
s->eq_put_step = RX_PULSESHAPER_COEFF_SETS*10/(3*2) - 1;
@@ -206,21 +210,7 @@
static __inline__ complexf_t equalizer_get(v17_rx_state_t *s)
#endif
{
- int i;
- int p;
- complexf_t z;
- complexf_t z1;
-
- /* Get the next equalized value. */
- z = complex_setf(0.0f, 0.0f);
- p = s->eq_step - 1;
- for (i = 0; i < V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V17_EQUALIZER_MASK;
- z1 = complex_mulf(&s->eq_coeff[i], &s->eq_buf[p]);
- z = complex_addf(&z, &z1);
- }
- return z;
+ return cvec_circular_dot_prodf(s->eq_buf, s->eq_coeff, V17_EQUALIZER_LEN, s->eq_step);
}
/*- End of function --------------------------------------------------------*/
@@ -230,28 +220,18 @@
static void tune_equalizer(v17_rx_state_t *s, const complexf_t *z, const complexf_t *target)
#endif
{
- int i;
- int p;
- complexf_t ez;
- complexf_t z1;
+ complexf_t err;
/* Find the x and y mismatch from the exact constellation position. */
- ez = complex_subf(target, z);
+ err = complex_subf(target, z);
//span_log(&s->logging, SPAN_LOG_FLOW, "Equalizer error %f\n", sqrt(ez.re*ez.re + ez.im*ez.im));
- ez.re *= s->eq_delta;
- ez.im *= s->eq_delta;
+ err.re *= s->eq_delta;
+ err.im *= s->eq_delta;
- p = s->eq_step - 1;
- for (i = 0; i < V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V17_EQUALIZER_MASK;
- z1 = complex_conjf(&s->eq_buf[p]);
- z1 = complex_mulf(&ez, &z1);
- s->eq_coeff[i] = complex_addf(&s->eq_coeff[i], &z1);
- /* Leak a little to tame uncontrolled wandering */
- s->eq_coeff[i].re *= 0.9999f;
- s->eq_coeff[i].im *= 0.9999f;
- }
+ err = complex_subf(target, z);
+ err.re *= s->eq_delta;
+ err.im *= s->eq_delta;
+ cvec_circular_lmsf(s->eq_buf, s->eq_coeff, V17_EQUALIZER_LEN, s->eq_step, &err);
}
/*- End of function --------------------------------------------------------*/
@@ -565,7 +545,8 @@
/* Add a sample to the equalizer's circular buffer, but don't calculate anything
at this time. */
s->eq_buf[s->eq_step] = *sample;
- s->eq_step = (s->eq_step + 1) & V17_EQUALIZER_MASK;
+ if (++s->eq_step >= V17_EQUALIZER_LEN)
+ s->eq_step = 0;
/* On alternate insertions we have a whole baud and must process it. */
if ((s->baud_half ^= 1))
@@ -628,7 +609,7 @@
p = 3.14159f + angle*2.0f*3.14159f/(65536.0f*65536.0f) - 0.321751f;
span_log(&s->logging, SPAN_LOG_FLOW, "Spin (short) by %.5f rads\n", p);
zz = complex_setf(cosf(p), -sinf(p));
- for (i = 0; i <= V17_EQUALIZER_MASK; i++)
+ for (i = 0; i < V17_EQUALIZER_LEN; i++)
s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz);
s->carrier_phase += (0x80000000 + angle - 219937506);
@@ -716,7 +697,7 @@
p = angle*2.0f*3.14159f/(65536.0f*65536.0f) - 0.321751f;
span_log(&s->logging, SPAN_LOG_FLOW, "Spin (long) by %.5f rads\n", p);
zz = complex_setf(cosf(p), -sinf(p));
- for (i = 0; i <= V17_EQUALIZER_MASK; i++)
+ for (i = 0; i < V17_EQUALIZER_LEN; i++)
s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz);
s->carrier_phase += (angle - 219937506);
@@ -960,7 +941,6 @@
int v17_rx(v17_rx_state_t *s, const int16_t amp[], int len)
{
int i;
- int j;
int step;
int16_t x;
int32_t diff;
@@ -968,15 +948,18 @@
complexf_t zz;
complexf_t sample;
#if defined(SPANDSP_USE_FIXED_POINT)
- complexi_t zi;
+ int32_t vi;
#endif
- int32_t power;
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ int32_t v;
+#else
float v;
+#endif
+ int32_t power;
for (i = 0; i < len; i++)
{
- s->rrc_filter[s->rrc_filter_step] =
- s->rrc_filter[s->rrc_filter_step + V17_RX_FILTER_STEPS] = amp[i];
+ s->rrc_filter[s->rrc_filter_step] = amp[i];
if (++s->rrc_filter_step >= V17_RX_FILTER_STEPS)
s->rrc_filter_step = 0;
@@ -1052,17 +1035,13 @@
if (step < 0)
step += RX_PULSESHAPER_COEFF_SETS;
#if defined(SPANDSP_USE_FIXED_POINT)
- zi.re = (int32_t) rx_pulseshaper[step][0].re*(int32_t) s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V17_RX_FILTER_STEPS; j++)
- zi.re += (int32_t) rx_pulseshaper[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
- sample.re = zi.re*s->agc_scaling;
-#else
- zz.re = rx_pulseshaper[step][0].re*s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V17_RX_FILTER_STEPS; j++)
- zz.re += rx_pulseshaper[step][j].re*s->rrc_filter[j + s->rrc_filter_step];
- sample.re = zz.re*s->agc_scaling;
+ vi = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step);
+ //sample.re = (vi*(int32_t) s->agc_scaling) >> 15;
+ sample.re = vi*s->agc_scaling;
+#else
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.re = v*s->agc_scaling;
#endif
-
/* Symbol timing synchronisation band edge filters */
/* Low Nyquist band edge filter */
v = s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0 + s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1 + sample.re;
@@ -1087,27 +1066,22 @@
step = -s->eq_put_step;
if (step > RX_PULSESHAPER_COEFF_SETS - 1)
step = RX_PULSESHAPER_COEFF_SETS - 1;
-#if defined(SPANDSP_USE_FIXED_POINT)
- zi.im = (int32_t) rx_pulseshaper[step][0].im*(int32_t) s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V17_RX_FILTER_STEPS; j++)
- zi.im += (int32_t) rx_pulseshaper[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
- sample.im = zi.im*s->agc_scaling;
s->eq_put_step += RX_PULSESHAPER_COEFF_SETS*10/(3*2);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ vi = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V17_RX_FILTER_STEPS, s->rrc_filter_step);
+ //sample.im = (vi*(int32_t) s->agc_scaling) >> 15;
+ sample.im = vi*s->agc_scaling;
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
zz.im = -sample.re*z.im - sample.im*z.re;
- process_half_baud(s, &zz);
#else
- zz.im = rx_pulseshaper[step][0].im*s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V17_RX_FILTER_STEPS; j++)
- zz.im += rx_pulseshaper[step][j].im*s->rrc_filter[j + s->rrc_filter_step];
- sample.im = zz.im*s->agc_scaling;
- s->eq_put_step += RX_PULSESHAPER_COEFF_SETS*10/(3*2);
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_im[step], V17_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.im = v*s->agc_scaling;
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
zz.im = -sample.re*z.im - sample.im*z.re;
- process_half_baud(s, &zz);
#endif
+ process_half_baud(s, &zz);
}
#if defined(SPANDSP_USE_FIXED_POINT)
dds_advance(&s->carrier_phase, s->carrier_phase_rate);
@@ -1165,7 +1139,7 @@
}
s->bit_rate = bit_rate;
#if defined(SPANDSP_USE_FIXED_POINT)
- memset(s->rrc_filter, 0, sizeof(s->rrc_filter));
+ vec_zeroi16(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#else
vec_zerof(s->rrc_filter, sizeof(s->rrc_filter)/sizeof(s->rrc_filter[0]));
#endif
Modified: freeswitch/trunk/libs/spandsp/src/v22bis_rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v22bis_rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v22bis_rx.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v22bis_rx.c,v 1.41 2008/09/07 12:45:17 steveu Exp $
+ * $Id: v22bis_rx.c,v 1.42 2008/09/18 14:59:30 steveu Exp $
*/
/*! \file */
@@ -590,15 +590,15 @@
/* TODO: get rid of this */
if (s->caller)
{
- ii = rx_pulseshaper_2400[6][0].re*s->rx.rrc_filter[s->rx.rrc_filter_step];
+ ii = rx_pulseshaper_2400_re[6][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
- ii += rx_pulseshaper_2400[6][j].re*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+ ii += rx_pulseshaper_2400_re[6][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
}
else
{
- ii = rx_pulseshaper_1200[6][0].re*s->rx.rrc_filter[s->rx.rrc_filter_step];
+ ii = rx_pulseshaper_1200_re[6][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
- ii += rx_pulseshaper_1200[6][j].re*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+ ii += rx_pulseshaper_1200_re[6][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
}
power = power_meter_update(&(s->rx.rx_power), (int16_t) (ii/10.0f));
if (s->rx.signal_present)
@@ -643,22 +643,22 @@
s->rx.eq_put_step += PULSESHAPER_COEFF_SETS*40/(3*2);
if (s->caller)
{
- ii = rx_pulseshaper_2400[step][0].re*s->rx.rrc_filter[s->rx.rrc_filter_step];
- qq = rx_pulseshaper_2400[step][0].im*s->rx.rrc_filter[s->rx.rrc_filter_step];
+ ii = rx_pulseshaper_2400_re[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
+ qq = rx_pulseshaper_2400_im[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
{
- ii += rx_pulseshaper_2400[step][j].re*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
- qq += rx_pulseshaper_2400[step][j].im*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+ ii += rx_pulseshaper_2400_re[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+ qq += rx_pulseshaper_2400_im[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
}
}
else
{
- ii = rx_pulseshaper_1200[step][0].re*s->rx.rrc_filter[s->rx.rrc_filter_step];
- qq = rx_pulseshaper_1200[step][0].im*s->rx.rrc_filter[s->rx.rrc_filter_step];
+ ii = rx_pulseshaper_1200_re[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
+ qq = rx_pulseshaper_1200_im[step][0]*s->rx.rrc_filter[s->rx.rrc_filter_step];
for (j = 1; j < V22BIS_RX_FILTER_STEPS; j++)
{
- ii += rx_pulseshaper_1200[step][j].re*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
- qq += rx_pulseshaper_1200[step][j].im*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+ ii += rx_pulseshaper_1200_re[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
+ qq += rx_pulseshaper_1200_im[step][j]*s->rx.rrc_filter[j + s->rx.rrc_filter_step];
}
}
sample.re = ii*s->rx.agc_scaling;
Modified: freeswitch/trunk/libs/spandsp/src/v27ter_rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v27ter_rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v27ter_rx.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v27ter_rx.c,v 1.104 2008/09/16 14:12:23 steveu Exp $
+ * $Id: v27ter_rx.c,v 1.107 2008/09/18 14:59:30 steveu Exp $
*/
/*! \file */
@@ -86,6 +86,8 @@
#define V27TER_TRAINING_SEG_5_LEN 1074
#define V27TER_TRAINING_SEG_6_LEN 8
+#define V27TER_EQUALIZER_LEN (V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN)
+
enum
{
TRAINING_STAGE_NORMAL_OPERATION = 0,
@@ -168,16 +170,16 @@
#endif
{
*coeffs = s->eq_coeff;
- return V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN;
+ return V27TER_EQUALIZER_LEN;
}
/*- End of function --------------------------------------------------------*/
static void equalizer_save(v27ter_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
- cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V27TER_EQUALIZER_LEN);
#else
- cvec_copyf(s->eq_coeff_save, s->eq_coeff, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_copyf(s->eq_coeff_save, s->eq_coeff, V27TER_EQUALIZER_LEN);
#endif
}
/*- End of function --------------------------------------------------------*/
@@ -185,13 +187,13 @@
static void equalizer_restore(v27ter_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
- cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
- cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_MASK);
- s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
-#else
- cvec_copyf(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
- cvec_zerof(s->eq_buf, V27TER_EQUALIZER_MASK);
- s->eq_delta = EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_LEN);
+ cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_LEN);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN);
+#else
+ cvec_copyf(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_LEN);
+ cvec_zerof(s->eq_buf, V27TER_EQUALIZER_LEN);
+ s->eq_delta = EQUALIZER_DELTA/V27TER_EQUALIZER_LEN;
#endif
s->eq_put_step = (s->bit_rate == 4800) ? RX_PULSESHAPER_4800_COEFF_SETS*5/2 : RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2);
@@ -203,15 +205,15 @@
{
/* Start with an equalizer based on everything being perfect. */
#if defined(SPANDSP_USE_FIXED_POINTx)
- cvec_zeroi16(s->eq_coeff, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_zeroi16(s->eq_coeff, V27TER_EQUALIZER_LEN);
s->eq_coeff[V27TER_EQUALIZER_PRE_LEN] = complex_seti16(1.414f*FP_FACTOR, 0);
- cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_MASK);
- s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_LEN);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN);
#else
- cvec_zerof(s->eq_coeff, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_zerof(s->eq_coeff, V27TER_EQUALIZER_LEN);
s->eq_coeff[V27TER_EQUALIZER_PRE_LEN] = complex_setf(1.414f, 0.0f);
- cvec_zerof(s->eq_buf, V27TER_EQUALIZER_MASK);
- s->eq_delta = EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
+ cvec_zerof(s->eq_buf, V27TER_EQUALIZER_LEN);
+ s->eq_delta = EQUALIZER_DELTA/V27TER_EQUALIZER_LEN;
#endif
s->eq_put_step = (s->bit_rate == 4800) ? RX_PULSESHAPER_4800_COEFF_SETS*5/2 : RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2);
@@ -237,36 +239,19 @@
static __inline__ complexf_t equalizer_get(v27ter_rx_state_t *s)
#endif
{
- int i;
- int p;
#if defined(SPANDSP_USE_FIXED_POINTx)
+ complexi32_t zz;
complexi16_t z;
- complexi16_t z1;
-#else
- complexf_t z;
- complexf_t z1;
-#endif
/* Get the next equalized value. */
- p = s->eq_step - 1;
-#if defined(SPANDSP_USE_FIXED_POINTx)
- z = complex_seti16(0, 0);
- for (i = 0; i < V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V27TER_EQUALIZER_MASK;
- z1 = complex_mul_q4_12(&s->eq_coeff[i], &s->eq_buf[p]);
- z = complex_addi16(&z, &z1);
- }
+ zz = cvec_circular_dot_prodi16(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step);
+ z.re = zz.re >> FP_SHIFT_FACTOR;
+ z.im = zz.im >> FP_SHIFT_FACTOR;
+ return z;
#else
- z = complex_setf(0.0f, 0.0f);
- for (i = 0; i < V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V27TER_EQUALIZER_MASK;
- z1 = complex_mulf(&s->eq_coeff[i], &s->eq_buf[p]);
- z = complex_addf(&z, &z1);
- }
+ /* Get the next equalized value. */
+ return cvec_circular_dot_prodf(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step);
#endif
- return z;
}
/*- End of function --------------------------------------------------------*/
@@ -276,45 +261,24 @@
static void tune_equalizer(v27ter_rx_state_t *s, const complexf_t *z, const complexf_t *target)
#endif
{
- int i;
- int p;
#if defined(SPANDSP_USE_FIXED_POINTx)
- complexi16_t ez;
- complexi16_t z1;
-#else
- complexf_t ez;
- complexf_t z1;
-#endif
+ complexi16_t err;
/* Find the x and y mismatch from the exact constellation position. */
-#if defined(SPANDSP_USE_FIXED_POINTx)
- ez.re = target->re*FP_FACTOR - z->re;
- ez.im = target->im*FP_FACTOR - z->im;
- ez.re = ((int32_t) ez.re*(int32_t) s->eq_delta) >> 15;
- ez.im = ((int32_t) ez.im*(int32_t) s->eq_delta) >> 15;
-#else
- ez = complex_subf(target, z);
- ez.re *= s->eq_delta;
- ez.im *= s->eq_delta;
-#endif
+ err.re = target->re*FP_FACTOR - z->re;
+ err.im = target->im*FP_FACTOR - z->im;
+ err.re = ((int32_t) err.re*(int32_t) s->eq_delta) >> 15;
+ err.im = ((int32_t) err.im*(int32_t) s->eq_delta) >> 15;
+ cvec_circular_lmsi16(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step, &err);
+#else
+ complexf_t err;
- p = s->eq_step - 1;
- for (i = 0; i < V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V27TER_EQUALIZER_MASK;
-#if defined(SPANDSP_USE_FIXED_POINTx)
- z1 = complex_conji16(&s->eq_buf[p]);
- z1 = complex_mul_q4_12(&ez, &z1);
- s->eq_coeff[i] = complex_addi16(&s->eq_coeff[i], &z1);
-#else
- z1 = complex_conjf(&s->eq_buf[p]);
- z1 = complex_mulf(&ez, &z1);
- s->eq_coeff[i] = complex_addf(&s->eq_coeff[i], &z1);
- /* Leak a little to tame uncontrolled wandering */
- s->eq_coeff[i].re *= 0.9999f;
- s->eq_coeff[i].im *= 0.9999f;
+ /* Find the x and y mismatch from the exact constellation position. */
+ err = complex_subf(target, z);
+ err.re *= s->eq_delta;
+ err.im *= s->eq_delta;
+ cvec_circular_lmsf(s->eq_buf, s->eq_coeff, V27TER_EQUALIZER_LEN, s->eq_step, &err);
#endif
- }
}
/*- End of function --------------------------------------------------------*/
@@ -508,13 +472,13 @@
/* This routine adapts the position of the half baud samples entering the equalizer. */
/* Perform a Gardner test for baud alignment */
- p = s->eq_buf[(s->eq_step - 3) & V27TER_EQUALIZER_MASK].re
- - s->eq_buf[(s->eq_step - 1) & V27TER_EQUALIZER_MASK].re;
- p *= s->eq_buf[(s->eq_step - 2) & V27TER_EQUALIZER_MASK].re;
-
- q = s->eq_buf[(s->eq_step - 3) & V27TER_EQUALIZER_MASK].im
- - s->eq_buf[(s->eq_step - 1) & V27TER_EQUALIZER_MASK].im;
- q *= s->eq_buf[(s->eq_step - 2) & V27TER_EQUALIZER_MASK].im;
+ p = s->eq_buf[(s->eq_step - 3) & V27TER_EQUALIZER_LEN].re
+ - s->eq_buf[(s->eq_step - 1) & V27TER_EQUALIZER_LEN].re;
+ p *= s->eq_buf[(s->eq_step - 2) & V27TER_EQUALIZER_LEN].re;
+
+ q = s->eq_buf[(s->eq_step - 3) & V27TER_EQUALIZER_LEN].im
+ - s->eq_buf[(s->eq_step - 1) & V27TER_EQUALIZER_LEN].im;
+ q *= s->eq_buf[(s->eq_step - 2) & V27TER_EQUALIZER_LEN].im;
s->gardner_integrate += (p + q > 0.0f) ? s->gardner_step : -s->gardner_step;
@@ -560,7 +524,8 @@
#else
s->eq_buf[s->eq_step] = *sample;
#endif
- s->eq_step = (s->eq_step + 1) & V27TER_EQUALIZER_MASK;
+ if (++s->eq_step >= V27TER_EQUALIZER_LEN)
+ s->eq_step = 0;
/* On alternate insertions we have a whole baud, and must process it. */
if ((s->baud_half ^= 1))
@@ -642,7 +607,7 @@
p = angle*2.0f*3.14159f/(65536.0f*65536.0f);
#if defined(SPANDSP_USE_FIXED_POINTx)
zz = complex_setf(cosf(p), -sinf(p));
- for (i = 0; i <= V27TER_EQUALIZER_MASK; i++)
+ for (i = 0; i < V27TER_EQUALIZER_LEN; i++)
{
z1 = complex_setf(s->eq_buf[i].re, s->eq_buf[i].im);
z1 = complex_mulf(&z1, &zz);
@@ -651,7 +616,7 @@
}
#else
zz = complex_setf(cosf(p), -sinf(p));
- for (i = 0; i <= V27TER_EQUALIZER_MASK; i++)
+ for (i = 0; i < V27TER_EQUALIZER_LEN; i++)
s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz);
#endif
s->carrier_phase += angle;
@@ -774,7 +739,6 @@
int v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], int len)
{
int i;
- int j;
int step;
int16_t x;
int32_t diff;
@@ -782,11 +746,12 @@
complexi16_t z;
complexi16_t zz;
complexi16_t sample;
- complexi32_t zi;
+ int32_t v;
#else
complexf_t z;
complexf_t zz;
complexf_t sample;
+ float v;
#endif
int32_t power;
@@ -794,8 +759,7 @@
{
for (i = 0; i < len; i++)
{
- s->rrc_filter[s->rrc_filter_step] =
- s->rrc_filter[s->rrc_filter_step + V27TER_RX_4800_FILTER_STEPS] = amp[i];
+ s->rrc_filter[s->rrc_filter_step] = amp[i];
if (++s->rrc_filter_step >= V27TER_RX_4800_FILTER_STEPS)
s->rrc_filter_step = 0;
@@ -887,28 +851,18 @@
step = RX_PULSESHAPER_4800_COEFF_SETS - 1;
s->eq_put_step += RX_PULSESHAPER_4800_COEFF_SETS*5/2;
#if defined(SPANDSP_USE_FIXED_POINT)
- zi.re = (int32_t) rx_pulseshaper_4800[step][0].re*(int32_t) s->rrc_filter[s->rrc_filter_step];
- zi.im = (int32_t) rx_pulseshaper_4800[step][0].im*(int32_t) s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V27TER_RX_4800_FILTER_STEPS; j++)
- {
- zi.re += (int32_t) rx_pulseshaper_4800[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
- zi.im += (int32_t) rx_pulseshaper_4800[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
- }
- sample.re = ((int32_t) zi.re*(int32_t) s->agc_scaling) >> 15;
- sample.im = ((int32_t) zi.im*(int32_t) s->agc_scaling) >> 15;
+ v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_4800_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.re = (v*(int32_t) s->agc_scaling) >> 15;
+ v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_4800_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.im = (v*(int32_t) s->agc_scaling) >> 15;
z = dds_lookup_complexi16(s->carrier_phase);
zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15;
zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15;
#else
- zz.re = rx_pulseshaper_4800[step][0].re*s->rrc_filter[s->rrc_filter_step];
- zz.im = rx_pulseshaper_4800[step][0].im*s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V27TER_RX_4800_FILTER_STEPS; j++)
- {
- zz.re += rx_pulseshaper_4800[step][j].re*s->rrc_filter[j + s->rrc_filter_step];
- zz.im += rx_pulseshaper_4800[step][j].im*s->rrc_filter[j + s->rrc_filter_step];
- }
- sample.re = zz.re*s->agc_scaling;
- sample.im = zz.im*s->agc_scaling;
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_4800_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.re = v*s->agc_scaling;
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_4800_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.im = v*s->agc_scaling;
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
zz.im = -sample.re*z.im - sample.im*z.re;
@@ -926,8 +880,7 @@
{
for (i = 0; i < len; i++)
{
- s->rrc_filter[s->rrc_filter_step] =
- s->rrc_filter[s->rrc_filter_step + V27TER_RX_2400_FILTER_STEPS] = amp[i];
+ s->rrc_filter[s->rrc_filter_step] = amp[i];
if (++s->rrc_filter_step >= V27TER_RX_2400_FILTER_STEPS)
s->rrc_filter_step = 0;
@@ -1020,28 +973,18 @@
step = RX_PULSESHAPER_2400_COEFF_SETS - 1;
s->eq_put_step += RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2);
#if defined(SPANDSP_USE_FIXED_POINT)
- zi.re = (int32_t) rx_pulseshaper_2400[step][0].re*(int32_t) s->rrc_filter[s->rrc_filter_step];
- zi.im = (int32_t) rx_pulseshaper_2400[step][0].im*(int32_t) s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V27TER_RX_2400_FILTER_STEPS; j++)
- {
- zi.re += (int32_t) rx_pulseshaper_2400[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
- zi.im += (int32_t) rx_pulseshaper_2400[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
- }
- sample.re = ((int32_t) zi.re*(int32_t) s->agc_scaling) >> 15;
- sample.im = ((int32_t) zi.im*(int32_t) s->agc_scaling) >> 15;
+ v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_2400_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.re = (v*(int32_t) s->agc_scaling) >> 15;
+ v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_2400_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.im = (v*(int32_t) s->agc_scaling) >> 15;
z = dds_lookup_complexi16(s->carrier_phase);
zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15;
zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15;
#else
- zz.re = rx_pulseshaper_2400[step][0].re*s->rrc_filter[s->rrc_filter_step];
- zz.im = rx_pulseshaper_2400[step][0].im*s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V27TER_RX_2400_FILTER_STEPS; j++)
- {
- zz.re += rx_pulseshaper_2400[step][j].re*s->rrc_filter[j + s->rrc_filter_step];
- zz.im += rx_pulseshaper_2400[step][j].im*s->rrc_filter[j + s->rrc_filter_step];
- }
- sample.re = zz.re*s->agc_scaling;
- sample.im = zz.im*s->agc_scaling;
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_2400_re[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.re = v*s->agc_scaling;
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_2400_im[step], V27TER_RX_FILTER_STEPS, s->rrc_filter_step);
+ sample.im = v*s->agc_scaling;
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
zz.im = -sample.re*z.im - sample.im*z.re;
Modified: freeswitch/trunk/libs/spandsp/src/v29rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v29rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v29rx.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v29rx.c,v 1.140 2008/09/16 14:12:23 steveu Exp $
+ * $Id: v29rx.c,v 1.144 2008/09/18 14:59:30 steveu Exp $
*/
/*! \file */
@@ -79,6 +79,8 @@
#define V29_TRAINING_SEG_3_LEN 384
#define V29_TRAINING_SEG_4_LEN 48
+#define V29_EQUALIZER_LEN (V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN)
+
enum
{
TRAINING_STAGE_NORMAL_OPERATION = 0,
@@ -176,16 +178,16 @@
#endif
{
*coeffs = s->eq_coeff;
- return V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN;
+ return V29_EQUALIZER_LEN;
}
/*- End of function --------------------------------------------------------*/
static void equalizer_save(v29_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINT)
- cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
+ cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V29_EQUALIZER_LEN);
#else
- cvec_copyf(s->eq_coeff_save, s->eq_coeff, V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
+ cvec_copyf(s->eq_coeff_save, s->eq_coeff, V29_EQUALIZER_LEN);
#endif
}
/*- End of function --------------------------------------------------------*/
@@ -193,13 +195,13 @@
static void equalizer_restore(v29_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINT)
- cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
- cvec_zeroi16(s->eq_buf, V29_EQUALIZER_MASK);
- s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
-#else
- cvec_copyf(s->eq_coeff, s->eq_coeff_save, V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
- cvec_zerof(s->eq_buf, V29_EQUALIZER_MASK);
- s->eq_delta = EQUALIZER_DELTA/(V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
+ cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V29_EQUALIZER_LEN);
+ cvec_zeroi16(s->eq_buf, V29_EQUALIZER_LEN);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/V29_EQUALIZER_LEN;
+#else
+ cvec_copyf(s->eq_coeff, s->eq_coeff_save, V29_EQUALIZER_LEN);
+ cvec_zerof(s->eq_buf, V29_EQUALIZER_LEN);
+ s->eq_delta = EQUALIZER_DELTA/V29_EQUALIZER_LEN;
#endif
s->eq_put_step = RX_PULSESHAPER_COEFF_SETS*10/(3*2) - 1;
@@ -211,15 +213,15 @@
{
/* Start with an equalizer based on everything being perfect */
#if defined(SPANDSP_USE_FIXED_POINT)
- cvec_zeroi16(s->eq_coeff, V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
- s->eq_coeff[V29_EQUALIZER_PRE_LEN] = complex_seti16(3*FP_FACTOR, 0*FP_FACTOR);
- cvec_zeroi16(s->eq_buf, V29_EQUALIZER_MASK);
- s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
-#else
- cvec_zerof(s->eq_coeff, V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
- s->eq_coeff[V29_EQUALIZER_PRE_LEN] = complex_setf(3.0f, 0.0f);
- cvec_zerof(s->eq_buf, V29_EQUALIZER_MASK);
- s->eq_delta = EQUALIZER_DELTA/(V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN);
+ cvec_zeroi16(s->eq_coeff, V29_EQUALIZER_LEN);
+ s->eq_coeff[V29_EQUALIZER_POST_LEN] = complex_seti16(3*FP_FACTOR, 0*FP_FACTOR);
+ cvec_zeroi16(s->eq_buf, V29_EQUALIZER_LEN);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/V29_EQUALIZER_LEN;
+#else
+ cvec_zerof(s->eq_coeff, V29_EQUALIZER_LEN);
+ s->eq_coeff[V29_EQUALIZER_POST_LEN] = complex_setf(3.0f, 0.0f);
+ cvec_zerof(s->eq_buf, V29_EQUALIZER_LEN);
+ s->eq_delta = EQUALIZER_DELTA/V29_EQUALIZER_LEN;
#endif
s->eq_put_step = RX_PULSESHAPER_COEFF_SETS*10/(3*2) - 1;
@@ -232,8 +234,8 @@
{
complexi16_t z;
- z.re = ((int32_t) x->re*(int32_t) y->re - (int32_t) x->im*(int32_t) y->im) >> 12;
- z.im = ((int32_t) x->re*(int32_t) y->im + (int32_t) x->im*(int32_t) y->re) >> 12;
+ z.re = ((int32_t) x->re*(int32_t) y->re - (int32_t) x->im*(int32_t) y->im) >> FP_SHIFT_FACTOR;
+ z.im = ((int32_t) x->re*(int32_t) y->im + (int32_t) x->im*(int32_t) y->re) >> FP_SHIFT_FACTOR;
return z;
}
/*- End of function --------------------------------------------------------*/
@@ -245,36 +247,19 @@
static __inline__ complexf_t equalizer_get(v29_rx_state_t *s)
#endif
{
- int i;
- int p;
#if defined(SPANDSP_USE_FIXED_POINT)
+ complexi32_t zz;
complexi16_t z;
- complexi16_t z1;
-#else
- complexf_t z;
- complexf_t z1;
-#endif
/* Get the next equalized value. */
- p = s->eq_step - 1;
-#if defined(SPANDSP_USE_FIXED_POINT)
- z = complex_seti16(0, 0);
- for (i = 0; i < V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V29_EQUALIZER_MASK;
- z1 = complex_mul_q4_12(&s->eq_coeff[i], &s->eq_buf[p]);
- z = complex_addi16(&z, &z1);
- }
+ zz = cvec_circular_dot_prodi16(s->eq_buf, s->eq_coeff, V29_EQUALIZER_LEN, s->eq_step);
+ z.re = zz.re >> FP_SHIFT_FACTOR;
+ z.im = zz.im >> FP_SHIFT_FACTOR;
+ return z;
#else
- z = complex_setf(0.0f, 0.0f);
- for (i = 0; i < V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V29_EQUALIZER_MASK;
- z1 = complex_mulf(&s->eq_coeff[i], &s->eq_buf[p]);
- z = complex_addf(&z, &z1);
- }
+ /* Get the next equalized value. */
+ return cvec_circular_dot_prodf(s->eq_buf, s->eq_coeff, V29_EQUALIZER_LEN, s->eq_step);
#endif
- return z;
}
/*- End of function --------------------------------------------------------*/
@@ -284,45 +269,24 @@
static void tune_equalizer(v29_rx_state_t *s, const complexf_t *z, const complexf_t *target)
#endif
{
- int i;
- int p;
#if defined(SPANDSP_USE_FIXED_POINT)
- complexi16_t ez;
- complexi16_t z1;
-#else
- complexf_t ez;
- complexf_t z1;
-#endif
+ complexi16_t err;
/* Find the x and y mismatch from the exact constellation position. */
-#if defined(SPANDSP_USE_FIXED_POINT)
- ez.re = target->re*FP_FACTOR - z->re;
- ez.im = target->im*FP_FACTOR - z->im;
- ez.re = ((int32_t) ez.re*(int32_t) s->eq_delta) >> 15;
- ez.im = ((int32_t) ez.im*(int32_t) s->eq_delta) >> 15;
-#else
- ez = complex_subf(target, z);
- ez.re *= s->eq_delta;
- ez.im *= s->eq_delta;
-#endif
+ err.re = target->re*FP_FACTOR - z->re;
+ err.im = target->im*FP_FACTOR - z->im;
+ err.re = ((int32_t) err.re*(int32_t) s->eq_delta) >> 15;
+ err.im = ((int32_t) err.im*(int32_t) s->eq_delta) >> 15;
+ cvec_circular_lmsi16(s->eq_buf, s->eq_coeff, V29_EQUALIZER_LEN, s->eq_step, &err);
+#else
+ complexf_t err;
- p = s->eq_step - 1;
- for (i = 0; i < V29_EQUALIZER_PRE_LEN + 1 + V29_EQUALIZER_POST_LEN; i++)
- {
- p = (p - 1) & V29_EQUALIZER_MASK;
-#if defined(SPANDSP_USE_FIXED_POINT)
- z1 = complex_conji16(&s->eq_buf[p]);
- z1 = complex_mul_q4_12(&ez, &z1);
- s->eq_coeff[i] = complex_addi16(&s->eq_coeff[i], &z1);
-#else
- z1 = complex_conjf(&s->eq_buf[p]);
- z1 = complex_mulf(&ez, &z1);
- s->eq_coeff[i] = complex_addf(&s->eq_coeff[i], &z1);
- /* Leak a little to tame uncontrolled wandering */
- s->eq_coeff[i].re *= 0.9999f;
- s->eq_coeff[i].im *= 0.9999f;
+ /* Find the x and y mismatch from the exact constellation position. */
+ err = complex_subf(target, z);
+ err.re *= s->eq_delta;
+ err.im *= s->eq_delta;
+ cvec_circular_lmsf(s->eq_buf, s->eq_coeff, V29_EQUALIZER_LEN, s->eq_step, &err);
#endif
- }
}
/*- End of function --------------------------------------------------------*/
@@ -597,7 +561,8 @@
/* Add a sample to the equalizer's circular buffer, but don't calculate anything
at this time. */
s->eq_buf[s->eq_step] = *sample;
- s->eq_step = (s->eq_step + 1) & V29_EQUALIZER_MASK;
+ if (++s->eq_step >= V29_EQUALIZER_LEN)
+ s->eq_step = 0;
/* On alternate insertions we have a whole baud, and must process it. */
if ((s->baud_half ^= 1))
@@ -687,7 +652,7 @@
p = angle*2.0f*3.14159f/(65536.0f*65536.0f);
#if defined(SPANDSP_USE_FIXED_POINT)
zz = complex_setf(cosf(p), -sinf(p));
- for (i = 0; i <= V29_EQUALIZER_MASK; i++)
+ for (i = 0; i < V29_EQUALIZER_LEN; i++)
{
z1 = complex_setf(s->eq_buf[i].re, s->eq_buf[i].im);
z1 = complex_mulf(&z1, &zz);
@@ -696,7 +661,7 @@
}
#else
zz = complex_setf(cosf(p), -sinf(p));
- for (i = 0; i <= V29_EQUALIZER_MASK; i++)
+ for (i = 0; i < V29_EQUALIZER_LEN; i++)
s->eq_buf[i] = complex_mulf(&s->eq_buf[i], &zz);
#endif
s->carrier_phase += angle;
@@ -860,7 +825,6 @@
int v29_rx(v29_rx_state_t *s, const int16_t amp[], int len)
{
int i;
- int j;
int step;
int16_t x;
int32_t diff;
@@ -879,8 +843,7 @@
for (i = 0; i < len; i++)
{
- s->rrc_filter[s->rrc_filter_step] =
- s->rrc_filter[s->rrc_filter_step + V29_RX_FILTER_STEPS] = amp[i];
+ s->rrc_filter[s->rrc_filter_step] = amp[i];
if (++s->rrc_filter_step >= V29_RX_FILTER_STEPS)
s->rrc_filter_step = 0;
@@ -956,25 +919,21 @@
if (step < 0)
step += RX_PULSESHAPER_COEFF_SETS;
#if defined(SPANDSP_USE_FIXED_POINT)
- v = (int32_t) rx_pulseshaper[step][0].re*(int32_t) s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V29_RX_FILTER_STEPS; j++)
- v += (int32_t) rx_pulseshaper[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
+ v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V29_RX_FILTER_STEPS, s->rrc_filter_step);
sample.re = (v*s->agc_scaling) >> 15;
#else
- v = rx_pulseshaper[step][0].re*s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V29_RX_FILTER_STEPS; j++)
- v += rx_pulseshaper[step][j].re*s->rrc_filter[j + s->rrc_filter_step];
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_re[step], V29_RX_FILTER_STEPS, s->rrc_filter_step);
sample.re = v*s->agc_scaling;
#endif
/* Symbol timing synchronisation band edge filters */
#if defined(SPANDSP_USE_FIXED_POINT)
/* Low Nyquist band edge filter */
- v = ((s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0) >> 12) + ((s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1) >> 12) + sample.re;
+ v = ((s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0) >> FP_SHIFT_FACTOR) + ((s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1) >> FP_SHIFT_FACTOR) + sample.re;
s->symbol_sync_low[1] = s->symbol_sync_low[0];
s->symbol_sync_low[0] = v;
/* High Nyquist band edge filter */
- v = ((s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0) >> 12) + ((s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1) >> 12) + sample.re;
+ v = ((s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0) >> FP_SHIFT_FACTOR) + ((s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1) >> FP_SHIFT_FACTOR) + sample.re;
s->symbol_sync_high[1] = s->symbol_sync_high[0];
s->symbol_sync_high[0] = v;
#else
@@ -1008,17 +967,13 @@
step = RX_PULSESHAPER_COEFF_SETS - 1;
s->eq_put_step += RX_PULSESHAPER_COEFF_SETS*10/(3*2);
#if defined(SPANDSP_USE_FIXED_POINT)
- v = (int32_t) rx_pulseshaper[step][0].im*(int32_t) s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V29_RX_FILTER_STEPS; j++)
- v += (int32_t) rx_pulseshaper[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
+ v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_im[step], V29_RX_FILTER_STEPS, s->rrc_filter_step);
sample.im = (v*s->agc_scaling) >> 15;
z = dds_lookup_complexi16(s->carrier_phase);
zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15;
zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15;
#else
- v = rx_pulseshaper[step][0].im*s->rrc_filter[s->rrc_filter_step];
- for (j = 1; j < V29_RX_FILTER_STEPS; j++)
- v += rx_pulseshaper[step][j].im*s->rrc_filter[j + s->rrc_filter_step];
+ v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_im[step], V29_RX_FILTER_STEPS, s->rrc_filter_step);
sample.im = v*s->agc_scaling;
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
Modified: freeswitch/trunk/libs/spandsp/src/vector_float.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/vector_float.c (original)
+++ freeswitch/trunk/libs/spandsp/src/vector_float.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_float.c,v 1.12 2008/09/16 15:21:52 steveu Exp $
+ * $Id: vector_float.c,v 1.14 2008/09/18 13:54:32 steveu Exp $
*/
/*! \file */
@@ -337,22 +337,25 @@
{
int i;
float z;
- __m128 num1, num2, num3, num4;
+ __m128 n1;
+ __m128 n2;
+ __m128 n3;
+ __m128 n4;
z = 0.0f;
if ((i = n & ~3))
{
- num4 = _mm_setzero_ps(); //sets sum to zero
+ n4 = _mm_setzero_ps(); //sets sum to zero
for (i -= 4; i >= 0; i -= 4)
{
- num1 = _mm_loadu_ps(x + i);
- num2 = _mm_loadu_ps(y + i);
- num3 = _mm_mul_ps(num1, num2);
- num4 = _mm_add_ps(num4, num3);
+ n1 = _mm_loadu_ps(x + i);
+ n2 = _mm_loadu_ps(y + i);
+ n3 = _mm_mul_ps(n1, n2);
+ n4 = _mm_add_ps(n4, n3);
}
- num4 = _mm_add_ps(_mm_movehl_ps(num4, num4), num4);
- num4 = _mm_add_ss(_mm_shuffle_ps(num4, num4, 1), num4);
- _mm_store_ss(&z, num4);
+ n4 = _mm_add_ps(_mm_movehl_ps(n4, n4), n4);
+ n4 = _mm_add_ss(_mm_shuffle_ps(n4, n4, 1), n4);
+ _mm_store_ss(&z, n4);
}
/* Now deal with the last 1 to 3 elements, which don't fill in an SSE2 register */
switch (n & 3)
@@ -405,4 +408,34 @@
}
/*- End of function --------------------------------------------------------*/
#endif
+
+float vec_circular_dot_prodf(const float x[], const float y[], int n, int pos)
+{
+ float z;
+
+ z = vec_dot_prodf(&x[pos], &y[0], n - pos);
+ z += vec_dot_prodf(&x[0], &y[n - pos], pos);
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+void vec_lmsf(const float x[], float y[], int n, float error)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ {
+ y[i] += x[i]*error;
+ /* Leak a little to tame uncontrolled wandering */
+ y[i] *= 0.9999f;
+ }
+}
+/*- End of function --------------------------------------------------------*/
+
+void vec_circular_lmsf(const float x[], float y[], int n, int pos, float error)
+{
+ vec_lmsf(&x[pos], &y[0], n - pos, error);
+ vec_lmsf(&x[0], &y[n - pos], pos, error);
+}
+/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/vector_int.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/vector_int.c (original)
+++ freeswitch/trunk/libs/spandsp/src/vector_int.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_int.c,v 1.13 2008/09/16 15:21:52 steveu Exp $
+ * $Id: vector_int.c,v 1.15 2008/09/18 13:54:32 steveu Exp $
*/
/*! \file */
@@ -156,7 +156,33 @@
for (i = 0; i < n; i++)
z += (int32_t) x[i]*(int32_t) y[i];
#endif
- return z;
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+int32_t vec_circular_dot_prodi16(const int16_t x[], const int16_t y[], int n, int pos)
+{
+ int32_t z;
+
+ z = vec_dot_prodi16(&x[pos], &y[0], n - pos);
+ z += vec_dot_prodi16(&x[0], &y[n - pos], pos);
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+void vec_lmsi16(const int16_t x[], int16_t y[], int n, int16_t error)
+{
+ int i;
+
+ for (i = 0; i < n; i++)
+ y[i] += ((int32_t) x[i]*(int32_t) error) >> 15;
+}
+/*- End of function --------------------------------------------------------*/
+
+void vec_circular_lmsi16(const int16_t x[], int16_t y[], int n, int pos, int16_t error)
+{
+ vec_lmsi16(&x[pos], &y[0], n - pos, error);
+ vec_lmsi16(&x[0], &y[n - pos], pos, error);
}
/*- End of function --------------------------------------------------------*/
@@ -315,7 +341,7 @@
: "S" (x), "a" (n), "d" (out), [lower] "m" (lower_bound), [upper] "m" (upper_bound)
: "ecx"
);
- return max;
+ return max;
#else
int i;
int16_t min;
Modified: freeswitch/trunk/libs/spandsp/tests/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/Makefile.am (original)
+++ freeswitch/trunk/libs/spandsp/tests/Makefile.am Tue Sep 30 23:59:45 2008
@@ -16,7 +16,7 @@
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
-## $Id: Makefile.am,v 1.106 2008/09/09 14:05:55 steveu Exp $
+## $Id: Makefile.am,v 1.107 2008/09/18 12:05:35 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@@ -41,6 +41,9 @@
bell_mf_tx_tests \
bert_tests \
bit_operations_tests \
+ complex_tests \
+ complex_vector_float_tests \
+ complex_vector_int_tests \
crc_tests \
dc_restore_tests \
dds_tests \
@@ -132,6 +135,15 @@
bit_operations_tests_SOURCES = bit_operations_tests.c
bit_operations_tests_LDADD = $(LIBDIR) -lspandsp
+complex_tests_SOURCES = complex_tests.c
+complex_tests_LDADD = $(LIBDIR) -lspandsp
+
+complex_vector_float_tests_SOURCES = complex_vector_float_tests.c
+complex_vector_float_tests_LDADD = $(LIBDIR) -lspandsp
+
+complex_vector_int_tests_SOURCES = complex_vector_int_tests.c
+complex_vector_int_tests_LDADD = $(LIBDIR) -lspandsp
+
crc_tests_SOURCES = crc_tests.c
crc_tests_LDADD = $(LIBDIR) -lspandsp
Modified: freeswitch/trunk/libs/spandsp/tests/g722_tests.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/g722_tests.c (original)
+++ freeswitch/trunk/libs/spandsp/tests/g722_tests.c Tue Sep 30 23:59:45 2008
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: g722_tests.c,v 1.26 2008/05/13 13:17:25 steveu Exp $
+ * $Id: g722_tests.c,v 1.27 2008/09/19 14:02:05 steveu Exp $
*/
/*! \file */
@@ -109,8 +109,10 @@
static const char *encode_test_files[] =
{
- TESTDATA_DIR "T1C1.XMT", TESTDATA_DIR "T2R1.COD",
- TESTDATA_DIR "T1C2.XMT", TESTDATA_DIR "T2R2.COD",
+ TESTDATA_DIR "T1C1.XMT",
+ TESTDATA_DIR "T2R1.COD",
+ TESTDATA_DIR "T1C2.XMT",
+ TESTDATA_DIR "T2R2.COD",
NULL
};
@@ -295,6 +297,7 @@
if (itutests)
{
+#if 1
/* ITU G.722 encode tests, using configuration 1. The QMF is bypassed */
for (file = 0; encode_test_files[file]; file += 2)
{
@@ -341,7 +344,8 @@
}
printf("Test passed\n");
}
-
+#endif
+#if 1
/* ITU G.722 decode tests, using configuration 2. The QMF is bypassed */
/* Run each of the tests for each of the modes - 48kbps, 56kbps and 64kbps. */
for (mode = 1; mode <= 3; mode++)
@@ -404,7 +408,7 @@
printf("Test passed\n");
}
}
-
+#endif
printf("Tests passed.\n");
}
else
Modified: freeswitch/trunk/libs/spandsp/tests/regression_tests.sh
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/regression_tests.sh (original)
+++ freeswitch/trunk/libs/spandsp/tests/regression_tests.sh Tue Sep 30 23:59:45 2008
@@ -17,7 +17,7 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-# $Id: regression_tests.sh,v 1.52 2008/09/02 13:56:10 steveu Exp $
+# $Id: regression_tests.sh,v 1.53 2008/09/18 12:09:51 steveu Exp $
#
ITUTESTS_TIF=../test-data/itu/fax/itutests.tif
@@ -99,6 +99,33 @@
fi
echo bit_operations_tests completed OK
+./complex_tests >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+ echo complex_tests failed!
+ exit $RETVAL
+fi
+echo complex_tests completed OK
+
+./complex_vector_float_tests >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+ echo complex_vector_float_tests failed!
+ exit $RETVAL
+fi
+echo complex_vector_float_tests completed OK
+
+./complex_vector_int_tests >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+ echo complex_vector_int_tests failed!
+ exit $RETVAL
+fi
+echo complex_vector_int_tests completed OK
+
./crc_tests >$STDOUT_DEST 2>$STDERR_DEST
RETVAL=$?
if [ $RETVAL != 0 ]
Modified: freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c (original)
+++ freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c Tue Sep 30 23:59:45 2008
@@ -1,7 +1,7 @@
/*
* SpanDSP - a series of DSP components for telephony
*
- * vector_int_tests.c
+ * complex_vector_int_tests.c
*
* Written by Steve Underwood <steveu(a)coppice.org>
*
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_int_tests.c,v 1.9 2008/09/16 15:21:52 steveu Exp $
+ * $Id: vector_int_tests.c,v 1.10 2008/09/18 12:05:35 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
@@ -139,10 +139,51 @@
}
/*- End of function --------------------------------------------------------*/
+static int test_vec_circular_dot_prodi16(void)
+{
+ int i;
+ int j;
+ int pos;
+ int len;
+ int32_t za;
+ int32_t zb;
+ int16_t x[99];
+ int16_t y[99];
+
+ /* Verify that we can do circular sample buffer "dot" linear coefficient buffer
+ operations properly, by doing two sub-dot products. */
+ for (i = 0; i < 99; i++)
+ {
+ x[i] = rand();
+ y[i] = rand();
+ }
+
+ len = 95;
+ for (pos = 0; pos < len; pos++)
+ {
+ za = vec_circular_dot_prodi16(x, y, len, pos);
+ zb = 0;
+ for (i = 0; i < len; i++)
+ {
+ j = (pos + i) % len;
+ zb += (int32_t) x[j]*(int32_t) y[i];
+ }
+
+ if (za != zb)
+ {
+ printf("Tests failed\n");
+ exit(2);
+ }
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
int main(int argc, char *argv[])
{
test_vec_dot_prodi16();
test_vec_min_maxi16();
+ test_vec_circular_dot_prodi16();
printf("Tests passed.\n");
return 0;
1
0
[commit] r9769 - in freeswitch/trunk/libs/spandsp: . src src/spandsp tests
by Freeswitch SVN 01 Oct '08
by Freeswitch SVN 01 Oct '08
01 Oct '08
Author: anthm
Date: Tue Sep 30 23:56:17 2008
New Revision: 9769
Modified:
freeswitch/trunk/libs/spandsp/.update
freeswitch/trunk/libs/spandsp/config-h.in
freeswitch/trunk/libs/spandsp/configure.ac
freeswitch/trunk/libs/spandsp/src/spandsp/at_interpreter.h
freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h
freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h
freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h
freeswitch/trunk/libs/spandsp/src/spandsp/version.h
freeswitch/trunk/libs/spandsp/src/t30.c
freeswitch/trunk/libs/spandsp/src/v17rx.c
freeswitch/trunk/libs/spandsp/src/v27ter_rx.c
freeswitch/trunk/libs/spandsp/src/v29rx.c
freeswitch/trunk/libs/spandsp/src/vector_float.c
freeswitch/trunk/libs/spandsp/src/vector_int.c
freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c
freeswitch/trunk/libs/spandsp/tests/vector_float_tests.c
freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c
Log:
update to snapshot spandsp-20080916.tar.gz
Modified: freeswitch/trunk/libs/spandsp/.update
==============================================================================
--- freeswitch/trunk/libs/spandsp/.update (original)
+++ freeswitch/trunk/libs/spandsp/.update Tue Sep 30 23:56:17 2008
@@ -1 +1 @@
-Tue Sep 30 23:53:44 EDT 2008
+Tue Sep 30 23:55:26 EDT 2008
Modified: freeswitch/trunk/libs/spandsp/config-h.in
==============================================================================
--- freeswitch/trunk/libs/spandsp/config-h.in (original)
+++ freeswitch/trunk/libs/spandsp/config-h.in Tue Sep 30 23:56:17 2008
@@ -257,6 +257,30 @@
/* Enable fixed point processing, where possible, instead of floating point */
#undef SPANDSP_USE_FIXED_POINT
+/* Use the MMX instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_MMX
+
+/* Use the SSE instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE
+
+/* Use the SSE2 instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE2
+
+/* Use the SSE3 instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE3
+
+/* Use the SSE4A instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE4A
+
+/* Use the SSE4.1 instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE4_1
+
+/* Use the SSE4.2 instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE4_2
+
+/* Use the SSE5 instruction set (i386 and x86_64 only). */
+#undef SPANDSP_USE_SSE5
+
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
Modified: freeswitch/trunk/libs/spandsp/configure.ac
==============================================================================
--- freeswitch/trunk/libs/spandsp/configure.ac (original)
+++ freeswitch/trunk/libs/spandsp/configure.ac Tue Sep 30 23:56:17 2008
@@ -16,7 +16,7 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-# $Id: configure.ac,v 1.57 2008/09/12 14:41:55 steveu Exp $
+# $Id: configure.ac,v 1.59 2008/09/16 15:21:52 steveu Exp $
# @start 1
@@ -121,6 +121,13 @@
AC_ARG_ENABLE(test_data, [ --enable-test-data Build TIFF test files for some ITU test images])
AC_ARG_ENABLE(mmx, [ --enable-mmx Enable MMX support])
AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support])
+AC_ARG_ENABLE(sse2, [ --enable-sse2 Enable SSE2 support])
+AC_ARG_ENABLE(sse3, [ --enable-sse3 Enable SSE3 support])
+AC_ARG_ENABLE(sse3, [ --enable-sse3 Enable SSE3 support])
+AC_ARG_ENABLE(sse4_1, [ --enable-sse4-1 Enable SSE4.1 support])
+AC_ARG_ENABLE(sse4_2, [ --enable-sse4-2 Enable SSE4.2 support])
+AC_ARG_ENABLE(sse4a, [ --enable-sse4a Enable SSE4A support])
+AC_ARG_ENABLE(sse5, [ --enable-sse5 Enable SSE5 support])
AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support])
AC_FUNC_ERROR_AT_LINE
@@ -285,6 +292,24 @@
case "${ax_cv_c_compiler_vendor}" in
gnu)
COMP_VENDOR_CFLAGS="-std=gnu99 -ffast-math -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
+ if test "$enable_sse5" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse4a" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse4a $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse4_2" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse4_1" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse41 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse3" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse3 $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse2" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-msse2 $COMP_VENDOR_CFLAGS"
+ fi
if test "$enable_sse" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse $COMP_VENDOR_CFLAGS"
fi
@@ -302,6 +327,12 @@
;;
sun)
COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -errwarn=%all -xvpara"
+ if test "$enable_sse3" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
+ fi
+ if test "$enable_sse2" = "yes" ; then
+ COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
+ fi
if test "$enable_sse" = "yes" ; then
COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
fi
@@ -323,6 +354,12 @@
AM_CONDITIONAL([COND_TESTDATA], [test "$enable_test_data" = yes])
AM_CONDITIONAL([COND_MMX], [test "$enable_mmx" = yes])
AM_CONDITIONAL([COND_SSE], [test "$enable_sse" = yes])
+AM_CONDITIONAL([COND_SSE2], [test "$enable_sse2" = yes])
+AM_CONDITIONAL([COND_SSE3], [test "$enable_sse3" = yes])
+AM_CONDITIONAL([COND_SSE4_1], [test "$enable_sse4_1" = yes])
+AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes])
+AM_CONDITIONAL([COND_SSE4A], [test "$enable_sse4a" = yes])
+AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes])
if test "$enable_fixed_point" = "yes" ; then
AC_DEFINE([SPANDSP_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point])
SPANDSP_USE_FIXED_POINT="#define SPANDSP_USE_FIXED_POINT 1"
@@ -336,6 +373,58 @@
[AC_DEFINE([SPANDSP_MISALIGNED_ACCESS_FAILS], [1], [Do not expect a misaligned memory access to work correctly])
SPANDSP_MISALIGNED_ACCESS_FAILS="#define SPANDSP_MISALIGNED_ACCESS_FAILS 1"],
[SPANDSP_MISALIGNED_ACCESS_FAILS="#undef SPANDSP_MISALIGNED_ACCESS_FAILS"])
+if test "$enable_mmx" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse2" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse3" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse4_1" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse4_2" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_2], [1], [Use the SSE4.2 instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse4a" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_2], [1], [Use the SSE4.2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4A], [1], [Use the SSE4A instruction set (i386 and x86_64 only).])
+fi
+if test "$enable_sse5" = "yes" ; then
+ AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE4_2], [1], [Use the SSE4.2 instruction set (i386 and x86_64 only).])
+ AC_DEFINE([SPANDSP_USE_SSE5], [1], [Use the SSE5 instruction set (i386 and x86_64 only).])
+fi
AC_SUBST(CC_FOR_BUILD)
AC_SUBST(CPPFLAGS_FOR_BUILD)
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/at_interpreter.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/at_interpreter.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/at_interpreter.h Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: at_interpreter.h,v 1.18 2008/06/11 17:52:30 steveu Exp $
+ * $Id: at_interpreter.h,v 1.19 2008/09/16 12:45:50 steveu Exp $
*/
/*! \file */
@@ -204,6 +204,7 @@
int rings_indicated;
int do_hangup;
int silent_dial;
+ int command_dial;
int ok_is_pending;
int dte_is_waiting;
/*! \brief TRUE if a carrier is presnt. Otherwise FALSE. */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v17rx.h Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v17rx.h,v 1.53 2008/09/08 12:54:32 steveu Exp $
+ * $Id: v17rx.h,v 1.54 2008/09/16 13:02:05 steveu Exp $
*/
/*! \file */
@@ -290,10 +290,17 @@
int32_t carrier_phase_rate;
/*! \brief The carrier update rate saved for reuse when using short training. */
int32_t carrier_phase_rate_save;
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ /*! \brief The proportional part of the carrier tracking filter. */
+ float carrier_track_p;
+ /*! \brief The integral part of the carrier tracking filter. */
+ float carrier_track_i;
+#else
/*! \brief The proportional part of the carrier tracking filter. */
float carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
float carrier_track_i;
+#endif
/*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
power_meter_t power;
@@ -301,10 +308,6 @@
int32_t carrier_on_power;
/*! \brief The power meter level at which carrier off is declared. */
int32_t carrier_off_power;
- /*! \brief The scaling factor accessed by the AGC algorithm. */
- float agc_scaling;
- /*! \brief The previous value of agc_scaling, needed to reuse old training. */
- float agc_scaling_save;
/*! \brief Current read offset into the equalizer buffer. */
int eq_step;
@@ -317,6 +320,11 @@
int baud_half;
#if defined(SPANDSP_USE_FIXED_POINTx)
+ /*! \brief The scaling factor accessed by the AGC algorithm. */
+ float agc_scaling;
+ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
+ float agc_scaling_save;
+
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
@@ -335,6 +343,11 @@
/*! Baud phase for symbol sync. */
int32_t baud_phase;
#else
+ /*! \brief The scaling factor accessed by the AGC algorithm. */
+ float agc_scaling;
+ /*! \brief The previous value of agc_scaling, needed to reuse old training. */
+ float agc_scaling_save;
+
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v27ter_rx.h Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v27ter_rx.h,v 1.49 2008/09/13 14:59:31 steveu Exp $
+ * $Id: v27ter_rx.h,v 1.51 2008/09/16 14:12:23 steveu Exp $
*/
/*! \file */
@@ -100,10 +100,12 @@
/*! \brief A counter for the number of consecutive bits of repeating pattern through
the scrambler. */
int scrambler_pattern_count;
- /*! \brief The section of the training data we are currently in. */
- int training_stage;
/*! \brief The current step in the table of BC constellation positions. */
int training_bc;
+ /*! \brief TRUE if the previous trained values are to be reused. */
+ int old_train;
+ /*! \brief The section of the training data we are currently in. */
+ int training_stage;
/*! \brief A count of how far through the current training step we are. */
int training_count;
/*! \brief A measure of how much mismatch there is between the real constellation,
@@ -119,8 +121,10 @@
int low_samples;
/*! \brief A highest magnitude sample seen. */
int16_t high_sample;
- /*! \brief TRUE if the previous trained values are to be reused. */
- int old_train;
+
+ /*! \brief The position of the current symbol in the constellation, used for
+ differential decoding. */
+ int constellation_state;
/*! \brief The current phase of the carrier (i.e. the DDS parameter). */
uint32_t carrier_phase;
@@ -147,11 +151,7 @@
/*! \brief The power meter level at which carrier off is declared. */
int32_t carrier_off_power;
- /*! \brief The position of the current symbol in the constellation, used for
- differential decoding. */
- int constellation_state;
-
- /*! \brief Current offset into the equalizer buffer. */
+ /*! \brief Current read offset into the equalizer buffer. */
int eq_step;
/*! \brief Current write offset into the equalizer buffer. */
int eq_put_step;
@@ -161,20 +161,20 @@
/*! \brief The current half of the baud. */
int baud_half;
-#if defined(SPANDSP_USE_FIXED_POINTx)
+#if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief The scaling factor accessed by the AGC algorithm. */
- float agc_scaling;
+ int16_t agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */
- float agc_scaling_save;
+ int16_t agc_scaling_save;
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
- complexi16_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
- complexi16_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
+ /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
/*! \brief The equalizer signal buffer. */
- complexi16_t eq_buf[V27TER_EQUALIZER_MASK + 1];
+ /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_MASK + 1];
#else
/*! \brief The scaling factor accessed by the AGC algorithm. */
float agc_scaling;
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v29rx.h Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v29rx.h,v 1.60 2008/09/13 14:10:31 steveu Exp $
+ * $Id: v29rx.h,v 1.62 2008/09/16 14:12:23 steveu Exp $
*/
/*! \file */
@@ -168,10 +168,12 @@
unsigned int scramble_reg;
/*! \brief The register for the training scrambler. */
uint8_t training_scramble_reg;
- /*! \brief The section of the training data we are currently in. */
- int training_stage;
/*! \brief The current step in the table of CD constellation positions. */
int training_cd;
+ /*! \brief TRUE if the previous trained values are to be reused. */
+ int old_train;
+ /*! \brief The section of the training data we are currently in. */
+ int training_stage;
/*! \brief A count of how far through the current training step we are. */
int training_count;
/*! \brief A measure of how much mismatch there is between the real constellation,
@@ -187,8 +189,10 @@
int low_samples;
/*! \brief A highest magnitude sample seen. */
int16_t high_sample;
- /*! \brief TRUE if the previous trained values are to be reused. */
- int old_train;
+
+ /*! \brief The position of the current symbol in the constellation, used for
+ differential decoding. */
+ int constellation_state;
/*! \brief The current phase of the carrier (i.e. the DDS parameter). */
uint32_t carrier_phase;
@@ -215,11 +219,7 @@
/*! \brief The power meter level at which carrier off is declared. */
int32_t carrier_off_power;
- /*! \brief The position of the current symbol in the constellation, used for
- differential decoding. */
- int constellation_state;
-
- /*! \brief Current offset into the equalizer buffer. */
+ /*! \brief Current read offset into the equalizer buffer. */
int eq_step;
/*! \brief Current write offset into the equalizer buffer. */
int eq_put_step;
@@ -231,9 +231,9 @@
#if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief The scaling factor accessed by the AGC algorithm. */
- int32_t agc_scaling;
+ int16_t agc_scaling;
/*! \brief The previous value of agc_scaling, needed to reuse old training. */
- int32_t agc_scaling_save;
+ int16_t agc_scaling_save;
/*! \brief The current delta factor for updating the equalizer coefficients. */
int16_t eq_delta;
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Tue Sep 30 23:56:17 2008
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20080913
-#define SPANDSP_RELEASE_TIME 155039
+#define SPANDSP_RELEASE_DATE 20080916
+#define SPANDSP_RELEASE_TIME 152844
#endif
/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/t30.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/t30.c (original)
+++ freeswitch/trunk/libs/spandsp/src/t30.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t30.c,v 1.266 2008/09/11 15:13:42 steveu Exp $
+ * $Id: t30.c,v 1.267 2008/09/16 12:45:01 steveu Exp $
*/
/*! \file */
@@ -682,7 +682,7 @@
}
/*- End of function --------------------------------------------------------*/
-static int send_rr(t30_state_t *s)
+static void send_rr(t30_state_t *s)
{
if (s->current_status != T30_ERR_TX_T5EXP)
send_simple_frame(s, T30_RR);
Modified: freeswitch/trunk/libs/spandsp/src/v17rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v17rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v17rx.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v17rx.c,v 1.116 2008/09/07 12:45:17 steveu Exp $
+ * $Id: v17rx.c,v 1.118 2008/09/16 14:12:23 steveu Exp $
*/
/*! \file */
@@ -133,13 +133,6 @@
}
/*- End of function --------------------------------------------------------*/
-int v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs)
-{
- *coeffs = s->eq_coeff;
- return V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN;
-}
-/*- End of function --------------------------------------------------------*/
-
static void report_status_change(v17_rx_state_t *s, int status)
{
if (s->status_handler)
@@ -149,37 +142,69 @@
}
/*- End of function --------------------------------------------------------*/
+#if defined(SPANDSP_USE_FIXED_POINTx)
+int v17_rx_equalizer_state(v17_rx_state_t *s, complexi16_t **coeffs)
+#else
+int v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs)
+#endif
+{
+ *coeffs = s->eq_coeff;
+ return V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN;
+}
+/*- End of function --------------------------------------------------------*/
+
static void equalizer_save(v17_rx_state_t *s)
{
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ cvec_copyi16(s->eq_coeff_save, s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+#else
cvec_copyf(s->eq_coeff_save, s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+#endif
}
/*- End of function --------------------------------------------------------*/
static void equalizer_restore(v17_rx_state_t *s)
{
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ cvec_zeroi16(s->eq_buf, V17_EQUALIZER_MASK);
+ s->eq_delta = 32768.0f*EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+#else
cvec_copyf(s->eq_coeff, s->eq_coeff_save, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
cvec_zerof(s->eq_buf, V17_EQUALIZER_MASK);
+ s->eq_delta = EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+#endif
s->eq_put_step = RX_PULSESHAPER_COEFF_SETS*10/(3*2) - 1;
s->eq_step = 0;
- s->eq_delta = EQUALIZER_SLOW_ADAPT_RATIO*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
}
/*- End of function --------------------------------------------------------*/
static void equalizer_reset(v17_rx_state_t *s)
{
/* Start with an equalizer based on everything being perfect */
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ cvec_zeroi16(s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+ s->eq_coeff[V17_EQUALIZER_PRE_LEN] = complex_seti16(3*FP_FACTOR, 0);
+ cvec_zeroi16(s->eq_buf, V17_EQUALIZER_MASK);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+#else
cvec_zerof(s->eq_coeff, V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
s->eq_coeff[V17_EQUALIZER_PRE_LEN] = complex_setf(3.0f, 0.0f);
cvec_zerof(s->eq_buf, V17_EQUALIZER_MASK);
+ s->eq_delta = EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
+#endif
s->eq_put_step = RX_PULSESHAPER_COEFF_SETS*10/(3*2) - 1;
s->eq_step = 0;
- s->eq_delta = EQUALIZER_DELTA/(V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN);
}
/*- End of function --------------------------------------------------------*/
+#if defined(SPANDSP_USE_FIXED_POINTx)
+static __inline__ complexi16_t equalizer_get(v17_rx_state_t *s)
+#else
static __inline__ complexf_t equalizer_get(v17_rx_state_t *s)
+#endif
{
int i;
int p;
@@ -199,7 +224,11 @@
}
/*- End of function --------------------------------------------------------*/
+#if defined(SPANDSP_USE_FIXED_POINTx)
+static void tune_equalizer(v17_rx_state_t *s, const complexi16_t *z, const complexi16_t *target)
+#else
static void tune_equalizer(v17_rx_state_t *s, const complexf_t *z, const complexf_t *target)
+#endif
{
int i;
int p;
@@ -1080,7 +1109,11 @@
process_half_baud(s, &zz);
#endif
}
- dds_advancef(&(s->carrier_phase), s->carrier_phase_rate);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ dds_advance(&s->carrier_phase, s->carrier_phase_rate);
+#else
+ dds_advancef(&s->carrier_phase, s->carrier_phase_rate);
+#endif
}
return 0;
}
Modified: freeswitch/trunk/libs/spandsp/src/v27ter_rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v27ter_rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v27ter_rx.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v27ter_rx.c,v 1.102 2008/09/13 14:59:30 steveu Exp $
+ * $Id: v27ter_rx.c,v 1.104 2008/09/16 14:12:23 steveu Exp $
*/
/*! \file */
@@ -31,10 +31,10 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
-#include <stdlib.h>
#include "floating_fudge.h"
#if defined(HAVE_TGMATH_H)
#include <tgmath.h>
@@ -71,20 +71,20 @@
signal to a static constellation, even though dealing with differences is all
that is necessary. */
-#define CARRIER_NOMINAL_FREQ 1800.0f
-#define EQUALIZER_DELTA 0.25f
+#define CARRIER_NOMINAL_FREQ 1800.0f
+#define EQUALIZER_DELTA 0.25f
#if defined(SPANDSP_USE_FIXED_POINT)
-#define FP_FACTOR 4096
-#define FP_SHIFT_FACTOR 12
+#define FP_FACTOR 4096
+#define FP_SHIFT_FACTOR 12
#endif
/* Segments of the training sequence */
/* V.27ter defines a long and a short sequence. FAX doesn't use the
short sequence, so it is not implemented here. */
-#define V27TER_TRAINING_SEG_3_LEN 50
-#define V27TER_TRAINING_SEG_5_LEN 1074
-#define V27TER_TRAINING_SEG_6_LEN 8
+#define V27TER_TRAINING_SEG_3_LEN 50
+#define V27TER_TRAINING_SEG_5_LEN 1074
+#define V27TER_TRAINING_SEG_6_LEN 8
enum
{
@@ -152,13 +152,6 @@
}
/*- End of function --------------------------------------------------------*/
-int v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs)
-{
- *coeffs = s->eq_coeff;
- return V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN;
-}
-/*- End of function --------------------------------------------------------*/
-
static void report_status_change(v27ter_rx_state_t *s, int status)
{
if (s->status_handler)
@@ -168,6 +161,17 @@
}
/*- End of function --------------------------------------------------------*/
+#if defined(SPANDSP_USE_FIXED_POINTx)
+int v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexi16_t **coeffs)
+#else
+int v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs)
+#endif
+{
+ *coeffs = s->eq_coeff;
+ return V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN;
+}
+/*- End of function --------------------------------------------------------*/
+
static void equalizer_save(v27ter_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
@@ -183,14 +187,15 @@
#if defined(SPANDSP_USE_FIXED_POINTx)
cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_MASK);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
#else
cvec_copyf(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
cvec_zerof(s->eq_buf, V27TER_EQUALIZER_MASK);
+ s->eq_delta = EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
#endif
s->eq_put_step = (s->bit_rate == 4800) ? RX_PULSESHAPER_4800_COEFF_SETS*5/2 : RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2);
s->eq_step = 0;
- s->eq_delta = EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
}
/*- End of function --------------------------------------------------------*/
@@ -201,15 +206,16 @@
cvec_zeroi16(s->eq_coeff, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
s->eq_coeff[V27TER_EQUALIZER_PRE_LEN] = complex_seti16(1.414f*FP_FACTOR, 0);
cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_MASK);
+ s->eq_delta = 32768.0f*EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
#else
cvec_zerof(s->eq_coeff, V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
s->eq_coeff[V27TER_EQUALIZER_PRE_LEN] = complex_setf(1.414f, 0.0f);
cvec_zerof(s->eq_buf, V27TER_EQUALIZER_MASK);
+ s->eq_delta = EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
#endif
s->eq_put_step = (s->bit_rate == 4800) ? RX_PULSESHAPER_4800_COEFF_SETS*5/2 : RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2);
s->eq_step = 0;
- s->eq_delta = EQUALIZER_DELTA/(V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN);
}
/*- End of function --------------------------------------------------------*/
@@ -313,12 +319,65 @@
/*- End of function --------------------------------------------------------*/
#if defined(SPANDSP_USE_FIXED_POINTx)
+static __inline__ int find_quadrant(const complexi16_t *z)
+#else
+static __inline__ int find_quadrant(const complexf_t *z)
+#endif
+{
+ int b1;
+ int b2;
+
+ /* Split the space along the two diagonals. */
+ b1 = (z->im > z->re);
+ b2 = (z->im < -z->re);
+ return (b2 << 1) | (b1 ^ b2);
+}
+/*- End of function --------------------------------------------------------*/
+
+#if defined(SPANDSP_USE_FIXED_POINTx)
+static __inline__ int find_octant(complexi16_t *z)
+#else
+static __inline__ int find_octant(complexf_t *z)
+#endif
+{
+ float abs_re;
+ float abs_im;
+ int b1;
+ int b2;
+ int bits;
+
+ /* Are we near an axis or a diagonal? */
+ abs_re = fabsf(z->re);
+ abs_im = fabsf(z->im);
+ if (abs_im > abs_re*0.4142136f && abs_im < abs_re*2.4142136f)
+ {
+ /* Split the space along the two axes. */
+ b1 = (z->re < 0.0f);
+ b2 = (z->im < 0.0f);
+ bits = (b2 << 2) | ((b1 ^ b2) << 1) | 1;
+ }
+ else
+ {
+ /* Split the space along the two diagonals. */
+ b1 = (z->im > z->re);
+ b2 = (z->im < -z->re);
+ bits = (b2 << 2) | ((b1 ^ b2) << 1);
+ }
+ return bits;
+}
+/*- End of function --------------------------------------------------------*/
+
+#if defined(SPANDSP_USE_FIXED_POINTx)
static __inline__ void track_carrier(v27ter_rx_state_t *s, const complexi16_t *z, const complexi16_t *target)
#else
static __inline__ void track_carrier(v27ter_rx_state_t *s, const complexf_t *z, const complexf_t *target)
#endif
{
+#if defined(SPANDSP_USE_FIXED_POINTx)
+ int32_t error;
+#else
float error;
+#endif
/* For small errors the imaginary part of the difference between the actual and the target
positions is proportional to the phase error, for any particular target. However, the
@@ -395,55 +454,6 @@
/*- End of function --------------------------------------------------------*/
#if defined(SPANDSP_USE_FIXED_POINTx)
-static __inline__ int find_quadrant(const complexi16_t *z)
-#else
-static __inline__ int find_quadrant(const complexf_t *z)
-#endif
-{
- int b1;
- int b2;
-
- /* Split the space along the two diagonals. */
- b1 = (z->im > z->re);
- b2 = (z->im < -z->re);
- return (b2 << 1) | (b1 ^ b2);
-}
-/*- End of function --------------------------------------------------------*/
-
-#if defined(SPANDSP_USE_FIXED_POINTx)
-static __inline__ int find_octant(complexi16_t *z)
-#else
-static __inline__ int find_octant(complexf_t *z)
-#endif
-{
- float abs_re;
- float abs_im;
- int b1;
- int b2;
- int bits;
-
- /* Are we near an axis or a diagonal? */
- abs_re = fabsf(z->re);
- abs_im = fabsf(z->im);
- if (abs_im > abs_re*0.4142136f && abs_im < abs_re*2.4142136f)
- {
- /* Split the space along the two axes. */
- b1 = (z->re < 0.0f);
- b2 = (z->im < 0.0f);
- bits = (b2 << 2) | ((b1 ^ b2) << 1) | 1;
- }
- else
- {
- /* Split the space along the two diagonals. */
- b1 = (z->im > z->re);
- b2 = (z->im < -z->re);
- bits = (b2 << 2) | ((b1 ^ b2) << 1);
- }
- return bits;
-}
-/*- End of function --------------------------------------------------------*/
-
-#if defined(SPANDSP_USE_FIXED_POINTx)
static void decode_baud(v27ter_rx_state_t *s, complexi16_t *z)
#else
static void decode_baud(v27ter_rx_state_t *s, complexf_t *z)
@@ -460,25 +470,23 @@
int nearest;
int raw_bits;
- switch (s->bit_rate)
+ if (s->bit_rate == 2400)
{
- case 4800:
- default:
- nearest = find_octant(z);
- raw_bits = phase_steps_4800[(nearest - s->constellation_state) & 7];
- put_bit(s, raw_bits);
- put_bit(s, raw_bits >> 1);
- put_bit(s, raw_bits >> 2);
- s->constellation_state = nearest;
- break;
- case 2400:
nearest = find_quadrant(z);
raw_bits = phase_steps_2400[(nearest - s->constellation_state) & 3];
put_bit(s, raw_bits);
put_bit(s, raw_bits >> 1);
s->constellation_state = nearest;
nearest <<= 1;
- break;
+ }
+ else
+ {
+ nearest = find_octant(z);
+ raw_bits = phase_steps_4800[(nearest - s->constellation_state) & 7];
+ put_bit(s, raw_bits);
+ put_bit(s, raw_bits >> 1);
+ put_bit(s, raw_bits >> 2);
+ s->constellation_state = nearest;
}
track_carrier(s, z, &v27ter_constellation[nearest]);
if (--s->eq_skip <= 0)
@@ -526,7 +534,7 @@
}
/*- End of function --------------------------------------------------------*/
-#if defined(SPANDSP_USE_FIXED_POINTx)
+#if defined(SPANDSP_USE_FIXED_POINT)
static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexi16_t *sample)
#else
static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t *sample)
@@ -546,7 +554,12 @@
/* Add a sample to the equalizer's circular buffer, but don't calculate anything
at this time. */
+#if defined(SPANDSP_USE_FIXED_POINT)
+ s->eq_buf[s->eq_step].re = sample->re/(float) FP_FACTOR;
+ s->eq_buf[s->eq_step].im = sample->im/(float) FP_FACTOR;
+#else
s->eq_buf[s->eq_step] = *sample;
+#endif
s->eq_step = (s->eq_step + 1) & V27TER_EQUALIZER_MASK;
/* On alternate insertions we have a whole baud, and must process it. */
@@ -765,16 +778,15 @@
int step;
int16_t x;
int32_t diff;
- complexf_t z;
#if defined(SPANDSP_USE_FIXED_POINT)
- complexi_t zi;
-#endif
-#if defined(SPANDSP_USE_FIXED_POINTx)
- complexi16_t sample;
+ complexi16_t z;
complexi16_t zz;
+ complexi16_t sample;
+ complexi32_t zi;
#else
- complexf_t sample;
+ complexf_t z;
complexf_t zz;
+ complexf_t sample;
#endif
int32_t power;
@@ -832,8 +844,7 @@
continue;
}
#if defined(IAXMODEM_STUFF)
- /* Carrier has dropped, but the put_bit is
- pending the signal_present delay. */
+ /* Carrier has dropped, but the put_bit is pending the signal_present delay. */
s->carrier_drop_pending = TRUE;
#endif
}
@@ -861,8 +872,8 @@
if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION)
{
/* Only AGC during the initial training */
-#if defined(SPANDSP_USE_FIXED_POINTx)
- s->agc_scaling = (float) FP_FACTOR*(1.0f/RX_PULSESHAPER_4800_GAIN)*1.414f/sqrtf(power);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ s->agc_scaling = (float) FP_FACTOR*32768.0f*(1.0f/RX_PULSESHAPER_4800_GAIN)*1.414f/sqrtf(power);
#else
s->agc_scaling = (1.0f/RX_PULSESHAPER_4800_GAIN)*1.414f/sqrtf(power);
#endif
@@ -883,8 +894,11 @@
zi.re += (int32_t) rx_pulseshaper_4800[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
zi.im += (int32_t) rx_pulseshaper_4800[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
}
- sample.re = zi.re*s->agc_scaling;
- sample.im = zi.im*s->agc_scaling;
+ sample.re = ((int32_t) zi.re*(int32_t) s->agc_scaling) >> 15;
+ sample.im = ((int32_t) zi.im*(int32_t) s->agc_scaling) >> 15;
+ z = dds_lookup_complexi16(s->carrier_phase);
+ zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15;
+ zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15;
#else
zz.re = rx_pulseshaper_4800[step][0].re*s->rrc_filter[s->rrc_filter_step];
zz.im = rx_pulseshaper_4800[step][0].im*s->rrc_filter[s->rrc_filter_step];
@@ -895,16 +909,17 @@
}
sample.re = zz.re*s->agc_scaling;
sample.im = zz.im*s->agc_scaling;
-#endif
- /* Shift to baseband - since this is done in a full complex form, the
- result is clean, and requires no further filtering, apart from the
- equalizer. */
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
zz.im = -sample.re*z.im - sample.im*z.re;
+#endif
process_half_baud(s, &zz);
}
- dds_advancef(&(s->carrier_phase), s->carrier_phase_rate);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ dds_advance(&s->carrier_phase, s->carrier_phase_rate);
+#else
+ dds_advancef(&s->carrier_phase, s->carrier_phase_rate);
+#endif
}
}
else
@@ -990,8 +1005,8 @@
if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION)
{
/* Only AGC during the initial training */
-#if defined(SPANDSP_USE_FIXED_POINTx)
- s->agc_scaling = (float) FP_FACTOR*(1.0f/RX_PULSESHAPER_2400_GAIN)*1.414f/sqrtf(power);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ s->agc_scaling = (float) FP_FACTOR*32768.0f*(1.0f/RX_PULSESHAPER_2400_GAIN)*1.414f/sqrtf(power);
#else
s->agc_scaling = (1.0f/RX_PULSESHAPER_2400_GAIN)*1.414f/sqrtf(power);
#endif
@@ -1012,8 +1027,11 @@
zi.re += (int32_t) rx_pulseshaper_2400[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
zi.im += (int32_t) rx_pulseshaper_2400[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step];
}
- sample.re = zi.re*s->agc_scaling;
- sample.im = zi.im*s->agc_scaling;
+ sample.re = ((int32_t) zi.re*(int32_t) s->agc_scaling) >> 15;
+ sample.im = ((int32_t) zi.im*(int32_t) s->agc_scaling) >> 15;
+ z = dds_lookup_complexi16(s->carrier_phase);
+ zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15;
+ zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15;
#else
zz.re = rx_pulseshaper_2400[step][0].re*s->rrc_filter[s->rrc_filter_step];
zz.im = rx_pulseshaper_2400[step][0].im*s->rrc_filter[s->rrc_filter_step];
@@ -1024,16 +1042,17 @@
}
sample.re = zz.re*s->agc_scaling;
sample.im = zz.im*s->agc_scaling;
-#endif
- /* Shift to baseband - since this is done in a full complex form, the
- result is clean, and requires no further filtering apart from the
- equalizer. */
z = dds_lookup_complexf(s->carrier_phase);
zz.re = sample.re*z.re - sample.im*z.im;
zz.im = -sample.re*z.im - sample.im*z.re;
+#endif
process_half_baud(s, &zz);
}
- dds_advancef(&(s->carrier_phase), s->carrier_phase_rate);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ dds_advance(&s->carrier_phase, s->carrier_phase_rate);
+#else
+ dds_advancef(&s->carrier_phase, s->carrier_phase_rate);
+#endif
}
}
return 0;
@@ -1103,7 +1122,7 @@
{
s->carrier_phase_rate = dds_phase_ratef(CARRIER_NOMINAL_FREQ);
#if defined(SPANDSP_USE_FIXED_POINTx)
- s->agc_scaling = (float) FP_FACTOR*0.005f/RX_PULSESHAPER_4800_GAIN;
+ s->agc_scaling = (float) FP_FACTOR*32768.0f*0.005f/RX_PULSESHAPER_4800_GAIN;
#else
s->agc_scaling = 0.005f/RX_PULSESHAPER_4800_GAIN;
#endif
Modified: freeswitch/trunk/libs/spandsp/src/v29rx.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v29rx.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v29rx.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v29rx.c,v 1.138 2008/09/13 15:48:04 steveu Exp $
+ * $Id: v29rx.c,v 1.140 2008/09/16 14:12:23 steveu Exp $
*/
/*! \file */
@@ -65,19 +65,19 @@
#include "v29rx_floating_rrc.h"
#endif
-#define CARRIER_NOMINAL_FREQ 1700.0f
-#define BAUD_RATE 2400
-#define EQUALIZER_DELTA 0.21f
+#define CARRIER_NOMINAL_FREQ 1700.0f
+#define BAUD_RATE 2400
+#define EQUALIZER_DELTA 0.21f
#if defined(SPANDSP_USE_FIXED_POINT)
-#define FP_FACTOR 4096
-#define FP_SHIFT_FACTOR 12
+#define FP_FACTOR 4096
+#define FP_SHIFT_FACTOR 12
#endif
/* Segments of the training sequence */
-#define V29_TRAINING_SEG_2_LEN 128
-#define V29_TRAINING_SEG_3_LEN 384
-#define V29_TRAINING_SEG_4_LEN 48
+#define V29_TRAINING_SEG_2_LEN 128
+#define V29_TRAINING_SEG_3_LEN 384
+#define V29_TRAINING_SEG_4_LEN 48
enum
{
@@ -146,6 +146,12 @@
}
/*- End of function --------------------------------------------------------*/
+float v29_rx_signal_power(v29_rx_state_t *s)
+{
+ return power_meter_current_dbm0(&s->power);
+}
+/*- End of function --------------------------------------------------------*/
+
void v29_rx_signal_cutoff(v29_rx_state_t *s, float cutoff)
{
/* The 0.4 factor allows for the gain of the DC blocker */
@@ -154,9 +160,12 @@
}
/*- End of function --------------------------------------------------------*/
-float v29_rx_signal_power(v29_rx_state_t *s)
+static void report_status_change(v29_rx_state_t *s, int status)
{
- return power_meter_current_dbm0(&s->power);
+ if (s->status_handler)
+ s->status_handler(s->status_user_data, status);
+ else if (s->put_bit)
+ s->put_bit(s->put_bit_user_data, status);
}
/*- End of function --------------------------------------------------------*/
@@ -171,15 +180,6 @@
}
/*- End of function --------------------------------------------------------*/
-static void report_status_change(v29_rx_state_t *s, int status)
-{
- if (s->status_handler)
- s->status_handler(s->status_user_data, status);
- else if (s->put_bit)
- s->put_bit(s->put_bit_user_data, status);
-}
-/*- End of function --------------------------------------------------------*/
-
static void equalizer_save(v29_rx_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINT)
@@ -519,7 +519,7 @@
v = (((s->symbol_sync_low[1] >> 5)*(s->symbol_sync_high[1] >> 4)) >> 15)*SYNC_CROSS_CORR_COEFF_A
+ (((s->symbol_sync_low[0] >> 5)*(s->symbol_sync_high[1] >> 4)) >> 15)*SYNC_CROSS_CORR_COEFF_B
+ (((s->symbol_sync_low[1] >> 5)*(s->symbol_sync_high[0] >> 4)) >> 15)*SYNC_CROSS_CORR_COEFF_C;
- /* Filter away any DC component */
+ /* Filter away any DC component */
p = v - s->symbol_sync_dc_filter[1];
s->symbol_sync_dc_filter[1] = s->symbol_sync_dc_filter[0];
s->symbol_sync_dc_filter[0] = v;
@@ -541,7 +541,7 @@
v = s->symbol_sync_low[1]*s->symbol_sync_high[1]*SYNC_CROSS_CORR_COEFF_A
+ s->symbol_sync_low[0]*s->symbol_sync_high[1]*SYNC_CROSS_CORR_COEFF_B
+ s->symbol_sync_low[1]*s->symbol_sync_high[0]*SYNC_CROSS_CORR_COEFF_C;
- /* Filter away any DC component */
+ /* Filter away any DC component */
p = v - s->symbol_sync_dc_filter[1];
s->symbol_sync_dc_filter[1] = s->symbol_sync_dc_filter[0];
s->symbol_sync_dc_filter[0] = v;
@@ -1026,7 +1026,11 @@
#endif
process_half_baud(s, &zz);
}
- dds_advancef(&(s->carrier_phase), s->carrier_phase_rate);
+#if defined(SPANDSP_USE_FIXED_POINT)
+ dds_advance(&s->carrier_phase, s->carrier_phase_rate);
+#else
+ dds_advancef(&s->carrier_phase, s->carrier_phase_rate);
+#endif
}
return 0;
}
Modified: freeswitch/trunk/libs/spandsp/src/vector_float.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/vector_float.c (original)
+++ freeswitch/trunk/libs/spandsp/src/vector_float.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_float.c,v 1.11 2008/07/02 14:48:26 steveu Exp $
+ * $Id: vector_float.c,v 1.12 2008/09/16 15:21:52 steveu Exp $
*/
/*! \file */
@@ -44,6 +44,32 @@
#endif
#include <assert.h>
+#if defined(SPANDSP_USE_MMX)
+#include <mmintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE)
+#include <xmmintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE2)
+#include <emmintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE3)
+#include <pmmintrin.h>
+#include <tmmintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE4_1)
+#include <smmintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE4_2)
+#include <nmmintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE4A)
+#include <ammintrin.h>
+#endif
+#if defined(SPANDSP_USE_SSE5)
+#include <bmmintrin.h>
+#endif
+
#include "spandsp/telephony.h"
#include "spandsp/vector_float.h"
@@ -100,7 +126,7 @@
int i;
for (i = 0; i < n; i++)
- z[i] = 0.0;
+ z[i] = 0.0L;
}
/*- End of function --------------------------------------------------------*/
#endif
@@ -306,6 +332,41 @@
/*- End of function --------------------------------------------------------*/
#endif
+#if defined(__GNUC__) && defined(SPANDSP_USE_SSE2)
+float vec_dot_prodf(const float x[], const float y[], int n)
+{
+ int i;
+ float z;
+ __m128 num1, num2, num3, num4;
+
+ z = 0.0f;
+ if ((i = n & ~3))
+ {
+ num4 = _mm_setzero_ps(); //sets sum to zero
+ for (i -= 4; i >= 0; i -= 4)
+ {
+ num1 = _mm_loadu_ps(x + i);
+ num2 = _mm_loadu_ps(y + i);
+ num3 = _mm_mul_ps(num1, num2);
+ num4 = _mm_add_ps(num4, num3);
+ }
+ num4 = _mm_add_ps(_mm_movehl_ps(num4, num4), num4);
+ num4 = _mm_add_ss(_mm_shuffle_ps(num4, num4, 1), num4);
+ _mm_store_ss(&z, num4);
+ }
+ /* Now deal with the last 1 to 3 elements, which don't fill in an SSE2 register */
+ switch (n & 3)
+ {
+ case 3:
+ z += x[n - 3]*y[n - 3];
+ case 2:
+ z += x[n - 2]*y[n - 2];
+ case 1:
+ z += x[n - 1]*y[n - 1];
+ }
+ return z;
+}
+#else
float vec_dot_prodf(const float x[], const float y[], int n)
{
int i;
@@ -317,6 +378,7 @@
return z;
}
/*- End of function --------------------------------------------------------*/
+#endif
double vec_dot_prod(const double x[], const double y[], int n)
{
@@ -336,7 +398,7 @@
int i;
long double z;
- z = 0.0;
+ z = 0.0L;
for (i = 0; i < n; i++)
z += x[i]*y[i];
return z;
Modified: freeswitch/trunk/libs/spandsp/src/vector_int.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/vector_int.c (original)
+++ freeswitch/trunk/libs/spandsp/src/vector_int.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_int.c,v 1.12 2008/09/01 16:07:34 steveu Exp $
+ * $Id: vector_int.c,v 1.13 2008/09/16 15:21:52 steveu Exp $
*/
/*! \file */
@@ -51,7 +51,7 @@
{
int32_t z;
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && defined(SPANDSP_USE_MMX)
__asm__ __volatile__(
" emms;\n"
" pxor %%mm0,%%mm0;\n"
@@ -162,7 +162,7 @@
int32_t vec_min_maxi16(const int16_t x[], int n, int16_t out[])
{
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && defined(SPANDSP_USE_MMX)
static const int32_t lower_bound = 0x80008000;
static const int32_t upper_bound = 0x7FFF7FFF;
int32_t max;
Modified: freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c (original)
+++ freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: at_interpreter_tests.c,v 1.18 2008/08/17 16:25:52 steveu Exp $
+ * $Id: at_interpreter_tests.c,v 1.19 2008/09/16 12:45:25 steveu Exp $
*/
/*! \file */
@@ -350,7 +350,7 @@
{"AT+VTX\r", "\r\nOK\r\n"}, /* V.253 10.1.6 - Transmit data state */
{"AT+WS46\r", "\r\nOK\r\n"}, /* 3GPP TS 27.007 5.9 - PCCA STD-101 [17] select wireless network */
{"ATA\r", "\r\nERROR\r\n"}, /* V.250 6.3.5 - Answer */
- {"ATDT -1234567890ABCDPSTW*#+,!@\r", ""}, /* V.250 6.3.1 - Dial */
+ {"ATDT -1234567890ABCDPSTW*#+,!@\r;", ""}, /* V.250 6.3.1 - Dial */
{"ATE1\r", "\r\nOK\r\n"}, /* V.250 6.2.4 - Command echo */
{"ATE0\r", "ATE0\r\r\nOK\r\n"}, /* V.250 6.2.4 - Command echo */
{"ATH\r", "\r\nOK\r\n"}, /* V.250 6.3.6 - Hook control */
Modified: freeswitch/trunk/libs/spandsp/tests/vector_float_tests.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/vector_float_tests.c (original)
+++ freeswitch/trunk/libs/spandsp/tests/vector_float_tests.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_float_tests.c,v 1.9 2008/05/13 13:17:27 steveu Exp $
+ * $Id: vector_float_tests.c,v 1.10 2008/09/16 15:21:52 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
@@ -49,26 +49,82 @@
}
/*- End of function --------------------------------------------------------*/
-int main(int argc, char *argv[])
+static int test_vec_dot_prod(void)
{
int i;
double x[100];
double y[100];
double zsa;
double zsb;
+ double ratio;
for (i = 0; i < 99; i++)
{
x[i] = rand();
y[i] = rand();
}
- zsa = vec_dot_prod(x, y, 99);
- zsb = vec_dot_prod_dumb(x, y, 99);
- if (zsa != zsb)
+ for (i = 1; i < 99; i++)
{
- printf("Tests failed\n");
- exit(2);
+ zsa = vec_dot_prod(x, y, i);
+ zsb = vec_dot_prod_dumb(x, y, i);
+ ratio = zsa/zsb;
+ if (ratio < 0.9999 || ratio > 1.0001)
+ {
+ printf("vec_dot_prod() - %f %f\n", zsa, zsb);
+ printf("Tests failed\n");
+ exit(2);
+ }
}
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static float vec_dot_prodf_dumb(const float x[], const float y[], int n)
+{
+ int i;
+ float z;
+
+ z = 0.0;
+ for (i = 0; i < n; i++)
+ z += x[i]*y[i];
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_vec_dot_prodf(void)
+{
+ int i;
+ float x[100];
+ float y[100];
+ float zsa;
+ float zsb;
+ float ratio;
+
+ for (i = 0; i < 99; i++)
+ {
+ x[i] = rand();
+ y[i] = rand();
+ }
+ for (i = 1; i < 99; i++)
+ {
+ zsa = vec_dot_prodf(x, y, i);
+ zsb = vec_dot_prodf_dumb(x, y, i);
+ ratio = zsa/zsb;
+ if (ratio < 0.9999f || ratio > 1.0001f)
+ {
+ printf("vec_dot_prodf() - %e %e\n", zsa, zsb);
+ printf("Tests failed\n");
+ exit(2);
+ }
+ }
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ test_vec_dot_prod();
+ test_vec_dot_prodf();
printf("Tests passed.\n");
return 0;
Modified: freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c (original)
+++ freeswitch/trunk/libs/spandsp/tests/vector_int_tests.c Tue Sep 30 23:56:17 2008
@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: vector_int_tests.c,v 1.8 2008/05/13 13:17:27 steveu Exp $
+ * $Id: vector_int_tests.c,v 1.9 2008/09/16 15:21:52 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
@@ -44,8 +44,36 @@
z = 0;
for (i = 0; i < n; i++)
- z += x[i]*y[i];
- return z;
+ z += (int32_t) x[i]*(int32_t) y[i];
+ return z;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_vec_dot_prodi16(void)
+{
+ int i;
+ int32_t za;
+ int32_t zb;
+ int16_t x[99];
+ int16_t y[99];
+
+ for (i = 0; i < 99; i++)
+ {
+ x[i] = rand();
+ y[i] = rand();
+ }
+
+ for (i = 1; i < 99; i++)
+ {
+ za = vec_dot_prodi16(x, y, i);
+ zb = vec_dot_prodi16_dumb(x, y, i);
+ if (za != zb)
+ {
+ printf("Tests failed\n");
+ exit(2);
+ }
+ }
+ return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -79,7 +107,7 @@
}
/*- End of function --------------------------------------------------------*/
-int main(int argc, char *argv[])
+static int test_vec_min_maxi16(void)
{
int i;
int32_t za;
@@ -95,14 +123,6 @@
y[i] = rand();
}
- za = vec_dot_prodi16(x, y, 99);
- zb = vec_dot_prodi16_dumb(x, y, 99);
- if (za != zb)
- {
- printf("Tests failed\n");
- exit(2);
- }
-
x[42] = -32768;
za = vec_min_maxi16_dumb(x, 99, outa);
zb = vec_min_maxi16(x, 99, outb);
@@ -115,6 +135,15 @@
printf("Tests failed\n");
exit(2);
}
+ return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ test_vec_dot_prodi16();
+ test_vec_min_maxi16();
+
printf("Tests passed.\n");
return 0;
}
1
0