A bunch of tweaks to the G.722.1 codec

This commit is contained in:
Steve Underwood 2010-12-26 13:25:03 +08:00
parent d24af1e1c2
commit 5d5485708d
48 changed files with 1402 additions and 1189 deletions

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## 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_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@ -26,6 +24,7 @@ noinst_SCRIPTS = g722_1.spec
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = autogen.sh \ EXTRA_DIST = autogen.sh \
g722_1.pc \
g722_1.spec \ g722_1.spec \
unpack_g722_1_data.sh \ unpack_g722_1_data.sh \
wrapper.xsl \ wrapper.xsl \
@ -50,6 +49,9 @@ SUBDIRS = src $(MAYBE_DOC) $(MAYBE_TESTS)
DIST_SUBDIRS = src doc tests test-data DIST_SUBDIRS = src doc tests test-data
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = g722_1.pc
faq: faq.xml faq: faq.xml
cd faq ; xsltproc ../wrapper.xsl ../faq.xml cd faq ; xsltproc ../wrapper.xsl ../faq.xml

View File

@ -16,11 +16,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # 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 if [ "x$UNAME" = "xFreeBSD" ]; then
echo "" echo ""

View File

@ -15,17 +15,11 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # 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 # @start 1
AC_INIT 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_compiler_vendor.m4)
m4_include(config/ax_check_real_file.m4) m4_include(config/ax_check_real_file.m4)
m4_include(config/ax_fixed_point_machine.m4) m4_include(config/ax_fixed_point_machine.m4)
@ -111,6 +105,22 @@ else
CXXFLAGS=${CXXFLAGS-"-g -O2"} CXXFLAGS=${CXXFLAGS-"-g -O2"}
fi 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_CONST
AC_C_INLINE AC_C_INLINE
AC_C_VOLATILE AC_C_VOLATILE
@ -190,7 +200,7 @@ AC_CHECK_HEADERS([audiofile.h])
AC_LANG([C]) AC_LANG([C])
if test "${build}" = "${host}" if test "${build}" == "${host}"
then then
case "${host}" in case "${host}" in
x86_64-*) x86_64-*)
@ -270,6 +280,7 @@ sun)
COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS" COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
fi fi
COMP_VENDOR_LDFLAGS= COMP_VENDOR_LDFLAGS=
REMOVE_FROM_VAR(CFLAGS, -Xc)
;; ;;
*) *)
COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes" 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 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]) 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="#define G722_1_USE_FIXED_POINT 1"
fixed = "yes"
G722_1_VECTORS_FOR_TESTS="fixed" G722_1_VECTORS_FOR_TESTS="fixed"
else else
AX_FIXED_POINT_MACHINE([$host], AX_FIXED_POINT_MACHINE([$host],
[ [AC_DEFINE([G722_1_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point])
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="#define G722_1_USE_FIXED_POINT 1"
fixed = "yes"
],
[G722_1_USE_FIXED_POINT="#undef G722_1_USE_FIXED_POINT"]) [G722_1_USE_FIXED_POINT="#undef G722_1_USE_FIXED_POINT"])
G722_1_VECTORS_FOR_TESTS="floating" G722_1_VECTORS_FOR_TESTS="floating"
fi fi
AM_CONDITIONAL([COND_FIXED], [test "$fixed" = "yes"])
AX_MISALIGNED_ACCESS_FAILS([$host], AX_MISALIGNED_ACCESS_FAILS([$host],
[AC_DEFINE([G722_1_MISALIGNED_ACCESS_FAILS], [1], [Do not expect a misaligned memory access to work correctly]) [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"], G722_1_MISALIGNED_ACCESS_FAILS="#define G722_1_MISALIGNED_ACCESS_FAILS 1"],
@ -363,6 +368,7 @@ AC_CONFIG_FILES([Makefile
src/Makefile src/Makefile
src/g722_1.h src/g722_1.h
tests/Makefile tests/Makefile
g722_1.pc
g722_1.spec]) g722_1.spec])
AC_CONFIG_FILES([tests/regression_tests.sh], [chmod +x tests/regression_tests.sh]) AC_CONFIG_FILES([tests/regression_tests.sh], [chmod +x tests/regression_tests.sh])

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## 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 MAINTAINERCLEANFILES = Makefile.in

View File

@ -47,14 +47,13 @@ rm -rf %{buildroot}
%{_libdir}/libg722_1.so.* %{_libdir}/libg722_1.so.*
%{_datadir}/libg722_1
%files devel %files devel
%defattr(-,root,root,-) %defattr(-,root,root,-)
%doc doc/api %doc doc/api
%{_includedir}/g722_1.h %{_includedir}/g722_1.h
%{_includedir}/g722_1 %{_includedir}/g722_1
%{_libdir}/libg722_1.so %{_libdir}/libg722_1.so
%{_libdir}/pkgconfig/g722_1.pc
%post -p /sbin/ldconfig %post -p /sbin/ldconfig

View File

@ -15,18 +15,19 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## 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_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
MAINTAINERCLEANFILES = Makefile.in 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.dsp \
libg722_1.sln \ libg722_1.2005.sln \
libg722_1.vcproj \ libg722_1.2008.sln \
libg722_1.2005.vcproj \
libg722_1.2008.vcproj \
msvc/gettimeofday.c \ msvc/gettimeofday.c \
msvc/inttypes.h \ msvc/inttypes.h \
msvc/tgmath.h \ msvc/tgmath.h \
@ -36,13 +37,16 @@ EXTRA_DIST = g722_1/version.h.in \
msvc/msvcproj.head \ msvc/msvcproj.head \
msvc/msvcproj.foot \ msvc/msvcproj.foot \
msvc/vc8proj.head \ msvc/vc8proj.head \
msvc/vc8proj.foot msvc/vc8proj.foot \
msvc/vc9proj.head \
msvc/vc9proj.foot
INCLUDES = -I$(top_builddir) INCLUDES = -I$(top_builddir)
lib_LTLIBRARIES = libg722_1.la lib_LTLIBRARIES = libg722_1.la
libg722_1_la_SOURCES = bitstream.c \ libg722_1_la_SOURCES = basop32.c \
bitstream.c \
coef2sam.c \ coef2sam.c \
common.c \ common.c \
commonf.c \ commonf.c \
@ -55,11 +59,9 @@ libg722_1_la_SOURCES = bitstream.c \
encoderf.c \ encoderf.c \
huff_tab.c \ huff_tab.c \
sam2coef.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) 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 \ nobase_include_HEADERS = g722_1/g722_1.h \
@ -76,10 +78,10 @@ noinst_HEADERS = basop32.h \
defs.h \ defs.h \
huff_tab.h \ huff_tab.h \
sam2coef.h \ sam2coef.h \
tables.h tables.h \
utilities.h
noinst_PROGRAMS = make_dct4_tables \ noinst_PROGRAMS = make_dct4_tables
make_tables
dct4.$(OBJEXT): dct4.h dct4.$(OBJEXT): dct4.h
@ -88,6 +90,9 @@ dct4.lo: dct4.h
dct4.h: make_dct4_tables$(EXEEXT) dct4.h: make_dct4_tables$(EXEEXT)
./make_dct4_tables$(EXEEXT) >dct4.h ./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) #coef2sam.h: make_tables$(EXEEXT)
# ./make_tables$(EXEEXT) coef2sam >coef2samx.h # ./make_tables$(EXEEXT) coef2sam >coef2samx.h
@ -95,13 +100,15 @@ dct4.h: make_dct4_tables$(EXEEXT)
# ./make_tables$(EXEEXT) sam2coef >sam2coefx.h # ./make_tables$(EXEEXT) sam2coef >sam2coefx.h
DSP = libg722_1.dsp 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 WIN32SOURCES = $(libg722_1_la_SOURCES) msvc/gettimeofday.c
WIN32HEADERS = $(nobase_include_HEADERS) g722_1.h WIN32HEADERS = $(nobase_include_HEADERS) g722_1.h
DSPOUT = | awk '{printf("%s\r\n", $$0)}' >> $(DSP) 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 $(DSP): msvc/msvcproj.head msvc/msvcproj.foot Makefile.am
echo "creating $(DSP)" echo "creating $(DSP)"
@ -124,26 +131,38 @@ $(DSP): msvc/msvcproj.head msvc/msvcproj.foot Makefile.am
echo "# End Group" $(DSPOUT); \ echo "# End Group" $(DSPOUT); \
cat $(srcdir)/msvc/msvcproj.foot $(DSPOUT) ) cat $(srcdir)/msvc/msvcproj.foot $(DSPOUT) )
$(VCPROJ): msvc/vc8proj.head msvc/vc8proj.foot Makefile.am $(VCPROJ8): msvc/vc8proj.head msvc/vc8proj.foot Makefile.am
echo "creating $(VCPROJ)" echo "creating $(VCPROJ8)"
@(cp $(srcdir)/msvc/vc8proj.head $(VCPROJ); \ @(cp $(srcdir)/msvc/vc8proj.head $(VCPROJ8); \
for file in $(WIN32SOURCES); do \ for file in $(WIN32SOURCES); do \
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \ myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \
echo "<File RelativePath=\""$$myfile"\"></File>" $(VCPROJOUT8); \
done; \ done; \
echo "</Filter><Filter Name=\"Header Files\">" $(VCPROJOUT); \ echo "</Filter><Filter Name=\"Header Files\">" $(VCPROJOUT8); \
for file in $(WIN32HEADERS); do \ for file in $(WIN32HEADERS); do \
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \ myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \
echo "<File RelativePath=\""$$myfile"\"></File>" $(VCPROJOUT8); \
done; \ 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 "<File RelativePath=\""$$myfile"\"></File>" $(VCPROJOUT9); \
done; \
echo "</Filter><Filter Name=\"Header Files\">" $(VCPROJOUT9); \
for file in $(WIN32HEADERS); do \
myfile=`echo $$file | sed -e 's|/|\\\\|g'`; \
echo "<File RelativePath=\""$$myfile"\"></File>" $(VCPROJOUT9); \
done; \
cat $(srcdir)/msvc/vc9proj.foot $(VCPROJOUT9) )
dist-hook: g722_1/version.h
g722_1/version.h: g722_1/version.h:
NOWDATE=`date --utc +"%Y%m%d"` ; \ NOWDATE=`date --utc +"%Y%m%d"` ; \
NOWTIME=`date --utc +"%H%M%S"` ; \ NOWTIME=`date --utc +"%H%M%S"` ; \
sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \ sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \
<g722_1/version.h.in >g722_1/version.h <$(srcdir)/g722_1/version.h.in >$@
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.in >g722_1/version.h

View File

@ -9,8 +9,6 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: basop32.c,v 1.5 2008/09/22 13:08:31 steveu Exp $
*/ */
/*! \file */ /*! \file */

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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) #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 --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
int16_t shl(int16_t var1, int16_t var2); /* Short shift left, 1 */ 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 */ 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_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_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*/ 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 norm_s(int16_t var1); /* Short norm, 15 */
int16_t div_s(int16_t var1, int16_t var2); /* Short division, 18 */ 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 norm_l(int32_t L_var1); /* Long norm, 30 */
#endif #endif

View File

@ -8,8 +8,6 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: bitstream.c,v 1.2 2008/10/17 13:18:21 steveu Exp $
*/ */
/*! \file */ /*! \file */

View File

@ -8,8 +8,6 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: bitstream.h,v 1.2 2008/10/17 13:18:21 steveu Exp $
*/ */
/*! \file */ /*! \file */

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: coef2sam.c,v 1.10 2008/10/02 11:43:54 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -29,18 +27,16 @@
#include "defs.h" #include "defs.h"
#include "coef2sam.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.
The "Reversed MLT" is an overlapped block transform which uses even symmetry It is thus similar to a MLT which uses odd symmetry on the left, even symmetry
on the left, odd symmetry on the right and a Type IV DCT as the block transform. on the right and a Type IV DST as the block transform. In fact, it is equivalent
It is thus similar to a MLT which uses odd symmetry on the left, even symmetry to reversing the order of the samples, performing an MLT and then negating all
on the right and a Type IV DST as the block transform. In fact, it is equivalent the even-numbered coefficients. */
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) #if defined(G722_1_USE_FIXED_POINT)
void rmlt_coefs_to_samples(int16_t coefs[], 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); new_samples[i] = shl(new_samples[i], mag_shift);
} }
if (dct_length == DCT_LENGTH) win = (dct_length == DCT_LENGTH) ? rmlt_to_samples_window : max_rmlt_to_samples_window;
win = rmlt_to_samples_window;
else
win = max_rmlt_to_samples_window;
last = half_dct_length - 1; last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++) for (i = 0; i < half_dct_length; i++)
{ {
/* Get the first half of the windowed samples */ /* Get the first half of the windowed samples */
sum = 0L; sum = L_mult(win[i], new_samples[last - i]);
sum = L_mac(sum, win[i], new_samples[last - i]);
sum = L_mac(sum, win[dct_length - i - 1], old_samples[i]); sum = L_mac(sum, win[dct_length - i - 1], old_samples[i]);
out_samples[i] = xround(L_shl(sum, 2)); out_samples[i] = xround(L_shl(sum, 2));
/* Get the second half of the windowed samples */ /* Get the second half of the windowed samples */
sum = 0L; sum = L_mult(win[half_dct_length + i], new_samples[i]);
sum = L_mac(sum, win[half_dct_length + i], new_samples[i]);
sum = L_mac(sum, negate(win[last - i]), old_samples[last - i]); sum = L_mac(sum, negate(win[last - i]), old_samples[last - i]);
out_samples[half_dct_length + i] = xround(L_shl(sum, 2)); out_samples[half_dct_length + i] = xround(L_shl(sum, 2));
} }
/* Save the second half of the new samples for /* Save the second half of the new samples for
next time, when they will be the old samples. */ next time, when they will be the old samples. */
for (i = 0; i < half_dct_length; i++) vec_copyi16(old_samples, &new_samples[half_dct_length], half_dct_length);
old_samples[i] = new_samples[half_dct_length + i];
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
#else #else
@ -116,10 +106,7 @@ void rmlt_coefs_to_samples(float coefs[],
/* Perform a Type IV (inverse) DCT on the coefficients */ /* Perform a Type IV (inverse) DCT on the coefficients */
dct_type_iv(coefs, new_samples, dct_length); dct_type_iv(coefs, new_samples, dct_length);
if (dct_length == DCT_LENGTH) win = (dct_length == DCT_LENGTH) ? rmlt_to_samples_window : max_rmlt_to_samples_window;
win = rmlt_to_samples_window;
else
win = max_rmlt_to_samples_window;
last = half_dct_length - 1; last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++) 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 /* Save the second half of the new samples for next time, when they will
be the old samples. */ be the old samples. */
for (i = 0; i < half_dct_length; i++) vec_copyf(old_samples, &new_samples[half_dct_length], half_dct_length);
old_samples[i] = new_samples[half_dct_length + i];
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
#endif #endif

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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) #if defined(G722_1_USE_FIXED_POINT)

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: common.c,v 1.6 2008/09/30 14:06:39 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -38,41 +36,7 @@ static void compute_raw_pow_categories(int16_t *power_categories,
int16_t number_of_regions, int16_t number_of_regions,
int16_t offset); int16_t offset);
/**************************************************************************************** /* Compute a series of categorizations */
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
-------|--------------|----------------|----------------
****************************************************************************************/
void categorize(int16_t number_of_available_bits, void categorize(int16_t number_of_available_bits,
int16_t number_of_regions, int16_t number_of_regions,
int16_t num_categorization_control_possibilities, 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 /* 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 consumption per region. We compensate for this by pretending we have fewer
available bits. */ available bits. */
if (number_of_regions == NUMBER_OF_REGIONS) frame_size = (number_of_regions == NUMBER_OF_REGIONS) ? DCT_LENGTH : MAX_DCT_LENGTH;
frame_size = DCT_LENGTH;
else
frame_size = MAX_DCT_LENGTH;
temp = sub(number_of_available_bits, frame_size); temp = sub(number_of_available_bits, frame_size);
if (temp > 0) if (temp > 0)
@ -114,45 +75,7 @@ void categorize(int16_t number_of_available_bits,
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*************************************************************************** /* Compute the power_categories and the category balances */
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
-------|--------------|----------------|----------------
***************************************************************************/
void comp_powercat_and_catbalance(int16_t *power_categories, void comp_powercat_and_catbalance(int16_t *power_categories,
int16_t *category_balances, int16_t *category_balances,
int16_t *rms_index, 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 num_categorization_control_possibilities,
int16_t offset) int16_t offset)
{ {
int16_t expected_number_of_code_bits; int16_t expected_number_of_code_bits;
int16_t region; int16_t region;
int16_t max_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++) 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]]); 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++) for (region = 0; region < number_of_regions; region++)
{ {
max_rate_categories[region] = power_categories[region]; max_rate_categories[region] = power_categories[region];
@ -277,42 +198,16 @@ void comp_powercat_and_catbalance(int16_t *power_categories,
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*************************************************************************** /* Calculate the the category offset. This is the shift required
Function: calc_offset To get the most out of the number of available bits. A binary
type search is used to find the offset. */
Syntax: offset=calc_offset(int16_t *rms_index,int16_t number_of_regions,int16_t available_bits) int16_t 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)
{ {
int16_t answer; int16_t answer;
int16_t delta; int16_t delta;
int16_t test_offset; int16_t test_offset;
int16_t region,j; int16_t region;
int16_t j;
int16_t power_cats[MAX_NUMBER_OF_REGIONS]; int16_t power_cats[MAX_NUMBER_OF_REGIONS];
int16_t bits; int16_t bits;
int16_t offset; 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 --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*************************************************************************** /* Compute the power categories given the offset
Function: compute_raw_pow_categories This is kind of redundant since they were already computed
in calc_offset to determine the offset. */
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
-------|--------------|----------------|----------------
***************************************************************************/
static void compute_raw_pow_categories(int16_t *power_categories, int16_t *rms_index, int16_t number_of_regions, int16_t 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; int16_t region;

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: commonf.c,v 1.11 2008/09/30 14:06:39 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -34,9 +32,7 @@
#if !defined(G722_1_USE_FIXED_POINT) #if !defined(G722_1_USE_FIXED_POINT)
/**************************************************************************************** /* Compute a series of categorizations */
Description: Computes a series of categorizations
****************************************************************************************/
void categorize(int number_of_regions, void categorize(int number_of_regions,
int number_of_available_bits, int number_of_available_bits,
int rms_index[MAX_NUMBER_OF_REGIONS], int rms_index[MAX_NUMBER_OF_REGIONS],

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C)2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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) #if defined(HAVE_CONFIG_H)
@ -29,6 +27,7 @@
#include "g722_1/g722_1.h" #include "g722_1/g722_1.h"
#include "defs.h" #include "defs.h"
#include "utilities.h"
#if !defined(G722_1_USE_FIXED_POINT) #if !defined(G722_1_USE_FIXED_POINT)
@ -52,9 +51,7 @@ static const cos_msin_t *cos_msin_table[] =
cos_msin_640 cos_msin_640
}; };
/********************************************************************************* /* Discrete Cosine Transform, Type IV */
Description: Discrete Cosine Transform, Type IV
*********************************************************************************/
void dct_type_iv(float input[], float output[], int dct_length) void dct_type_iv(float input[], float output[], int dct_length)
{ {
float buffer_a[MAX_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_low;
float *in_ptr_high; float *in_ptr_high;
float *next_in_base; float *next_in_base;
float *out_ptr_low; float *out_ptr;
float *out_ptr_high;
float *next_out_base; float *next_out_base;
float *out_buffer; float *out_buffer;
float *in_buffer; float *in_buffer;
float *buffer_swap; float *buffer_swap;
float *fptr0; float *fptr0;
const float *fptr2;
const float *core_a;
float in_val_low; float in_val_low;
float in_val_high; float in_val_high;
float cos_even; float cos_even;
float cos_odd; float cos_odd;
float msin_even; float msin_even;
float msin_odd; float msin_odd;
float sum; const float *fptr2;
const float *core_a;
const cos_msin_t **table_ptr_ptr; const cos_msin_t **table_ptr_ptr;
const cos_msin_t *cos_msin_ptr; const cos_msin_t *cos_msin_ptr;
int set_span; 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--) for (sets_left = set_count; sets_left > 0; sets_left--)
{ {
/* Set up output pointers for the current set */ /* Set up output pointers for the current set */
out_ptr_low = next_out_base; out_ptr = next_out_base;
next_out_base += set_span; next_out_base += set_span;
out_ptr_high = next_out_base;
/* Loop over all the butterflies in the current set */ /* 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_low = *in_ptr++;
in_val_high = *in_ptr++; in_val_high = *in_ptr++;
*out_ptr_low++ = in_val_low + in_val_high; out_ptr[i] = in_val_low + in_val_high;
*--out_ptr_high = 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. /* Decide which buffers to use as input and output next time.
Except for the first time (when the input buffer is the Except for the first time (when the input buffer is the
subroutine input) we just alternate the local buffers. */ subroutine input) we just alternate the local buffers. */
in_buffer = out_buffer; in_buffer = out_buffer;
if (out_buffer == buffer_a) out_buffer = (out_buffer == buffer_a) ? buffer_b : buffer_a;
out_buffer = buffer_b;
else
out_buffer = buffer_a;
} }
/* Do dct_size/10 ten-point transforms */ /* 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; fptr2 = core_a;
for (k = 0; k < CORE_SIZE; k++) for (k = 0; k < CORE_SIZE; k++)
{ {
sum = 0; buffer_swap[k] = vec_dot_prodf(fptr0, fptr2, CORE_SIZE);
for (i = 0; i < CORE_SIZE; i++)
sum += fptr0[i]*fptr2[i];
fptr2 += CORE_SIZE; fptr2 += CORE_SIZE;
buffer_swap[k] = sum;
} }
fptr0 += CORE_SIZE; fptr0 += CORE_SIZE;
buffer_swap += 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 */ /* Initialization for the loop over sets at the current size */
set_span = dct_length >> set_count_log; set_span = dct_length >> set_count_log;
set_count = 1 << set_count_log; set_count = 1 << set_count_log;
next_in_base = in_buffer; next_in_base = in_buffer;
if (set_count_log == 0) next_out_base = (set_count_log == 0) ? output : out_buffer;
next_out_base = output; table_ptr_ptr++;
else
next_out_base = out_buffer;
++table_ptr_ptr;
/* Loop over all the sets of this size */ /* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--) 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 */ /* Set up the pointers for the current set */
in_ptr_low = next_in_base; in_ptr_low = next_in_base;
in_ptr_high = in_ptr_low + (set_span >> 1); in_ptr_high = in_ptr_low + (set_span >> 1);
next_in_base += set_span; out_ptr = next_out_base;
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
cos_msin_ptr = *table_ptr_ptr; cos_msin_ptr = *table_ptr_ptr;
/* Loop over all the butterfly pairs in the current set */ /* 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; cos_even = cos_msin_ptr[i].cosine;
msin_even = (*cos_msin_ptr++).minus_sine; msin_even = cos_msin_ptr[i].minus_sine;
*out_ptr_low++ = cos_even * *in_ptr_low - msin_even * *in_ptr_high; cos_odd = cos_msin_ptr[i + 1].cosine;
*--out_ptr_high = msin_even * *in_ptr_low++ + cos_even * *in_ptr_high++; msin_odd = cos_msin_ptr[i + 1].minus_sine;
out_ptr[i] = cos_even*in_ptr_low[i] - msin_even*in_ptr_high[i];
cos_odd = (*cos_msin_ptr).cosine; out_ptr[set_span - 1 - i] = msin_even*in_ptr_low[i] + cos_even*in_ptr_high[i];
msin_odd = (*cos_msin_ptr++).minus_sine; out_ptr[i + 1] = cos_odd*in_ptr_low[i + 1] + msin_odd*in_ptr_high[i + 1];
*out_ptr_low++ = cos_odd * *in_ptr_low + msin_odd * *in_ptr_high; out_ptr[set_span - 2 - i] = msin_odd*in_ptr_low[i + 1] - cos_odd*in_ptr_high[i + 1];
*--out_ptr_high = msin_odd * *in_ptr_low++ - cos_odd * *in_ptr_high++;
} }
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 */ /* Swap input and output buffers for next time */

View File

@ -6,29 +6,23 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_a.c,v 1.8 2008/09/30 14:06:39 steveu Exp $
*/ */
/********************************************************************************* /* Discrete Cosine Transform, Type IV used for MLT
* Filename: dct_type_iv_a.c
* The basis functions are
* Purpose: Discrete Cosine Transform, Type IV used for MLT
* cos(PI*(t+0.5)*(k+0.5)/block_length)
* The basis functions are
* for time t and basis function number k. Due to the symmetry of the
* cos(PI*(t+0.5)*(k+0.5)/block_length) expression in t and k, it is clear that the forward and inverse transforms
* are the same. */
* 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 */ /*! \file */
@ -47,51 +41,31 @@
#include "dct4_a.h" #include "dct4_a.h"
/********************************************************************************* /* Discrete Cosine Transform, Type IV used for MLT */
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
*********************************************************************************/
void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length) void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length)
{ {
int16_t buffer_a[MAX_DCT_LENGTH]; int16_t buffer_a[MAX_DCT_LENGTH];
int16_t buffer_b[MAX_DCT_LENGTH]; int16_t buffer_b[MAX_DCT_LENGTH];
int16_t buffer_c[MAX_DCT_LENGTH]; int16_t buffer_c[MAX_DCT_LENGTH];
int16_t *in_ptr; int16_t *in_ptr;
int16_t *in_ptr_low; int16_t *out_ptr;
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 *in_buffer; int16_t *in_buffer;
int16_t *out_buffer;
int16_t *buffer_swap; int16_t *buffer_swap;
int16_t in_val_low; int16_t in_val_low;
int16_t in_val_high; int16_t in_val_high;
int16_t out_val_low;
int16_t out_val_high;
int16_t in_low_even; int16_t in_low_even;
int16_t in_low_odd; int16_t in_low_odd;
int16_t in_high_even; int16_t in_high_even;
int16_t in_high_odd; 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 *pair_ptr;
int16_t cos_even; int16_t cos_even;
int16_t cos_odd; int16_t cos_odd;
int16_t msin_even; int16_t msin_even;
int16_t msin_odd; int16_t msin_odd;
int16_t neg_cos_odd;
int16_t neg_msin_even;
int32_t sum; int32_t sum;
int16_t set_span; int16_t set_span;
int16_t half_span;
int16_t set_count; int16_t set_count;
int16_t set_count_log; int16_t set_count_log;
int16_t pairs_left; 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 i;
int16_t k; int16_t k;
int16_t index; int16_t index;
const cos_msin_t **table_ptr_ptr;
const cos_msin_t *cos_msin_ptr;
int16_t temp; int16_t temp;
int32_t acca; int32_t acca;
int16_t dct_length_log; 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 */ /* Do the sum/difference butterflies, the first part of
/* converting one N-point transform into N/2 two-point */ converting one N-point transform into N/2 two-point
/* transforms, where N = 1 << DCT_LENGTH_LOG. = 64/128 */ transforms, where N = 1 << DCT_LENGTH_LOG. = 64/128 */
if (dct_length == DCT_LENGTH) if (dct_length == DCT_LENGTH)
{ {
dct_length_log = DCT_LENGTH_LOG; 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; index = 0L;
in_buffer = input; in_buffer = input;
out_buffer = buffer_a; 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++) for (set_count_log = 0; set_count_log <= temp; set_count_log++)
{ {
/* Initialization for the loop over sets at the current size */ /* Loop over all the sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ set_span = dct_length >> set_count_log;
set_span = shr(dct_length, set_count_log); set_count = 1 << set_count_log;
half_span = set_span >> 1;
set_count = shl(1, set_count_log);
in_ptr = in_buffer; 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--) 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 */ /* Loop over all the butterflies in the current set */
do for (i = 0; i < half_span; i++)
{ {
in_val_low = *in_ptr++; in_val_low = *in_ptr++;
in_val_high = *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;
acca = L_sub(in_val_low, in_val_high); acca = L_add(in_val_low, in_val_high);
acca = L_shr(acca, 1); out_ptr[i] = (int16_t) L_shr(acca, 1);
out_val_high = (int16_t) acca;
*out_ptr_low++ = out_val_low; acca = L_sub(in_val_low, in_val_high);
*--out_ptr_high = out_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. */ /* Decide which buffers to use as input and output next time.
/* Except for the first time (when the input buffer is the */ Except for the first time (when the input buffer is the
/* subroutine input) we just alternate the local buffers. */ subroutine input) we just alternate the local buffers. */
in_buffer = out_buffer; in_buffer = out_buffer;
if (out_buffer == buffer_a) out_buffer = (out_buffer == buffer_a) ? buffer_b : buffer_a;
out_buffer = buffer_b;
else
out_buffer = buffer_a;
index = add(index, 1); index = add(index, 1);
} }
/* Do N/2 two-point transforms, */ /* Do N/2 two-point transforms, where N = 1 << DCT_LENGTH_LOG */
/* where N = 1 << DCT_LENGTH_LOG */
pair_ptr = in_buffer; pair_ptr = in_buffer;
buffer_swap = buffer_c; buffer_swap = buffer_c;
temp = sub(dct_length_log, 1); temp = 1 << (dct_length_log - 1);
temp = shl(1, temp);
for (pairs_left = temp; pairs_left > 0; pairs_left--) for (pairs_left = temp; pairs_left > 0; pairs_left--)
{ {
for (k = 0; k < CORE_SIZE; k++) 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]); sum = L_mac(sum, pair_ptr[i], dct_core_a[i][k]);
buffer_swap[k] = xround(sum); buffer_swap[k] = xround(sum);
} }
/* Address arithmetic */
pair_ptr += CORE_SIZE; pair_ptr += CORE_SIZE;
buffer_swap += 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); temp = sub(dct_length_log, 2);
for (set_count_log = temp; set_count_log >= 0; set_count_log--) for (set_count_log = temp; set_count_log >= 0; set_count_log--)
{ {
/* Initialization for the loop over sets at the current size */ /* Loop over all the sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ set_span = dct_length >> set_count_log;
set_span = shr(dct_length, set_count_log); set_count = 1 << set_count_log;
set_count = shl(1, set_count_log); half_span = set_span >> 1;
next_in_base = in_buffer; in_ptr = in_buffer;
next_out_base = (set_count_log == 0) ? output : out_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--) 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 */ /* 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[i];
in_low_even = *in_ptr_low++; in_low_odd = in_ptr[i + 1];
in_low_odd = *in_ptr_low++; in_high_even = in_ptr[half_span + i];
in_high_even = *in_ptr_high++; in_high_odd = in_ptr[half_span + i + 1];
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;
sum = 0L; cos_even = cos_msin_ptr[i].cosine;
sum = L_mac(sum, cos_even, in_low_even); msin_even = cos_msin_ptr[i].minus_sine;
neg_msin_even = negate(msin_even); cos_odd = cos_msin_ptr[i + 1].cosine;
sum = L_mac(sum, neg_msin_even, in_high_even); msin_odd = cos_msin_ptr[i + 1].minus_sine;
out_low_even = xround(sum);
sum = 0L; sum = L_mult(cos_even, in_low_even);
sum = L_mac(sum, msin_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); 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_mult(cos_odd, in_low_odd);
sum = L_mac(sum, cos_odd, in_low_odd);
sum = L_mac(sum, msin_odd, in_high_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_mult(msin_odd, in_low_odd);
sum = L_mac(sum, msin_odd, in_low_odd); sum = L_mac(sum, -cos_odd, in_high_odd);
neg_cos_odd = negate(cos_odd); out_ptr[set_span - 2 - i] = xround(sum);
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;
} }
while (out_ptr_low < out_ptr_high); in_ptr += set_span;
out_ptr += set_span;
} }
/* Swap input and output buffers for next time */ /* Swap input and output buffers for next time */
buffer_swap = in_buffer; buffer_swap = in_buffer;
in_buffer = out_buffer; in_buffer = out_buffer;
out_buffer = buffer_swap; out_buffer = buffer_swap;
table_ptr_ptr++;
} }
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_a.h,v 1.4 2008/09/25 15:56:31 steveu Exp $
*/ */
typedef struct typedef struct

View File

@ -6,29 +6,23 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_s.c,v 1.8 2008/09/30 14:06:39 steveu Exp $
*/ */
/******************************************************************************** /* Discrete Cosine Transform, Type IV used for inverse MLT
* Filename: dct_type_iv_s.c
* The basis functions are
* Purpose: Discrete Cosine Transform, Type IV used for inverse MLT
* cos(PI*(t+0.5)*(k+0.5)/block_length)
* The basis functions are
* for time t and basis function number k. Due to the symmetry of the
* cos(PI*(t+0.5)*(k+0.5)/block_length) expression in t and k, it is clear that the forward and inverse transforms
* are the same. */
* 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 */ /*! \file */
@ -45,67 +39,51 @@
#if defined(G722_1_USE_FIXED_POINT) #if defined(G722_1_USE_FIXED_POINT)
#include "dct4_s.h" #include "dct4_s.h"
#include "utilities.h"
/******************************************************************************** /* Discrete Cosine Transform, Type IV used for inverse MLT */
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
********************************************************************************/
void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length) void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length)
{ {
int16_t buffer_a[MAX_DCT_LENGTH]; int16_t buffer_a[MAX_DCT_LENGTH];
int16_t buffer_b[MAX_DCT_LENGTH]; int16_t buffer_b[MAX_DCT_LENGTH];
int16_t buffer_c[MAX_DCT_LENGTH]; int16_t buffer_c[MAX_DCT_LENGTH];
int16_t *in_ptr; int16_t *in_ptr;
int16_t *in_ptr_low; int16_t *out_ptr;
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 *in_buffer; int16_t *in_buffer;
int16_t *out_buffer;
int16_t *buffer_swap; int16_t *buffer_swap;
int16_t in_val_low; int16_t in_val_low;
int16_t in_val_high; int16_t in_val_high;
int16_t out_val_low;
int16_t out_val_high;
int16_t in_low_even; int16_t in_low_even;
int16_t in_low_odd; int16_t in_low_odd;
int16_t in_high_even; int16_t in_high_even;
int16_t in_high_odd; 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 *pair_ptr;
int16_t cos_even; int16_t cos_even;
int16_t cos_odd; int16_t cos_odd;
int16_t msin_even; int16_t msin_even;
int16_t msin_odd; int16_t msin_odd;
int16_t set_span; int16_t set_span;
int16_t half_span;
int16_t set_count; int16_t set_count;
int16_t set_count_log; int16_t set_count_log;
int16_t pairs_left; int16_t pairs_left;
int16_t sets_left; int16_t sets_left;
int16_t i; int16_t i;
int16_t j;
int16_t k; int16_t k;
int16_t index; int16_t index;
int16_t dummy; int16_t dummy;
int16_t dct_length_log;
int32_t sum; int32_t sum;
int32_t acca;
const cos_msin_t **table_ptr_ptr; const cos_msin_t **table_ptr_ptr;
const cos_msin_t *cos_msin_ptr; const cos_msin_t *cos_msin_ptr;
int32_t acca;
int16_t temp;
int16_t dct_length_log;
const int16_t *dither_ptr; const int16_t *dither_ptr;
/* Do the sum/difference butterflies, the first part of */ /* Do the sum/difference butterflies, the first part of
/* converting one N-point transform into 32 - 10 point transforms */ converting one N-point transform into 32 - 10 point transforms
/* transforms, where N = 1 << DCT_LENGTH_LOG. */ transforms, where N = 1 << DCT_LENGTH_LOG. */
if (dct_length == DCT_LENGTH) if (dct_length == DCT_LENGTH)
{ {
dct_length_log = DCT_LENGTH_LOG; 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; index = 0;
i = 0; i = 0;
j = 0;
for (set_count_log = 0; set_count_log <= dct_length_log - 2; set_count_log++) 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 */ /* Loop over all the sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ set_span = dct_length >> set_count_log;
set_span = shr(dct_length, set_count_log); set_count = 1 << set_count_log;
half_span = set_span >> 1;
set_count = shl(1, set_count_log);
in_ptr = in_buffer; in_ptr = in_buffer;
next_out_base = out_buffer; out_ptr = out_buffer;
/* Loop over all the sets of this size */ if (index < 1)
temp = sub(index, 1);
if (temp < 0)
{ {
for (sets_left = set_count; sets_left > 0; sets_left--) 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 */ /* Loop over all the butterflies in the current set */
do for (i = 0; i < half_span; i++)
{ {
in_val_low = *in_ptr++; in_val_low = *in_ptr++;
in_val_high = *in_ptr++; in_val_high = *in_ptr++;
/* BEST METHOD OF GETTING RID OF BIAS, BUT COMPUTATIONALLY UNPLEASANT */ dummy = add(in_val_low, dither_ptr[j++]);
/* ALTERNATIVE METHOD, SMEARS BIAS OVER THE ENTIRE FRAME, COMPUTATIONALLY SIMPLEST. */
/* IF THIS WORKS, IT'S PREFERABLE */
dummy = add(in_val_low, dither_ptr[i++]);
acca = L_add(dummy, in_val_high); 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++]); dummy = add(in_val_low, dither_ptr[j++]);
acca = L_add(dummy, -in_val_high); acca = L_sub(dummy, in_val_high);
out_val_high = (int16_t) L_shr(acca, 1); out_ptr[set_span - 1 - i] = (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 */
} }
while (out_ptr_low < out_ptr_high); out_ptr += set_span;
} }
} }
else else
{ {
for (sets_left = set_count; sets_left > 0; sets_left--) 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 */ /* Loop over all the butterflies in the current set */
do for (i = 0; i < half_span; i++)
{ {
in_val_low = *in_ptr++; in_val_low = *in_ptr++;
in_val_high = *in_ptr++; in_val_high = *in_ptr++;
out_val_low = add(in_val_low, in_val_high); out_ptr[i] = add(in_val_low, in_val_high);
out_val_high = add(in_val_low, negate(in_val_high)); out_ptr[set_span - 1 - i] = sub(in_val_low, in_val_high);
*out_ptr_low++ = out_val_low;
*--out_ptr_high = out_val_high;
} }
while (out_ptr_low < out_ptr_high); out_ptr += set_span;
} }
} }
/* Decide which buffers to use as input and output next time. */ /* Decide which buffers to use as input and output next time.
/* Except for the first time (when the input buffer is the */ Except for the first time (when the input buffer is the
/* subroutine input) we just alternate the local buffers. */ subroutine input) we just alternate the local buffers. */
in_buffer = out_buffer; in_buffer = out_buffer;
out_buffer = (out_buffer == buffer_a) ? buffer_b : buffer_a;
if (out_buffer == buffer_a) index++;
out_buffer = buffer_b;
else
out_buffer = buffer_a;
index = add(index, 1);
} }
/* Do 32 - 10 point transforms */ /* 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; buffer_swap += CORE_SIZE;
} }
for (i = 0; i < dct_length; i++) vec_copyi16(in_buffer, buffer_c, dct_length);
in_buffer[i] = buffer_c[i];
table_ptr_ptr = s_cos_msin_table; 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--) 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 */ /* Initialization for the loop over sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */ set_span = dct_length >> set_count_log;
set_span = shr(dct_length, set_count_log); set_count = 1 << set_count_log;
half_span = set_span >> 1;
set_count = shl(1, set_count_log); in_ptr = in_buffer;
next_in_base = in_buffer; out_ptr = (set_count_log == 0) ? output : out_buffer;
if (set_count_log == 0) cos_msin_ptr = *table_ptr_ptr++;
next_out_base = output;
else
next_out_base = out_buffer;
/* Loop over all the sets of this size */ /* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--) 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 */ /* 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_even = in_ptr[i];
in_low_odd = *in_ptr_low++; in_low_odd = in_ptr[i + 1];
in_high_even = *in_ptr_high++; in_high_even = in_ptr[half_span + i];
in_high_odd = *in_ptr_high++; in_high_odd = in_ptr[half_span + i + 1];
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;
sum = 0L; cos_even = cos_msin_ptr[i].cosine;
sum = L_mac(sum, cos_even, in_low_even); msin_even = cos_msin_ptr[i].minus_sine;
sum = L_mac(sum, negate(msin_even), in_high_even); cos_odd = cos_msin_ptr[i + 1].cosine;
out_low_even = xround(L_shl(sum, 1)); msin_odd = cos_msin_ptr[i + 1].minus_sine;
sum = 0L; sum = L_mult(cos_even, in_low_even);
sum = L_mac(sum, msin_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); 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_mult(cos_odd, in_low_odd);
sum = L_mac(sum, cos_odd, in_low_odd);
sum = L_mac(sum, msin_odd, in_high_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_mult(msin_odd, in_low_odd);
sum = L_mac(sum, msin_odd, in_low_odd); sum = L_mac(sum, -cos_odd, in_high_odd);
sum = L_mac(sum, negate(cos_odd), in_high_odd); out_ptr[set_span - 2 - i] = xround(L_shl(sum, 1));
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;
} }
while (out_ptr_low < out_ptr_high); in_ptr += set_span;
out_ptr += set_span;
} }
/* Swap input and output buffers for next time */ /* Swap input and output buffers for next time */
buffer_swap = in_buffer; buffer_swap = in_buffer;
in_buffer = out_buffer; in_buffer = out_buffer;
out_buffer = buffer_swap; out_buffer = buffer_swap;
index++;
index = add(index, 1);
table_ptr_ptr++;
} }
/* ADD IN BIAS FOR OUTPUT */ /* Add in bias for output */
if (dct_length == DCT_LENGTH) 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]); sum = L_add(output[i], syn_bias_7khz[i]);
acca = L_sub(sum, 32767); output[i] = saturate(sum);
if (acca > 0)
sum = 32767L;
acca = L_add(sum, 32768L);
if (acca < 0)
sum = -32768L;
output[i] = (int16_t) sum;
} }
} }
} }

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_s.h,v 1.4 2008/09/25 15:56:31 steveu Exp $
*/ */
typedef struct typedef struct
@ -196,11 +194,9 @@ static const int16_t max_dither[MAX_DCT_LENGTH] =
for (index = 0;index < length;index++) for (index = 0;index < length;index++)
{ {
angle = scale * ((double)index + 0.5); angle = scale * ((double)index + 0.5);
table[index].cosine = (short) (FTOI((18427)* cos(angle))); table[index].cosine = (int16_t) (FTOI((18427)* cos(angle)));
table[index].minus_sine = (short) (FTOI((18427)*(-sin(angle)))); table[index].minus_sine = (int16_t) (FTOI((18427)*(-sin(angle))));
} }
********************************************************************************/ ********************************************************************************/
static const cos_msin_t s_cos_msin_2[DCT_LENGTH_DIV_32] = static const cos_msin_t s_cos_msin_2[DCT_LENGTH_DIV_32] =

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C)2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: decoder.c,v 1.21 2008/11/21 15:30:22 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -94,9 +92,7 @@ static void decoder(g722_1_decode_state_t *s,
int16_t old_decoder_mlt_coefs[], int16_t old_decoder_mlt_coefs[],
int frame_error_flag); int frame_error_flag);
/*************************************************************************** /* Decodes the out_words into MLT coefs using G.722.1 Annex C */
Description: Decodes the out_words into mlt coefs using G.722.1 Annex C
***************************************************************************/
void decoder(g722_1_decode_state_t *s, void decoder(g722_1_decode_state_t *s,
int16_t number_of_regions, int16_t number_of_regions,
int16_t decoder_mlt_coefs[], 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 absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
int16_t decoder_power_categories[MAX_NUMBER_OF_REGIONS]; int16_t decoder_power_categories[MAX_NUMBER_OF_REGIONS];
int16_t decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]; 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_bits;
int16_t num_categorization_control_possibilities; int16_t num_categorization_control_possibilities;
int16_t number_of_coefs; int16_t number_of_coefs;
int16_t number_of_valid_coefs; int16_t number_of_valid_coefs;
uint16_t categorization_control;
number_of_valid_coefs = number_of_regions*REGION_SIZE; number_of_valid_coefs = number_of_regions*REGION_SIZE;
@ -184,9 +180,7 @@ void decoder(g722_1_decode_state_t *s,
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*************************************************************************** /* Recover differential_region_power_index from code bits */
Description: Recover differential_region_power_index from code bits
***************************************************************************/
static void decode_envelope(g722_1_decode_state_t *s, static void decode_envelope(g722_1_decode_state_t *s,
int16_t number_of_regions, int16_t number_of_regions,
int16_t *decoder_region_standard_deviation, 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))) while ((i >= 0) && ((temp1 >= 0) || (temp2 > 0)))
{ {
i = sub(i, 1); i = sub(i, 1);
temp = shr(temp, 1); temp >>= 1;
max_index = sub(max_index, 2); max_index = sub(max_index, 2);
temp1 = sub(temp, 8); temp1 = sub(temp, 8);
temp2 = sub(max_index, 28); 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) if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
{ {
temp = shl(index, 1); temp = shl(index, 1);
index = (int16_t) *(decoder_table_ptr + temp); index = decoder_table_ptr[temp];
} }
else else
{ {
temp = shl(index, 1); temp = shl(index, 1);
index = (int16_t) *(decoder_table_ptr + temp + 1); index = decoder_table_ptr[temp + 1];
} }
s->number_of_bits_left--; 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) if ((signs_index & bit) == 0)
decoder_mlt_value = negate(decoder_mlt_value); decoder_mlt_value = negate(decoder_mlt_value);
bit = shr(bit, 1); bit >>= 1;
} }
*decoder_mlt_ptr++ = decoder_mlt_value; *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) if (*decoder_mlt_ptr == 0)
{ {
*decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos; *decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos;
random_word = shr(random_word, 1); random_word >>= 1;
} }
/* pointer arithmetic */ /* pointer arithmetic */
decoder_mlt_ptr++; 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) if (*decoder_mlt_ptr == 0)
{ {
*decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos; *decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos;
random_word = shr(random_word,1); random_word >>= 1;
} }
/* pointer arithmetic */ /* pointer arithmetic */
decoder_mlt_ptr++; decoder_mlt_ptr++;

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: decoderf.c,v 1.22 2008/11/21 15:30:22 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -33,6 +31,7 @@
#include "huff_tab.h" #include "huff_tab.h"
#include "tables.h" #include "tables.h"
#include "bitstream.h" #include "bitstream.h"
#include "utilities.h"
#if !defined(G722_1_USE_FIXED_POINT) #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 absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
int decoder_power_categories[MAX_NUMBER_OF_REGIONS]; int decoder_power_categories[MAX_NUMBER_OF_REGIONS];
int decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]; int decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1];
int rate_control;
int num_categorization_control_bits; int num_categorization_control_bits;
int num_categorization_control_possibilities; int num_categorization_control_possibilities;
int number_of_coefs; int number_of_coefs;
int number_of_valid_coefs; int number_of_valid_coefs;
int rmlt_scale_factor; int rmlt_scale_factor;
int rate_control;
number_of_valid_coefs = s->number_of_regions*REGION_SIZE; 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) if (category == NUM_CATEGORIES - 1)
{ {
noifillpos = standard_deviation*0.70711f; noifillpos = standard_deviation*0.70711;
noifillneg = -noifillpos; noifillneg = -noifillpos;
/* This assumes region_size = 20 */ /* This assumes region_size = 20 */
@ -555,27 +554,21 @@ static void error_handling(int number_of_coefs,
float *decoder_mlt_coefs, float *decoder_mlt_coefs,
float *old_decoder_mlt_coefs) float *old_decoder_mlt_coefs)
{ {
int i;
/* If both the current and previous frames are errored, /* If both the current and previous frames are errored,
set the mlt coefficients to 0. If only the current frame set the mlt coefficients to 0. If only the current frame
is errored, repeat the previous frame's MLT coefficients. */ is errored, repeat the previous frame's MLT coefficients. */
if (*frame_error_flag) if (*frame_error_flag)
{ {
for (i = 0; i < number_of_valid_coefs; i++) vec_copyf(decoder_mlt_coefs, old_decoder_mlt_coefs, number_of_valid_coefs);
decoder_mlt_coefs[i] = old_decoder_mlt_coefs[i]; vec_zerof(old_decoder_mlt_coefs, number_of_valid_coefs);
for (i = 0; i < number_of_valid_coefs; i++)
old_decoder_mlt_coefs[i] = 0.0f;
} }
else else
{ {
/* Store in case the next frame has errors. */ /* Store in case the next frame has errors. */
for (i = 0; i < number_of_valid_coefs; i++) vec_copyf(old_decoder_mlt_coefs, decoder_mlt_coefs, number_of_valid_coefs);
old_decoder_mlt_coefs[i] = decoder_mlt_coefs[i];
} }
/* Zero out the upper 1/8 of the spectrum. */ /* Zero out the upper 1/8 of the spectrum. */
for (i = number_of_valid_coefs; i < number_of_coefs; i++) vec_zerof(&decoder_mlt_coefs[number_of_valid_coefs], number_of_coefs - number_of_valid_coefs);
decoder_mlt_coefs[i] = 0.0f;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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) #define MAX(a,b) (a > b ? a : b)

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: encoder.c,v 1.26 2008/11/21 15:30:22 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -32,6 +30,7 @@
#include "huff_tab.h" #include "huff_tab.h"
#include "tables.h" #include "tables.h"
#include "bitstream.h" #include "bitstream.h"
#include "utilities.h"
#if defined(G722_1_USE_FIXED_POINT) #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_num_bits[number_of_regions] = num_categorization_control_bits;
drp_code_bits[number_of_regions] = categorization_control; drp_code_bits[number_of_regions] = categorization_control;
bit_count = 0;
/* These code bits are right justified. */ /* 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]); g722_1_bitstream_put(&s->bitstream, &out_code, drp_code_bits[region], drp_num_bits[region]);
bit_count += 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++) for (region = 0; region < number_of_regions; region++)
{ {
n = sub(absolute_region_power_index[region], 39); n = sub(absolute_region_power_index[region], 39) >> 1;
n = shr(n, 1);
if (n > 0) if (n > 0)
{ {
temp = (int16_t) L_mult0(region, REGION_SIZE); temp = (int16_t) L_mult0(region, REGION_SIZE);
raw_mlt_ptr = &mlt_coefs[temp]; raw_mlt_ptr = &mlt_coefs[temp];
for (i = 0; i < REGION_SIZE; i++) for (i = 0; i < REGION_SIZE; i++)
{ {
acca = L_shl(*raw_mlt_ptr, 16); 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; *raw_mlt_ptr++ = (int16_t) acca;
} }
temp = sub(absolute_region_power_index[region], shl(n, 1)); absolute_region_power_index[region] = sub(absolute_region_power_index[region], shl(n, 1));
absolute_region_power_index[region] = temp;
} }
} }
} }
@ -281,7 +275,6 @@ static int16_t compute_region_powers(int16_t *mlt_coefs,
{ {
int16_t *input_ptr; int16_t *input_ptr;
int32_t long_accumulator; int32_t long_accumulator;
int16_t itemp1;
int16_t power_shift; int16_t power_shift;
int16_t region; int16_t region;
int16_t j; int16_t j;
@ -295,12 +288,8 @@ static int16_t compute_region_powers(int16_t *mlt_coefs,
input_ptr = mlt_coefs; input_ptr = mlt_coefs;
for (region = 0; region < number_of_regions; region++) for (region = 0; region < number_of_regions; region++)
{ {
long_accumulator = 0; long_accumulator = vec_dot_prodi16(input_ptr, input_ptr, REGION_SIZE);
for (j = 0; j < REGION_SIZE; j++) input_ptr += REGION_SIZE;
{
itemp1 = *input_ptr++;
long_accumulator = L_mac0(long_accumulator, itemp1, itemp1);
}
power_shift = 0; power_shift = 0;
acca = long_accumulator & 0x7FFF0000L; 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 /* 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. 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) So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9)
to drp_code_bits[0]. */ to drp_code_bits[0]. */
@ -520,7 +509,8 @@ static int16_t vector_huffman(int16_t category,
int16_t num_vecs; int16_t num_vecs;
int16_t kmax; int16_t kmax;
int16_t kmax_plus_one; int16_t kmax_plus_one;
int16_t index,signs_index; int16_t index;
int16_t signs_index;
const int16_t *bitcount_table_ptr; const int16_t *bitcount_table_ptr;
const uint16_t *code_table_ptr; const uint16_t *code_table_ptr;
int32_t code_bits; int32_t code_bits;

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: encoderf.c,v 1.22 2008/11/21 15:30:22 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -33,6 +31,7 @@
#include "huff_tab.h" #include "huff_tab.h"
#include "tables.h" #include "tables.h"
#include "bitstream.h" #include "bitstream.h"
#include "utilities.h"
#if !defined(G722_1_USE_FIXED_POINT) #if !defined(G722_1_USE_FIXED_POINT)
@ -218,7 +217,6 @@ static int compute_region_powers(int number_of_regions,
float *input_ptr; float *input_ptr;
int iterations; int iterations;
float ftemp0; float ftemp0;
float ftemp1;
int index; int index;
int index_min; int index_min;
int index_max; int index_max;
@ -230,13 +228,9 @@ static int compute_region_powers(int number_of_regions,
input_ptr = mlt_coefs; input_ptr = mlt_coefs;
for (region = 0; region < number_of_regions; region++) for (region = 0; region < number_of_regions; region++)
{ {
ftemp0 = 0.0f; ftemp0 = vec_dot_prodf(input_ptr, input_ptr, REGION_SIZE);
for (j = 0; j < REGION_SIZE; j++)
{
ftemp1 = *input_ptr++;
ftemp0 += ftemp1*ftemp1;
}
ftemp0 *= REGION_SIZE_INVERSE; ftemp0 *= REGION_SIZE_INVERSE;
input_ptr += REGION_SIZE;
index_min = 0; index_min = 0;
index_max = REGION_POWER_TABLE_SIZE; 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 /* 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. 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) So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9)
to drp_code_bits[0]. */ to drp_code_bits[0]. */
@ -448,7 +442,7 @@ static int vector_huffman(int category,
number_of_non_zero = 0; number_of_non_zero = 0;
for (j = 0; j < vec_dim; j++) 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) if (k != 0)
{ {
number_of_non_zero++; number_of_non_zero++;
@ -458,12 +452,12 @@ static int vector_huffman(int category,
if (k > kmax) if (k > kmax)
k = kmax; k = kmax;
} }
index = index*(kmax_plus_one) + k; index = index*kmax_plus_one + k;
raw_mlt_ptr++; raw_mlt_ptr++;
} }
code_bits = *(code_table_ptr + index); code_bits = code_table_ptr[index];
number_of_code_bits = *(bitcount_table_ptr + index) + number_of_non_zero; number_of_code_bits = bitcount_table_ptr[index] + number_of_non_zero;
number_of_region_bits += number_of_code_bits; number_of_region_bits += number_of_code_bits;
code_bits = (code_bits << number_of_non_zero) + signs_index; code_bits = (code_bits << number_of_non_zero) + signs_index;

View File

@ -7,8 +7,6 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * 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 */ /*! \file */

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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_) #if !defined(_G722_1_G722_1_H_)

View File

@ -9,8 +9,6 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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_) #if !defined(_G722_1_VERSION_H_)

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: huff_tab.c,v 1.7 2008/09/30 14:06:40 steveu Exp $
*/ */
/*! \file */ /*! \file */

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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 #define REGION_POWER_STEPSIZE_DB 3.010299957

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: make_dct4_tables.c,v 1.2 2008/10/02 11:43:54 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -29,7 +27,11 @@
#include "g722_1/g722_1.h" #include "g722_1/g722_1.h"
#if defined(PI)
#undef PI
#endif
#define PI 3.141592653589793238462 #define PI 3.141592653589793238462
#include "defs.h" #include "defs.h"
static void set_up_one_table(int length) 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++) for (i = 0; i <= length_log; i++)
set_up_one_table(dct_size << i); set_up_one_table(dct_size << i);
return 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: make_tables.c,v 1.5 2008/11/21 15:30:22 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -37,6 +35,7 @@
#undef PI #undef PI
#endif #endif
#define PI 3.141592653589793238462 #define PI 3.141592653589793238462
/* These may have been defined in the main header for the codec, so we clear out /* These may have been defined in the main header for the codec, so we clear out
any pre-existing definitions here. */ any pre-existing definitions here. */
#if defined(ENCODER_SCALE_FACTOR) #if defined(ENCODER_SCALE_FACTOR)
@ -124,7 +123,7 @@ static void generate_sam2coef_tables(void)
for (i = 0; i < DCT_LENGTH; i++) for (i = 0; i < DCT_LENGTH; i++)
{ {
angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH; angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH;
printf(" %.15e,\n", sin(angle)); printf(" %.15ef,\n", sin(angle));
} }
printf("};\n\n"); printf("};\n\n");
@ -132,7 +131,7 @@ static void generate_sam2coef_tables(void)
for (i = 0; i < MAX_DCT_LENGTH; i++) for (i = 0; i < MAX_DCT_LENGTH; i++)
{ {
angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH; 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"); printf("};\n\n");
@ -180,7 +179,7 @@ static void generate_coef2sam_tables(void)
for (i = 0; i < DCT_LENGTH; i++) for (i = 0; i < DCT_LENGTH; i++)
{ {
angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH; angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH;
printf(" %.15e,\n", sin(angle)); printf(" %.15ef,\n", sin(angle));
} }
printf("};\n\n"); printf("};\n\n");
@ -188,7 +187,7 @@ static void generate_coef2sam_tables(void)
for (i = 0; i < MAX_DCT_LENGTH; i++) for (i = 0; i < MAX_DCT_LENGTH; i++)
{ {
angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH; 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"); printf("};\n\n");
@ -218,7 +217,7 @@ int main(int argc, char *argv[])
for (i = 0; i < REGION_POWER_TABLE_SIZE; i++) 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)); 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"); printf("};\n\n");
@ -226,7 +225,7 @@ int main(int argc, char *argv[])
for (i = 0; i < REGION_POWER_TABLE_SIZE; i++) 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)); 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"); printf("};\n\n");
@ -259,14 +258,14 @@ int main(int argc, char *argv[])
printf("const float step_size[NUM_CATEGORIES] =\n{\n"); printf("const float step_size[NUM_CATEGORIES] =\n{\n");
for (i = 0; i < NUM_CATEGORIES; i++) for (i = 0; i < NUM_CATEGORIES; i++)
{ {
printf(" %.15e,\n", step_size[i]); printf(" %.15ef,\n", step_size[i]);
} }
printf("};\n\n"); printf("};\n\n");
printf("const float step_size_inverse_table[NUM_CATEGORIES] =\n{\n"); printf("const float step_size_inverse_table[NUM_CATEGORIES] =\n{\n");
for (i = 0; i < NUM_CATEGORIES; i++) 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"); printf("};\n\n");
@ -275,7 +274,7 @@ int main(int argc, char *argv[])
for (i = 0; i < REGION_POWER_TABLE_SIZE; i++) 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)); 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"); printf("};\n\n");
@ -283,9 +282,10 @@ int main(int argc, char *argv[])
for (i = 0; i < REGION_POWER_TABLE_SIZE - 1; i++) 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))); 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"); printf("};\n\n");
return 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: sam2coef.c,v 1.12 2008/10/02 11:43:54 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -29,17 +27,16 @@
#include "defs.h" #include "defs.h"
#include "sam2coef.h" #include "sam2coef.h"
#include "utilities.h"
/************************************************************************************ /* Convert Samples to Reversed MLT (Modulated Lapped Transform) Coefficients
Purpose: Convert Samples to Reversed MLT (Modulated Lapped Transform) Coefficients
The "Reversed MLT" is an overlapped block transform which uses even symmetry 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. 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 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 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 to reversing the order of the samples, performing an MLT and then negating all
the even-numbered coefficients. the even-numbered coefficients. */
***************************************************************************/
#if defined(G722_1_USE_FIXED_POINT) #if defined(G722_1_USE_FIXED_POINT)
int16_t samples_to_rmlt_coefs(const int16_t new_samples[], 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; half_dct_length = dct_length >> 1;
if (dct_length == DCT_LENGTH) win = (dct_length == DCT_LENGTH) ? samples_to_rmlt_window : max_samples_to_rmlt_window;
win = samples_to_rmlt_window;
else
win = max_samples_to_rmlt_window;
/* Get the first half of the windowed samples */ /* Get the first half of the windowed samples */
last = half_dct_length - 1; last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++) for (i = 0; i < half_dct_length; i++)
{ {
acca = 0L; acca = L_mult(win[last - i], old_samples[last - i]);
acca = L_mac(acca, win[last - i], old_samples[last - i]);
acca = L_mac(acca, win[half_dct_length + i], old_samples[half_dct_length + i]); acca = L_mac(acca, win[half_dct_length + i], old_samples[half_dct_length + i]);
temp = xround(acca); windowed_data[i] = xround(acca);
windowed_data[i] = temp;
} }
/* Get the second half of the windowed samples */ /* Get the second half of the windowed samples */
last = dct_length - 1; last = dct_length - 1;
for (i = 0; i < half_dct_length; i++) for (i = 0; i < half_dct_length; i++)
{ {
acca = 0L; acca = L_mult(win[last - i], new_samples[i]);
acca = L_mac(acca, win[last - i], new_samples[i]);
acca = L_mac(acca, negate(win[i]), new_samples[last - i]); acca = L_mac(acca, negate(win[i]), new_samples[last - i]);
temp = xround(acca); windowed_data[half_dct_length + i] = xround(acca);
windowed_data[half_dct_length + i] = temp;
} }
/* Save the new samples for next time, when they will be the old samples. */ /* Save the new samples for next time, when they will be the old samples. */
for (i = 0; i < dct_length; i++) vec_copyi16(old_samples, new_samples, dct_length);
old_samples[i] = new_samples[i];
/* Calculate how many bits to shift up the input to the DCT. */ /* Calculate how many bits to shift up the input to the DCT. */
temp1 = 0; temp1 = 0;
@ -156,10 +145,7 @@ void samples_to_rmlt_coefs(const float new_samples[],
half_dct_length = dct_length >> 1; half_dct_length = dct_length >> 1;
if (dct_length == DCT_LENGTH) win = (dct_length == DCT_LENGTH) ? samples_to_rmlt_window : max_samples_to_rmlt_window;
win = samples_to_rmlt_window;
else
win = max_samples_to_rmlt_window;
/* Get the first half of the windowed samples. */ /* Get the first half of the windowed samples. */
last = half_dct_length - 1; last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++) 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; windowed_data[half_dct_length + i] = sum;
} }
/* Save the new samples for next time, when they will be the old samples. */ /* Save the new samples for next time, when they will be the old samples. */
for (i = 0; i < dct_length; i++) vec_copyf(old_samples, new_samples, dct_length);
old_samples[i] = new_samples[i];
/* Perform a Type IV DCT on the windowed data to get the coefficients. */ /* Perform a Type IV DCT on the windowed data to get the coefficients. */
dct_type_iv(windowed_data, coefs, dct_length); dct_type_iv(windowed_data, coefs, dct_length);

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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) #if defined(G722_1_USE_FIXED_POINT)

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: tables.c,v 1.11 2008/09/30 14:06:40 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -65,70 +63,70 @@ const int16_t int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE] =
#else #else
const float region_standard_deviation_table[REGION_POWER_TABLE_SIZE] = const float region_standard_deviation_table[REGION_POWER_TABLE_SIZE] =
{ {
2.441406247570224e-04f, 2.441406247570224e-04,
3.452669826719395e-04f, 3.452669826719395e-04,
4.882812495545411e-04f, 4.882812495545411e-04,
6.905339654011486e-04f, 6.905339654011486e-04,
9.765624991900746e-04f, 9.765624991900746e-04,
1.381067930916839e-03f, 1.381067930916839e-03,
1.953124998542134e-03f, 1.953124998542134e-03,
2.762135862062757e-03f, 2.762135862062757e-03,
3.906249997408239e-03f, 3.906249997408239e-03,
5.524271724583683e-03f, 5.524271724583683e-03,
7.812499995464418e-03f, 7.812499995464418e-03,
1.104854345008369e-02f, 1.104854345008369e-02,
1.562499999222472e-02f, 1.562499999222472e-02,
2.209708690200003e-02f, 2.209708690200003e-02,
3.124999998704119e-02f, 3.124999998704119e-02,
4.419417380766535e-02f, 4.419417380766535e-02,
6.249999997926591e-02f, 6.249999997926591e-02,
8.838834762266132e-02f, 8.838834762266132e-02,
1.249999999688989e-01f, 1.249999999688989e-01,
1.767766952599839e-01f, 1.767766952599839e-01,
2.499999999585318e-01f, 2.499999999585318e-01,
3.535533905492901e-01f, 3.535533905492901e-01,
4.999999999585318e-01f, 4.999999999585318e-01,
7.071067811572251e-01f, 7.071067811572251e-01,
1.000000000000000e+00f, 1.000000000000000e+00,
1.414213562431740e+00f, 1.414213562431740e+00,
2.000000000165873e+00f, 2.000000000165873e+00,
2.828427125098059e+00f, 2.828427125098059e+00,
4.000000000663491e+00f, 4.000000000663491e+00,
5.656854250665278e+00f, 5.656854250665278e+00,
8.000000001990472e+00f, 8.000000001990472e+00,
1.131370850226887e+01f, 1.131370850226887e+01,
1.600000000530792e+01f, 1.600000000530792e+01,
2.262741700641438e+01f, 2.262741700641438e+01,
3.200000001326981e+01f, 3.200000001326981e+01,
4.525483401658204e+01f, 4.525483401658204e+01,
6.400000003184756e+01f, 6.400000003184756e+01,
9.050966804067060e+01f, 9.050966804067060e+01,
1.280000000743110e+02f, 1.280000000743110e+02,
1.810193360963542e+02f, 1.810193360963542e+02,
2.560000001698536e+02f, 2.560000001698536e+02,
3.620386722227349e+02f, 3.620386722227349e+02,
5.120000003821707e+02f, 5.120000003821707e+02,
7.240773445055215e+02f, 7.240773445055215e+02,
1.024000000849268e+03f, 1.024000000849268e+03,
1.448154689131149e+03f, 1.448154689131149e+03,
2.048000001868390e+03f, 2.048000001868390e+03,
2.896309378502505e+03f, 2.896309378502505e+03,
4.096000004076487e+03f, 4.096000004076487e+03,
5.792618757485434e+03f, 5.792618757485434e+03,
8.192000008832390e+03f, 8.192000008832390e+03,
1.158523751593169e+04f, 1.158523751593169e+04,
1.638400001902361e+04f, 1.638400001902361e+04,
2.317047503378509e+04f, 2.317047503378509e+04,
3.276800004076484e+04f, 3.276800004076484e+04,
4.634095007141347e+04f, 4.634095007141347e+04,
6.553600008696507e+04f, 6.553600008696507e+04,
9.268190015051374e+04f, 9.268190015051374e+04,
1.310720001848009e+05f, 1.310720001848009e+05,
1.853638003164007e+05f, 1.853638003164007e+05,
2.621440003913428e+05f, 2.621440003913428e+05,
3.707276006635486e+05f, 3.707276006635486e+05,
5.242880008261676e+05f, 5.242880008261676e+05,
7.414552013885899e+05f 7.414552013885899e+05
}; };
#endif #endif
@ -146,70 +144,70 @@ const int16_t standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] =
#else #else
const float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] = const float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] =
{ {
4.096000004076488e+03f, 4.096000004076488e+03,
2.896309378502504e+03f, 2.896309378502504e+03,
2.048000001868390e+03f, 2.048000001868390e+03,
1.448154689131149e+03f, 1.448154689131149e+03,
1.024000000849268e+03f, 1.024000000849268e+03,
7.240773445055215e+02f, 7.240773445055215e+02,
5.120000003821708e+02f, 5.120000003821708e+02,
3.620386722227349e+02f, 3.620386722227349e+02,
2.560000001698537e+02f, 2.560000001698537e+02,
1.810193360963542e+02f, 1.810193360963542e+02,
1.280000000743110e+02f, 1.280000000743110e+02,
9.050966804067060e+01f, 9.050966804067060e+01,
6.400000003184756e+01f, 6.400000003184756e+01,
4.525483401658203e+01f, 4.525483401658203e+01,
3.200000001326982e+01f, 3.200000001326982e+01,
2.262741700641438e+01f, 2.262741700641438e+01,
1.600000000530793e+01f, 1.600000000530793e+01,
1.131370850226887e+01f, 1.131370850226887e+01,
8.000000001990474e+00f, 8.000000001990474e+00,
5.656854250665277e+00f, 5.656854250665277e+00,
4.000000000663491e+00f, 4.000000000663491e+00,
2.828427125098059e+00f, 2.828427125098059e+00,
2.000000000165873e+00f, 2.000000000165873e+00,
1.414213562431740e+00f, 1.414213562431740e+00,
1.000000000000000e+00f, 1.000000000000000e+00,
7.071067811572251e-01f, 7.071067811572251e-01,
4.999999999585318e-01f, 4.999999999585318e-01,
3.535533905492901e-01f, 3.535533905492901e-01,
2.499999999585318e-01f, 2.499999999585318e-01,
1.767766952599838e-01f, 1.767766952599838e-01,
1.249999999688989e-01f, 1.249999999688989e-01,
8.838834762266132e-02f, 8.838834762266132e-02,
6.249999997926592e-02f, 6.249999997926592e-02,
4.419417380766535e-02f, 4.419417380766535e-02,
3.124999998704120e-02f, 3.124999998704120e-02,
2.209708690200002e-02f, 2.209708690200002e-02,
1.562499999222472e-02f, 1.562499999222472e-02,
1.104854345008369e-02f, 1.104854345008369e-02,
7.812499995464418e-03f, 7.812499995464418e-03,
5.524271724583683e-03f, 5.524271724583683e-03,
3.906249997408239e-03f, 3.906249997408239e-03,
2.762135862062757e-03f, 2.762135862062757e-03,
1.953124998542134e-03f, 1.953124998542134e-03,
1.381067930916839e-03f, 1.381067930916839e-03,
9.765624991900747e-04f, 9.765624991900747e-04,
6.905339654011486e-04f, 6.905339654011486e-04,
4.882812495545411e-04f, 4.882812495545411e-04,
3.452669826719394e-04f, 3.452669826719394e-04,
2.441406247570224e-04f, 2.441406247570224e-04,
1.726334913216520e-04f, 1.726334913216520e-04,
1.220703123683871e-04f, 1.220703123683871e-04,
8.631674565366727e-05f, 8.631674565366727e-05,
6.103515617913153e-05f, 6.103515617913153e-05,
4.315837282325419e-05f, 4.315837282325419e-05,
3.051757808703478e-05f, 3.051757808703478e-05,
2.157918640983742e-05f, 2.157918640983742e-05,
1.525878904225187e-05f, 1.525878904225187e-05,
1.078959320402385e-05f, 1.078959320402385e-05,
7.629394520493171e-06f, 7.629394520493171e-06,
5.394796601564505e-06f, 5.394796601564505e-06,
3.814697259930213e-06f, 3.814697259930213e-06,
2.697398300558537e-06f, 2.697398300558537e-06,
1.907348629806920e-06f, 1.907348629806920e-06,
1.348699150167414e-06f 1.348699150167414e-06
}; };
#endif #endif
@ -241,14 +239,14 @@ const float step_size[NUM_CATEGORIES] =
const float step_size_inverse_table[NUM_CATEGORIES] = const float step_size_inverse_table[NUM_CATEGORIES] =
{ {
2.82805443e+00f, 2.82805443e+00,
2.00000000e+00f, 2.00000000e+00,
1.41422713e+00f, 1.41422713e+00,
1.00000000e+00f, 1.00000000e+00,
7.07113564e-01f, 7.07113564e-01,
5.00000000e-01f, 5.00000000e-01,
3.53556782e-01f, 3.53556782e-01,
3.53556782e-01f 3.53556782e-01
}; };
#endif #endif
@ -279,137 +277,137 @@ const float dead_zone[NUM_CATEGORIES] =
#if !defined(G722_1_USE_FIXED_POINT) #if !defined(G722_1_USE_FIXED_POINT)
const float region_power_table[REGION_POWER_TABLE_SIZE] = const float region_power_table[REGION_POWER_TABLE_SIZE] =
{ {
5.96046448e-08f, 5.96046448e-08,
1.19209290e-07f, 1.19209290e-07,
2.38418579e-07f, 2.38418579e-07,
4.76837158e-07f, 4.76837158e-07,
9.53674316e-07f, 9.53674316e-07,
1.90734863e-06f, 1.90734863e-06,
3.81469727e-06f, 3.81469727e-06,
7.62939453e-06f, 7.62939453e-06,
1.52587891e-05f, 1.52587891e-05,
3.05175781e-05f, 3.05175781e-05,
6.10351562e-05f, 6.10351562e-05,
1.22070312e-04f, 1.22070312e-04,
2.44140625e-04f, 2.44140625e-04,
4.88281250e-04f, 4.88281250e-04,
9.76562500e-04f, 9.76562500e-04,
1.95312500e-03f, 1.95312500e-03,
3.90625000e-03f, 3.90625000e-03,
7.81250000e-03f, 7.81250000e-03,
1.56250000e-02f, 1.56250000e-02,
3.12500000e-02f, 3.12500000e-02,
6.25000000e-02f, 6.25000000e-02,
1.25000000e-01f, 1.25000000e-01,
2.50000000e-01f, 2.50000000e-01,
5.00000000e-01f, 5.00000000e-01,
1.00000000e+00f, 1.00000000e+00,
2.00000000e+00f, 2.00000000e+00,
4.00000000e+00f, 4.00000000e+00,
8.00000000e+00f, 8.00000000e+00,
1.60000000e+01f, 1.60000000e+01,
3.20000000e+01f, 3.20000000e+01,
6.40000000e+01f, 6.40000000e+01,
1.28000000e+02f, 1.28000000e+02,
2.56000000e+02f, 2.56000000e+02,
5.12000000e+02f, 5.12000000e+02,
1.02400000e+03f, 1.02400000e+03,
2.04800000e+03f, 2.04800000e+03,
4.09600000e+03f, 4.09600000e+03,
8.19200000e+03f, 8.19200000e+03,
1.63840000e+04f, 1.63840000e+04,
3.27680000e+04f, 3.27680000e+04,
6.55360000e+04f, 6.55360000e+04,
1.31072000e+05f, 1.31072000e+05,
2.62144000e+05f, 2.62144000e+05,
5.24288000e+05f, 5.24288000e+05,
1.04857600e+06f, 1.04857600e+06,
2.09715200e+06f, 2.09715200e+06,
4.19430400e+06f, 4.19430400e+06,
8.38860800e+06f, 8.38860800e+06,
1.67772160e+07f, 1.67772160e+07,
3.35544320e+07f, 3.35544320e+07,
6.71088640e+07f, 6.71088640e+07,
1.34217728e+08f, 1.34217728e+08,
2.68435456e+08f, 2.68435456e+08,
5.36870912e+08f, 5.36870912e+08,
1.07374182e+09f, 1.07374182e+09,
2.14748365e+09f, 2.14748365e+09,
4.29496730e+09f, 4.29496730e+09,
8.58993459e+09f, 8.58993459e+09,
1.71798692e+10f, 1.71798692e+10,
3.43597384e+10f, 3.43597384e+10,
6.87194767e+10f, 6.87194767e+10,
1.37438953e+11f, 1.37438953e+11,
2.74877907e+11f, 2.74877907e+11,
5.49755814e+11f 5.49755814e+11
}; };
const float region_power_table_boundary[REGION_POWER_TABLE_SIZE - 1] = const float region_power_table_boundary[REGION_POWER_TABLE_SIZE - 1] =
{ {
8.42936956e-08f, 8.42936956e-08,
1.68587391e-07f, 1.68587391e-07,
3.37174782e-07f, 3.37174782e-07,
6.74349565e-07f, 6.74349565e-07,
1.34869913e-06f, 1.34869913e-06,
2.69739826e-06f, 2.69739826e-06,
5.39479652e-06f, 5.39479652e-06,
1.07895930e-05f, 1.07895930e-05,
2.15791861e-05f, 2.15791861e-05,
4.31583721e-05f, 4.31583721e-05,
8.63167443e-05f, 8.63167443e-05,
1.72633489e-04f, 1.72633489e-04,
3.45266977e-04f, 3.45266977e-04,
6.90533954e-04f, 6.90533954e-04,
1.38106791e-03f, 1.38106791e-03,
2.76213582e-03f, 2.76213582e-03,
5.52427163e-03f, 5.52427163e-03,
1.10485433e-02f, 1.10485433e-02,
2.20970865e-02f, 2.20970865e-02,
4.41941731e-02f, 4.41941731e-02,
8.83883461e-02f, 8.83883461e-02,
1.76776692e-01f, 1.76776692e-01,
3.53553385e-01f, 3.53553385e-01,
7.07106769e-01f, 7.07106769e-01,
1.41421354e+00f, 1.41421354e+00,
2.82842708e+00f, 2.82842708e+00,
5.65685415e+00f, 5.65685415e+00,
1.13137083e+01f, 1.13137083e+01,
2.26274166e+01f, 2.26274166e+01,
4.52548332e+01f, 4.52548332e+01,
9.05096664e+01f, 9.05096664e+01,
1.81019333e+02f, 1.81019333e+02,
3.62038666e+02f, 3.62038666e+02,
7.24077332e+02f, 7.24077332e+02,
1.44815466e+03f, 1.44815466e+03,
2.89630933e+03f, 2.89630933e+03,
5.79261865e+03f, 5.79261865e+03,
1.15852373e+04f, 1.15852373e+04,
2.31704746e+04f, 2.31704746e+04,
4.63409492e+04f, 4.63409492e+04,
9.26818984e+04f, 9.26818984e+04,
1.85363797e+05f, 1.85363797e+05,
3.70727594e+05f, 3.70727594e+05,
7.41455188e+05f, 7.41455188e+05,
1.48291038e+06f, 1.48291038e+06,
2.96582075e+06f, 2.96582075e+06,
5.93164150e+06f, 5.93164150e+06,
1.18632830e+07f, 1.18632830e+07,
2.37265660e+07f, 2.37265660e+07,
4.74531320e+07f, 4.74531320e+07,
9.49062640e+07f, 9.49062640e+07,
1.89812528e+08f, 1.89812528e+08,
3.79625056e+08f, 3.79625056e+08,
7.59250112e+08f, 7.59250112e+08,
1.51850022e+09f, 1.51850022e+09,
3.03700045e+09f, 3.03700045e+09,
6.07400090e+09f, 6.07400090e+09,
1.21480018e+10f, 1.21480018e+10,
2.42960036e+10f, 2.42960036e+10,
4.85920072e+10f, 4.85920072e+10,
9.71840143e+10f, 9.71840143e+10,
1.94368029e+11f, 1.94368029e+11,
3.88736057e+11f 3.88736057e+11
}; };
#endif #endif

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 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 #define REGION_POWER_TABLE_SIZE 64

View File

@ -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 <config.h>
#endif
#include <inttypes.h>
#if defined(G722_1_USE_MMX)
#include <mmintrin.h>
#endif
#if defined(G722_1_USE_SSE)
#include <xmmintrin.h>
#endif
#if defined(G722_1_USE_SSE2)
#include <emmintrin.h>
#endif
#if defined(G722_1_USE_SSE3)
#include <pmmintrin.h>
#include <tmmintrin.h>
#endif
#if defined(G722_1_USE_SSE4_1)
#include <smmintrin.h>
#endif
#if defined(G722_1_USE_SSE4_2)
#include <nmmintrin.h>
#endif
#if defined(G722_1_USE_SSE4A)
#include <ammintrin.h>
#endif
#if defined(G722_1_USE_SSE5)
#include <bmmintrin.h>
#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 ------------------------------------------------------------*/

View File

@ -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 ------------------------------------------------------------*/

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## 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 SUBDIRS = itu local

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Id: Makefile.am,v 1.3 2008/09/23 16:03:04 steveu Exp $
SUBDIRS = SUBDIRS =

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Id: Makefile.am,v 1.3 2008/09/24 16:12:52 steveu Exp $
SUBDIRS = SUBDIRS =

View File

@ -15,8 +15,6 @@
## You should have received a copy of the GNU General Public License ## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software ## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## 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_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
@ -33,8 +31,8 @@ LIBDIR = -L$(top_builddir)/src
noinst_PROGRAMS = g722_1_tests noinst_PROGRAMS = g722_1_tests
noinst_HEADERS = itu_bit_stream.c \ noinst_HEADERS = g192_bit_stream.h \
timing.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 g722_1_tests_LDADD = $(LIBDIR) -lg722_1

View File

@ -0,0 +1,177 @@
/*
* broadvoice - a library for the BroadVoice 16 and 32 codecs
*
* g192_bit_stream.c
*
* Copyright 2008-2009 Steve Underwood <steveu@coppice.org>
*
* 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 <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <audiofile.h>
#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 ------------------------------------------------------------*/

View File

@ -0,0 +1,75 @@
/*
* broadvoice - a library for the BroadVoice 16 and 32 codecs
*
* g192_bit_stream.h
*
* Copyright 2008-2009 Steve Underwood <steveu@coppice.org>
*
* 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 ------------------------------------------------------------*/

View File

@ -6,14 +6,12 @@
* Adapted by Steve Underwood <steveu@coppice.org> from the reference * Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is: * code supplied with ITU G.722.1, which is:
* *
* © 2004 Polycom, Inc. * (C) 2004 Polycom, Inc.
* All rights reserved. * All rights reserved.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: g722_1_tests.c,v 1.14 2008/11/21 15:30:22 steveu Exp $
*/ */
/*! \file */ /*! \file */
@ -36,7 +34,7 @@
#include <g722_1.h> #include <g722_1.h>
#include "timing.h" #include "timing.h"
#include "itu_bit_stream.h" #include "g192_bit_stream.h"
typedef struct typedef struct
{ {
@ -227,7 +225,7 @@ static void parse_command_line(char *argv[], coder_control_t *control)
} }
else if (strcasecmp(*argv, "i") == 0) 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"); printf("Encoding format = ITU-format bitstream\n");
} }
else else

View File

@ -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 <steveu@coppice.org> 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 <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <audiofile.h>
#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 ------------------------------------------------------------*/

View File

@ -16,9 +16,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # 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 STDOUT_DEST=xyzzy
STDERR_DEST=xyzzy2 STDERR_DEST=xyzzy2
@ -33,7 +30,7 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_out_32000.itu
RETVAL=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests E failed! echo g722_1_tests encode failed!
exit $RETVAL exit $RETVAL
fi fi
./g722_1_tests E I 24000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_in.pcm $TMP_FILE ./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=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests E failed! echo g722_1_tests encode failed!
exit $RETVAL exit $RETVAL
fi 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 ./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 diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_out_24000.pcm
RETVAL=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests D failed! echo g722_1_tests decode failed!
exit $RETVAL exit $RETVAL
fi fi
./g722_1_tests D I 32000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_enc_out_32000.itu $TMP_FILE ./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=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests D failed! echo g722_1_tests decode failed!
exit $RETVAL exit $RETVAL
fi fi
@ -68,7 +65,7 @@ diff $TMP_FILE ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_out_24000_fe.pcm
RETVAL=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests D failed! echo g722_1_tests decode failed!
exit $RETVAL exit $RETVAL
fi fi
./g722_1_tests D I 32000 16000 ../test-data/itu/g722_1/$VECTOR_CLASS/g722_1_dec_in_32000_fe.itu $TMP_FILE ./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=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests D failed! echo g722_1_tests decode failed!
exit $RETVAL exit $RETVAL
fi 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 ./g722_1_tests E I 32000 16000 ../test-data/local/short_wb_voice.wav $TMP_FILE
RETVAL=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests E failed! echo g722_1_tests encode failed!
exit $RETVAL exit $RETVAL
fi 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 ./g722_1_tests D I 32000 16000 $TMP_FILE test.au
RETVAL=$? RETVAL=$?
if [ $RETVAL != 0 ] if [ $RETVAL != 0 ]
then then
echo g722_1_tests D failed! echo g722_1_tests decode failed!
exit $RETVAL exit $RETVAL
fi fi
echo g722_1_tests D completed OK echo g722_1_tests decode completed OK
echo echo
echo All regression tests successfully completed echo All regression tests successfully completed

View File

@ -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 * 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 * You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software * License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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_) #if !defined(_TIMING_H_)

View File

@ -16,9 +16,6 @@
# You should have received a copy of the GNU Lesser General Public # You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software # License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # 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" ITUDATA="../../../T-REC-G.722.1-200505-I!!SOFT-ZST-E.zip"