diff --git a/Freeswitch.2008.express.sln b/Freeswitch.2008.express.sln index ad3cafe5cd..d9cb441e2f 100644 --- a/Freeswitch.2008.express.sln +++ b/Freeswitch.2008.express.sln @@ -1642,6 +1642,7 @@ Global {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.All|Win32.Build.0 = Release|Win32 {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.All|x64.ActiveCfg = Release|Win32 {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.Debug|Win32.ActiveCfg = Debug|Win32 + {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.Debug|Win32.Build.0 = Debug|Win32 {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.Debug|x64.ActiveCfg = Debug|Win32 {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.Debug|x64.Build.0 = Debug|Win32 {D5D2BF72-29FE-4982-A9FA-82AB2086DB1B}.Release|Win32.ActiveCfg = Release|Win32 @@ -2047,6 +2048,7 @@ Global {B808178B-82F0-4CF4-A2B1-921939FA24D0}.Debug|Win32.Build.0 = Debug|Win32 {B808178B-82F0-4CF4-A2B1-921939FA24D0}.Debug|x64.ActiveCfg = Debug|Win32 {B808178B-82F0-4CF4-A2B1-921939FA24D0}.Release|Win32.ActiveCfg = Release|Win32 + {B808178B-82F0-4CF4-A2B1-921939FA24D0}.Release|Win32.Build.0 = Release|Win32 {B808178B-82F0-4CF4-A2B1-921939FA24D0}.Release|x64.ActiveCfg = Release|Win32 {9778F1C0-09BC-4698-8EBC-BD982247209A}.All|Win32.ActiveCfg = Release|Win32 {9778F1C0-09BC-4698-8EBC-BD982247209A}.All|x64.ActiveCfg = Release|x64 diff --git a/build/modules.conf.in b/build/modules.conf.in index bd5d49a7ad..69d90a8dd4 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -73,6 +73,8 @@ endpoints/mod_loopback #event_handlers/mod_event_multicast event_handlers/mod_event_socket event_handlers/mod_cdr_csv +event_handlers/mod_cdr_sqlite +#event_handlers/mod_cdr_pg_csv #event_handlers/mod_radius_cdr #event_handlers/mod_erlang_event formats/mod_native_file diff --git a/conf/autoload_configs/cdr_pg_csv.conf.xml b/conf/autoload_configs/cdr_pg_csv.conf.xml index ec62053190..2f2efa9b26 100644 --- a/conf/autoload_configs/cdr_pg_csv.conf.xml +++ b/conf/autoload_configs/cdr_pg_csv.conf.xml @@ -1,23 +1,21 @@ + + + + + + + - + + + - - - - - - - - - - - diff --git a/conf/autoload_configs/cdr_sqlite.conf.xml b/conf/autoload_configs/cdr_sqlite.conf.xml new file mode 100644 index 0000000000..872c04c4fb --- /dev/null +++ b/conf/autoload_configs/cdr_sqlite.conf.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/conf/autoload_configs/modules.conf.xml b/conf/autoload_configs/modules.conf.xml index 118d7c4d81..51c62f2059 100644 --- a/conf/autoload_configs/modules.conf.xml +++ b/conf/autoload_configs/modules.conf.xml @@ -19,6 +19,7 @@ + diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml index 896dd0e712..fba809ba2c 100644 --- a/conf/autoload_configs/switch.conf.xml +++ b/conf/autoload_configs/switch.conf.xml @@ -23,7 +23,13 @@ - + diff --git a/conf/notify-voicemail.tpl b/conf/notify-voicemail.tpl index 5defd74b3a..365faa2921 100644 --- a/conf/notify-voicemail.tpl +++ b/conf/notify-voicemail.tpl @@ -37,6 +37,7 @@ Content-Transfer-Encoding: 7bit Created: ${voicemail_time}
Duration: ${voicemail_message_len}
Account: ${voicemail_account}@${voicemail_domain}
+ diff --git a/conf/voicemail.tpl b/conf/voicemail.tpl index a98f9d703e..2774b78a9e 100644 --- a/conf/voicemail.tpl +++ b/conf/voicemail.tpl @@ -37,6 +37,7 @@ Content-Transfer-Encoding: 7bit Created: ${voicemail_time}
Duration: ${voicemail_message_len}
Account: ${voicemail_account}@${voicemail_domain}
+ diff --git a/debian/changelog b/debian/changelog index 8065d932e3..158984b9b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +freeswitch (1.0.head~git.master.20101222.1-1) unstable; urgency=low + + * cleaning work + + -- Michal Bielicki Wed, 22 Dec 2010 22:48:02 +0200 + freeswitch (1.0.head~git.master.20101015.1-1) unstable; urgency=low * reintroduced mod_flite diff --git a/debian/sounds/freeswitch-sounds-en-us-callie/debian/changelog b/debian/sounds/freeswitch-sounds-en-us-callie/debian/changelog index 9ca1d1a933..9bb038ae96 100644 --- a/debian/sounds/freeswitch-sounds-en-us-callie/debian/changelog +++ b/debian/sounds/freeswitch-sounds-en-us-callie/debian/changelog @@ -1,11 +1,17 @@ -freeswitch-sounds-en-us-callie (1.0.head-git.master,20101014.1-1) unstable; urgency=low +freeswitch-sounds-en-us-callie (1.0.14~git.master.20101222.1-1) unstable; urgency=low - * Change upstream package version numbering scheme for unreleased versions: - new format is major.minor.micro~git.branch.date.commits-1 + * Bumped up to 1.0.14 version + * Clean ups + + -- Michal Bielicki Wed, 22 Dec 2010 22:55:02 +0200 + +freeswitch-sounds-en-us-callie (1.0.head~git.master.20101014.1-1) unstable; urgency=low + + * Change upstream package version numbering scheme for unreleased versions: new format is major.minor.micro~git.branch.date.commits-1 * Change source format to 3.0 (quilt). * Upgrade debhelper compatibility to version 7. - -- Michal Bielicki Fr, 14 Oct 2010 05:05:02 +0200 + -- Michal Bielicki Fri, 14 Oct 2010 05:05:02 +0200 freeswitch-sounds-en-us-callie (1.0.12-0ubuntu1) jaunty; urgency=low diff --git a/debian/sounds/freeswitch-sounds-en-us-callie/debian/files b/debian/sounds/freeswitch-sounds-en-us-callie/debian/files deleted file mode 100644 index 3da0b654c4..0000000000 --- a/debian/sounds/freeswitch-sounds-en-us-callie/debian/files +++ /dev/null @@ -1,6 +0,0 @@ -freeswitch-sounds-en-us-callie-8000_1.0.12-0ubuntu1_all.deb net extra -freeswitch-sounds-en-us-callie-16000_1.0.12-0ubuntu1_all.deb net extra -freeswitch-sounds-en-us-callie-32000_1.0.12-0ubuntu1_all.deb net extra -freeswitch-sounds-en-us-callie-48000_1.0.12-0ubuntu1_all.deb net extra -freeswitch-sounds-en-us-callie_1.0.12-0ubuntu1_all.deb net extra -freeswitch-sounds-en-us-callie-omega_1.0.12-0ubuntu1_all.deb net extra diff --git a/debian/sounds/freeswitch-sounds-en-us-callie/debian/rules b/debian/sounds/freeswitch-sounds-en-us-callie/debian/rules old mode 100644 new mode 100755 diff --git a/debian/sounds/freeswitch-sounds-music/debian/changelog b/debian/sounds/freeswitch-sounds-music/debian/changelog index 2d639c0691..c5c52da460 100644 --- a/debian/sounds/freeswitch-sounds-music/debian/changelog +++ b/debian/sounds/freeswitch-sounds-music/debian/changelog @@ -1,3 +1,9 @@ +freeswitch-sounds-music (1.0.8~git.master.20101222.1-1) unstable; urgency=low + + * Clean ups + + -- Michal Bielicki Wed, 22 Dec 2010 22:55:02 +0200 + freeswitch-sounds-music (1.0.head-git.master,20101014.1-1) unstable; urgency=low * Change upstream package version numbering scheme for unreleased versions: @@ -5,7 +11,7 @@ freeswitch-sounds-music (1.0.head-git.master,20101014.1-1) unstable; urgency=low * Change source format to 3.0 (quilt). * Upgrade debhelper compatibility to version 7. - -- Michal Bielicki Fr, 14 Oct 2010 05:05:02 +0200 + -- Michal Bielicki Fri, 14 Oct 2010 05:05:02 +0200 freeswitch-sounds-music (1.0.8-0ubuntu3) jaunty; urgency=low diff --git a/debian/sounds/freeswitch-sounds-music/debian/files b/debian/sounds/freeswitch-sounds-music/debian/files deleted file mode 100644 index 9251f8dd29..0000000000 --- a/debian/sounds/freeswitch-sounds-music/debian/files +++ /dev/null @@ -1,6 +0,0 @@ -freeswitch-sounds-music-8000_1.0.8-0ubuntu3_all.deb net extra -freeswitch-sounds-music-16000_1.0.8-0ubuntu3_all.deb net extra -freeswitch-sounds-music-32000_1.0.8-0ubuntu3_all.deb net extra -freeswitch-sounds-music-48000_1.0.8-0ubuntu3_all.deb net extra -freeswitch-sounds-music_1.0.8-0ubuntu3_all.deb net extra -freeswitch-sounds-music-omega_1.0.8-0ubuntu3_all.deb net extra diff --git a/debian/sounds/freeswitch-sounds-music/debian/rules b/debian/sounds/freeswitch-sounds-music/debian/rules old mode 100644 new mode 100755 diff --git a/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/changelog b/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/changelog index 38cc529ef6..44eb4c72b6 100644 --- a/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/changelog +++ b/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/changelog @@ -1,3 +1,9 @@ +freeswitch-sounds-ru-ru-elena (1.0.8~git.master.20101222.1-1) unstable; urgency=low + + * Clean ups + + -- Michal Bielicki Wed, 22 Dec 2010 22:55:02 +0200 + freeswitch-sounds-ru-ru-elena (1.0.head-git.master,20101014.1-1) unstable; urgency=low * Change upstream package version numbering scheme for unreleased versions: diff --git a/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/files b/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/files deleted file mode 100644 index f4b6f0c92d..0000000000 --- a/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/files +++ /dev/null @@ -1,6 +0,0 @@ -freeswitch-sounds-ru-ru-elena-8000_1.0.12-0ubuntu3_all.deb net extra -freeswitch-sounds-ru-ru-elena-16000_1.0.12-0ubuntu3_all.deb net extra -freeswitch-sounds-ru-ru-elena-32000_1.0.12-0ubuntu3_all.deb net extra -freeswitch-sounds-ru-ru-elena-48000_1.0.12-0ubuntu3_all.deb net extra -freeswitch-sounds-ru-ru-elena_1.0.12-0ubuntu3_all.deb net extra -freeswitch-sounds-ru-ru-elena-omega_1.0.12-0ubuntu3_all.deb net extra diff --git a/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/rules b/debian/sounds/freeswitch-sounds-ru-RU-elena/debian/rules old mode 100644 new mode 100755 diff --git a/debian/sounds/getsounds.sh b/debian/sounds/getsounds.sh index bf59a02772..b75a86f309 100755 --- a/debian/sounds/getsounds.sh +++ b/debian/sounds/getsounds.sh @@ -1,5 +1,5 @@ #!/bin/bash -sounds_en_us_callie="freeswitch-sounds-en-us-callie-48000-1.0.12.tar.gz" +sounds_en_us_callie="freeswitch-sounds-en-us-callie-48000-1.0.14.tar.gz" sounds_music="freeswitch-sounds-music-48000-1.0.8.tar.gz" sounds_ru_RU_elena="freeswitch-sounds-ru-RU-elena-48000-1.0.12.tar.gz" @@ -27,4 +27,4 @@ if [ ! -f $sounds_ru_RU_elena ] wget http://files.freeswitch.org/$sounds_ru_RU_elena fi tar zxvf $sounds_ru_RU_elena -cd .. \ No newline at end of file +cd .. diff --git a/docs/ChangeLog b/docs/ChangeLog index 0ca48c0e81..41f94d78ab 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -80,7 +80,6 @@ freeswitch (1.0.7) core: change channel app_flags to be realm specific and default old version to use __FILE__ as the realm name to avoid cross fire between apps using app flags (r:09c1815c) core: preanswer before getting variables to avoid crash (r:25fe16df) core: Windows: Don't report "unknown command" on console when empty command has been given (r:c8f9fb56/FSCORE-641) - embedded languages: Provide core level support for conditional Set Global Variable (r:c017c24b/FSCORE-612) core: Windows: Add start parameter -monotonic-clock, replaces build flag WIN32_MONOTONIC (r:3515c7a0/FSCORE-643) core: Improve RTP timing on playback of files (r:d6d7773c/FSCORE-639) core: Allows bind_meta_app to use chars other than * (r:fd254766/FSCORE-630) @@ -156,7 +155,19 @@ freeswitch (1.0.7) core: normalize tests for outbound channels to use switch_channel_direction instead of testing for CF_OUTBOUND (r:93cc3dc5) core: add CF_DIALPLAN (r:3ff07445) core: tweak on calle[re] id (r:9db4a826) + core: cid logic changes for calle[re] (r:8f452bc5) + core: change switch_strip_spaces to specify if you want it to dup the string or destroy the current buffer (r:4d7e4f1e) + core: fix secondary issue with min_digits = 0 and terminator key pressed to cancel (r:fe005bdd/FS-2789) + core: fix dtmf issue with jb on (r:90e58696) + core: fix ignore_early_media=ring_ready (r:5b752c54) + core: prevent race on execute_on_answer called from the B-leg of a call (r:751e0291) + core: drop rtp frame that was already replaced with a cng frame (r:34a0ca50) + core: fix partial match counting as exact match in dmachine (r:5eb951aa) + core: try to adjust the timer to be ok with the horrible 10000 microsecond kernel resolution on amazon ec3 but that doesn't mean it's not horribly wrong to run the kernel that slow (r:903b2901) + embedded languages: Provide core level support for conditional Set Global Variable (r:c017c24b/FSCORE-612) + embedded languages: add insertFile front end to switch_ivr_insert_file and reswig (r:c4e350ab) lang: Improve French phrase files (FSCONFIG-23) + lang: Update langs - Add pt_PT, update es to have es_ES and es_MX, update mod_say_es and add mod_say_pt (FS-2937) (r:c81a9448/FS-2937) libapr: Fix issue where after a bridge with a member, uuid of Agent is set to single quote character ' (r:3fee704d/FS-2738) libdingaling: fix race on shutdown causing crash (FSMOD-47) libdingaling: Fix crash in new GV interface when exceeding 24 calls (r:be00609a/FS-2171) @@ -176,9 +187,11 @@ freeswitch (1.0.7) libesl: allow fs_cli -x to have args up to 1024 chars (was 256) (r:7039ba47) libesl: Make last_event pointer last longer (r:a15f51d5/ESL-37) libesl: use a packet buffer for ESL (r:2081bf97) + libesl: Noevent/Noevents disparity (r:d29d83d7/ESL-53) libfreetdm: implemented freetdm config nodes and ss7 initial configuration libfreetdm: fix codec for CAS signaling (r:b76e7f18) libfreetdm: freetdm: ss7- added support for incoming group blocks, started adding support for ansi (r:c219a73c) + libg7221: A bunch of tweaks to the G.722.1 codec (r:5d548570) libgnutls: link to libgcrypt as well, please report any platforms this breaks, but it should be portable (r:c569fb0f/FS-1248) libopenzap: Add CLI tracing libs: Merged OpenZAP and FreeTDM into the FreeSWITCH tree. @@ -216,6 +229,8 @@ freeswitch (1.0.7) mod_callcenter: Fix bad return type so it compile on archlinux, thx bougyman (r:3a475986) mod_callcenter: Make callcenter_config agent get return the value of the item requested. Also added queue param max-wait-time-with-no-agent-time-reached: If the max-wai-time-with-no-agent is already reached for the queue, then new caller can wait for x amount of second before it kicked out of the queue rather than get rejected automatically. (r:81a03869) mod_callcenter: Add new event socket agent-offering. Plus some documentation and better handling of bad agent type -- FS-2869 (r:80174cf3/FS-2869) + mod_cdr_sqlite: initial commit (r:f625fe3b) + mod_cdr_sqlite: config file for mod_cdr_sqlite (r:25bc8fe3) mod_cidlookup: null xml is bad (r:095815f8) mod_cid_lookup: honor skipcitystate when using whitepages (r:a66654de/FSMOD-53) mod_commands: make break uuid_break and add cascade flag @@ -235,6 +250,8 @@ freeswitch (1.0.7) mod_commands: FS-2210 Add support for auto completion for uuid_simplify (r:72bcc01b/FS-2210) mod_commands: allow epoch in strftime_tz (r:bbf1cd1f) mod_commands: Dramatic jitterbuffer changes (r:d5470961) + mod_commands: add uuid_buglist to fetch the current media-bugs attached to a given session uuid (r:f6eab64c) + mod_commands: add recovery_refresh app and api and use it in mod_conference to send a message to the channel telling it to sync its recovery snapshot (r:650393fb) mod_conference: Fix reporting of volume up/down (MODAPP-419) mod_conference: add last talking time per member to conference xml list mod_conference: add terminate-on-silence conference param @@ -245,6 +262,9 @@ freeswitch (1.0.7) mod_conference: refactor conference to use switch_ivr_dmachine for the digit parsing controls are now bound to each member separately based on conference_controls channel var, then the caller-controls param in the profile or a default to "default" (r:ac19f73c) mod_conference: Fix crash on dtmf action (r:4d5389bd/FS-2781) mod_conference: revert to the last transfered conference on recover (r:d11c83b1) + mod_conference: Add a chan var conference_enter_sound to override conference enter-sound param on the profile (r:651acc62) + mod_conference: Add an unique id to the conference obj so that we can track conferences. (r:479f3de2) + mod_conference: Fix corrupted audio when playing "you are now (un)muted..." (r:10257c7d/FS-2768) mod_curl: use method=post when post requested (r:c6a4ddd0/FSMOD-69) mod_db: fix stack corruption (MODAPP-407) mod_dialplan_xml: Add in the INFO log the caller id number when processing a request (Currenly only show the caller name) (r:e1df5e13) @@ -280,6 +300,7 @@ freeswitch (1.0.7) mod_fifo: fix fifo race in use count dec (r:402e383b) mod_fifo: add outbound_ring_timeout param to mod_fifo (r:3885eea7) mod_fifo: add default_lag to fifo (r:dd4fb5be) + mod_fifo: Fix crash when using fifo_destroy_after_use (r:ee562c82/FS-2879) mod_freetdm: Fix for TON and NPI not passed through to channel variables on incoming calls mod_freetdm: add pvt data to freetdm channels fix fxs features (r:9d456900) mod_freetdm: export and import boost custom data (r:edb2d582) @@ -357,6 +378,7 @@ freeswitch (1.0.7) mod_lua: Add switch_core_sqldb functionality from inside Lua script (r:26f2e095/FS-1384) mod_lua: Made 2nd arg to freeswitch.Dbh:query (cb func) optional (r:87db11af) mod_lua: Added SAF_ROUTING_EXEC flag to lua app, so it can be run inline (r:7d5ca1c0) + mod_lua: spelling error in -ERR return code encounterd -> encountered (r:86e7cdc5/FS-2949) mod_managed: Added wrapper for switch_event_bind for .net (r:a5f07a80/MODLANG-165) mod_managed: add additional support (r:5be58aac) mod_managed: add mono 2.8 patch file see FS-2774 (r:6a948bd9/FS-2774) @@ -417,6 +439,7 @@ freeswitch (1.0.7) mod_skypopen: making XEvents to works when EARLYMEDIA, and correctly manage threads death mod_skypopen: now answer a call only when directed to do it (before was trying to answer any incoming call). Lot of changes to a messy part, so maybe some problem will come out... (r:45c6c4d3) mod_skypopen: ignore early media sent by channels to be bridged before our channel is answered (r:ef14b78a) + mod_snapshot: fix bad codepaths in mod_snapshot (r:844ac220) mod_sndfile: Add support for .alaw and .ulaw to mod_sndfile (r:facf09b8/MODFORM-41) mod_sndfile: return break in mod_sndfile when seek returns failure (r:564dc7e4) mod_sofia: Send SIP MESSAGE to unregistered users by prefixing sip: to user@domain @@ -521,6 +544,10 @@ freeswitch (1.0.7) mod_sofia: remove check for va_list completely in sofia since i don't even think it happens ever (r:dfecc914) mod_sofia: have mod_sofia always elect to be the session refresher so we know it will work, also make the session-expires set to 0 imply 100% disabled session timers (r:321013ef) mod_sofia: Do not set nat mode when the device's network_ip is within the acl also so if your FS is behind nat and your phone is too then it will still make the right decisions (r:6c6eab8c) + mod_sofia: prevent race on codec change mid-call (r:668763f4) + mod_sofia: improve fail2ban logging (r:f4d52d4c/FS-2943) + mod_sofia: refactor sofia_contact to try the profile_name first then the domain to resolve the profile then fall back to querying every profile to reduce confusion with multi-homers (d'oh) also special profile name * will force a search-all situation (r:81608da0) + mod_sofia: support allowing pidf-ful presence clients to share the same account and 'appear offline' without influencing each other =/ also refactor the contact generation string based on nat into a helper function (r:97a68c50) mod_spandsp: initial checkin of mod_fax/mod_voipcodecs merge into mod_spandsp (r:fa9a59a8) mod_spandsp: rework of new mod_spandsp to have functions broken up into different c files (r:65400642) mod_spandsp: improve duplicate digit detection and add 'min_dup_digit_spacing_ms' channel variable for use with the dtmf detector (r:eab4f246/FSMOD-45) diff --git a/freeswitch.spec b/freeswitch.spec index ceacfbafb2..05401b8e8a 100644 --- a/freeswitch.spec +++ b/freeswitch.spec @@ -379,7 +379,7 @@ ENDPOINTS_MODULES="endpoints/mod_dingaling endpoints/mod_loopback ../../libs/fre # Event Handlers # ###################################################################################################################### -EVENT_HANDLERS_MODULES="event_handlers/mod_cdr_csv event_handlers/mod_event_socket event_handlers/mod_event_multicast" +EVENT_HANDLERS_MODULES="event_handlers/mod_cdr_csv event_handlers/mod_cdr_sqlite event_handlers/mod_event_socket event_handlers/mod_event_multicast" ###################################################################################################################### # # File and Audio Format Handlers @@ -620,6 +620,7 @@ fi %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/callcenter.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_csv.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_pg_csv.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_sqlite.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cidlookup.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/conference.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/console.conf.xml @@ -746,6 +747,7 @@ fi %{prefix}/mod/mod_bv.so* %{prefix}/mod/mod_callcenter.so* %{prefix}/mod/mod_cdr_csv.so* +%{prefix}/mod/mod_cdr_sqlite.so* %{prefix}/mod/mod_celt.so* %{prefix}/mod/mod_cidlookup.so* %{prefix}/mod/mod_cluechoo.so* diff --git a/libs/esl/lua/esl_lua.2008.sln b/libs/esl/lua/esl_lua.2008.sln new file mode 100644 index 0000000000..cdfbd44ab7 --- /dev/null +++ b/libs/esl/lua/esl_lua.2008.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ESL", "esl_lua.2008.vcproj", "{86B6AB99-A261-455A-9CD6-9142A5A1652E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|Win32.ActiveCfg = Debug|Win32 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|Win32.Build.0 = Debug|Win32 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|x64.ActiveCfg = Debug|x64 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Debug|x64.Build.0 = Debug|x64 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|Win32.ActiveCfg = Release|Win32 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|Win32.Build.0 = Release|Win32 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|x64.ActiveCfg = Release|x64 + {86B6AB99-A261-455A-9CD6-9142A5A1652E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/esl/lua/esl_lua.2008.vcproj b/libs/esl/lua/esl_lua.2008.vcproj new file mode 100644 index 0000000000..38111c8580 --- /dev/null +++ b/libs/esl/lua/esl_lua.2008.vcproj @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/esl/perl/ESL/Dispatch.pm b/libs/esl/perl/ESL/Dispatch.pm index 1d21934046..d1712d1cfc 100644 --- a/libs/esl/perl/ESL/Dispatch.pm +++ b/libs/esl/perl/ESL/Dispatch.pm @@ -40,7 +40,8 @@ sub set_callback($;$$) { $self->{_callback}->{$event} = shift; my $subclass = shift; if($subclass) { - $self->{_custom_subclass} = split(/,/, $subclass); + my @subclasses = split(/,/, $subclass); + $self->{_custom_subclass} = \@subclasses; } } @@ -79,7 +80,7 @@ sub run($;) { for(;;) { # Only register for events we have callbacks for. for my $key ( keys %{$self->{_callback}} ) { - if ($key eq "CUSTOM") { + if ($key =~ m/custom/i) { foreach $subclass (@{$self->{_custom_subclass}}) { $self->{_esl}->events("plain", "$key $subclass"); } diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index efd52542a6..21354c4442 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -733,11 +733,28 @@ static void ftdm_span_add(ftdm_span_t *span) FT_DECLARE(ftdm_status_t) ftdm_span_stop(ftdm_span_t *span) { - ftdm_status_t status = FTDM_FAIL; - if (span->stop) { - status = span->stop(span); - span->stop = NULL; + ftdm_status_t status = FTDM_SUCCESS; + + ftdm_mutex_lock(span->mutex); + + if (!ftdm_test_flag(span, FTDM_SPAN_STARTED)) { + status = FTDM_EINVAL; + goto done; } + + if (!span->stop) { + status = FTDM_ENOSYS; + goto done; + } + + status = span->stop(span); + if (FTDM_SUCCESS == status) { + ftdm_clear_flag(span, FTDM_SPAN_STARTED); + } + +done: + ftdm_mutex_unlock(span->mutex); + return status; } @@ -5063,11 +5080,28 @@ FT_DECLARE(ftdm_status_t) ftdm_configure_span_signaling(ftdm_span_t *span, const FT_DECLARE(ftdm_status_t) ftdm_span_start(ftdm_span_t *span) { - if (span->start) { - return span->start(span); + ftdm_status_t status = FTDM_FAIL; + + ftdm_mutex_lock(span->mutex); + + if (ftdm_test_flag(span, FTDM_SPAN_STARTED)) { + status = FTDM_EINVAL; + goto done; } - return FTDM_FAIL; + if (!span->start) { + status = FTDM_ENOSYS; + goto done; + } + + status = span->start(span); + if (status == FTDM_SUCCESS) { + ftdm_set_flag_locked(span, FTDM_SPAN_STARTED); + } + +done: + ftdm_mutex_unlock(span->mutex); + return status; } FT_DECLARE(ftdm_status_t) ftdm_channel_add_to_group(const char* name, ftdm_channel_t* ftdmchan) diff --git a/libs/freetdm/src/include/private/ftdm_types.h b/libs/freetdm/src/include/private/ftdm_types.h index 2d683e3098..d79835733b 100644 --- a/libs/freetdm/src/include/private/ftdm_types.h +++ b/libs/freetdm/src/include/private/ftdm_types.h @@ -168,7 +168,7 @@ typedef enum { typedef enum { FTDM_SPAN_CONFIGURED = (1 << 0), - FTDM_SPAN_READY = (1 << 1), + FTDM_SPAN_STARTED = (1 << 1), FTDM_SPAN_STATE_CHANGE = (1 << 2), FTDM_SPAN_SUSPENDED = (1 << 3), FTDM_SPAN_IN_THREAD = (1 << 4), diff --git a/libs/iksemel/configure.ac b/libs/iksemel/configure.ac index f7687922c2..1b8af13683 100644 --- a/libs/iksemel/configure.ac +++ b/libs/iksemel/configure.ac @@ -84,7 +84,7 @@ AC_ARG_ENABLE(64, if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then if test "${enable_64}" = "yes"; then CFLAGS="$CFLAGS -m64" - CXXFLAGS="$CXXFLAGS -m64" + CXXFLAGS="$CXXFLAGS -m64 -lgpg-error" fi fi diff --git a/libs/libg722_1/Makefile.am b/libs/libg722_1/Makefile.am index f815fb8ddc..9d885335bb 100644 --- a/libs/libg722_1/Makefile.am +++ b/libs/libg722_1/Makefile.am @@ -15,8 +15,6 @@ ## 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: Makefile.am,v 1.6 2008/09/30 14:06:39 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) @@ -26,6 +24,7 @@ noinst_SCRIPTS = g722_1.spec MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = autogen.sh \ + g722_1.pc \ g722_1.spec \ unpack_g722_1_data.sh \ wrapper.xsl \ @@ -50,6 +49,9 @@ SUBDIRS = src $(MAYBE_DOC) $(MAYBE_TESTS) DIST_SUBDIRS = src doc tests test-data +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = g722_1.pc + faq: faq.xml cd faq ; xsltproc ../wrapper.xsl ../faq.xml diff --git a/libs/libg722_1/autogen.sh b/libs/libg722_1/autogen.sh index 96422dbee3..98fb7e4f8a 100755 --- a/libs/libg722_1/autogen.sh +++ b/libs/libg722_1/autogen.sh @@ -16,11 +16,6 @@ # 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: autogen.sh,v 1.1.1.1 2008/09/20 09:47:17 steveu Exp $ -# - -UNAME=`uname` if [ "x$UNAME" = "xFreeBSD" ]; then echo "" diff --git a/libs/libg722_1/configure.ac b/libs/libg722_1/configure.ac index 64e276b280..62095ce374 100644 --- a/libs/libg722_1/configure.ac +++ b/libs/libg722_1/configure.ac @@ -15,17 +15,11 @@ # 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: configure.ac,v 1.9 2008/10/09 14:17:12 steveu Exp $ # @start 1 AC_INIT -CFLAGS="$CFLAGS $CONFIGURE_CFLAGS" -CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS" -LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS" - m4_include(config/ax_compiler_vendor.m4) m4_include(config/ax_check_real_file.m4) m4_include(config/ax_fixed_point_machine.m4) @@ -111,6 +105,22 @@ else CXXFLAGS=${CXXFLAGS-"-g -O2"} fi +AC_DEFUN([REMOVE_FROM_VAR],[ + new_val="" + removed=0 + for i in $$1; do + if test "x$i" != "x$2"; then + new_val="$new_val $i" + else + removed=1 + fi + done + if test $removed = "1"; then + echo " removed \"$2\" from $1" + $1=$new_val + fi +]) + AC_C_CONST AC_C_INLINE AC_C_VOLATILE @@ -190,7 +200,7 @@ AC_CHECK_HEADERS([audiofile.h]) AC_LANG([C]) -if test "${build}" = "${host}" +if test "${build}" == "${host}" then case "${host}" in x86_64-*) @@ -270,6 +280,7 @@ sun) COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS" fi COMP_VENDOR_LDFLAGS= + REMOVE_FROM_VAR(CFLAGS, -Xc) ;; *) COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes" @@ -293,20 +304,14 @@ AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes]) if test "$enable_fixed_point" = "yes" ; then AC_DEFINE([G722_1_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point]) G722_1_USE_FIXED_POINT="#define G722_1_USE_FIXED_POINT 1" - fixed = "yes" G722_1_VECTORS_FOR_TESTS="fixed" else AX_FIXED_POINT_MACHINE([$host], - [ - AC_DEFINE([G722_1_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point]) - G722_1_USE_FIXED_POINT="#define G722_1_USE_FIXED_POINT 1" - fixed = "yes" - ], + [AC_DEFINE([G722_1_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point]) + G722_1_USE_FIXED_POINT="#define G722_1_USE_FIXED_POINT 1"], [G722_1_USE_FIXED_POINT="#undef G722_1_USE_FIXED_POINT"]) G722_1_VECTORS_FOR_TESTS="floating" fi -AM_CONDITIONAL([COND_FIXED], [test "$fixed" = "yes"]) - AX_MISALIGNED_ACCESS_FAILS([$host], [AC_DEFINE([G722_1_MISALIGNED_ACCESS_FAILS], [1], [Do not expect a misaligned memory access to work correctly]) G722_1_MISALIGNED_ACCESS_FAILS="#define G722_1_MISALIGNED_ACCESS_FAILS 1"], @@ -363,6 +368,7 @@ AC_CONFIG_FILES([Makefile src/Makefile src/g722_1.h tests/Makefile + g722_1.pc g722_1.spec]) AC_CONFIG_FILES([tests/regression_tests.sh], [chmod +x tests/regression_tests.sh]) diff --git a/libs/libg722_1/doc/Makefile.am b/libs/libg722_1/doc/Makefile.am index 4e58bbd8b8..a56809d00a 100644 --- a/libs/libg722_1/doc/Makefile.am +++ b/libs/libg722_1/doc/Makefile.am @@ -15,8 +15,6 @@ ## 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: Makefile.am,v 1.1.1.1 2008/09/20 09:47:17 steveu Exp $ MAINTAINERCLEANFILES = Makefile.in diff --git a/libs/libg722_1/g722_1.pc.in b/libs/libg722_1/g722_1.pc.in new file mode 100644 index 0000000000..0fc01fbc73 --- /dev/null +++ b/libs/libg722_1/g722_1.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: spandsp +Description: A library for the ITU G.722.1 and G.722.1C audio codecs. +Requires: +Version: @VERSION@ +Libs: -L${libdir} -lg722_1 -lm +Cflags: -I${includedir} diff --git a/libs/libg722_1/g722_1.spec.in b/libs/libg722_1/g722_1.spec.in index db1d06a686..0c2b26dbc3 100644 --- a/libs/libg722_1/g722_1.spec.in +++ b/libs/libg722_1/g722_1.spec.in @@ -47,14 +47,13 @@ rm -rf %{buildroot} %{_libdir}/libg722_1.so.* -%{_datadir}/libg722_1 - %files devel %defattr(-,root,root,-) %doc doc/api %{_includedir}/g722_1.h %{_includedir}/g722_1 %{_libdir}/libg722_1.so +%{_libdir}/pkgconfig/g722_1.pc %post -p /sbin/ldconfig diff --git a/libs/libg722_1/src/Makefile.am b/libs/libg722_1/src/Makefile.am index 1943658d91..8600e920b2 100644 --- a/libs/libg722_1/src/Makefile.am +++ b/libs/libg722_1/src/Makefile.am @@ -15,18 +15,19 @@ ## 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: Makefile.am,v 1.10 2008/10/16 15:46:12 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) MAINTAINERCLEANFILES = Makefile.in -EXTRA_DIST = g722_1/version.h.in \ +EXTRA_DIST = make_tables.c \ + g722_1/version.h.in \ libg722_1.dsp \ - libg722_1.sln \ - libg722_1.vcproj \ + libg722_1.2005.sln \ + libg722_1.2008.sln \ + libg722_1.2005.vcproj \ + libg722_1.2008.vcproj \ msvc/gettimeofday.c \ msvc/inttypes.h \ msvc/tgmath.h \ @@ -36,13 +37,16 @@ EXTRA_DIST = g722_1/version.h.in \ msvc/msvcproj.head \ msvc/msvcproj.foot \ msvc/vc8proj.head \ - msvc/vc8proj.foot + msvc/vc8proj.foot \ + msvc/vc9proj.head \ + msvc/vc9proj.foot INCLUDES = -I$(top_builddir) lib_LTLIBRARIES = libg722_1.la -libg722_1_la_SOURCES = bitstream.c \ +libg722_1_la_SOURCES = basop32.c \ + bitstream.c \ coef2sam.c \ common.c \ commonf.c \ @@ -55,11 +59,9 @@ libg722_1_la_SOURCES = bitstream.c \ encoderf.c \ huff_tab.c \ sam2coef.c \ - tables.c + tables.c \ + utilities.c -if COND_FIXED -libg722_1_la_SOURCES += basop32.c -endif libg722_1_la_LDFLAGS = -version-info @G722_1_LT_CURRENT@:@G722_1_LT_REVISION@:@G722_1_LT_AGE@ $(COMP_VENDOR_LDFLAGS) nobase_include_HEADERS = g722_1/g722_1.h \ @@ -76,10 +78,10 @@ noinst_HEADERS = basop32.h \ defs.h \ huff_tab.h \ sam2coef.h \ - tables.h + tables.h \ + utilities.h -noinst_PROGRAMS = make_dct4_tables \ - make_tables +noinst_PROGRAMS = make_dct4_tables dct4.$(OBJEXT): dct4.h @@ -88,6 +90,9 @@ dct4.lo: dct4.h dct4.h: make_dct4_tables$(EXEEXT) ./make_dct4_tables$(EXEEXT) >dct4.h +make_dct4_tables$(EXEEXT): $(top_srcdir)/src/make_dct4_tables.c + $(CC_FOR_BUILD) -o make_dct4_tables$(EXEEXT) $(top_srcdir)/src/make_dct4_tables.c -DHAVE_CONFIG_H -I$(top_builddir)/src -lm + #coef2sam.h: make_tables$(EXEEXT) # ./make_tables$(EXEEXT) coef2sam >coef2samx.h @@ -95,13 +100,15 @@ dct4.h: make_dct4_tables$(EXEEXT) # ./make_tables$(EXEEXT) sam2coef >sam2coefx.h DSP = libg722_1.dsp -VCPROJ = libg722_1.vcproj +VCPROJ8 = libg722_1.2005.vcproj +VCPROJ9 = libg722_1.2008.vcproj WIN32SOURCES = $(libg722_1_la_SOURCES) msvc/gettimeofday.c WIN32HEADERS = $(nobase_include_HEADERS) g722_1.h DSPOUT = | awk '{printf("%s\r\n", $$0)}' >> $(DSP) -VCPROJOUT = | awk '{printf("%s\r\n", $$0)}' >> $(VCPROJ) +VCPROJOUT8 = | awk '{printf("%s\r\n", $$0)}' >> $(VCPROJ8) +VCPROJOUT9 = | awk '{printf("%s\r\n", $$0)}' >> $(VCPROJ9) $(DSP): msvc/msvcproj.head msvc/msvcproj.foot Makefile.am echo "creating $(DSP)" @@ -124,26 +131,38 @@ $(DSP): msvc/msvcproj.head msvc/msvcproj.foot Makefile.am echo "# End Group" $(DSPOUT); \ cat $(srcdir)/msvc/msvcproj.foot $(DSPOUT) ) -$(VCPROJ): msvc/vc8proj.head msvc/vc8proj.foot Makefile.am - echo "creating $(VCPROJ)" - @(cp $(srcdir)/msvc/vc8proj.head $(VCPROJ); \ +$(VCPROJ8): msvc/vc8proj.head msvc/vc8proj.foot Makefile.am + echo "creating $(VCPROJ8)" + @(cp $(srcdir)/msvc/vc8proj.head $(VCPROJ8); \ for file in $(WIN32SOURCES); do \ - echo "" $(VCPROJOUT); \ + myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \ + echo "" $(VCPROJOUT8); \ done; \ - echo "" $(VCPROJOUT); \ + echo "" $(VCPROJOUT8); \ for file in $(WIN32HEADERS); do \ - echo "" $(VCPROJOUT); \ + myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \ + echo "" $(VCPROJOUT8); \ done; \ - cat $(srcdir)/msvc/vc8proj.foot $(VCPROJOUT) ) + cat $(srcdir)/msvc/vc8proj.foot $(VCPROJOUT8) ) + +$(VCPROJ9): msvc/vc9proj.head msvc/vc9proj.foot Makefile.am + echo "creating $(VCPROJ9)" + @(cp $(srcdir)/msvc/vc9proj.head $(VCPROJ9); \ + for file in $(WIN32SOURCES); do \ + myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \ + echo "" $(VCPROJOUT9); \ + done; \ + echo "" $(VCPROJOUT9); \ + for file in $(WIN32HEADERS); do \ + myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \ + echo "" $(VCPROJOUT9); \ + done; \ + cat $(srcdir)/msvc/vc9proj.foot $(VCPROJOUT9) ) + +dist-hook: g722_1/version.h g722_1/version.h: NOWDATE=`date --utc +"%Y%m%d"` ; \ NOWTIME=`date --utc +"%H%M%S"` ; \ sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \ - g722_1/version.h - -dist-hook: - NOWDATE=`date --utc +"%Y%m%d"` ; \ - NOWTIME=`date --utc +"%H%M%S"` ; \ - sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \ - g722_1/version.h + <$(srcdir)/g722_1/version.h.in >$@ diff --git a/libs/libg722_1/src/basop32.c b/libs/libg722_1/src/basop32.c index 54220f4fac..3a51f45eee 100644 --- a/libs/libg722_1/src/basop32.c +++ b/libs/libg722_1/src/basop32.c @@ -9,8 +9,6 @@ * 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. - * - * $Id: basop32.c,v 1.5 2008/09/22 13:08:31 steveu Exp $ */ /*! \file */ @@ -19,9 +17,10 @@ #include #endif +#include + #if defined(G722_1_USE_FIXED_POINT) -#include #include #include diff --git a/libs/libg722_1/src/basop32.h b/libs/libg722_1/src/basop32.h index abc105f35e..36dae35297 100644 --- a/libs/libg722_1/src/basop32.h +++ b/libs/libg722_1/src/basop32.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: basop32.h,v 1.3 2008/09/22 13:08:31 steveu Exp $ */ #if !defined(BASOP32_H_DEFINED) @@ -104,14 +102,14 @@ static __inline__ int32_t L_mac(int32_t L_var3, int16_t var1, int16_t var2) } /*- End of function --------------------------------------------------------*/ -int16_t shl(int16_t var1, int16_t var2); /* Short shift left, 1 */ -int16_t shr(int16_t var1, int16_t var2); /* Short shift right, 1 */ -int32_t L_sub(int32_t L_var1, int32_t L_var2); /* Long sub, 2 */ -int32_t L_shl(int32_t L_var1, int16_t var2); /* Long shift left, 2 */ -int32_t L_shr(int32_t L_var1, int16_t var2); /* Long shift right, 2*/ -int16_t norm_s(int16_t var1); /* Short norm, 15 */ -int16_t div_s(int16_t var1, int16_t var2); /* Short division, 18 */ -int16_t norm_l(int32_t L_var1); /* Long norm, 30 */ +int16_t shl(int16_t var1, int16_t var2); /* Short shift left, 1 */ +int16_t shr(int16_t var1, int16_t var2); /* Short shift right, 1 */ +int32_t L_sub(int32_t L_var1, int32_t L_var2); /* Long sub, 2 */ +int32_t L_shl(int32_t L_var1, int16_t var2); /* Long shift left, 2 */ +int32_t L_shr(int32_t L_var1, int16_t var2); /* Long shift right, 2 */ +int16_t norm_s(int16_t var1); /* Short norm, 15 */ +int16_t div_s(int16_t var1, int16_t var2); /* Short division, 18 */ +int16_t norm_l(int32_t L_var1); /* Long norm, 30 */ #endif diff --git a/libs/libg722_1/src/bitstream.c b/libs/libg722_1/src/bitstream.c index ddaabd0edf..016ab8ee45 100644 --- a/libs/libg722_1/src/bitstream.c +++ b/libs/libg722_1/src/bitstream.c @@ -8,8 +8,6 @@ * 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. - * - * $Id: bitstream.c,v 1.2 2008/10/17 13:18:21 steveu Exp $ */ /*! \file */ diff --git a/libs/libg722_1/src/bitstream.h b/libs/libg722_1/src/bitstream.h index 20e386513f..f2cc4b8bce 100644 --- a/libs/libg722_1/src/bitstream.h +++ b/libs/libg722_1/src/bitstream.h @@ -8,8 +8,6 @@ * 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. - * - * $Id: bitstream.h,v 1.2 2008/10/17 13:18:21 steveu Exp $ */ /*! \file */ diff --git a/libs/libg722_1/src/coef2sam.c b/libs/libg722_1/src/coef2sam.c index 38d4943ca8..19f5a211ac 100644 --- a/libs/libg722_1/src/coef2sam.c +++ b/libs/libg722_1/src/coef2sam.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: coef2sam.c,v 1.10 2008/10/02 11:43:54 steveu Exp $ */ /*! \file */ @@ -29,18 +27,16 @@ #include "defs.h" #include "coef2sam.h" +#include "utilities.h" -/************************************************************************************* +/* Convert Reversed MLT (Modulated Lapped Transform) Coefficients to Samples - Purpose: Convert Reversed MLT (Modulated Lapped Transform) Coefficients to Samples - - The "Reversed MLT" is an overlapped block transform which uses even symmetry - on the left, odd symmetry on the right and a Type IV DCT as the block transform. - It is thus similar to a MLT which uses odd symmetry on the left, even symmetry - on the right and a Type IV DST as the block transform. In fact, it is equivalent - to reversing the order of the samples, performing an MLT and then negating all - the even-numbered coefficients. -***************************************************************************/ + The "Reversed MLT" is an overlapped block transform which uses even symmetry + on the left, odd symmetry on the right and a Type IV DCT as the block transform. + It is thus similar to a MLT which uses odd symmetry on the left, even symmetry + on the right and a Type IV DST as the block transform. In fact, it is equivalent + to reversing the order of the samples, performing an MLT and then negating all + the even-numbered coefficients. */ #if defined(G722_1_USE_FIXED_POINT) void rmlt_coefs_to_samples(int16_t coefs[], @@ -73,29 +69,23 @@ void rmlt_coefs_to_samples(int16_t coefs[], new_samples[i] = shl(new_samples[i], mag_shift); } - if (dct_length == DCT_LENGTH) - win = rmlt_to_samples_window; - else - win = max_rmlt_to_samples_window; + win = (dct_length == DCT_LENGTH) ? rmlt_to_samples_window : max_rmlt_to_samples_window; last = half_dct_length - 1; for (i = 0; i < half_dct_length; i++) { /* Get the first half of the windowed samples */ - sum = 0L; - sum = L_mac(sum, win[i], new_samples[last - i]); + sum = L_mult(win[i], new_samples[last - i]); sum = L_mac(sum, win[dct_length - i - 1], old_samples[i]); out_samples[i] = xround(L_shl(sum, 2)); /* Get the second half of the windowed samples */ - sum = 0L; - sum = L_mac(sum, win[half_dct_length + i], new_samples[i]); + sum = L_mult(win[half_dct_length + i], new_samples[i]); sum = L_mac(sum, negate(win[last - i]), old_samples[last - i]); out_samples[half_dct_length + i] = xround(L_shl(sum, 2)); } /* Save the second half of the new samples for next time, when they will be the old samples. */ - for (i = 0; i < half_dct_length; i++) - old_samples[i] = new_samples[half_dct_length + i]; + vec_copyi16(old_samples, &new_samples[half_dct_length], half_dct_length); } /*- End of function --------------------------------------------------------*/ #else @@ -116,10 +106,7 @@ void rmlt_coefs_to_samples(float coefs[], /* Perform a Type IV (inverse) DCT on the coefficients */ dct_type_iv(coefs, new_samples, dct_length); - if (dct_length == DCT_LENGTH) - win = rmlt_to_samples_window; - else - win = max_rmlt_to_samples_window; + win = (dct_length == DCT_LENGTH) ? rmlt_to_samples_window : max_rmlt_to_samples_window; last = half_dct_length - 1; for (i = 0; i < half_dct_length; i++) { @@ -135,8 +122,7 @@ void rmlt_coefs_to_samples(float coefs[], /* Save the second half of the new samples for next time, when they will be the old samples. */ - for (i = 0; i < half_dct_length; i++) - old_samples[i] = new_samples[half_dct_length + i]; + vec_copyf(old_samples, &new_samples[half_dct_length], half_dct_length); } /*- End of function --------------------------------------------------------*/ #endif diff --git a/libs/libg722_1/src/coef2sam.h b/libs/libg722_1/src/coef2sam.h index 731d28ddeb..21590761ea 100644 --- a/libs/libg722_1/src/coef2sam.h +++ b/libs/libg722_1/src/coef2sam.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: coef2sam.h,v 1.2 2008/10/02 11:43:54 steveu Exp $ */ #if defined(G722_1_USE_FIXED_POINT) diff --git a/libs/libg722_1/src/common.c b/libs/libg722_1/src/common.c index 46f6595054..b763a8465d 100644 --- a/libs/libg722_1/src/common.c +++ b/libs/libg722_1/src/common.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: common.c,v 1.6 2008/09/30 14:06:39 steveu Exp $ */ /*! \file */ @@ -38,41 +36,7 @@ static void compute_raw_pow_categories(int16_t *power_categories, int16_t number_of_regions, int16_t offset); -/**************************************************************************************** - Function: categorize - - Syntax: void categorize(int16_t number_of_available_bits, - int16_t number_of_regions, - int16_t num_categorization_control_possibilities, - int16_t rms_index, - int16_t power_categories, - int16_t category_balances) - - inputs: number_of_regions - num_categorization_control_possibilities - number_of_available_bits - rms_index[MAX_NUMBER_OF_REGIONS] - - outputs: power_categories[MAX_NUMBER_OF_REGIONS] - category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES-1] - - Description: Computes a series of categorizations - - WMOPS: 7kHz | 24kbit | 32kbit - -------|--------------|---------------- - AVG | 0.14 | 0.14 - -------|--------------|---------------- - MAX | 0.15 | 0.15 - -------|--------------|---------------- - - 14kHz | 24kbit | 32kbit | 48kbit - -------|--------------|----------------|---------------- - AVG | 0.42 | 0.45 | 0.48 - -------|--------------|----------------|---------------- - MAX | 0.47 | 0.52 | 0.52 - -------|--------------|----------------|---------------- - -****************************************************************************************/ +/* Compute a series of categorizations */ void categorize(int16_t number_of_available_bits, int16_t number_of_regions, int16_t num_categorization_control_possibilities, @@ -88,10 +52,7 @@ void categorize(int16_t number_of_available_bits, /* At higher bit rates, there is an increase for most categories in average bit consumption per region. We compensate for this by pretending we have fewer available bits. */ - if (number_of_regions == NUMBER_OF_REGIONS) - frame_size = DCT_LENGTH; - else - frame_size = MAX_DCT_LENGTH; + frame_size = (number_of_regions == NUMBER_OF_REGIONS) ? DCT_LENGTH : MAX_DCT_LENGTH; temp = sub(number_of_available_bits, frame_size); if (temp > 0) @@ -114,45 +75,7 @@ void categorize(int16_t number_of_available_bits, } /*- End of function --------------------------------------------------------*/ -/*************************************************************************** - Function: comp_powercat_and_catbalance - - Syntax: void comp_powercat_and_catbalance(int16_t *power_categories, - int16_t *category_balances, - int16_t *rms_index, - int16_t number_of_available_bits, - int16_t number_of_regions, - int16_t num_categorization_control_possibilities, - int16_t offset) - - - inputs: *rms_index - number_of_available_bits - number_of_regions - num_categorization_control_possibilities - offset - - outputs: *power_categories - *category_balances - - - Description: Computes the power_categories and the category balances - - WMOPS: 7kHz | 24kbit | 32kbit - -------|--------------|---------------- - AVG | 0.10 | 0.10 - -------|--------------|---------------- - MAX | 0.11 | 0.11 - -------|--------------|---------------- - - 14kHz | 24kbit | 32kbit | 48kbit - -------|--------------|----------------|---------------- - AVG | 0.32 | 0.35 | 0.38 - -------|--------------|----------------|---------------- - MAX | 0.38 | 0.42 | 0.43 - -------|--------------|----------------|---------------- - -***************************************************************************/ +/* Compute the power_categories and the category balances */ void comp_powercat_and_catbalance(int16_t *power_categories, int16_t *category_balances, int16_t *rms_index, @@ -161,7 +84,6 @@ void comp_powercat_and_catbalance(int16_t *power_categories, int16_t num_categorization_control_possibilities, int16_t offset) { - int16_t expected_number_of_code_bits; int16_t region; int16_t max_region; @@ -190,7 +112,6 @@ void comp_powercat_and_catbalance(int16_t *power_categories, for (region = 0; region < number_of_regions; region++) expected_number_of_code_bits = add(expected_number_of_code_bits, expected_bits_table[power_categories[region]]); - for (region = 0; region < number_of_regions; region++) { max_rate_categories[region] = power_categories[region]; @@ -277,42 +198,16 @@ void comp_powercat_and_catbalance(int16_t *power_categories, } /*- End of function --------------------------------------------------------*/ -/*************************************************************************** - Function: calc_offset - - Syntax: offset=calc_offset(int16_t *rms_index,int16_t number_of_regions,int16_t available_bits) - - input: int16_t *rms_index - int16_t number_of_regions - int16_t available_bits - - output: int16_t offset - - Description: Calculates the the category offset. This is the shift required - To get the most out of the number of available bits. A binary - type search is used to find the offset. - - WMOPS: 7kHz | 24kbit | 32kbit - -------|--------------|---------------- - AVG | 0.04 | 0.04 - -------|--------------|---------------- - MAX | 0.04 | 0.04 - -------|--------------|---------------- - - 14kHz | 24kbit | 32kbit | 48kbit - -------|--------------|----------------|---------------- - AVG | 0.08 | 0.08 | 0.08 - -------|--------------|----------------|---------------- - MAX | 0.09 | 0.09 | 0.09 - -------|--------------|----------------|---------------- - -***************************************************************************/ -int16_t calc_offset(int16_t *rms_index,int16_t number_of_regions,int16_t available_bits) +/* Calculate the the category offset. This is the shift required + To get the most out of the number of available bits. A binary + type search is used to find the offset. */ +int16_t calc_offset(int16_t *rms_index, int16_t number_of_regions, int16_t available_bits) { int16_t answer; int16_t delta; int16_t test_offset; - int16_t region,j; + int16_t region; + int16_t j; int16_t power_cats[MAX_NUMBER_OF_REGIONS]; int16_t bits; int16_t offset; @@ -360,40 +255,9 @@ int16_t calc_offset(int16_t *rms_index,int16_t number_of_regions,int16_t availab } /*- End of function --------------------------------------------------------*/ -/*************************************************************************** - Function: compute_raw_pow_categories - - Syntax: void compute_raw_pow_categories(int16_t *power_categories, - int16_t *rms_index, - int16_t number_of_regions, - int16_t offset) - inputs: *rms_index - number_of_regions - offset - - outputs: *power_categories - - - - Description: This function computes the power categories given the offset - This is kind of redundant since they were already computed - in calc_offset to determine the offset. - - WMOPS: | 24kbit | 32kbit - -------|--------------|---------------- - AVG | 0.01 | 0.01 - -------|--------------|---------------- - MAX | 0.01 | 0.01 - -------|--------------|---------------- - - 14kHz | 24kbit | 32kbit | 48kbit - -------|--------------|----------------|---------------- - AVG | 0.01 | 0.01 | 0.01 - -------|--------------|----------------|---------------- - MAX | 0.01 | 0.01 | 0.01 - -------|--------------|----------------|---------------- - -***************************************************************************/ +/* Compute the power categories given the offset + This is kind of redundant since they were already computed + in calc_offset to determine the offset. */ static void compute_raw_pow_categories(int16_t *power_categories, int16_t *rms_index, int16_t number_of_regions, int16_t offset) { int16_t region; diff --git a/libs/libg722_1/src/commonf.c b/libs/libg722_1/src/commonf.c index dd2050aa1b..d86d1cf3ae 100644 --- a/libs/libg722_1/src/commonf.c +++ b/libs/libg722_1/src/commonf.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: commonf.c,v 1.11 2008/09/30 14:06:39 steveu Exp $ */ /*! \file */ @@ -34,9 +32,7 @@ #if !defined(G722_1_USE_FIXED_POINT) -/**************************************************************************************** - Description: Computes a series of categorizations -****************************************************************************************/ +/* Compute a series of categorizations */ void categorize(int number_of_regions, int number_of_available_bits, int rms_index[MAX_NUMBER_OF_REGIONS], diff --git a/libs/libg722_1/src/dct4.c b/libs/libg722_1/src/dct4.c index cb3a7fde03..9f0a61d6f6 100644 --- a/libs/libg722_1/src/dct4.c +++ b/libs/libg722_1/src/dct4.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C)2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: dct4.c,v 1.8 2008/09/29 16:09:26 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -29,6 +27,7 @@ #include "g722_1/g722_1.h" #include "defs.h" +#include "utilities.h" #if !defined(G722_1_USE_FIXED_POINT) @@ -52,9 +51,7 @@ static const cos_msin_t *cos_msin_table[] = cos_msin_640 }; -/********************************************************************************* - Description: Discrete Cosine Transform, Type IV -*********************************************************************************/ +/* Discrete Cosine Transform, Type IV */ void dct_type_iv(float input[], float output[], int dct_length) { float buffer_a[MAX_DCT_LENGTH]; @@ -64,22 +61,20 @@ void dct_type_iv(float input[], float output[], int dct_length) float *in_ptr_low; float *in_ptr_high; float *next_in_base; - float *out_ptr_low; - float *out_ptr_high; + float *out_ptr; float *next_out_base; float *out_buffer; float *in_buffer; float *buffer_swap; float *fptr0; - const float *fptr2; - const float *core_a; float in_val_low; float in_val_high; float cos_even; float cos_odd; float msin_even; float msin_odd; - float sum; + const float *fptr2; + const float *core_a; const cos_msin_t **table_ptr_ptr; const cos_msin_t *cos_msin_ptr; int set_span; @@ -120,29 +115,24 @@ void dct_type_iv(float input[], float output[], int dct_length) for (sets_left = set_count; sets_left > 0; sets_left--) { /* Set up output pointers for the current set */ - out_ptr_low = next_out_base; + out_ptr = next_out_base; next_out_base += set_span; - out_ptr_high = next_out_base; /* Loop over all the butterflies in the current set */ - do + for (i = 0; i < (set_span >> 1); i++) { in_val_low = *in_ptr++; in_val_high = *in_ptr++; - *out_ptr_low++ = in_val_low + in_val_high; - *--out_ptr_high = in_val_low - in_val_high; + out_ptr[i] = in_val_low + in_val_high; + out_ptr[set_span - 1 - i] = in_val_low - in_val_high; } - while (out_ptr_low < out_ptr_high); } /* Decide which buffers to use as input and output next time. Except for the first time (when the input buffer is the subroutine input) we just alternate the local buffers. */ in_buffer = out_buffer; - if (out_buffer == buffer_a) - out_buffer = buffer_b; - else - out_buffer = buffer_a; + out_buffer = (out_buffer == buffer_a) ? buffer_b : buffer_a; } /* Do dct_size/10 ten-point transforms */ @@ -153,11 +143,8 @@ void dct_type_iv(float input[], float output[], int dct_length) fptr2 = core_a; for (k = 0; k < CORE_SIZE; k++) { - sum = 0; - for (i = 0; i < CORE_SIZE; i++) - sum += fptr0[i]*fptr2[i]; + buffer_swap[k] = vec_dot_prodf(fptr0, fptr2, CORE_SIZE); fptr2 += CORE_SIZE; - buffer_swap[k] = sum; } fptr0 += CORE_SIZE; buffer_swap += CORE_SIZE; @@ -172,14 +159,10 @@ void dct_type_iv(float input[], float output[], int dct_length) { /* Initialization for the loop over sets at the current size */ set_span = dct_length >> set_count_log; - set_count = 1 << set_count_log; next_in_base = in_buffer; - if (set_count_log == 0) - next_out_base = output; - else - next_out_base = out_buffer; - ++table_ptr_ptr; + next_out_base = (set_count_log == 0) ? output : out_buffer; + table_ptr_ptr++; /* Loop over all the sets of this size */ for (sets_left = set_count; sets_left > 0; sets_left--) @@ -187,26 +170,23 @@ void dct_type_iv(float input[], float output[], int dct_length) /* Set up the pointers for the current set */ in_ptr_low = next_in_base; in_ptr_high = in_ptr_low + (set_span >> 1); - next_in_base += set_span; - out_ptr_low = next_out_base; - next_out_base += set_span; - out_ptr_high = next_out_base; + out_ptr = next_out_base; cos_msin_ptr = *table_ptr_ptr; /* Loop over all the butterfly pairs in the current set */ - do + for (i = 0; i < (set_span >> 1); i += 2) { - cos_even = (*cos_msin_ptr).cosine; - msin_even = (*cos_msin_ptr++).minus_sine; - *out_ptr_low++ = cos_even * *in_ptr_low - msin_even * *in_ptr_high; - *--out_ptr_high = msin_even * *in_ptr_low++ + cos_even * *in_ptr_high++; - - cos_odd = (*cos_msin_ptr).cosine; - msin_odd = (*cos_msin_ptr++).minus_sine; - *out_ptr_low++ = cos_odd * *in_ptr_low + msin_odd * *in_ptr_high; - *--out_ptr_high = msin_odd * *in_ptr_low++ - cos_odd * *in_ptr_high++; + cos_even = cos_msin_ptr[i].cosine; + msin_even = cos_msin_ptr[i].minus_sine; + cos_odd = cos_msin_ptr[i + 1].cosine; + msin_odd = cos_msin_ptr[i + 1].minus_sine; + out_ptr[i] = cos_even*in_ptr_low[i] - msin_even*in_ptr_high[i]; + out_ptr[set_span - 1 - i] = msin_even*in_ptr_low[i] + cos_even*in_ptr_high[i]; + out_ptr[i + 1] = cos_odd*in_ptr_low[i + 1] + msin_odd*in_ptr_high[i + 1]; + out_ptr[set_span - 2 - i] = msin_odd*in_ptr_low[i + 1] - cos_odd*in_ptr_high[i + 1]; } - while (out_ptr_low < out_ptr_high); + next_in_base += set_span; + next_out_base += set_span; } /* Swap input and output buffers for next time */ diff --git a/libs/libg722_1/src/dct4_a.c b/libs/libg722_1/src/dct4_a.c index 0f9c90eba0..d4ed1504e1 100644 --- a/libs/libg722_1/src/dct4_a.c +++ b/libs/libg722_1/src/dct4_a.c @@ -6,29 +6,23 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: dct4_a.c,v 1.8 2008/09/30 14:06:39 steveu Exp $ */ -/********************************************************************************* -* Filename: dct_type_iv_a.c -* -* Purpose: Discrete Cosine Transform, Type IV used for MLT -* -* The basis functions are -* -* cos(PI*(t+0.5)*(k+0.5)/block_length) -* -* for time t and basis function number k. Due to the symmetry of the expression -* in t and k, it is clear that the forward and inverse transforms are the same. -* -*********************************************************************************/ +/* Discrete Cosine Transform, Type IV used for MLT + + The basis functions are + + cos(PI*(t+0.5)*(k+0.5)/block_length) + + for time t and basis function number k. Due to the symmetry of the + expression in t and k, it is clear that the forward and inverse transforms + are the same. */ /*! \file */ @@ -47,51 +41,31 @@ #include "dct4_a.h" -/********************************************************************************* - Function: dct_type_iv_a - - Syntax: void dct_type_iv_a (input, output, dct_length) - int16_t input[], output[], dct_length; - - Description: Discrete Cosine Transform, Type IV used for MLT -*********************************************************************************/ - +/* Discrete Cosine Transform, Type IV used for MLT */ void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length) { int16_t buffer_a[MAX_DCT_LENGTH]; int16_t buffer_b[MAX_DCT_LENGTH]; int16_t buffer_c[MAX_DCT_LENGTH]; int16_t *in_ptr; - int16_t *in_ptr_low; - int16_t *in_ptr_high; - int16_t *next_in_base; - int16_t *out_ptr_low; - int16_t *out_ptr_high; - int16_t *next_out_base; - int16_t *out_buffer; + int16_t *out_ptr; int16_t *in_buffer; + int16_t *out_buffer; int16_t *buffer_swap; int16_t in_val_low; int16_t in_val_high; - int16_t out_val_low; - int16_t out_val_high; int16_t in_low_even; int16_t in_low_odd; int16_t in_high_even; int16_t in_high_odd; - int16_t out_low_even; - int16_t out_low_odd; - int16_t out_high_even; - int16_t out_high_odd; int16_t *pair_ptr; int16_t cos_even; int16_t cos_odd; int16_t msin_even; int16_t msin_odd; - int16_t neg_cos_odd; - int16_t neg_msin_even; int32_t sum; int16_t set_span; + int16_t half_span; int16_t set_count; int16_t set_count_log; int16_t pairs_left; @@ -99,15 +73,15 @@ void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length) int16_t i; int16_t k; int16_t index; - const cos_msin_t **table_ptr_ptr; - const cos_msin_t *cos_msin_ptr; int16_t temp; int32_t acca; int16_t dct_length_log; + const cos_msin_t **table_ptr_ptr; + const cos_msin_t *cos_msin_ptr; - /* Do the sum/difference butterflies, the first part of */ - /* converting one N-point transform into N/2 two-point */ - /* transforms, where N = 1 << DCT_LENGTH_LOG. = 64/128 */ + /* Do the sum/difference butterflies, the first part of + converting one N-point transform into N/2 two-point + transforms, where N = 1 << DCT_LENGTH_LOG. = 64/128 */ if (dct_length == DCT_LENGTH) { dct_length_log = DCT_LENGTH_LOG; @@ -123,62 +97,45 @@ void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length) index = 0L; in_buffer = input; out_buffer = buffer_a; - temp = sub(dct_length_log, 2); + temp = dct_length_log - 2; for (set_count_log = 0; set_count_log <= temp; set_count_log++) { - /* Initialization for the loop over sets at the current size */ - /* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ - set_span = shr(dct_length, set_count_log); - - set_count = shl(1, set_count_log); + /* Loop over all the sets at the current size */ + set_span = dct_length >> set_count_log; + set_count = 1 << set_count_log; + half_span = set_span >> 1; in_ptr = in_buffer; - next_out_base = out_buffer; + out_ptr = out_buffer; - /* Loop over all the sets of this size */ for (sets_left = set_count; sets_left > 0; sets_left--) { - /* Set up output pointers for the current set */ - out_ptr_low = next_out_base; - next_out_base = next_out_base + set_span; - out_ptr_high = next_out_base; - /* Loop over all the butterflies in the current set */ - do + for (i = 0; i < half_span; i++) { - in_val_low = *in_ptr++; - in_val_high = *in_ptr++; - acca = L_add(in_val_low, in_val_high); - acca = L_shr(acca, 1); - out_val_low = (int16_t) acca; + in_val_low = *in_ptr++; + in_val_high = *in_ptr++; - acca = L_sub(in_val_low, in_val_high); - acca = L_shr(acca, 1); - out_val_high = (int16_t) acca; + acca = L_add(in_val_low, in_val_high); + out_ptr[i] = (int16_t) L_shr(acca, 1); - *out_ptr_low++ = out_val_low; - *--out_ptr_high = out_val_high; + acca = L_sub(in_val_low, in_val_high); + out_ptr[set_span - 1 - i] = (int16_t) L_shr(acca, 1); } - while (out_ptr_low < out_ptr_high); + out_ptr += set_span; } - /* Decide which buffers to use as input and output next time. */ - /* Except for the first time (when the input buffer is the */ - /* subroutine input) we just alternate the local buffers. */ + /* Decide which buffers to use as input and output next time. + Except for the first time (when the input buffer is the + subroutine input) we just alternate the local buffers. */ in_buffer = out_buffer; - if (out_buffer == buffer_a) - out_buffer = buffer_b; - else - out_buffer = buffer_a; + out_buffer = (out_buffer == buffer_a) ? buffer_b : buffer_a; index = add(index, 1); } - /* Do N/2 two-point transforms, */ - /* where N = 1 << DCT_LENGTH_LOG */ + /* Do N/2 two-point transforms, where N = 1 << DCT_LENGTH_LOG */ pair_ptr = in_buffer; buffer_swap = buffer_c; - temp = sub(dct_length_log, 1); - temp = shl(1, temp); - + temp = 1 << (dct_length_log - 1); for (pairs_left = temp; pairs_left > 0; pairs_left--) { for (k = 0; k < CORE_SIZE; k++) @@ -188,7 +145,6 @@ void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length) sum = L_mac(sum, pair_ptr[i], dct_core_a[i][k]); buffer_swap[k] = xround(sum); } - /* Address arithmetic */ pair_ptr += CORE_SIZE; buffer_swap += CORE_SIZE; } @@ -202,77 +158,53 @@ void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length) temp = sub(dct_length_log, 2); for (set_count_log = temp; set_count_log >= 0; set_count_log--) { - /* Initialization for the loop over sets at the current size */ - /* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ - set_span = shr(dct_length, set_count_log); - set_count = shl(1, set_count_log); - next_in_base = in_buffer; - next_out_base = (set_count_log == 0) ? output : out_buffer; + /* Loop over all the sets at the current size */ + set_span = dct_length >> set_count_log; + set_count = 1 << set_count_log; + half_span = set_span >> 1; + in_ptr = in_buffer; + out_ptr = (set_count_log == 0) ? output : out_buffer; + cos_msin_ptr = *table_ptr_ptr++; - /* Loop over all the sets of this size */ for (sets_left = set_count; sets_left > 0; sets_left--) { - /* Set up the pointers for the current set */ - in_ptr_low = next_in_base; - temp = shr(set_span, 1); - - /* Address arithmetic */ - in_ptr_high = in_ptr_low + temp; - next_in_base += set_span; - out_ptr_low = next_out_base; - next_out_base += set_span; - out_ptr_high = next_out_base; - cos_msin_ptr = *table_ptr_ptr; - /* Loop over all the butterfly pairs in the current set */ - do + for (i = 0; i < half_span; i += 2) { - /* Address arithmetic */ - in_low_even = *in_ptr_low++; - in_low_odd = *in_ptr_low++; - in_high_even = *in_ptr_high++; - in_high_odd = *in_ptr_high++; - cos_even = cos_msin_ptr[0].cosine; - msin_even = cos_msin_ptr[0].minus_sine; - cos_odd = cos_msin_ptr[1].cosine; - msin_odd = cos_msin_ptr[1].minus_sine; - cos_msin_ptr += 2; + in_low_even = in_ptr[i]; + in_low_odd = in_ptr[i + 1]; + in_high_even = in_ptr[half_span + i]; + in_high_odd = in_ptr[half_span + i + 1]; - sum = 0L; - sum = L_mac(sum, cos_even, in_low_even); - neg_msin_even = negate(msin_even); - sum = L_mac(sum, neg_msin_even, in_high_even); - out_low_even = xround(sum); + cos_even = cos_msin_ptr[i].cosine; + msin_even = cos_msin_ptr[i].minus_sine; + cos_odd = cos_msin_ptr[i + 1].cosine; + msin_odd = cos_msin_ptr[i + 1].minus_sine; - sum = 0L; - sum = L_mac(sum, msin_even,in_low_even); + sum = L_mult(cos_even, in_low_even); + sum = L_mac(sum, -msin_even, in_high_even); + out_ptr[i] = xround(sum); + + sum = L_mult(msin_even,in_low_even); sum = L_mac(sum, cos_even, in_high_even); - out_high_even = xround(sum); + out_ptr[set_span - 1 - i] = xround(sum); - sum = 0L; - sum = L_mac(sum, cos_odd, in_low_odd); + sum = L_mult(cos_odd, in_low_odd); sum = L_mac(sum, msin_odd, in_high_odd); - out_low_odd = xround(sum); + out_ptr[i + 1] = xround(sum); - sum = 0L; - sum = L_mac(sum, msin_odd, in_low_odd); - neg_cos_odd = negate(cos_odd); - sum = L_mac(sum, neg_cos_odd, in_high_odd); - out_high_odd = xround(sum); - - *out_ptr_low++ = out_low_even; - *--out_ptr_high = out_high_even; - *out_ptr_low++ = out_low_odd; - *--out_ptr_high = out_high_odd; + sum = L_mult(msin_odd, in_low_odd); + sum = L_mac(sum, -cos_odd, in_high_odd); + out_ptr[set_span - 2 - i] = xround(sum); } - while (out_ptr_low < out_ptr_high); + in_ptr += set_span; + out_ptr += set_span; } /* Swap input and output buffers for next time */ buffer_swap = in_buffer; in_buffer = out_buffer; out_buffer = buffer_swap; - table_ptr_ptr++; } } /*- End of function --------------------------------------------------------*/ diff --git a/libs/libg722_1/src/dct4_a.h b/libs/libg722_1/src/dct4_a.h index bcc63bf29d..4d4b95c68e 100644 --- a/libs/libg722_1/src/dct4_a.h +++ b/libs/libg722_1/src/dct4_a.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: dct4_a.h,v 1.4 2008/09/25 15:56:31 steveu Exp $ */ typedef struct diff --git a/libs/libg722_1/src/dct4_s.c b/libs/libg722_1/src/dct4_s.c index 71151b3f14..c195693cef 100644 --- a/libs/libg722_1/src/dct4_s.c +++ b/libs/libg722_1/src/dct4_s.c @@ -6,29 +6,23 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: dct4_s.c,v 1.8 2008/09/30 14:06:39 steveu Exp $ */ -/******************************************************************************** -* Filename: dct_type_iv_s.c -* -* Purpose: Discrete Cosine Transform, Type IV used for inverse MLT -* -* The basis functions are -* -* cos(PI*(t+0.5)*(k+0.5)/block_length) -* -* for time t and basis function number k. Due to the symmetry of the expression -* in t and k, it is clear that the forward and inverse transforms are the same. -* -*********************************************************************************/ +/* Discrete Cosine Transform, Type IV used for inverse MLT + + The basis functions are + + cos(PI*(t+0.5)*(k+0.5)/block_length) + + for time t and basis function number k. Due to the symmetry of the + expression in t and k, it is clear that the forward and inverse transforms + are the same. */ /*! \file */ @@ -45,67 +39,51 @@ #if defined(G722_1_USE_FIXED_POINT) #include "dct4_s.h" +#include "utilities.h" -/******************************************************************************** - Function: dct_type_iv_s - - Syntax: void dct_type_iv_s (int16_t *input,int16_t *output,int16_t dct_length) - - - Description: Discrete Cosine Transform, Type IV used for inverse MLT -********************************************************************************/ +/* Discrete Cosine Transform, Type IV used for inverse MLT */ void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length) { int16_t buffer_a[MAX_DCT_LENGTH]; int16_t buffer_b[MAX_DCT_LENGTH]; int16_t buffer_c[MAX_DCT_LENGTH]; int16_t *in_ptr; - int16_t *in_ptr_low; - int16_t *in_ptr_high; - int16_t *next_in_base; - int16_t *out_ptr_low; - int16_t *out_ptr_high; - int16_t *next_out_base; - int16_t *out_buffer; + int16_t *out_ptr; int16_t *in_buffer; + int16_t *out_buffer; int16_t *buffer_swap; int16_t in_val_low; int16_t in_val_high; - int16_t out_val_low; - int16_t out_val_high; int16_t in_low_even; int16_t in_low_odd; int16_t in_high_even; int16_t in_high_odd; - int16_t out_low_even; - int16_t out_low_odd; - int16_t out_high_even; - int16_t out_high_odd; int16_t *pair_ptr; int16_t cos_even; int16_t cos_odd; int16_t msin_even; int16_t msin_odd; int16_t set_span; + int16_t half_span; int16_t set_count; int16_t set_count_log; int16_t pairs_left; int16_t sets_left; int16_t i; + int16_t j; int16_t k; int16_t index; int16_t dummy; + int16_t dct_length_log; int32_t sum; + int32_t acca; const cos_msin_t **table_ptr_ptr; const cos_msin_t *cos_msin_ptr; - int32_t acca; - int16_t temp; - int16_t dct_length_log; const int16_t *dither_ptr; - /* Do the sum/difference butterflies, the first part of */ - /* converting one N-point transform into 32 - 10 point transforms */ - /* transforms, where N = 1 << DCT_LENGTH_LOG. */ + /* Do the sum/difference butterflies, the first part of + converting one N-point transform into 32 - 10 point transforms + transforms, where N = 1 << DCT_LENGTH_LOG. */ if (dct_length == DCT_LENGTH) { dct_length_log = DCT_LENGTH_LOG; @@ -122,92 +100,61 @@ void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length) index = 0; i = 0; + j = 0; for (set_count_log = 0; set_count_log <= dct_length_log - 2; set_count_log++) { - /* Initialization for the loop over sets at the current size */ - /* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ - set_span = shr(dct_length, set_count_log); - - set_count = shl(1, set_count_log); + /* Loop over all the sets at the current size */ + set_span = dct_length >> set_count_log; + set_count = 1 << set_count_log; + half_span = set_span >> 1; in_ptr = in_buffer; - next_out_base = out_buffer; + out_ptr = out_buffer; - /* Loop over all the sets of this size */ - temp = sub(index, 1); - if (temp < 0) + if (index < 1) { for (sets_left = set_count; sets_left > 0; sets_left--) { - /* Set up output pointers for the current set */ - /* pointer arithmetic */ - out_ptr_low = next_out_base; - next_out_base += set_span; - out_ptr_high = next_out_base; - /* Loop over all the butterflies in the current set */ - do + for (i = 0; i < half_span; i++) { in_val_low = *in_ptr++; in_val_high = *in_ptr++; - /* BEST METHOD OF GETTING RID OF BIAS, BUT COMPUTATIONALLY UNPLEASANT */ - /* ALTERNATIVE METHOD, SMEARS BIAS OVER THE ENTIRE FRAME, COMPUTATIONALLY SIMPLEST. */ - /* IF THIS WORKS, IT'S PREFERABLE */ - - dummy = add(in_val_low, dither_ptr[i++]); + dummy = add(in_val_low, dither_ptr[j++]); acca = L_add(dummy, in_val_high); - out_val_low = (int16_t) L_shr(acca, 1); + out_ptr[i] = (int16_t) L_shr(acca, 1); - dummy = add(in_val_low, dither_ptr[i++]); - acca = L_add(dummy, -in_val_high); - out_val_high = (int16_t) L_shr(acca, 1); - - *out_ptr_low++ = out_val_low; - *--out_ptr_high = out_val_high; - - /* this involves comparison of pointers */ - /* pointer arithmetic */ + dummy = add(in_val_low, dither_ptr[j++]); + acca = L_sub(dummy, in_val_high); + out_ptr[set_span - 1 - i] = (int16_t) L_shr(acca, 1); } - while (out_ptr_low < out_ptr_high); + out_ptr += set_span; } } else { for (sets_left = set_count; sets_left > 0; sets_left--) { - /* Set up output pointers for the current set */ - out_ptr_low = next_out_base; - next_out_base += set_span; - out_ptr_high = next_out_base; - /* Loop over all the butterflies in the current set */ - do + for (i = 0; i < half_span; i++) { in_val_low = *in_ptr++; in_val_high = *in_ptr++; - out_val_low = add(in_val_low, in_val_high); - out_val_high = add(in_val_low, negate(in_val_high)); - - *out_ptr_low++ = out_val_low; - *--out_ptr_high = out_val_high; + out_ptr[i] = add(in_val_low, in_val_high); + out_ptr[set_span - 1 - i] = sub(in_val_low, in_val_high); } - while (out_ptr_low < out_ptr_high); + out_ptr += set_span; } } - /* Decide which buffers to use as input and output next time. */ - /* Except for the first time (when the input buffer is the */ - /* subroutine input) we just alternate the local buffers. */ + /* Decide which buffers to use as input and output next time. + Except for the first time (when the input buffer is the + subroutine input) we just alternate the local buffers. */ in_buffer = out_buffer; - - if (out_buffer == buffer_a) - out_buffer = buffer_b; - else - out_buffer = buffer_a; - - index = add(index, 1); + out_buffer = (out_buffer == buffer_a) ? buffer_b : buffer_a; + index++; } /* Do 32 - 10 point transforms */ @@ -228,8 +175,7 @@ void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length) buffer_swap += CORE_SIZE; } - for (i = 0; i < dct_length; i++) - in_buffer[i] = buffer_c[i]; + vec_copyi16(in_buffer, buffer_c, dct_length); table_ptr_ptr = s_cos_msin_table; @@ -238,90 +184,61 @@ void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length) for (set_count_log = dct_length_log - 2; set_count_log >= 0; set_count_log--) { /* Initialization for the loop over sets at the current size */ - /* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ - set_span = shr(dct_length, set_count_log); - - set_count = shl(1, set_count_log); - next_in_base = in_buffer; - if (set_count_log == 0) - next_out_base = output; - else - next_out_base = out_buffer; + set_span = dct_length >> set_count_log; + set_count = 1 << set_count_log; + half_span = set_span >> 1; + in_ptr = in_buffer; + out_ptr = (set_count_log == 0) ? output : out_buffer; + cos_msin_ptr = *table_ptr_ptr++; /* Loop over all the sets of this size */ for (sets_left = set_count; sets_left > 0; sets_left--) { - /* Set up the pointers for the current set */ - in_ptr_low = next_in_base; - temp = shr(set_span, 1); - in_ptr_high = in_ptr_low + temp; - next_in_base += set_span; - out_ptr_low = next_out_base; - next_out_base += set_span; - out_ptr_high = next_out_base; - cos_msin_ptr = *table_ptr_ptr; - /* Loop over all the butterfly pairs in the current set */ - do + for (i = 0; i < half_span; i += 2) { - in_low_even = *in_ptr_low++; - in_low_odd = *in_ptr_low++; - in_high_even = *in_ptr_high++; - in_high_odd = *in_ptr_high++; - cos_even = cos_msin_ptr[0].cosine; - msin_even = cos_msin_ptr[0].minus_sine; - cos_odd = cos_msin_ptr[1].cosine; - msin_odd = cos_msin_ptr[1].minus_sine; - cos_msin_ptr += 2; + in_low_even = in_ptr[i]; + in_low_odd = in_ptr[i + 1]; + in_high_even = in_ptr[half_span + i]; + in_high_odd = in_ptr[half_span + i + 1]; - sum = 0L; - sum = L_mac(sum, cos_even, in_low_even); - sum = L_mac(sum, negate(msin_even), in_high_even); - out_low_even = xround(L_shl(sum, 1)); + cos_even = cos_msin_ptr[i].cosine; + msin_even = cos_msin_ptr[i].minus_sine; + cos_odd = cos_msin_ptr[i + 1].cosine; + msin_odd = cos_msin_ptr[i + 1].minus_sine; - sum = 0L; - sum = L_mac(sum, msin_even, in_low_even); + sum = L_mult(cos_even, in_low_even); + sum = L_mac(sum, -msin_even, in_high_even); + out_ptr[i] = xround(L_shl(sum, 1)); + + sum = L_mult(msin_even, in_low_even); sum = L_mac(sum, cos_even, in_high_even); - out_high_even = xround(L_shl(sum, 1)); + out_ptr[set_span - 1 - i] = xround(L_shl(sum, 1)); - sum = 0L; - sum = L_mac(sum, cos_odd, in_low_odd); + sum = L_mult(cos_odd, in_low_odd); sum = L_mac(sum, msin_odd, in_high_odd); - out_low_odd = xround(L_shl(sum, 1)); + out_ptr[i + 1] = xround(L_shl(sum, 1)); - sum = 0L; - sum = L_mac(sum, msin_odd, in_low_odd); - sum = L_mac(sum, negate(cos_odd), in_high_odd); - out_high_odd = xround(L_shl(sum, 1)); - - *out_ptr_low++ = out_low_even; - *--out_ptr_high = out_high_even; - *out_ptr_low++ = out_low_odd; - *--out_ptr_high = out_high_odd; + sum = L_mult(msin_odd, in_low_odd); + sum = L_mac(sum, -cos_odd, in_high_odd); + out_ptr[set_span - 2 - i] = xround(L_shl(sum, 1)); } - while (out_ptr_low < out_ptr_high); + in_ptr += set_span; + out_ptr += set_span; } /* Swap input and output buffers for next time */ buffer_swap = in_buffer; in_buffer = out_buffer; out_buffer = buffer_swap; - - index = add(index, 1); - table_ptr_ptr++; + index++; } - /* ADD IN BIAS FOR OUTPUT */ + /* Add in bias for output */ if (dct_length == DCT_LENGTH) { - for (i = 0; i < 320; i++) + for (i = 0; i < DCT_LENGTH; i++) { sum = L_add(output[i], syn_bias_7khz[i]); - acca = L_sub(sum, 32767); - if (acca > 0) - sum = 32767L; - acca = L_add(sum, 32768L); - if (acca < 0) - sum = -32768L; - output[i] = (int16_t) sum; + output[i] = saturate(sum); } } } diff --git a/libs/libg722_1/src/dct4_s.h b/libs/libg722_1/src/dct4_s.h index 68040d0659..533be1c7b9 100644 --- a/libs/libg722_1/src/dct4_s.h +++ b/libs/libg722_1/src/dct4_s.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: dct4_s.h,v 1.4 2008/09/25 15:56:31 steveu Exp $ */ typedef struct @@ -196,11 +194,9 @@ static const int16_t max_dither[MAX_DCT_LENGTH] = for (index = 0;index < length;index++) { angle = scale * ((double)index + 0.5); - table[index].cosine = (short) (FTOI((18427)* cos(angle))); - table[index].minus_sine = (short) (FTOI((18427)*(-sin(angle)))); + table[index].cosine = (int16_t) (FTOI((18427)* cos(angle))); + table[index].minus_sine = (int16_t) (FTOI((18427)*(-sin(angle)))); } - - ********************************************************************************/ static const cos_msin_t s_cos_msin_2[DCT_LENGTH_DIV_32] = diff --git a/libs/libg722_1/src/decoder.c b/libs/libg722_1/src/decoder.c index 80fcab4d5a..f1db32f282 100644 --- a/libs/libg722_1/src/decoder.c +++ b/libs/libg722_1/src/decoder.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C)2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: decoder.c,v 1.21 2008/11/21 15:30:22 steveu Exp $ */ /*! \file */ @@ -94,9 +92,7 @@ static void decoder(g722_1_decode_state_t *s, int16_t old_decoder_mlt_coefs[], int frame_error_flag); -/*************************************************************************** - Description: Decodes the out_words into mlt coefs using G.722.1 Annex C -***************************************************************************/ +/* Decodes the out_words into MLT coefs using G.722.1 Annex C */ void decoder(g722_1_decode_state_t *s, int16_t number_of_regions, int16_t decoder_mlt_coefs[], @@ -109,11 +105,11 @@ void decoder(g722_1_decode_state_t *s, int16_t absolute_region_power_index[MAX_NUMBER_OF_REGIONS]; int16_t decoder_power_categories[MAX_NUMBER_OF_REGIONS]; int16_t decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]; - uint16_t categorization_control; int16_t num_categorization_control_bits; int16_t num_categorization_control_possibilities; int16_t number_of_coefs; int16_t number_of_valid_coefs; + uint16_t categorization_control; number_of_valid_coefs = number_of_regions*REGION_SIZE; @@ -184,9 +180,7 @@ void decoder(g722_1_decode_state_t *s, } /*- End of function --------------------------------------------------------*/ -/*************************************************************************** - Description: Recover differential_region_power_index from code bits -***************************************************************************/ +/* Recover differential_region_power_index from code bits */ static void decode_envelope(g722_1_decode_state_t *s, int16_t number_of_regions, int16_t *decoder_region_standard_deviation, @@ -262,7 +256,7 @@ static void decode_envelope(g722_1_decode_state_t *s, while ((i >= 0) && ((temp1 >= 0) || (temp2 > 0))) { i = sub(i, 1); - temp = shr(temp, 1); + temp >>= 1; max_index = sub(max_index, 2); temp1 = sub(temp, 8); temp2 = sub(max_index, 28); @@ -365,12 +359,12 @@ static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s, if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0) { temp = shl(index, 1); - index = (int16_t) *(decoder_table_ptr + temp); + index = decoder_table_ptr[temp]; } else { temp = shl(index, 1); - index = (int16_t) *(decoder_table_ptr + temp + 1); + index = decoder_table_ptr[temp + 1]; } s->number_of_bits_left--; } @@ -406,7 +400,7 @@ static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s, { if ((signs_index & bit) == 0) decoder_mlt_value = negate(decoder_mlt_value); - bit = shr(bit, 1); + bit >>= 1; } *decoder_mlt_ptr++ = decoder_mlt_value; } @@ -440,7 +434,7 @@ static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s, if (*decoder_mlt_ptr == 0) { *decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos; - random_word = shr(random_word, 1); + random_word >>= 1; } /* pointer arithmetic */ decoder_mlt_ptr++; @@ -451,7 +445,7 @@ static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s, if (*decoder_mlt_ptr == 0) { *decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos; - random_word = shr(random_word,1); + random_word >>= 1; } /* pointer arithmetic */ decoder_mlt_ptr++; diff --git a/libs/libg722_1/src/decoderf.c b/libs/libg722_1/src/decoderf.c index 761a0cff30..e0e8e61743 100644 --- a/libs/libg722_1/src/decoderf.c +++ b/libs/libg722_1/src/decoderf.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: decoderf.c,v 1.22 2008/11/21 15:30:22 steveu Exp $ */ /*! \file */ @@ -33,6 +31,7 @@ #include "huff_tab.h" #include "tables.h" #include "bitstream.h" +#include "utilities.h" #if !defined(G722_1_USE_FIXED_POINT) @@ -84,12 +83,12 @@ static void decoder(g722_1_decode_state_t *s, int absolute_region_power_index[MAX_NUMBER_OF_REGIONS]; int decoder_power_categories[MAX_NUMBER_OF_REGIONS]; int decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]; - int rate_control; int num_categorization_control_bits; int num_categorization_control_possibilities; int number_of_coefs; int number_of_valid_coefs; int rmlt_scale_factor; + int rate_control; number_of_valid_coefs = s->number_of_regions*REGION_SIZE; @@ -451,7 +450,7 @@ static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s, if (category == NUM_CATEGORIES - 1) { - noifillpos = standard_deviation*0.70711f; + noifillpos = standard_deviation*0.70711; noifillneg = -noifillpos; /* This assumes region_size = 20 */ @@ -555,27 +554,21 @@ static void error_handling(int number_of_coefs, float *decoder_mlt_coefs, float *old_decoder_mlt_coefs) { - int i; - /* If both the current and previous frames are errored, set the mlt coefficients to 0. If only the current frame is errored, repeat the previous frame's MLT coefficients. */ if (*frame_error_flag) { - for (i = 0; i < number_of_valid_coefs; i++) - decoder_mlt_coefs[i] = old_decoder_mlt_coefs[i]; - for (i = 0; i < number_of_valid_coefs; i++) - old_decoder_mlt_coefs[i] = 0.0f; + vec_copyf(decoder_mlt_coefs, old_decoder_mlt_coefs, number_of_valid_coefs); + vec_zerof(old_decoder_mlt_coefs, number_of_valid_coefs); } else { /* Store in case the next frame has errors. */ - for (i = 0; i < number_of_valid_coefs; i++) - old_decoder_mlt_coefs[i] = decoder_mlt_coefs[i]; + vec_copyf(old_decoder_mlt_coefs, decoder_mlt_coefs, number_of_valid_coefs); } /* Zero out the upper 1/8 of the spectrum. */ - for (i = number_of_valid_coefs; i < number_of_coefs; i++) - decoder_mlt_coefs[i] = 0.0f; + vec_zerof(&decoder_mlt_coefs[number_of_valid_coefs], number_of_coefs - number_of_valid_coefs); } /*- End of function --------------------------------------------------------*/ diff --git a/libs/libg722_1/src/defs.h b/libs/libg722_1/src/defs.h index 7a565d0565..9c2c83dd10 100644 --- a/libs/libg722_1/src/defs.h +++ b/libs/libg722_1/src/defs.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: defs.h,v 1.16 2008/10/01 15:31:10 steveu Exp $ */ #define MAX(a,b) (a > b ? a : b) diff --git a/libs/libg722_1/src/encoder.c b/libs/libg722_1/src/encoder.c index fef4b44883..054d6b36bd 100644 --- a/libs/libg722_1/src/encoder.c +++ b/libs/libg722_1/src/encoder.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: encoder.c,v 1.26 2008/11/21 15:30:22 steveu Exp $ */ /*! \file */ @@ -32,6 +30,7 @@ #include "huff_tab.h" #include "tables.h" #include "bitstream.h" +#include "utilities.h" #if defined(G722_1_USE_FIXED_POINT) @@ -99,9 +98,8 @@ static void bits_to_words(g722_1_encode_state_t *s, drp_num_bits[number_of_regions] = num_categorization_control_bits; drp_code_bits[number_of_regions] = categorization_control; - bit_count = 0; /* These code bits are right justified. */ - for (region = 0; region <= number_of_regions; region++) + for (bit_count = 0, region = 0; region <= number_of_regions; region++) { g722_1_bitstream_put(&s->bitstream, &out_code, drp_code_bits[region], drp_num_bits[region]); bit_count += drp_num_bits[region]; @@ -247,14 +245,11 @@ void adjust_abs_region_power_index(int16_t *absolute_region_power_index, for (region = 0; region < number_of_regions; region++) { - n = sub(absolute_region_power_index[region], 39); - n = shr(n, 1); + n = sub(absolute_region_power_index[region], 39) >> 1; if (n > 0) { temp = (int16_t) L_mult0(region, REGION_SIZE); - raw_mlt_ptr = &mlt_coefs[temp]; - for (i = 0; i < REGION_SIZE; i++) { acca = L_shl(*raw_mlt_ptr, 16); @@ -264,8 +259,7 @@ void adjust_abs_region_power_index(int16_t *absolute_region_power_index, *raw_mlt_ptr++ = (int16_t) acca; } - temp = sub(absolute_region_power_index[region], shl(n, 1)); - absolute_region_power_index[region] = temp; + absolute_region_power_index[region] = sub(absolute_region_power_index[region], shl(n, 1)); } } } @@ -281,7 +275,6 @@ static int16_t compute_region_powers(int16_t *mlt_coefs, { int16_t *input_ptr; int32_t long_accumulator; - int16_t itemp1; int16_t power_shift; int16_t region; int16_t j; @@ -295,12 +288,8 @@ static int16_t compute_region_powers(int16_t *mlt_coefs, input_ptr = mlt_coefs; for (region = 0; region < number_of_regions; region++) { - long_accumulator = 0; - for (j = 0; j < REGION_SIZE; j++) - { - itemp1 = *input_ptr++; - long_accumulator = L_mac0(long_accumulator, itemp1, itemp1); - } + long_accumulator = vec_dot_prodi16(input_ptr, input_ptr, REGION_SIZE); + input_ptr += REGION_SIZE; power_shift = 0; acca = long_accumulator & 0x7FFF0000L; @@ -348,7 +337,7 @@ static int16_t compute_region_powers(int16_t *mlt_coefs, } /* The MLT is currently scaled too low by the factor - ENCODER_SCALE_FACTOR(=18318)/32768 * (1./sqrt(160). + ENCODER_SCALE_FACTOR(=18318)/32768 * (1.0/sqrt(160). This is the ninth power of 1 over the square root of 2. So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9) to drp_code_bits[0]. */ @@ -520,7 +509,8 @@ static int16_t vector_huffman(int16_t category, int16_t num_vecs; int16_t kmax; int16_t kmax_plus_one; - int16_t index,signs_index; + int16_t index; + int16_t signs_index; const int16_t *bitcount_table_ptr; const uint16_t *code_table_ptr; int32_t code_bits; diff --git a/libs/libg722_1/src/encoderf.c b/libs/libg722_1/src/encoderf.c index 36a52064f0..2589886aa3 100644 --- a/libs/libg722_1/src/encoderf.c +++ b/libs/libg722_1/src/encoderf.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: encoderf.c,v 1.22 2008/11/21 15:30:22 steveu Exp $ */ /*! \file */ @@ -33,6 +31,7 @@ #include "huff_tab.h" #include "tables.h" #include "bitstream.h" +#include "utilities.h" #if !defined(G722_1_USE_FIXED_POINT) @@ -218,7 +217,6 @@ static int compute_region_powers(int number_of_regions, float *input_ptr; int iterations; float ftemp0; - float ftemp1; int index; int index_min; int index_max; @@ -230,13 +228,9 @@ static int compute_region_powers(int number_of_regions, input_ptr = mlt_coefs; for (region = 0; region < number_of_regions; region++) { - ftemp0 = 0.0f; - for (j = 0; j < REGION_SIZE; j++) - { - ftemp1 = *input_ptr++; - ftemp0 += ftemp1*ftemp1; - } + ftemp0 = vec_dot_prodf(input_ptr, input_ptr, REGION_SIZE); ftemp0 *= REGION_SIZE_INVERSE; + input_ptr += REGION_SIZE; index_min = 0; index_max = REGION_POWER_TABLE_SIZE; @@ -260,7 +254,7 @@ static int compute_region_powers(int number_of_regions, } /* The MLT is currently scaled too low by the factor - ENCODER_SCALE_FACTOR(=18318)/32768 * (1./sqrt(160). + ENCODER_SCALE_FACTOR(=18318)/32768 * (1.0/sqrt(160). This is the ninth power of 1 over the square root of 2. So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9) to drp_code_bits[0]. */ @@ -448,7 +442,7 @@ static int vector_huffman(int category, number_of_non_zero = 0; for (j = 0; j < vec_dim; j++) { - k = (int) (fabs(*raw_mlt_ptr) * inv_of_step_size_times_std_dev + dead_zone[category]); + k = (int) (fabs(*raw_mlt_ptr)*inv_of_step_size_times_std_dev + dead_zone[category]); if (k != 0) { number_of_non_zero++; @@ -458,12 +452,12 @@ static int vector_huffman(int category, if (k > kmax) k = kmax; } - index = index*(kmax_plus_one) + k; + index = index*kmax_plus_one + k; raw_mlt_ptr++; } - code_bits = *(code_table_ptr + index); - number_of_code_bits = *(bitcount_table_ptr + index) + number_of_non_zero; + code_bits = code_table_ptr[index]; + number_of_code_bits = bitcount_table_ptr[index] + number_of_non_zero; number_of_region_bits += number_of_code_bits; code_bits = (code_bits << number_of_non_zero) + signs_index; diff --git a/libs/libg722_1/src/g722_1.h.in b/libs/libg722_1/src/g722_1.h.in index e4a1e415b1..86c0921a65 100644 --- a/libs/libg722_1/src/g722_1.h.in +++ b/libs/libg722_1/src/g722_1.h.in @@ -7,8 +7,6 @@ * 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. - * - * $Id: g722_1.h.in,v 1.1.1.1 2008/09/20 09:47:17 steveu Exp $ */ /*! \file */ diff --git a/libs/libg722_1/src/g722_1/g722_1.h b/libs/libg722_1/src/g722_1/g722_1.h index 3408abbf31..6f2a497eb1 100644 --- a/libs/libg722_1/src/g722_1/g722_1.h +++ b/libs/libg722_1/src/g722_1/g722_1.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: g722_1.h,v 1.14 2008/10/17 13:18:21 steveu Exp $ */ #if !defined(_G722_1_G722_1_H_) diff --git a/libs/libg722_1/src/g722_1/version.h.in b/libs/libg722_1/src/g722_1/version.h.in index f9c66d0745..e825425ce9 100644 --- a/libs/libg722_1/src/g722_1/version.h.in +++ b/libs/libg722_1/src/g722_1/version.h.in @@ -9,8 +9,6 @@ * 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. - * - * $Id: version.h.in,v 1.2 2008/09/20 16:52:51 steveu Exp $ */ #if !defined(_G722_1_VERSION_H_) diff --git a/libs/libg722_1/src/huff_tab.c b/libs/libg722_1/src/huff_tab.c index 07f5085b35..3583ba30ff 100644 --- a/libs/libg722_1/src/huff_tab.c +++ b/libs/libg722_1/src/huff_tab.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: huff_tab.c,v 1.7 2008/09/30 14:06:40 steveu Exp $ */ /*! \file */ diff --git a/libs/libg722_1/src/huff_tab.h b/libs/libg722_1/src/huff_tab.h index a58b843f5e..3d58962c83 100644 --- a/libs/libg722_1/src/huff_tab.h +++ b/libs/libg722_1/src/huff_tab.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: huff_tab.h,v 1.4 2008/09/30 14:06:40 steveu Exp $ */ #define REGION_POWER_STEPSIZE_DB 3.010299957 diff --git a/libs/libg722_1/src/make_dct4_tables.c b/libs/libg722_1/src/make_dct4_tables.c index 015daf355a..ffb4a94063 100644 --- a/libs/libg722_1/src/make_dct4_tables.c +++ b/libs/libg722_1/src/make_dct4_tables.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: make_dct4_tables.c,v 1.2 2008/10/02 11:43:54 steveu Exp $ */ /*! \file */ @@ -29,7 +27,11 @@ #include "g722_1/g722_1.h" +#if defined(PI) +#undef PI +#endif #define PI 3.141592653589793238462 + #include "defs.h" static void set_up_one_table(int length) @@ -99,6 +101,7 @@ int main(int argc, char *argv[]) for (i = 0; i <= length_log; i++) set_up_one_table(dct_size << i); + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/src/make_tables.c b/libs/libg722_1/src/make_tables.c index d234d8a8a0..aa6d5cb748 100644 --- a/libs/libg722_1/src/make_tables.c +++ b/libs/libg722_1/src/make_tables.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: make_tables.c,v 1.5 2008/11/21 15:30:22 steveu Exp $ */ /*! \file */ @@ -37,6 +35,7 @@ #undef PI #endif #define PI 3.141592653589793238462 + /* These may have been defined in the main header for the codec, so we clear out any pre-existing definitions here. */ #if defined(ENCODER_SCALE_FACTOR) @@ -124,7 +123,7 @@ static void generate_sam2coef_tables(void) for (i = 0; i < DCT_LENGTH; i++) { angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH; - printf(" %.15e,\n", sin(angle)); + printf(" %.15ef,\n", sin(angle)); } printf("};\n\n"); @@ -132,7 +131,7 @@ static void generate_sam2coef_tables(void) for (i = 0; i < MAX_DCT_LENGTH; i++) { angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH; - printf(" %.15le,\n", sin(angle)); + printf(" %.15ef,\n", sin(angle)); } printf("};\n\n"); @@ -180,7 +179,7 @@ static void generate_coef2sam_tables(void) for (i = 0; i < DCT_LENGTH; i++) { angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH; - printf(" %.15e,\n", sin(angle)); + printf(" %.15ef,\n", sin(angle)); } printf("};\n\n"); @@ -188,7 +187,7 @@ static void generate_coef2sam_tables(void) for (i = 0; i < MAX_DCT_LENGTH; i++) { angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH; - printf(" %.15e,\n", sin(angle)); + printf(" %.15ef,\n", sin(angle)); } printf("};\n\n"); @@ -218,7 +217,7 @@ int main(int argc, char *argv[]) for (i = 0; i < REGION_POWER_TABLE_SIZE; i++) { value = pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(i - REGION_POWER_TABLE_NUM_NEGATIVES)); - printf(" %.15e,\n", sqrt(value)); + printf(" %.15ef,\n", sqrt(value)); } printf("};\n\n"); @@ -226,7 +225,7 @@ int main(int argc, char *argv[]) for (i = 0; i < REGION_POWER_TABLE_SIZE; i++) { value = pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(i - REGION_POWER_TABLE_NUM_NEGATIVES)); - printf(" %.15e,\n", 1.0/sqrt(value)); + printf(" %.15ef,\n", 1.0/sqrt(value)); } printf("};\n\n"); @@ -259,14 +258,14 @@ int main(int argc, char *argv[]) printf("const float step_size[NUM_CATEGORIES] =\n{\n"); for (i = 0; i < NUM_CATEGORIES; i++) { - printf(" %.15e,\n", step_size[i]); + printf(" %.15ef,\n", step_size[i]); } printf("};\n\n"); printf("const float step_size_inverse_table[NUM_CATEGORIES] =\n{\n"); for (i = 0; i < NUM_CATEGORIES; i++) { - printf(" %.15e,\n", 1.0/step_size[i]); + printf(" %.15ef,\n", 1.0/step_size[i]); } printf("};\n\n"); @@ -275,7 +274,7 @@ int main(int argc, char *argv[]) for (i = 0; i < REGION_POWER_TABLE_SIZE; i++) { value = pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(i - REGION_POWER_TABLE_NUM_NEGATIVES)); - printf(" %.15e,\n", value); + printf(" %.15ef,\n", value); } printf("};\n\n"); @@ -283,9 +282,10 @@ int main(int argc, char *argv[]) for (i = 0; i < REGION_POWER_TABLE_SIZE - 1; i++) { value = (float) pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(0.5 + (i - REGION_POWER_TABLE_NUM_NEGATIVES))); - printf(" %.15e,\n", value); + printf(" %.15ef,\n", value); } printf("};\n\n"); + return 0; } /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/src/sam2coef.c b/libs/libg722_1/src/sam2coef.c index 50f61d27ce..604c2874c8 100644 --- a/libs/libg722_1/src/sam2coef.c +++ b/libs/libg722_1/src/sam2coef.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: sam2coef.c,v 1.12 2008/10/02 11:43:54 steveu Exp $ */ /*! \file */ @@ -29,17 +27,16 @@ #include "defs.h" #include "sam2coef.h" +#include "utilities.h" -/************************************************************************************ - Purpose: Convert Samples to Reversed MLT (Modulated Lapped Transform) Coefficients +/* Convert Samples to Reversed MLT (Modulated Lapped Transform) Coefficients - The "Reversed MLT" is an overlapped block transform which uses even symmetry - on the left, odd symmetry on the right and a Type IV DCT as the block transform. - It is thus similar to a MLT which uses odd symmetry on the left, even symmetry - on the right and a Type IV DST as the block transform. In fact, it is equivalent - to reversing the order of the samples, performing an MLT and then negating all - the even-numbered coefficients. -***************************************************************************/ + The "Reversed MLT" is an overlapped block transform which uses even symmetry + on the left, odd symmetry on the right and a Type IV DCT as the block transform. + It is thus similar to a MLT which uses odd symmetry on the left, even symmetry + on the right and a Type IV DST as the block transform. In fact, it is equivalent + to reversing the order of the samples, performing an MLT and then negating all + the even-numbered coefficients. */ #if defined(G722_1_USE_FIXED_POINT) int16_t samples_to_rmlt_coefs(const int16_t new_samples[], @@ -62,34 +59,26 @@ int16_t samples_to_rmlt_coefs(const int16_t new_samples[], half_dct_length = dct_length >> 1; - if (dct_length == DCT_LENGTH) - win = samples_to_rmlt_window; - else - win = max_samples_to_rmlt_window; + win = (dct_length == DCT_LENGTH) ? samples_to_rmlt_window : max_samples_to_rmlt_window; /* Get the first half of the windowed samples */ last = half_dct_length - 1; for (i = 0; i < half_dct_length; i++) { - acca = 0L; - acca = L_mac(acca, win[last - i], old_samples[last - i]); + acca = L_mult(win[last - i], old_samples[last - i]); acca = L_mac(acca, win[half_dct_length + i], old_samples[half_dct_length + i]); - temp = xround(acca); - windowed_data[i] = temp; + windowed_data[i] = xround(acca); } /* Get the second half of the windowed samples */ last = dct_length - 1; for (i = 0; i < half_dct_length; i++) { - acca = 0L; - acca = L_mac(acca, win[last - i], new_samples[i]); + acca = L_mult(win[last - i], new_samples[i]); acca = L_mac(acca, negate(win[i]), new_samples[last - i]); - temp = xround(acca); - windowed_data[half_dct_length + i] = temp; + windowed_data[half_dct_length + i] = xround(acca); } /* Save the new samples for next time, when they will be the old samples. */ - for (i = 0; i < dct_length; i++) - old_samples[i] = new_samples[i]; + vec_copyi16(old_samples, new_samples, dct_length); /* Calculate how many bits to shift up the input to the DCT. */ temp1 = 0; @@ -156,10 +145,7 @@ void samples_to_rmlt_coefs(const float new_samples[], half_dct_length = dct_length >> 1; - if (dct_length == DCT_LENGTH) - win = samples_to_rmlt_window; - else - win = max_samples_to_rmlt_window; + win = (dct_length == DCT_LENGTH) ? samples_to_rmlt_window : max_samples_to_rmlt_window; /* Get the first half of the windowed samples. */ last = half_dct_length - 1; for (i = 0; i < half_dct_length; i++) @@ -177,8 +163,7 @@ void samples_to_rmlt_coefs(const float new_samples[], windowed_data[half_dct_length + i] = sum; } /* Save the new samples for next time, when they will be the old samples. */ - for (i = 0; i < dct_length; i++) - old_samples[i] = new_samples[i]; + vec_copyf(old_samples, new_samples, dct_length); /* Perform a Type IV DCT on the windowed data to get the coefficients. */ dct_type_iv(windowed_data, coefs, dct_length); diff --git a/libs/libg722_1/src/sam2coef.h b/libs/libg722_1/src/sam2coef.h index 26f3cbaa02..1df19bb48f 100644 --- a/libs/libg722_1/src/sam2coef.h +++ b/libs/libg722_1/src/sam2coef.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: sam2coef.h,v 1.2 2008/10/02 11:43:54 steveu Exp $ */ #if defined(G722_1_USE_FIXED_POINT) diff --git a/libs/libg722_1/src/tables.c b/libs/libg722_1/src/tables.c index 62a0e8d808..a0eed803bf 100644 --- a/libs/libg722_1/src/tables.c +++ b/libs/libg722_1/src/tables.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: tables.c,v 1.11 2008/09/30 14:06:40 steveu Exp $ */ /*! \file */ @@ -65,70 +63,70 @@ const int16_t int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE] = #else const float region_standard_deviation_table[REGION_POWER_TABLE_SIZE] = { - 2.441406247570224e-04f, - 3.452669826719395e-04f, - 4.882812495545411e-04f, - 6.905339654011486e-04f, - 9.765624991900746e-04f, - 1.381067930916839e-03f, - 1.953124998542134e-03f, - 2.762135862062757e-03f, - 3.906249997408239e-03f, - 5.524271724583683e-03f, - 7.812499995464418e-03f, - 1.104854345008369e-02f, - 1.562499999222472e-02f, - 2.209708690200003e-02f, - 3.124999998704119e-02f, - 4.419417380766535e-02f, - 6.249999997926591e-02f, - 8.838834762266132e-02f, - 1.249999999688989e-01f, - 1.767766952599839e-01f, - 2.499999999585318e-01f, - 3.535533905492901e-01f, - 4.999999999585318e-01f, - 7.071067811572251e-01f, - 1.000000000000000e+00f, - 1.414213562431740e+00f, - 2.000000000165873e+00f, - 2.828427125098059e+00f, - 4.000000000663491e+00f, - 5.656854250665278e+00f, - 8.000000001990472e+00f, - 1.131370850226887e+01f, - 1.600000000530792e+01f, - 2.262741700641438e+01f, - 3.200000001326981e+01f, - 4.525483401658204e+01f, - 6.400000003184756e+01f, - 9.050966804067060e+01f, - 1.280000000743110e+02f, - 1.810193360963542e+02f, - 2.560000001698536e+02f, - 3.620386722227349e+02f, - 5.120000003821707e+02f, - 7.240773445055215e+02f, - 1.024000000849268e+03f, - 1.448154689131149e+03f, - 2.048000001868390e+03f, - 2.896309378502505e+03f, - 4.096000004076487e+03f, - 5.792618757485434e+03f, - 8.192000008832390e+03f, - 1.158523751593169e+04f, - 1.638400001902361e+04f, - 2.317047503378509e+04f, - 3.276800004076484e+04f, - 4.634095007141347e+04f, - 6.553600008696507e+04f, - 9.268190015051374e+04f, - 1.310720001848009e+05f, - 1.853638003164007e+05f, - 2.621440003913428e+05f, - 3.707276006635486e+05f, - 5.242880008261676e+05f, - 7.414552013885899e+05f + 2.441406247570224e-04, + 3.452669826719395e-04, + 4.882812495545411e-04, + 6.905339654011486e-04, + 9.765624991900746e-04, + 1.381067930916839e-03, + 1.953124998542134e-03, + 2.762135862062757e-03, + 3.906249997408239e-03, + 5.524271724583683e-03, + 7.812499995464418e-03, + 1.104854345008369e-02, + 1.562499999222472e-02, + 2.209708690200003e-02, + 3.124999998704119e-02, + 4.419417380766535e-02, + 6.249999997926591e-02, + 8.838834762266132e-02, + 1.249999999688989e-01, + 1.767766952599839e-01, + 2.499999999585318e-01, + 3.535533905492901e-01, + 4.999999999585318e-01, + 7.071067811572251e-01, + 1.000000000000000e+00, + 1.414213562431740e+00, + 2.000000000165873e+00, + 2.828427125098059e+00, + 4.000000000663491e+00, + 5.656854250665278e+00, + 8.000000001990472e+00, + 1.131370850226887e+01, + 1.600000000530792e+01, + 2.262741700641438e+01, + 3.200000001326981e+01, + 4.525483401658204e+01, + 6.400000003184756e+01, + 9.050966804067060e+01, + 1.280000000743110e+02, + 1.810193360963542e+02, + 2.560000001698536e+02, + 3.620386722227349e+02, + 5.120000003821707e+02, + 7.240773445055215e+02, + 1.024000000849268e+03, + 1.448154689131149e+03, + 2.048000001868390e+03, + 2.896309378502505e+03, + 4.096000004076487e+03, + 5.792618757485434e+03, + 8.192000008832390e+03, + 1.158523751593169e+04, + 1.638400001902361e+04, + 2.317047503378509e+04, + 3.276800004076484e+04, + 4.634095007141347e+04, + 6.553600008696507e+04, + 9.268190015051374e+04, + 1.310720001848009e+05, + 1.853638003164007e+05, + 2.621440003913428e+05, + 3.707276006635486e+05, + 5.242880008261676e+05, + 7.414552013885899e+05 }; #endif @@ -146,70 +144,70 @@ const int16_t standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] = #else const float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] = { - 4.096000004076488e+03f, - 2.896309378502504e+03f, - 2.048000001868390e+03f, - 1.448154689131149e+03f, - 1.024000000849268e+03f, - 7.240773445055215e+02f, - 5.120000003821708e+02f, - 3.620386722227349e+02f, - 2.560000001698537e+02f, - 1.810193360963542e+02f, - 1.280000000743110e+02f, - 9.050966804067060e+01f, - 6.400000003184756e+01f, - 4.525483401658203e+01f, - 3.200000001326982e+01f, - 2.262741700641438e+01f, - 1.600000000530793e+01f, - 1.131370850226887e+01f, - 8.000000001990474e+00f, - 5.656854250665277e+00f, - 4.000000000663491e+00f, - 2.828427125098059e+00f, - 2.000000000165873e+00f, - 1.414213562431740e+00f, - 1.000000000000000e+00f, - 7.071067811572251e-01f, - 4.999999999585318e-01f, - 3.535533905492901e-01f, - 2.499999999585318e-01f, - 1.767766952599838e-01f, - 1.249999999688989e-01f, - 8.838834762266132e-02f, - 6.249999997926592e-02f, - 4.419417380766535e-02f, - 3.124999998704120e-02f, - 2.209708690200002e-02f, - 1.562499999222472e-02f, - 1.104854345008369e-02f, - 7.812499995464418e-03f, - 5.524271724583683e-03f, - 3.906249997408239e-03f, - 2.762135862062757e-03f, - 1.953124998542134e-03f, - 1.381067930916839e-03f, - 9.765624991900747e-04f, - 6.905339654011486e-04f, - 4.882812495545411e-04f, - 3.452669826719394e-04f, - 2.441406247570224e-04f, - 1.726334913216520e-04f, - 1.220703123683871e-04f, - 8.631674565366727e-05f, - 6.103515617913153e-05f, - 4.315837282325419e-05f, - 3.051757808703478e-05f, - 2.157918640983742e-05f, - 1.525878904225187e-05f, - 1.078959320402385e-05f, - 7.629394520493171e-06f, - 5.394796601564505e-06f, - 3.814697259930213e-06f, - 2.697398300558537e-06f, - 1.907348629806920e-06f, - 1.348699150167414e-06f + 4.096000004076488e+03, + 2.896309378502504e+03, + 2.048000001868390e+03, + 1.448154689131149e+03, + 1.024000000849268e+03, + 7.240773445055215e+02, + 5.120000003821708e+02, + 3.620386722227349e+02, + 2.560000001698537e+02, + 1.810193360963542e+02, + 1.280000000743110e+02, + 9.050966804067060e+01, + 6.400000003184756e+01, + 4.525483401658203e+01, + 3.200000001326982e+01, + 2.262741700641438e+01, + 1.600000000530793e+01, + 1.131370850226887e+01, + 8.000000001990474e+00, + 5.656854250665277e+00, + 4.000000000663491e+00, + 2.828427125098059e+00, + 2.000000000165873e+00, + 1.414213562431740e+00, + 1.000000000000000e+00, + 7.071067811572251e-01, + 4.999999999585318e-01, + 3.535533905492901e-01, + 2.499999999585318e-01, + 1.767766952599838e-01, + 1.249999999688989e-01, + 8.838834762266132e-02, + 6.249999997926592e-02, + 4.419417380766535e-02, + 3.124999998704120e-02, + 2.209708690200002e-02, + 1.562499999222472e-02, + 1.104854345008369e-02, + 7.812499995464418e-03, + 5.524271724583683e-03, + 3.906249997408239e-03, + 2.762135862062757e-03, + 1.953124998542134e-03, + 1.381067930916839e-03, + 9.765624991900747e-04, + 6.905339654011486e-04, + 4.882812495545411e-04, + 3.452669826719394e-04, + 2.441406247570224e-04, + 1.726334913216520e-04, + 1.220703123683871e-04, + 8.631674565366727e-05, + 6.103515617913153e-05, + 4.315837282325419e-05, + 3.051757808703478e-05, + 2.157918640983742e-05, + 1.525878904225187e-05, + 1.078959320402385e-05, + 7.629394520493171e-06, + 5.394796601564505e-06, + 3.814697259930213e-06, + 2.697398300558537e-06, + 1.907348629806920e-06, + 1.348699150167414e-06 }; #endif @@ -241,14 +239,14 @@ const float step_size[NUM_CATEGORIES] = const float step_size_inverse_table[NUM_CATEGORIES] = { - 2.82805443e+00f, - 2.00000000e+00f, - 1.41422713e+00f, - 1.00000000e+00f, - 7.07113564e-01f, - 5.00000000e-01f, - 3.53556782e-01f, - 3.53556782e-01f + 2.82805443e+00, + 2.00000000e+00, + 1.41422713e+00, + 1.00000000e+00, + 7.07113564e-01, + 5.00000000e-01, + 3.53556782e-01, + 3.53556782e-01 }; #endif @@ -279,137 +277,137 @@ const float dead_zone[NUM_CATEGORIES] = #if !defined(G722_1_USE_FIXED_POINT) const float region_power_table[REGION_POWER_TABLE_SIZE] = { - 5.96046448e-08f, - 1.19209290e-07f, - 2.38418579e-07f, - 4.76837158e-07f, - 9.53674316e-07f, - 1.90734863e-06f, - 3.81469727e-06f, - 7.62939453e-06f, - 1.52587891e-05f, - 3.05175781e-05f, - 6.10351562e-05f, - 1.22070312e-04f, - 2.44140625e-04f, - 4.88281250e-04f, - 9.76562500e-04f, - 1.95312500e-03f, - 3.90625000e-03f, - 7.81250000e-03f, - 1.56250000e-02f, - 3.12500000e-02f, - 6.25000000e-02f, - 1.25000000e-01f, - 2.50000000e-01f, - 5.00000000e-01f, - 1.00000000e+00f, - 2.00000000e+00f, - 4.00000000e+00f, - 8.00000000e+00f, - 1.60000000e+01f, - 3.20000000e+01f, - 6.40000000e+01f, - 1.28000000e+02f, - 2.56000000e+02f, - 5.12000000e+02f, - 1.02400000e+03f, - 2.04800000e+03f, - 4.09600000e+03f, - 8.19200000e+03f, - 1.63840000e+04f, - 3.27680000e+04f, - 6.55360000e+04f, - 1.31072000e+05f, - 2.62144000e+05f, - 5.24288000e+05f, - 1.04857600e+06f, - 2.09715200e+06f, - 4.19430400e+06f, - 8.38860800e+06f, - 1.67772160e+07f, - 3.35544320e+07f, - 6.71088640e+07f, - 1.34217728e+08f, - 2.68435456e+08f, - 5.36870912e+08f, - 1.07374182e+09f, - 2.14748365e+09f, - 4.29496730e+09f, - 8.58993459e+09f, - 1.71798692e+10f, - 3.43597384e+10f, - 6.87194767e+10f, - 1.37438953e+11f, - 2.74877907e+11f, - 5.49755814e+11f + 5.96046448e-08, + 1.19209290e-07, + 2.38418579e-07, + 4.76837158e-07, + 9.53674316e-07, + 1.90734863e-06, + 3.81469727e-06, + 7.62939453e-06, + 1.52587891e-05, + 3.05175781e-05, + 6.10351562e-05, + 1.22070312e-04, + 2.44140625e-04, + 4.88281250e-04, + 9.76562500e-04, + 1.95312500e-03, + 3.90625000e-03, + 7.81250000e-03, + 1.56250000e-02, + 3.12500000e-02, + 6.25000000e-02, + 1.25000000e-01, + 2.50000000e-01, + 5.00000000e-01, + 1.00000000e+00, + 2.00000000e+00, + 4.00000000e+00, + 8.00000000e+00, + 1.60000000e+01, + 3.20000000e+01, + 6.40000000e+01, + 1.28000000e+02, + 2.56000000e+02, + 5.12000000e+02, + 1.02400000e+03, + 2.04800000e+03, + 4.09600000e+03, + 8.19200000e+03, + 1.63840000e+04, + 3.27680000e+04, + 6.55360000e+04, + 1.31072000e+05, + 2.62144000e+05, + 5.24288000e+05, + 1.04857600e+06, + 2.09715200e+06, + 4.19430400e+06, + 8.38860800e+06, + 1.67772160e+07, + 3.35544320e+07, + 6.71088640e+07, + 1.34217728e+08, + 2.68435456e+08, + 5.36870912e+08, + 1.07374182e+09, + 2.14748365e+09, + 4.29496730e+09, + 8.58993459e+09, + 1.71798692e+10, + 3.43597384e+10, + 6.87194767e+10, + 1.37438953e+11, + 2.74877907e+11, + 5.49755814e+11 }; const float region_power_table_boundary[REGION_POWER_TABLE_SIZE - 1] = { - 8.42936956e-08f, - 1.68587391e-07f, - 3.37174782e-07f, - 6.74349565e-07f, - 1.34869913e-06f, - 2.69739826e-06f, - 5.39479652e-06f, - 1.07895930e-05f, - 2.15791861e-05f, - 4.31583721e-05f, - 8.63167443e-05f, - 1.72633489e-04f, - 3.45266977e-04f, - 6.90533954e-04f, - 1.38106791e-03f, - 2.76213582e-03f, - 5.52427163e-03f, - 1.10485433e-02f, - 2.20970865e-02f, - 4.41941731e-02f, - 8.83883461e-02f, - 1.76776692e-01f, - 3.53553385e-01f, - 7.07106769e-01f, - 1.41421354e+00f, - 2.82842708e+00f, - 5.65685415e+00f, - 1.13137083e+01f, - 2.26274166e+01f, - 4.52548332e+01f, - 9.05096664e+01f, - 1.81019333e+02f, - 3.62038666e+02f, - 7.24077332e+02f, - 1.44815466e+03f, - 2.89630933e+03f, - 5.79261865e+03f, - 1.15852373e+04f, - 2.31704746e+04f, - 4.63409492e+04f, - 9.26818984e+04f, - 1.85363797e+05f, - 3.70727594e+05f, - 7.41455188e+05f, - 1.48291038e+06f, - 2.96582075e+06f, - 5.93164150e+06f, - 1.18632830e+07f, - 2.37265660e+07f, - 4.74531320e+07f, - 9.49062640e+07f, - 1.89812528e+08f, - 3.79625056e+08f, - 7.59250112e+08f, - 1.51850022e+09f, - 3.03700045e+09f, - 6.07400090e+09f, - 1.21480018e+10f, - 2.42960036e+10f, - 4.85920072e+10f, - 9.71840143e+10f, - 1.94368029e+11f, - 3.88736057e+11f + 8.42936956e-08, + 1.68587391e-07, + 3.37174782e-07, + 6.74349565e-07, + 1.34869913e-06, + 2.69739826e-06, + 5.39479652e-06, + 1.07895930e-05, + 2.15791861e-05, + 4.31583721e-05, + 8.63167443e-05, + 1.72633489e-04, + 3.45266977e-04, + 6.90533954e-04, + 1.38106791e-03, + 2.76213582e-03, + 5.52427163e-03, + 1.10485433e-02, + 2.20970865e-02, + 4.41941731e-02, + 8.83883461e-02, + 1.76776692e-01, + 3.53553385e-01, + 7.07106769e-01, + 1.41421354e+00, + 2.82842708e+00, + 5.65685415e+00, + 1.13137083e+01, + 2.26274166e+01, + 4.52548332e+01, + 9.05096664e+01, + 1.81019333e+02, + 3.62038666e+02, + 7.24077332e+02, + 1.44815466e+03, + 2.89630933e+03, + 5.79261865e+03, + 1.15852373e+04, + 2.31704746e+04, + 4.63409492e+04, + 9.26818984e+04, + 1.85363797e+05, + 3.70727594e+05, + 7.41455188e+05, + 1.48291038e+06, + 2.96582075e+06, + 5.93164150e+06, + 1.18632830e+07, + 2.37265660e+07, + 4.74531320e+07, + 9.49062640e+07, + 1.89812528e+08, + 3.79625056e+08, + 7.59250112e+08, + 1.51850022e+09, + 3.03700045e+09, + 6.07400090e+09, + 1.21480018e+10, + 2.42960036e+10, + 4.85920072e+10, + 9.71840143e+10, + 1.94368029e+11, + 3.88736057e+11 }; #endif diff --git a/libs/libg722_1/src/tables.h b/libs/libg722_1/src/tables.h index bf0aacba61..9b39979f18 100644 --- a/libs/libg722_1/src/tables.h +++ b/libs/libg722_1/src/tables.h @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: tables.h,v 1.7 2008/09/26 17:37:31 steveu Exp $ */ #define REGION_POWER_TABLE_SIZE 64 diff --git a/libs/libg722_1/src/utilities.c b/libs/libg722_1/src/utilities.c new file mode 100644 index 0000000000..71cac6caf4 --- /dev/null +++ b/libs/libg722_1/src/utilities.c @@ -0,0 +1,467 @@ +/* + * g722_1 - a library for the G.722.1 and Annex C codecs + * + * utilities.c + * + * Copyright (C) 2006 Steve Underwood + * + * 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. + */ + +#if defined(HAVE_CONFIG_H) +#include +#endif + +#include + +#if defined(G722_1_USE_MMX) +#include +#endif +#if defined(G722_1_USE_SSE) +#include +#endif +#if defined(G722_1_USE_SSE2) +#include +#endif +#if defined(G722_1_USE_SSE3) +#include +#include +#endif +#if defined(G722_1_USE_SSE4_1) +#include +#endif +#if defined(G722_1_USE_SSE4_2) +#include +#endif +#if defined(G722_1_USE_SSE4A) +#include +#endif +#if defined(G722_1_USE_SSE5) +#include +#endif + +#include "utilities.h" + +#if defined(G722_1_USE_FIXED_POINT) +void vec_copyi16(int16_t z[], const int16_t x[], int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i]; +} +/*- End of function --------------------------------------------------------*/ + +int32_t vec_dot_prodi16(const int16_t x[], const int16_t y[], int n) +{ + int32_t z; + +#if defined(__GNUC__) && defined(G722_1_USE_MMX) +#if defined(__x86_64__) + __asm__ __volatile__( + " emms;\n" + " pxor %%mm0,%%mm0;\n" + " leal -32(%%rsi,%%eax,2),%%edx;\n" /* edx = top - 32 */ + + " cmpl %%rdx,%%rsi;\n" + " ja 1f;\n" + + /* Work in blocks of 16 int16_t's until we are near the end */ + " .p2align 2;\n" + "2:\n" + " movq (%%rdi),%%mm1;\n" + " movq (%%rsi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + " movq 8(%%rdi),%%mm1;\n" + " movq 8(%%rsi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + " movq 16(%%rdi),%%mm1;\n" + " movq 16(%%rsi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + " movq 24(%%rdi),%%mm1;\n" + " movq 24(%%rsi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " addl $32,%%rsi;\n" + " addl $32,%%rdi;\n" + " cmpl %%rdx,%%rsi;\n" + " jbe 2b;\n" + + " .p2align 2;\n" + "1:\n" + " addl $24,%%rdx;\n" /* Now edx = top - 8 */ + " cmpl %%rdx,%%rsi;\n" + " ja 3f;\n" + + /* Work in blocks of 4 int16_t's until we are near the end */ + " .p2align 2;\n" + "4:\n" + " movq (%%rdi),%%mm1;\n" + " movq (%%rsi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " addl $8,%%rsi;\n" + " addl $8,%%rdi;\n" + " cmpl %%rdx,%%rsi;" + " jbe 4b;\n" + + " .p2align 2;\n" + "3:\n" + " addl $4,%%rdx;\n" /* Now edx = top - 4 */ + " cmpl %%rdx,%%rsi;\n" + " ja 5f;\n" + + /* Work in a block of 2 int16_t's */ + " movd (%%rdi),%%mm1;\n" + " movd (%%rsi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " addl $4,%%rsi;\n" + " addl $4,%%rdi;\n" + + " .p2align 2;\n" + "5:\n" + " addl $2,%%rdx;\n" /* Now edx = top - 2 */ + " cmpl %%rdx,%%rsi;\n" + " ja 6f;\n" + + /* Deal with the very last int16_t, when n is odd */ + " movswl (%%rdi),%%eax;\n" + " andl $65535,%%eax;\n" + " movd %%eax,%%mm1;\n" + " movswl (%%rsi),%%eax;\n" + " andl $65535,%%eax;\n" + " movd %%eax,%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " .p2align 2;\n" + "6:\n" + /* Merge the pieces of the answer */ + " movq %%mm0,%%mm1;\n" + " punpckhdq %%mm0,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + /* Et voila, eax has the final result */ + " movd %%mm0,%%eax;\n" + + " emms;\n" + : "=a" (z) + : "S" (x), "D" (y), "a" (n) + : "cc" + ); +#else + __asm__ __volatile__( + " emms;\n" + " pxor %%mm0,%%mm0;\n" + " leal -32(%%esi,%%eax,2),%%edx;\n" /* edx = top - 32 */ + + " cmpl %%edx,%%esi;\n" + " ja 1f;\n" + + /* Work in blocks of 16 int16_t's until we are near the end */ + " .p2align 2;\n" + "2:\n" + " movq (%%edi),%%mm1;\n" + " movq (%%esi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + " movq 8(%%edi),%%mm1;\n" + " movq 8(%%esi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + " movq 16(%%edi),%%mm1;\n" + " movq 16(%%esi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + " movq 24(%%edi),%%mm1;\n" + " movq 24(%%esi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " addl $32,%%esi;\n" + " addl $32,%%edi;\n" + " cmpl %%edx,%%esi;\n" + " jbe 2b;\n" + + " .p2align 2;\n" + "1:\n" + " addl $24,%%edx;\n" /* Now edx = top - 8 */ + " cmpl %%edx,%%esi;\n" + " ja 3f;\n" + + /* Work in blocks of 4 int16_t's until we are near the end */ + " .p2align 2;\n" + "4:\n" + " movq (%%edi),%%mm1;\n" + " movq (%%esi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " addl $8,%%esi;\n" + " addl $8,%%edi;\n" + " cmpl %%edx,%%esi;" + " jbe 4b;\n" + + " .p2align 2;\n" + "3:\n" + " addl $4,%%edx;\n" /* Now edx = top - 4 */ + " cmpl %%edx,%%esi;\n" + " ja 5f;\n" + + /* Work in a block of 2 int16_t's */ + " movd (%%edi),%%mm1;\n" + " movd (%%esi),%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " addl $4,%%esi;\n" + " addl $4,%%edi;\n" + + " .p2align 2;\n" + "5:\n" + " addl $2,%%edx;\n" /* Now edx = top - 2 */ + " cmpl %%edx,%%esi;\n" + " ja 6f;\n" + + /* Deal with the very last int16_t, when n is odd */ + " movswl (%%edi),%%eax;\n" + " andl $65535,%%eax;\n" + " movd %%eax,%%mm1;\n" + " movswl (%%esi),%%eax;\n" + " andl $65535,%%eax;\n" + " movd %%eax,%%mm2;\n" + " pmaddwd %%mm2,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + + " .p2align 2;\n" + "6:\n" + /* Merge the pieces of the answer */ + " movq %%mm0,%%mm1;\n" + " punpckhdq %%mm0,%%mm1;\n" + " paddd %%mm1,%%mm0;\n" + /* Et voila, eax has the final result */ + " movd %%mm0,%%eax;\n" + + " emms;\n" + : "=a" (z) + : "S" (x), "D" (y), "a" (n) + : "cc" + ); +#endif +#else + int i; + + z = 0; + for (i = 0; i < n; i++) + z += (int32_t) x[i]*(int32_t) y[i]; +#endif + return z; +} +/*- End of function --------------------------------------------------------*/ +#else +#if defined(__GNUC__) && defined(G722_1_USE_SSE2) +void vec_copyf(float z[], const float x[], int n) +{ + int i; + __m128 n1; + + if ((i = n & ~3)) + { + for (i -= 4; i >= 0; i -= 4) + { + n1 = _mm_loadu_ps(x + i); + _mm_storeu_ps(z + i, n1); + } + } + /* Now deal with the last 1 to 3 elements, which don't fill an SSE2 register */ + switch (n & 3) + { + case 3: + z[n - 3] = x[n - 3]; + case 2: + z[n - 2] = x[n - 2]; + case 1: + z[n - 1] = x[n - 1]; + } +} +#else +void vec_copyf(float z[], const float x[], int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i]; +} +#endif +/*- End of function --------------------------------------------------------*/ + +#if defined(__GNUC__) && defined(G722_1_USE_SSE2) +void vec_zerof(float z[], int n) +{ + int i; + __m128 n1; + + if ((i = n & ~3)) + { + n1 = _mm_setzero_ps(); + for (i -= 4; i >= 0; i -= 4) + _mm_storeu_ps(z + i, n1); + } + /* Now deal with the last 1 to 3 elements, which don't fill an SSE2 register */ + switch (n & 3) + { + case 3: + z[n - 3] = 0; + case 2: + z[n - 2] = 0; + case 1: + z[n - 1] = 0; + } +} +#else +void vec_zerof(float z[], int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = 0.0f; +} +#endif +/*- End of function --------------------------------------------------------*/ + +void vec_subf(float z[], const float x[], const float y[], int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i] - y[i]; +} +/*- End of function --------------------------------------------------------*/ + +#if defined(__GNUC__) && defined(G722_1_USE_SSE2) +void vec_mulf(float z[], const float x[], const float y[], int n) +{ + int i; + __m128 n1; + __m128 n2; + __m128 n3; + + if ((i = n & ~3)) + { + for (i -= 4; i >= 0; i -= 4) + { + n1 = _mm_loadu_ps(x + i); + n2 = _mm_loadu_ps(y + i); + n3 = _mm_mul_ps(n1, n2); + _mm_storeu_ps(z + i, n3); + } + } + /* Now deal with the last 1 to 3 elements, which don't fill an SSE2 register */ + switch (n & 3) + { + case 3: + z[n - 3] = x[n - 3]*y[n - 3]; + case 2: + z[n - 2] = x[n - 2]*y[n - 2]; + case 1: + z[n - 1] = x[n - 1]*y[n - 1]; + } +} +#else +void vec_mulf(float z[], const float x[], const float y[], int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i]*y[i]; +} +#endif +/*- End of function --------------------------------------------------------*/ + +#if defined(__GNUC__) && defined(G722_1_USE_SSE2) +float vec_dot_prodf(const float x[], const float y[], int n) +{ + int i; + float z; + __m128 n1; + __m128 n2; + __m128 n3; + __m128 n4; + + z = 0.0f; + if ((i = n & ~3)) + { + n4 = _mm_setzero_ps(); //sets sum to zero + for (i -= 4; i >= 0; i -= 4) + { + n1 = _mm_loadu_ps(x + i); + n2 = _mm_loadu_ps(y + i); + n3 = _mm_mul_ps(n1, n2); + n4 = _mm_add_ps(n4, n3); + } + 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 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; + float z; + + z = 0.0f; + for (i = 0; i < n; i++) + z += x[i]*y[i]; + return z; +} +/*- End of function --------------------------------------------------------*/ +#endif + +void vec_scalar_mulf(float z[], const float x[], float y, int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i]*y; +} +/*- End of function --------------------------------------------------------*/ + +void vec_scaled_addf(float z[], const float x[], float x_scale, const float y[], float y_scale, int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i]*x_scale + y[i]*y_scale; +} +/*- End of function --------------------------------------------------------*/ + +void vec_scaled_subf(float z[], const float x[], float x_scale, const float y[], float y_scale, int n) +{ + int i; + + for (i = 0; i < n; i++) + z[i] = x[i]*x_scale - y[i]*y_scale; +} +/*- End of function --------------------------------------------------------*/ +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/src/utilities.h b/libs/libg722_1/src/utilities.h new file mode 100644 index 0000000000..9d17103a16 --- /dev/null +++ b/libs/libg722_1/src/utilities.h @@ -0,0 +1,32 @@ +/* + * g722_1 - a library for the G.722.1 and Annex C codecs + * + * utilities.h + * + * Copyright (C) 2006 Steve Underwood + * + * 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. + */ + +#if !defined(__UTILITIES_H__) +#define __UTILITIES_H__ + +/* Prototypes for some general purpose signal and vector functions */ +#if defined(G722_1_USE_FIXED_POINT) +void vec_copyi16(int16_t z[], const int16_t x[], int n); +int32_t vec_dot_prodi16(const int16_t x[], const int16_t y[], int n); +#else +void vec_copyf(float z[], const float x[], int n); +void vec_zerof(float z[], int n); +void vec_subf(float z[], const float x[], const float y[], int n); +void vec_scalar_mulf(float z[], const float x[], float y, int n); +void vec_mulf(float z[], const float x[], const float y[], int n); +float vec_dot_prodf(const float x[], const float y[], int n); +void vec_scaled_addf(float z[], const float x[], float x_scale, const float y[], float y_scale, int n); +void vec_scaled_subf(float z[], const float x[], float x_scale, const float y[], float y_scale, int n); +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/test-data/Makefile.am b/libs/libg722_1/test-data/Makefile.am index 83ddb94843..0b27a6830d 100644 --- a/libs/libg722_1/test-data/Makefile.am +++ b/libs/libg722_1/test-data/Makefile.am @@ -15,8 +15,6 @@ ## 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: Makefile.am,v 1.2 2008/09/20 16:31:19 steveu Exp $ SUBDIRS = itu local diff --git a/libs/libg722_1/test-data/itu/Makefile.am b/libs/libg722_1/test-data/itu/Makefile.am index ae990154c0..df51ad0a07 100644 --- a/libs/libg722_1/test-data/itu/Makefile.am +++ b/libs/libg722_1/test-data/itu/Makefile.am @@ -15,8 +15,6 @@ ## 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: Makefile.am,v 1.3 2008/09/23 16:03:04 steveu Exp $ SUBDIRS = diff --git a/libs/libg722_1/test-data/local/Makefile.am b/libs/libg722_1/test-data/local/Makefile.am index a7aca423c5..142fb4cc4e 100644 --- a/libs/libg722_1/test-data/local/Makefile.am +++ b/libs/libg722_1/test-data/local/Makefile.am @@ -15,8 +15,6 @@ ## 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: Makefile.am,v 1.3 2008/09/24 16:12:52 steveu Exp $ SUBDIRS = diff --git a/libs/libg722_1/tests/Makefile.am b/libs/libg722_1/tests/Makefile.am index afad2f6433..aec0cecc29 100644 --- a/libs/libg722_1/tests/Makefile.am +++ b/libs/libg722_1/tests/Makefile.am @@ -15,8 +15,6 @@ ## 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: Makefile.am,v 1.4 2008/10/19 04:05:02 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) @@ -33,8 +31,8 @@ LIBDIR = -L$(top_builddir)/src noinst_PROGRAMS = g722_1_tests -noinst_HEADERS = itu_bit_stream.c \ +noinst_HEADERS = g192_bit_stream.h \ timing.h -g722_1_tests_SOURCES = g722_1_tests.c itu_bit_stream.c +g722_1_tests_SOURCES = g722_1_tests.c g192_bit_stream.c g722_1_tests_LDADD = $(LIBDIR) -lg722_1 diff --git a/libs/libg722_1/tests/g192_bit_stream.c b/libs/libg722_1/tests/g192_bit_stream.c new file mode 100644 index 0000000000..36a853c6cc --- /dev/null +++ b/libs/libg722_1/tests/g192_bit_stream.c @@ -0,0 +1,177 @@ +/* + * broadvoice - a library for the BroadVoice 16 and 32 codecs + * + * g192_bit_stream.c + * + * Copyright 2008-2009 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. + */ + +/*! \file */ + +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "g192_bit_stream.h" + +#if !defined(FALSE) +#define FALSE 0 +#endif +#if !defined(TRUE) +#define TRUE (!FALSE) +#endif + +enum +{ + G192_FRAME_ERASURE = 0x6B20, + G192_FRAME_SYNC_1 = 0x6B21, + G192_FRAME_SYNC_2 = 0x6B22, + G192_FRAME_SYNC_3 = 0x6B23, + G192_FRAME_SYNC_4 = 0x6B24, + G192_FRAME_SYNC_5 = 0x6B25, + G192_FRAME_SYNC_6 = 0x6B26, + G192_FRAME_SYNC_7 = 0x6B27, + G192_FRAME_SYNC_8 = 0x6B28, + G192_FRAME_SYNC_9 = 0x6B29, + G192_FRAME_SYNC_10 = 0x6B2A, + G192_FRAME_SYNC_11 = 0x6B2B, + G192_FRAME_SYNC_12 = 0x6B2C, + G192_FRAME_SYNC_13 = 0x6B2D, + G192_FRAME_SYNC_14 = 0x6B2E, + G192_FRAME_SYNC_15 = 0x6B2F, + G192_HARD_ZERO = 0x7F, + G192_INDETERMINATE = 0x00, + G192_HARD_ONE = 0x81 +}; + +int itu_codec_bitstream_write(const uint8_t out_data[], + int number_of_bits, + int mode, + FILE *fp_bitstream) +{ + int i; + int j; + int bit_count; + int number_of_bytes; + uint8_t packed_word; + int16_t out_array[2 + number_of_bits + 7]; + + number_of_bytes = (number_of_bits + 7)/8; + if (mode == ITU_CODEC_BITSTREAM_PACKED) + { + return fwrite(out_data, 1, number_of_bytes, fp_bitstream); + } + j = 0; + out_array[j++] = G192_FRAME_SYNC_1; + out_array[j++] = number_of_bits; + for (i = 0; i < number_of_bytes; i++) + { + packed_word = out_data[i]; + for (bit_count = 7; bit_count >= 0; bit_count--) + out_array[j++] = ((packed_word >> bit_count) & 1) ? G192_HARD_ONE : G192_HARD_ZERO; + } + + return fwrite(out_array, sizeof(int16_t), number_of_bits + 2, fp_bitstream); +} +/*- End of function --------------------------------------------------------*/ + +int itu_codec_bitstream_read(uint8_t in_data[], + int16_t *erasure, + int number_of_bits, + int mode, + FILE *fp_bitstream) +{ + int i; + int j; + int bit_pos; + int nsamp; + int limit; + int rem; + int len; + int erased_frame; + int16_t packed_word; + int16_t bit; + int16_t in_array[2 + number_of_bits]; + + *erasure = FALSE; + if (mode == ITU_CODEC_BITSTREAM_PACKED) + { + nsamp = fread(in_data, 1, number_of_bits/8, fp_bitstream); + if (nsamp <= 0) + return -1; + return nsamp*8; + } + + nsamp = fread(in_array, sizeof(int16_t), 2, fp_bitstream); + if (nsamp < 2) + return -1; + if (in_array[0] < G192_FRAME_ERASURE || in_array[0] > G192_FRAME_SYNC_15) + { + *erasure = TRUE; + return 0; + } + erased_frame = (in_array[0] == G192_FRAME_ERASURE); + len = in_array[1]; + if (len > number_of_bits) + { + *erasure = TRUE; + return 0; + } + nsamp = fread(in_array, sizeof(int16_t), len, fp_bitstream); + if (nsamp != len) + { + *erasure = TRUE; + return nsamp; + } + + limit = (nsamp + 7)/8; + for (i = 0, j = 0; i < limit; i++) + { + packed_word = 0; + rem = (i == (limit - 1)) ? (limit*8 - nsamp) : 0; + for (bit_pos = 7; bit_pos >= rem; bit_pos--) + { + bit = in_array[j++]; + if (bit >= 0x0001 && bit <= G192_HARD_ZERO) + { + /* Its a zero */ + } + else if (bit >= G192_HARD_ONE && bit <= 0x00FF) + { + /* Its a one */ + packed_word |= (1 << bit_pos); + } + else + { + /* Bad bit */ + *erasure = 1; + } + } + in_data[i] = packed_word; + } + if (erased_frame) + *erasure = TRUE; + return nsamp; +} +/*- End of function --------------------------------------------------------*/ +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/tests/g192_bit_stream.h b/libs/libg722_1/tests/g192_bit_stream.h new file mode 100644 index 0000000000..1948aa2e80 --- /dev/null +++ b/libs/libg722_1/tests/g192_bit_stream.h @@ -0,0 +1,75 @@ +/* + * broadvoice - a library for the BroadVoice 16 and 32 codecs + * + * g192_bit_stream.h + * + * Copyright 2008-2009 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. + */ + +/*! \file */ + +#if !defined(_G192_BIT_STREAM_H_) +#define _G192_BIT_STREAM_H_ + +/*! \page g192_bit_stream_page ITU G.192 codec bit stream handling +\section g192_bit_stream_page_sec_1 What does it do? + +\section g192_bit_stream_page_sec_2 How does it work? +*/ + +enum +{ + ITU_CODEC_BITSTREAM_PACKED = 0, + ITU_CODEC_BITSTREAM_G192 = 1 +}; + +#if defined(__cplusplus) +extern "C" +{ +#endif + +/*! \brief Write a frame of data to an output file. + \param out_data The buffer for the data to be written. + \param number_of_bits The number of bits to be written. + \param mode 0 = continuous, 1 = ITU G.192 codec bitstream format. + \param fp_bitstream The file context to be written to. + \return The number of words written. */ +int itu_codec_bitstream_write(const uint8_t out_data[], + int number_of_bits, + int mode, + FILE *fp_bitstream); + +/*! \brief Read a frame of data from an input file. + \param in_data The buffer for the data to be read. + \param p_erasure Set to TRUE if there is a frame erasure, else set to FALSE. + \param number_of_bits The number of bits to be read. + \param mode 0 = continuous, 1 = ITU G.192 codec bitstream format. + \param fp_bitstream The file context to be read from. + \return The number of words read. */ +int itu_codec_bitstream_read(uint8_t in_data[], + int16_t *p_erasure, + int number_of_bits, + int mode, + FILE *fp_bitstream); + +#if defined(__cplusplus) +} +#endif + +#endif +/*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/tests/g722_1_tests.c b/libs/libg722_1/tests/g722_1_tests.c index 9f0b9519f9..7cc6befce1 100644 --- a/libs/libg722_1/tests/g722_1_tests.c +++ b/libs/libg722_1/tests/g722_1_tests.c @@ -6,14 +6,12 @@ * Adapted by Steve Underwood from the reference * code supplied with ITU G.722.1, which is: * - * © 2004 Polycom, Inc. + * (C) 2004 Polycom, Inc. * All rights reserved. * * 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. - * - * $Id: g722_1_tests.c,v 1.14 2008/11/21 15:30:22 steveu Exp $ */ /*! \file */ @@ -36,7 +34,7 @@ #include #include "timing.h" -#include "itu_bit_stream.h" +#include "g192_bit_stream.h" typedef struct { @@ -227,7 +225,7 @@ static void parse_command_line(char *argv[], coder_control_t *control) } else if (strcasecmp(*argv, "i") == 0) { - control->encoded_format = ITU_CODEC_BITSTREAM_ITU; + control->encoded_format = ITU_CODEC_BITSTREAM_G192; printf("Encoding format = ITU-format bitstream\n"); } else diff --git a/libs/libg722_1/tests/itu_bit_stream.c b/libs/libg722_1/tests/itu_bit_stream.c deleted file mode 100644 index d07ef374eb..0000000000 --- a/libs/libg722_1/tests/itu_bit_stream.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * g722_1 - a library for the G.722.1 and Annex C codecs - * - * itu_bit_stream.c - * - * Adapted by Steve Underwood from the reference - * code supplied with ITU G.722.1, which is: - * - * © 2004 Polycom, Inc. - * All rights reserved. - * - * 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. - * - * $Id: itu_bit_stream.c,v 1.6 2008/11/21 15:30:22 steveu Exp $ - */ - -/*! \file */ - -#if defined(HAVE_CONFIG_H) -#include "config.h" -#endif - -#include -#include -#include -#include - -#include "itu_bit_stream.h" - -static const int16_t frame_start = 0x6B21; -static const int16_t erased_frame_start = 0x6B20; -static const int16_t one = 0x0081; -static const int16_t zero = 0x007F; - -void itu_codec_bitstream_write(const uint8_t out_data[], - int number_of_bits, - int mode, - FILE *fp_bitstream) -{ - int i; - int j; - int bit_count; - int number_of_bytes; - uint8_t packed_word; - int16_t out_array[2 + number_of_bits + 7]; - - number_of_bytes = (number_of_bits + 7)/8; - if (mode == ITU_CODEC_BITSTREAM_PACKED) - { - fwrite(out_data, 1, number_of_bytes, fp_bitstream); - return; - } - j = 0; - out_array[j++] = frame_start; - out_array[j++] = number_of_bits; - for (i = 0; i < number_of_bytes; i++) - { - packed_word = out_data[i]; - for (bit_count = 7; bit_count >= 0; bit_count--) - out_array[j++] = ((packed_word >> bit_count) & 1) ? one : zero; - } - - fwrite(out_array, sizeof(int16_t), number_of_bits + 2, fp_bitstream); -} -/*- End of function --------------------------------------------------------*/ - -int itu_codec_bitstream_read(uint8_t in_data[], - int16_t *p_frame_error_flag, - int number_of_bits, - int mode, - FILE *fp_bitstream) -{ - int i; - int j; - int bit_count; - int nsamp; - int len; - int erased_frame; - int16_t packed_word; - int16_t bit; - int16_t in_array[2 + number_of_bits]; - - if (mode == ITU_CODEC_BITSTREAM_PACKED) - return fread(in_data, 1, number_of_bits/8, fp_bitstream)*8; - - nsamp = fread(in_array, sizeof(int16_t), 2, fp_bitstream); - if (nsamp < 2) - return -1; - if (in_array[0] != frame_start && in_array[0] != erased_frame_start) - { - *p_frame_error_flag = 1; - return 0; - } - erased_frame = (in_array[0] == erased_frame_start); - len = in_array[1]; - if (len > number_of_bits) - { - *p_frame_error_flag = 1; - return 0; - } - nsamp = fread(in_array, sizeof(int16_t), len, fp_bitstream); - if (nsamp != len) - { - *p_frame_error_flag = 1; - return nsamp; - } - *p_frame_error_flag = 0; - - for (i = 0, j = 0; i < nsamp/8; i++) - { - packed_word = 0; - bit_count = 7; - while (bit_count >= 0) - { - bit = in_array[j++]; - if (bit == zero) - bit = 0; - else if (bit == one) - bit = 1; - else - { - /* Bad bit */ - bit = 1; - *p_frame_error_flag = 1; - /* printf("read_ITU_format: bit not zero or one: %4x\n", bit); */ - } - packed_word = (packed_word << 1) | bit; - bit_count--; - } - in_data[i] = packed_word; - } - if (erased_frame) - *p_frame_error_flag = 1; - return nsamp; -} -/*- End of function --------------------------------------------------------*/ -/*- End of file ------------------------------------------------------------*/ diff --git a/libs/libg722_1/tests/regression_tests.sh.in b/libs/libg722_1/tests/regression_tests.sh.in index 6b52213b58..4be36b2008 100644 --- a/libs/libg722_1/tests/regression_tests.sh.in +++ b/libs/libg722_1/tests/regression_tests.sh.in @@ -16,9 +16,6 @@ # 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: regression_tests.sh.in,v 1.4 2008/11/21 15:30:22 steveu Exp $ -# STDOUT_DEST=xyzzy STDERR_DEST=xyzzy2 @@ -33,7 +30,7 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_out_32000.itu RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests E failed! + echo g722_1_tests encode failed! exit $RETVAL fi ./g722_1_tests E I 24000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_in.pcm $TMP_FILE @@ -41,17 +38,17 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_out_24000.itu RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests E failed! + echo g722_1_tests encode failed! exit $RETVAL fi -echo g722_1_tests E completed OK +echo g722_1_tests encode completed OK ./g722_1_tests D I 24000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_out_24000.itu $TMP_FILE diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_out_24000.pcm RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests D failed! + echo g722_1_tests decode failed! exit $RETVAL fi ./g722_1_tests D I 32000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_out_32000.itu $TMP_FILE @@ -59,7 +56,7 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_out_32000.pcm RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests D failed! + echo g722_1_tests decode failed! exit $RETVAL fi @@ -68,7 +65,7 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_out_24000_fe.pcm RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests D failed! + echo g722_1_tests decode failed! exit $RETVAL fi ./g722_1_tests D I 32000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_in_32000_fe.itu $TMP_FILE @@ -76,28 +73,28 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_out_32000_fe.pcm RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests D failed! + echo g722_1_tests decode failed! exit $RETVAL fi -echo g722_1_tests D completed OK +echo g722_1_tests decode completed OK ./g722_1_tests E I 32000 16000 ../test-data/local/short_wb_voice.wav $TMP_FILE RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests E failed! + echo g722_1_tests encode failed! exit $RETVAL fi -echo g722_1_tests E completed OK +echo g722_1_tests encode completed OK ./g722_1_tests D I 32000 16000 $TMP_FILE test.au RETVAL=$? if [ $RETVAL != 0 ] then - echo g722_1_tests D failed! + echo g722_1_tests decode failed! exit $RETVAL fi -echo g722_1_tests D completed OK +echo g722_1_tests decode completed OK echo echo All regression tests successfully completed diff --git a/libs/libg722_1/tests/timing.h b/libs/libg722_1/tests/timing.h index 3fb1b3cc74..f95f3b8df1 100644 --- a/libs/libg722_1/tests/timing.h +++ b/libs/libg722_1/tests/timing.h @@ -1,5 +1,5 @@ /* - * SpanDSP - a series of DSP components for telephony + * g722_1 - a library for the G.722.1 and Annex C codecs * * timing.h - Provide access to the Pentium/Athlon TSC timer register * @@ -21,8 +21,6 @@ * 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: timing.h,v 1.1 2008/10/17 15:17:39 steveu Exp $ */ #if !defined(_TIMING_H_) diff --git a/libs/libg722_1/unpack_g722_1_data.sh b/libs/libg722_1/unpack_g722_1_data.sh index 75741e0dd1..f8b85f4d30 100755 --- a/libs/libg722_1/unpack_g722_1_data.sh +++ b/libs/libg722_1/unpack_g722_1_data.sh @@ -16,9 +16,6 @@ # 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: unpack_g722_1_data.sh,v 1.2 2008/09/26 12:09:29 steveu Exp $ -# ITUDATA="../../../T-REC-G.722.1-200505-I!!SOFT-ZST-E.zip" diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index 45387b8585..aba4eef0eb 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -4275,6 +4275,7 @@ static void process_state_iv_eor(t30_state_t *s, const uint8_t *msg, int len) break; case T30_ERR: /* TODO: Continue with the next message if MPS or EOM? */ + s->current_status = T30_ERR_RETRYDCN; s->timer_t5 = 0; send_dcn(s); break; @@ -4319,6 +4320,7 @@ static void process_state_iv_eor_rnr(t30_state_t *s, const uint8_t *msg, int len break; case T30_ERR: /* TODO: Continue with the next message if MPS or EOM? */ + s->current_status = T30_ERR_RETRYDCN; s->timer_t5 = 0; send_dcn(s); break; diff --git a/libs/win32/libg722_1/libg722_1.vcproj b/libs/win32/libg722_1/libg722_1.vcproj index e3101a22b9..a7a9530d05 100644 --- a/libs/win32/libg722_1/libg722_1.vcproj +++ b/libs/win32/libg722_1/libg722_1.vcproj @@ -342,6 +342,10 @@ RelativePath="..\..\libg722_1\src\tables.c" > + + + + + @@ -143,6 +144,7 @@ + diff --git a/libs/win32/libg722_1/libg722_1.vcxproj.filters b/libs/win32/libg722_1/libg722_1.vcxproj.filters index 855a60fae6..d54ad6e890 100644 --- a/libs/win32/libg722_1/libg722_1.vcxproj.filters +++ b/libs/win32/libg722_1/libg722_1.vcxproj.filters @@ -60,6 +60,9 @@ Source Files + + Source Files + @@ -92,5 +95,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 840a06c204..bcd3c0aee2 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -246,6 +246,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_close(_Inout_ switch_media */ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove_all(_In_ switch_core_session_t *session); +SWITCH_DECLARE(switch_status_t) switch_core_media_bug_enumerate(switch_core_session_t *session, switch_stream_handle_t *stream); + /*! \brief Read a frame from the bug \param bug the bug to read from diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 0ede8e638f..0bd2a8b2b0 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -216,6 +216,7 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg); char *tts_name; char *voice_name; + SWITCH_DECLARE(int) insertFile(const char *file, const char *insert_file, int sample_point); SWITCH_DECLARE(int) answer(); SWITCH_DECLARE(int) preAnswer(); SWITCH_DECLARE(void) hangup(const char *cause = "normal_clearing"); diff --git a/src/include/switch_types.h b/src/include/switch_types.h index e04f437eb3..bb5f59865f 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -791,6 +791,7 @@ typedef enum { SWITCH_MESSAGE_INDICATE_UDPTL_MODE, SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS, SWITCH_MESSAGE_INDICATE_JITTER_BUFFER, + SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; @@ -1096,6 +1097,8 @@ typedef enum { CF_RECOVERED, CF_JITTERBUFFER, CF_DIALPLAN, + CF_BLOCK_BROADCAST_UNTIL_MEDIA, + CF_CNG_PLC, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ CF_FLAG_MAX } switch_channel_flag_t; diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 2deb437948..8daaace7f3 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -2226,6 +2226,40 @@ SWITCH_STANDARD_API(uuid_deflect) return SWITCH_STATUS_SUCCESS; } +#define UUID_RECOVERY_REFRESH_SYNTAX " " +SWITCH_STANDARD_API(uuid_recovery_refresh) +{ + switch_core_session_t *tsession = NULL; + char *uuid = NULL, *text = NULL; + + if (!zstr(cmd) && (uuid = strdup(cmd))) { + if ((text = strchr(uuid, ' '))) { + *text++ = '\0'; + } + } + + if (zstr(uuid) || zstr(text)) { + stream->write_function(stream, "-USAGE: %s\n", UUID_RECOVERY_REFRESH_SYNTAX); + } else { + if ((tsession = switch_core_session_locate(uuid))) { + switch_core_session_message_t msg = { 0 }; + + /* Tell the channel to recovery_refresh the call */ + msg.from = __FILE__; + msg.string_arg = text; + msg.message_id = SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH; + switch_core_session_receive_message(tsession, &msg); + stream->write_function(stream, "+OK:%s\n", msg.string_reply); + switch_core_session_rwunlock(tsession); + } else { + stream->write_function(stream, "-ERR No Such Channel %s!\n", uuid); + } + } + + switch_safe_free(uuid); + return SWITCH_STATUS_SUCCESS; +} + #define SCHED_TRANSFER_SYNTAX "[+]