Moved split-3rd-party branch to the trunk
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1227 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
commit
b4bedb935f
435 changed files with 56737 additions and 85658 deletions
4
Makefile
4
Makefile
|
@ -1,7 +1,7 @@
|
|||
include build.mak
|
||||
include build/host-$(HOST_NAME).mak
|
||||
|
||||
DIRS = pjlib pjlib-util pjnath pjmedia pjsip pjsip-apps
|
||||
DIRS = pjlib pjlib-util pjnath third_party pjmedia pjsip pjsip-apps
|
||||
|
||||
ifdef MINSIZE
|
||||
MAKE_FLAGS := MINSIZE=1
|
||||
|
@ -9,13 +9,11 @@ endif
|
|||
|
||||
all clean dep depend distclean doc print realclean:
|
||||
for dir in $(DIRS); do \
|
||||
if [ -d $$dir ]; then \
|
||||
if $(MAKE) $(MAKE_FLAGS) -C $$dir/build $@; then \
|
||||
true; \
|
||||
else \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
LIBS = pjlib/lib/libpj-$(TARGET_NAME).a \
|
||||
|
|
491
aconfigure
491
aconfigure
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.59 for pjproject 0.5.10.
|
||||
# Generated by GNU Autoconf 2.59 for pjproject 0.6.0.
|
||||
#
|
||||
# Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
# This configure script is free software; the Free Software Foundation
|
||||
|
@ -267,8 +267,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='pjproject'
|
||||
PACKAGE_TARNAME='pjproject'
|
||||
PACKAGE_VERSION='0.5.10'
|
||||
PACKAGE_STRING='pjproject 0.5.10'
|
||||
PACKAGE_VERSION='0.6.0'
|
||||
PACKAGE_STRING='pjproject 0.6.0'
|
||||
PACKAGE_BUGREPORT=''
|
||||
|
||||
# Factoring default headers for most tests.
|
||||
|
@ -308,7 +308,7 @@ ac_includes_default="\
|
|||
# include <unistd.h>
|
||||
#endif"
|
||||
|
||||
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX ac_pjdir CPP EGREP ac_os_objs ac_pjmedia_snd ac_pa_cflags ac_pa_use_alsa ac_no_small_filter ac_no_large_filter ac_no_g711_plc ac_no_speex_aec ac_no_g711_codec ac_no_l16_codec ac_no_gsm_codec ac_no_speex_codec ac_no_ilbc_codec ac_no_ssl openssl_h_present libssl_present libcrypto_present ac_cross_compile ac_linux_poll ac_host ac_main_obj LIBOBJS LTLIBOBJS'
|
||||
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX ac_pjdir CPP EGREP ac_os_objs ac_pjmedia_snd ac_pa_cflags ac_pa_use_alsa ac_no_small_filter ac_no_large_filter ac_no_speex_aec ac_no_g711_codec ac_no_l16_codec ac_no_gsm_codec ac_no_speex_codec ac_no_ilbc_codec ac_no_ssl openssl_h_present libssl_present libcrypto_present ac_cross_compile ac_linux_poll ac_host ac_main_obj LIBOBJS LTLIBOBJS'
|
||||
ac_subst_files=''
|
||||
|
||||
# Initialize some variables set by options.
|
||||
|
@ -785,7 +785,7 @@ if test "$ac_init_help" = "long"; then
|
|||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures pjproject 0.5.10 to adapt to many kinds of systems.
|
||||
\`configure' configures pjproject 0.6.0 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
|
@ -847,7 +847,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of pjproject 0.5.10:";;
|
||||
short | recursive ) echo "Configuration of pjproject 0.6.0:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -859,7 +859,6 @@ Optional Features:
|
|||
--disable-sound Exclude sound (i.e. use null sound)
|
||||
--disable-small-filter Exclude small filter in resampling
|
||||
--disable-large-filter Exclude large filter in resampling
|
||||
--disable-g711-plc Exclude G.711 Annex A PLC
|
||||
--disable-speex-aec Exclude Speex Acoustic Echo Canceller/AEC
|
||||
--disable-g711-codec Exclude G.711 codecs from the build
|
||||
--disable-l16-codec Exclude Linear/L16 codec family from the build
|
||||
|
@ -978,7 +977,7 @@ fi
|
|||
test -n "$ac_init_help" && exit 0
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
pjproject configure 0.5.10
|
||||
pjproject configure 0.6.0
|
||||
generated by GNU Autoconf 2.59
|
||||
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
|
@ -992,7 +991,7 @@ cat >&5 <<_ACEOF
|
|||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by pjproject $as_me 0.5.10, which was
|
||||
It was created by pjproject $as_me 0.6.0, which was
|
||||
generated by GNU Autoconf 2.59. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
@ -1440,7 +1439,7 @@ test -n "$target_alias" &&
|
|||
program_prefix=${target_alias}-
|
||||
ac_config_headers="$ac_config_headers pjlib/include/pj/compat/os_auto.h pjlib/include/pj/compat/m_auto.h pjmedia/include/pjmedia/config_auto.h pjmedia/include/pjmedia-codec/config_auto.h pjsip/include/pjsip/sip_autoconf.h"
|
||||
|
||||
ac_config_files="$ac_config_files build.mak build/os-auto.mak pjlib/build/os-auto.mak pjlib-util/build/os-auto.mak pjmedia/build/os-auto.mak pjsip/build/os-auto.mak"
|
||||
ac_config_files="$ac_config_files build.mak build/os-auto.mak pjlib/build/os-auto.mak pjlib-util/build/os-auto.mak pjmedia/build/os-auto.mak pjsip/build/os-auto.mak third_party/build/portaudio/os-auto.mak third_party/build/os-auto.mak"
|
||||
|
||||
|
||||
|
||||
|
@ -8375,6 +8374,433 @@ echo "${ECHO_T}Checking if sound is disabled... yes" >&6
|
|||
fi;
|
||||
|
||||
|
||||
if test "${ac_cv_header_sys_soundcard_h+set}" = set; then
|
||||
echo "$as_me:$LINENO: checking for sys/soundcard.h" >&5
|
||||
echo $ECHO_N "checking for sys/soundcard.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_sys_soundcard_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_sys_soundcard_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_sys_soundcard_h" >&6
|
||||
else
|
||||
# Is the header compilable?
|
||||
echo "$as_me:$LINENO: checking sys/soundcard.h usability" >&5
|
||||
echo $ECHO_N "checking sys/soundcard.h usability... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
$ac_includes_default
|
||||
#include <sys/soundcard.h>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
||||
echo "${ECHO_T}$ac_header_compiler" >&6
|
||||
|
||||
# Is the header present?
|
||||
echo "$as_me:$LINENO: checking sys/soundcard.h presence" >&5
|
||||
echo $ECHO_N "checking sys/soundcard.h presence... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <sys/soundcard.h>
|
||||
_ACEOF
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
||||
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } >/dev/null; then
|
||||
if test -s conftest.err; then
|
||||
ac_cpp_err=$ac_c_preproc_warn_flag
|
||||
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
|
||||
else
|
||||
ac_cpp_err=
|
||||
fi
|
||||
else
|
||||
ac_cpp_err=yes
|
||||
fi
|
||||
if test -z "$ac_cpp_err"; then
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
||||
echo "${ECHO_T}$ac_header_preproc" >&6
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
|
||||
yes:no: )
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: proceeding with the compiler's result" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: proceeding with the compiler's result" >&2;}
|
||||
ac_header_preproc=yes
|
||||
;;
|
||||
no:yes:* )
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: present but cannot be compiled" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: present but cannot be compiled" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: check for missing prerequisite headers?" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: check for missing prerequisite headers?" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: see the Autoconf documentation" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: see the Autoconf documentation" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: proceeding with the preprocessor's result" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: sys/soundcard.h: in the future, the compiler will take precedence" >&5
|
||||
echo "$as_me: WARNING: sys/soundcard.h: in the future, the compiler will take precedence" >&2;}
|
||||
(
|
||||
cat <<\_ASBOX
|
||||
## ------------------------------------ ##
|
||||
## Report this to the pjproject lists. ##
|
||||
## ------------------------------------ ##
|
||||
_ASBOX
|
||||
) |
|
||||
sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
esac
|
||||
echo "$as_me:$LINENO: checking for sys/soundcard.h" >&5
|
||||
echo $ECHO_N "checking for sys/soundcard.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_sys_soundcard_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_cv_header_sys_soundcard_h=$ac_header_preproc
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_sys_soundcard_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_sys_soundcard_h" >&6
|
||||
|
||||
fi
|
||||
if test $ac_cv_header_sys_soundcard_h = yes; then
|
||||
ac_pa_cflags="$ac_pa_cflags -DHAVE_SYS_SOUNDCARD_H"
|
||||
fi
|
||||
|
||||
|
||||
if test "${ac_cv_header_linux_soundcard_h+set}" = set; then
|
||||
echo "$as_me:$LINENO: checking for linux/soundcard.h" >&5
|
||||
echo $ECHO_N "checking for linux/soundcard.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_linux_soundcard_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_linux_soundcard_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_linux_soundcard_h" >&6
|
||||
else
|
||||
# Is the header compilable?
|
||||
echo "$as_me:$LINENO: checking linux/soundcard.h usability" >&5
|
||||
echo $ECHO_N "checking linux/soundcard.h usability... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
$ac_includes_default
|
||||
#include <linux/soundcard.h>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
||||
echo "${ECHO_T}$ac_header_compiler" >&6
|
||||
|
||||
# Is the header present?
|
||||
echo "$as_me:$LINENO: checking linux/soundcard.h presence" >&5
|
||||
echo $ECHO_N "checking linux/soundcard.h presence... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <linux/soundcard.h>
|
||||
_ACEOF
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
||||
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } >/dev/null; then
|
||||
if test -s conftest.err; then
|
||||
ac_cpp_err=$ac_c_preproc_warn_flag
|
||||
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
|
||||
else
|
||||
ac_cpp_err=
|
||||
fi
|
||||
else
|
||||
ac_cpp_err=yes
|
||||
fi
|
||||
if test -z "$ac_cpp_err"; then
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
||||
echo "${ECHO_T}$ac_header_preproc" >&6
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
|
||||
yes:no: )
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: proceeding with the compiler's result" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: proceeding with the compiler's result" >&2;}
|
||||
ac_header_preproc=yes
|
||||
;;
|
||||
no:yes:* )
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: present but cannot be compiled" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: present but cannot be compiled" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: check for missing prerequisite headers?" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: check for missing prerequisite headers?" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: see the Autoconf documentation" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: see the Autoconf documentation" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: proceeding with the preprocessor's result" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: linux/soundcard.h: in the future, the compiler will take precedence" >&5
|
||||
echo "$as_me: WARNING: linux/soundcard.h: in the future, the compiler will take precedence" >&2;}
|
||||
(
|
||||
cat <<\_ASBOX
|
||||
## ------------------------------------ ##
|
||||
## Report this to the pjproject lists. ##
|
||||
## ------------------------------------ ##
|
||||
_ASBOX
|
||||
) |
|
||||
sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
esac
|
||||
echo "$as_me:$LINENO: checking for linux/soundcard.h" >&5
|
||||
echo $ECHO_N "checking for linux/soundcard.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_linux_soundcard_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_cv_header_linux_soundcard_h=$ac_header_preproc
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_linux_soundcard_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_linux_soundcard_h" >&6
|
||||
|
||||
fi
|
||||
if test $ac_cv_header_linux_soundcard_h = yes; then
|
||||
ac_pa_cflags="$ac_pa_cflags -DHAVE_LINUX_SOUNDCARD_H"
|
||||
fi
|
||||
|
||||
|
||||
if test "${ac_cv_header_machine_soundcard_h+set}" = set; then
|
||||
echo "$as_me:$LINENO: checking for machine/soundcard.h" >&5
|
||||
echo $ECHO_N "checking for machine/soundcard.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_machine_soundcard_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_machine_soundcard_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_machine_soundcard_h" >&6
|
||||
else
|
||||
# Is the header compilable?
|
||||
echo "$as_me:$LINENO: checking machine/soundcard.h usability" >&5
|
||||
echo $ECHO_N "checking machine/soundcard.h usability... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
$ac_includes_default
|
||||
#include <machine/soundcard.h>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
|
||||
echo "${ECHO_T}$ac_header_compiler" >&6
|
||||
|
||||
# Is the header present?
|
||||
echo "$as_me:$LINENO: checking machine/soundcard.h presence" >&5
|
||||
echo $ECHO_N "checking machine/soundcard.h presence... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <machine/soundcard.h>
|
||||
_ACEOF
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
|
||||
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } >/dev/null; then
|
||||
if test -s conftest.err; then
|
||||
ac_cpp_err=$ac_c_preproc_warn_flag
|
||||
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
|
||||
else
|
||||
ac_cpp_err=
|
||||
fi
|
||||
else
|
||||
ac_cpp_err=yes
|
||||
fi
|
||||
if test -z "$ac_cpp_err"; then
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
|
||||
echo "${ECHO_T}$ac_header_preproc" >&6
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
|
||||
yes:no: )
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: proceeding with the compiler's result" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: proceeding with the compiler's result" >&2;}
|
||||
ac_header_preproc=yes
|
||||
;;
|
||||
no:yes:* )
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: present but cannot be compiled" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: present but cannot be compiled" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: check for missing prerequisite headers?" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: check for missing prerequisite headers?" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: see the Autoconf documentation" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: see the Autoconf documentation" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: section \"Present But Cannot Be Compiled\"" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: section \"Present But Cannot Be Compiled\"" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: proceeding with the preprocessor's result" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: proceeding with the preprocessor's result" >&2;}
|
||||
{ echo "$as_me:$LINENO: WARNING: machine/soundcard.h: in the future, the compiler will take precedence" >&5
|
||||
echo "$as_me: WARNING: machine/soundcard.h: in the future, the compiler will take precedence" >&2;}
|
||||
(
|
||||
cat <<\_ASBOX
|
||||
## ------------------------------------ ##
|
||||
## Report this to the pjproject lists. ##
|
||||
## ------------------------------------ ##
|
||||
_ASBOX
|
||||
) |
|
||||
sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
esac
|
||||
echo "$as_me:$LINENO: checking for machine/soundcard.h" >&5
|
||||
echo $ECHO_N "checking for machine/soundcard.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_machine_soundcard_h+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_cv_header_machine_soundcard_h=$ac_header_preproc
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_header_machine_soundcard_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_machine_soundcard_h" >&6
|
||||
|
||||
fi
|
||||
if test $ac_cv_header_machine_soundcard_h = yes; then
|
||||
ac_pa_cflags="$ac_pa_cflags -DHAVE_MACHINE_SOUNDCARD_H"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test "$enable_sound" = "no"; then
|
||||
true;
|
||||
else
|
||||
|
@ -8382,7 +8808,7 @@ else
|
|||
*darwin*)
|
||||
LIBS="$LIBS -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox"
|
||||
if test "`uname -r`" = "6.8"; then
|
||||
#ac_pa_cflags="-DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS"
|
||||
#ac_pa_cflags="$ac_pa_cflags -DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS"
|
||||
#AC_MSG_RESULT([Setting additional PortAudio CFLAGS.. -DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS])
|
||||
ac_pjmedia_snd=pa_old_darwinos
|
||||
echo "$as_me:$LINENO: result: Checking sound device backend... old coreaudio" >&5
|
||||
|
@ -8588,20 +9014,6 @@ echo "${ECHO_T}Checking if large filter is disabled... no" >&6
|
|||
fi;
|
||||
|
||||
|
||||
# Check whether --enable-g711-plc or --disable-g711-plc was given.
|
||||
if test "${enable_g711_plc+set}" = set; then
|
||||
enableval="$enable_g711_plc"
|
||||
if test "$enable_g711_plc" = "no"; then
|
||||
ac_no_g711_plc='-DPJMEDIA_HAS_G711_PLC=0'
|
||||
echo "$as_me:$LINENO: result: Checking if G.711 Annex A PLC is disabled...yes" >&5
|
||||
echo "${ECHO_T}Checking if G.711 Annex A PLC is disabled...yes" >&6
|
||||
fi
|
||||
else
|
||||
echo "$as_me:$LINENO: result: Checking if G.711 Annex A PLC is disabled...no" >&5
|
||||
echo "${ECHO_T}Checking if G.711 Annex A PLC is disabled...no" >&6
|
||||
fi;
|
||||
|
||||
|
||||
# Check whether --enable-speex-aec or --disable-speex-aec was given.
|
||||
if test "${enable_speex_aec+set}" = set; then
|
||||
enableval="$enable_speex_aec"
|
||||
|
@ -9498,7 +9910,7 @@ _ASBOX
|
|||
} >&5
|
||||
cat >&5 <<_CSEOF
|
||||
|
||||
This file was extended by pjproject $as_me 0.5.10, which was
|
||||
This file was extended by pjproject $as_me 0.6.0, which was
|
||||
generated by GNU Autoconf 2.59. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -9558,7 +9970,7 @@ _ACEOF
|
|||
|
||||
cat >>$CONFIG_STATUS <<_ACEOF
|
||||
ac_cs_version="\\
|
||||
pjproject config.status 0.5.10
|
||||
pjproject config.status 0.6.0
|
||||
configured by $0, generated by GNU Autoconf 2.59,
|
||||
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
||||
|
||||
|
@ -9666,6 +10078,8 @@ do
|
|||
"pjlib-util/build/os-auto.mak" ) CONFIG_FILES="$CONFIG_FILES pjlib-util/build/os-auto.mak" ;;
|
||||
"pjmedia/build/os-auto.mak" ) CONFIG_FILES="$CONFIG_FILES pjmedia/build/os-auto.mak" ;;
|
||||
"pjsip/build/os-auto.mak" ) CONFIG_FILES="$CONFIG_FILES pjsip/build/os-auto.mak" ;;
|
||||
"third_party/build/portaudio/os-auto.mak" ) CONFIG_FILES="$CONFIG_FILES third_party/build/portaudio/os-auto.mak" ;;
|
||||
"third_party/build/os-auto.mak" ) CONFIG_FILES="$CONFIG_FILES third_party/build/os-auto.mak" ;;
|
||||
"pjlib/include/pj/compat/os_auto.h" ) CONFIG_HEADERS="$CONFIG_HEADERS pjlib/include/pj/compat/os_auto.h" ;;
|
||||
"pjlib/include/pj/compat/m_auto.h" ) CONFIG_HEADERS="$CONFIG_HEADERS pjlib/include/pj/compat/m_auto.h" ;;
|
||||
"pjmedia/include/pjmedia/config_auto.h" ) CONFIG_HEADERS="$CONFIG_HEADERS pjmedia/include/pjmedia/config_auto.h" ;;
|
||||
|
@ -9786,7 +10200,6 @@ s,@ac_pa_cflags@,$ac_pa_cflags,;t t
|
|||
s,@ac_pa_use_alsa@,$ac_pa_use_alsa,;t t
|
||||
s,@ac_no_small_filter@,$ac_no_small_filter,;t t
|
||||
s,@ac_no_large_filter@,$ac_no_large_filter,;t t
|
||||
s,@ac_no_g711_plc@,$ac_no_g711_plc,;t t
|
||||
s,@ac_no_speex_aec@,$ac_no_speex_aec,;t t
|
||||
s,@ac_no_g711_codec@,$ac_no_g711_codec,;t t
|
||||
s,@ac_no_l16_codec@,$ac_no_l16_codec,;t t
|
||||
|
@ -10290,3 +10703,25 @@ if test "$no_create" != yes; then
|
|||
fi
|
||||
|
||||
|
||||
|
||||
echo "$as_me:$LINENO: result:
|
||||
|
||||
The configuration for current target has been written to 'build.mak', and 'os-auto.mak' in various build directories.
|
||||
|
||||
Customizations can be put in:
|
||||
- 'user.mak'
|
||||
- 'pjlib/include/pj/config_site.h'
|
||||
|
||||
The next step now is to run 'make dep' and 'make'.
|
||||
" >&5
|
||||
echo "${ECHO_T}
|
||||
|
||||
The configuration for current target has been written to 'build.mak', and 'os-auto.mak' in various build directories.
|
||||
|
||||
Customizations can be put in:
|
||||
- 'user.mak'
|
||||
- 'pjlib/include/pj/config_site.h'
|
||||
|
||||
The next step now is to run 'make dep' and 'make'.
|
||||
" >&6
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
AC_INIT(pjproject,0.5.10)
|
||||
AC_INIT(pjproject,0.6.0)
|
||||
|
||||
host_orig="$host"
|
||||
|
||||
|
@ -17,6 +17,8 @@ AC_CONFIG_FILES([build.mak
|
|||
pjlib-util/build/os-auto.mak
|
||||
pjmedia/build/os-auto.mak
|
||||
pjsip/build/os-auto.mak
|
||||
third_party/build/portaudio/os-auto.mak
|
||||
third_party/build/os-auto.mak
|
||||
])
|
||||
|
||||
|
||||
|
@ -252,6 +254,13 @@ AC_ARG_ENABLE(sound,
|
|||
)
|
||||
|
||||
AC_SUBST(ac_pa_cflags)
|
||||
AC_CHECK_HEADER(sys/soundcard.h,
|
||||
[ac_pa_cflags="$ac_pa_cflags -DHAVE_SYS_SOUNDCARD_H"])
|
||||
AC_CHECK_HEADER(linux/soundcard.h,
|
||||
[ac_pa_cflags="$ac_pa_cflags -DHAVE_LINUX_SOUNDCARD_H"])
|
||||
AC_CHECK_HEADER(machine/soundcard.h,
|
||||
[ac_pa_cflags="$ac_pa_cflags -DHAVE_MACHINE_SOUNDCARD_H"])
|
||||
|
||||
if test "$enable_sound" = "no"; then
|
||||
true;
|
||||
else
|
||||
|
@ -259,7 +268,7 @@ else
|
|||
*darwin*)
|
||||
LIBS="$LIBS -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox"
|
||||
if test "`uname -r`" = "6.8"; then
|
||||
#ac_pa_cflags="-DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS"
|
||||
#ac_pa_cflags="$ac_pa_cflags -DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS"
|
||||
#AC_MSG_RESULT([Setting additional PortAudio CFLAGS.. -DPA_OLD_CORE_AUDIO -DMOSX_USE_NON_ATOMIC_FLAG_BITS])
|
||||
ac_pjmedia_snd=pa_old_darwinos
|
||||
AC_MSG_RESULT([Checking sound device backend... old coreaudio])
|
||||
|
@ -310,17 +319,6 @@ AC_ARG_ENABLE(large-filter,
|
|||
fi],
|
||||
AC_MSG_RESULT([Checking if large filter is disabled... no]))
|
||||
|
||||
dnl # Include G.711 Annex A PLC
|
||||
AC_SUBST(ac_no_g711_plc)
|
||||
AC_ARG_ENABLE(g711-plc,
|
||||
AC_HELP_STRING([--disable-g711-plc],
|
||||
[Exclude G.711 Annex A PLC]),
|
||||
[if test "$enable_g711_plc" = "no"; then
|
||||
[ac_no_g711_plc='-DPJMEDIA_HAS_G711_PLC=0']
|
||||
AC_MSG_RESULT([Checking if G.711 Annex A PLC is disabled...yes])
|
||||
fi],
|
||||
AC_MSG_RESULT([Checking if G.711 Annex A PLC is disabled...no]))
|
||||
|
||||
dnl # Include Speex AEC
|
||||
AC_SUBST(ac_no_speex_aec)
|
||||
AC_ARG_ENABLE(speex-aec,
|
||||
|
@ -519,3 +517,15 @@ esac
|
|||
AC_SUBST(CC)
|
||||
AC_OUTPUT()
|
||||
|
||||
|
||||
AC_MSG_RESULT([
|
||||
|
||||
The configuration for current target has been written to 'build.mak', and 'os-auto.mak' in various build directories.
|
||||
|
||||
Customizations can be put in:
|
||||
- 'user.mak'
|
||||
- 'pjlib/include/pj/config_site.h'
|
||||
|
||||
The next step now is to run 'make dep' and 'make'.
|
||||
])
|
||||
|
||||
|
|
35
build.mak.in
35
build.mak.in
|
@ -7,20 +7,43 @@ export TARGET_NAME := @target@
|
|||
export CROSS_COMPILE := @ac_cross_compile@
|
||||
export LINUX_POLL := @ac_linux_poll@
|
||||
|
||||
# Application can use this
|
||||
# Determine which party libraries to use
|
||||
export APP_THIRD_PARTY_LIBS := -lresample-$(TARGET_NAME)
|
||||
|
||||
ifneq (@ac_no_gsm_codec@,1)
|
||||
APP_THIRD_PARTY_LIBS += -lgsmcodec-$(TARGET_NAME)
|
||||
endif
|
||||
|
||||
ifneq (@ac_no_speex_codec@,1)
|
||||
APP_THIRD_PARTY_LIBS += -lspeex-$(TARGET_NAME)
|
||||
endif
|
||||
|
||||
ifneq (@ac_no_ilbc_codec@,1)
|
||||
APP_THIRD_PARTY_LIBS += -lilbccodec-$(TARGET_NAME)
|
||||
endif
|
||||
|
||||
ifneq ($(findstring pa,@ac_pjmedia_snd@),)
|
||||
APP_THIRD_PARTY_LIBS += -lportaudio-$(TARGET_NAME)
|
||||
endif
|
||||
|
||||
|
||||
# CFLAGS, LDFLAGS, and LIBS to be used by applications
|
||||
export PJDIR := @ac_pjdir@
|
||||
export APP_CC := $(CROSS_COMPILE)$(CC_NAME)
|
||||
export APP_CFLAGS := -DPJ_AUTOCONF=1\
|
||||
@CFLAGS@\
|
||||
-I$(PJDIR)/pjlib/include\
|
||||
-I$(PJDIR)/pjlib-util/include\
|
||||
-I$(PJDIR)/pjnath/include\
|
||||
-I$(PJDIR)/pjmedia/include\
|
||||
-I$(PJDIR)/pjsip/include
|
||||
export APP_CXXFLAGS := $(APP_CFLAGS)
|
||||
export APP_LDFLAGS := -L$(PJDIR)/pjlib/lib\
|
||||
-L$(PJDIR)/pjlib-util/lib\
|
||||
-L$(PJDIR)/pjnath/lib\
|
||||
-L$(PJDIR)/pjmedia/lib\
|
||||
-L$(PJDIR)/pjsip/lib\
|
||||
-L$(PJDIR)/third_party/lib\
|
||||
@LDFLAGS@
|
||||
export APP_LDLIBS := -lpjsua-$(TARGET_NAME)\
|
||||
-lpjsip-ua-$(TARGET_NAME)\
|
||||
|
@ -28,8 +51,16 @@ export APP_LDLIBS := -lpjsua-$(TARGET_NAME)\
|
|||
-lpjsip-$(TARGET_NAME)\
|
||||
-lpjmedia-codec-$(TARGET_NAME)\
|
||||
-lpjmedia-$(TARGET_NAME)\
|
||||
-lpjmedia-codec-$(TARGET_NAME)\
|
||||
-lpjnath-$(TARGET_NAME)\
|
||||
-lpjlib-util-$(TARGET_NAME)\
|
||||
$(APP_THIRD_PARTY_LIBS)\
|
||||
-lpj-$(TARGET_NAME)\
|
||||
@LIBS@
|
||||
|
||||
export PJ_DIR := $(PJDIR)
|
||||
export PJ_CC := $(APP_CC)
|
||||
export PJ_CFLAGS := $(APP_CFLAGS)
|
||||
export PJ_CXXFLAGS := $(APP_CXXFLAGS)
|
||||
export PJ_LDFLAGS := $(APP_LDFLAGS)
|
||||
export PJ_LDLIBS := $(APP_LDLIBS)
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
# Include host/target/compiler selection.
|
||||
# This will export CC_NAME, MACHINE_NAME, OS_NAME, and HOST_NAME variables.
|
||||
#
|
||||
include ../../build.mak
|
||||
include $(PJDIR)/build.mak
|
||||
|
||||
#
|
||||
# Include global compiler specific definitions
|
||||
#
|
||||
include ../../build/cc-$(CC_NAME).mak
|
||||
include $(PJDIR)/build/cc-$(CC_NAME).mak
|
||||
|
||||
#
|
||||
# (Optionally) Include compiler specific configuration that is
|
||||
|
@ -19,13 +19,13 @@ include ../../build/cc-$(CC_NAME).mak
|
|||
#
|
||||
# Include global machine specific definitions
|
||||
#
|
||||
include ../../build/m-$(MACHINE_NAME).mak
|
||||
include $(PJDIR)/build/m-$(MACHINE_NAME).mak
|
||||
-include m-$(MACHINE_NAME).mak
|
||||
|
||||
#
|
||||
# Include target OS specific definitions
|
||||
#
|
||||
include ../../build/os-$(OS_NAME).mak
|
||||
include $(PJDIR)/build/os-$(OS_NAME).mak
|
||||
|
||||
#
|
||||
# (Optionally) Include target OS specific configuration that is
|
||||
|
@ -37,7 +37,7 @@ include ../../build/os-$(OS_NAME).mak
|
|||
#
|
||||
# Include host specific definitions
|
||||
#
|
||||
include ../../build/host-$(HOST_NAME).mak
|
||||
include $(PJDIR)/build/host-$(HOST_NAME).mak
|
||||
|
||||
#
|
||||
# (Optionally) Include host specific configuration that is
|
||||
|
@ -49,6 +49,6 @@ include ../../build/host-$(HOST_NAME).mak
|
|||
#
|
||||
# Include global user configuration, if any
|
||||
#
|
||||
-include ../../user.mak
|
||||
-include $(PJDIR)/user.mak
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ export OS_CFLAGS := $(CC_DEF)PJ_LINUX=1
|
|||
|
||||
export OS_CXXFLAGS :=
|
||||
|
||||
export OS_LDFLAGS := $(CC_LIB)pthread$(LIBEXT2) -lm
|
||||
export OS_LDFLAGS := -lportaudio-$(TARGET_NAME) -lgsmcodec-$(TARGET_NAME) -lilbccodec-$(TARGET_NAME) -lspeex-$(TARGET_NAME) -lresample-$(TARGET_NAME) $(CC_LIB)pthread$(LIBEXT2) -lm
|
||||
|
||||
export OS_SOURCES :=
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
ifeq ($(LIBDIR),)
|
||||
LIBDIR = ../lib
|
||||
endif
|
||||
ifeq ($(BINDIR),)
|
||||
BINDIR = ../bin
|
||||
endif
|
||||
|
||||
#
|
||||
# The full path of output lib file (e.g. ../lib/libapp.a).
|
||||
|
@ -71,7 +75,7 @@ print_lib: print_common
|
|||
@echo LIBDIR=$(LIBDIR)
|
||||
|
||||
$(LIB): $(LIBDIR) $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
|
||||
$(AR)$(LIB) $(OBJS)
|
||||
$(AR) $(LIB) $(OBJS)
|
||||
$(RANLIB) $(LIB)
|
||||
|
||||
$(EXE): $(BINDIR) $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
PJDIR=`pwd`
|
||||
|
||||
#
|
||||
# Detect machine, unless the choice has been made already.
|
||||
#
|
||||
|
@ -91,16 +93,18 @@ if test -f build.mak; then
|
|||
cp -f build.mak build.mak.old
|
||||
fi
|
||||
|
||||
echo 'Writing build.mak as follows:'
|
||||
echo " MACHINE_NAME = $MACHINE_NAME"
|
||||
echo " OS_NAME = $OS_NAME"
|
||||
echo " HOST_NAME = $HOST_NAME"
|
||||
echo " CC_NAME = $CC_NAME"
|
||||
echo " TARGET_NAME = $TARGET_NAME"
|
||||
echo " CROSS_COMPILE= $CROSS_COMPILE"
|
||||
echo " LINUX_POLL = $LINUX_POLL"
|
||||
echo 'build.mak configurations are set as follows:'
|
||||
echo " PJDIR = $PJDIR"
|
||||
echo " MACHINE_NAME = $MACHINE_NAME"
|
||||
echo " OS_NAME = $OS_NAME"
|
||||
echo " HOST_NAME = $HOST_NAME"
|
||||
echo " CC_NAME = $CC_NAME"
|
||||
echo " TARGET_NAME = $TARGET_NAME"
|
||||
echo " CROSS_COMPILE = $CROSS_COMPILE"
|
||||
echo " LINUX_POLL = $LINUX_POLL"
|
||||
|
||||
echo "# Auto-generated build.mak" > build.mak
|
||||
echo "export PJDIR := $PJDIR" >> build.mak
|
||||
echo "export MACHINE_NAME := $MACHINE_NAME" >> build.mak
|
||||
echo "export OS_NAME := $OS_NAME" >> build.mak
|
||||
echo "export HOST_NAME := $HOST_NAME" >> build.mak
|
||||
|
@ -109,8 +113,31 @@ echo "export TARGET_NAME := $TARGET_NAME" >> build.mak
|
|||
echo "export CROSS_COMPILE := $CROSS_COMPILE" >> build.mak
|
||||
echo "export LINUX_POLL := $LINUX_POLL" >> build.mak
|
||||
|
||||
echo >> build.mak
|
||||
|
||||
cat << EOF >> build.mak
|
||||
export APP_CC = \$(CROSS_COMPILE)\$(CC_NAME)
|
||||
|
||||
export APP_CFLAGS = \$(CC_CFLAGS) \$(OS_CFLAGS) \$(HOST_CFLAGS) \$(M_CFLAGS) \$(CFLAGS) -I\$(PJDIR)/pjlib/include -I\$(PJDIR)/pjlib-util/include -I\$(PJDIR)/pjnath/include -I\$(PJDIR)/pjmedia/include -I\$(PJDIR)/pjsip/include
|
||||
|
||||
export APP_CXXFLAGS = \$(APP_CFLAGS)
|
||||
|
||||
export APP_LDFLAGS = -L\$(PJDIR)/pjlib/lib -L\$(PJDIR)/pjlib-util/lib -L\$(PJDIR)/pjnath/lib -L\$(PJDIR)/pjmedia/lib -L\$(PJDIR)/pjsip/lib -L\$(PJDIR)/third_party/lib
|
||||
|
||||
export APP_LDLIBS = -lpjsua-\$(TARGET_NAME) -lpjsip-ua-\$(TARGET_NAME) -lpjsip-simple-\$(TARGET_NAME) -lpjsip-\$(TARGET_NAME) -lpjmedia-codec-\$(TARGET_NAME) -lpjmedia-\$(TARGET_NAME) -lpjnath-\$(TARGET_NAME) -lpjlib-util-\$(TARGET_NAME) \$(APP_THIRD_PARTY_LIBS) -lpj-\$(TARGET_NAME) \$(CC_LDFLAGS) \$(OS_LDFLAGS) \$(M_LDFLAGS) \$(HOST_LDFLAGS) \$(LDFLAGS)
|
||||
|
||||
export PJ_DIR = \$(PJDIR)
|
||||
export PJ_CC = \$(APP_CC)
|
||||
export PJ_CFLAGS = \$(APP_CFLAGS)
|
||||
export PJ_CXXFLAGS = \$(APP_CXXFLAGS)
|
||||
export PJ_LDFLAGS = \$(APP_LDFLAGS)
|
||||
export PJ_LDLIBS = \$(APP_LDLIBS)
|
||||
|
||||
EOF
|
||||
|
||||
touch user.mak
|
||||
|
||||
|
||||
echo
|
||||
echo "The configuration for current host has been written to 'build.mak'."
|
||||
echo "Customizations can be put in:"
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
# OS make file may override this with os-specific files
|
||||
export UTIL_TEST_OBJS = main.o
|
||||
|
||||
include ../../build/common.mak
|
||||
include ../../build.mak
|
||||
include $(PJDIR)/build/common.mak
|
||||
|
||||
RULES_MAK := ../../build/rules.mak
|
||||
RULES_MAK := $(PJDIR)/build/rules.mak
|
||||
|
||||
PJLIB_LIB:=../../pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
|
||||
PJLIB_LIB:=$(PJDIR)/pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
|
||||
export PJLIB_UTIL_LIB:=../lib/libpjlib-util-$(TARGET_NAME)$(LIBEXT)
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="pjlib_util"
|
||||
ProjectGUID="{D1823239-F34E-4134-8385-3C85FE23C7DD}"
|
||||
ProjectGUID="{FE07F272-AE7F-4549-9E9F-EF9B80CB1693}"
|
||||
RootNamespace="pjlib_util"
|
||||
>
|
||||
<Platforms>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
include ../../build/common.mak
|
||||
include ../../build.mak
|
||||
include $(PJDIR)/build/common.mak
|
||||
|
||||
RULES_MAK := ../../build/rules.mak
|
||||
RULES_MAK := $(PJDIR)/build/rules.mak
|
||||
|
||||
|
||||
export PJLIB_LIB := ../lib/libpj-$(TARGET_NAME)$(LIBEXT)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="pjlib"
|
||||
ProjectGUID="{5D0985B4-DAA1-42DB-BDB6-30C2409EAE14}"
|
||||
ProjectGUID="{DA0E03ED-53A7-4050-8A85-90541C5509F8}"
|
||||
RootNamespace="pjlib"
|
||||
>
|
||||
<Platforms>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,49 +1,20 @@
|
|||
include ../../build.mak
|
||||
|
||||
# Before we include local os-mak, set default sound framework to use
|
||||
# PortAudio.
|
||||
export SOUND_OBJS = $(PORTAUDIO_OBJS)
|
||||
THIRD_PARTY:=$(PJDIR)/third_party
|
||||
PA_DIR := $(THIRD_PARTY)/build/portaudio/src
|
||||
|
||||
# Also set default codec files to be included
|
||||
# If these codecs are to be excluded, then the appropriate PJMEDIA_HAS_XXX_CODEC macros
|
||||
# MUST be set too in pj/config_site.h, to inform applications about the codec
|
||||
# availability.
|
||||
#
|
||||
# E.g., to exclude Speex, we need to exclude SPEEX_OBJS from CODEC_OBJS, AND specify
|
||||
# "#define PJMEDIA_HAS_SPEEX_CODEC 0" in pj/config_site.h.
|
||||
#
|
||||
export CODEC_OBJS = l16.o $(GSM_OBJS) $(SPEEX_OBJS) $(ILBC_OBJS)
|
||||
include $(PJDIR)/build/common.mak
|
||||
|
||||
RULES_MAK := $(PJDIR)/build/rules.mak
|
||||
|
||||
include ../../build/common.mak
|
||||
|
||||
RULES_MAK := ../../build/rules.mak
|
||||
|
||||
PJLIB_LIB:=../../pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
|
||||
PJLIB_UTIL_LIB:=../../pjlib-util/lib/libpjlib-util-$(TARGET_NAME)$(LIBEXT)
|
||||
PJNATH_LIB:=../../pjnath/lib/libpjnath-$(TARGET_NAME)$(LIBEXT)
|
||||
PJLIB_LIB:=$(PJDIR)/pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
|
||||
PJLIB_UTIL_LIB:=$(PJDIR)/pjlib-util/lib/libpjlib-util-$(TARGET_NAME)$(LIBEXT)
|
||||
PJNATH_LIB:=$(PJDIR)/pjnath/lib/libpjnath-$(TARGET_NAME)$(LIBEXT)
|
||||
|
||||
export PJMEDIA_LIB:=../lib/libpjmedia-$(TARGET_NAME)$(LIBEXT)
|
||||
export PJMEDIA_CODEC_LIB:=../lib/libpjmedia-codec-$(TARGET_NAME)$(LIBEXT)
|
||||
export PJSDP_LIB:=../lib/libpjsdp-$(TARGET_NAME)$(LIBEXT)
|
||||
|
||||
###############################################################################
|
||||
# Sound frameworks
|
||||
# These are activated by setting SOUND_OBJS var, e.g.:
|
||||
# export SOUND_OBJS = $(PORTAUDIO_OBJS), or
|
||||
# export SOUND_OBJS = $(NULLSOUND_OBJS)
|
||||
#
|
||||
PA_DIR:=portaudio
|
||||
PORTAUDIO_OBJS := pasound.o \
|
||||
$(PA_DIR)/pa_allocation.o \
|
||||
$(PA_DIR)/pa_converters.o \
|
||||
$(PA_DIR)/pa_cpuload.o \
|
||||
$(PA_DIR)/pa_dither.o \
|
||||
$(PA_DIR)/pa_front.o \
|
||||
$(PA_DIR)/pa_process.o \
|
||||
$(PA_DIR)/pa_skeleton.o \
|
||||
$(PA_DIR)/pa_stream.o \
|
||||
$(PA_DIR)/pa_trace.o
|
||||
|
||||
NULLSOUND_OBJS := nullsound.o
|
||||
|
||||
###############################################################################
|
||||
|
@ -54,8 +25,7 @@ export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
|
|||
$(CC_INC)../../pjlib/include \
|
||||
$(CC_INC)../../pjlib-util/include \
|
||||
$(CC_INC)../../pjnath/include \
|
||||
$(CC_INC)../src/pjmedia/portaudio \
|
||||
$(CC_INC)../src/pjmedia-codec
|
||||
$(CC_INC)../..
|
||||
export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
|
||||
$(HOST_CXXFLAGS) $(CXXFLAGS)
|
||||
export _LDFLAGS := $(subst /,$(HOST_PSEP),$(PJMEDIA_LIB)) \
|
||||
|
@ -71,11 +41,11 @@ export _LDFLAGS := $(subst /,$(HOST_PSEP),$(PJMEDIA_LIB)) \
|
|||
export PJMEDIA_SRCDIR = ../src/pjmedia
|
||||
export PJMEDIA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
|
||||
alaw_ulaw.o alaw_ulaw_table.o clock_thread.o codec.o \
|
||||
conference.o echo_common.o echo_port.o echo_speex.o \
|
||||
conference.o echo_common.o echo_port.o \
|
||||
echo_suppress.o endpoint.o errno.o \
|
||||
g711.o jbuf.o master_port.o mem_capture.o mem_player.o \
|
||||
mp3_writer.o null_port.o plc_common.o plc_steveu.o \
|
||||
port.o splitcomb.o resample.o \
|
||||
null_port.o plc_common.o port.o splitcomb.o \
|
||||
resample_resample.o \
|
||||
resample_port.o rtcp.o rtp.o sdp.o sdp_cmp.o sdp_neg.o \
|
||||
session.o silencedet.o sound_port.o stream.o \
|
||||
tonegen.o transport_ice.o transport_udp.o \
|
||||
|
@ -100,43 +70,6 @@ export PJSDP_CFLAGS += $(_CFLAGS)
|
|||
###############################################################################
|
||||
# Defines for building PJMEDIA-Codec library
|
||||
#
|
||||
GSM_OBJS := gsm.o \
|
||||
gsm/add.o gsm/code.o gsm/decode.o \
|
||||
gsm/gsm_create.o gsm/gsm_decode.o gsm/gsm_destroy.o \
|
||||
gsm/gsm_encode.o gsm/gsm_explode.o gsm/gsm_implode.o \
|
||||
gsm/gsm_option.o gsm/long_term.o \
|
||||
gsm/lpc.o gsm/preprocess.o gsm/rpe.o gsm/short_term.o \
|
||||
gsm/table.o
|
||||
GSM_CFLAGS :=
|
||||
|
||||
SPEEX_OBJS := speex_codec.o \
|
||||
speex/bits.o speex/cb_search.o speex/exc_10_16_table.o \
|
||||
speex/exc_10_32_table.o speex/exc_20_32_table.o \
|
||||
speex/exc_5_256_table.o speex/exc_5_64_table.o \
|
||||
speex/exc_8_128_table.o speex/fftwrap.o speex/filterbank.o \
|
||||
speex/filters.o speex/gain_table.o speex/gain_table_lbr.o \
|
||||
speex/hexc_10_32_table.o speex/hexc_table.o \
|
||||
speex/high_lsp_tables.o speex/jitter.o \
|
||||
speex/kiss_fft.o speex/kiss_fftr.o speex/lpc_spx.o \
|
||||
speex/lsp.o speex/lsp_tables_nb.o speex/ltp.o \
|
||||
speex/math_approx.o speex/misc.o speex/mdf.o speex/modes.o \
|
||||
speex/nb_celp.o speex/preprocess_spx.o \
|
||||
speex/quant_lsp.o speex/sb_celp.o speex/smallft.o \
|
||||
speex/speex.o speex/speex_callbacks.o speex/speex_header.o \
|
||||
speex/stereo.o speex/vbr.o speex/vq.o speex/window.o
|
||||
SPEEX_CFLAGS := -DHAVE_CONFIG_H=1 -I../src/pjmedia-codec
|
||||
|
||||
ILBC_OBJS := ilbc.o \
|
||||
ilbc/FrameClassify.o ilbc/LPCdecode.o ilbc/LPCencode.o \
|
||||
ilbc/StateConstructW.o ilbc/StateSearchW.o ilbc/anaFilter.o \
|
||||
ilbc/constants.o ilbc/createCB.o ilbc/doCPLC.o \
|
||||
ilbc/enhancer.o ilbc/filter.o ilbc/gainquant.o \
|
||||
ilbc/getCBvec.o ilbc/helpfun.o ilbc/hpInput.o \
|
||||
ilbc/hpOutput.o ilbc/iCBConstruct.o ilbc/iCBSearch.o \
|
||||
ilbc/iLBC_decode.o ilbc/iLBC_encode.o ilbc/lsf.o \
|
||||
ilbc/packing.o ilbc/syntFilter.o
|
||||
ILBC_CFLAGS :=
|
||||
|
||||
export PJMEDIA_CODEC_SRCDIR = ../src/pjmedia-codec
|
||||
export PJMEDIA_CODEC_OBJS += \
|
||||
$(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# @configure_input@
|
||||
|
||||
# PJMEDIA features exclusion
|
||||
export CFLAGS += @ac_no_small_filter@ @ac_no_large_filter@ @ac_no_g711_plc@ @ac_no_speex_aec@
|
||||
export CFLAGS += @ac_no_small_filter@ @ac_no_large_filter@ @ac_no_speex_aec@
|
||||
|
||||
# Define the desired sound device backend
|
||||
# Valid values are:
|
||||
|
@ -44,77 +44,34 @@ endif
|
|||
ifeq ($(AC_NO_GSM_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_GSM_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += $(GSM_OBJS)
|
||||
export CODEC_OBJS += gsm.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_SPEEX_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_SPEEX_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += $(SPEEX_OBJS)
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/speex -I$(THIRD_PARTY)/speex/include
|
||||
export CODEC_OBJS += speex_codec.o
|
||||
|
||||
ifneq (@ac_no_speex_aec@,1)
|
||||
export PJMEDIA_OBJS += echo_speex.o
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_ILBC_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_ILBC_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += $(ILBC_OBJS)
|
||||
export CODEC_OBJS += ilbc.o
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# PortAudio on Unix
|
||||
# PortAudio
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),pa_unix)
|
||||
# Host APIs and utils
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_unix_hostapis.o $(PA_DIR)/pa_unix_util.o
|
||||
|
||||
# Include ALSA?
|
||||
ifeq ($(AC_PA_USE_ALSA),1)
|
||||
export CFLAGS += -DPA_USE_ALSA=1
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_linux_alsa.o
|
||||
endif
|
||||
|
||||
export CFLAGS += -DPA_USE_OSS=1 \
|
||||
-DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_unix_oss.o
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# PortAudio on MacOS X (using current PortAudio)
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),pa_darwinos)
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_mac_hostapis.o \
|
||||
$(PA_DIR)/pa_unix_util.o \
|
||||
$(PA_DIR)/pa_mac_core.o \
|
||||
$(PA_DIR)/pa_mac_core_blocking.o \
|
||||
$(PA_DIR)/pa_mac_core_utilities.o \
|
||||
$(PA_DIR)/ringbuffer.o
|
||||
export CFLAGS += -DPA_USE_COREAUDIO=1 \
|
||||
-DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export CFLAGS += @ac_pa_cflags@
|
||||
endif
|
||||
|
||||
#
|
||||
# PortAudio on MacOS X (using old PortAudio, for MacOS X 10.2.x)
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),pa_old_darwinos)
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_mac_hostapis.o \
|
||||
$(PA_DIR)/pa_unix_util.o \
|
||||
$(PA_DIR)/pa_mac_core_old.o
|
||||
export CFLAGS += -DPA_USE_COREAUDIO=1 \
|
||||
-DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export CFLAGS += @ac_pa_cflags@
|
||||
endif
|
||||
|
||||
#
|
||||
#
|
||||
# PortAudio on Win32 (WMME)
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),pa_win32)
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_win_hostapis.o $(PA_DIR)/pa_win_util.o \
|
||||
$(PA_DIR)/pa_win_wmme.o
|
||||
export CFLAGS += -DPA_NO_ASIO -DPA_NO_DS \
|
||||
-DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
ifneq ($(findstring pa,$(AC_PJMEDIA_SND)),)
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/portaudio -I$(THIRD_PARTY)/portaudio/include -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export SOUND_OBJS = pasound.o
|
||||
endif
|
||||
|
||||
#
|
||||
|
|
|
@ -1,17 +1,91 @@
|
|||
#
|
||||
# OS specific configuration for Darwin/MacOS target.
|
||||
#
|
||||
|
||||
# PJMEDIA features exclusion
|
||||
export CFLAGS +=
|
||||
|
||||
# Define the desired sound device backend
|
||||
# Valid values are:
|
||||
# - pa_unix: PortAudio on Unix (OSS or ALSA)
|
||||
# - pa_darwinos: PortAudio on MacOSX (CoreAudio)
|
||||
# - pa_old_darwinos: PortAudio on MacOSX (old CoreAudio, for OSX 10.2)
|
||||
# - pa_win32: PortAudio on Win32 (WMME)
|
||||
# - ds: Win32 DirectSound (dsound.c)
|
||||
# - null: Null sound device (nullsound.c)
|
||||
AC_PJMEDIA_SND=pa_old_darwinos
|
||||
|
||||
# For Unix, specify if ALSA should be supported
|
||||
AC_PA_USE_ALSA=0
|
||||
|
||||
#
|
||||
# PJMEDIA_OBJS specified here are object files to be included in PJMEDIA
|
||||
# (the library) for this specific operating system. Object files common
|
||||
# to all operating systems should go in Makefile instead.
|
||||
# Codecs
|
||||
#
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_mac_hostapis.o \
|
||||
$(PA_DIR)/pa_unix_util.o \
|
||||
$(PA_DIR)/pa_mac_core.o
|
||||
AC_NO_G711_CODEC=0
|
||||
AC_NO_L16_CODEC=0
|
||||
AC_NO_GSM_CODEC=0
|
||||
AC_NO_SPEEX_CODEC=0
|
||||
AC_NO_ILBC_CODEC=0
|
||||
|
||||
export CODEC_OBJS=
|
||||
|
||||
ifeq ($(AC_NO_G711_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_G711_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS +=
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_L16_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_L16_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += l16.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_GSM_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_GSM_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += gsm.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_SPEEX_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_SPEEX_CODEC=0
|
||||
else
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/speex -I$(THIRD_PARTY)/speex/include
|
||||
export CODEC_OBJS += speex_codec.o
|
||||
|
||||
#ifeq (@ac_no_speex_aec@,1)
|
||||
ifeq (0,1)
|
||||
export PJMEDIA_OBJS += echo_speex.o
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_ILBC_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_ILBC_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += ilbc.o
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# PortAudio
|
||||
#
|
||||
ifneq ($(findstring pa,$(AC_PJMEDIA_SND)),)
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/portaudio -I$(THIRD_PARTY)/portaudio/include -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export SOUND_OBJS = pasound.o
|
||||
endif
|
||||
|
||||
#
|
||||
# Win32 DirectSound
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),ds)
|
||||
export SOUND_OBJS = dsound.o
|
||||
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_WIN32_DIRECT_SOUND
|
||||
endif
|
||||
|
||||
#
|
||||
# Last resort, null sound device
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),null)
|
||||
export SOUND_OBJS = nullsound.o
|
||||
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_NULL_SOUND
|
||||
endif
|
||||
|
||||
# $(PA_DIR)/pa_mac_alt.o
|
||||
# $(PA_DIR)/ringbuffer.o
|
||||
|
||||
export OS_CFLAGS += $(CC_DEF)PA_USE_COREAUDIO=1 $(CC_DEF)PA_BIG_ENDIAN=1
|
||||
|
|
|
@ -1,14 +1,85 @@
|
|||
#
|
||||
# OS specific configuration for Linux OS target.
|
||||
#
|
||||
# Linux
|
||||
|
||||
# Define the desired sound device backend
|
||||
# Valid values are:
|
||||
# - pa_unix: PortAudio on Unix (OSS or ALSA)
|
||||
# - pa_darwinos: PortAudio on MacOSX (CoreAudio)
|
||||
# - pa_old_darwinos: PortAudio on MacOSX (old CoreAudio, for OSX 10.2)
|
||||
# - pa_win32: PortAudio on Win32 (WMME)
|
||||
# - ds: Win32 DirectSound (dsound.c)
|
||||
# - null: Null sound device (nullsound.c)
|
||||
AC_PJMEDIA_SND=pa_unix
|
||||
|
||||
#
|
||||
# PJMEDIA_OBJS specified here are object files to be included in PJMEDIA
|
||||
# (the library) for this specific operating system. Object files common
|
||||
# to all operating systems should go in Makefile instead.
|
||||
# Codecs
|
||||
#
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_unix_hostapis.o $(PA_DIR)/pa_unix_util.o \
|
||||
$(PA_DIR)/pa_unix_oss.o
|
||||
# $(PA_DIR)/pa_linux_alsa.o
|
||||
AC_NO_G711_CODEC=0
|
||||
AC_NO_L16_CODEC=0
|
||||
AC_NO_GSM_CODEC=0
|
||||
AC_NO_SPEEX_CODEC=0
|
||||
AC_NO_ILBC_CODEC=0
|
||||
|
||||
export CODEC_OBJS=
|
||||
|
||||
ifeq ($(AC_NO_G711_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_G711_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS +=
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_L16_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_L16_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += l16.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_GSM_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_GSM_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += gsm.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_SPEEX_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_SPEEX_CODEC=0
|
||||
else
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/speex -I$(THIRD_PARTY)/speex/include
|
||||
export CODEC_OBJS += speex_codec.o
|
||||
|
||||
ifeq (1,1)
|
||||
export PJMEDIA_OBJS += echo_speex.o
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_ILBC_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_ILBC_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += ilbc.o
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# PortAudio
|
||||
#
|
||||
ifneq ($(findstring pa,$(AC_PJMEDIA_SND)),)
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/portaudio -I$(THIRD_PARTY)/portaudio/include -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export SOUND_OBJS = pasound.o
|
||||
endif
|
||||
|
||||
#
|
||||
# Win32 DirectSound
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),ds)
|
||||
export SOUND_OBJS = dsound.o
|
||||
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_WIN32_DIRECT_SOUND
|
||||
endif
|
||||
|
||||
#
|
||||
# Last resort, null sound device
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),null)
|
||||
export SOUND_OBJS = nullsound.o
|
||||
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_NULL_SOUND
|
||||
endif
|
||||
|
||||
|
||||
export OS_CFLAGS += $(CC_DEF)PA_USE_OSS=1
|
||||
|
|
|
@ -1,26 +1,87 @@
|
|||
#
|
||||
# OS specific configuration for Win32 OS target.
|
||||
#
|
||||
# PJMEDIA features exclusion
|
||||
export CFLAGS +=
|
||||
|
||||
# Define the desired sound device backend
|
||||
# Valid values are:
|
||||
# - pa_unix: PortAudio on Unix (OSS or ALSA)
|
||||
# - pa_darwinos: PortAudio on MacOSX (CoreAudio)
|
||||
# - pa_old_darwinos: PortAudio on MacOSX (old CoreAudio, for OSX 10.2)
|
||||
# - pa_win32: PortAudio on Win32 (WMME)
|
||||
# - ds: Win32 DirectSound (dsound.c)
|
||||
# - null: Null sound device (nullsound.c)
|
||||
AC_PJMEDIA_SND=pa_win32
|
||||
|
||||
#
|
||||
# PJMEDIA_OBJS specified here are object files to be included in PJMEDIA
|
||||
# (the library) for this specific operating system. Object files common
|
||||
# to all operating systems should go in Makefile instead.
|
||||
# Codecs
|
||||
#
|
||||
export PJMEDIA_OBJS += $(PA_DIR)/pa_win_hostapis.o $(PA_DIR)/pa_win_util.o \
|
||||
$(PA_DIR)/pa_win_wmme.o
|
||||
AC_NO_G711_CODEC=0
|
||||
AC_NO_L16_CODEC=0
|
||||
AC_NO_GSM_CODEC=0
|
||||
AC_NO_SPEEX_CODEC=0
|
||||
AC_NO_ILBC_CODEC=0
|
||||
|
||||
export OS_CFLAGS += -DPA_NO_ASIO -DPA_NO_DS \
|
||||
-DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export CODEC_OBJS=
|
||||
|
||||
# Example:
|
||||
# to activate Null sound, uncomment these two lines below.
|
||||
#export SOUND_OBJS = $(NULLSOUND_OBJS)
|
||||
#export OS_CFLAGS += $(CC_DEF)PJMEDIA_HAS_NULL_SOUND
|
||||
ifeq ($(AC_NO_G711_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_G711_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS +=
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_L16_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_L16_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += l16.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_GSM_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_GSM_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += gsm.o
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_SPEEX_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_SPEEX_CODEC=0
|
||||
else
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/speex -I$(THIRD_PARTY)/speex/include
|
||||
export CODEC_OBJS += speex_codec.o
|
||||
|
||||
#ifeq (@ac_no_speex_aec@,1)
|
||||
ifeq (0,1)
|
||||
export PJMEDIA_OBJS += echo_speex.o
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(AC_NO_ILBC_CODEC),1)
|
||||
export CFLAGS += -DPJMEDIA_HAS_ILBC_CODEC=0
|
||||
else
|
||||
export CODEC_OBJS += ilbc.o
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# PortAudio
|
||||
#
|
||||
ifneq ($(findstring pa,$(AC_PJMEDIA_SND)),)
|
||||
export CFLAGS += -I$(THIRD_PARTY)/build/portaudio -I$(THIRD_PARTY)/portaudio/include -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_PORTAUDIO_SOUND
|
||||
export SOUND_OBJS = pasound.o
|
||||
endif
|
||||
|
||||
#
|
||||
# Win32 DirectSound
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),ds)
|
||||
export SOUND_OBJS = dsound.o
|
||||
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_WIN32_DIRECT_SOUND
|
||||
endif
|
||||
|
||||
#
|
||||
# Last resort, null sound device
|
||||
#
|
||||
ifeq ($(AC_PJMEDIA_SND),null)
|
||||
export SOUND_OBJS = nullsound.o
|
||||
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_NULL_SOUND
|
||||
endif
|
||||
|
||||
# Example:
|
||||
# to include only GSM and exclude Speex codec, uncomment the "export" line below.
|
||||
# Note that you'll need to put "#define PJMEDIA_HAS_SPEEX_CODEC 0" in
|
||||
# <pj/config_site.h>
|
||||
#export CODEC_OBJS = $(GSM_OBJS)
|
||||
|
||||
|
|
|
@ -40,8 +40,9 @@ RSC=rc.exe
|
|||
# PROP Output_Dir ".\output\pjmedia-i386-win32-vc6-release"
|
||||
# PROP Intermediate_Dir ".\output\pjmedia-i386-win32-vc6-release"
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /GX /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /I "../src/pjmedia-codec" /I "../../pjnath/include" /D "NDEBUG" /D "PA_NO_ASIO" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /GX /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjnath/include" /I "../../third_party/portaudio/include" /I "../../third_party/speex/include" /I "../.." /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
|
@ -64,8 +65,9 @@ LIB32=link.exe -lib
|
|||
# PROP Output_Dir ".\output\pjmedia-i386-win32-vc6-debug"
|
||||
# PROP Intermediate_Dir ".\output\pjmedia-i386-win32-vc6-debug"
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /I "../src/pjmedia-codec" /I "../../pjnath/include" /D "_DEBUG" /D "PA_NO_ASIO" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjnath/include" /I "../../third_party/portaudio/include" /I "../../third_party/speex/include" /I "../.." /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
|
@ -159,10 +161,6 @@ SOURCE=..\src\pjmedia\mem_player.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\mp3_writer.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\null_port.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -179,24 +177,19 @@ SOURCE=..\src\pjmedia\plc_common.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\plc_steveu.c
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\plc_steveu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\port.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\resample.c
|
||||
SOURCE=..\src\pjmedia\resample_port.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\resample_port.c
|
||||
SOURCE=..\src\pjmedia\resample_resample.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\resample_speex.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
@ -332,10 +325,6 @@ SOURCE=..\include\pjmedia\mem_port.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\pjmedia\mp3_port.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\include\pjmedia\null_port.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -427,156 +416,5 @@ SOURCE=..\include\pjmedia\wav_port.h
|
|||
SOURCE=..\include\pjmedia\wave.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "PortAudio Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\dsound_wrapper.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\dsound_wrapper.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_allocation.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_allocation.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_converters.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_converters.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_cpuload.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_cpuload.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_dither.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_dither.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_endianness.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_front.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_hostapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_process.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_process.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_skeleton.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_stream.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_stream.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_trace.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_trace.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_types.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_util.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_win_ds.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_win_hostapis.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_win_util.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_win_wmme.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_win_wmme.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_x86_plain_converters.c
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\pa_x86_plain_converters.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\portaudio\portaudio.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resample Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\largefilter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\src\pjmedia\smallfilter.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="pjmedia"
|
||||
ProjectGUID="{1434FE6C-89C6-4E13-8150-D5A4B1038AAA}"
|
||||
ProjectGUID="{7FDE3880-A4AB-49E3-B439-EBEF0A0C7A65}"
|
||||
RootNamespace="pjmedia"
|
||||
>
|
||||
<Platforms>
|
||||
|
@ -43,8 +43,8 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="../include,../../pjlib/include,../../pjlib-util/include,../src/pjmedia/portaudio,../src/pjmedia-codec,../../pjnath/include"
|
||||
PreprocessorDefinitions="NDEBUG;PA_NO_ASIO;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1"
|
||||
AdditionalIncludeDirectories="../include,../../pjlib/include,../../pjlib-util/include,../../pjnath/include,../../third_party/portaudio/include,../../third_party/speex/include,../.."
|
||||
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
|
@ -119,8 +119,8 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include,../../pjlib/include,../../pjlib-util/include,../src/pjmedia/portaudio,../src/pjmedia-codec,../../pjnath/include"
|
||||
PreprocessorDefinitions="_DEBUG;PA_NO_ASIO;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1"
|
||||
AdditionalIncludeDirectories="../include,../../pjlib/include,../../pjlib-util/include,../../pjnath/include,../../third_party/portaudio/include,../../third_party/speex/include,../.."
|
||||
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
|
@ -571,28 +571,6 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\mp3_writer.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\null_port.c"
|
||||
>
|
||||
|
@ -681,34 +659,6 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\plc_steveu.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="2"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\plc_steveu.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\port.c"
|
||||
>
|
||||
|
@ -731,28 +681,6 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\resample.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\resample_port.c"
|
||||
>
|
||||
|
@ -775,6 +703,14 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\resample_resample.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\resample_speex.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\rtcp.c"
|
||||
>
|
||||
|
@ -1196,10 +1132,6 @@
|
|||
RelativePath="..\include\pjmedia\mem_port.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\pjmedia\mp3_port.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\pjmedia\null_port.h"
|
||||
>
|
||||
|
@ -1293,442 +1225,6 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="PortAudio Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\dsound_wrapper.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\dsound_wrapper.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_allocation.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_allocation.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_converters.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_converters.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_cpuload.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_cpuload.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_dither.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_dither.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_endianness.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_front.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_hostapi.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_process.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_process.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_skeleton.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_stream.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_stream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_trace.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_trace.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_types.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_util.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_win_ds.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_win_hostapis.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_win_util.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_win_wmme.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_win_wmme.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_x86_plain_converters.c"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
WarningLevel="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\pa_x86_plain_converters.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\portaudio\portaudio.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resample Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\largefilter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\pjmedia\smallfilter.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
|
|
@ -40,8 +40,9 @@ RSC=rc.exe
|
|||
# PROP Output_Dir ".\output\pjmedia-codec-i386-win32-vc6-release"
|
||||
# PROP Intermediate_Dir ".\output\pjmedia-codec-i386-win32-vc6-release"
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /c
|
||||
# ADD CPP /nologo /MD /W4 /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /I "../../third_party/speex/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
|
@ -64,8 +65,9 @@ LIB32=link.exe -lib
|
|||
# PROP Output_Dir ".\output\pjmedia-codec-i386-win32-vc6-debug"
|
||||
# PROP Intermediate_Dir ".\output\pjmedia-codec-i386-win32-vc6-debug"
|
||||
# PROP Target_Dir ""
|
||||
F90=df.exe
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /ZI /Od /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /ZI /Od /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /I "../../third_party/speex/include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
|
@ -161,720 +163,5 @@ SOURCE="..\include\pjmedia-codec\speex.h"
|
|||
SOURCE="..\include\pjmedia-codec\types.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "GSM 06.10 Library"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\add.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\code.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\config.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\debug.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\decode.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm_create.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm_decode.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm_destroy.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm_encode.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm_option.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\gsm_print.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\long_term.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\lpc.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\preprocess.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\private.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\proto.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\rpe.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\short_term.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\table.c"
|
||||
# ADD CPP /W2
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\toast.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\gsm\unproto.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Speex Codec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "Speex Header Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\_kiss_fft_guts.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\arch.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\cb_search.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\cb_search_arm4.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\cb_search_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\cb_search_sse.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\config.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fftwrap.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filterbank.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filters.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filters_arm4.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filters_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filters_sse.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fixed_arm4.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fixed_arm5e.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fixed_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fixed_debug.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fixed_generic.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\kiss_fft.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\kiss_fftr.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\lpc.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\lpc_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\lsp.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\ltp.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\ltp_arm4.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\ltp_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\ltp_sse.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\math_approx.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\misc.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\misc_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\modes.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\nb_celp.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\pseudofloat.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\quant_lsp.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\sb_celp.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\smallft.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_bits.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_callbacks.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_echo.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_header.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_jitter.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_preprocess.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_stereo.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_types.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\stack_alloc.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vbr.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vq.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vq_arm4.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vq_bfin.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vq_sse.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Speex Source Files"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\bits.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\cb_search.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\exc_10_16_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\exc_10_32_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\exc_20_32_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\exc_5_256_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\exc_5_64_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\exc_8_128_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\fftwrap.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filterbank.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\filters.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\gain_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\gain_table_lbr.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\hexc_10_32_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\hexc_table.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\high_lsp_tables.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\jitter.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\kiss_fft.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\kiss_fftr.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\lpc_spx.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\lsp.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\lsp_tables_nb.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\ltp.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\math_approx.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\mdf.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\misc.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\modes.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\nb_celp.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\preprocess_spx.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\quant_lsp.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\sb_celp.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\smallft.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_callbacks.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\speex_header.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\stereo.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vbr.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\vq.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\speex\window.c"
|
||||
# ADD CPP /W3
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "iLBC Codec"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\anaFilter.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\anaFilter.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\constants.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\constants.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\createCB.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\createCB.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\doCPLC.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\doCPLC.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\enhancer.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\enhancer.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\filter.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\filter.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\FrameClassify.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\FrameClassify.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\gainquant.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\gainquant.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\getCBvec.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\getCBvec.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\helpfun.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\helpfun.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\hpInput.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\hpInput.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\hpOutput.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\hpOutput.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iCBConstruct.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iCBConstruct.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iCBSearch.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iCBSearch.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iLBC_decode.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iLBC_decode.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iLBC_define.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iLBC_encode.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iLBC_encode.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\iLBC_test.c"
|
||||
# PROP Exclude_From_Build 1
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\LPCdecode.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\LPCdecode.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\LPCencode.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\LPCencode.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\lsf.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\lsf.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\packing.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\packing.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\StateConstructW.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\StateConstructW.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\StateSearchW.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\StateSearchW.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\syntFilter.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE="..\src\pjmedia-codec\ilbc\syntFilter.h"
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -38,7 +38,6 @@
|
|||
#include <pjmedia/jbuf.h>
|
||||
#include <pjmedia/master_port.h>
|
||||
#include <pjmedia/mem_port.h>
|
||||
#include <pjmedia/mp3_port.h>
|
||||
#include <pjmedia/null_port.h>
|
||||
#include <pjmedia/plc.h>
|
||||
#include <pjmedia/port.h>
|
||||
|
|
|
@ -108,24 +108,57 @@
|
|||
#endif
|
||||
|
||||
|
||||
/**
|
||||
/*
|
||||
* ** THIS MACRO IS DEPRECATED in 0.6. **
|
||||
* ** See libresample for configuring this **
|
||||
*
|
||||
* Include small filter table in resample.
|
||||
* This adds about 9KB in rdata.
|
||||
*/
|
||||
/*
|
||||
#ifndef PJMEDIA_HAS_SMALL_FILTER
|
||||
# define PJMEDIA_HAS_SMALL_FILTER 1
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*
|
||||
* ** THIS MACRO IS DEPRECATED in 0.6. **
|
||||
* ** See libresample for configuring this **
|
||||
*
|
||||
* Include large filter table in resample.
|
||||
* This adds about 32KB in rdata.
|
||||
*/
|
||||
/*
|
||||
#ifndef PJMEDIA_HAS_LARGE_FILTER
|
||||
# define PJMEDIA_HAS_LARGE_FILTER 1
|
||||
#endif
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specify whether libresample should be used for the sampling
|
||||
* rate conversion. This macro and PJMEDIA_HAS_SPEEX_RESAMPLE
|
||||
* are mutually exclusive.
|
||||
*
|
||||
* Default: 1 (Yes)
|
||||
*/
|
||||
#ifndef PJMEDIA_HAS_LIBRESAMPLE
|
||||
# define PJMEDIA_HAS_LIBRESAMPLE 1
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Include large filter table in resample.
|
||||
* This adds about 32KB in rdata.
|
||||
* Specify whether Speex sample rate convertor should be used for the
|
||||
* sampling rate conversion. This macro and PJMEDIA_HAS_LIBRESAMPLE
|
||||
* are mutually exclusive.
|
||||
*
|
||||
* Default: 0
|
||||
*/
|
||||
#ifndef PJMEDIA_HAS_LARGE_FILTER
|
||||
# define PJMEDIA_HAS_LARGE_FILTER 1
|
||||
#ifndef PJMEDIA_HAS_SPEEX_RESAMPLE
|
||||
# define PJMEDIA_HAS_SPEEX_RESAMPLE 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default file player/writer buffer size.
|
||||
*/
|
||||
|
@ -243,9 +276,14 @@
|
|||
|
||||
/**
|
||||
* Enable Steve Underwood's PLC.
|
||||
*
|
||||
* ** This has now been deprecated. If the codec does not have **
|
||||
* ** PLC, then no PLC will be used for that particular codec. **
|
||||
*
|
||||
* Set this to zero, or other link error will occur.
|
||||
*/
|
||||
#ifndef PJMEDIA_HAS_STEVEU_PLC
|
||||
# define PJMEDIA_HAS_STEVEU_PLC PJ_HAS_FLOATING_POINT
|
||||
# define PJMEDIA_HAS_STEVEU_PLC 0
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -275,7 +313,7 @@
|
|||
* 16 will effectively zero the signal.
|
||||
*/
|
||||
#ifndef PJMEDIA_ECHO_SUPPRESS_FACTOR
|
||||
# define PJMEDIA_ECHO_SUPPRESS_FACTOR 4
|
||||
# define PJMEDIA_ECHO_SUPPRESS_FACTOR 10
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ typedef struct pjmedia_resample pjmedia_resample;
|
|||
* used, at the expense of more CPU and memory,
|
||||
* because temporary buffer needs to be created.
|
||||
* @param large_filter If true, large filter size will be used.
|
||||
* @param channel_count Number of channels.
|
||||
* @param rate_in Clock rate of the input samples.
|
||||
* @param rate_out Clock rate of the output samples.
|
||||
* @param samples_per_frame Number of samples per frame in the input.
|
||||
|
@ -76,6 +77,7 @@ typedef struct pjmedia_resample pjmedia_resample;
|
|||
PJ_DECL(pj_status_t) pjmedia_resample_create(pj_pool_t *pool,
|
||||
pj_bool_t high_quality,
|
||||
pj_bool_t large_filter,
|
||||
unsigned channel_count,
|
||||
unsigned rate_in,
|
||||
unsigned rate_out,
|
||||
unsigned samples_per_frame,
|
||||
|
@ -106,6 +108,13 @@ PJ_DECL(void) pjmedia_resample_run( pjmedia_resample *resample,
|
|||
PJ_DECL(unsigned) pjmedia_resample_get_input_size(pjmedia_resample *resample);
|
||||
|
||||
|
||||
/**
|
||||
* Destroy the resample.
|
||||
*
|
||||
* @param resample The resample session.
|
||||
*/
|
||||
PJ_DECL(void) pjmedia_resample_destroy(pjmedia_resample *resample);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -27,13 +27,16 @@
|
|||
#include <pj/pool.h>
|
||||
#include <pj/string.h>
|
||||
#include <pj/os.h>
|
||||
#include "gsm/gsm.h"
|
||||
#include "../../third_party/gsm/inc/gsm.h"
|
||||
|
||||
/*
|
||||
* Only build this file if PJMEDIA_HAS_GSM_CODEC != 0
|
||||
*/
|
||||
#if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC != 0
|
||||
|
||||
/* We removed PLC in 0.6 */
|
||||
#define PLC_DISABLED 1
|
||||
|
||||
|
||||
/* Prototypes for GSM factory */
|
||||
static pj_status_t gsm_test_alloc( pjmedia_codec_factory *factory,
|
||||
|
@ -72,9 +75,11 @@ static pj_status_t gsm_codec_decode( pjmedia_codec *codec,
|
|||
const struct pjmedia_frame *input,
|
||||
unsigned output_buf_len,
|
||||
struct pjmedia_frame *output);
|
||||
#if !PLC_DISABLED
|
||||
static pj_status_t gsm_codec_recover(pjmedia_codec *codec,
|
||||
unsigned output_buf_len,
|
||||
struct pjmedia_frame *output);
|
||||
#endif
|
||||
|
||||
/* Definition for GSM codec operations. */
|
||||
static pjmedia_codec_op gsm_op =
|
||||
|
@ -86,7 +91,11 @@ static pjmedia_codec_op gsm_op =
|
|||
&gsm_codec_parse,
|
||||
&gsm_codec_encode,
|
||||
&gsm_codec_decode,
|
||||
#if !PLC_DISABLED
|
||||
&gsm_codec_recover
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Definition for GSM codec factory operations. */
|
||||
|
@ -116,7 +125,9 @@ struct gsm_data
|
|||
void *encoder;
|
||||
void *decoder;
|
||||
pj_bool_t plc_enabled;
|
||||
#if !PLC_DISABLED
|
||||
pjmedia_plc *plc;
|
||||
#endif
|
||||
pj_bool_t vad_enabled;
|
||||
pjmedia_silence_det *vad;
|
||||
pj_timestamp last_tx;
|
||||
|
@ -259,7 +270,9 @@ static pj_status_t gsm_default_attr (pjmedia_codec_factory *factory,
|
|||
|
||||
attr->setting.frm_per_pkt = 1;
|
||||
attr->setting.vad = 1;
|
||||
#if !PLC_DISABLED
|
||||
attr->setting.plc = 1;
|
||||
#endif
|
||||
|
||||
/* Default all other flag bits disabled. */
|
||||
|
||||
|
@ -320,6 +333,7 @@ static pj_status_t gsm_alloc_codec( pjmedia_codec_factory *factory,
|
|||
sizeof(struct gsm_data));
|
||||
codec->codec_data = gsm_data;
|
||||
|
||||
#if !PLC_DISABLED
|
||||
/* Create PLC */
|
||||
status = pjmedia_plc_create(gsm_codec_factory.pool, 8000,
|
||||
160, 0, &gsm_data->plc);
|
||||
|
@ -327,6 +341,7 @@ static pj_status_t gsm_alloc_codec( pjmedia_codec_factory *factory,
|
|||
pj_mutex_unlock(gsm_codec_factory.mutex);
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create silence detector */
|
||||
status = pjmedia_silence_det_create(gsm_codec_factory.pool,
|
||||
|
@ -351,7 +366,6 @@ static pj_status_t gsm_dealloc_codec( pjmedia_codec_factory *factory,
|
|||
pjmedia_codec *codec )
|
||||
{
|
||||
struct gsm_data *gsm_data;
|
||||
pj_int16_t frame[160];
|
||||
int i;
|
||||
|
||||
PJ_ASSERT_RETURN(factory && codec, PJ_EINVAL);
|
||||
|
@ -362,13 +376,18 @@ static pj_status_t gsm_dealloc_codec( pjmedia_codec_factory *factory,
|
|||
/* Close codec, if it's not closed. */
|
||||
gsm_codec_close(codec);
|
||||
|
||||
#if !PLC_DISABLED
|
||||
/* Clear left samples in the PLC, since codec+plc will be reused
|
||||
* next time.
|
||||
*/
|
||||
for (i=0; i<2; ++i) {
|
||||
pj_int16_t frame[160];
|
||||
pjmedia_zero_samples(frame, PJ_ARRAY_SIZE(frame));
|
||||
pjmedia_plc_save(gsm_data->plc, frame);
|
||||
}
|
||||
#else
|
||||
PJ_UNUSED_ARG(i);
|
||||
#endif
|
||||
|
||||
/* Re-init silence_period */
|
||||
pj_set_timestamp32(&gsm_data->last_tx, 0, 0);
|
||||
|
@ -569,13 +588,16 @@ static pj_status_t gsm_codec_decode( pjmedia_codec *codec,
|
|||
output->size = 320;
|
||||
output->type = PJMEDIA_FRAME_TYPE_AUDIO;
|
||||
|
||||
#if !PLC_DISABLED
|
||||
if (gsm_data->plc_enabled)
|
||||
pjmedia_plc_save( gsm_data->plc, output->buf);
|
||||
#endif
|
||||
|
||||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#if !PLC_DISABLED
|
||||
/*
|
||||
* Recover lost frame.
|
||||
*/
|
||||
|
@ -594,6 +616,7 @@ static pj_status_t gsm_codec_recover(pjmedia_codec *codec,
|
|||
|
||||
return PJ_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* PJMEDIA_HAS_GSM_CODEC */
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include <pj/pool.h>
|
||||
#include <pj/string.h>
|
||||
#include <pj/os.h>
|
||||
#include "ilbc/iLBC_encode.h"
|
||||
#include "ilbc/iLBC_decode.h"
|
||||
#include "../../third_party/ilbc/iLBC_encode.h"
|
||||
#include "../../third_party/ilbc/iLBC_decode.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
Jean-Marc Valin <jean-marc.valin@usherbrooke.ca>
|
||||
All the code except the following
|
||||
|
||||
David Rowe <david@voicetronix.com.au> via VoiceTronix
|
||||
lsp.c lsp.h
|
||||
Also ideas and feedback
|
||||
|
||||
John Francis Edwards:
|
||||
wave_out.[ch], some #ifdefs for windows port and MSVC project files
|
||||
|
||||
Segher Boessenkool
|
||||
Misc. optimizations (for QMF in particular)
|
||||
|
||||
Atsuhiko Yamanaka <ymnk@jcraft.com>:
|
||||
Patch to speexenc.c to add Vorbis comment format
|
||||
|
||||
Radim Kolar <hsn@cybermail.net>:
|
||||
Patch to speexenc.c for supporting more input formats
|
|
@ -1,33 +0,0 @@
|
|||
Copyright 2002-2005
|
||||
Xiph.org Foundation
|
||||
Jean-Marc Valin
|
||||
David Rowe
|
||||
EpicGames
|
||||
Analog Devices
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,21 +0,0 @@
|
|||
2005-09-07 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* libspeex/cb_search.c: (split_cb_search_shape_sign_N1):
|
||||
add declaration for n, seems like an obvious build fix, slap
|
||||
me down if it's not
|
||||
|
||||
2004-02-18 Jean-Marc Valin <jean-marc.valin@usherbrooke.ca>
|
||||
Patch for compiling with mingw32 sent by j@thing.net
|
||||
|
||||
2004-02-18 Jean-Marc Valin <jean-marc.valin@usherbrooke.ca>
|
||||
Integrated IRIX patch (getopt stuff) from Michael Pruett <michael@68k.org>
|
||||
|
||||
2004-02-18 Jean-Marc Valin <jean-marc.valin@usherbrooke.ca>
|
||||
Changed the Makefile.am so that KDevelop can parse SUBDIRS correctly
|
||||
|
||||
2002/03/27 Jean-Marc Valin:
|
||||
Working encoder and decoder for both narrowband and wideband.
|
||||
|
||||
2002/02/27 Jean-Marc Valin:
|
||||
Got the basic encoder working as a demo with quantization only on some
|
||||
parameters.
|
|
@ -1,9 +0,0 @@
|
|||
This Speex taken from SVN
|
||||
url="http://svn.xiph.org/trunk/speex",
|
||||
committed-rev="12136"
|
||||
name=""
|
||||
committed-date="2006-11-22T02:21:19.831305Z"
|
||||
last-author="jm"
|
||||
kind="dir"
|
||||
uuid="0101bb08-14d6-0310-b084-bc0e0c8e3800"
|
||||
revision="12140"
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2003-2004, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define MIN(a,b) ((a)<(b) ? (a):(b))
|
||||
#define MAX(a,b) ((a)>(b) ? (a):(b))
|
||||
|
||||
/* kiss_fft.h
|
||||
defines kiss_fft_scalar as either short or a float type
|
||||
and defines
|
||||
typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
|
||||
#include "kiss_fft.h"
|
||||
#include "math_approx.h"
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
4*4*4*2
|
||||
*/
|
||||
|
||||
struct kiss_fft_state{
|
||||
int nfft;
|
||||
int inverse;
|
||||
int factors[2*MAXFACTORS];
|
||||
kiss_fft_cpx twiddles[1];
|
||||
};
|
||||
|
||||
/*
|
||||
Explanation of macros dealing with complex math:
|
||||
|
||||
C_MUL(m,a,b) : m = a*b
|
||||
C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
|
||||
C_SUB( res, a,b) : res = a - b
|
||||
C_SUBFROM( res , a) : res -= a
|
||||
C_ADDTO( res , a) : res += a
|
||||
* */
|
||||
#ifdef FIXED_POINT
|
||||
#include "misc.h"
|
||||
# define FRACBITS 15
|
||||
# define SAMPPROD spx_int32_t
|
||||
#define SAMP_MAX 32767
|
||||
|
||||
#define SAMP_MIN -SAMP_MAX
|
||||
|
||||
#if defined(CHECK_OVERFLOW)
|
||||
# define CHECK_OVERFLOW_OP(a,op,b) \
|
||||
if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
|
||||
fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
|
||||
#endif
|
||||
|
||||
|
||||
# define smul(a,b) ( (SAMPPROD)(a)*(b) )
|
||||
# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS )
|
||||
|
||||
# define S_MUL(a,b) sround( smul(a,b) )
|
||||
|
||||
# define C_MUL(m,a,b) \
|
||||
do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
|
||||
(m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
|
||||
|
||||
# define DIVSCALAR(x,k) \
|
||||
(x) = sround( smul( x, SAMP_MAX/k ) )
|
||||
|
||||
# define C_FIXDIV(c,div) \
|
||||
do { DIVSCALAR( (c).r , div); \
|
||||
DIVSCALAR( (c).i , div); }while (0)
|
||||
|
||||
# define C_MULBYSCALAR( c, s ) \
|
||||
do{ (c).r = sround( smul( (c).r , s ) ) ;\
|
||||
(c).i = sround( smul( (c).i , s ) ) ; }while(0)
|
||||
|
||||
#else /* not FIXED_POINT*/
|
||||
|
||||
# define S_MUL(a,b) ( (a)*(b) )
|
||||
#define C_MUL(m,a,b) \
|
||||
do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
|
||||
(m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
|
||||
# define C_FIXDIV(c,div) /* NOOP */
|
||||
# define C_MULBYSCALAR( c, s ) \
|
||||
do{ (c).r *= (s);\
|
||||
(c).i *= (s); }while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_OVERFLOW_OP
|
||||
# define CHECK_OVERFLOW_OP(a,op,b) /* noop */
|
||||
#endif
|
||||
|
||||
#define C_ADD( res, a,b)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((a).r,+,(b).r)\
|
||||
CHECK_OVERFLOW_OP((a).i,+,(b).i)\
|
||||
(res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
|
||||
}while(0)
|
||||
#define C_SUB( res, a,b)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((a).r,-,(b).r)\
|
||||
CHECK_OVERFLOW_OP((a).i,-,(b).i)\
|
||||
(res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
|
||||
}while(0)
|
||||
#define C_ADDTO( res , a)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((res).r,+,(a).r)\
|
||||
CHECK_OVERFLOW_OP((res).i,+,(a).i)\
|
||||
(res).r += (a).r; (res).i += (a).i;\
|
||||
}while(0)
|
||||
|
||||
#define C_SUBFROM( res , a)\
|
||||
do {\
|
||||
CHECK_OVERFLOW_OP((res).r,-,(a).r)\
|
||||
CHECK_OVERFLOW_OP((res).i,-,(a).i)\
|
||||
(res).r -= (a).r; (res).i -= (a).i; \
|
||||
}while(0)
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
# define KISS_FFT_COS(phase) floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase))))
|
||||
# define KISS_FFT_SIN(phase) floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase))))
|
||||
# define HALF_OF(x) ((x)>>1)
|
||||
#elif defined(USE_SIMD)
|
||||
# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
|
||||
# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
|
||||
# define HALF_OF(x) ((x)*_mm_set1_ps(.5))
|
||||
#else
|
||||
# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
|
||||
# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
|
||||
# define HALF_OF(x) ((x)*.5)
|
||||
#endif
|
||||
|
||||
#define kf_cexp(x,phase) \
|
||||
do{ \
|
||||
(x)->r = KISS_FFT_COS(phase);\
|
||||
(x)->i = KISS_FFT_SIN(phase);\
|
||||
}while(0)
|
||||
#define kf_cexp2(x,phase) \
|
||||
do{ \
|
||||
(x)->r = spx_cos_norm((phase));\
|
||||
(x)->i = spx_cos_norm((phase)-32768);\
|
||||
}while(0)
|
||||
|
||||
|
||||
/* a debugging function */
|
||||
#define pcpx(c)\
|
||||
fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
|
|
@ -1,195 +0,0 @@
|
|||
/* Copyright (C) 2003 Jean-Marc Valin */
|
||||
/**
|
||||
@file arch.h
|
||||
@brief Various architecture definitions Speex
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ARCH_H
|
||||
#define ARCH_H
|
||||
|
||||
#include "speex/speex_types.h"
|
||||
|
||||
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
|
||||
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
|
||||
#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */
|
||||
#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */
|
||||
#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
typedef spx_int16_t spx_word16_t;
|
||||
typedef spx_int32_t spx_word32_t;
|
||||
typedef spx_word32_t spx_mem_t;
|
||||
typedef spx_word16_t spx_coef_t;
|
||||
typedef spx_word16_t spx_lsp_t;
|
||||
typedef spx_word32_t spx_sig_t;
|
||||
|
||||
#define Q15ONE 32767
|
||||
|
||||
#define LPC_SCALING 8192
|
||||
#define SIG_SCALING 16384
|
||||
#define LSP_SCALING 8192.
|
||||
#define GAMMA_SCALING 32768.
|
||||
#define GAIN_SCALING 64
|
||||
#define GAIN_SCALING_1 0.015625
|
||||
|
||||
#define LPC_SHIFT 13
|
||||
#define LSP_SHIFT 13
|
||||
#define SIG_SHIFT 14
|
||||
|
||||
#define VERY_SMALL 0
|
||||
#define VERY_LARGE32 ((spx_word32_t)2147483647)
|
||||
#define VERY_LARGE16 ((spx_word16_t)32767)
|
||||
#define Q15_ONE ((spx_word16_t)32767)
|
||||
|
||||
|
||||
#ifdef FIXED_DEBUG
|
||||
#include "fixed_debug.h"
|
||||
#else
|
||||
|
||||
#include "fixed_generic.h"
|
||||
|
||||
#ifdef ARM5E_ASM
|
||||
#include "fixed_arm5e.h"
|
||||
#elif defined (ARM4_ASM)
|
||||
#include "fixed_arm4.h"
|
||||
#elif defined (ARM5E_ASM)
|
||||
#include "fixed_arm5e.h"
|
||||
#elif defined (BFIN_ASM)
|
||||
#include "fixed_bfin.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
typedef float spx_mem_t;
|
||||
typedef float spx_coef_t;
|
||||
typedef float spx_lsp_t;
|
||||
typedef float spx_sig_t;
|
||||
typedef float spx_word16_t;
|
||||
typedef float spx_word32_t;
|
||||
|
||||
#define Q15ONE 1.0f
|
||||
#define LPC_SCALING 1.f
|
||||
#define SIG_SCALING 1.f
|
||||
#define LSP_SCALING 1.f
|
||||
#define GAMMA_SCALING 1.f
|
||||
#define GAIN_SCALING 1.f
|
||||
#define GAIN_SCALING_1 1.f
|
||||
|
||||
#define LPC_SHIFT 0
|
||||
#define LSP_SHIFT 0
|
||||
#define SIG_SHIFT 0
|
||||
|
||||
#define VERY_SMALL 1e-15f
|
||||
#define VERY_LARGE32 1e15f
|
||||
#define VERY_LARGE16 1e15f
|
||||
#define Q15_ONE ((spx_word16_t)1.f)
|
||||
|
||||
#define QCONST16(x,bits) (x)
|
||||
#define QCONST32(x,bits) (x)
|
||||
|
||||
#define NEG16(x) (-(x))
|
||||
#define NEG32(x) (-(x))
|
||||
#define EXTRACT16(x) (x)
|
||||
#define EXTEND32(x) (x)
|
||||
#define SHR16(a,shift) (a)
|
||||
#define SHL16(a,shift) (a)
|
||||
#define SHR32(a,shift) (a)
|
||||
#define SHL32(a,shift) (a)
|
||||
#define PSHR16(a,shift) (a)
|
||||
#define PSHR32(a,shift) (a)
|
||||
#define VSHR32(a,shift) (a)
|
||||
#define SATURATE16(x,a) (x)
|
||||
#define SATURATE32(x,a) (x)
|
||||
|
||||
#define PSHR(a,shift) (a)
|
||||
#define SHR(a,shift) (a)
|
||||
#define SHL(a,shift) (a)
|
||||
#define SATURATE(x,a) (x)
|
||||
|
||||
#define ADD16(a,b) ((a)+(b))
|
||||
#define SUB16(a,b) ((a)-(b))
|
||||
#define ADD32(a,b) ((a)+(b))
|
||||
#define SUB32(a,b) ((a)-(b))
|
||||
#define MULT16_16_16(a,b) ((a)*(b))
|
||||
#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b))
|
||||
#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
|
||||
|
||||
#define MULT16_32_Q11(a,b) ((a)*(b))
|
||||
#define MULT16_32_Q13(a,b) ((a)*(b))
|
||||
#define MULT16_32_Q14(a,b) ((a)*(b))
|
||||
#define MULT16_32_Q15(a,b) ((a)*(b))
|
||||
#define MULT16_32_P15(a,b) ((a)*(b))
|
||||
|
||||
#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b))
|
||||
#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b))
|
||||
|
||||
#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b))
|
||||
#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b))
|
||||
#define MAC16_16_P13(c,a,b) ((c)+(a)*(b))
|
||||
#define MULT16_16_Q11_32(a,b) ((a)*(b))
|
||||
#define MULT16_16_Q13(a,b) ((a)*(b))
|
||||
#define MULT16_16_Q14(a,b) ((a)*(b))
|
||||
#define MULT16_16_Q15(a,b) ((a)*(b))
|
||||
#define MULT16_16_P15(a,b) ((a)*(b))
|
||||
#define MULT16_16_P13(a,b) ((a)*(b))
|
||||
#define MULT16_16_P14(a,b) ((a)*(b))
|
||||
|
||||
#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
|
||||
#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b))
|
||||
#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
|
||||
#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b))
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
|
||||
|
||||
/* 2 on TI C5x DSP */
|
||||
#define BYTES_PER_CHAR 2
|
||||
#define BITS_PER_CHAR 16
|
||||
#define LOG2_BITS_PER_CHAR 4
|
||||
|
||||
#else
|
||||
|
||||
#define BYTES_PER_CHAR 1
|
||||
#define BITS_PER_CHAR 8
|
||||
#define LOG2_BITS_PER_CHAR 3
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,363 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: speex_bits.c
|
||||
|
||||
Handles bit packing/unpacking
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <speex/speex_bits.h>
|
||||
#include "misc.h"
|
||||
|
||||
/* Maximum size of the bit-stream (for fixed-size allocation) */
|
||||
#ifndef MAX_CHARS_PER_FRAME
|
||||
#define MAX_CHARS_PER_FRAME (2000/BYTES_PER_CHAR)
|
||||
#endif
|
||||
|
||||
void speex_bits_init(SpeexBits *bits)
|
||||
{
|
||||
bits->chars = (char*)speex_alloc(MAX_CHARS_PER_FRAME);
|
||||
if (!bits->chars)
|
||||
return;
|
||||
|
||||
bits->buf_size = MAX_CHARS_PER_FRAME;
|
||||
|
||||
bits->owner=1;
|
||||
|
||||
speex_bits_reset(bits);
|
||||
}
|
||||
|
||||
void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
|
||||
{
|
||||
bits->chars = (char*)buff;
|
||||
bits->buf_size = buf_size;
|
||||
|
||||
bits->owner=0;
|
||||
|
||||
speex_bits_reset(bits);
|
||||
}
|
||||
|
||||
void speex_bits_destroy(SpeexBits *bits)
|
||||
{
|
||||
if (bits->owner)
|
||||
speex_free(bits->chars);
|
||||
/* Will do something once the allocation is dynamic */
|
||||
}
|
||||
|
||||
void speex_bits_reset(SpeexBits *bits)
|
||||
{
|
||||
bits->chars[0]=0;
|
||||
bits->nbBits=0;
|
||||
bits->charPtr=0;
|
||||
bits->bitPtr=0;
|
||||
bits->overflow=0;
|
||||
}
|
||||
|
||||
void speex_bits_rewind(SpeexBits *bits)
|
||||
{
|
||||
bits->charPtr=0;
|
||||
bits->bitPtr=0;
|
||||
bits->overflow=0;
|
||||
}
|
||||
|
||||
void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
|
||||
{
|
||||
int i;
|
||||
int nchars = len / BYTES_PER_CHAR;
|
||||
if (nchars > bits->buf_size)
|
||||
{
|
||||
speex_warning_int("Packet is larger than allocated buffer: ", len);
|
||||
if (bits->owner)
|
||||
{
|
||||
char *tmp = (char*)speex_realloc(bits->chars, nchars);
|
||||
if (tmp)
|
||||
{
|
||||
bits->buf_size=nchars;
|
||||
bits->chars=tmp;
|
||||
} else {
|
||||
nchars=bits->buf_size;
|
||||
speex_warning("Could not resize input buffer: truncating input");
|
||||
}
|
||||
} else {
|
||||
speex_warning("Do not own input buffer: truncating input");
|
||||
nchars=bits->buf_size;
|
||||
}
|
||||
}
|
||||
#if (BYTES_PER_CHAR==2)
|
||||
/* Swap bytes to proper endian order (could be done externally) */
|
||||
#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8))
|
||||
#else
|
||||
#define HTOLS(A) (A)
|
||||
#endif
|
||||
for (i=0;i<nchars;i++)
|
||||
bits->chars[i]=HTOLS(chars[i]);
|
||||
|
||||
bits->nbBits=nchars<<LOG2_BITS_PER_CHAR;
|
||||
bits->charPtr=0;
|
||||
bits->bitPtr=0;
|
||||
bits->overflow=0;
|
||||
}
|
||||
|
||||
static void speex_bits_flush(SpeexBits *bits)
|
||||
{
|
||||
int i;
|
||||
int nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
|
||||
if (bits->charPtr>0)
|
||||
{
|
||||
for (i=bits->charPtr;i<nchars; i++)
|
||||
bits->chars[i-bits->charPtr]=bits->chars[i];
|
||||
}
|
||||
bits->nbBits -= bits->charPtr<<LOG2_BITS_PER_CHAR;
|
||||
bits->charPtr=0;
|
||||
}
|
||||
|
||||
void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes)
|
||||
{
|
||||
int i,pos;
|
||||
int nchars = nbytes/BYTES_PER_CHAR;
|
||||
|
||||
if (((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)+nchars > bits->buf_size)
|
||||
{
|
||||
/* Packet is larger than allocated buffer */
|
||||
if (bits->owner)
|
||||
{
|
||||
char *tmp = (char*)speex_realloc(bits->chars, (bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1);
|
||||
if (tmp)
|
||||
{
|
||||
bits->buf_size=(bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1;
|
||||
bits->chars=tmp;
|
||||
} else {
|
||||
nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1;
|
||||
speex_warning("Could not resize input buffer: truncating input");
|
||||
}
|
||||
} else {
|
||||
speex_warning("Do not own input buffer: truncating input");
|
||||
nchars=bits->buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
speex_bits_flush(bits);
|
||||
pos=bits->nbBits>>LOG2_BITS_PER_CHAR;
|
||||
for (i=0;i<nchars;i++)
|
||||
bits->chars[pos+i]=HTOLS(chars[i]);
|
||||
bits->nbBits+=nchars<<LOG2_BITS_PER_CHAR;
|
||||
}
|
||||
|
||||
int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes)
|
||||
{
|
||||
int i;
|
||||
int max_nchars = max_nbytes/BYTES_PER_CHAR;
|
||||
int charPtr, bitPtr, nbBits;
|
||||
|
||||
/* Insert terminator, but save the data so we can put it back after */
|
||||
bitPtr=bits->bitPtr;
|
||||
charPtr=bits->charPtr;
|
||||
nbBits=bits->nbBits;
|
||||
speex_bits_insert_terminator(bits);
|
||||
bits->bitPtr=bitPtr;
|
||||
bits->charPtr=charPtr;
|
||||
bits->nbBits=nbBits;
|
||||
|
||||
if (max_nchars > ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR))
|
||||
max_nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
|
||||
|
||||
for (i=0;i<max_nchars;i++)
|
||||
chars[i]=HTOLS(bits->chars[i]);
|
||||
return max_nchars*BYTES_PER_CHAR;
|
||||
}
|
||||
|
||||
int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes)
|
||||
{
|
||||
int max_nchars = max_nbytes/BYTES_PER_CHAR;
|
||||
int i;
|
||||
if (max_nchars > ((bits->nbBits)>>LOG2_BITS_PER_CHAR))
|
||||
max_nchars = ((bits->nbBits)>>LOG2_BITS_PER_CHAR);
|
||||
for (i=0;i<max_nchars;i++)
|
||||
chars[i]=HTOLS(bits->chars[i]);
|
||||
|
||||
if (bits->bitPtr>0)
|
||||
bits->chars[0]=bits->chars[max_nchars];
|
||||
else
|
||||
bits->chars[0]=0;
|
||||
for (i=1;i<((bits->nbBits)>>LOG2_BITS_PER_CHAR)+1;i++)
|
||||
bits->chars[i]=0;
|
||||
bits->charPtr=0;
|
||||
bits->nbBits &= (BITS_PER_CHAR-1);
|
||||
return max_nchars*BYTES_PER_CHAR;
|
||||
}
|
||||
|
||||
void speex_bits_pack(SpeexBits *bits, int data, int nbBits)
|
||||
{
|
||||
unsigned int d=data;
|
||||
|
||||
if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size)
|
||||
{
|
||||
speex_warning("Buffer too small to pack bits");
|
||||
if (bits->owner)
|
||||
{
|
||||
int new_nchars = ((bits->buf_size+5)*3)>>1;
|
||||
char *tmp = (char*)speex_realloc(bits->chars, new_nchars);
|
||||
if (tmp)
|
||||
{
|
||||
speex_memset_bytes(tmp, 0, new_nchars);
|
||||
bits->buf_size=new_nchars;
|
||||
bits->chars=tmp;
|
||||
} else {
|
||||
speex_warning("Could not resize input buffer: not packing");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
speex_warning("Do not own input buffer: not packing");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while(nbBits)
|
||||
{
|
||||
int bit;
|
||||
bit = (d>>(nbBits-1))&1;
|
||||
bits->chars[bits->charPtr] |= bit<<(BITS_PER_CHAR-1-bits->bitPtr);
|
||||
bits->bitPtr++;
|
||||
|
||||
if (bits->bitPtr==BITS_PER_CHAR)
|
||||
{
|
||||
bits->bitPtr=0;
|
||||
bits->charPtr++;
|
||||
bits->chars[bits->charPtr] = 0;
|
||||
}
|
||||
bits->nbBits++;
|
||||
nbBits--;
|
||||
}
|
||||
}
|
||||
|
||||
int speex_bits_unpack_signed(SpeexBits *bits, int nbBits)
|
||||
{
|
||||
unsigned int d=speex_bits_unpack_unsigned(bits,nbBits);
|
||||
/* If number is negative */
|
||||
if (d>>(nbBits-1))
|
||||
{
|
||||
d |= (-1)<<nbBits;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits)
|
||||
{
|
||||
unsigned int d=0;
|
||||
if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits)
|
||||
bits->overflow=1;
|
||||
if (bits->overflow)
|
||||
return 0;
|
||||
while(nbBits)
|
||||
{
|
||||
d<<=1;
|
||||
d |= (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1;
|
||||
bits->bitPtr++;
|
||||
if (bits->bitPtr==BITS_PER_CHAR)
|
||||
{
|
||||
bits->bitPtr=0;
|
||||
bits->charPtr++;
|
||||
}
|
||||
nbBits--;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
|
||||
{
|
||||
unsigned int d=0;
|
||||
int bitPtr, charPtr;
|
||||
char *chars;
|
||||
|
||||
if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits)
|
||||
bits->overflow=1;
|
||||
if (bits->overflow)
|
||||
return 0;
|
||||
|
||||
bitPtr=bits->bitPtr;
|
||||
charPtr=bits->charPtr;
|
||||
chars = bits->chars;
|
||||
while(nbBits)
|
||||
{
|
||||
d<<=1;
|
||||
d |= (chars[charPtr]>>(BITS_PER_CHAR-1 - bitPtr))&1;
|
||||
bitPtr++;
|
||||
if (bitPtr==BITS_PER_CHAR)
|
||||
{
|
||||
bitPtr=0;
|
||||
charPtr++;
|
||||
}
|
||||
nbBits--;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
int speex_bits_peek(SpeexBits *bits)
|
||||
{
|
||||
if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+1>bits->nbBits)
|
||||
bits->overflow=1;
|
||||
if (bits->overflow)
|
||||
return 0;
|
||||
return (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1;
|
||||
}
|
||||
|
||||
void speex_bits_advance(SpeexBits *bits, int n)
|
||||
{
|
||||
if (((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+n>bits->nbBits) || bits->overflow){
|
||||
bits->overflow=1;
|
||||
return;
|
||||
}
|
||||
bits->charPtr += (bits->bitPtr+n) >> LOG2_BITS_PER_CHAR; /* divide by BITS_PER_CHAR */
|
||||
bits->bitPtr = (bits->bitPtr+n) & (BITS_PER_CHAR-1); /* modulo by BITS_PER_CHAR */
|
||||
}
|
||||
|
||||
int speex_bits_remaining(SpeexBits *bits)
|
||||
{
|
||||
if (bits->overflow)
|
||||
return -1;
|
||||
else
|
||||
return bits->nbBits-((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr);
|
||||
}
|
||||
|
||||
int speex_bits_nbytes(SpeexBits *bits)
|
||||
{
|
||||
return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
|
||||
}
|
||||
|
||||
void speex_bits_insert_terminator(SpeexBits *bits)
|
||||
{
|
||||
if (bits->bitPtr)
|
||||
speex_bits_pack(bits, 0, 1);
|
||||
while (bits->bitPtr)
|
||||
speex_bits_pack(bits, 1, 1);
|
||||
}
|
|
@ -1,606 +0,0 @@
|
|||
/* Copyright (C) 2002-2006 Jean-Marc Valin
|
||||
File: cb_search.c
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "cb_search.h"
|
||||
#include "filters.h"
|
||||
#include "stack_alloc.h"
|
||||
#include "vq.h"
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef _USE_SSE
|
||||
#include "cb_search_sse.h"
|
||||
#elif defined(ARM4_ASM) || defined(ARM5E_ASM)
|
||||
#include "cb_search_arm4.h"
|
||||
#elif defined(BFIN_ASM)
|
||||
#include "cb_search_bfin.h"
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
|
||||
static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
|
||||
{
|
||||
int i, j, k;
|
||||
VARDECL(spx_word16_t *shape);
|
||||
ALLOC(shape, subvect_size, spx_word16_t);
|
||||
for (i=0;i<shape_cb_size;i++)
|
||||
{
|
||||
spx_word16_t *res;
|
||||
|
||||
res = resp+i*subvect_size;
|
||||
for (k=0;k<subvect_size;k++)
|
||||
shape[k] = (spx_word16_t)shape_cb[i*subvect_size+k];
|
||||
E[i]=0;
|
||||
|
||||
/* Compute codeword response using convolution with impulse response */
|
||||
for(j=0;j<subvect_size;j++)
|
||||
{
|
||||
spx_word32_t resj=0;
|
||||
spx_word16_t res16;
|
||||
for (k=0;k<=j;k++)
|
||||
resj = MAC16_16(resj,shape[k],r[j-k]);
|
||||
#ifdef FIXED_POINT
|
||||
res16 = EXTRACT16(SHR32(resj, 13));
|
||||
#else
|
||||
res16 = 0.03125f*resj;
|
||||
#endif
|
||||
/* Compute codeword energy */
|
||||
E[i]=MAC16_16(E[i],res16,res16);
|
||||
res[j] = res16;
|
||||
/*printf ("%d\n", (int)res[j]);*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_TARGET_UPDATE
|
||||
static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len)
|
||||
{
|
||||
int n;
|
||||
for (n=0;n<len;n++)
|
||||
t[n] = SUB16(t[n],PSHR32(MULT16_16(g,r[n]),13));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void split_cb_search_shape_sign_N1(
|
||||
spx_word16_t target[], /* target vector */
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
|
||||
const void *par, /* Codebook/search parameters*/
|
||||
int p, /* number of LPC coeffs */
|
||||
int nsf, /* number of samples in subframe */
|
||||
spx_sig_t *exc,
|
||||
spx_word16_t *r,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int update_target
|
||||
)
|
||||
{
|
||||
int i,j,m,q;
|
||||
VARDECL(spx_word16_t *resp);
|
||||
#ifdef _USE_SSE
|
||||
VARDECL(__m128 *resp2);
|
||||
VARDECL(__m128 *E);
|
||||
#else
|
||||
spx_word16_t *resp2;
|
||||
VARDECL(spx_word32_t *E);
|
||||
#endif
|
||||
VARDECL(spx_word16_t *t);
|
||||
VARDECL(spx_sig_t *e);
|
||||
const signed char *shape_cb;
|
||||
int shape_cb_size, subvect_size, nb_subvect;
|
||||
const split_cb_params *params;
|
||||
int best_index;
|
||||
spx_word32_t best_dist;
|
||||
int have_sign;
|
||||
|
||||
params = (const split_cb_params *) par;
|
||||
subvect_size = params->subvect_size;
|
||||
nb_subvect = params->nb_subvect;
|
||||
shape_cb_size = 1<<params->shape_bits;
|
||||
shape_cb = params->shape_cb;
|
||||
have_sign = params->have_sign;
|
||||
ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
|
||||
#ifdef _USE_SSE
|
||||
ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
|
||||
ALLOC(E, shape_cb_size>>2, __m128);
|
||||
#else
|
||||
resp2 = resp;
|
||||
ALLOC(E, shape_cb_size, spx_word32_t);
|
||||
#endif
|
||||
ALLOC(t, nsf, spx_word16_t);
|
||||
ALLOC(e, nsf, spx_sig_t);
|
||||
|
||||
/* FIXME: Do we still need to copy the target? */
|
||||
for (i=0;i<nsf;i++)
|
||||
t[i]=target[i];
|
||||
|
||||
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
|
||||
|
||||
for (i=0;i<nb_subvect;i++)
|
||||
{
|
||||
spx_word16_t *x=t+subvect_size*i;
|
||||
/*Find new n-best based on previous n-best j*/
|
||||
if (have_sign)
|
||||
vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);
|
||||
else
|
||||
vq_nbest(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);
|
||||
|
||||
speex_bits_pack(bits,best_index,params->shape_bits+have_sign);
|
||||
|
||||
{
|
||||
int rind;
|
||||
spx_word16_t *res;
|
||||
spx_word16_t sign=1;
|
||||
rind = best_index;
|
||||
if (rind>=shape_cb_size)
|
||||
{
|
||||
sign=-1;
|
||||
rind-=shape_cb_size;
|
||||
}
|
||||
res = resp+rind*subvect_size;
|
||||
if (sign>0)
|
||||
for (m=0;m<subvect_size;m++)
|
||||
t[subvect_size*i+m] = SUB16(t[subvect_size*i+m], res[m]);
|
||||
else
|
||||
for (m=0;m<subvect_size;m++)
|
||||
t[subvect_size*i+m] = ADD16(t[subvect_size*i+m], res[m]);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
if (sign)
|
||||
{
|
||||
for (j=0;j<subvect_size;j++)
|
||||
e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
|
||||
} else {
|
||||
for (j=0;j<subvect_size;j++)
|
||||
e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
|
||||
}
|
||||
#else
|
||||
for (j=0;j<subvect_size;j++)
|
||||
e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
for (m=0;m<subvect_size;m++)
|
||||
{
|
||||
spx_word16_t g;
|
||||
int rind;
|
||||
spx_word16_t sign=1;
|
||||
rind = best_index;
|
||||
if (rind>=shape_cb_size)
|
||||
{
|
||||
sign=-1;
|
||||
rind-=shape_cb_size;
|
||||
}
|
||||
|
||||
q=subvect_size-m;
|
||||
#ifdef FIXED_POINT
|
||||
g=sign*shape_cb[rind*subvect_size+m];
|
||||
#else
|
||||
g=sign*0.03125*shape_cb[rind*subvect_size+m];
|
||||
#endif
|
||||
target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));
|
||||
}
|
||||
}
|
||||
|
||||
/* Update excitation */
|
||||
/* FIXME: We could update the excitation directly above */
|
||||
for (j=0;j<nsf;j++)
|
||||
exc[j]=ADD32(exc[j],e[j]);
|
||||
|
||||
/* Update target: only update target if necessary */
|
||||
if (update_target)
|
||||
{
|
||||
VARDECL(spx_sig_t *r2);
|
||||
ALLOC(r2, nsf, spx_sig_t);
|
||||
syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
|
||||
for (j=0;j<nsf;j++)
|
||||
target[j]=SUB16(target[j],EXTRACT16(PSHR32(r2[j],8)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void split_cb_search_shape_sign(
|
||||
spx_word16_t target[], /* target vector */
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
|
||||
const void *par, /* Codebook/search parameters*/
|
||||
int p, /* number of LPC coeffs */
|
||||
int nsf, /* number of samples in subframe */
|
||||
spx_sig_t *exc,
|
||||
spx_word16_t *r,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int complexity,
|
||||
int update_target
|
||||
)
|
||||
{
|
||||
int i,j,k,m,n,q;
|
||||
VARDECL(spx_word16_t *resp);
|
||||
#ifdef _USE_SSE
|
||||
VARDECL(__m128 *resp2);
|
||||
VARDECL(__m128 *E);
|
||||
#else
|
||||
spx_word16_t *resp2;
|
||||
VARDECL(spx_word32_t *E);
|
||||
#endif
|
||||
VARDECL(spx_word16_t *t);
|
||||
VARDECL(spx_sig_t *e);
|
||||
VARDECL(spx_sig_t *r2);
|
||||
VARDECL(spx_word16_t *tmp);
|
||||
VARDECL(spx_word32_t *ndist);
|
||||
VARDECL(spx_word32_t *odist);
|
||||
VARDECL(int *itmp);
|
||||
VARDECL(spx_word16_t **ot2);
|
||||
VARDECL(spx_word16_t **nt2);
|
||||
spx_word16_t **ot, **nt;
|
||||
VARDECL(int **nind);
|
||||
VARDECL(int **oind);
|
||||
VARDECL(int *ind);
|
||||
const signed char *shape_cb;
|
||||
int shape_cb_size, subvect_size, nb_subvect;
|
||||
const split_cb_params *params;
|
||||
int N=2;
|
||||
VARDECL(int *best_index);
|
||||
VARDECL(spx_word32_t *best_dist);
|
||||
VARDECL(int *best_nind);
|
||||
VARDECL(int *best_ntarget);
|
||||
int have_sign;
|
||||
N=complexity;
|
||||
if (N>10)
|
||||
N=10;
|
||||
/* Complexity isn't as important for the codebooks as it is for the pitch */
|
||||
N=(2*N)/3;
|
||||
if (N<1)
|
||||
N=1;
|
||||
if (N==1)
|
||||
{
|
||||
split_cb_search_shape_sign_N1(target,ak,awk1,awk2,par,p,nsf,exc,r,bits,stack,update_target);
|
||||
return;
|
||||
}
|
||||
ALLOC(ot2, N, spx_word16_t*);
|
||||
ALLOC(nt2, N, spx_word16_t*);
|
||||
ALLOC(oind, N, int*);
|
||||
ALLOC(nind, N, int*);
|
||||
|
||||
params = (const split_cb_params *) par;
|
||||
subvect_size = params->subvect_size;
|
||||
nb_subvect = params->nb_subvect;
|
||||
shape_cb_size = 1<<params->shape_bits;
|
||||
shape_cb = params->shape_cb;
|
||||
have_sign = params->have_sign;
|
||||
ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
|
||||
#ifdef _USE_SSE
|
||||
ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
|
||||
ALLOC(E, shape_cb_size>>2, __m128);
|
||||
#else
|
||||
resp2 = resp;
|
||||
ALLOC(E, shape_cb_size, spx_word32_t);
|
||||
#endif
|
||||
ALLOC(t, nsf, spx_word16_t);
|
||||
ALLOC(e, nsf, spx_sig_t);
|
||||
ALLOC(r2, nsf, spx_sig_t);
|
||||
ALLOC(ind, nb_subvect, int);
|
||||
|
||||
ALLOC(tmp, 2*N*nsf, spx_word16_t);
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
ot2[i]=tmp+2*i*nsf;
|
||||
nt2[i]=tmp+(2*i+1)*nsf;
|
||||
}
|
||||
ot=ot2;
|
||||
nt=nt2;
|
||||
ALLOC(best_index, N, int);
|
||||
ALLOC(best_dist, N, spx_word32_t);
|
||||
ALLOC(best_nind, N, int);
|
||||
ALLOC(best_ntarget, N, int);
|
||||
ALLOC(ndist, N, spx_word32_t);
|
||||
ALLOC(odist, N, spx_word32_t);
|
||||
|
||||
ALLOC(itmp, 2*N*nb_subvect, int);
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
nind[i]=itmp+2*i*nb_subvect;
|
||||
oind[i]=itmp+(2*i+1)*nb_subvect;
|
||||
}
|
||||
|
||||
for (i=0;i<nsf;i++)
|
||||
t[i]=target[i];
|
||||
|
||||
for (j=0;j<N;j++)
|
||||
speex_move(&ot[j][0], t, nsf*sizeof(spx_word16_t));
|
||||
|
||||
/* Pre-compute codewords response and energy */
|
||||
compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
|
||||
|
||||
for (j=0;j<N;j++)
|
||||
odist[j]=0;
|
||||
|
||||
/*For all subvectors*/
|
||||
for (i=0;i<nb_subvect;i++)
|
||||
{
|
||||
/*"erase" nbest list*/
|
||||
for (j=0;j<N;j++)
|
||||
ndist[j]=VERY_LARGE32;
|
||||
|
||||
/*For all n-bests of previous subvector*/
|
||||
for (j=0;j<N;j++)
|
||||
{
|
||||
spx_word16_t *x=ot[j]+subvect_size*i;
|
||||
spx_word32_t tener = 0;
|
||||
for (m=0;m<subvect_size;m++)
|
||||
tener = MAC16_16(tener, x[m],x[m]);
|
||||
#ifdef FIXED_POINT
|
||||
tener = SHR32(tener,1);
|
||||
#else
|
||||
tener *= .5;
|
||||
#endif
|
||||
/*Find new n-best based on previous n-best j*/
|
||||
if (have_sign)
|
||||
vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);
|
||||
else
|
||||
vq_nbest(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);
|
||||
|
||||
/*For all new n-bests*/
|
||||
for (k=0;k<N;k++)
|
||||
{
|
||||
/* Compute total distance (including previous sub-vectors */
|
||||
spx_word32_t err = ADD32(ADD32(odist[j],best_dist[k]),tener);
|
||||
|
||||
/*update n-best list*/
|
||||
if (err<ndist[N-1])
|
||||
{
|
||||
for (m=0;m<N;m++)
|
||||
{
|
||||
if (err < ndist[m])
|
||||
{
|
||||
for (n=N-1;n>m;n--)
|
||||
{
|
||||
ndist[n] = ndist[n-1];
|
||||
best_nind[n] = best_nind[n-1];
|
||||
best_ntarget[n] = best_ntarget[n-1];
|
||||
}
|
||||
ndist[m] = err;
|
||||
best_nind[n] = best_index[k];
|
||||
best_ntarget[n] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i==0)
|
||||
break;
|
||||
}
|
||||
for (j=0;j<N;j++)
|
||||
{
|
||||
/*previous target (we don't care what happened before*/
|
||||
for (m=(i+1)*subvect_size;m<nsf;m++)
|
||||
nt[j][m]=ot[best_ntarget[j]][m];
|
||||
|
||||
/* New code: update the rest of the target only if it's worth it */
|
||||
for (m=0;m<subvect_size;m++)
|
||||
{
|
||||
spx_word16_t g;
|
||||
int rind;
|
||||
spx_word16_t sign=1;
|
||||
rind = best_nind[j];
|
||||
if (rind>=shape_cb_size)
|
||||
{
|
||||
sign=-1;
|
||||
rind-=shape_cb_size;
|
||||
}
|
||||
|
||||
q=subvect_size-m;
|
||||
#ifdef FIXED_POINT
|
||||
g=sign*shape_cb[rind*subvect_size+m];
|
||||
#else
|
||||
g=sign*0.03125*shape_cb[rind*subvect_size+m];
|
||||
#endif
|
||||
target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));
|
||||
}
|
||||
|
||||
for (q=0;q<nb_subvect;q++)
|
||||
nind[j][q]=oind[best_ntarget[j]][q];
|
||||
nind[j][i]=best_nind[j];
|
||||
}
|
||||
|
||||
/*update old-new data*/
|
||||
/* just swap pointers instead of a long copy */
|
||||
{
|
||||
spx_word16_t **tmp2;
|
||||
tmp2=ot;
|
||||
ot=nt;
|
||||
nt=tmp2;
|
||||
}
|
||||
for (j=0;j<N;j++)
|
||||
for (m=0;m<nb_subvect;m++)
|
||||
oind[j][m]=nind[j][m];
|
||||
for (j=0;j<N;j++)
|
||||
odist[j]=ndist[j];
|
||||
}
|
||||
|
||||
/*save indices*/
|
||||
for (i=0;i<nb_subvect;i++)
|
||||
{
|
||||
ind[i]=nind[0][i];
|
||||
speex_bits_pack(bits,ind[i],params->shape_bits+have_sign);
|
||||
}
|
||||
|
||||
/* Put everything back together */
|
||||
for (i=0;i<nb_subvect;i++)
|
||||
{
|
||||
int rind;
|
||||
spx_word16_t sign=1;
|
||||
rind = ind[i];
|
||||
if (rind>=shape_cb_size)
|
||||
{
|
||||
sign=-1;
|
||||
rind-=shape_cb_size;
|
||||
}
|
||||
#ifdef FIXED_POINT
|
||||
if (sign==1)
|
||||
{
|
||||
for (j=0;j<subvect_size;j++)
|
||||
e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
|
||||
} else {
|
||||
for (j=0;j<subvect_size;j++)
|
||||
e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
|
||||
}
|
||||
#else
|
||||
for (j=0;j<subvect_size;j++)
|
||||
e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
|
||||
#endif
|
||||
}
|
||||
/* Update excitation */
|
||||
for (j=0;j<nsf;j++)
|
||||
exc[j]=ADD32(exc[j],e[j]);
|
||||
|
||||
/* Update target: only update target if necessary */
|
||||
if (update_target)
|
||||
{
|
||||
syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
|
||||
for (j=0;j<nsf;j++)
|
||||
target[j]=SUB16(target[j],EXTRACT16(PSHR32(r2[j],8)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void split_cb_shape_sign_unquant(
|
||||
spx_sig_t *exc,
|
||||
const void *par, /* non-overlapping codebook */
|
||||
int nsf, /* number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_int32_t *seed
|
||||
)
|
||||
{
|
||||
int i,j;
|
||||
VARDECL(int *ind);
|
||||
VARDECL(int *signs);
|
||||
const signed char *shape_cb;
|
||||
int shape_cb_size, subvect_size, nb_subvect;
|
||||
const split_cb_params *params;
|
||||
int have_sign;
|
||||
|
||||
params = (const split_cb_params *) par;
|
||||
subvect_size = params->subvect_size;
|
||||
nb_subvect = params->nb_subvect;
|
||||
shape_cb_size = 1<<params->shape_bits;
|
||||
shape_cb = params->shape_cb;
|
||||
have_sign = params->have_sign;
|
||||
|
||||
ALLOC(ind, nb_subvect, int);
|
||||
ALLOC(signs, nb_subvect, int);
|
||||
|
||||
/* Decode codewords and gains */
|
||||
for (i=0;i<nb_subvect;i++)
|
||||
{
|
||||
if (have_sign)
|
||||
signs[i] = speex_bits_unpack_unsigned(bits, 1);
|
||||
else
|
||||
signs[i] = 0;
|
||||
ind[i] = speex_bits_unpack_unsigned(bits, params->shape_bits);
|
||||
}
|
||||
/* Compute decoded excitation */
|
||||
for (i=0;i<nb_subvect;i++)
|
||||
{
|
||||
spx_word16_t s=1;
|
||||
if (signs[i])
|
||||
s=-1;
|
||||
#ifdef FIXED_POINT
|
||||
if (s==1)
|
||||
{
|
||||
for (j=0;j<subvect_size;j++)
|
||||
exc[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5);
|
||||
} else {
|
||||
for (j=0;j<subvect_size;j++)
|
||||
exc[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5));
|
||||
}
|
||||
#else
|
||||
for (j=0;j<subvect_size;j++)
|
||||
exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void noise_codebook_quant(
|
||||
spx_word16_t target[], /* target vector */
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
|
||||
const void *par, /* Codebook/search parameters*/
|
||||
int p, /* number of LPC coeffs */
|
||||
int nsf, /* number of samples in subframe */
|
||||
spx_sig_t *exc,
|
||||
spx_word16_t *r,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int complexity,
|
||||
int update_target
|
||||
)
|
||||
{
|
||||
int i;
|
||||
VARDECL(spx_sig_t *tmp);
|
||||
ALLOC(tmp, nsf, spx_sig_t);
|
||||
for (i=0;i<nsf;i++)
|
||||
tmp[i]=PSHR32(EXTEND32(target[i]),SIG_SHIFT);
|
||||
residue_percep_zero(tmp, ak, awk1, awk2, tmp, nsf, p, stack);
|
||||
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i]+=tmp[i];
|
||||
for (i=0;i<nsf;i++)
|
||||
target[i]=0;
|
||||
}
|
||||
|
||||
|
||||
void noise_codebook_unquant(
|
||||
spx_sig_t *exc,
|
||||
const void *par, /* non-overlapping codebook */
|
||||
int nsf, /* number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_int32_t *seed
|
||||
)
|
||||
{
|
||||
int i;
|
||||
/* FIXME: This is bad, but I don't think the function ever gets called anyway */
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i]=SHL32(EXTEND32(speex_rand(1, seed)),SIG_SHIFT);
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin & David Rowe */
|
||||
/**
|
||||
@file cb_search.h
|
||||
@brief Overlapped codebook search
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef CB_SEARCH_H
|
||||
#define CB_SEARCH_H
|
||||
|
||||
#include <speex/speex_bits.h>
|
||||
#include "misc.h"
|
||||
|
||||
/** Split codebook parameters. */
|
||||
typedef struct split_cb_params {
|
||||
int subvect_size;
|
||||
int nb_subvect;
|
||||
const signed char *shape_cb;
|
||||
int shape_bits;
|
||||
int have_sign;
|
||||
} split_cb_params;
|
||||
|
||||
|
||||
void split_cb_search_shape_sign(
|
||||
spx_word16_t target[], /* target vector */
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
|
||||
const void *par, /* Codebook/search parameters */
|
||||
int p, /* number of LPC coeffs */
|
||||
int nsf, /* number of samples in subframe */
|
||||
spx_sig_t *exc,
|
||||
spx_word16_t *r,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int complexity,
|
||||
int update_target
|
||||
);
|
||||
|
||||
void split_cb_shape_sign_unquant(
|
||||
spx_sig_t *exc,
|
||||
const void *par, /* non-overlapping codebook */
|
||||
int nsf, /* number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_int32_t *seed
|
||||
);
|
||||
|
||||
|
||||
void noise_codebook_quant(
|
||||
spx_word16_t target[], /* target vector */
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs for this subframe */
|
||||
const void *par, /* Codebook/search parameters */
|
||||
int p, /* number of LPC coeffs */
|
||||
int nsf, /* number of samples in subframe */
|
||||
spx_sig_t *exc,
|
||||
spx_word16_t *r,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int complexity,
|
||||
int update_target
|
||||
);
|
||||
|
||||
|
||||
void noise_codebook_unquant(
|
||||
spx_sig_t *exc,
|
||||
const void *par, /* non-overlapping codebook */
|
||||
int nsf, /* number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_int32_t *seed
|
||||
);
|
||||
|
||||
#endif
|
|
@ -1,137 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file cb_search_arm4.h
|
||||
@brief Fixed codebook functions (ARM4 version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* This optimization is temporaly disabled until it is fixed to account for the fact
|
||||
that "r" is now a 16-bit array */
|
||||
#if 0
|
||||
#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
|
||||
static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
|
||||
{
|
||||
int i, j, k;
|
||||
//const signed char *shape;
|
||||
for (i=0;i<shape_cb_size;i+=4)
|
||||
{
|
||||
|
||||
//shape = shape_cb;
|
||||
E[0]=0;
|
||||
E[1]=0;
|
||||
E[2]=0;
|
||||
E[3]=0;
|
||||
|
||||
/* Compute codeword response using convolution with impulse response */
|
||||
for(j=0;j<subvect_size;j++)
|
||||
{
|
||||
#if 1
|
||||
spx_word16_t *res;
|
||||
res = resp+j;
|
||||
spx_word32_t resj0,resj1,resj2,resj3;
|
||||
spx_word32_t dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8;
|
||||
__asm__ __volatile__ (
|
||||
"mov %0, #0 \n\t"
|
||||
"mov %1, #0 \n\t"
|
||||
"mov %2, #0 \n\t"
|
||||
"mov %3, #0 \n\t"
|
||||
".weighted%=: \n\t"
|
||||
"ldrsb %8, [%6] \n\t"
|
||||
"ldr %10, [%5], #-4 \n\t"
|
||||
"mov %9, %6 \n\t"
|
||||
"ldrsb %11, [%9, %7]! \n\t"
|
||||
"mla %0, %10, %8, %0 \n\t"
|
||||
"ldrsb %8, [%9, %7]! \n\t"
|
||||
"mla %1, %10, %11, %1 \n\t"
|
||||
"ldrsb %11, [%9, %7]! \n\t"
|
||||
"mla %2, %10, %8, %2 \n\t"
|
||||
"subs %4, %4, #1 \n\t"
|
||||
"mla %3, %10, %11, %3 \n\t"
|
||||
"add %6, %6, #1 \n\t"
|
||||
"bne .weighted%= \n\t"
|
||||
: "=r" (resj0), "=r" (resj1), "=r" (resj2), "=r" (resj3),
|
||||
"=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
|
||||
"=r" (dead5), "=r" (dead6), "=r" (dead7), "=r" (dead8)
|
||||
: "4" (j+1), "5" (r+j), "6" (shape_cb), "7" (subvect_size)
|
||||
: "cc", "memory");
|
||||
#else
|
||||
spx_word16_t *res;
|
||||
res = resp+j;
|
||||
spx_word32_t resj0=0;
|
||||
spx_word32_t resj1=0;
|
||||
spx_word32_t resj2=0;
|
||||
spx_word32_t resj3=0;
|
||||
for (k=0;k<=j;k++)
|
||||
{
|
||||
const signed char *shape=shape_cb+k;
|
||||
resj0 = MAC16_16(resj0,*shape,r[j-k]);
|
||||
shape += subvect_size;
|
||||
resj1 = MAC16_16(resj1,*shape,r[j-k]);
|
||||
shape += subvect_size;
|
||||
resj2 = MAC16_16(resj2,*shape,r[j-k]);
|
||||
shape += subvect_size;
|
||||
resj3 = MAC16_16(resj3,*shape,r[j-k]);
|
||||
shape += subvect_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
resj0 = SHR(resj0, 11);
|
||||
resj1 = SHR(resj1, 11);
|
||||
resj2 = SHR(resj2, 11);
|
||||
resj3 = SHR(resj3, 11);
|
||||
#else
|
||||
resj0 *= 0.03125;
|
||||
resj1 *= 0.03125;
|
||||
resj2 *= 0.03125;
|
||||
resj3 *= 0.03125;
|
||||
#endif
|
||||
|
||||
/* Compute codeword energy */
|
||||
E[0]=ADD32(E[0],MULT16_16(resj0,resj0));
|
||||
E[1]=ADD32(E[1],MULT16_16(resj1,resj1));
|
||||
E[2]=ADD32(E[2],MULT16_16(resj2,resj2));
|
||||
E[3]=ADD32(E[3],MULT16_16(resj3,resj3));
|
||||
*res = resj0;
|
||||
res += subvect_size;
|
||||
*res = resj1;
|
||||
res += subvect_size;
|
||||
*res = resj2;
|
||||
res += subvect_size;
|
||||
*res = resj3;
|
||||
res += subvect_size;
|
||||
}
|
||||
resp += subvect_size<<2;
|
||||
shape_cb += subvect_size<<2;
|
||||
E+=4;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,112 +0,0 @@
|
|||
/* Copyright (C) 2005 Analog Devices */
|
||||
/**
|
||||
@author Jean-Marc Valin
|
||||
@file cb_search_bfin.h
|
||||
@brief Fixed codebook functions (Blackfin version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
|
||||
void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<shape_cb_size;i++)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"P0 = %0;\n\t"
|
||||
"LC0 = P0;\n\t"
|
||||
"P1 = %1;\n\t"
|
||||
"P2 = %2;\n\t"
|
||||
"P3 = %3;\n\t"
|
||||
"P0 = 1;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
"R2 = 0;\n\t"
|
||||
"A1 = 0;\n\t"
|
||||
"LOOP outter%= LC0;\n\t"
|
||||
"LOOP_BEGIN outter%=;\n\t"
|
||||
"A0 = 0;\n\t"
|
||||
"P4 = P1;\n\t"
|
||||
"I1 = P2;\n\t"
|
||||
"R0 = B[P4++] (X) || R1.L = W[I1--];\n\t"
|
||||
"LOOP inner%= LC1 = P0;\n\t"
|
||||
"LOOP_BEGIN inner%=;\n\t"
|
||||
"A0 += R0.L*R1.L (IS) || R0 = B[P4++] (X) || R1.L = W[I1--];\n\t"
|
||||
"LOOP_END inner%=;\n\t"
|
||||
"R0 = A0;\n\t"
|
||||
"R0 >>>= 13;\n\t"
|
||||
"A1 += R0.L*R0.L (IS);\n\t"
|
||||
"W[P3++] = R0;\n\t"
|
||||
"P0 += 1;\n\t"
|
||||
"P2 += 2;\n\t"
|
||||
"LOOP_END outter%=;\n\t"
|
||||
"P4 = %4;\n\t"
|
||||
"R1 = A1;\n\t"
|
||||
"[P4] = R1;\n\t"
|
||||
:
|
||||
: "m" (subvect_size), "m" (shape_cb), "m" (r), "m" (resp), "m" (E)
|
||||
: "A0", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "I0", "I1", "L0",
|
||||
"L1", "A0", "A1", "memory"
|
||||
#if !(__GNUC__ == 3)
|
||||
, "LC0", "LC1" /* gcc 3.4 doesn't know about LC registers */
|
||||
#endif
|
||||
);
|
||||
shape_cb += subvect_size;
|
||||
resp += subvect_size;
|
||||
E++;
|
||||
}
|
||||
}
|
||||
|
||||
#define OVERRIDE_TARGET_UPDATE
|
||||
static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len)
|
||||
{
|
||||
if (!len)
|
||||
return;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"I0 = %0;\n\t"
|
||||
"I1 = %1;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
"R2 = 4096;\n\t"
|
||||
"LOOP tupdate%= LC0 = %3;\n\t"
|
||||
"LOOP_BEGIN tupdate%=;\n\t"
|
||||
"R0.L = W[I0] || R1.L = W[I1++];\n\t"
|
||||
"R1 = (A1 = R1.L*%2.L) (IS);\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"R1 >>>= 13;\n\t"
|
||||
"R0.L = R0.L - R1.L;\n\t"
|
||||
"W[I0++] = R0.L;\n\t"
|
||||
"LOOP_END tupdate%=;\n\t"
|
||||
:
|
||||
: "a" (t), "a" (r), "d" (g), "a" (len)
|
||||
: "R0", "R1", "R2", "A1", "I0", "I1", "L0", "L1"
|
||||
);
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file cb_search_sse.h
|
||||
@brief Fixed codebook functions (SSE version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W)
|
||||
{
|
||||
union {
|
||||
float __a[4];
|
||||
__m128 __v;
|
||||
} __u;
|
||||
|
||||
__u.__v = U;
|
||||
|
||||
*__Z = __u.__a[0];
|
||||
*__Y = __u.__a[1];
|
||||
*__X = __u.__a[2];
|
||||
*__W = __u.__a[3];
|
||||
|
||||
}
|
||||
|
||||
#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
|
||||
static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack)
|
||||
{
|
||||
int i, j, k;
|
||||
__m128 resj, EE;
|
||||
VARDECL(__m128 *r);
|
||||
VARDECL(__m128 *shape);
|
||||
ALLOC(r, subvect_size, __m128);
|
||||
ALLOC(shape, subvect_size, __m128);
|
||||
for(j=0;j<subvect_size;j++)
|
||||
r[j] = _mm_load_ps1(_r+j);
|
||||
for (i=0;i<shape_cb_size;i+=4)
|
||||
{
|
||||
float *_res = resp+i*subvect_size;
|
||||
const signed char *_shape = shape_cb+i*subvect_size;
|
||||
EE = _mm_setzero_ps();
|
||||
for(j=0;j<subvect_size;j++)
|
||||
{
|
||||
shape[j] = _mm_setr_ps(0.03125*_shape[j], 0.03125*_shape[subvect_size+j], 0.03125*_shape[2*subvect_size+j], 0.03125*_shape[3*subvect_size+j]);
|
||||
}
|
||||
for(j=0;j<subvect_size;j++)
|
||||
{
|
||||
resj = _mm_setzero_ps();
|
||||
for (k=0;k<=j;k++)
|
||||
resj = _mm_add_ps(resj, _mm_mul_ps(shape[k],r[j-k]));
|
||||
_spx_mm_getr_ps(resj, _res+j, _res+subvect_size+j, _res+2*subvect_size+j, _res+3*subvect_size+j);
|
||||
*resp2++ = resj;
|
||||
EE = _mm_add_ps(EE, _mm_mul_ps(resj, resj));
|
||||
}
|
||||
E[i>>2] = EE;
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: exc_10_16_table.c
|
||||
Codebook for excitation in narrowband CELP mode (3200 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
const signed char exc_10_16_table[160] = {
|
||||
22,39,14,44,11,35,-2,23,-4,6,
|
||||
46,-28,13,-27,-23,12,4,20,-5,9,
|
||||
37,-18,-23,23,0,9,-6,-20,4,-1,
|
||||
-17,-5,-4,17,0,1,9,-2,1,2,
|
||||
2,-12,8,-25,39,15,9,16,-55,-11,
|
||||
9,11,5,10,-2,-60,8,13,-6,11,
|
||||
-16,27,-47,-12,11,1,16,-7,9,-3,
|
||||
-29,9,-14,25,-19,34,36,12,40,-10,
|
||||
-3,-24,-14,-37,-21,-35,-2,-36,3,-6,
|
||||
67,28,6,-17,-3,-12,-16,-15,-17,-7,
|
||||
-59,-36,-13,1,7,1,2,10,2,11,
|
||||
13,10,8,-2,7,3,5,4,2,2,
|
||||
-3,-8,4,-5,6,7,-42,15,35,-2,
|
||||
-46,38,28,-20,-9,1,7,-3,0,-2,
|
||||
0,0,0,0,0,0,0,0,0,0,
|
||||
-15,-28,52,32,5,-5,-17,-20,-10,-1};
|
|
@ -1,66 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: exc_10_32_table.c
|
||||
Codebook for excitation in narrowband CELP mode (4000 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
const signed char exc_10_32_table[320] = {
|
||||
7,17,17,27,25,22,12,4,-3,0,
|
||||
28,-36,39,-24,-15,3,-9,15,-5,10,
|
||||
31,-28,11,31,-21,9,-11,-11,-2,-7,
|
||||
-25,14,-22,31,4,-14,19,-12,14,-5,
|
||||
4,-7,4,-5,9,0,-2,42,-47,-16,
|
||||
1,8,0,9,23,-57,0,28,-11,6,
|
||||
-31,55,-45,3,-5,4,2,-2,4,-7,
|
||||
-3,6,-2,7,-3,12,5,8,54,-10,
|
||||
8,-7,-8,-24,-25,-27,-14,-5,8,5,
|
||||
44,23,5,-9,-11,-11,-13,-9,-12,-8,
|
||||
-29,-8,-22,6,-15,3,-12,-1,-5,-3,
|
||||
34,-1,29,-16,17,-4,12,2,1,4,
|
||||
-2,-4,2,-1,11,-3,-52,28,30,-9,
|
||||
-32,25,44,-20,-24,4,6,-1,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,
|
||||
-25,-10,22,29,13,-13,-22,-13,-4,0,
|
||||
-4,-16,10,15,-36,-24,28,25,-1,-3,
|
||||
66,-33,-11,-15,6,0,3,4,-2,5,
|
||||
24,-20,-47,29,19,-2,-4,-1,0,-1,
|
||||
-2,3,1,8,-11,5,5,-57,28,28,
|
||||
0,-16,4,-4,12,-6,-1,2,-20,61,
|
||||
-9,24,-22,-42,29,6,17,8,4,2,
|
||||
-65,15,8,10,5,6,5,3,2,-2,
|
||||
-3,5,-9,4,-5,23,13,23,-3,-63,
|
||||
3,-5,-4,-6,0,-3,23,-36,-46,9,
|
||||
5,5,8,4,9,-5,1,-3,10,1,
|
||||
-6,10,-11,24,-47,31,22,-12,14,-10,
|
||||
6,11,-7,-7,7,-31,51,-12,-6,7,
|
||||
6,-17,9,-11,-20,52,-19,3,-6,-6,
|
||||
-8,-5,23,-41,37,1,-21,10,-14,8,
|
||||
7,5,-15,-15,23,39,-26,-33,7,2,
|
||||
-32,-30,-21,-8,4,12,17,15,14,11};
|
|
@ -1,66 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: exc_20_32_table.c
|
||||
Codebook for excitation in narrowband CELP mode (2000 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
const signed char exc_20_32_table[640] = {
|
||||
12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5,
|
||||
31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11,
|
||||
42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2,
|
||||
-33,11,-16,33,11,-4,9,-4,11,2,6,-5,8,-5,11,-4,-6,26,-36,-16,
|
||||
0,4,-2,-8,12,6,-1,34,-46,-22,9,9,21,9,5,-66,-5,26,2,10,
|
||||
13,2,19,9,12,-81,3,13,13,0,-14,22,-35,6,-7,-4,6,-6,10,-6,
|
||||
-31,38,-33,0,-10,-11,5,-12,12,-17,5,0,-6,13,-9,10,8,25,33,2,
|
||||
-12,8,-6,10,-2,21,7,17,43,5,11,-7,-9,-20,-36,-20,-23,-4,-4,-3,
|
||||
27,-9,-9,-49,-39,-38,-11,-9,6,5,23,25,5,3,3,4,1,2,-3,-1,
|
||||
87,39,17,-21,-9,-19,-9,-15,-13,-14,-17,-11,-10,-11,-8,-6,-1,-3,-3,-1,
|
||||
-54,-34,-27,-8,-11,-4,-5,0,0,4,8,6,9,7,9,7,6,5,5,5,
|
||||
48,10,19,-10,12,-1,9,-3,2,5,-3,2,-2,-2,0,-2,-26,6,9,-7,
|
||||
-16,-9,2,7,7,-5,-43,11,22,-11,-9,34,37,-15,-13,-6,1,-1,1,1,
|
||||
-64,56,52,-11,-27,5,4,3,1,2,1,3,-1,-4,-4,-10,-7,-4,-4,2,
|
||||
-1,-7,-7,-12,-10,-15,-9,-5,-5,-11,-16,-13,6,16,4,-13,-16,-10,-4,2,
|
||||
-47,-13,25,47,19,-14,-20,-8,-17,0,-3,-13,1,6,-17,-14,15,1,10,6,
|
||||
-24,0,-10,19,-69,-8,14,49,17,-5,33,-29,3,-4,0,2,-8,5,-6,2,
|
||||
120,-56,-12,-47,23,-9,6,-5,1,2,-5,1,-10,4,-1,-1,4,-1,0,-3,
|
||||
30,-52,-67,30,22,11,-1,-4,3,0,7,2,0,1,-10,-4,-8,-13,5,1,
|
||||
1,-1,5,13,-9,-3,-10,-62,22,48,-4,-6,2,3,5,1,1,4,1,13,
|
||||
3,-20,10,-9,13,-2,-4,9,-20,44,-1,20,-32,-67,19,0,28,11,8,2,
|
||||
-11,15,-19,-53,31,2,34,10,6,-4,-58,8,10,13,14,1,12,2,0,0,
|
||||
-128,37,-8,44,-9,26,-3,18,2,6,11,-1,9,1,5,3,0,1,1,2,
|
||||
12,3,-2,-3,7,25,9,18,-6,-37,3,-8,-16,3,-10,-7,17,-34,-44,11,
|
||||
17,-15,-3,-16,-1,-13,11,-46,-65,-2,8,13,2,4,4,5,15,5,9,6,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
-9,19,-12,12,-28,38,29,-1,12,2,5,23,-10,3,4,-15,21,-4,3,3,
|
||||
6,17,-9,-4,-8,-20,26,5,-10,6,1,-19,18,-15,-12,47,-6,-2,-7,-9,
|
||||
-1,-17,-2,-2,-14,30,-14,2,-7,-4,-1,-12,11,-25,16,-3,-12,11,-7,7,
|
||||
-17,1,19,-28,31,-7,-10,7,-10,3,12,5,-16,6,24,41,-29,-54,0,1,
|
||||
7,-1,5,-6,13,10,-4,-8,8,-9,-27,-53,-38,-1,10,19,17,16,12,12,
|
||||
0,3,-7,-4,13,12,-31,-14,6,-5,3,5,17,43,50,25,10,1,-6,-2};
|
|
@ -1,290 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: exc_5_256_table.c
|
||||
Codebook for excitation in narrowband CELP mode (12800 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
const signed char exc_5_256_table[1280] = {
|
||||
-8,-37,5,-43,5,
|
||||
73,61,39,12,-3,
|
||||
-61,-32,2,42,30,
|
||||
-3,17,-27,9,34,
|
||||
20,-1,-5,2,23,
|
||||
-7,-46,26,53,-47,
|
||||
20,-2,-33,-89,-51,
|
||||
-64,27,11,15,-34,
|
||||
-5,-56,25,-9,-1,
|
||||
-29,1,40,67,-23,
|
||||
-16,16,33,19,7,
|
||||
14,85,22,-10,-10,
|
||||
-12,-7,-1,52,89,
|
||||
29,11,-20,-37,-46,
|
||||
-15,17,-24,-28,24,
|
||||
2,1,0,23,-101,
|
||||
23,14,-1,-23,-18,
|
||||
9,5,-13,38,1,
|
||||
-28,-28,4,27,51,
|
||||
-26,34,-40,35,47,
|
||||
54,38,-54,-26,-6,
|
||||
42,-25,13,-30,-36,
|
||||
18,41,-4,-33,23,
|
||||
-32,-7,-4,51,-3,
|
||||
17,-52,56,-47,36,
|
||||
-2,-21,36,10,8,
|
||||
-33,31,19,9,-5,
|
||||
-40,10,-9,-21,19,
|
||||
18,-78,-18,-5,0,
|
||||
-26,-36,-47,-51,-44,
|
||||
18,40,27,-2,29,
|
||||
49,-26,2,32,-54,
|
||||
30,-73,54,3,-5,
|
||||
36,22,53,10,-1,
|
||||
-84,-53,-29,-5,3,
|
||||
-44,53,-51,4,22,
|
||||
71,-35,-1,33,-5,
|
||||
-27,-7,36,17,-23,
|
||||
-39,16,-9,-55,-15,
|
||||
-20,39,-35,6,-39,
|
||||
-14,18,48,-64,-17,
|
||||
-15,9,39,81,37,
|
||||
-68,37,47,-21,-6,
|
||||
-104,13,6,9,-2,
|
||||
35,8,-23,18,42,
|
||||
45,21,33,-5,-49,
|
||||
9,-6,-43,-56,39,
|
||||
2,-16,-25,87,1,
|
||||
-3,-9,17,-25,-11,
|
||||
-9,-1,10,2,-14,
|
||||
-14,4,-1,-10,28,
|
||||
-23,40,-32,26,-9,
|
||||
26,4,-27,-23,3,
|
||||
42,-60,1,49,-3,
|
||||
27,10,-52,-40,-2,
|
||||
18,45,-23,17,-44,
|
||||
3,-3,17,-46,52,
|
||||
-40,-47,25,75,31,
|
||||
-49,53,30,-30,-32,
|
||||
-36,38,-6,-15,-16,
|
||||
54,-27,-48,3,38,
|
||||
-29,-32,-22,-14,-4,
|
||||
-23,-13,32,-39,9,
|
||||
8,-45,-13,34,-16,
|
||||
49,40,32,31,28,
|
||||
23,23,32,47,59,
|
||||
-68,8,62,44,25,
|
||||
-14,-24,-65,-16,36,
|
||||
67,-25,-38,-21,4,
|
||||
-33,-2,42,5,-63,
|
||||
40,11,26,-42,-23,
|
||||
-61,79,-31,23,-20,
|
||||
10,-32,53,-25,-36,
|
||||
10,-26,-5,3,0,
|
||||
-71,5,-10,-37,1,
|
||||
-24,21,-54,-17,1,
|
||||
-29,-25,-15,-27,32,
|
||||
68,45,-16,-37,-18,
|
||||
-5,1,0,-77,71,
|
||||
-6,3,-20,71,-67,
|
||||
29,-35,10,-30,19,
|
||||
4,16,17,5,0,
|
||||
-14,19,2,28,26,
|
||||
59,3,2,24,39,
|
||||
55,-50,-45,-18,-17,
|
||||
33,-35,14,-1,1,
|
||||
8,87,-35,-29,0,
|
||||
-27,13,-7,23,-13,
|
||||
37,-40,50,-35,14,
|
||||
19,-7,-14,49,54,
|
||||
-5,22,-2,-29,-8,
|
||||
-27,38,13,27,48,
|
||||
12,-41,-21,-15,28,
|
||||
7,-16,-24,-19,-20,
|
||||
11,-20,9,2,13,
|
||||
23,-20,11,27,-27,
|
||||
71,-69,8,2,-6,
|
||||
22,12,16,16,9,
|
||||
-16,-8,-17,1,25,
|
||||
1,40,-37,-33,66,
|
||||
94,53,4,-22,-25,
|
||||
-41,-42,25,35,-16,
|
||||
-15,57,31,-29,-32,
|
||||
21,16,-60,45,15,
|
||||
-1,7,57,-26,-47,
|
||||
-29,11,8,15,19,
|
||||
-105,-8,54,27,10,
|
||||
-17,6,-12,-1,-10,
|
||||
4,0,23,-10,31,
|
||||
13,11,10,12,-64,
|
||||
23,-3,-8,-19,16,
|
||||
52,24,-40,16,10,
|
||||
40,5,9,0,-13,
|
||||
-7,-21,-8,-6,-7,
|
||||
-21,59,16,-53,18,
|
||||
-60,11,-47,14,-18,
|
||||
25,-13,-24,4,-39,
|
||||
16,-28,54,26,-67,
|
||||
30,27,-20,-52,20,
|
||||
-12,55,12,18,-16,
|
||||
39,-14,-6,-26,56,
|
||||
-88,-55,12,25,26,
|
||||
-37,6,75,0,-34,
|
||||
-81,54,-30,1,-7,
|
||||
49,-23,-14,21,10,
|
||||
-62,-58,-57,-47,-34,
|
||||
15,-4,34,-78,31,
|
||||
25,-11,7,50,-10,
|
||||
42,-63,14,-36,-4,
|
||||
57,55,57,53,42,
|
||||
-42,-1,15,40,37,
|
||||
15,25,-11,6,1,
|
||||
31,-2,-6,-1,-7,
|
||||
-64,34,28,30,-1,
|
||||
3,21,0,-88,-12,
|
||||
-56,25,-28,40,8,
|
||||
-28,-14,9,12,2,
|
||||
-6,-17,22,49,-6,
|
||||
-26,14,28,-20,4,
|
||||
-12,50,35,40,13,
|
||||
-38,-58,-29,17,30,
|
||||
22,60,26,-54,-39,
|
||||
-12,58,-28,-63,10,
|
||||
-21,-8,-12,26,-62,
|
||||
6,-10,-11,-22,-6,
|
||||
-7,4,1,18,2,
|
||||
-70,11,14,4,13,
|
||||
19,-24,-34,24,67,
|
||||
17,51,-21,13,23,
|
||||
54,-30,48,1,-13,
|
||||
80,26,-16,-2,13,
|
||||
-4,6,-30,29,-24,
|
||||
73,-58,30,-27,20,
|
||||
-2,-21,41,45,30,
|
||||
-27,-3,-5,-18,-20,
|
||||
-49,-3,-35,10,42,
|
||||
-19,-67,-53,-11,9,
|
||||
13,-15,-33,-51,-30,
|
||||
15,7,25,-30,4,
|
||||
28,-22,-34,54,-29,
|
||||
39,-46,20,16,34,
|
||||
-4,47,75,1,-44,
|
||||
-55,-24,7,-1,9,
|
||||
-42,50,-8,-36,41,
|
||||
68,0,-4,-10,-23,
|
||||
-15,-50,64,36,-9,
|
||||
-27,12,25,-38,-47,
|
||||
-37,32,-49,51,-36,
|
||||
2,-4,69,-26,19,
|
||||
7,45,67,46,13,
|
||||
-63,46,15,-47,4,
|
||||
-41,13,-6,5,-21,
|
||||
37,26,-55,-7,33,
|
||||
-1,-28,10,-17,-64,
|
||||
-14,0,-36,-17,93,
|
||||
-3,-9,-66,44,-21,
|
||||
3,-12,38,-6,-13,
|
||||
-12,19,13,43,-43,
|
||||
-10,-12,6,-5,9,
|
||||
-49,32,-5,2,4,
|
||||
5,15,-16,10,-21,
|
||||
8,-62,-8,64,8,
|
||||
79,-1,-66,-49,-18,
|
||||
5,40,-5,-30,-45,
|
||||
1,-6,21,-32,93,
|
||||
-18,-30,-21,32,21,
|
||||
-18,22,8,5,-41,
|
||||
-54,80,22,-10,-7,
|
||||
-8,-23,-64,66,56,
|
||||
-14,-30,-41,-46,-14,
|
||||
-29,-37,27,-14,42,
|
||||
-2,-9,-29,34,14,
|
||||
33,-14,22,4,10,
|
||||
26,26,28,32,23,
|
||||
-72,-32,3,0,-14,
|
||||
35,-42,-78,-32,6,
|
||||
29,-18,-45,-5,7,
|
||||
-33,-45,-3,-22,-34,
|
||||
8,-8,4,-51,-25,
|
||||
-9,59,-78,21,-5,
|
||||
-25,-48,66,-15,-17,
|
||||
-24,-49,-13,25,-23,
|
||||
-64,-6,40,-24,-19,
|
||||
-11,57,-33,-8,1,
|
||||
10,-52,-54,28,39,
|
||||
49,34,-11,-61,-41,
|
||||
-43,10,15,-15,51,
|
||||
30,15,-51,32,-34,
|
||||
-2,-34,14,18,16,
|
||||
1,1,-3,-3,1,
|
||||
1,-18,6,16,48,
|
||||
12,-5,-42,7,36,
|
||||
48,7,-20,-10,7,
|
||||
12,2,54,39,-38,
|
||||
37,54,4,-11,-8,
|
||||
-46,-10,5,-10,-34,
|
||||
46,-12,29,-37,39,
|
||||
36,-11,24,56,17,
|
||||
14,20,25,0,-25,
|
||||
-28,55,-7,-5,27,
|
||||
3,9,-26,-8,6,
|
||||
-24,-10,-30,-31,-34,
|
||||
18,4,22,21,40,
|
||||
-1,-29,-37,-8,-21,
|
||||
92,-29,11,-3,11,
|
||||
73,23,22,7,4,
|
||||
-44,-9,-11,21,-13,
|
||||
11,9,-78,-1,47,
|
||||
114,-12,-37,-19,-5,
|
||||
-11,-22,19,12,-30,
|
||||
7,38,45,-21,-8,
|
||||
-9,55,-45,56,-21,
|
||||
7,17,46,-57,-87,
|
||||
-6,27,31,31,7,
|
||||
-56,-12,46,21,-5,
|
||||
-12,36,3,3,-21,
|
||||
43,19,12,-7,9,
|
||||
-14,0,-9,-33,-91,
|
||||
7,26,3,-11,64,
|
||||
83,-31,-46,25,2,
|
||||
9,5,2,2,-1,
|
||||
20,-17,10,-5,-27,
|
||||
-8,20,8,-19,16,
|
||||
-21,-13,-31,5,5,
|
||||
42,24,9,34,-20,
|
||||
28,-61,22,11,-39,
|
||||
64,-20,-1,-30,-9,
|
||||
-20,24,-25,-24,-29,
|
||||
22,-60,6,-5,41,
|
||||
-9,-87,14,34,15,
|
||||
-57,52,69,15,-3,
|
||||
-102,58,16,3,6,
|
||||
60,-75,-32,26,7,
|
||||
-57,-27,-32,-24,-21,
|
||||
-29,-16,62,-46,31,
|
||||
30,-27,-15,7,15};
|
|
@ -1,98 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: exc_5_64_table.c
|
||||
Codebook for excitation in narrowband CELP mode (9600 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
const signed char exc_5_64_table[320]={
|
||||
1,5,-15,49,-66,
|
||||
-48,-4,50,-44,7,
|
||||
37,16,-18,25,-26,
|
||||
-26,-15,19,19,-27,
|
||||
-47,28,57,5,-17,
|
||||
-32,-41,68,21,-2,
|
||||
64,56,8,-16,-13,
|
||||
-26,-9,-16,11,6,
|
||||
-39,25,-19,22,-31,
|
||||
20,-45,55,-43,10,
|
||||
-16,47,-40,40,-20,
|
||||
-51,3,-17,-14,-15,
|
||||
-24,53,-20,-46,46,
|
||||
27,-68,32,3,-18,
|
||||
-5,9,-31,16,-9,
|
||||
-10,-1,-23,48,95,
|
||||
47,25,-41,-32,-3,
|
||||
15,-25,-55,36,41,
|
||||
-27,20,5,13,14,
|
||||
-22,5,2,-23,18,
|
||||
46,-15,17,-18,-34,
|
||||
-5,-8,27,-55,73,
|
||||
16,2,-1,-17,40,
|
||||
-78,33,0,2,19,
|
||||
4,53,-16,-15,-16,
|
||||
-28,-3,-13,49,8,
|
||||
-7,-29,27,-13,32,
|
||||
20,32,-61,16,14,
|
||||
41,44,40,24,20,
|
||||
7,4,48,-60,-77,
|
||||
17,-6,-48,65,-15,
|
||||
32,-30,-71,-10,-3,
|
||||
-6,10,-2,-7,-29,
|
||||
-56,67,-30,7,-5,
|
||||
86,-6,-10,0,5,
|
||||
-31,60,34,-38,-3,
|
||||
24,10,-2,30,23,
|
||||
24,-41,12,70,-43,
|
||||
15,-17,6,13,16,
|
||||
-13,8,30,-15,-8,
|
||||
5,23,-34,-98,-4,
|
||||
-13,13,-48,-31,70,
|
||||
12,31,25,24,-24,
|
||||
26,-7,33,-16,8,
|
||||
5,-11,-14,-8,-65,
|
||||
13,10,-2,-9,0,
|
||||
-3,-68,5,35,7,
|
||||
0,-31,-1,-17,-9,
|
||||
-9,16,-37,-18,-1,
|
||||
69,-48,-28,22,-21,
|
||||
-11,5,49,55,23,
|
||||
-86,-36,16,2,13,
|
||||
63,-51,30,-11,13,
|
||||
24,-18,-6,14,-19,
|
||||
1,41,9,-5,27,
|
||||
-36,-44,-34,-37,-21,
|
||||
-26,31,-39,15,43,
|
||||
5,-8,29,20,-8,
|
||||
-20,-52,-28,-1,13,
|
||||
26,-34,-10,-9,27,
|
||||
-8,8,27,-66,4,
|
||||
12,-22,49,10,-77,
|
||||
32,-18,3,-38,12,
|
||||
-3,-1,2,2,0};
|
|
@ -1,162 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: exc_8_128_table.c
|
||||
Codebook for excitation in narrowband CELP mode (7000 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
const signed char exc_8_128_table[1024] = {
|
||||
-14,9,13,-32,2,-10,31,-10,
|
||||
-8,-8,6,-4,-1,10,-64,23,
|
||||
6,20,13,6,8,-22,16,34,
|
||||
7,42,-49,-28,5,26,4,-15,
|
||||
41,34,41,32,33,24,23,14,
|
||||
8,40,34,4,-24,-41,-19,-15,
|
||||
13,-13,33,-54,24,27,-44,33,
|
||||
27,-15,-15,24,-19,14,-36,14,
|
||||
-9,24,-12,-4,37,-5,16,-34,
|
||||
5,10,33,-15,-54,-16,12,25,
|
||||
12,1,2,0,3,-1,-4,-4,
|
||||
11,2,-56,54,27,-20,13,-6,
|
||||
-46,-41,-33,-11,-5,7,12,14,
|
||||
-14,-5,8,20,6,3,4,-8,
|
||||
-5,-42,11,8,-14,25,-2,2,
|
||||
13,11,-22,39,-9,9,5,-45,
|
||||
-9,7,-9,12,-7,34,-17,-102,
|
||||
7,2,-42,18,35,-9,-34,11,
|
||||
-5,-2,3,22,46,-52,-25,-9,
|
||||
-94,8,11,-5,-5,-5,4,-7,
|
||||
-35,-7,54,5,-32,3,24,-9,
|
||||
-22,8,65,37,-1,-12,-23,-6,
|
||||
-9,-28,55,-33,14,-3,2,18,
|
||||
-60,41,-17,8,-16,17,-11,0,
|
||||
-11,29,-28,37,9,-53,33,-14,
|
||||
-9,7,-25,-7,-11,26,-32,-8,
|
||||
24,-21,22,-19,19,-10,29,-14,
|
||||
0,0,0,0,0,0,0,0,
|
||||
-5,-52,10,41,6,-30,-4,16,
|
||||
32,22,-27,-22,32,-3,-28,-3,
|
||||
3,-35,6,17,23,21,8,2,
|
||||
4,-45,-17,14,23,-4,-31,-11,
|
||||
-3,14,1,19,-11,2,61,-8,
|
||||
9,-12,7,-10,12,-3,-24,99,
|
||||
-48,23,50,-37,-5,-23,0,8,
|
||||
-14,35,-64,-5,46,-25,13,-1,
|
||||
-49,-19,-15,9,34,50,25,11,
|
||||
-6,-9,-16,-20,-32,-33,-32,-27,
|
||||
10,-8,12,-15,56,-14,-32,33,
|
||||
3,-9,1,65,-9,-9,-10,-2,
|
||||
-6,-23,9,17,3,-28,13,-32,
|
||||
4,-2,-10,4,-16,76,12,-52,
|
||||
6,13,33,-6,4,-14,-9,-3,
|
||||
1,-15,-16,28,1,-15,11,16,
|
||||
9,4,-21,-37,-40,-6,22,12,
|
||||
-15,-23,-14,-17,-16,-9,-10,-9,
|
||||
13,-39,41,5,-9,16,-38,25,
|
||||
46,-47,4,49,-14,17,-2,6,
|
||||
18,5,-6,-33,-22,44,50,-2,
|
||||
1,3,-6,7,7,-3,-21,38,
|
||||
-18,34,-14,-41,60,-13,6,16,
|
||||
-24,35,19,-13,-36,24,3,-17,
|
||||
-14,-10,36,44,-44,-29,-3,3,
|
||||
-54,-8,12,55,26,4,-2,-5,
|
||||
2,-11,22,-23,2,22,1,-25,
|
||||
-39,66,-49,21,-8,-2,10,-14,
|
||||
-60,25,6,10,27,-25,16,5,
|
||||
-2,-9,26,-13,-20,58,-2,7,
|
||||
52,-9,2,5,-4,-15,23,-1,
|
||||
-38,23,8,27,-6,0,-27,-7,
|
||||
39,-10,-14,26,11,-45,-12,9,
|
||||
-5,34,4,-35,10,43,-22,-11,
|
||||
56,-7,20,1,10,1,-26,9,
|
||||
94,11,-27,-14,-13,1,-11,0,
|
||||
14,-5,-6,-10,-4,-15,-8,-41,
|
||||
21,-5,1,-28,-8,22,-9,33,
|
||||
-23,-4,-4,-12,39,4,-7,3,
|
||||
-60,80,8,-17,2,-6,12,-5,
|
||||
1,9,15,27,31,30,27,23,
|
||||
61,47,26,10,-5,-8,-12,-13,
|
||||
5,-18,25,-15,-4,-15,-11,12,
|
||||
-2,-2,-16,-2,-6,24,12,11,
|
||||
-4,9,1,-9,14,-45,57,12,
|
||||
20,-35,26,11,-64,32,-10,-10,
|
||||
42,-4,-9,-16,32,24,7,10,
|
||||
52,-11,-57,29,0,8,0,-6,
|
||||
17,-17,-56,-40,7,20,18,12,
|
||||
-6,16,5,7,-1,9,1,10,
|
||||
29,12,16,13,-2,23,7,9,
|
||||
-3,-4,-5,18,-64,13,55,-25,
|
||||
9,-9,24,14,-25,15,-11,-40,
|
||||
-30,37,1,-19,22,-5,-31,13,
|
||||
-2,0,7,-4,16,-67,12,66,
|
||||
-36,24,-8,18,-15,-23,19,0,
|
||||
-45,-7,4,3,-13,13,35,5,
|
||||
13,33,10,27,23,0,-7,-11,
|
||||
43,-74,36,-12,2,5,-8,6,
|
||||
-33,11,-16,-14,-5,-7,-3,17,
|
||||
-34,27,-16,11,-9,15,33,-31,
|
||||
8,-16,7,-6,-7,63,-55,-17,
|
||||
11,-1,20,-46,34,-30,6,9,
|
||||
19,28,-9,5,-24,-8,-23,-2,
|
||||
31,-19,-16,-5,-15,-18,0,26,
|
||||
18,37,-5,-15,-2,17,5,-27,
|
||||
21,-33,44,12,-27,-9,17,11,
|
||||
25,-21,-31,-7,13,33,-8,-25,
|
||||
-7,7,-10,4,-6,-9,48,-82,
|
||||
-23,-8,6,11,-23,3,-3,49,
|
||||
-29,25,31,4,14,16,9,-4,
|
||||
-18,10,-26,3,5,-44,-9,9,
|
||||
-47,-55,15,9,28,1,4,-3,
|
||||
46,6,-6,-38,-29,-31,-15,-6,
|
||||
3,0,14,-6,8,-54,-50,33,
|
||||
-5,1,-14,33,-48,26,-4,-5,
|
||||
-3,-5,-3,-5,-28,-22,77,55,
|
||||
-1,2,10,10,-9,-14,-66,-49,
|
||||
11,-36,-6,-20,10,-10,16,12,
|
||||
4,-1,-16,45,-44,-50,31,-2,
|
||||
25,42,23,-32,-22,0,11,20,
|
||||
-40,-35,-40,-36,-32,-26,-21,-13,
|
||||
52,-22,6,-24,-20,17,-5,-8,
|
||||
36,-25,-11,21,-26,6,34,-8,
|
||||
7,20,-3,5,-25,-8,18,-5,
|
||||
-9,-4,1,-9,20,20,39,48,
|
||||
-24,9,5,-65,22,29,4,3,
|
||||
-43,-11,32,-6,9,19,-27,-10,
|
||||
-47,-14,24,10,-7,-36,-7,-1,
|
||||
-4,-5,-5,16,53,25,-26,-29,
|
||||
-4,-12,45,-58,-34,33,-5,2,
|
||||
-1,27,-48,31,-15,22,-5,4,
|
||||
7,7,-25,-3,11,-22,16,-12,
|
||||
8,-3,7,-11,45,14,-73,-19,
|
||||
56,-46,24,-20,28,-12,-2,-1,
|
||||
-36,-3,-33,19,-6,7,2,-15,
|
||||
5,-31,-45,8,35,13,20,0,
|
||||
-9,48,-13,-43,-3,-13,2,-5,
|
||||
72,-68,-27,2,1,-2,-7,5,
|
||||
36,33,-40,-12,-4,-5,23,19};
|
|
@ -1,314 +0,0 @@
|
|||
/* Copyright (C) 2005-2006 Jean-Marc Valin
|
||||
File: fftwrap.c
|
||||
|
||||
Wrapper for various FFTs
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/*#define USE_SMALLFT*/
|
||||
#define USE_KISS_FFT
|
||||
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
#define MAX_FFT_SIZE 2048
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
static int maximize_range(spx_word16_t *in, spx_word16_t *out, spx_word16_t bound, int len)
|
||||
{
|
||||
int i, shift;
|
||||
spx_word16_t max_val = 0;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
if (in[i]>max_val)
|
||||
max_val = in[i];
|
||||
if (-in[i]>max_val)
|
||||
max_val = -in[i];
|
||||
}
|
||||
shift=0;
|
||||
while (max_val <= (bound>>1) && max_val != 0)
|
||||
{
|
||||
max_val <<= 1;
|
||||
shift++;
|
||||
}
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
out[i] = in[i] << shift;
|
||||
}
|
||||
return shift;
|
||||
}
|
||||
|
||||
static void renorm_range(spx_word16_t *in, spx_word16_t *out, int shift, int len)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
out[i] = (in[i] + (1<<(shift-1))) >> shift;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SMALLFT
|
||||
|
||||
#include "smallft.h"
|
||||
#include <math.h>
|
||||
|
||||
void *spx_fft_init(int size)
|
||||
{
|
||||
struct drft_lookup *table;
|
||||
table = speex_alloc(sizeof(struct drft_lookup));
|
||||
spx_drft_init((struct drft_lookup *)table, size);
|
||||
return (void*)table;
|
||||
}
|
||||
|
||||
void spx_fft_destroy(void *table)
|
||||
{
|
||||
spx_drft_clear(table);
|
||||
speex_free(table);
|
||||
}
|
||||
|
||||
void spx_fft(void *table, float *in, float *out)
|
||||
{
|
||||
if (in==out)
|
||||
{
|
||||
int i;
|
||||
float scale = 1./((struct drft_lookup *)table)->n;
|
||||
speex_warning("FFT should not be done in-place");
|
||||
for (i=0;i<((struct drft_lookup *)table)->n;i++)
|
||||
out[i] = scale*in[i];
|
||||
} else {
|
||||
int i;
|
||||
float scale = 1./((struct drft_lookup *)table)->n;
|
||||
for (i=0;i<((struct drft_lookup *)table)->n;i++)
|
||||
out[i] = scale*in[i];
|
||||
}
|
||||
spx_drft_forward((struct drft_lookup *)table, out);
|
||||
}
|
||||
|
||||
void spx_ifft(void *table, float *in, float *out)
|
||||
{
|
||||
if (in==out)
|
||||
{
|
||||
speex_warning("FFT should not be done in-place");
|
||||
} else {
|
||||
int i;
|
||||
for (i=0;i<((struct drft_lookup *)table)->n;i++)
|
||||
out[i] = in[i];
|
||||
}
|
||||
spx_drft_backward((struct drft_lookup *)table, out);
|
||||
}
|
||||
|
||||
#elif defined(USE_KISS_FFT)
|
||||
|
||||
#include "kiss_fftr.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
struct kiss_config {
|
||||
kiss_fftr_cfg forward;
|
||||
kiss_fftr_cfg backward;
|
||||
kiss_fft_cpx *freq_data;
|
||||
int N;
|
||||
};
|
||||
|
||||
void *spx_fft_init(int size)
|
||||
{
|
||||
struct kiss_config *table;
|
||||
table = (struct kiss_config*)speex_alloc(sizeof(struct kiss_config));
|
||||
table->freq_data = (kiss_fft_cpx*)speex_alloc(sizeof(kiss_fft_cpx)*((size>>1)+1));
|
||||
table->forward = kiss_fftr_alloc(size,0,NULL,NULL);
|
||||
table->backward = kiss_fftr_alloc(size,1,NULL,NULL);
|
||||
table->N = size;
|
||||
return table;
|
||||
}
|
||||
|
||||
void spx_fft_destroy(void *table)
|
||||
{
|
||||
struct kiss_config *t = (struct kiss_config *)table;
|
||||
kiss_fftr_free(t->forward);
|
||||
kiss_fftr_free(t->backward);
|
||||
speex_free(t->freq_data);
|
||||
speex_free(table);
|
||||
}
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out)
|
||||
{
|
||||
int i;
|
||||
int shift;
|
||||
struct kiss_config *t = (struct kiss_config *)table;
|
||||
shift = maximize_range(in, in, 32000, t->N);
|
||||
kiss_fftr(t->forward, in, t->freq_data);
|
||||
out[0] = t->freq_data[0].r;
|
||||
for (i=1;i<t->N>>1;i++)
|
||||
{
|
||||
out[(i<<1)-1] = t->freq_data[i].r;
|
||||
out[(i<<1)] = t->freq_data[i].i;
|
||||
}
|
||||
out[(i<<1)-1] = t->freq_data[i].r;
|
||||
renorm_range(in, in, shift, t->N);
|
||||
renorm_range(out, out, shift, t->N);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out)
|
||||
{
|
||||
int i;
|
||||
float scale;
|
||||
struct kiss_config *t = (struct kiss_config *)table;
|
||||
scale = 1./t->N;
|
||||
kiss_fftr(t->forward, in, t->freq_data);
|
||||
out[0] = scale*t->freq_data[0].r;
|
||||
for (i=1;i<t->N>>1;i++)
|
||||
{
|
||||
out[(i<<1)-1] = scale*t->freq_data[i].r;
|
||||
out[(i<<1)] = scale*t->freq_data[i].i;
|
||||
}
|
||||
out[(i<<1)-1] = scale*t->freq_data[i].r;
|
||||
}
|
||||
#endif
|
||||
|
||||
void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out)
|
||||
{
|
||||
int i;
|
||||
struct kiss_config *t = (struct kiss_config *)table;
|
||||
t->freq_data[0].r = in[0];
|
||||
t->freq_data[0].i = 0;
|
||||
for (i=1;i<t->N>>1;i++)
|
||||
{
|
||||
t->freq_data[i].r = in[(i<<1)-1];
|
||||
t->freq_data[i].i = in[(i<<1)];
|
||||
}
|
||||
t->freq_data[i].r = in[(i<<1)-1];
|
||||
t->freq_data[i].i = 0;
|
||||
|
||||
kiss_fftri(t->backward, t->freq_data, out);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#error No other FFT implemented
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
/*#include "smallft.h"*/
|
||||
|
||||
|
||||
void spx_fft_float(void *table, float *in, float *out)
|
||||
{
|
||||
int i;
|
||||
#ifdef USE_SMALLFT
|
||||
int N = ((struct drft_lookup *)table)->n;
|
||||
#elif defined(USE_KISS_FFT)
|
||||
int N = ((struct kiss_config *)table)->N;
|
||||
#else
|
||||
#endif
|
||||
#ifdef VAR_ARRAYS
|
||||
spx_word16_t _in[N];
|
||||
spx_word16_t _out[N];
|
||||
#else
|
||||
spx_word16_t _in[MAX_FFT_SIZE];
|
||||
spx_word16_t _out[MAX_FFT_SIZE];
|
||||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
_in[i] = (int)floor(.5+in[i]);
|
||||
spx_fft(table, _in, _out);
|
||||
for (i=0;i<N;i++)
|
||||
out[i] = _out[i];
|
||||
#if 0
|
||||
if (!fixed_point)
|
||||
{
|
||||
float scale;
|
||||
struct drft_lookup t;
|
||||
spx_drft_init(&t, ((struct kiss_config *)table)->N);
|
||||
scale = 1./((struct kiss_config *)table)->N;
|
||||
for (i=0;i<((struct kiss_config *)table)->N;i++)
|
||||
out[i] = scale*in[i];
|
||||
spx_drft_forward(&t, out);
|
||||
spx_drft_clear(&t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void spx_ifft_float(void *table, float *in, float *out)
|
||||
{
|
||||
int i;
|
||||
#ifdef USE_SMALLFT
|
||||
int N = ((struct drft_lookup *)table)->n;
|
||||
#elif defined(USE_KISS_FFT)
|
||||
int N = ((struct kiss_config *)table)->N;
|
||||
#else
|
||||
#endif
|
||||
#ifdef VAR_ARRAYS
|
||||
spx_word16_t _in[N];
|
||||
spx_word16_t _out[N];
|
||||
#else
|
||||
spx_word16_t _in[MAX_FFT_SIZE];
|
||||
spx_word16_t _out[MAX_FFT_SIZE];
|
||||
#endif
|
||||
for (i=0;i<N;i++)
|
||||
_in[i] = (int)floor(.5+in[i]);
|
||||
spx_ifft(table, _in, _out);
|
||||
for (i=0;i<N;i++)
|
||||
out[i] = _out[i];
|
||||
#if 0
|
||||
if (!fixed_point)
|
||||
{
|
||||
int i;
|
||||
struct drft_lookup t;
|
||||
spx_drft_init(&t, ((struct kiss_config *)table)->N);
|
||||
for (i=0;i<((struct kiss_config *)table)->N;i++)
|
||||
out[i] = in[i];
|
||||
spx_drft_backward(&t, out);
|
||||
spx_drft_clear(&t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void spx_fft_float(void *table, float *in, float *out)
|
||||
{
|
||||
spx_fft(table, in, out);
|
||||
}
|
||||
void spx_ifft_float(void *table, float *in, float *out)
|
||||
{
|
||||
spx_ifft(table, in, out);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,58 +0,0 @@
|
|||
/* Copyright (C) 2005 Jean-Marc Valin
|
||||
File: fftwrap.h
|
||||
|
||||
Wrapper for various FFTs
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef FFTWRAP_H
|
||||
#define FFTWRAP_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
/** Compute tables for an FFT */
|
||||
void *spx_fft_init(int size);
|
||||
|
||||
/** Destroy tables for an FFT */
|
||||
void spx_fft_destroy(void *table);
|
||||
|
||||
/** Forward (real to half-complex) transform */
|
||||
void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out);
|
||||
|
||||
/** Backward (half-complex to real) transform */
|
||||
void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out);
|
||||
|
||||
/** Forward (real to half-complex) transform of float data */
|
||||
void spx_fft_float(void *table, float *in, float *out);
|
||||
|
||||
/** Backward (half-complex to real) transform of float data */
|
||||
void spx_ifft_float(void *table, float *in, float *out);
|
||||
|
||||
#endif
|
|
@ -1,200 +0,0 @@
|
|||
/* Copyright (C) 2006 Jean-Marc Valin */
|
||||
/**
|
||||
@file filterbank.c
|
||||
@brief Converting between psd and filterbank
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "filterbank.h"
|
||||
#include "misc.h"
|
||||
#include <math.h>
|
||||
#include "math_approx.h"
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
#define toBARK(n) (MULT16_16(26829,spx_atan(SHR32(MULT16_16(97,n),2))) + MULT16_16(4588,spx_atan(MULT16_32_Q15(20,MULT16_16(n,n)))) + MULT16_16(3355,n))
|
||||
|
||||
#else
|
||||
#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n))
|
||||
#endif
|
||||
|
||||
#define toMEL(n) (2595.f*log10(1.f+(n)/700.f))
|
||||
|
||||
FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type)
|
||||
{
|
||||
FilterBank *bank;
|
||||
spx_word32_t df;
|
||||
spx_word32_t max_mel, mel_interval;
|
||||
int i;
|
||||
int id1;
|
||||
int id2;
|
||||
df = DIV32(SHL32(sampling,15),MULT16_16(2,len));
|
||||
max_mel = toBARK(EXTRACT16(MULT16_16_Q15(QCONST16(.5f,15),sampling)));
|
||||
mel_interval = PDIV32(max_mel,banks-1);
|
||||
|
||||
bank = (FilterBank*)speex_alloc(sizeof(FilterBank));
|
||||
bank->nb_banks = banks;
|
||||
bank->len = len;
|
||||
bank->bank_left = (int*)speex_alloc(len*sizeof(int));
|
||||
bank->bank_right = (int*)speex_alloc(len*sizeof(int));
|
||||
bank->filter_left = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t));
|
||||
bank->filter_right = (spx_word16_t*)speex_alloc(len*sizeof(spx_word16_t));
|
||||
/* Think I can safely disable normalisation that for fixed-point (and probably float as well) */
|
||||
#ifndef FIXED_POINT
|
||||
bank->scaling = (float*)speex_alloc(banks*sizeof(float));
|
||||
#endif
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_word16_t curr_freq;
|
||||
spx_word32_t mel;
|
||||
spx_word16_t val;
|
||||
curr_freq = EXTRACT16(MULT16_32_P15(i,df));
|
||||
mel = toBARK(curr_freq);
|
||||
if (mel > max_mel)
|
||||
break;
|
||||
#ifdef FIXED_POINT
|
||||
id1 = DIV32(mel,mel_interval);
|
||||
#else
|
||||
id1 = (int)(floor(mel/mel_interval));
|
||||
#endif
|
||||
if (id1>banks-2)
|
||||
{
|
||||
id1 = banks-2;
|
||||
val = Q15_ONE;
|
||||
} else {
|
||||
val = DIV32_16(mel - id1*mel_interval,EXTRACT16(PSHR32(mel_interval,15)));
|
||||
}
|
||||
id2 = id1+1;
|
||||
bank->bank_left[i] = id1;
|
||||
bank->filter_left[i] = SUB16(Q15_ONE,val);
|
||||
bank->bank_right[i] = id2;
|
||||
bank->filter_right[i] = val;
|
||||
}
|
||||
|
||||
/* Think I can safely disable normalisation for fixed-point (and probably float as well) */
|
||||
#ifndef FIXED_POINT
|
||||
for (i=0;i<bank->nb_banks;i++)
|
||||
bank->scaling[i] = 0;
|
||||
for (i=0;i<bank->len;i++)
|
||||
{
|
||||
int id = bank->bank_left[i];
|
||||
bank->scaling[id] += bank->filter_left[i];
|
||||
id = bank->bank_right[i];
|
||||
bank->scaling[id] += bank->filter_right[i];
|
||||
}
|
||||
for (i=0;i<bank->nb_banks;i++)
|
||||
bank->scaling[i] = Q15_ONE/(bank->scaling[i]);
|
||||
#endif
|
||||
return bank;
|
||||
}
|
||||
|
||||
void filterbank_destroy(FilterBank *bank)
|
||||
{
|
||||
speex_free(bank->bank_left);
|
||||
speex_free(bank->bank_right);
|
||||
speex_free(bank->filter_left);
|
||||
speex_free(bank->filter_right);
|
||||
#ifndef FIXED_POINT
|
||||
speex_free(bank->scaling);
|
||||
#endif
|
||||
speex_free(bank);
|
||||
}
|
||||
|
||||
void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<bank->nb_banks;i++)
|
||||
mel[i] = 0;
|
||||
|
||||
for (i=0;i<bank->len;i++)
|
||||
{
|
||||
int id;
|
||||
id = bank->bank_left[i];
|
||||
mel[id] += MULT16_32_P15(bank->filter_left[i],ps[i]);
|
||||
id = bank->bank_right[i];
|
||||
mel[id] += MULT16_32_P15(bank->filter_right[i],ps[i]);
|
||||
}
|
||||
/* Think I can safely disable normalisation that for fixed-point (and probably float as well) */
|
||||
#ifndef FIXED_POINT
|
||||
/*for (i=0;i<bank->nb_banks;i++)
|
||||
mel[i] = MULT16_32_P15(Q15(bank->scaling[i]),mel[i]);
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *ps)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<bank->len;i++)
|
||||
{
|
||||
spx_word32_t tmp;
|
||||
int id1, id2;
|
||||
id1 = bank->bank_left[i];
|
||||
id2 = bank->bank_right[i];
|
||||
tmp = MULT16_16(mel[id1],bank->filter_left[i]);
|
||||
tmp += MULT16_16(mel[id2],bank->filter_right[i]);
|
||||
ps[i] = EXTRACT16(PSHR32(tmp,15));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef FIXED_POINT
|
||||
void filterbank_compute_bank(FilterBank *bank, float *ps, float *mel)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<bank->nb_banks;i++)
|
||||
mel[i] = 0;
|
||||
|
||||
for (i=0;i<bank->len;i++)
|
||||
{
|
||||
int id = bank->bank_left[i];
|
||||
mel[id] += bank->filter_left[i]*ps[i];
|
||||
id = bank->bank_right[i];
|
||||
mel[id] += bank->filter_right[i]*ps[i];
|
||||
}
|
||||
for (i=0;i<bank->nb_banks;i++)
|
||||
mel[i] *= bank->scaling[i];
|
||||
}
|
||||
|
||||
void filterbank_compute_psd(FilterBank *bank, float *mel, float *ps)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<bank->len;i++)
|
||||
{
|
||||
int id = bank->bank_left[i];
|
||||
ps[i] = mel[id]*bank->filter_left[i];
|
||||
id = bank->bank_right[i];
|
||||
ps[i] += mel[id]*bank->filter_right[i];
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,66 +0,0 @@
|
|||
/* Copyright (C) 2006 Jean-Marc Valin */
|
||||
/**
|
||||
@file filterbank.h
|
||||
@brief Converting between psd and filterbank
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FILTERBANK_H
|
||||
#define FILTERBANK_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
typedef struct {
|
||||
int *bank_left;
|
||||
int *bank_right;
|
||||
spx_word16_t *filter_left;
|
||||
spx_word16_t *filter_right;
|
||||
#ifndef FIXED_POINT
|
||||
float *scaling;
|
||||
#endif
|
||||
int nb_banks;
|
||||
int len;
|
||||
} FilterBank;
|
||||
|
||||
|
||||
FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type);
|
||||
|
||||
void filterbank_destroy(FilterBank *bank);
|
||||
|
||||
void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel);
|
||||
|
||||
void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *psd);
|
||||
|
||||
#ifndef FIXED_POINT
|
||||
void filterbank_compute_bank(FilterBank *bank, float *psd, float *mel);
|
||||
void filterbank_compute_psd(FilterBank *bank, float *mel, float *psd);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -1,930 +0,0 @@
|
|||
/* Copyright (C) 2002-2006 Jean-Marc Valin
|
||||
File: filters.c
|
||||
Various analysis/synthesis filters
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "filters.h"
|
||||
#include "stack_alloc.h"
|
||||
#include "misc.h"
|
||||
#include "math_approx.h"
|
||||
#include "ltp.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _USE_SSE
|
||||
#include "filters_sse.h"
|
||||
#elif defined (ARM4_ASM) || defined(ARM5E_ASM)
|
||||
#include "filters_arm4.h"
|
||||
#elif defined (BFIN_ASM)
|
||||
#include "filters_bfin.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void bw_lpc(spx_word16_t gamma, const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t tmp=gamma;
|
||||
for (i=0;i<order;i++)
|
||||
{
|
||||
lpc_out[i] = MULT16_16_P15(tmp,lpc_in[i]);
|
||||
tmp = MULT16_16_P15(tmp, gamma);
|
||||
}
|
||||
}
|
||||
|
||||
void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem)
|
||||
{
|
||||
int i;
|
||||
#ifdef FIXED_POINT
|
||||
const spx_word16_t Pcoef[5][3] = {{16384, -31313, 14991}, {16384, -31569, 15249}, {16384, -31677, 15328}, {16384, -32313, 15947}, {16384, -22446, 6537}};
|
||||
const spx_word16_t Zcoef[5][3] = {{15672, -31344, 15672}, {15802, -31601, 15802}, {15847, -31694, 15847}, {16162, -32322, 16162}, {14418, -28836, 14418}};
|
||||
#else
|
||||
const spx_word16_t Pcoef[5][3] = {{1.00000f, -1.91120f, 0.91498f}, {1.00000f, -1.92683f, 0.93071f}, {1.00000f, -1.93338f, 0.93553f}, {1.00000f, -1.97226f, 0.97332f}, {1.00000f, -1.37000f, 0.39900f}};
|
||||
const spx_word16_t Zcoef[5][3] = {{0.95654f, -1.91309f, 0.95654f}, {0.96446f, -1.92879f, 0.96446f}, {0.96723f, -1.93445f, 0.96723f}, {0.98645f, -1.97277f, 0.98645f}, {0.88000f, -1.76000f, 0.88000f}};
|
||||
#endif
|
||||
const spx_word16_t *den, *num;
|
||||
if (filtID>4)
|
||||
filtID=4;
|
||||
|
||||
den = Pcoef[filtID]; num = Zcoef[filtID];
|
||||
/*return;*/
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_word16_t yi;
|
||||
spx_word32_t vout = ADD32(MULT16_16(num[0], x[i]),mem[0]);
|
||||
yi = EXTRACT16(SATURATE(PSHR32(vout,14),32767));
|
||||
mem[0] = ADD32(MAC16_16(mem[1], num[1],x[i]), SHL32(MULT16_32_Q15(-den[1],vout),1));
|
||||
mem[1] = ADD32(MULT16_16(num[2],x[i]), SHL32(MULT16_32_Q15(-den[2],vout),1));
|
||||
y[i] = yi;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
/* FIXME: These functions are ugly and probably introduce too much error */
|
||||
void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
y[i] = SHL32(MULT16_32_Q14(EXTRACT16(SHR32(x[i],7)),scale),7);
|
||||
}
|
||||
}
|
||||
|
||||
void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int len)
|
||||
{
|
||||
int i;
|
||||
if (scale > SHL32(EXTEND32(SIG_SCALING), 8))
|
||||
{
|
||||
spx_word16_t scale_1;
|
||||
scale = PSHR32(scale, SIG_SHIFT);
|
||||
scale_1 = EXTRACT16(PDIV32_16(SHL32(EXTEND32(SIG_SCALING),7),scale));
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
y[i] = MULT16_16_P15(scale_1, x[i]);
|
||||
}
|
||||
} else if (scale > SHR32(EXTEND32(SIG_SCALING), 2)) {
|
||||
spx_word16_t scale_1;
|
||||
scale = PSHR32(scale, SIG_SHIFT-5);
|
||||
scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale);
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
y[i] = PSHR32(MULT16_16(scale_1, SHL16(x[i],2)),8);
|
||||
}
|
||||
} else {
|
||||
spx_word16_t scale_1;
|
||||
scale = PSHR32(scale, SIG_SHIFT-7);
|
||||
if (scale < 5)
|
||||
scale = 5;
|
||||
scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale);
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
y[i] = PSHR32(MULT16_16(scale_1, SHL16(x[i],2)),6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<len;i++)
|
||||
y[i] = scale*x[i];
|
||||
}
|
||||
|
||||
void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
|
||||
{
|
||||
int i;
|
||||
float scale_1 = 1/scale;
|
||||
for (i=0;i<len;i++)
|
||||
y[i] = scale_1*x[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
|
||||
|
||||
spx_word16_t compute_rms(const spx_sig_t *x, int len)
|
||||
{
|
||||
int i;
|
||||
spx_word32_t sum=0;
|
||||
spx_sig_t max_val=1;
|
||||
int sig_shift;
|
||||
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_sig_t tmp = x[i];
|
||||
if (tmp<0)
|
||||
tmp = -tmp;
|
||||
if (tmp > max_val)
|
||||
max_val = tmp;
|
||||
}
|
||||
|
||||
sig_shift=0;
|
||||
while (max_val>16383)
|
||||
{
|
||||
sig_shift++;
|
||||
max_val >>= 1;
|
||||
}
|
||||
|
||||
for (i=0;i<len;i+=4)
|
||||
{
|
||||
spx_word32_t sum2=0;
|
||||
spx_word16_t tmp;
|
||||
tmp = EXTRACT16(SHR32(x[i],sig_shift));
|
||||
sum2 = MAC16_16(sum2,tmp,tmp);
|
||||
tmp = EXTRACT16(SHR32(x[i+1],sig_shift));
|
||||
sum2 = MAC16_16(sum2,tmp,tmp);
|
||||
tmp = EXTRACT16(SHR32(x[i+2],sig_shift));
|
||||
sum2 = MAC16_16(sum2,tmp,tmp);
|
||||
tmp = EXTRACT16(SHR32(x[i+3],sig_shift));
|
||||
sum2 = MAC16_16(sum2,tmp,tmp);
|
||||
sum = ADD32(sum,SHR32(sum2,6));
|
||||
}
|
||||
|
||||
return EXTRACT16(PSHR32(SHL32(EXTEND32(spx_sqrt(DIV32(sum,len))),(sig_shift+3)),SIG_SHIFT));
|
||||
}
|
||||
|
||||
spx_word16_t compute_rms16(const spx_word16_t *x, int len)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t max_val=10;
|
||||
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_sig_t tmp = x[i];
|
||||
if (tmp<0)
|
||||
tmp = -tmp;
|
||||
if (tmp > max_val)
|
||||
max_val = tmp;
|
||||
}
|
||||
if (max_val>16383)
|
||||
{
|
||||
spx_word32_t sum=0;
|
||||
for (i=0;i<len;i+=4)
|
||||
{
|
||||
spx_word32_t sum2=0;
|
||||
sum2 = MAC16_16(sum2,SHR16(x[i],1),SHR16(x[i],1));
|
||||
sum2 = MAC16_16(sum2,SHR16(x[i+1],1),SHR16(x[i+1],1));
|
||||
sum2 = MAC16_16(sum2,SHR16(x[i+2],1),SHR16(x[i+2],1));
|
||||
sum2 = MAC16_16(sum2,SHR16(x[i+3],1),SHR16(x[i+3],1));
|
||||
sum = ADD32(sum,SHR32(sum2,6));
|
||||
}
|
||||
return SHL16(spx_sqrt(DIV32(sum,len)),4);
|
||||
} else {
|
||||
spx_word32_t sum=0;
|
||||
int sig_shift=0;
|
||||
if (max_val < 8192)
|
||||
sig_shift=1;
|
||||
if (max_val < 4096)
|
||||
sig_shift=2;
|
||||
if (max_val < 2048)
|
||||
sig_shift=3;
|
||||
for (i=0;i<len;i+=4)
|
||||
{
|
||||
spx_word32_t sum2=0;
|
||||
sum2 = MAC16_16(sum2,SHL16(x[i],sig_shift),SHL16(x[i],sig_shift));
|
||||
sum2 = MAC16_16(sum2,SHL16(x[i+1],sig_shift),SHL16(x[i+1],sig_shift));
|
||||
sum2 = MAC16_16(sum2,SHL16(x[i+2],sig_shift),SHL16(x[i+2],sig_shift));
|
||||
sum2 = MAC16_16(sum2,SHL16(x[i+3],sig_shift),SHL16(x[i+3],sig_shift));
|
||||
sum = ADD32(sum,SHR32(sum2,6));
|
||||
}
|
||||
return SHL16(spx_sqrt(DIV32(sum,len)),3-sig_shift);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OVERRIDE_NORMALIZE16
|
||||
int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
|
||||
{
|
||||
int i;
|
||||
spx_sig_t max_val=1;
|
||||
int sig_shift;
|
||||
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_sig_t tmp = x[i];
|
||||
if (tmp<0)
|
||||
tmp = NEG32(tmp);
|
||||
if (tmp >= max_val)
|
||||
max_val = tmp;
|
||||
}
|
||||
|
||||
sig_shift=0;
|
||||
while (max_val>max_scale)
|
||||
{
|
||||
sig_shift++;
|
||||
max_val >>= 1;
|
||||
}
|
||||
|
||||
for (i=0;i<len;i++)
|
||||
y[i] = EXTRACT16(SHR32(x[i], sig_shift));
|
||||
|
||||
return sig_shift;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
spx_word16_t compute_rms(const spx_sig_t *x, int len)
|
||||
{
|
||||
int i;
|
||||
float sum=0;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
sum += x[i]*x[i];
|
||||
}
|
||||
return sqrt(.1+sum/len);
|
||||
}
|
||||
spx_word16_t compute_rms16(const spx_word16_t *x, int len)
|
||||
{
|
||||
return compute_rms(x, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef OVERRIDE_FILTER_MEM2
|
||||
#ifdef PRECISION16
|
||||
void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t xi,yi,nyi;
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi= EXTRACT16(PSHR32(SATURATE(x[i],536870911),SIG_SHIFT));
|
||||
yi = EXTRACT16(PSHR32(SATURATE(ADD32(x[i], SHL32(mem[0],1)),536870911),SIG_SHIFT));
|
||||
nyi = NEG16(yi);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_16(MAC16_16(mem[j+1], num[j],xi), den[j],nyi);
|
||||
}
|
||||
mem[ord-1] = ADD32(MULT16_16(num[ord-1],xi), MULT16_16(den[ord-1],nyi));
|
||||
y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_sig_t xi,yi,nyi;
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHR32(mem[i],1);
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi=SATURATE(x[i],805306368);
|
||||
yi = SATURATE(ADD32(xi, SHL32(mem[0],2)),805306368);
|
||||
nyi = NEG32(yi);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_32_Q15(MAC16_32_Q15(mem[j+1], num[j],xi), den[j],nyi);
|
||||
}
|
||||
mem[ord-1] = SUB32(MULT16_32_Q15(num[ord-1],xi), MULT16_32_Q15(den[ord-1],yi));
|
||||
y[i] = yi;
|
||||
}
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHL32(mem[i],1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#ifndef OVERRIDE_FILTER_MEM16
|
||||
void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t xi,yi,nyi;
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi= x[i];
|
||||
yi = EXTRACT16(SATURATE(ADD32(EXTEND32(x[i]),PSHR32(mem[0],LPC_SHIFT)),32767));
|
||||
nyi = NEG16(yi);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_16(MAC16_16(mem[j+1], num[j],xi), den[j],nyi);
|
||||
}
|
||||
mem[ord-1] = ADD32(MULT16_16(num[ord-1],xi), MULT16_16(den[ord-1],nyi));
|
||||
y[i] = yi;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
filter_mem2(x, num, den, y, N, ord, mem);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef OVERRIDE_IIR_MEM2
|
||||
#ifdef PRECISION16
|
||||
void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t yi,nyi;
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
yi = EXTRACT16(PSHR32(SATURATE(x[i] + SHL32(mem[0],1),536870911),SIG_SHIFT));
|
||||
nyi = NEG16(yi);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_16(mem[j+1],den[j],nyi);
|
||||
}
|
||||
mem[ord-1] = MULT16_16(den[ord-1],nyi);
|
||||
y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_word32_t xi,yi,nyi;
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHR32(mem[i],1);
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi=SATURATE(x[i],805306368);
|
||||
yi = SATURATE(xi + SHL32(mem[0],2),805306368);
|
||||
nyi = NEG32(yi);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_32_Q15(mem[j+1],den[j],nyi);
|
||||
}
|
||||
mem[ord-1] = MULT16_32_Q15(den[ord-1],nyi);
|
||||
y[i] = yi;
|
||||
}
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHL32(mem[i],1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#ifndef OVERRIDE_IIR_MEM16
|
||||
void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t yi,nyi;
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
yi = EXTRACT16(SATURATE(ADD32(EXTEND32(x[i]),PSHR32(mem[0],LPC_SHIFT)),32767));
|
||||
nyi = NEG16(yi);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_16(mem[j+1],den[j],nyi);
|
||||
}
|
||||
mem[ord-1] = MULT16_16(den[ord-1],nyi);
|
||||
y[i] = yi;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
iir_mem2(x, den, y, N, ord, mem);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef OVERRIDE_FIR_MEM2
|
||||
#ifdef PRECISION16
|
||||
void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t xi,yi;
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi= EXTRACT16(PSHR32(SATURATE(x[i],536870911),SIG_SHIFT));
|
||||
yi = EXTRACT16(PSHR32(SATURATE(x[i] + SHL32(mem[0],1),536870911),SIG_SHIFT));
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_16(mem[j+1], num[j],xi);
|
||||
}
|
||||
mem[ord-1] = MULT16_16(num[ord-1],xi);
|
||||
y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_word32_t xi,yi;
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHR32(mem[i],1);
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi=SATURATE(x[i],805306368);
|
||||
yi = xi + SHL32(mem[0],2);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_32_Q15(mem[j+1], num[j],xi);
|
||||
}
|
||||
mem[ord-1] = MULT16_32_Q15(num[ord-1],xi);
|
||||
y[i] = SATURATE(yi,805306368);
|
||||
}
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHL32(mem[i],1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#ifndef OVERRIDE_FIR_MEM16
|
||||
void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t xi,yi;
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
xi=x[i];
|
||||
yi = EXTRACT16(SATURATE(ADD32(EXTEND32(x[i]),PSHR32(mem[0],LPC_SHIFT)),32767));
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem[j] = MAC16_16(mem[j+1], num[j],xi);
|
||||
}
|
||||
mem[ord-1] = MULT16_16(num[ord-1],xi);
|
||||
y[i] = yi;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
fir_mem2(x, num, y, N, ord, mem);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void syn_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
|
||||
{
|
||||
int i;
|
||||
VARDECL(spx_mem_t *mem);
|
||||
ALLOC(mem, ord, spx_mem_t);
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i]=0;
|
||||
iir_mem2(xx, ak, y, N, ord, mem);
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i]=0;
|
||||
filter_mem2(y, awk1, awk2, y, N, ord, mem);
|
||||
}
|
||||
|
||||
void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
|
||||
{
|
||||
int i;
|
||||
VARDECL(spx_mem_t *mem);
|
||||
ALLOC(mem, ord, spx_mem_t);
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i]=0;
|
||||
filter_mem2(xx, ak, awk1, y, N, ord, mem);
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i]=0;
|
||||
fir_mem2(y, awk2, y, N, ord, mem);
|
||||
}
|
||||
|
||||
#ifndef OVERRIDE_COMPUTE_IMPULSE_RESPONSE
|
||||
void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t y1, ny1i, ny2i;
|
||||
VARDECL(spx_mem_t *mem1);
|
||||
VARDECL(spx_mem_t *mem2);
|
||||
ALLOC(mem1, ord, spx_mem_t);
|
||||
ALLOC(mem2, ord, spx_mem_t);
|
||||
|
||||
y[0] = LPC_SCALING;
|
||||
for (i=0;i<ord;i++)
|
||||
y[i+1] = awk1[i];
|
||||
i++;
|
||||
for (;i<N;i++)
|
||||
y[i] = VERY_SMALL;
|
||||
for (i=0;i<ord;i++)
|
||||
mem1[i] = mem2[i] = 0;
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
y1 = ADD16(y[i], EXTRACT16(PSHR32(mem1[0],LPC_SHIFT)));
|
||||
ny1i = NEG16(y1);
|
||||
y[i] = PSHR32(ADD32(SHL32(EXTEND32(y1),LPC_SHIFT+1),mem2[0]),LPC_SHIFT);
|
||||
ny2i = NEG16(y[i]);
|
||||
for (j=0;j<ord-1;j++)
|
||||
{
|
||||
mem1[j] = MAC16_16(mem1[j+1], awk2[j],ny1i);
|
||||
mem2[j] = MAC16_16(mem2[j+1], ak[j],ny2i);
|
||||
}
|
||||
mem1[ord-1] = MULT16_16(awk2[ord-1],ny1i);
|
||||
mem2[ord-1] = MULT16_16(ak[ord-1],ny2i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack)
|
||||
{
|
||||
int i,j,k,M2;
|
||||
VARDECL(spx_word16_t *a);
|
||||
VARDECL(spx_word16_t *x);
|
||||
spx_word16_t *x2;
|
||||
|
||||
ALLOC(a, M, spx_word16_t);
|
||||
ALLOC(x, N+M-1, spx_word16_t);
|
||||
x2=x+M-1;
|
||||
M2=M>>1;
|
||||
for (i=0;i<M;i++)
|
||||
a[M-i-1]= aa[i];
|
||||
|
||||
for (i=0;i<M-1;i++)
|
||||
x[i]=mem[M-i-2];
|
||||
for (i=0;i<N;i++)
|
||||
x[i+M-1]=SATURATE(PSHR(xx[i],1),16383);
|
||||
for (i=0,k=0;i<N;i+=2,k++)
|
||||
{
|
||||
y1[k]=0;
|
||||
y2[k]=0;
|
||||
for (j=0;j<M2;j++)
|
||||
{
|
||||
y1[k]=ADD32(y1[k],MULT16_16(a[j],ADD16(x[i+j],x2[i-j])));
|
||||
y2[k]=SUB32(y2[k],MULT16_16(a[j],SUB16(x[i+j],x2[i-j])));
|
||||
j++;
|
||||
y1[k]=ADD32(y1[k],MULT16_16(a[j],ADD16(x[i+j],x2[i-j])));
|
||||
y2[k]=ADD32(y2[k],MULT16_16(a[j],SUB16(x[i+j],x2[i-j])));
|
||||
}
|
||||
y1[k] = SHR32(y1[k],1);
|
||||
y2[k] = SHR32(y2[k],1);
|
||||
}
|
||||
for (i=0;i<M-1;i++)
|
||||
mem[i]=SATURATE(PSHR(xx[N-i-1],1),16383);
|
||||
}
|
||||
|
||||
|
||||
/* By segher */
|
||||
void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack)
|
||||
/* assumptions:
|
||||
all odd x[i] are zero -- well, actually they are left out of the array now
|
||||
N and M are multiples of 4 */
|
||||
{
|
||||
int i, j;
|
||||
VARDECL(spx_word16_t *xx);
|
||||
|
||||
ALLOC(xx, M+N-1, spx_word16_t);
|
||||
|
||||
for (i = 0; i < N/2; i++)
|
||||
xx[2*i] = PSHR32(x[N/2-1-i],SIG_SHIFT);
|
||||
for (i = 0; i < M - 1; i += 2)
|
||||
xx[N+i] = mem[i+1];
|
||||
|
||||
for (i = 0; i < N; i += 4) {
|
||||
spx_sig_t y0, y1, y2, y3;
|
||||
spx_word16_t x0;
|
||||
|
||||
y0 = y1 = y2 = y3 = 0;
|
||||
x0 = xx[N-4-i];
|
||||
|
||||
for (j = 0; j < M; j += 4) {
|
||||
spx_word16_t x1;
|
||||
spx_word16_t a0, a1;
|
||||
|
||||
a0 = a[j];
|
||||
a1 = a[j+1];
|
||||
x1 = xx[N-2+j-i];
|
||||
|
||||
y0 = ADD32(y0,SHR32(MULT16_16(a0, x1),2));
|
||||
y1 = ADD32(y1,SHR32(MULT16_16(a1, x1),2));
|
||||
y2 = ADD32(y2,SHR32(MULT16_16(a0, x0),2));
|
||||
y3 = ADD32(y3,SHR32(MULT16_16(a1, x0),2));
|
||||
|
||||
a0 = a[j+2];
|
||||
a1 = a[j+3];
|
||||
x0 = xx[N+j-i];
|
||||
|
||||
y0 = ADD32(y0,SHR32(MULT16_16(a0, x0),2));
|
||||
y1 = ADD32(y1,SHR32(MULT16_16(a1, x0),2));
|
||||
y2 = ADD32(y2,SHR32(MULT16_16(a0, x1),2));
|
||||
y3 = ADD32(y3,SHR32(MULT16_16(a1, x1),2));
|
||||
}
|
||||
y[i] = y0;
|
||||
y[i+1] = y1;
|
||||
y[i+2] = y2;
|
||||
y[i+3] = y3;
|
||||
}
|
||||
|
||||
for (i = 0; i < M - 1; i += 2)
|
||||
mem[i+1] = xx[i];
|
||||
}
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#if 0
|
||||
const spx_word16_t shift_filt[3][7] = {{-33, 1043, -4551, 19959, 19959, -4551, 1043},
|
||||
{-98, 1133, -4425, 29179, 8895, -2328, 444},
|
||||
{444, -2328, 8895, 29179, -4425, 1133, -98}};
|
||||
#else
|
||||
const spx_word16_t shift_filt[3][7] = {{-390, 1540, -4993, 20123, 20123, -4993, 1540},
|
||||
{-1064, 2817, -6694, 31589, 6837, -990, -209},
|
||||
{-209, -990, 6837, 31589, -6694, 2817, -1064}};
|
||||
#endif
|
||||
#else
|
||||
#if 0
|
||||
const float shift_filt[3][7] = {{-9.9369e-04, 3.1831e-02, -1.3889e-01, 6.0910e-01, 6.0910e-01, -1.3889e-01, 3.1831e-02},
|
||||
{-0.0029937, 0.0345613, -0.1350474, 0.8904793, 0.2714479, -0.0710304, 0.0135403},
|
||||
{0.0135403, -0.0710304, 0.2714479, 0.8904793, -0.1350474, 0.0345613, -0.0029937}};
|
||||
#else
|
||||
const float shift_filt[3][7] = {{-0.011915f, 0.046995f, -0.152373f, 0.614108f, 0.614108f, -0.152373f, 0.046995f},
|
||||
{-0.0324855f, 0.0859768f, -0.2042986f, 0.9640297f, 0.2086420f, -0.0302054f, -0.0063646f},
|
||||
{-0.0063646f, -0.0302054f, 0.2086420f, 0.9640297f, -0.2042986f, 0.0859768f, -0.0324855f}};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int interp_pitch(
|
||||
spx_word16_t *exc, /*decoded excitation*/
|
||||
spx_word16_t *interp, /*decoded excitation*/
|
||||
int pitch, /*pitch period*/
|
||||
int len
|
||||
)
|
||||
{
|
||||
int i,j,k;
|
||||
spx_word32_t corr[4][7];
|
||||
spx_word32_t maxcorr;
|
||||
int maxi, maxj;
|
||||
for (i=0;i<7;i++)
|
||||
{
|
||||
corr[0][i] = inner_prod(exc, exc-pitch-3+i, len);
|
||||
}
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
for (j=0;j<7;j++)
|
||||
{
|
||||
int i1, i2;
|
||||
spx_word32_t tmp=0;
|
||||
i1 = 3-j;
|
||||
if (i1<0)
|
||||
i1 = 0;
|
||||
i2 = 10-j;
|
||||
if (i2>7)
|
||||
i2 = 7;
|
||||
for (k=i1;k<i2;k++)
|
||||
tmp += MULT16_32_Q15(shift_filt[i][k],corr[0][j+k-3]);
|
||||
corr[i+1][j] = tmp;
|
||||
}
|
||||
}
|
||||
maxi=maxj=0;
|
||||
maxcorr = corr[0][0];
|
||||
for (i=0;i<4;i++)
|
||||
{
|
||||
for (j=0;j<7;j++)
|
||||
{
|
||||
if (corr[i][j] > maxcorr)
|
||||
{
|
||||
maxcorr = corr[i][j];
|
||||
maxi=i;
|
||||
maxj=j;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_word32_t tmp = 0;
|
||||
if (maxi>0)
|
||||
{
|
||||
for (k=0;k<7;k++)
|
||||
{
|
||||
tmp += MULT16_16(exc[i-(pitch-maxj+3)+k-3],shift_filt[maxi-1][k]);
|
||||
}
|
||||
} else {
|
||||
tmp = SHL32(exc[i-(pitch-maxj+3)],15);
|
||||
}
|
||||
interp[i] = PSHR32(tmp,15);
|
||||
}
|
||||
return pitch-maxj+3;
|
||||
}
|
||||
|
||||
void multicomb(
|
||||
spx_word16_t *exc, /*decoded excitation*/
|
||||
spx_word16_t *new_exc, /*enhanced excitation*/
|
||||
spx_coef_t *ak, /*LPC filter coefs*/
|
||||
int p, /*LPC order*/
|
||||
int nsf, /*sub-frame size*/
|
||||
int pitch, /*pitch period*/
|
||||
int max_pitch,
|
||||
spx_word16_t comb_gain, /*gain of comb filter*/
|
||||
char *stack
|
||||
)
|
||||
{
|
||||
int i;
|
||||
VARDECL(spx_word16_t *iexc);
|
||||
spx_word16_t old_ener, new_ener;
|
||||
int corr_pitch;
|
||||
|
||||
spx_word16_t iexc0_mag, iexc1_mag, exc_mag;
|
||||
spx_word32_t corr0, corr1;
|
||||
spx_word16_t gain0, gain1;
|
||||
spx_word16_t pgain1, pgain2;
|
||||
spx_word16_t c1, c2;
|
||||
spx_word16_t g1, g2;
|
||||
spx_word16_t ngain;
|
||||
spx_word16_t gg1, gg2;
|
||||
#ifdef FIXED_POINT
|
||||
int scaledown=0;
|
||||
#endif
|
||||
#if 0 /* Set to 1 to enable full pitch search */
|
||||
int nol_pitch[6];
|
||||
spx_word16_t nol_pitch_coef[6];
|
||||
spx_word16_t ol_pitch_coef;
|
||||
open_loop_nbest_pitch(exc, 20, 120, nsf,
|
||||
nol_pitch, nol_pitch_coef, 6, stack);
|
||||
corr_pitch=nol_pitch[0];
|
||||
ol_pitch_coef = nol_pitch_coef[0];
|
||||
/*Try to remove pitch multiples*/
|
||||
for (i=1;i<6;i++)
|
||||
{
|
||||
#ifdef FIXED_POINT
|
||||
if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],19661)) &&
|
||||
#else
|
||||
if ((nol_pitch_coef[i]>.6*nol_pitch_coef[0]) &&
|
||||
#endif
|
||||
(ABS(2*nol_pitch[i]-corr_pitch)<=2 || ABS(3*nol_pitch[i]-corr_pitch)<=3 ||
|
||||
ABS(4*nol_pitch[i]-corr_pitch)<=4 || ABS(5*nol_pitch[i]-corr_pitch)<=5))
|
||||
{
|
||||
corr_pitch = nol_pitch[i];
|
||||
}
|
||||
}
|
||||
#else
|
||||
corr_pitch = pitch;
|
||||
#endif
|
||||
|
||||
ALLOC(iexc, 2*nsf, spx_word16_t);
|
||||
|
||||
interp_pitch(exc, iexc, corr_pitch, 80);
|
||||
if (corr_pitch>max_pitch)
|
||||
interp_pitch(exc, iexc+nsf, 2*corr_pitch, 80);
|
||||
else
|
||||
interp_pitch(exc, iexc+nsf, -corr_pitch, 80);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<nsf;i++)
|
||||
{
|
||||
if (ABS16(exc[i])>16383)
|
||||
{
|
||||
scaledown = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (scaledown)
|
||||
{
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i] = SHR16(exc[i],1);
|
||||
for (i=0;i<2*nsf;i++)
|
||||
iexc[i] = SHR16(iexc[i],1);
|
||||
}
|
||||
#endif
|
||||
/*interp_pitch(exc, iexc+2*nsf, 2*corr_pitch, 80);*/
|
||||
|
||||
/*printf ("%d %d %f\n", pitch, corr_pitch, max_corr*ener_1);*/
|
||||
iexc0_mag = spx_sqrt(1000+inner_prod(iexc,iexc,nsf));
|
||||
iexc1_mag = spx_sqrt(1000+inner_prod(iexc+nsf,iexc+nsf,nsf));
|
||||
exc_mag = spx_sqrt(1+inner_prod(exc,exc,nsf));
|
||||
corr0 = inner_prod(iexc,exc,nsf);
|
||||
if (corr0<0)
|
||||
corr0=0;
|
||||
corr1 = inner_prod(iexc+nsf,exc,nsf);
|
||||
if (corr1<0)
|
||||
corr1=0;
|
||||
#ifdef FIXED_POINT
|
||||
/* Doesn't cost much to limit the ratio and it makes the rest easier */
|
||||
if (SHL32(EXTEND32(iexc0_mag),6) < EXTEND32(exc_mag))
|
||||
iexc0_mag = ADD16(1,PSHR16(exc_mag,6));
|
||||
if (SHL32(EXTEND32(iexc1_mag),6) < EXTEND32(exc_mag))
|
||||
iexc1_mag = ADD16(1,PSHR16(exc_mag,6));
|
||||
#endif
|
||||
if (corr0 > MULT16_16(iexc0_mag,exc_mag))
|
||||
pgain1 = QCONST16(1., 14);
|
||||
else
|
||||
pgain1 = PDIV32_16(SHL32(PDIV32(corr0, exc_mag),14),iexc0_mag);
|
||||
if (corr1 > MULT16_16(iexc1_mag,exc_mag))
|
||||
pgain2 = QCONST16(1., 14);
|
||||
else
|
||||
pgain2 = PDIV32_16(SHL32(PDIV32(corr1, exc_mag),14),iexc1_mag);
|
||||
gg1 = PDIV32_16(SHL32(EXTEND32(exc_mag),8), iexc0_mag);
|
||||
gg2 = PDIV32_16(SHL32(EXTEND32(exc_mag),8), iexc1_mag);
|
||||
if (comb_gain>0)
|
||||
{
|
||||
#ifdef FIXED_POINT
|
||||
c1 = (MULT16_16_Q15(QCONST16(.4,15),comb_gain)+QCONST16(.07,15));
|
||||
c2 = QCONST16(.5,15)+MULT16_16_Q14(QCONST16(1.72,14),(c1-QCONST16(.07,15)));
|
||||
#else
|
||||
c1 = .4*comb_gain+.07;
|
||||
c2 = .5+1.72*(c1-.07);
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
c1=c2=0;
|
||||
}
|
||||
#ifdef FIXED_POINT
|
||||
g1 = 32767 - MULT16_16_Q13(MULT16_16_Q15(c2, pgain1),pgain1);
|
||||
g2 = 32767 - MULT16_16_Q13(MULT16_16_Q15(c2, pgain2),pgain2);
|
||||
#else
|
||||
g1 = 1-c2*pgain1*pgain1;
|
||||
g2 = 1-c2*pgain2*pgain2;
|
||||
#endif
|
||||
if (g1<c1)
|
||||
g1 = c1;
|
||||
if (g2<c1)
|
||||
g2 = c1;
|
||||
g1 = (spx_word16_t)PDIV32_16(SHL32(EXTEND32(c1),14),(spx_word16_t)g1);
|
||||
g2 = (spx_word16_t)PDIV32_16(SHL32(EXTEND32(c1),14),(spx_word16_t)g2);
|
||||
if (corr_pitch>max_pitch)
|
||||
{
|
||||
gain0 = MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q14(g1,gg1));
|
||||
gain1 = MULT16_16_Q15(QCONST16(.3,15),MULT16_16_Q14(g2,gg2));
|
||||
} else {
|
||||
gain0 = MULT16_16_Q15(QCONST16(.6,15),MULT16_16_Q14(g1,gg1));
|
||||
gain1 = MULT16_16_Q15(QCONST16(.6,15),MULT16_16_Q14(g2,gg2));
|
||||
}
|
||||
for (i=0;i<nsf;i++)
|
||||
new_exc[i] = ADD16(exc[i], EXTRACT16(PSHR32(ADD32(MULT16_16(gain0,iexc[i]), MULT16_16(gain1,iexc[i+nsf])),8)));
|
||||
/* FIXME: compute_rms16 is currently not quite accurate enough (but close) */
|
||||
new_ener = compute_rms16(new_exc, nsf);
|
||||
old_ener = compute_rms16(exc, nsf);
|
||||
|
||||
if (old_ener < 1)
|
||||
old_ener = 1;
|
||||
if (new_ener < 1)
|
||||
new_ener = 1;
|
||||
if (old_ener > new_ener)
|
||||
old_ener = new_ener;
|
||||
ngain = PDIV32_16(SHL32(EXTEND32(old_ener),14),new_ener);
|
||||
|
||||
for (i=0;i<nsf;i++)
|
||||
new_exc[i] = MULT16_16_Q14(ngain, new_exc[i]);
|
||||
#ifdef FIXED_POINT
|
||||
if (scaledown)
|
||||
{
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i] = SHL16(exc[i],1);
|
||||
for (i=0;i<nsf;i++)
|
||||
new_exc[i] = SHL16(SATURATE16(new_exc[i],16383),1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file filters.h
|
||||
@brief Various analysis/synthesis filters
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FILTERS_H
|
||||
#define FILTERS_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
spx_word16_t compute_rms(const spx_sig_t *x, int len);
|
||||
spx_word16_t compute_rms16(const spx_word16_t *x, int len);
|
||||
void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
|
||||
void signal_div(const spx_word16_t *x, spx_word16_t *y, spx_word32_t scale, int len);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define HIGHPASS_NARROWBAND 0
|
||||
#define HIGHPASS_WIDEBAND 2
|
||||
#define HIGHPASS_INPUT 0
|
||||
#define HIGHPASS_OUTPUT 1
|
||||
#define HIGHPASS_IRS 4
|
||||
|
||||
void highpass(const spx_word16_t *x, spx_word16_t *y, int len, int filtID, spx_mem_t *mem);
|
||||
|
||||
|
||||
void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack);
|
||||
void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack);
|
||||
|
||||
|
||||
void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
|
||||
void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
|
||||
void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
|
||||
|
||||
void filter_mem16(const spx_word16_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
|
||||
void iir_mem16(const spx_word16_t *x, const spx_coef_t *den, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
|
||||
void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack);
|
||||
|
||||
/* Apply bandwidth expansion on LPC coef */
|
||||
void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
|
||||
|
||||
|
||||
|
||||
void syn_percep_zero(const spx_sig_t *x, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack);
|
||||
|
||||
void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack);
|
||||
|
||||
void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
|
||||
|
||||
void multicomb(
|
||||
spx_word16_t *exc, /*decoded excitation*/
|
||||
spx_word16_t *new_exc, /*enhanced excitation*/
|
||||
spx_coef_t *ak, /*LPC filter coefs*/
|
||||
int p, /*LPC order*/
|
||||
int nsf, /*sub-frame size*/
|
||||
int pitch, /*pitch period*/
|
||||
int max_pitch, /*pitch gain (3-tap)*/
|
||||
spx_word16_t comb_gain, /*gain of comb filter*/
|
||||
char *stack
|
||||
);
|
||||
|
||||
#endif
|
|
@ -1,389 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file filters_arm4.h
|
||||
@brief Various analysis/synthesis filters (ARM4 version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_NORMALIZE16
|
||||
int normalize16(const spx_sig_t *x, spx_word16_t *y, int max_scale, int len)
|
||||
{
|
||||
int i;
|
||||
spx_sig_t max_val=1;
|
||||
int sig_shift;
|
||||
int dead1, dead2, dead3, dead4, dead5, dead6;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"\tmov %1, #1 \n"
|
||||
"\tmov %3, #0 \n"
|
||||
|
||||
".normalize16loop1%=: \n"
|
||||
|
||||
"\tldr %4, [%0], #4 \n"
|
||||
"\tcmps %4, %1 \n"
|
||||
"\tmovgt %1, %4 \n"
|
||||
"\tcmps %4, %3 \n"
|
||||
"\tmovlt %3, %4 \n"
|
||||
|
||||
"\tsubs %2, %2, #1 \n"
|
||||
"\tbne .normalize16loop1%=\n"
|
||||
|
||||
"\trsb %3, %3, #0 \n"
|
||||
"\tcmp %1, %3 \n"
|
||||
"\tmovlt %1, %3 \n"
|
||||
: "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4),
|
||||
"=r" (dead5), "=r" (dead6)
|
||||
: "0" (x), "2" (len)
|
||||
: "cc");
|
||||
|
||||
sig_shift=0;
|
||||
while (max_val>max_scale)
|
||||
{
|
||||
sig_shift++;
|
||||
max_val >>= 1;
|
||||
}
|
||||
|
||||
__asm__ __volatile__ (
|
||||
".normalize16loop%=: \n"
|
||||
|
||||
"\tldr %4, [%0], #4 \n"
|
||||
"\tldr %5, [%0], #4 \n"
|
||||
"\tmov %4, %4, asr %3 \n"
|
||||
"\tstrh %4, [%1], #2 \n"
|
||||
"\tldr %4, [%0], #4 \n"
|
||||
"\tmov %5, %5, asr %3 \n"
|
||||
"\tstrh %5, [%1], #2 \n"
|
||||
"\tldr %5, [%0], #4 \n"
|
||||
"\tmov %4, %4, asr %3 \n"
|
||||
"\tstrh %4, [%1], #2 \n"
|
||||
"\tsubs %2, %2, #1 \n"
|
||||
"\tmov %5, %5, asr %3 \n"
|
||||
"\tstrh %5, [%1], #2 \n"
|
||||
|
||||
"\tbge .normalize16loop%=\n"
|
||||
: "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
|
||||
"=r" (dead5), "=r" (dead6)
|
||||
: "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift)
|
||||
: "cc", "memory");
|
||||
return sig_shift;
|
||||
}
|
||||
|
||||
#define OVERRIDE_FILTER_MEM2
|
||||
void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_sig_t xi,yi,nyi;
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHR32(mem[i],1);
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
int deadm, deadn, deadd, deadidx, x1, y1, dead1, dead2, dead3, dead4, dead5, dead6;
|
||||
xi=SATURATE(x[i],805306368);
|
||||
yi = SATURATE(ADD32(xi, SHL(mem[0],2)),805306368);
|
||||
nyi = -yi;
|
||||
y[i] = yi;
|
||||
__asm__ __volatile__ (
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
#ifdef SHORTCUTS
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
|
||||
#else
|
||||
".filterloop%=: \n"
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tldr %10, [%0, #4]\n"
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tsmull %7, %11, %5, %6\n"
|
||||
"\tadd %8, %8, %9, lsl #17\n"
|
||||
"\tldrsh %6, [%1], #2\n"
|
||||
"\tadd %10, %10, %8\n"
|
||||
"\tsmull %8, %9, %4, %6\n"
|
||||
"\tadd %10, %10, %7, lsr #15\n"
|
||||
"\tsubs %3, %3, #1\n"
|
||||
"\tadd %10, %10, %11, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
"\t bne .filterloop%=\n"
|
||||
#endif
|
||||
"\tmov %8, %8, lsr #15\n"
|
||||
"\tadd %10, %8, %9, lsl #17\n"
|
||||
"\tldrsh %6, [%2], #2\n"
|
||||
"\tsmull %8, %9, %5, %6\n"
|
||||
"\tadd %10, %10, %8, lsr #15\n"
|
||||
"\tadd %10, %10, %9, lsl #17\n"
|
||||
"\tstr %10, [%0], #4 \n"
|
||||
|
||||
: "=r" (deadm), "=r" (deadn), "=r" (deadd), "=r" (deadidx),
|
||||
"=r" (xi), "=r" (nyi), "=r" (dead1), "=r" (dead2),
|
||||
"=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6)
|
||||
: "0" (mem), "1" (num), "2" (den), "3" (ord-1), "4" (xi), "5" (nyi)
|
||||
: "cc", "memory");
|
||||
|
||||
}
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHL32(mem[i],1);
|
||||
}
|
||||
|
||||
#define OVERRIDE_IIR_MEM2
|
||||
void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_sig_t xi,yi,nyi;
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHR32(mem[i],1);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
int deadm, deadd, deadidx, dead1, dead2, dead3, dead4, dead5, dead6;
|
||||
xi=SATURATE(x[i],805306368);
|
||||
yi = SATURATE(ADD32(xi, SHL(mem[0],2)),805306368);
|
||||
nyi = -yi;
|
||||
y[i] = yi;
|
||||
__asm__ __volatile__ (
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
|
||||
#ifdef SHORTCUTS
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %7, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %7, %7, %8\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %9, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %9, %9, %8\n"
|
||||
"\tstr %9, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %7, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %7, %7, %8\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %9, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %9, %9, %8\n"
|
||||
"\tstr %9, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %7, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %7, %7, %8\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %9, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %9, %9, %8\n"
|
||||
"\tstr %9, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %7, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %7, %7, %8\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %9, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %9, %9, %8\n"
|
||||
"\tstr %9, [%0], #4 \n"
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tldr %7, [%0, #4]\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %7, %7, %8\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
|
||||
|
||||
|
||||
#else
|
||||
".iirloop%=: \n"
|
||||
"\tldr %7, [%0, #4]\n"
|
||||
|
||||
"\tldrsh %4, [%1], #2\n"
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tadd %8, %5, %6, lsl #17\n"
|
||||
"\tsmull %5, %6, %3, %4\n"
|
||||
"\tadd %7, %7, %8\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
"\tsubs %2, %2, #1\n"
|
||||
"\t bne .iirloop%=\n"
|
||||
|
||||
#endif
|
||||
"\tmov %5, %5, lsr #15\n"
|
||||
"\tadd %7, %5, %6, lsl #17\n"
|
||||
"\tstr %7, [%0], #4 \n"
|
||||
|
||||
: "=r" (deadm), "=r" (deadd), "=r" (deadidx), "=r" (nyi),
|
||||
"=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
|
||||
"=r" (dead5), "=r" (dead6)
|
||||
: "0" (mem), "1" (den), "2" (ord-1), "3" (nyi)
|
||||
: "cc", "memory");
|
||||
|
||||
}
|
||||
for (i=0;i<ord;i++)
|
||||
mem[i] = SHL32(mem[i],1);
|
||||
|
||||
}
|
|
@ -1,788 +0,0 @@
|
|||
/* Copyright (C) 2005 Analog Devices */
|
||||
/**
|
||||
@file filters_bfin.h
|
||||
@brief Various analysis/synthesis filters (Blackfin version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_NORMALIZE16
|
||||
int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
|
||||
{
|
||||
spx_sig_t max_val=1;
|
||||
int sig_shift;
|
||||
__asm__
|
||||
(
|
||||
"%0 = 0;\n\t"
|
||||
"I0 = %1;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
"R1 = [I0++];\n\t"
|
||||
"LOOP norm_max%= LC0 = %2;\n\t"
|
||||
"LOOP_BEGIN norm_max%=;\n\t"
|
||||
"R2 = ABS R1 || R1 = [I0++];\n\t"
|
||||
"%0 = MAX(%0, R2);\n\t"
|
||||
"LOOP_END norm_max%=;\n\t"
|
||||
: "=&d" (max_val)
|
||||
: "a" (x), "a" (len)
|
||||
: "R1", "R2"
|
||||
);
|
||||
|
||||
sig_shift=0;
|
||||
while (max_val>max_scale)
|
||||
{
|
||||
sig_shift++;
|
||||
max_val >>= 1;
|
||||
}
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"I0 = %0;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
"P1 = %1;\n\t"
|
||||
"R0 = [I0++];\n\t"
|
||||
"LOOP norm_shift%= LC0 = %3;\n\t"
|
||||
"LOOP_BEGIN norm_shift%=;\n\t"
|
||||
"R1 = ASHIFT R0 by %2.L || R0 = [I0++];\n\t"
|
||||
"W[P1++] = R1;\n\t"
|
||||
"LOOP_END norm_shift%=;\n\t"
|
||||
"R1 = ASHIFT R0 by %2.L;\n\t"
|
||||
"W[P1++] = R1;\n\t"
|
||||
: : "a" (x), "a" (y), "d" (-sig_shift), "a" (len-1)
|
||||
: "I0", "L0", "P1", "R0", "R1", "memory"
|
||||
);
|
||||
return sig_shift;
|
||||
}
|
||||
|
||||
#define OVERRIDE_FILTER_MEM2
|
||||
void filter_mem2(const spx_sig_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
spx_word32_t xy2[N+1];
|
||||
spx_word32_t *xy = xy2+1;
|
||||
spx_word32_t numden_a[2*ord+2];
|
||||
spx_word16_t *numden = (spx_word16_t*) numden_a;
|
||||
int i;
|
||||
for (i=0;i<ord;i++)
|
||||
{
|
||||
numden[2*i] = num[i];
|
||||
numden[2*i+1] = den[i];
|
||||
}
|
||||
__asm__ __volatile__
|
||||
(
|
||||
/* Register setup */
|
||||
"R0 = %5;\n\t" /*ord */
|
||||
|
||||
"P0 = %3;\n\t"
|
||||
"I0 = P0;\n\t"
|
||||
"B0 = P0;\n\t" /* numden */
|
||||
"L0 = 0;\n\t"
|
||||
|
||||
"P2 = %0;\n\t" /* Fused xy */
|
||||
"I2 = P2;\n\t"
|
||||
"L2 = 0;\n\t"
|
||||
|
||||
"P4 = %6;\n\t" /* mem */
|
||||
"P0 = %1;\n\t" /* _x */
|
||||
"P1 = %2;\n\t" /* _y */
|
||||
|
||||
/* First sample */
|
||||
"R1 = [P4++];\n\t"
|
||||
"R1 <<= 1;\n\t" /* shift mem */
|
||||
"R2 = [P0++];\n\t" /* load x[0] */
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"[P1++] = R1;\n\t" /* store y[0] */
|
||||
"R1 <<= 2;\n\t"
|
||||
"R2 <<= 2;\n\t"
|
||||
"R2 = PACK(R1.H, R2.H);\n\t" /* pack x16 and y16 */
|
||||
"[P2] = R2;\n\t"
|
||||
|
||||
/* Samples 1 to ord-1 (using memory) */
|
||||
"R0 += -1;\n\t"
|
||||
"R3 = 0;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"LOOP filter_start%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_start%=;\n\t"
|
||||
"R3 += 1;\n\t"
|
||||
"LC1 = R3;\n\t"
|
||||
|
||||
"R1 = [P4++];\n\t"
|
||||
"A1 = R1;\n\t"
|
||||
"A0 = 0;\n\t"
|
||||
"I0 = B0;\n\t"
|
||||
"I2 = P2;\n\t"
|
||||
"P2 += 4;\n\t"
|
||||
"R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP filter_start_inner%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter_start_inner%=;\n\t"
|
||||
"A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP_END filter_start_inner%=;\n\t"
|
||||
"A0 += A1;\n\t"
|
||||
"R4 = A0;\n\t"
|
||||
"R4 <<= 1;\n\t" /* shift mem */
|
||||
"R2 = [P0++];\n\t" /* load x */
|
||||
"R4 = R4 + R2;\n\t"
|
||||
"[P1++] = R4;\n\t" /* store y */
|
||||
"R4 <<= 2;\n\t"
|
||||
"R2 <<= 2;\n\t"
|
||||
"R2 = PACK(R4.H, R2.H);\n\t" /* pack x16 and y16 */
|
||||
"[P2] = R2;\n\t"
|
||||
|
||||
"LOOP_END filter_start%=;\n\t"
|
||||
|
||||
/* Samples ord to N*/
|
||||
"R0 = %5;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"I0 = B0;\n\t" /* numden */
|
||||
"R0 <<= 1;\n\t"
|
||||
"L0 = R0;\n\t"
|
||||
|
||||
"R0 = %5;\n\t" /* org */
|
||||
"R2 = %4;\n\t" /* N */
|
||||
"R2 = R2 - R0;\n\t"
|
||||
"R4 = [I0++];\n\t" /* numden */
|
||||
"LC0 = R2;\n\t"
|
||||
"P3 = R0;\n\t"
|
||||
"R0 <<= 2;\n\t"
|
||||
"R0 += 8;\n\t"
|
||||
"I2 = P2;\n\t"
|
||||
"M0 = R0;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"R5 = [I2--];\n\t" /* load xy */
|
||||
"LOOP filter_mid%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_mid%=;\n\t"
|
||||
"LOOP filter_mid_inner%= LC1=P3;\n\t"
|
||||
"LOOP_BEGIN filter_mid_inner%=;\n\t"
|
||||
"A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP_END filter_mid_inner%=;\n\t"
|
||||
"R0 = (A0 += A1) || I2 += M0;\n\t"
|
||||
"R0 = R0 << 1 || R5 = [P0++];\n\t" /* load x */
|
||||
"R0 = R0 + R5;\n\t"
|
||||
"R0 = R0 << 2 || [P1++] = R0;\n\t" /* shift y | store y */
|
||||
"R5 = R5 << 2;\n\t"
|
||||
"R5 = PACK(R0.H, R5.H);\n\t"
|
||||
"A1 = A0 = 0 || [I2--] = R5\n\t"
|
||||
"LOOP_END filter_mid%=;\n\t"
|
||||
"I2 += 4;\n\t"
|
||||
"P2 = I2;\n\t"
|
||||
/* Update memory */
|
||||
"P4 = %6;\n\t"
|
||||
"R0 = %5;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"P0 = B0;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"LOOP mem_update%= LC0;\n\t"
|
||||
"LOOP_BEGIN mem_update%=;\n\t"
|
||||
"I2 = P2;\n\t"
|
||||
"I0 = P0;\n\t"
|
||||
"P0 += 4;\n\t"
|
||||
"R0 = LC0;\n\t"
|
||||
"LC1 = R0;\n\t"
|
||||
"R5 = [I2--] || R4 = [I0++];\n\t"
|
||||
"LOOP mem_accum%= LC1;\n\t"
|
||||
"LOOP_BEGIN mem_accum%=;\n\t"
|
||||
"A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP_END mem_accum%=;\n\t"
|
||||
"R0 = (A0 += A1);\n\t"
|
||||
"A1 = A0 = 0 || [P4++] = R0;\n\t"
|
||||
"LOOP_END mem_update%=;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
: : "m" (xy), "m" (_x), "m" (_y), "m" (numden), "m" (N), "m" (ord), "m" (mem)
|
||||
: "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B0", "I0", "I2", "L0", "L2", "M0", "memory"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define OVERRIDE_FILTER_MEM16
|
||||
void filter_mem16(const spx_word16_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *_y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
VARDECL(spx_word32_t *xy2);
|
||||
VARDECL(spx_word32_t *numden_a);
|
||||
spx_word32_t *xy;
|
||||
spx_word16_t *numden;
|
||||
int i;
|
||||
|
||||
ALLOC(xy2, (N+1), spx_word32_t);
|
||||
ALLOC(numden_a, (2*ord+2), spx_word32_t);
|
||||
xy = xy2+1;
|
||||
numden = (spx_word16_t*) numden_a;
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
{
|
||||
numden[2*i] = num[i];
|
||||
numden[2*i+1] = den[i];
|
||||
}
|
||||
__asm__ __volatile__
|
||||
(
|
||||
/* Register setup */
|
||||
"R0 = %5;\n\t" /*ord */
|
||||
|
||||
"P0 = %3;\n\t"
|
||||
"I0 = P0;\n\t"
|
||||
"B0 = P0;\n\t" /* numden */
|
||||
"L0 = 0;\n\t"
|
||||
|
||||
"P2 = %0;\n\t" /* Fused xy */
|
||||
"I2 = P2;\n\t"
|
||||
"L2 = 0;\n\t"
|
||||
|
||||
"P4 = %6;\n\t" /* mem */
|
||||
"P0 = %1;\n\t" /* _x */
|
||||
"P1 = %2;\n\t" /* _y */
|
||||
|
||||
/* First sample */
|
||||
"R1 = [P4++];\n\t"
|
||||
"R1 <<= 3;\n\t" /* shift mem */
|
||||
"R1.L = R1 (RND);\n\t"
|
||||
"R2 = W[P0++];\n\t" /* load x[0] */
|
||||
"R1.L = R1.L + R2.L;\n\t"
|
||||
"W[P1++] = R1;\n\t" /* store y[0] */
|
||||
"R2 = PACK(R1.L, R2.L);\n\t" /* pack x16 and y16 */
|
||||
"[P2] = R2;\n\t"
|
||||
|
||||
/* Samples 1 to ord-1 (using memory) */
|
||||
"R0 += -1;\n\t"
|
||||
"R3 = 0;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"LOOP filter_start%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_start%=;\n\t"
|
||||
"R3 += 1;\n\t"
|
||||
"LC1 = R3;\n\t"
|
||||
|
||||
"R1 = [P4++];\n\t"
|
||||
"A1 = R1;\n\t"
|
||||
"A0 = 0;\n\t"
|
||||
"I0 = B0;\n\t"
|
||||
"I2 = P2;\n\t"
|
||||
"P2 += 4;\n\t"
|
||||
"R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP filter_start_inner%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter_start_inner%=;\n\t"
|
||||
"A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP_END filter_start_inner%=;\n\t"
|
||||
"A0 += A1;\n\t"
|
||||
"R4 = A0;\n\t"
|
||||
"R4 <<= 3;\n\t" /* shift mem */
|
||||
"R4.L = R4 (RND);\n\t"
|
||||
"R2 = W[P0++];\n\t" /* load x */
|
||||
"R4.L = R4.L + R2.L;\n\t"
|
||||
"W[P1++] = R4;\n\t" /* store y */
|
||||
//"R4 <<= 2;\n\t"
|
||||
//"R2 <<= 2;\n\t"
|
||||
"R2 = PACK(R4.L, R2.L);\n\t" /* pack x16 and y16 */
|
||||
"[P2] = R2;\n\t"
|
||||
|
||||
"LOOP_END filter_start%=;\n\t"
|
||||
|
||||
/* Samples ord to N*/
|
||||
"R0 = %5;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"I0 = B0;\n\t" /* numden */
|
||||
"R0 <<= 1;\n\t"
|
||||
"L0 = R0;\n\t"
|
||||
|
||||
"R0 = %5;\n\t" /* org */
|
||||
"R2 = %4;\n\t" /* N */
|
||||
"R2 = R2 - R0;\n\t"
|
||||
"R4 = [I0++];\n\t" /* numden */
|
||||
"LC0 = R2;\n\t"
|
||||
"P3 = R0;\n\t"
|
||||
"R0 <<= 2;\n\t"
|
||||
"R0 += 8;\n\t"
|
||||
"I2 = P2;\n\t"
|
||||
"M0 = R0;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"R5 = [I2--];\n\t" /* load xy */
|
||||
"LOOP filter_mid%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_mid%=;\n\t"
|
||||
"LOOP filter_mid_inner%= LC1=P3;\n\t"
|
||||
"LOOP_BEGIN filter_mid_inner%=;\n\t"
|
||||
"A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP_END filter_mid_inner%=;\n\t"
|
||||
"R0 = (A0 += A1) || I2 += M0;\n\t"
|
||||
"R0 = R0 << 3 || R5 = W[P0++];\n\t" /* load x */
|
||||
"R0.L = R0 (RND);\n\t"
|
||||
"R0.L = R0.L + R5.L;\n\t"
|
||||
"R5 = PACK(R0.L, R5.L) || W[P1++] = R0;\n\t" /* shift y | store y */
|
||||
"A1 = A0 = 0 || [I2--] = R5\n\t"
|
||||
"LOOP_END filter_mid%=;\n\t"
|
||||
"I2 += 4;\n\t"
|
||||
"P2 = I2;\n\t"
|
||||
/* Update memory */
|
||||
"P4 = %6;\n\t"
|
||||
"R0 = %5;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"P0 = B0;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"LOOP mem_update%= LC0;\n\t"
|
||||
"LOOP_BEGIN mem_update%=;\n\t"
|
||||
"I2 = P2;\n\t"
|
||||
"I0 = P0;\n\t"
|
||||
"P0 += 4;\n\t"
|
||||
"R0 = LC0;\n\t"
|
||||
"LC1 = R0;\n\t"
|
||||
"R5 = [I2--] || R4 = [I0++];\n\t"
|
||||
"LOOP mem_accum%= LC1;\n\t"
|
||||
"LOOP_BEGIN mem_accum%=;\n\t"
|
||||
"A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
|
||||
"LOOP_END mem_accum%=;\n\t"
|
||||
"R0 = (A0 += A1);\n\t"
|
||||
"A1 = A0 = 0 || [P4++] = R0;\n\t"
|
||||
"LOOP_END mem_update%=;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
: : "m" (xy), "m" (_x), "m" (_y), "m" (numden), "m" (N), "m" (ord), "m" (mem)
|
||||
: "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B0", "I0", "I2", "L0", "L2", "M0", "memory"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define OVERRIDE_IIR_MEM2
|
||||
void iir_mem2(const spx_sig_t *_x, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
spx_word16_t y[N+2];
|
||||
spx_word16_t *yy;
|
||||
yy = y+2;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
/* Register setup */
|
||||
"R0 = %5;\n\t" /*ord */
|
||||
|
||||
"P1 = %3;\n\t"
|
||||
"I1 = P1;\n\t"
|
||||
"B1 = P1;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
|
||||
"P3 = %0;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"L3 = 0;\n\t"
|
||||
|
||||
"P4 = %6;\n\t"
|
||||
"P0 = %1;\n\t"
|
||||
"P1 = %2;\n\t"
|
||||
|
||||
/* First sample */
|
||||
"R1 = [P4++];\n\t"
|
||||
"R1 <<= 1;\n\t"
|
||||
"R2 = [P0++];\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"[P1++] = R1;\n\t"
|
||||
"R1 <<= 2;\n\t"
|
||||
"W[P3] = R1.H;\n\t"
|
||||
"R2 <<= 2;\n\t"
|
||||
|
||||
/* Samples 1 to ord-1 (using memory) */
|
||||
"R0 += -1;\n\t"
|
||||
"R3 = 0;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"LOOP filter_start%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_start%=;\n\t"
|
||||
"R3 += 1;\n\t"
|
||||
"LC1 = R3;\n\t"
|
||||
|
||||
"R1 = [P4++];\n\t"
|
||||
"A1 = R1;\n\t"
|
||||
"I1 = B1;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"P3 += 2;\n\t"
|
||||
"LOOP filter_start_inner%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter_start_inner%=;\n\t"
|
||||
"R4.L = W[I1++];\n\t"
|
||||
"R5.L = W[I3--];\n\t"
|
||||
"A1 -= R4.L*R5.L (IS);\n\t"
|
||||
"LOOP_END filter_start_inner%=;\n\t"
|
||||
|
||||
"R1 = A1;\n\t"
|
||||
"R1 <<= 1;\n\t"
|
||||
"R2 = [P0++];\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"[P1++] = R1;\n\t"
|
||||
"R1 <<= 2;\n\t"
|
||||
"W[P3] = R1.H;\n\t"
|
||||
"R2 <<= 2;\n\t"
|
||||
"LOOP_END filter_start%=;\n\t"
|
||||
|
||||
/* Samples ord to N*/
|
||||
"R0 = %5;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"I1 = B1;\n\t"
|
||||
"L1 = R0;\n\t"
|
||||
|
||||
"R0 = %5;\n\t"
|
||||
"R2 = %4;\n\t"
|
||||
"R2 = R2 - R0;\n\t"
|
||||
"R4.L = W[I1++];\n\t"
|
||||
"LC0 = R2;\n\t"
|
||||
"LOOP filter_mid%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_mid%=;\n\t"
|
||||
"LC1 = R0;\n\t"
|
||||
"A1 = 0;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"P3 += 2;\n\t"
|
||||
"R5.L = W[I3--];\n\t"
|
||||
"LOOP filter_mid_inner%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter_mid_inner%=;\n\t"
|
||||
"A1 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
|
||||
"LOOP_END filter_mid_inner%=;\n\t"
|
||||
"R1 = A1;\n\t"
|
||||
"R1 = R1 << 1 || R2 = [P0++];\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"R1 = R1 << 2 || [P1++] = R1;\n\t"
|
||||
"W[P3] = R1.H;\n\t"
|
||||
"LOOP_END filter_mid%=;\n\t"
|
||||
|
||||
/* Update memory */
|
||||
"P4 = %6;\n\t"
|
||||
"R0 = %5;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"P1 = B1;\n\t"
|
||||
"LOOP mem_update%= LC0;\n\t"
|
||||
"LOOP_BEGIN mem_update%=;\n\t"
|
||||
"A0 = 0;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"I1 = P1;\n\t"
|
||||
"P1 += 2;\n\t"
|
||||
"R0 = LC0;\n\t"
|
||||
"LC1=R0;\n\t"
|
||||
"R5.L = W[I3--] || R4.L = W[I1++];\n\t"
|
||||
"LOOP mem_accum%= LC1;\n\t"
|
||||
"LOOP_BEGIN mem_accum%=;\n\t"
|
||||
"A0 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
|
||||
"LOOP_END mem_accum%=;\n\t"
|
||||
"R0 = A0;\n\t"
|
||||
"[P4++] = R0;\n\t"
|
||||
"LOOP_END mem_update%=;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
: : "m" (yy), "m" (_x), "m" (_y), "m" (den), "m" (N), "m" (ord), "m" (mem)
|
||||
: "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B1", "I1", "I3", "L1", "L3", "memory"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define OVERRIDE_IIR_MEM16
|
||||
void iir_mem16(const spx_word16_t *_x, const spx_coef_t *den, spx_word16_t *_y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
VARDECL(spx_word16_t *y);
|
||||
spx_word16_t *yy;
|
||||
|
||||
ALLOC(y, (N+2), spx_word16_t);
|
||||
yy = y+2;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
/* Register setup */
|
||||
"R0 = %5;\n\t" /*ord */
|
||||
|
||||
"P1 = %3;\n\t"
|
||||
"I1 = P1;\n\t"
|
||||
"B1 = P1;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
|
||||
"P3 = %0;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"L3 = 0;\n\t"
|
||||
|
||||
"P4 = %6;\n\t"
|
||||
"P0 = %1;\n\t"
|
||||
"P1 = %2;\n\t"
|
||||
|
||||
/* First sample */
|
||||
"R1 = [P4++];\n\t"
|
||||
"R1 = R1 << 3 (S);\n\t"
|
||||
"R1.L = R1 (RND);\n\t"
|
||||
"R2 = W[P0++];\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"W[P1++] = R1;\n\t"
|
||||
"W[P3] = R1;\n\t"
|
||||
|
||||
/* Samples 1 to ord-1 (using memory) */
|
||||
"R0 += -1;\n\t"
|
||||
"R3 = 0;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"LOOP filter_start%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_start%=;\n\t"
|
||||
"R3 += 1;\n\t"
|
||||
"LC1 = R3;\n\t"
|
||||
|
||||
"R1 = [P4++];\n\t"
|
||||
"A1 = R1;\n\t"
|
||||
"I1 = B1;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"P3 += 2;\n\t"
|
||||
"LOOP filter_start_inner%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter_start_inner%=;\n\t"
|
||||
"R4.L = W[I1++];\n\t"
|
||||
"R5.L = W[I3--];\n\t"
|
||||
"A1 -= R4.L*R5.L (IS);\n\t"
|
||||
"LOOP_END filter_start_inner%=;\n\t"
|
||||
|
||||
"R1 = A1;\n\t"
|
||||
"R1 <<= 3;\n\t"
|
||||
"R1.L = R1 (RND);\n\t"
|
||||
"R2 = W[P0++];\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"W[P1++] = R1;\n\t"
|
||||
"W[P3] = R1;\n\t"
|
||||
"LOOP_END filter_start%=;\n\t"
|
||||
|
||||
/* Samples ord to N*/
|
||||
"R0 = %5;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"I1 = B1;\n\t"
|
||||
"L1 = R0;\n\t"
|
||||
|
||||
"R0 = %5;\n\t"
|
||||
"R2 = %4;\n\t"
|
||||
"R2 = R2 - R0;\n\t"
|
||||
"R4.L = W[I1++];\n\t"
|
||||
"LC0 = R2;\n\t"
|
||||
"LOOP filter_mid%= LC0;\n\t"
|
||||
"LOOP_BEGIN filter_mid%=;\n\t"
|
||||
"LC1 = R0;\n\t"
|
||||
"A1 = 0;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"P3 += 2;\n\t"
|
||||
"R5.L = W[I3--];\n\t"
|
||||
"LOOP filter_mid_inner%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter_mid_inner%=;\n\t"
|
||||
"A1 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
|
||||
"LOOP_END filter_mid_inner%=;\n\t"
|
||||
"R1 = A1;\n\t"
|
||||
"R1 = R1 << 3 || R2 = W[P0++];\n\t"
|
||||
"R1.L = R1 (RND);\n\t"
|
||||
"R1 = R1 + R2;\n\t"
|
||||
"W[P1++] = R1;\n\t"
|
||||
"W[P3] = R1;\n\t"
|
||||
"LOOP_END filter_mid%=;\n\t"
|
||||
|
||||
/* Update memory */
|
||||
"P4 = %6;\n\t"
|
||||
"R0 = %5;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"P1 = B1;\n\t"
|
||||
"LOOP mem_update%= LC0;\n\t"
|
||||
"LOOP_BEGIN mem_update%=;\n\t"
|
||||
"A0 = 0;\n\t"
|
||||
"I3 = P3;\n\t"
|
||||
"I1 = P1;\n\t"
|
||||
"P1 += 2;\n\t"
|
||||
"R0 = LC0;\n\t"
|
||||
"LC1=R0;\n\t"
|
||||
"R5.L = W[I3--] || R4.L = W[I1++];\n\t"
|
||||
"LOOP mem_accum%= LC1;\n\t"
|
||||
"LOOP_BEGIN mem_accum%=;\n\t"
|
||||
"A0 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
|
||||
"LOOP_END mem_accum%=;\n\t"
|
||||
"R0 = A0;\n\t"
|
||||
"[P4++] = R0;\n\t"
|
||||
"LOOP_END mem_update%=;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
: : "m" (yy), "m" (_x), "m" (_y), "m" (den), "m" (N), "m" (ord), "m" (mem)
|
||||
: "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B1", "I1", "I3", "L1", "L3", "memory"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define OVERRIDE_FIR_MEM2
|
||||
void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i;
|
||||
spx_coef_t den2[12];
|
||||
spx_coef_t *den;
|
||||
den = (spx_coef_t*)((((int)den2)+4)&0xfffffffc);
|
||||
for (i=0;i<10;i++)
|
||||
den[i] = 0;
|
||||
filter_mem2(x, num, den, y, N, ord, mem);
|
||||
}
|
||||
|
||||
#define OVERRIDE_FIR_MEM16
|
||||
void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
|
||||
{
|
||||
int i;
|
||||
spx_coef_t den2[12];
|
||||
spx_coef_t *den;
|
||||
den = (spx_coef_t*)((((int)den2)+4)&0xfffffffc);
|
||||
for (i=0;i<10;i++)
|
||||
den[i] = 0;
|
||||
filter_mem16(x, num, den, y, N, ord, mem, stack);
|
||||
}
|
||||
|
||||
|
||||
#define OVERRIDE_COMPUTE_IMPULSE_RESPONSE
|
||||
void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
|
||||
{
|
||||
int i;
|
||||
VARDECL(spx_word16_t *ytmp);
|
||||
ALLOC(ytmp, N, spx_word16_t);
|
||||
spx_word16_t *ytmp2 = ytmp;
|
||||
y[0] = LPC_SCALING;
|
||||
for (i=0;i<ord;i++)
|
||||
y[i+1] = awk1[i];
|
||||
i++;
|
||||
for (;i<N;i++)
|
||||
y[i] = 0;
|
||||
|
||||
N-=1;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"I0 = %0;\n\t"
|
||||
"I1 = %1;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
"L2 = 0;\n\t"
|
||||
"L3 = 0;\n\t"
|
||||
"R0 = 1;\n\t"
|
||||
"R0 <<= 13;\n\t"
|
||||
"W[I0] = R0.L;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"W[I1] = R0.L;\n\t"
|
||||
"R0 = %5;\n\t"
|
||||
"LC0 = R0;\n\t"
|
||||
"R2 = 0;\n\t"
|
||||
"LOOP samples%= LC0;\n\t"
|
||||
"LOOP_BEGIN samples%=;\n\t"
|
||||
"R2 += 1;\n\t"
|
||||
"R2 = MIN(R2, %4);\n\t"
|
||||
"I0 = %0;\n\t"
|
||||
"I1 = %1;\n\t"
|
||||
"I2 = %2;\n\t"
|
||||
"I3 = %3;\n\t"
|
||||
"%0 += 2;\n\t"
|
||||
"%1 += 2;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"R0.L = W[I0--] || R1.L = W[I2++];\n\t"
|
||||
"LC1 = R2;\n\t"
|
||||
"LOOP filter%= LC1;\n\t"
|
||||
"LOOP_BEGIN filter%=;\n\t"
|
||||
"A0 -= R0.L*R1.L (IS) || R0.L = W[I1--] || R1.L = W[I3++];\n\t"
|
||||
"A1 -= R0.L*R1.L (IS) || R0.L = W[I0--] || R1.L = W[I2++];\n\t"
|
||||
"LOOP_END filter%=;\n\t"
|
||||
"R0 = A0, R1 = A1;\n\t"
|
||||
"R3 = W[%1] (X);\n\t"
|
||||
"R3 <<= 13;\n\t"
|
||||
"R0 = R0 + R3;\n\t"
|
||||
"R3 = R0 >>> 13;\n\t"
|
||||
"W[%0] = R3.L;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"R1 = R1 + R0;\n\t"
|
||||
"R1 >>>= 13;\n\t"
|
||||
"W[%1] = R1.L;\n\t"
|
||||
"LOOP_END samples%=;\n\t"
|
||||
: "=a" (ytmp2), "=a" (y)
|
||||
: "a" (awk2), "a" (ak), "d" (ord), "m" (N), "0" (ytmp2), "1" (y)
|
||||
: "A0", "A1", "R0", "R1", "R2", "R3", "I0", "I1", "I2", "I3", "L0", "L1", "L2", "L3", "A0", "A1"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0 /* Equivalent C function for filter_mem2 and compute_impulse_response */
|
||||
#define min(a,b) ((a)<(b) ? (a):(b))
|
||||
|
||||
void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
VARDECL(spx_word16_t *ytmp);
|
||||
ALLOC(ytmp, N, spx_word16_t);
|
||||
|
||||
y[0] = LPC_SCALING;
|
||||
for (i=0;i<ord;i++)
|
||||
y[i+1] = awk1[i];
|
||||
i++;
|
||||
for (;i<N;i++)
|
||||
y[i] = 0;
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
spx_word32_t yi = SHL32(EXTEND32(y[i]),LPC_SHIFT);
|
||||
spx_word32_t yi2 = 0;
|
||||
for (j=0;j<min(i,ord);j++)
|
||||
{
|
||||
yi = MAC16_16(yi, awk2[j], -ytmp[i-j-1]);
|
||||
yi2 = MAC16_16(yi2, ak[j], -y[i-j-1]);
|
||||
}
|
||||
ytmp[i] = EXTRACT16(SHR32(yi,LPC_SHIFT));
|
||||
yi2 = ADD32(yi2,SHL32(yi,1));
|
||||
y[i] = EXTRACT16(SHR32(yi2,LPC_SHIFT));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void filter_mem2(const spx_sig_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
|
||||
{
|
||||
int i,j;
|
||||
spx_word16_t xi,yi,nyi;
|
||||
spx_word16_t x[N],y[N];
|
||||
spx_word16_t *xx, *yy;
|
||||
xx = x;
|
||||
yy = y;
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
x[i] = EXTRACT16(SHR32(_x[i],SIG_SHIFT));
|
||||
}
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
{
|
||||
spx_word32_t yi = mem[i];
|
||||
for (j=0;j<i;j++)
|
||||
{
|
||||
yi = MAC16_16(yi, num[j], x[i-j-1]);
|
||||
yi = MAC16_16(yi, den[j], -y[i-j-1]);
|
||||
}
|
||||
_y[i] = ADD32(_x[i],SHL32(yi,1));
|
||||
y[i] = EXTRACT16(SHR32(_y[i],SIG_SHIFT));
|
||||
}
|
||||
for (i=ord;i<N;i++)
|
||||
{
|
||||
spx_word32_t yi = 0;
|
||||
for (j=0;j<ord;j++)
|
||||
{
|
||||
yi = MAC16_16(yi, num[j], x[i-j-1]);
|
||||
yi = MAC16_16(yi, den[j], -y[i-j-1]);
|
||||
}
|
||||
_y[i] = ADD32(_x[i],SHL32(yi,1));
|
||||
y[i] = EXTRACT16(SHR32(_y[i],SIG_SHIFT));
|
||||
}
|
||||
|
||||
for (i=0;i<ord;i++)
|
||||
{
|
||||
spx_mem_t m = 0;
|
||||
for (j=0;j<ord-i;j++)
|
||||
{
|
||||
m = MAC16_16(m, x[N-1-j], num[j+i]);
|
||||
m = MAC16_16(m, -y[N-1-j], den[j+i]);
|
||||
}
|
||||
mem[i] = m;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,336 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file filters_sse.h
|
||||
@brief Various analysis/synthesis filters (SSE version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
void filter_mem2_10(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
__m128 num[3], den[3], mem[3];
|
||||
|
||||
int i;
|
||||
|
||||
/* Copy numerator, denominator and memory to aligned xmm */
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
mem[i] = _mm_loadu_ps(_mem+4*i);
|
||||
num[i] = _mm_loadu_ps(_num+4*i);
|
||||
den[i] = _mm_loadu_ps(_den+4*i);
|
||||
}
|
||||
mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
|
||||
num[2] = _mm_setr_ps(_num[8], _num[9], 0, 0);
|
||||
den[2] = _mm_setr_ps(_den[8], _den[9], 0, 0);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
__m128 xx;
|
||||
__m128 yy;
|
||||
/* Compute next filter result */
|
||||
xx = _mm_load_ps1(x+i);
|
||||
yy = _mm_add_ss(xx, mem[0]);
|
||||
_mm_store_ss(y+i, yy);
|
||||
yy = _mm_shuffle_ps(yy, yy, 0);
|
||||
|
||||
/* Update memory */
|
||||
mem[0] = _mm_move_ss(mem[0], mem[1]);
|
||||
mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
|
||||
|
||||
mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
|
||||
mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
|
||||
|
||||
mem[1] = _mm_move_ss(mem[1], mem[2]);
|
||||
mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
|
||||
|
||||
mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
|
||||
mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
|
||||
|
||||
mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0xfd);
|
||||
|
||||
mem[2] = _mm_add_ps(mem[2], _mm_mul_ps(xx, num[2]));
|
||||
mem[2] = _mm_sub_ps(mem[2], _mm_mul_ps(yy, den[2]));
|
||||
}
|
||||
/* Put memory back in its place */
|
||||
_mm_storeu_ps(_mem, mem[0]);
|
||||
_mm_storeu_ps(_mem+4, mem[1]);
|
||||
_mm_store_ss(_mem+8, mem[2]);
|
||||
mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0x55);
|
||||
_mm_store_ss(_mem+9, mem[2]);
|
||||
}
|
||||
|
||||
void filter_mem2_8(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
__m128 num[2], den[2], mem[2];
|
||||
|
||||
int i;
|
||||
|
||||
/* Copy numerator, denominator and memory to aligned xmm */
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
mem[i] = _mm_loadu_ps(_mem+4*i);
|
||||
num[i] = _mm_loadu_ps(_num+4*i);
|
||||
den[i] = _mm_loadu_ps(_den+4*i);
|
||||
}
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
__m128 xx;
|
||||
__m128 yy;
|
||||
/* Compute next filter result */
|
||||
xx = _mm_load_ps1(x+i);
|
||||
yy = _mm_add_ss(xx, mem[0]);
|
||||
_mm_store_ss(y+i, yy);
|
||||
yy = _mm_shuffle_ps(yy, yy, 0);
|
||||
|
||||
/* Update memory */
|
||||
mem[0] = _mm_move_ss(mem[0], mem[1]);
|
||||
mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
|
||||
|
||||
mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
|
||||
mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
|
||||
|
||||
mem[1] = _mm_sub_ss(mem[1], mem[1]);
|
||||
mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
|
||||
|
||||
mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
|
||||
mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
|
||||
}
|
||||
/* Put memory back in its place */
|
||||
_mm_storeu_ps(_mem, mem[0]);
|
||||
_mm_storeu_ps(_mem+4, mem[1]);
|
||||
}
|
||||
|
||||
|
||||
#define OVERRIDE_FILTER_MEM2
|
||||
void filter_mem2(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
if(ord==10)
|
||||
filter_mem2_10(x, _num, _den, y, N, ord, _mem);
|
||||
else if (ord==8)
|
||||
filter_mem2_8(x, _num, _den, y, N, ord, _mem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void iir_mem2_10(const float *x, const float *_den, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
__m128 den[3], mem[3];
|
||||
|
||||
int i;
|
||||
|
||||
/* Copy numerator, denominator and memory to aligned xmm */
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
mem[i] = _mm_loadu_ps(_mem+4*i);
|
||||
den[i] = _mm_loadu_ps(_den+4*i);
|
||||
}
|
||||
mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
|
||||
den[2] = _mm_setr_ps(_den[8], _den[9], 0, 0);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
__m128 xx;
|
||||
__m128 yy;
|
||||
/* Compute next filter result */
|
||||
xx = _mm_load_ps1(x+i);
|
||||
yy = _mm_add_ss(xx, mem[0]);
|
||||
_mm_store_ss(y+i, yy);
|
||||
yy = _mm_shuffle_ps(yy, yy, 0);
|
||||
|
||||
/* Update memory */
|
||||
mem[0] = _mm_move_ss(mem[0], mem[1]);
|
||||
mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
|
||||
|
||||
mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
|
||||
|
||||
mem[1] = _mm_move_ss(mem[1], mem[2]);
|
||||
mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
|
||||
|
||||
mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
|
||||
|
||||
mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0xfd);
|
||||
|
||||
mem[2] = _mm_sub_ps(mem[2], _mm_mul_ps(yy, den[2]));
|
||||
}
|
||||
/* Put memory back in its place */
|
||||
_mm_storeu_ps(_mem, mem[0]);
|
||||
_mm_storeu_ps(_mem+4, mem[1]);
|
||||
_mm_store_ss(_mem+8, mem[2]);
|
||||
mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0x55);
|
||||
_mm_store_ss(_mem+9, mem[2]);
|
||||
}
|
||||
|
||||
|
||||
void iir_mem2_8(const float *x, const float *_den, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
__m128 den[2], mem[2];
|
||||
|
||||
int i;
|
||||
|
||||
/* Copy numerator, denominator and memory to aligned xmm */
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
mem[i] = _mm_loadu_ps(_mem+4*i);
|
||||
den[i] = _mm_loadu_ps(_den+4*i);
|
||||
}
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
__m128 xx;
|
||||
__m128 yy;
|
||||
/* Compute next filter result */
|
||||
xx = _mm_load_ps1(x+i);
|
||||
yy = _mm_add_ss(xx, mem[0]);
|
||||
_mm_store_ss(y+i, yy);
|
||||
yy = _mm_shuffle_ps(yy, yy, 0);
|
||||
|
||||
/* Update memory */
|
||||
mem[0] = _mm_move_ss(mem[0], mem[1]);
|
||||
mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
|
||||
|
||||
mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
|
||||
|
||||
mem[1] = _mm_sub_ss(mem[1], mem[1]);
|
||||
mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
|
||||
|
||||
mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
|
||||
}
|
||||
/* Put memory back in its place */
|
||||
_mm_storeu_ps(_mem, mem[0]);
|
||||
_mm_storeu_ps(_mem+4, mem[1]);
|
||||
}
|
||||
|
||||
#define OVERRIDE_IIR_MEM2
|
||||
void iir_mem2(const float *x, const float *_den, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
if(ord==10)
|
||||
iir_mem2_10(x, _den, y, N, ord, _mem);
|
||||
else if (ord==8)
|
||||
iir_mem2_8(x, _den, y, N, ord, _mem);
|
||||
}
|
||||
|
||||
|
||||
void fir_mem2_10(const float *x, const float *_num, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
__m128 num[3], mem[3];
|
||||
|
||||
int i;
|
||||
|
||||
/* Copy numerator, denominator and memory to aligned xmm */
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
mem[i] = _mm_loadu_ps(_mem+4*i);
|
||||
num[i] = _mm_loadu_ps(_num+4*i);
|
||||
}
|
||||
mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
|
||||
num[2] = _mm_setr_ps(_num[8], _num[9], 0, 0);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
__m128 xx;
|
||||
__m128 yy;
|
||||
/* Compute next filter result */
|
||||
xx = _mm_load_ps1(x+i);
|
||||
yy = _mm_add_ss(xx, mem[0]);
|
||||
_mm_store_ss(y+i, yy);
|
||||
yy = _mm_shuffle_ps(yy, yy, 0);
|
||||
|
||||
/* Update memory */
|
||||
mem[0] = _mm_move_ss(mem[0], mem[1]);
|
||||
mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
|
||||
|
||||
mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
|
||||
|
||||
mem[1] = _mm_move_ss(mem[1], mem[2]);
|
||||
mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
|
||||
|
||||
mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
|
||||
|
||||
mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0xfd);
|
||||
|
||||
mem[2] = _mm_add_ps(mem[2], _mm_mul_ps(xx, num[2]));
|
||||
}
|
||||
/* Put memory back in its place */
|
||||
_mm_storeu_ps(_mem, mem[0]);
|
||||
_mm_storeu_ps(_mem+4, mem[1]);
|
||||
_mm_store_ss(_mem+8, mem[2]);
|
||||
mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0x55);
|
||||
_mm_store_ss(_mem+9, mem[2]);
|
||||
}
|
||||
|
||||
void fir_mem2_8(const float *x, const float *_num, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
__m128 num[2], mem[2];
|
||||
|
||||
int i;
|
||||
|
||||
/* Copy numerator, denominator and memory to aligned xmm */
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
mem[i] = _mm_loadu_ps(_mem+4*i);
|
||||
num[i] = _mm_loadu_ps(_num+4*i);
|
||||
}
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
__m128 xx;
|
||||
__m128 yy;
|
||||
/* Compute next filter result */
|
||||
xx = _mm_load_ps1(x+i);
|
||||
yy = _mm_add_ss(xx, mem[0]);
|
||||
_mm_store_ss(y+i, yy);
|
||||
yy = _mm_shuffle_ps(yy, yy, 0);
|
||||
|
||||
/* Update memory */
|
||||
mem[0] = _mm_move_ss(mem[0], mem[1]);
|
||||
mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
|
||||
|
||||
mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
|
||||
|
||||
mem[1] = _mm_sub_ss(mem[1], mem[1]);
|
||||
mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
|
||||
|
||||
mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
|
||||
}
|
||||
/* Put memory back in its place */
|
||||
_mm_storeu_ps(_mem, mem[0]);
|
||||
_mm_storeu_ps(_mem+4, mem[1]);
|
||||
}
|
||||
|
||||
#define OVERRIDE_FIR_MEM2
|
||||
void fir_mem2(const float *x, const float *_num, float *y, int N, int ord, float *_mem)
|
||||
{
|
||||
if(ord==10)
|
||||
fir_mem2_10(x, _num, y, N, ord, _mem);
|
||||
else if (ord==8)
|
||||
fir_mem2_8(x, _num, y, N, ord, _mem);
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_arm4.h
|
||||
@brief ARM4 fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_ARM4_H
|
||||
#define FIXED_ARM4_H
|
||||
|
||||
#undef MULT16_32_Q14
|
||||
static inline spx_word32_t MULT16_32_Q14(spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
int dummy;
|
||||
asm (
|
||||
"smull %0,%1,%2,%3 \n\t"
|
||||
"mov %0, %0, lsr #14 \n\t"
|
||||
"add %0, %0, %1, lsl #18 \n\t"
|
||||
: "=&r"(res), "=&r" (dummy)
|
||||
: "r"(y),"r"((int)x));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q15
|
||||
static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
int dummy;
|
||||
asm (
|
||||
"smull %0,%1,%2,%3 \n\t"
|
||||
"mov %0, %0, lsr #15 \n\t"
|
||||
"add %0, %0, %1, lsl #17 \n\t"
|
||||
: "=&r"(res), "=&r" (dummy)
|
||||
: "r"(y),"r"((int)x));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef DIV32_16
|
||||
static inline short DIV32_16(int a, int b)
|
||||
{
|
||||
int res=0;
|
||||
int dead1, dead2, dead3, dead4, dead5;
|
||||
__asm__ __volatile__ (
|
||||
"\teor %5, %0, %1\n"
|
||||
"\tmovs %4, %0\n"
|
||||
"\trsbmi %0, %0, #0 \n"
|
||||
"\tmovs %4, %1\n"
|
||||
"\trsbmi %1, %1, #0 \n"
|
||||
"\tmov %4, #1\n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #14 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #14 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #13 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #13 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #12 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #12 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #11 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #11 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #10 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #10 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #9 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #9 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #8 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #8 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #7 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #7 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #6 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #6 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #5 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #5 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #4 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #4 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #3 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #2 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #2 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #1 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4, asl #1 \n"
|
||||
|
||||
"\tsubs %3, %0, %1 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
"\torrpl %2, %2, %4 \n"
|
||||
|
||||
"\tmovs %5, %5, lsr #31 \n"
|
||||
"\trsbne %2, %2, #0 \n"
|
||||
: "=r" (dead1), "=r" (dead2), "=r" (res),
|
||||
"=r" (dead3), "=r" (dead4), "=r" (dead5)
|
||||
: "0" (a), "1" (b), "2" (res)
|
||||
: "cc"
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -1,178 +0,0 @@
|
|||
/* Copyright (C) 2003 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_arm5e.h
|
||||
@brief ARM-tuned fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_ARM5E_H
|
||||
#define FIXED_ARM5E_H
|
||||
|
||||
#undef MULT16_16
|
||||
static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) {
|
||||
int res;
|
||||
asm ("smulbb %0,%1,%2;\n"
|
||||
: "=&r"(res)
|
||||
: "%r"(x),"r"(y));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef MAC16_16
|
||||
static inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
asm ("smlabb %0,%1,%2,%3;\n"
|
||||
: "=&r"(res)
|
||||
: "%r"(x),"r"(y),"r"(a));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q15
|
||||
static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
asm ("smulwb %0,%1,%2;\n"
|
||||
: "=&r"(res)
|
||||
: "%r"(y<<1),"r"(x));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q15
|
||||
static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
asm ("smlawb %0,%1,%2,%3;\n"
|
||||
: "=&r"(res)
|
||||
: "%r"(y<<1),"r"(x),"r"(a));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q11
|
||||
static inline spx_word32_t MULT16_32_Q11(spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
asm ("smulwb %0,%1,%2;\n"
|
||||
: "=&r"(res)
|
||||
: "%r"(y<<5),"r"(x));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q11
|
||||
static inline spx_word32_t MAC16_32_Q11(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
|
||||
int res;
|
||||
asm ("smlawb %0,%1,%2,%3;\n"
|
||||
: "=&r"(res)
|
||||
: "%r"(y<<5),"r"(x),"r"(a));
|
||||
return(res);
|
||||
}
|
||||
|
||||
#undef DIV32_16
|
||||
static inline short DIV32_16(int a, int b)
|
||||
{
|
||||
int res=0;
|
||||
int dead1, dead2, dead3, dead4, dead5;
|
||||
__asm__ __volatile__ (
|
||||
"\teor %5, %0, %1\n"
|
||||
"\tmovs %4, %0\n"
|
||||
"\trsbmi %0, %0, #0 \n"
|
||||
"\tmovs %4, %1\n"
|
||||
"\trsbmi %1, %1, #0 \n"
|
||||
"\tmov %4, #1\n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #14 \n"
|
||||
"\torrpl %2, %2, %4, asl #14 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #13 \n"
|
||||
"\torrpl %2, %2, %4, asl #13 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #12 \n"
|
||||
"\torrpl %2, %2, %4, asl #12 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #11 \n"
|
||||
"\torrpl %2, %2, %4, asl #11 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #10 \n"
|
||||
"\torrpl %2, %2, %4, asl #10 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #9 \n"
|
||||
"\torrpl %2, %2, %4, asl #9 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #8 \n"
|
||||
"\torrpl %2, %2, %4, asl #8 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #7 \n"
|
||||
"\torrpl %2, %2, %4, asl #7 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #6 \n"
|
||||
"\torrpl %2, %2, %4, asl #6 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #5 \n"
|
||||
"\torrpl %2, %2, %4, asl #5 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #4 \n"
|
||||
"\torrpl %2, %2, %4, asl #4 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #3 \n"
|
||||
"\torrpl %2, %2, %4, asl #3 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #2 \n"
|
||||
"\torrpl %2, %2, %4, asl #2 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1, asl #1 \n"
|
||||
"\torrpl %2, %2, %4, asl #1 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tsubs %3, %0, %1 \n"
|
||||
"\torrpl %2, %2, %4 \n"
|
||||
"\tmovpl %0, %3 \n"
|
||||
|
||||
"\tmovs %5, %5, lsr #31 \n"
|
||||
"\trsbne %2, %2, #0 \n"
|
||||
: "=r" (dead1), "=r" (dead2), "=r" (res),
|
||||
"=r" (dead3), "=r" (dead4), "=r" (dead5)
|
||||
: "0" (a), "1" (b), "2" (res)
|
||||
: "memory", "cc"
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,173 +0,0 @@
|
|||
/* Copyright (C) 2005 Analog Devices
|
||||
Author: Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_bfin.h
|
||||
@brief Blackfin fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_BFIN_H
|
||||
#define FIXED_BFIN_H
|
||||
|
||||
#undef PDIV32_16
|
||||
static inline spx_word16_t PDIV32_16(spx_word32_t a, spx_word16_t b)
|
||||
{
|
||||
spx_word32_t res, bb;
|
||||
bb = b;
|
||||
a += b>>1;
|
||||
__asm__ (
|
||||
"P0 = 15;\n\t"
|
||||
"R0 = %1;\n\t"
|
||||
"R1 = %2;\n\t"
|
||||
//"R0 = R0 + R1;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"DIVS (R0, R1);\n\t"
|
||||
"LOOP divide%= LC0 = P0;\n\t"
|
||||
"LOOP_BEGIN divide%=;\n\t"
|
||||
"DIVQ (R0, R1);\n\t"
|
||||
"LOOP_END divide%=;\n\t"
|
||||
"R0 = R0.L;\n\t"
|
||||
"%0 = R0;\n\t"
|
||||
: "=m" (res)
|
||||
: "m" (a), "m" (bb)
|
||||
: "P0", "R0", "R1", "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef DIV32_16
|
||||
static inline spx_word16_t DIV32_16(spx_word32_t a, spx_word16_t b)
|
||||
{
|
||||
spx_word32_t res, bb;
|
||||
bb = b;
|
||||
/* Make the roundinf consistent with the C version
|
||||
(do we need to do that?)*/
|
||||
if (a<0)
|
||||
a += (b-1);
|
||||
__asm__ (
|
||||
"P0 = 15;\n\t"
|
||||
"R0 = %1;\n\t"
|
||||
"R1 = %2;\n\t"
|
||||
"R0 <<= 1;\n\t"
|
||||
"DIVS (R0, R1);\n\t"
|
||||
"LOOP divide%= LC0 = P0;\n\t"
|
||||
"LOOP_BEGIN divide%=;\n\t"
|
||||
"DIVQ (R0, R1);\n\t"
|
||||
"LOOP_END divide%=;\n\t"
|
||||
"R0 = R0.L;\n\t"
|
||||
"%0 = R0;\n\t"
|
||||
: "=m" (res)
|
||||
: "m" (a), "m" (bb)
|
||||
: "P0", "R0", "R1", "cc");
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MAX16
|
||||
static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__ (
|
||||
"%1 = %1.L (X);\n\t"
|
||||
"%2 = %2.L (X);\n\t"
|
||||
"%0 = MAX(%1,%2);"
|
||||
: "=d" (res)
|
||||
: "%d" (a), "d" (b)
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q15
|
||||
static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__
|
||||
(
|
||||
"A1 = %2.L*%1.L (M);\n\t"
|
||||
"A1 = A1 >>> 15;\n\t"
|
||||
"%0 = (A1 += %2.L*%1.H) ;\n\t"
|
||||
: "=&W" (res), "=&d" (b)
|
||||
: "d" (a), "1" (b)
|
||||
: "A1"
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q15
|
||||
static inline spx_word32_t MAC16_32_Q15(spx_word32_t c, spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__
|
||||
(
|
||||
"A1 = %2.L*%1.L (M);\n\t"
|
||||
"A1 = A1 >>> 15;\n\t"
|
||||
"%0 = (A1 += %2.L*%1.H);\n\t"
|
||||
"%0 = %0 + %4;\n\t"
|
||||
: "=&W" (res), "=&d" (b)
|
||||
: "d" (a), "1" (b), "d" (c)
|
||||
: "A1"
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MULT16_32_Q14
|
||||
static inline spx_word32_t MULT16_32_Q14(spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__
|
||||
(
|
||||
"%2 <<= 1;\n\t"
|
||||
"A1 = %1.L*%2.L (M);\n\t"
|
||||
"A1 = A1 >>> 15;\n\t"
|
||||
"%0 = (A1 += %1.L*%2.H);\n\t"
|
||||
: "=W" (res), "=d" (a), "=d" (b)
|
||||
: "1" (a), "2" (b)
|
||||
: "A1"
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef MAC16_32_Q14
|
||||
static inline spx_word32_t MAC16_32_Q14(spx_word32_t c, spx_word16_t a, spx_word32_t b)
|
||||
{
|
||||
spx_word32_t res;
|
||||
__asm__
|
||||
(
|
||||
"%1 <<= 1;\n\t"
|
||||
"A1 = %2.L*%1.L (M);\n\t"
|
||||
"A1 = A1 >>> 15;\n\t"
|
||||
"%0 = (A1 += %2.L*%1.H);\n\t"
|
||||
"%0 = %0 + %4;\n\t"
|
||||
: "=&W" (res), "=&d" (b)
|
||||
: "d" (a), "1" (b), "d" (c)
|
||||
: "A1"
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,475 +0,0 @@
|
|||
/* Copyright (C) 2003 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_debug.h
|
||||
@brief Fixed-point operations with debugging
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_DEBUG_H
|
||||
#define FIXED_DEBUG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern long long spx_mips;
|
||||
#define MIPS_INC spx_mips++,
|
||||
|
||||
#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
|
||||
#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
|
||||
|
||||
|
||||
#define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768)
|
||||
#define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL)
|
||||
|
||||
static inline short NEG16(int x)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(x))
|
||||
{
|
||||
fprintf (stderr, "NEG16: input is not short: %d\n", (int)x);
|
||||
}
|
||||
res = -x;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "NEG16: output is not short: %d\n", (int)res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
static inline int NEG32(long long x)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT(x))
|
||||
{
|
||||
fprintf (stderr, "NEG16: input is not int: %d\n", (int)x);
|
||||
}
|
||||
res = -x;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "NEG16: output is not int: %d\n", (int)res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short EXTRACT16(int x)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(x))
|
||||
{
|
||||
fprintf (stderr, "EXTRACT16: input is not short: %d\n", x);
|
||||
}
|
||||
res = x;
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int EXTEND32(int x)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(x))
|
||||
{
|
||||
fprintf (stderr, "EXTEND32: input is not short: %d\n", x);
|
||||
}
|
||||
res = x;
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short SHR16(int a, int shift)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
|
||||
{
|
||||
fprintf (stderr, "SHR16: inputs are not short: %d %d\n", a, shift);
|
||||
}
|
||||
res = a>>shift;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "SHR16: output is not short: %d\n", res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
static inline short SHL16(int a, int shift)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
|
||||
{
|
||||
fprintf (stderr, "SHL16: inputs are not short: %d %d\n", a, shift);
|
||||
}
|
||||
res = a<<shift;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "SHL16: output is not short: %d\n", res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int SHR32(long long a, int shift)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
|
||||
{
|
||||
fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift);
|
||||
}
|
||||
res = a>>shift;
|
||||
if (!VERIFY_INT(res))
|
||||
{
|
||||
fprintf (stderr, "SHR32: output is not int: %d\n", (int)res);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
static inline int SHL32(long long a, int shift)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
|
||||
{
|
||||
fprintf (stderr, "SHL32: inputs are not int: %d %d\n", (int)a, shift);
|
||||
}
|
||||
res = a<<shift;
|
||||
if (!VERIFY_INT(res))
|
||||
{
|
||||
fprintf (stderr, "SHL32: output is not int: %d\n", (int)res);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift))
|
||||
#define PSHR32(a,shift) (SHR32((a)+((1<<((shift))>>1)),shift))
|
||||
#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
|
||||
|
||||
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
|
||||
#define SHR(a,shift) ((a) >> (shift))
|
||||
#define SHL(a,shift) ((a) << (shift))
|
||||
|
||||
static inline short ADD16(int a, int b)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "ADD16: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = a+b;
|
||||
if (!VERIFY_SHORT(res))
|
||||
{
|
||||
fprintf (stderr, "ADD16: output is not short: %d+%d=%d\n", a,b,res);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
static inline short SUB16(int a, int b)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "SUB16: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = a-b;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "SUB16: output is not short: %d\n", res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int ADD32(long long a, long long b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT(a) || !VERIFY_INT(b))
|
||||
{
|
||||
fprintf (stderr, "ADD32: inputs are not int: %d %d\n", (int)a, (int)b);
|
||||
}
|
||||
res = a+b;
|
||||
if (!VERIFY_INT(res))
|
||||
{
|
||||
fprintf (stderr, "ADD32: output is not int: %d\n", (int)res);
|
||||
}
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int SUB32(long long a, long long b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_INT(a) || !VERIFY_INT(b))
|
||||
{
|
||||
fprintf (stderr, "SUB32: inputs are not int: %d %d\n", (int)a, (int)b);
|
||||
}
|
||||
res = a-b;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "SUB32: output is not int: %d\n", (int)res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define ADD64(a,b) (MIPS_INC(a)+(b))
|
||||
|
||||
#define PSHR(a,shift) (SHR((a)+((1<<((shift))>>1)),shift))
|
||||
/* result fits in 16 bits */
|
||||
static inline short MULT16_16_16(int a, int b)
|
||||
{
|
||||
int res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_16: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = a*b;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "MULT16_16_16: output is not short: %d\n", res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int MULT16_16(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_16: output is not int: %d\n", (int)res);
|
||||
spx_mips++;
|
||||
return res;
|
||||
}
|
||||
|
||||
#define MAC16_16(c,a,b) (spx_mips--,ADD32((c),MULT16_16((a),(b))))
|
||||
#define MAC16_16_Q11(c,a,b) (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11))))
|
||||
#define MAC16_16_Q13(c,a,b) (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13))))
|
||||
#define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13)))
|
||||
|
||||
|
||||
static inline int MULT16_32_QX(int a, long long b, int Q)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b);
|
||||
}
|
||||
if (ABS32(b)>=(1<<(15+Q)))
|
||||
fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b);
|
||||
res = (((long long)a)*(long long)b) >> Q;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res);
|
||||
spx_mips+=5;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int MULT16_32_PX(int a, long long b, int Q)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b);
|
||||
}
|
||||
if (ABS32(b)>=(1<<(15+Q)))
|
||||
fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b);
|
||||
res = ((((long long)a)*(long long)b) + ((1<<Q)>>1))>> Q;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res);
|
||||
spx_mips+=5;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11)
|
||||
#define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b)))
|
||||
#define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12)
|
||||
#define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13)
|
||||
#define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14)
|
||||
#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15)
|
||||
#define MULT16_32_P15(a,b) MULT16_32_PX(a,b,15)
|
||||
#define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b)))
|
||||
|
||||
static inline int SATURATE(int a, int b)
|
||||
{
|
||||
if (a>b)
|
||||
a=b;
|
||||
if (a<-b)
|
||||
a = -b;
|
||||
return a;
|
||||
}
|
||||
|
||||
static inline int MULT16_16_Q11_32(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res >>= 11;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res);
|
||||
spx_mips+=3;
|
||||
return res;
|
||||
}
|
||||
static inline short MULT16_16_Q13(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res >>= 13;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res);
|
||||
spx_mips+=3;
|
||||
return res;
|
||||
}
|
||||
static inline short MULT16_16_Q14(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res >>= 14;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res);
|
||||
spx_mips+=3;
|
||||
return res;
|
||||
}
|
||||
static inline short MULT16_16_Q15(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res >>= 15;
|
||||
if (!VERIFY_SHORT(res))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res);
|
||||
}
|
||||
spx_mips+=3;
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline short MULT16_16_P13(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res += 4096;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int)res);
|
||||
res >>= 13;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res);
|
||||
spx_mips+=4;
|
||||
return res;
|
||||
}
|
||||
static inline short MULT16_16_P14(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res += 8192;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int)res);
|
||||
res >>= 14;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res);
|
||||
spx_mips+=4;
|
||||
return res;
|
||||
}
|
||||
static inline short MULT16_16_P15(int a, int b)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res += 16384;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int)res);
|
||||
res >>= 15;
|
||||
if (!VERIFY_SHORT(res))
|
||||
fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res);
|
||||
spx_mips+=4;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
static inline int DIV32_16(long long a, long long b)
|
||||
{
|
||||
long long res;
|
||||
if (b==0)
|
||||
{
|
||||
fprintf(stderr, "DIV32_16: divide by zero: %d/%d\n", (int)a, (int)b);
|
||||
return 0;
|
||||
}
|
||||
if (!VERIFY_INT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d\n", (int)a, (int)b);
|
||||
}
|
||||
res = a/b;
|
||||
if (!VERIFY_SHORT(res))
|
||||
{
|
||||
fprintf (stderr, "DIV32_16: output is not short: %d / %d = %d\n", (int)a,(int)b,(int)res);
|
||||
if (res>32767)
|
||||
res = 32767;
|
||||
if (res<-32768)
|
||||
res = -32768;
|
||||
}
|
||||
spx_mips+=20;
|
||||
return res;
|
||||
}
|
||||
static inline int DIV32(long long a, long long b)
|
||||
{
|
||||
long long res;
|
||||
if (b==0)
|
||||
{
|
||||
fprintf(stderr, "DIV32: divide by zero: %d/%d\n", (int)a, (int)b);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!VERIFY_INT(a) || !VERIFY_INT(b))
|
||||
{
|
||||
fprintf (stderr, "DIV32: inputs are not int/short: %d %d\n", (int)a, (int)b);
|
||||
}
|
||||
res = a/b;
|
||||
if (!VERIFY_INT(res))
|
||||
fprintf (stderr, "DIV32: output is not int: %d\n", (int)res);
|
||||
spx_mips+=36;
|
||||
return res;
|
||||
}
|
||||
#define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b)
|
||||
#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b)
|
||||
|
||||
#endif
|
|
@ -1,106 +0,0 @@
|
|||
/* Copyright (C) 2003 Jean-Marc Valin */
|
||||
/**
|
||||
@file fixed_generic.h
|
||||
@brief Generic fixed-point operations
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FIXED_GENERIC_H
|
||||
#define FIXED_GENERIC_H
|
||||
|
||||
#define QCONST16(x,bits) ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
|
||||
#define QCONST32(x,bits) ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
|
||||
|
||||
#define NEG16(x) (-(x))
|
||||
#define NEG32(x) (-(x))
|
||||
#define EXTRACT16(x) ((spx_word16_t)(x))
|
||||
#define EXTEND32(x) ((spx_word32_t)(x))
|
||||
#define SHR16(a,shift) ((a) >> (shift))
|
||||
#define SHL16(a,shift) ((a) << (shift))
|
||||
#define SHR32(a,shift) ((a) >> (shift))
|
||||
#define SHL32(a,shift) ((a) << (shift))
|
||||
#define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift))
|
||||
#define PSHR32(a,shift) (SHR32((a)+((1<<((shift))>>1)),shift))
|
||||
#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
|
||||
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
|
||||
#define SHR(a,shift) ((a) >> (shift))
|
||||
#define SHL(a,shift) ((spx_word32_t)(a) << (shift))
|
||||
#define PSHR(a,shift) (SHR((a)+((1<<((shift))>>1)),shift))
|
||||
#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
|
||||
|
||||
|
||||
#define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))
|
||||
#define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b))
|
||||
#define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b))
|
||||
#define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b))
|
||||
|
||||
|
||||
/* result fits in 16 bits */
|
||||
#define MULT16_16_16(a,b) ((((spx_word16_t)(a))*((spx_word16_t)(b))))
|
||||
|
||||
/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */
|
||||
#define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
|
||||
|
||||
#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
|
||||
#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
|
||||
#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
|
||||
#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
|
||||
|
||||
#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
|
||||
#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
|
||||
|
||||
#define MULT16_32_P15(a,b) ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
|
||||
#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
|
||||
#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
|
||||
|
||||
|
||||
#define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11)))
|
||||
#define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13)))
|
||||
#define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13)))
|
||||
|
||||
#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
|
||||
#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
|
||||
#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
|
||||
#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
|
||||
|
||||
#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
|
||||
#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
|
||||
#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
|
||||
|
||||
#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
|
||||
|
||||
#define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b))))
|
||||
#define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b))))
|
||||
#define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b)))
|
||||
#define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b)))
|
||||
|
||||
#endif
|
|
@ -1,160 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: gain_table.c
|
||||
Codebook for 3-tap pitch prediction gain (128 entries)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const signed char gain_cdbk_nb[512] = {
|
||||
-32, -32, -32, 0,
|
||||
-28, -67, -5, 33,
|
||||
-42, -6, -32, 18,
|
||||
-57, -10, -54, 35,
|
||||
-16, 27, -41, 42,
|
||||
19, -19, -40, 36,
|
||||
-45, 24, -21, 40,
|
||||
-8, -14, -18, 28,
|
||||
1, 14, -58, 53,
|
||||
-18, -88, -39, 39,
|
||||
-38, 21, -18, 37,
|
||||
-19, 20, -43, 38,
|
||||
10, 17, -48, 54,
|
||||
-52, -58, -13, 33,
|
||||
-44, -1, -11, 32,
|
||||
-12, -11, -34, 22,
|
||||
14, 0, -46, 46,
|
||||
-37, -35, -34, 5,
|
||||
-25, 44, -30, 43,
|
||||
6, -4, -63, 49,
|
||||
-31, 43, -41, 43,
|
||||
-23, 30, -43, 41,
|
||||
-43, 26, -14, 44,
|
||||
-33, 1, -13, 27,
|
||||
-13, 18, -37, 37,
|
||||
-46, -73, -45, 34,
|
||||
-36, 24, -25, 34,
|
||||
-36, -11, -20, 19,
|
||||
-25, 12, -18, 33,
|
||||
-36, -69, -59, 34,
|
||||
-45, 6, 8, 46,
|
||||
-22, -14, -24, 18,
|
||||
-1, 13, -44, 44,
|
||||
-39, -48, -26, 15,
|
||||
-32, 31, -37, 34,
|
||||
-33, 15, -46, 31,
|
||||
-24, 30, -36, 37,
|
||||
-41, 31, -23, 41,
|
||||
-50, 22, -4, 50,
|
||||
-22, 2, -21, 28,
|
||||
-17, 30, -34, 40,
|
||||
-7, -60, -28, 29,
|
||||
-38, 42, -28, 42,
|
||||
-44, -11, 21, 43,
|
||||
-16, 8, -44, 34,
|
||||
-39, -55, -43, 21,
|
||||
-11, -35, 26, 41,
|
||||
-9, 0, -34, 29,
|
||||
-8, 121, -81, 113,
|
||||
7, -16, -22, 33,
|
||||
-37, 33, -31, 36,
|
||||
-27, -7, -36, 17,
|
||||
-34, 70, -57, 65,
|
||||
-37, -11, -48, 21,
|
||||
-40, 17, -1, 44,
|
||||
-33, 6, -6, 33,
|
||||
-9, 0, -20, 34,
|
||||
-21, 69, -33, 57,
|
||||
-29, 33, -31, 35,
|
||||
-55, 12, -1, 49,
|
||||
-33, 27, -22, 35,
|
||||
-50, -33, -47, 17,
|
||||
-50, 54, 51, 94,
|
||||
-1, -5, -44, 35,
|
||||
-4, 22, -40, 45,
|
||||
-39, -66, -25, 24,
|
||||
-33, 1, -26, 20,
|
||||
-24, -23, -25, 12,
|
||||
-11, 21, -45, 44,
|
||||
-25, -45, -19, 17,
|
||||
-43, 105, -16, 82,
|
||||
5, -21, 1, 41,
|
||||
-16, 11, -33, 30,
|
||||
-13, -99, -4, 57,
|
||||
-37, 33, -15, 44,
|
||||
-25, 37, -63, 54,
|
||||
-36, 24, -31, 31,
|
||||
-53, -56, -38, 26,
|
||||
-41, -4, 4, 37,
|
||||
-33, 13, -30, 24,
|
||||
49, 52, -94, 114,
|
||||
-5, -30, -15, 23,
|
||||
1, 38, -40, 56,
|
||||
-23, 12, -36, 29,
|
||||
-17, 40, -47, 51,
|
||||
-37, -41, -39, 11,
|
||||
-49, 34, 0, 58,
|
||||
-18, -7, -4, 34,
|
||||
-16, 17, -27, 35,
|
||||
30, 5, -62, 65,
|
||||
4, 48, -68, 76,
|
||||
-43, 11, -11, 38,
|
||||
-18, 19, -15, 41,
|
||||
-23, -62, -39, 23,
|
||||
-42, 10, -2, 41,
|
||||
-21, -13, -13, 25,
|
||||
-9, 13, -47, 42,
|
||||
-23, -62, -24, 24,
|
||||
-44, 60, -21, 58,
|
||||
-18, -3, -52, 32,
|
||||
-22, 22, -36, 34,
|
||||
-75, 57, 16, 90,
|
||||
-19, 3, 10, 45,
|
||||
-29, 23, -38, 32,
|
||||
-5, -62, -51, 38,
|
||||
-51, 40, -18, 53,
|
||||
-42, 13, -24, 32,
|
||||
-34, 14, -20, 30,
|
||||
-56, -75, -26, 37,
|
||||
-26, 32, 15, 59,
|
||||
-26, 17, -29, 29,
|
||||
-7, 28, -52, 53,
|
||||
-12, -30, 5, 30,
|
||||
-5, -48, -5, 35,
|
||||
2, 2, -43, 40,
|
||||
21, 16, 16, 75,
|
||||
-25, -45, -32, 10,
|
||||
-43, 18, -10, 42,
|
||||
9, 0, -1, 52,
|
||||
-1, 7, -30, 36,
|
||||
19, -48, -4, 48,
|
||||
-28, 25, -29, 32,
|
||||
-22, 0, -31, 22,
|
||||
-32, 17, -10, 36,
|
||||
-64, -41, -62, 36,
|
||||
-52, 15, 16, 58,
|
||||
-30, -22, -32, 6,
|
||||
-7, 9, -38, 36};
|
|
@ -1,64 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: gain_table_lbr.c
|
||||
Codebook for 3-tap pitch prediction gain (32 entries)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const signed char gain_cdbk_lbr[128] = {
|
||||
-32, -32, -32, 0,
|
||||
-31, -58, -16, 22,
|
||||
-41, -24, -43, 14,
|
||||
-56, -22, -55, 29,
|
||||
-13, 33, -41, 47,
|
||||
-4, -39, -9, 29,
|
||||
-41, 15, -12, 38,
|
||||
-8, -15, -12, 31,
|
||||
1, 2, -44, 40,
|
||||
-22, -66, -42, 27,
|
||||
-38, 28, -23, 38,
|
||||
-21, 14, -37, 31,
|
||||
0, 21, -50, 52,
|
||||
-53, -71, -27, 33,
|
||||
-37, -1, -19, 25,
|
||||
-19, -5, -28, 22,
|
||||
6, 65, -44, 74,
|
||||
-33, -48, -33, 9,
|
||||
-40, 57, -14, 58,
|
||||
-17, 4, -45, 32,
|
||||
-31, 38, -33, 36,
|
||||
-23, 28, -40, 39,
|
||||
-43, 29, -12, 46,
|
||||
-34, 13, -23, 28,
|
||||
-16, 15, -27, 34,
|
||||
-14, -82, -15, 43,
|
||||
-31, 25, -32, 29,
|
||||
-21, 5, -5, 38,
|
||||
-47, -63, -51, 33,
|
||||
-46, 12, 3, 47,
|
||||
-28, -17, -29, 11,
|
||||
-10, 14, -40, 38};
|
|
@ -1,66 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: hexc_10_32_table.c
|
||||
Codebook for high-band excitation in SB-CELP mode (4000 bps)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const signed char hexc_10_32_table[320] = {
|
||||
-3, -2, -1, 0, -4, 5, 35, -40, -9, 13,
|
||||
-44, 5, -27, -1, -7, 6, -11, 7, -8, 7,
|
||||
19, -14, 15, -4, 9, -10, 10, -8, 10, -9,
|
||||
-1, 1, 0, 0, 2, 5, -18, 22, -53, 50,
|
||||
1, -23, 50, -36, 15, 3, -13, 14, -10, 6,
|
||||
1, 5, -3, 4, -2, 5, -32, 25, 5, -2,
|
||||
-1, -4, 1, 11, -29, 26, -6, -15, 30, -18,
|
||||
0, 15, -17, 40, -41, 3, 9, -2, -2, 3,
|
||||
-3, -1, -5, 2, 21, -6, -16, -21, 23, 2,
|
||||
60, 15, 16, -16, -9, 14, 9, -1, 7, -9,
|
||||
0, 1, 1, 0, -1, -6, 17, -28, 54, -45,
|
||||
-1, 1, -1, -6, -6, 2, 11, 26, -29, -2,
|
||||
46, -21, 34, 12, -23, 32, -23, 16, -10, 3,
|
||||
66, 19, -20, 24, 7, 11, -3, 0, -3, -1,
|
||||
-50, -46, 2, -18, -3, 4, -1, -2, 3, -3,
|
||||
-19, 41, -36, 9, 11, -24, 21, -16, 9, -3,
|
||||
-25, -3, 10, 18, -9, -2, -5, -1, -5, 6,
|
||||
-4, -3, 2, -26, 21, -19, 35, -15, 7, -13,
|
||||
17, -19, 39, -43, 48, -31, 16, -9, 7, -2,
|
||||
-5, 3, -4, 9, -19, 27, -55, 63, -35, 10,
|
||||
26, -44, -2, 9, 4, 1, -6, 8, -9, 5,
|
||||
-8, -1, -3, -16, 45, -42, 5, 15, -16, 10,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
-16, 24, -55, 47, -38, 27, -19, 7, -3, 1,
|
||||
16, 27, 20, -19, 18, 5, -7, 1, -5, 2,
|
||||
-6, 8, -22, 0, -3, -3, 8, -1, 7, -8,
|
||||
1, -3, 5, 0, 17, -48, 58, -52, 29, -7,
|
||||
-2, 3, -10, 6, -26, 58, -31, 1, -6, 3,
|
||||
93, -29, 39, 3, 17, 5, 6, -1, -1, -1,
|
||||
27, 13, 10, 19, -7, -34, 12, 10, -4, 9,
|
||||
-76, 9, 8, -28, -2, -11, 2, -1, 3, 1,
|
||||
-83, 38, -39, 4, -16, -6, -2, -5, 5, -2,
|
||||
};
|
|
@ -1,162 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: hexc_table.c
|
||||
Codebook for high-band excitation in SB-CELP mode (8000 bps with sign)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const signed char hexc_table[1024] = {
|
||||
-24, 21, -20, 5, -5, -7, 14, -10,
|
||||
2, -27, 16, -20, 0, -32, 26, 19,
|
||||
8, -11, -41, 31, 28, -27, -32, 34,
|
||||
42, 34, -17, 22, -10, 13, -29, 18,
|
||||
-12, -26, -24, 11, 22, 5, -5, -5,
|
||||
54, -68, -43, 57, -25, 24, 4, 4,
|
||||
26, -8, -12, -17, 54, 30, -45, 1,
|
||||
10, -15, 18, -41, 11, 68, -67, 37,
|
||||
-16, -24, -16, 38, -22, 6, -29, 30,
|
||||
66, -27, 5, 7, -16, 13, 2, -12,
|
||||
-7, -3, -20, 36, 4, -28, 9, 3,
|
||||
32, 48, 26, 39, 3, 0, 7, -21,
|
||||
-13, 5, -82, -7, 73, -20, 34, -9,
|
||||
-5, 1, -1, 10, -5, -10, -1, 9,
|
||||
1, -9, 10, 0, -14, 11, -1, -2,
|
||||
-1, 11, 20, 96, -81, -22, -12, -9,
|
||||
-58, 9, 24, -30, 26, -35, 27, -12,
|
||||
13, -18, 56, -59, 15, -7, 23, -15,
|
||||
-1, 6, -25, 14, -22, -20, 47, -11,
|
||||
16, 2, 38, -23, -19, -30, -9, 40,
|
||||
-11, 5, 4, -6, 8, 26, -21, -11,
|
||||
127, 4, 1, 6, -9, 2, -7, -2,
|
||||
-3, 7, -5, 10, -19, 7, -106, 91,
|
||||
-3, 9, -4, 21, -8, 26, -80, 8,
|
||||
1, -2, -10, -17, -17, -27, 32, 71,
|
||||
6, -29, 11, -23, 54, -38, 29, -22,
|
||||
39, 87, -31, -12, -20, 3, -2, -2,
|
||||
2, 20, 0, -1, -35, 27, 9, -6,
|
||||
-12, 3, -12, -6, 13, 1, 14, -22,
|
||||
-59, -15, -17, -25, 13, -7, 7, 3,
|
||||
0, 1, -7, 6, -3, 61, -37, -23,
|
||||
-23, -29, 38, -31, 27, 1, -8, 2,
|
||||
-27, 23, -26, 36, -34, 5, 24, -24,
|
||||
-6, 7, 3, -59, 78, -62, 44, -16,
|
||||
1, 6, 0, 17, 8, 45, 0, -110,
|
||||
6, 14, -2, 32, -77, -56, 62, -3,
|
||||
3, -13, 4, -16, 102, -15, -36, -1,
|
||||
9, -113, 6, 23, 0, 9, 9, 5,
|
||||
-8, -1, -14, 5, -12, 121, -53, -27,
|
||||
-8, -9, 22, -13, 3, 2, -3, 1,
|
||||
-2, -71, 95, 38, -19, 15, -16, -5,
|
||||
71, 10, 2, -32, -13, -5, 15, -1,
|
||||
-2, -14, -85, 30, 29, 6, 3, 2,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, -65, -56, -9, 18, 18, 23, -14,
|
||||
-2, 0, 12, -29, 26, -12, 1, 2,
|
||||
-12, -64, 90, -6, 4, 1, 5, -5,
|
||||
-110, -3, -31, 22, -29, 9, 0, 8,
|
||||
-40, -5, 21, -5, -5, 13, 10, -18,
|
||||
40, 1, 35, -20, 30, -28, 11, -6,
|
||||
19, 7, 14, 18, -64, 9, -6, 16,
|
||||
51, 68, 8, 16, 12, -8, 0, -9,
|
||||
20, -22, 25, 7, -4, -13, 41, -35,
|
||||
93, -18, -54, 11, -1, 1, -9, 4,
|
||||
-66, 66, -31, 20, -22, 25, -23, 11,
|
||||
10, 9, 19, 15, 11, -5, -31, -10,
|
||||
-23, -28, -6, -6, -3, -4, 5, 3,
|
||||
-28, 22, -11, -42, 25, -25, -16, 41,
|
||||
34, 47, -6, 2, 42, -19, -22, 5,
|
||||
-39, 32, 6, -35, 22, 17, -30, 8,
|
||||
-26, -11, -11, 3, -12, 33, 33, -37,
|
||||
21, -1, 6, -4, 3, 0, -5, 5,
|
||||
12, -12, 57, 27, -61, -3, 20, -17,
|
||||
2, 0, 4, 0, -2, -33, -58, 81,
|
||||
-23, 39, -10, -5, 2, 6, -7, 5,
|
||||
4, -3, -2, -13, -23, -72, 107, 15,
|
||||
-5, 0, -7, -3, -6, 5, -4, 15,
|
||||
47, 12, -31, 25, -16, 8, 22, -25,
|
||||
-62, -56, -18, 14, 28, 12, 2, -11,
|
||||
74, -66, 41, -20, -7, 16, -20, 16,
|
||||
-8, 0, -16, 4, -19, 92, 12, -59,
|
||||
-14, -39, 49, -25, -16, 23, -27, 19,
|
||||
-3, -33, 19, 85, -29, 6, -7, -10,
|
||||
16, -7, -12, 1, -6, 2, 4, -2,
|
||||
64, 10, -25, 41, -2, -31, 15, 0,
|
||||
110, 50, 69, 35, 28, 19, -10, 2,
|
||||
-43, -49, -56, -15, -16, 10, 3, 12,
|
||||
-1, -8, 1, 26, -12, -1, 7, -11,
|
||||
-27, 41, 25, 1, -11, -18, 22, -7,
|
||||
-1, -47, -8, 23, -3, -17, -7, 18,
|
||||
-125, 59, -5, 3, 18, 1, 2, 3,
|
||||
27, -35, 65, -53, 50, -46, 37, -21,
|
||||
-28, 7, 14, -37, -5, -5, 12, 5,
|
||||
-8, 78, -19, 21, -6, -16, 8, -7,
|
||||
5, 2, 7, 2, 10, -6, 12, -60,
|
||||
44, 11, -36, -32, 31, 0, 2, -2,
|
||||
2, 1, -3, 7, -10, 17, -21, 10,
|
||||
6, -2, 19, -2, 59, -38, -86, 38,
|
||||
8, -41, -30, -45, -33, 7, 15, 28,
|
||||
29, -7, 24, -40, 7, 7, 5, -2,
|
||||
9, 24, -23, -18, 6, -29, 30, 2,
|
||||
28, 49, -11, -46, 10, 43, -13, -9,
|
||||
-1, -3, -7, -7, -17, -6, 97, -33,
|
||||
-21, 3, 5, 1, 12, -43, -8, 28,
|
||||
7, -43, -7, 17, -20, 19, -1, 2,
|
||||
-13, 9, 54, 34, 9, -28, -11, -9,
|
||||
-17, 110, -59, 44, -26, 0, 3, -12,
|
||||
-47, 73, -34, -43, 38, -33, 16, -5,
|
||||
-46, -4, -6, -2, -25, 19, -29, 28,
|
||||
-13, 5, 14, 27, -40, -43, 4, 32,
|
||||
-13, -2, -35, -4, 112, -42, 9, -12,
|
||||
37, -28, 17, 14, -19, 35, -39, 23,
|
||||
3, -14, -1, -57, -5, 94, -9, 3,
|
||||
-39, 5, 30, -10, -32, 42, -13, -14,
|
||||
-97, -63, 30, -9, 1, -7, 12, 5,
|
||||
20, 17, -9, -36, -30, 25, 47, -9,
|
||||
-15, 12, -22, 98, -8, -50, 15, -27,
|
||||
21, -16, -11, 2, 12, -10, 10, -3,
|
||||
33, 36, -96, 0, -17, 31, -9, 9,
|
||||
3, -20, 13, -11, 8, -4, 10, -10,
|
||||
9, 1, 112, -70, -27, 5, -21, 2,
|
||||
-57, -3, -29, 10, 19, -21, 21, -10,
|
||||
-66, -3, 91, -35, 30, -12, 0, -7,
|
||||
59, -28, 26, 2, 14, -18, 1, 1,
|
||||
11, 17, 20, -54, -59, 27, 4, 29,
|
||||
32, 5, 19, 12, -4, 1, 7, -10,
|
||||
5, -2, 10, 0, 23, -5, 28, -104,
|
||||
46, 11, 16, 3, 29, 1, -8, -14,
|
||||
1, 7, -50, 88, -62, 26, 8, -17,
|
||||
-14, 50, 0, 32, -12, -3, -27, 18,
|
||||
-8, -5, 8, 3, -20, -11, 37, -12,
|
||||
9, 33, 46, -101, -1, -4, 1, 6,
|
||||
-1, 28, -42, -15, 16, 5, -1, -2,
|
||||
-55, 85, 38, -9, -4, 11, -2, -9,
|
||||
-6, 3, -20, -10, -77, 89, 24, -3,
|
||||
-104, -57, -26, -31, -20, -6, -9, 14,
|
||||
20, -23, 46, -15, -31, 28, 1, -15,
|
||||
-2, 6, -2, 31, 45, -76, 23, -25,
|
||||
};
|
|
@ -1,163 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: high_lsp_tables.c
|
||||
Codebooks for high-band LSPs in SB-CELP mode
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const signed char high_lsp_cdbk[512]={
|
||||
39,12,-14,-20,-29,-61,-67,-76,
|
||||
-32,-71,-67,68,77,46,34,5,
|
||||
-13,-48,-46,-72,-81,-84,-60,-58,
|
||||
-40,-28,82,93,68,45,29,3,
|
||||
-19,-47,-28,-43,-35,-30,-8,-13,
|
||||
-39,-91,-91,-123,-96,10,10,-6,
|
||||
-18,-55,-60,-91,-56,-36,-27,-16,
|
||||
-48,-75,40,28,-10,-28,35,9,
|
||||
37,19,1,-20,-31,-41,-18,-25,
|
||||
-35,-68,-80,45,27,-1,47,13,
|
||||
0,-29,-35,-57,-50,-79,-73,-38,
|
||||
-19,5,35,14,-10,-23,16,-8,
|
||||
5,-24,-40,-62,-23,-27,-22,-16,
|
||||
-18,-46,-72,-77,43,21,33,1,
|
||||
-80,-70,-70,-64,-56,-52,-39,-33,
|
||||
-31,-38,-19,-19,-15,32,33,-2,
|
||||
7,-15,-15,-24,-23,-33,-41,-56,
|
||||
-24,-57,5,89,64,41,27,5,
|
||||
-9,-47,-60,-97,-97,-124,-20,-9,
|
||||
-44,-73,31,29,-4,64,48,7,
|
||||
-35,-57,0,-3,-26,-47,-3,-6,
|
||||
-40,-76,-79,-48,12,81,55,10,
|
||||
9,-24,-43,-73,-57,-69,16,5,
|
||||
-28,-53,18,29,20,0,-4,-11,
|
||||
6,-13,23,7,-17,-35,-37,-37,
|
||||
-30,-68,-63,6,24,-9,-14,3,
|
||||
21,-13,-27,-57,-49,-80,-24,-41,
|
||||
-5,-16,-5,1,45,25,12,-7,
|
||||
3,-15,-6,-16,-15,-8,6,-13,
|
||||
-42,-81,-80,-87,14,1,-10,-3,
|
||||
-43,-69,-46,-24,-28,-29,36,6,
|
||||
-43,-56,-12,12,54,79,43,9,
|
||||
54,22,2,8,-12,-43,-46,-52,
|
||||
-38,-69,-89,-5,75,38,33,5,
|
||||
-13,-53,-62,-87,-89,-113,-99,-55,
|
||||
-34,-37,62,55,33,16,21,-2,
|
||||
-17,-46,-29,-38,-38,-48,-39,-42,
|
||||
-36,-75,-72,-88,-48,-30,21,2,
|
||||
-15,-57,-64,-98,-84,-76,25,1,
|
||||
-46,-80,-12,18,-7,3,34,6,
|
||||
38,31,23,4,-1,20,14,-15,
|
||||
-43,-78,-91,-24,14,-3,54,16,
|
||||
0,-27,-28,-44,-56,-83,-92,-89,
|
||||
-3,34,56,41,36,22,20,-8,
|
||||
-7,-35,-42,-62,-49,3,12,-10,
|
||||
-50,-87,-96,-66,92,70,38,9,
|
||||
-70,-71,-62,-42,-39,-43,-11,-7,
|
||||
-50,-79,-58,-50,-31,32,31,-6,
|
||||
-4,-25,7,-17,-38,-70,-58,-27,
|
||||
-43,-83,-28,59,36,20,31,2,
|
||||
-27,-71,-80,-109,-98,-75,-33,-32,
|
||||
-31,-2,33,15,-6,43,33,-5,
|
||||
0,-22,-10,-27,-34,-49,-11,-20,
|
||||
-41,-91,-100,-121,-39,57,41,10,
|
||||
-19,-50,-38,-59,-60,-70,-18,-20,
|
||||
-8,-31,-8,-15,1,-14,-26,-25,
|
||||
33,21,32,17,1,-19,-19,-26,
|
||||
-58,-81,-35,-22,45,30,11,-11,
|
||||
3,-26,-48,-87,-67,-83,-58,3,
|
||||
-1,-26,-20,44,10,25,39,5,
|
||||
-9,-35,-27,-38,7,10,4,-9,
|
||||
-42,-85,-102,-127,52,44,28,10,
|
||||
-47,-61,-40,-39,-17,-1,-10,-33,
|
||||
-42,-74,-48,21,-4,70,52,10};
|
||||
|
||||
|
||||
const signed char high_lsp_cdbk2[512]={
|
||||
-36,-62,6,-9,-10,-14,-56,23,
|
||||
1,-26,23,-48,-17,12,8,-7,
|
||||
23,29,-36,-28,-6,-29,-17,-5,
|
||||
40,23,10,10,-46,-13,36,6,
|
||||
4,-30,-29,62,32,-32,-1,22,
|
||||
-14,1,-4,-22,-45,2,54,4,
|
||||
-30,-57,-59,-12,27,-3,-31,8,
|
||||
-9,5,10,-14,32,66,19,9,
|
||||
2,-25,-37,23,-15,18,-38,-31,
|
||||
5,-9,-21,15,0,22,62,30,
|
||||
15,-12,-14,-46,77,21,33,3,
|
||||
34,29,-19,50,2,11,9,-38,
|
||||
-12,-37,62,1,-15,54,32,6,
|
||||
2,-24,20,35,-21,2,19,24,
|
||||
-13,55,4,9,39,-19,30,-1,
|
||||
-21,73,54,33,8,18,3,15,
|
||||
6,-19,-47,6,-3,-48,-50,1,
|
||||
26,20,8,-23,-50,65,-14,-55,
|
||||
-17,-31,-37,-28,53,-1,-17,-53,
|
||||
1,57,11,-8,-25,-30,-37,64,
|
||||
5,-52,-45,15,23,31,15,14,
|
||||
-25,24,33,-2,-44,-56,-18,6,
|
||||
-21,-43,4,-12,17,-37,20,-10,
|
||||
34,15,2,15,55,21,-11,-31,
|
||||
-6,46,25,16,-9,-25,-8,-62,
|
||||
28,17,20,-32,-29,26,30,25,
|
||||
-19,2,-16,-17,26,-51,2,50,
|
||||
42,19,-66,23,29,-2,3,19,
|
||||
-19,-37,32,15,6,30,-34,13,
|
||||
11,-5,40,31,10,-42,4,-9,
|
||||
26,-9,-70,17,-2,-23,20,-22,
|
||||
-55,51,-24,-31,22,-22,15,-13,
|
||||
3,-10,-28,-16,56,4,-63,11,
|
||||
-18,-15,-18,-38,-35,16,-7,34,
|
||||
-1,-21,-49,-47,9,-37,7,8,
|
||||
69,55,20,6,-33,-45,-10,-9,
|
||||
6,-9,12,71,15,-3,-42,-7,
|
||||
-24,32,-35,-2,-42,-17,-5,0,
|
||||
-2,-33,-54,13,-12,-34,47,23,
|
||||
19,55,7,-8,74,31,14,16,
|
||||
-23,-26,19,12,-18,-49,-28,-31,
|
||||
-20,2,-14,-20,-47,78,40,13,
|
||||
-23,-11,21,-6,18,1,47,5,
|
||||
38,35,32,46,22,8,13,16,
|
||||
-14,18,51,19,40,39,11,-26,
|
||||
-1,-17,47,2,-53,-15,31,-22,
|
||||
38,21,-15,-16,5,-33,53,15,
|
||||
-38,86,11,-3,-24,49,13,-4,
|
||||
-11,-18,28,20,-12,-27,-26,35,
|
||||
-25,-35,-3,-20,-61,30,10,-55,
|
||||
-12,-22,-52,-54,-14,19,-32,-12,
|
||||
45,15,-8,-48,-9,11,-32,8,
|
||||
-16,-34,-13,51,18,38,-2,-32,
|
||||
-17,22,-2,-18,-28,-70,59,27,
|
||||
-28,-19,-10,-20,-9,-9,-8,-21,
|
||||
21,-8,35,-2,45,-3,-9,12,
|
||||
0,30,7,-39,43,27,-38,-91,
|
||||
30,26,19,-55,-4,63,14,-17,
|
||||
13,9,13,2,7,4,6,61,
|
||||
72,-1,-17,29,-1,-22,-17,8,
|
||||
-28,-37,63,44,41,3,2,14,
|
||||
9,-6,75,-8,-7,-12,-15,-12,
|
||||
13,9,-4,30,-22,-65,15,0,
|
||||
-45,4,-4,1,5,22,11,23};
|
|
@ -1,508 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: speex_jitter.h
|
||||
|
||||
Adaptive jitter buffer for Speex
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "misc.h"
|
||||
#include <speex/speex.h>
|
||||
#include <speex/speex_bits.h>
|
||||
#include <speex/speex_jitter.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define LATE_BINS 10
|
||||
#define MAX_MARGIN 30 /**< Number of bins in margin histogram */
|
||||
|
||||
#define SPEEX_JITTER_MAX_BUFFER_SIZE 200 /**< Maximum number of packets in jitter buffer */
|
||||
|
||||
|
||||
|
||||
#define GT32(a,b) (((spx_int32_t)((a)-(b)))>0)
|
||||
#define GE32(a,b) (((spx_int32_t)((a)-(b)))>=0)
|
||||
#define LT32(a,b) (((spx_int32_t)((a)-(b)))<0)
|
||||
#define LE32(a,b) (((spx_int32_t)((a)-(b)))<=0)
|
||||
|
||||
/** Jitter buffer structure */
|
||||
struct JitterBuffer_ {
|
||||
spx_uint32_t pointer_timestamp; /**< Timestamp of what we will *get* next */
|
||||
spx_uint32_t current_timestamp; /**< Timestamp of the local clock (what we will *play* next) */
|
||||
|
||||
char *buf[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Buffer of packets (NULL if slot is free) */
|
||||
spx_uint32_t timestamp[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Timestamp of packet */
|
||||
int span[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Timestamp of packet */
|
||||
int len[SPEEX_JITTER_MAX_BUFFER_SIZE]; /**< Number of bytes in packet */
|
||||
|
||||
int tick_size; /**< Output granularity */
|
||||
int reset_state; /**< True if state was just reset */
|
||||
int buffer_margin; /**< How many frames we want to keep in the buffer (lower bound) */
|
||||
|
||||
int lost_count; /**< Number of consecutive lost packets */
|
||||
float shortterm_margin[MAX_MARGIN]; /**< Short term margin histogram */
|
||||
float longterm_margin[MAX_MARGIN]; /**< Long term margin histogram */
|
||||
float loss_rate; /**< Average loss rate */
|
||||
};
|
||||
|
||||
/** Initialise jitter buffer */
|
||||
JitterBuffer *jitter_buffer_init(int tick)
|
||||
{
|
||||
JitterBuffer *jitter = (JitterBuffer*)speex_alloc(sizeof(JitterBuffer));
|
||||
if (jitter)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
jitter->buf[i]=NULL;
|
||||
jitter->tick_size = tick;
|
||||
jitter->buffer_margin = 1;
|
||||
jitter_buffer_reset(jitter);
|
||||
}
|
||||
return jitter;
|
||||
}
|
||||
|
||||
/** Reset jitter buffer */
|
||||
void jitter_buffer_reset(JitterBuffer *jitter)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
if (jitter->buf[i])
|
||||
{
|
||||
speex_free(jitter->buf[i]);
|
||||
jitter->buf[i] = NULL;
|
||||
}
|
||||
}
|
||||
/* Timestamp is actually undefined at this point */
|
||||
jitter->pointer_timestamp = 0;
|
||||
jitter->current_timestamp = 0;
|
||||
jitter->reset_state = 1;
|
||||
jitter->lost_count = 0;
|
||||
jitter->loss_rate = 0;
|
||||
for (i=0;i<MAX_MARGIN;i++)
|
||||
{
|
||||
jitter->shortterm_margin[i] = 0;
|
||||
jitter->longterm_margin[i] = 0;
|
||||
}
|
||||
/*fprintf (stderr, "reset\n");*/
|
||||
}
|
||||
|
||||
/** Destroy jitter buffer */
|
||||
void jitter_buffer_destroy(JitterBuffer *jitter)
|
||||
{
|
||||
jitter_buffer_reset(jitter);
|
||||
speex_free(jitter);
|
||||
}
|
||||
|
||||
/** Put one packet into the jitter buffer */
|
||||
void jitter_buffer_put(JitterBuffer *jitter, const JitterBufferPacket *packet)
|
||||
{
|
||||
int i,j;
|
||||
spx_int32_t arrival_margin;
|
||||
/*fprintf (stderr, "put packet %d %d\n", timestamp, span);*/
|
||||
if (jitter->reset_state)
|
||||
{
|
||||
jitter->reset_state=0;
|
||||
jitter->pointer_timestamp = packet->timestamp;
|
||||
jitter->current_timestamp = packet->timestamp;
|
||||
/*fprintf(stderr, "reset to %d\n", timestamp);*/
|
||||
}
|
||||
|
||||
/* Cleanup buffer (remove old packets that weren't played) */
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
if (jitter->buf[i] && LE32(jitter->timestamp[i] + jitter->span[i], jitter->pointer_timestamp))
|
||||
{
|
||||
/*fprintf (stderr, "cleaned (not played)\n");*/
|
||||
speex_free(jitter->buf[i]);
|
||||
jitter->buf[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*Find an empty slot in the buffer*/
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
if (jitter->buf[i]==NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
/*fprintf(stderr, "%d %d %f\n", timestamp, jitter->pointer_timestamp, jitter->drift_average);*/
|
||||
/*No place left in the buffer*/
|
||||
if (i==SPEEX_JITTER_MAX_BUFFER_SIZE)
|
||||
{
|
||||
int earliest=jitter->timestamp[0];
|
||||
i=0;
|
||||
for (j=1;j<SPEEX_JITTER_MAX_BUFFER_SIZE;j++)
|
||||
{
|
||||
if (!jitter->buf[i] || LT32(jitter->timestamp[j],earliest))
|
||||
{
|
||||
earliest = jitter->timestamp[j];
|
||||
i=j;
|
||||
}
|
||||
}
|
||||
speex_free(jitter->buf[i]);
|
||||
jitter->buf[i]=NULL;
|
||||
if (jitter->lost_count>20)
|
||||
{
|
||||
jitter_buffer_reset(jitter);
|
||||
}
|
||||
/*fprintf (stderr, "Buffer is full, discarding earliest frame %d (currently at %d)\n", timestamp, jitter->pointer_timestamp);*/
|
||||
}
|
||||
|
||||
/* Copy packet in buffer */
|
||||
jitter->buf[i]=(char*)speex_alloc(packet->len);
|
||||
for (j=0;j<packet->len;j++)
|
||||
jitter->buf[i][j]=packet->data[j];
|
||||
jitter->timestamp[i]=packet->timestamp;
|
||||
jitter->span[i]=packet->span;
|
||||
jitter->len[i]=packet->len;
|
||||
|
||||
/* Adjust the buffer size depending on network conditions */
|
||||
arrival_margin = (packet->timestamp - jitter->current_timestamp) - jitter->buffer_margin*jitter->tick_size;
|
||||
|
||||
if (arrival_margin >= -LATE_BINS*jitter->tick_size)
|
||||
{
|
||||
spx_int32_t int_margin;
|
||||
for (i=0;i<MAX_MARGIN;i++)
|
||||
{
|
||||
jitter->shortterm_margin[i] *= .98;
|
||||
jitter->longterm_margin[i] *= .995;
|
||||
}
|
||||
int_margin = LATE_BINS + arrival_margin/jitter->tick_size;
|
||||
if (int_margin>MAX_MARGIN-1)
|
||||
int_margin = MAX_MARGIN-1;
|
||||
if (int_margin>=0)
|
||||
{
|
||||
jitter->shortterm_margin[int_margin] += .02;
|
||||
jitter->longterm_margin[int_margin] += .005;
|
||||
}
|
||||
} else {
|
||||
|
||||
/*fprintf (stderr, "way too late = %d\n", arrival_margin);*/
|
||||
if (jitter->lost_count>20)
|
||||
{
|
||||
jitter_buffer_reset(jitter);
|
||||
}
|
||||
}
|
||||
#if 0 /* Enable to check how much is being buffered */
|
||||
if (rand()%1000==0)
|
||||
{
|
||||
int count = 0;
|
||||
for (j=0;j<SPEEX_JITTER_MAX_BUFFER_SIZE;j++)
|
||||
{
|
||||
if (jitter->buf[j])
|
||||
count++;
|
||||
}
|
||||
fprintf (stderr, "buffer_size = %d\n", count);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Get one packet from the jitter buffer */
|
||||
int jitter_buffer_get(JitterBuffer *jitter, JitterBufferPacket *packet, spx_uint32_t *start_offset)
|
||||
{
|
||||
int i, j;
|
||||
float late_ratio_short;
|
||||
float late_ratio_long;
|
||||
float ontime_ratio_short;
|
||||
float ontime_ratio_long;
|
||||
float early_ratio_short;
|
||||
float early_ratio_long;
|
||||
int chunk_size;
|
||||
int incomplete = 0;
|
||||
|
||||
if (LT32(jitter->current_timestamp+jitter->tick_size, jitter->pointer_timestamp))
|
||||
{
|
||||
jitter->current_timestamp = jitter->pointer_timestamp;
|
||||
speex_warning("did you forget to call jitter_buffer_tick() by any chance?");
|
||||
}
|
||||
/*fprintf (stderr, "get packet %d %d\n", jitter->pointer_timestamp, jitter->current_timestamp);*/
|
||||
|
||||
/* FIXME: This should be only what remaining of the current tick */
|
||||
chunk_size = jitter->tick_size;
|
||||
|
||||
/* Compiling arrival statistics */
|
||||
|
||||
late_ratio_short = 0;
|
||||
late_ratio_long = 0;
|
||||
for (i=0;i<LATE_BINS;i++)
|
||||
{
|
||||
late_ratio_short += jitter->shortterm_margin[i];
|
||||
late_ratio_long += jitter->longterm_margin[i];
|
||||
}
|
||||
ontime_ratio_short = jitter->shortterm_margin[LATE_BINS];
|
||||
ontime_ratio_long = jitter->longterm_margin[LATE_BINS];
|
||||
early_ratio_short = early_ratio_long = 0;
|
||||
for (i=LATE_BINS+1;i<MAX_MARGIN;i++)
|
||||
{
|
||||
early_ratio_short += jitter->shortterm_margin[i];
|
||||
early_ratio_long += jitter->longterm_margin[i];
|
||||
}
|
||||
if (0&&jitter->pointer_timestamp%1000==0)
|
||||
{
|
||||
/*fprintf (stderr, "%f %f %f %f %f %f\n", early_ratio_short, early_ratio_long, ontime_ratio_short, ontime_ratio_long, late_ratio_short, late_ratio_long);*/
|
||||
/*fprintf (stderr, "%f %f\n", early_ratio_short + ontime_ratio_short + late_ratio_short, early_ratio_long + ontime_ratio_long + late_ratio_long);*/
|
||||
}
|
||||
|
||||
/* Adjusting the buffering */
|
||||
|
||||
if (late_ratio_short > .1 || late_ratio_long > .03)
|
||||
{
|
||||
/* If too many packets are arriving late */
|
||||
jitter->shortterm_margin[MAX_MARGIN-1] += jitter->shortterm_margin[MAX_MARGIN-2];
|
||||
jitter->longterm_margin[MAX_MARGIN-1] += jitter->longterm_margin[MAX_MARGIN-2];
|
||||
for (i=MAX_MARGIN-3;i>=0;i--)
|
||||
{
|
||||
jitter->shortterm_margin[i+1] = jitter->shortterm_margin[i];
|
||||
jitter->longterm_margin[i+1] = jitter->longterm_margin[i];
|
||||
}
|
||||
jitter->shortterm_margin[0] = 0;
|
||||
jitter->longterm_margin[0] = 0;
|
||||
jitter->pointer_timestamp -= jitter->tick_size;
|
||||
jitter->current_timestamp -= jitter->tick_size;
|
||||
/*fprintf (stderr, "i");*/
|
||||
/*fprintf (stderr, "interpolate (getting some slack)\n");*/
|
||||
} else if (late_ratio_short + ontime_ratio_short < .005 && late_ratio_long + ontime_ratio_long < .01 && early_ratio_short > .8)
|
||||
{
|
||||
/* Many frames arriving early */
|
||||
jitter->shortterm_margin[0] += jitter->shortterm_margin[1];
|
||||
jitter->longterm_margin[0] += jitter->longterm_margin[1];
|
||||
for (i=1;i<MAX_MARGIN-1;i++)
|
||||
{
|
||||
jitter->shortterm_margin[i] = jitter->shortterm_margin[i+1];
|
||||
jitter->longterm_margin[i] = jitter->longterm_margin[i+1];
|
||||
}
|
||||
jitter->shortterm_margin[MAX_MARGIN-1] = 0;
|
||||
jitter->longterm_margin[MAX_MARGIN-1] = 0;
|
||||
/*fprintf (stderr, "drop frame\n");*/
|
||||
/*fprintf (stderr, "d");*/
|
||||
jitter->pointer_timestamp += jitter->tick_size;
|
||||
jitter->current_timestamp += jitter->tick_size;
|
||||
/*fprintf (stderr, "dropping packet (getting more aggressive)\n");*/
|
||||
}
|
||||
|
||||
/* Searching for the packet that fits best */
|
||||
|
||||
/* Search the buffer for a packet with the right timestamp and spanning the whole current chunk */
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
if (jitter->buf[i] && jitter->timestamp[i]==jitter->pointer_timestamp && GE32(jitter->timestamp[i]+jitter->span[i],jitter->pointer_timestamp+chunk_size))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If no match, try for an "older" packet that still spans (fully) the current chunk */
|
||||
if (i==SPEEX_JITTER_MAX_BUFFER_SIZE)
|
||||
{
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
if (jitter->buf[i] && jitter->timestamp[i]<=jitter->pointer_timestamp && GE32(jitter->timestamp[i]+jitter->span[i],jitter->pointer_timestamp+chunk_size))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If still no match, try for an "older" packet that spans part of the current chunk */
|
||||
if (i==SPEEX_JITTER_MAX_BUFFER_SIZE)
|
||||
{
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
if (jitter->buf[i] && jitter->timestamp[i]<=jitter->pointer_timestamp && GT32(jitter->timestamp[i]+jitter->span[i],jitter->pointer_timestamp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If still no match, try for earliest packet possible */
|
||||
if (i==SPEEX_JITTER_MAX_BUFFER_SIZE)
|
||||
{
|
||||
int found = 0;
|
||||
spx_uint32_t best_time=0;
|
||||
int best_span=0;
|
||||
int besti=0;
|
||||
for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
|
||||
{
|
||||
/* check if packet starts within current chunk */
|
||||
if (jitter->buf[i] && LT32(jitter->timestamp[i],jitter->pointer_timestamp+chunk_size) && GE32(jitter->timestamp[i],jitter->pointer_timestamp))
|
||||
{
|
||||
if (!found || LT32(jitter->timestamp[i],best_time) || (jitter->timestamp[i]==best_time && GT32(jitter->span[i],best_span)))
|
||||
{
|
||||
best_time = jitter->timestamp[i];
|
||||
best_span = jitter->span[i];
|
||||
besti = i;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
i=besti;
|
||||
incomplete = 1;
|
||||
/*fprintf (stderr, "incomplete: %d %d %d %d\n", jitter->timestamp[i], jitter->pointer_timestamp, chunk_size, jitter->span[i]);*/
|
||||
}
|
||||
}
|
||||
|
||||
/* If we find something */
|
||||
if (i!=SPEEX_JITTER_MAX_BUFFER_SIZE)
|
||||
{
|
||||
/* We (obviously) haven't lost this packet */
|
||||
jitter->lost_count = 0;
|
||||
jitter->loss_rate = .999*jitter->loss_rate;
|
||||
/* Check for potential overflow */
|
||||
packet->len = jitter->len[i];
|
||||
/* Copy packet */
|
||||
for (j=0;j<packet->len;j++)
|
||||
packet->data[j] = jitter->buf[i][j];
|
||||
/* Remove packet */
|
||||
speex_free(jitter->buf[i]);
|
||||
jitter->buf[i] = NULL;
|
||||
/* Set timestamp and span (if requested) */
|
||||
if (start_offset)
|
||||
*start_offset = jitter->timestamp[i]-jitter->pointer_timestamp;
|
||||
packet->timestamp = jitter->timestamp[i];
|
||||
packet->span = jitter->span[i];
|
||||
/* Point at the end of the current packet */
|
||||
jitter->pointer_timestamp = jitter->timestamp[i]+jitter->span[i];
|
||||
if (incomplete)
|
||||
return JITTER_BUFFER_INCOMPLETE;
|
||||
else
|
||||
return JITTER_BUFFER_OK;
|
||||
}
|
||||
|
||||
|
||||
/* If we haven't found anything worth returning */
|
||||
/*fprintf (stderr, "not found\n");*/
|
||||
jitter->lost_count++;
|
||||
/*fprintf (stderr, "m");*/
|
||||
/*fprintf (stderr, "lost_count = %d\n", jitter->lost_count);*/
|
||||
jitter->loss_rate = .999*jitter->loss_rate + .001;
|
||||
if (start_offset)
|
||||
*start_offset = 0;
|
||||
packet->timestamp = jitter->pointer_timestamp;
|
||||
packet->span = jitter->tick_size;
|
||||
jitter->pointer_timestamp += chunk_size;
|
||||
packet->len = 0;
|
||||
return JITTER_BUFFER_MISSING;
|
||||
|
||||
}
|
||||
|
||||
/** Get pointer timestamp of jitter buffer */
|
||||
int jitter_buffer_get_pointer_timestamp(JitterBuffer *jitter)
|
||||
{
|
||||
return jitter->pointer_timestamp;
|
||||
}
|
||||
|
||||
void jitter_buffer_tick(JitterBuffer *jitter)
|
||||
{
|
||||
jitter->current_timestamp += jitter->tick_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate)
|
||||
{
|
||||
jitter->dec = decoder;
|
||||
speex_decoder_ctl(decoder, SPEEX_GET_FRAME_SIZE, &jitter->frame_size);
|
||||
|
||||
jitter->packets = jitter_buffer_init(jitter->frame_size);
|
||||
|
||||
speex_bits_init(&jitter->current_packet);
|
||||
jitter->valid_bits = 0;
|
||||
|
||||
}
|
||||
|
||||
void speex_jitter_destroy(SpeexJitter *jitter)
|
||||
{
|
||||
jitter_buffer_destroy(jitter->packets);
|
||||
speex_bits_destroy(&jitter->current_packet);
|
||||
}
|
||||
|
||||
void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp)
|
||||
{
|
||||
JitterBufferPacket p;
|
||||
p.data = packet;
|
||||
p.len = len;
|
||||
p.timestamp = timestamp;
|
||||
p.span = jitter->frame_size;
|
||||
jitter_buffer_put(jitter->packets, &p);
|
||||
}
|
||||
|
||||
void speex_jitter_get(SpeexJitter *jitter, short *out, int *current_timestamp)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
char data[2048];
|
||||
JitterBufferPacket packet;
|
||||
packet.data = data;
|
||||
|
||||
if (jitter->valid_bits)
|
||||
{
|
||||
/* Try decoding last received packet */
|
||||
ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
|
||||
if (ret == 0)
|
||||
{
|
||||
jitter_buffer_tick(jitter->packets);
|
||||
return;
|
||||
} else {
|
||||
jitter->valid_bits = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ret = jitter_buffer_get(jitter->packets, &packet, NULL);
|
||||
|
||||
if (ret != JITTER_BUFFER_OK)
|
||||
{
|
||||
/* No packet found */
|
||||
|
||||
/*fprintf (stderr, "lost/late frame\n");*/
|
||||
/*Packet is late or lost*/
|
||||
speex_decode_int(jitter->dec, NULL, out);
|
||||
} else {
|
||||
speex_bits_read_from(&jitter->current_packet, packet.data, packet.len);
|
||||
/* Decode packet */
|
||||
ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
|
||||
if (ret == 0)
|
||||
{
|
||||
jitter->valid_bits = 1;
|
||||
} else {
|
||||
/* Error while decoding */
|
||||
for (i=0;i<jitter->frame_size;i++)
|
||||
out[i]=0;
|
||||
}
|
||||
}
|
||||
jitter_buffer_tick(jitter->packets);
|
||||
}
|
||||
|
||||
int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter)
|
||||
{
|
||||
return jitter_buffer_get_pointer_timestamp(jitter->packets);
|
||||
}
|
|
@ -1,434 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2003-2004, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "_kiss_fft_guts.h"
|
||||
#include "misc.h"
|
||||
|
||||
/* The guts header contains all the multiplication and addition macros that are defined for
|
||||
fixed or floating point complex numbers. It also delares the kf_ internal functions.
|
||||
*/
|
||||
|
||||
static kiss_fft_cpx *scratchbuf=NULL;
|
||||
static size_t nscratchbuf=0;
|
||||
static kiss_fft_cpx *tmpbuf=NULL;
|
||||
static size_t ntmpbuf=0;
|
||||
|
||||
#define CHECKBUF(buf,nbuf,n) \
|
||||
do { \
|
||||
if ( nbuf < (size_t)(n) ) {\
|
||||
speex_free(buf); \
|
||||
buf = (kiss_fft_cpx*)KISS_FFT_MALLOC(sizeof(kiss_fft_cpx)*(n)); \
|
||||
nbuf = (size_t)(n); \
|
||||
} \
|
||||
}while(0)
|
||||
|
||||
static void kf_bfly2(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx * Fout2;
|
||||
kiss_fft_cpx * tw1 = st->twiddles;
|
||||
kiss_fft_cpx t;
|
||||
Fout2 = Fout + m;
|
||||
if (!st->inverse) {
|
||||
int i;
|
||||
kiss_fft_cpx *x=Fout;
|
||||
for (i=0;i<2*m;i++)
|
||||
{
|
||||
x[i].r = SHR(x[i].r,1);
|
||||
x[i].i = SHR(x[i].i,1);
|
||||
}
|
||||
}
|
||||
|
||||
do{
|
||||
C_MUL (t, *Fout2 , *tw1);
|
||||
tw1 += fstride;
|
||||
C_SUB( *Fout2 , *Fout , t );
|
||||
C_ADDTO( *Fout , t );
|
||||
++Fout2;
|
||||
++Fout;
|
||||
}while (--m);
|
||||
}
|
||||
|
||||
static void kf_bfly4(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
const size_t m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx *tw1,*tw2,*tw3;
|
||||
kiss_fft_cpx scratch[6];
|
||||
size_t k=m;
|
||||
const size_t m2=2*m;
|
||||
const size_t m3=3*m;
|
||||
|
||||
tw3 = tw2 = tw1 = st->twiddles;
|
||||
|
||||
if (!st->inverse) {
|
||||
int i;
|
||||
kiss_fft_cpx *x=Fout;
|
||||
for (i=0;i<4*m;i++)
|
||||
{
|
||||
x[i].r = PSHR16(x[i].r,2);
|
||||
x[i].i = PSHR16(x[i].i,2);
|
||||
}
|
||||
}
|
||||
if (st->inverse)
|
||||
{
|
||||
do {
|
||||
C_MUL(scratch[0],Fout[m] , *tw1 );
|
||||
C_MUL(scratch[1],Fout[m2] , *tw2 );
|
||||
C_MUL(scratch[2],Fout[m3] , *tw3 );
|
||||
|
||||
C_SUB( scratch[5] , *Fout, scratch[1] );
|
||||
C_ADDTO(*Fout, scratch[1]);
|
||||
C_ADD( scratch[3] , scratch[0] , scratch[2] );
|
||||
C_SUB( scratch[4] , scratch[0] , scratch[2] );
|
||||
C_SUB( Fout[m2], *Fout, scratch[3] );
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
tw3 += fstride*3;
|
||||
C_ADDTO( *Fout , scratch[3] );
|
||||
|
||||
Fout[m].r = scratch[5].r - scratch[4].i;
|
||||
Fout[m].i = scratch[5].i + scratch[4].r;
|
||||
Fout[m3].r = scratch[5].r + scratch[4].i;
|
||||
Fout[m3].i = scratch[5].i - scratch[4].r;
|
||||
++Fout;
|
||||
} while(--k);
|
||||
} else
|
||||
{
|
||||
do {
|
||||
C_MUL(scratch[0],Fout[m] , *tw1 );
|
||||
C_MUL(scratch[1],Fout[m2] , *tw2 );
|
||||
C_MUL(scratch[2],Fout[m3] , *tw3 );
|
||||
|
||||
C_SUB( scratch[5] , *Fout, scratch[1] );
|
||||
C_ADDTO(*Fout, scratch[1]);
|
||||
C_ADD( scratch[3] , scratch[0] , scratch[2] );
|
||||
C_SUB( scratch[4] , scratch[0] , scratch[2] );
|
||||
C_SUB( Fout[m2], *Fout, scratch[3] );
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
tw3 += fstride*3;
|
||||
C_ADDTO( *Fout , scratch[3] );
|
||||
|
||||
Fout[m].r = scratch[5].r + scratch[4].i;
|
||||
Fout[m].i = scratch[5].i - scratch[4].r;
|
||||
Fout[m3].r = scratch[5].r - scratch[4].i;
|
||||
Fout[m3].i = scratch[5].i + scratch[4].r;
|
||||
++Fout;
|
||||
}while(--k);
|
||||
}
|
||||
}
|
||||
|
||||
static void kf_bfly3(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
size_t m
|
||||
)
|
||||
{
|
||||
size_t k=m;
|
||||
const size_t m2 = 2*m;
|
||||
kiss_fft_cpx *tw1,*tw2;
|
||||
kiss_fft_cpx scratch[5];
|
||||
kiss_fft_cpx epi3;
|
||||
epi3 = st->twiddles[fstride*m];
|
||||
|
||||
tw1=tw2=st->twiddles;
|
||||
|
||||
do{
|
||||
if (!st->inverse) {
|
||||
C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3);
|
||||
}
|
||||
|
||||
C_MUL(scratch[1],Fout[m] , *tw1);
|
||||
C_MUL(scratch[2],Fout[m2] , *tw2);
|
||||
|
||||
C_ADD(scratch[3],scratch[1],scratch[2]);
|
||||
C_SUB(scratch[0],scratch[1],scratch[2]);
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
|
||||
Fout[m].r = Fout->r - HALF_OF(scratch[3].r);
|
||||
Fout[m].i = Fout->i - HALF_OF(scratch[3].i);
|
||||
|
||||
C_MULBYSCALAR( scratch[0] , epi3.i );
|
||||
|
||||
C_ADDTO(*Fout,scratch[3]);
|
||||
|
||||
Fout[m2].r = Fout[m].r + scratch[0].i;
|
||||
Fout[m2].i = Fout[m].i - scratch[0].r;
|
||||
|
||||
Fout[m].r -= scratch[0].i;
|
||||
Fout[m].i += scratch[0].r;
|
||||
|
||||
++Fout;
|
||||
}while(--k);
|
||||
}
|
||||
|
||||
static void kf_bfly5(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
|
||||
int u;
|
||||
kiss_fft_cpx scratch[13];
|
||||
kiss_fft_cpx * twiddles = st->twiddles;
|
||||
kiss_fft_cpx *tw;
|
||||
kiss_fft_cpx ya,yb;
|
||||
ya = twiddles[fstride*m];
|
||||
yb = twiddles[fstride*2*m];
|
||||
|
||||
Fout0=Fout;
|
||||
Fout1=Fout0+m;
|
||||
Fout2=Fout0+2*m;
|
||||
Fout3=Fout0+3*m;
|
||||
Fout4=Fout0+4*m;
|
||||
|
||||
tw=st->twiddles;
|
||||
for ( u=0; u<m; ++u ) {
|
||||
if (!st->inverse) {
|
||||
C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5);
|
||||
}
|
||||
scratch[0] = *Fout0;
|
||||
|
||||
C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
|
||||
C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]);
|
||||
C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]);
|
||||
C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]);
|
||||
|
||||
C_ADD( scratch[7],scratch[1],scratch[4]);
|
||||
C_SUB( scratch[10],scratch[1],scratch[4]);
|
||||
C_ADD( scratch[8],scratch[2],scratch[3]);
|
||||
C_SUB( scratch[9],scratch[2],scratch[3]);
|
||||
|
||||
Fout0->r += scratch[7].r + scratch[8].r;
|
||||
Fout0->i += scratch[7].i + scratch[8].i;
|
||||
|
||||
scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r);
|
||||
scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r);
|
||||
|
||||
scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i);
|
||||
scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i);
|
||||
|
||||
C_SUB(*Fout1,scratch[5],scratch[6]);
|
||||
C_ADD(*Fout4,scratch[5],scratch[6]);
|
||||
|
||||
scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r);
|
||||
scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r);
|
||||
scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i);
|
||||
scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i);
|
||||
|
||||
C_ADD(*Fout2,scratch[11],scratch[12]);
|
||||
C_SUB(*Fout3,scratch[11],scratch[12]);
|
||||
|
||||
++Fout0;++Fout1;++Fout2;++Fout3;++Fout4;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform the butterfly for one stage of a mixed radix FFT */
|
||||
static void kf_bfly_generic(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m,
|
||||
int p
|
||||
)
|
||||
{
|
||||
int u,k,q1,q;
|
||||
kiss_fft_cpx * twiddles = st->twiddles;
|
||||
kiss_fft_cpx t;
|
||||
int Norig = st->nfft;
|
||||
|
||||
CHECKBUF(scratchbuf,nscratchbuf,p);
|
||||
|
||||
for ( u=0; u<m; ++u ) {
|
||||
k=u;
|
||||
for ( q1=0 ; q1<p ; ++q1 ) {
|
||||
scratchbuf[q1] = Fout[ k ];
|
||||
if (!st->inverse) {
|
||||
C_FIXDIV(scratchbuf[q1],p);
|
||||
}
|
||||
k += m;
|
||||
}
|
||||
|
||||
k=u;
|
||||
for ( q1=0 ; q1<p ; ++q1 ) {
|
||||
int twidx=0;
|
||||
Fout[ k ] = scratchbuf[0];
|
||||
for (q=1;q<p;++q ) {
|
||||
twidx += fstride * k;
|
||||
if (twidx>=Norig) twidx-=Norig;
|
||||
C_MUL(t,scratchbuf[q] , twiddles[twidx] );
|
||||
C_ADDTO( Fout[ k ] ,t);
|
||||
}
|
||||
k += m;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void kf_work(
|
||||
kiss_fft_cpx * Fout,
|
||||
const kiss_fft_cpx * f,
|
||||
const size_t fstride,
|
||||
int in_stride,
|
||||
int * factors,
|
||||
const kiss_fft_cfg st
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx * Fout_beg=Fout;
|
||||
const int p=*factors++; /* the radix */
|
||||
const int m=*factors++; /* stage's fft length/p */
|
||||
const kiss_fft_cpx * Fout_end = Fout + p*m;
|
||||
|
||||
if (m==1) {
|
||||
do{
|
||||
*Fout = *f;
|
||||
f += fstride*in_stride;
|
||||
}while(++Fout != Fout_end );
|
||||
}else{
|
||||
do{
|
||||
kf_work( Fout , f, fstride*p, in_stride, factors,st);
|
||||
f += fstride*in_stride;
|
||||
}while( (Fout += m) != Fout_end );
|
||||
}
|
||||
|
||||
Fout=Fout_beg;
|
||||
|
||||
switch (p) {
|
||||
case 2: kf_bfly2(Fout,fstride,st,m); break;
|
||||
case 3: kf_bfly3(Fout,fstride,st,m); break;
|
||||
case 4: kf_bfly4(Fout,fstride,st,m); break;
|
||||
case 5: kf_bfly5(Fout,fstride,st,m); break;
|
||||
default: kf_bfly_generic(Fout,fstride,st,m,p); break;
|
||||
}
|
||||
}
|
||||
|
||||
/* facbuf is populated by p1,m1,p2,m2, ...
|
||||
where
|
||||
p[i] * m[i] = m[i-1]
|
||||
m0 = n */
|
||||
static
|
||||
void kf_factor(int n,int * facbuf)
|
||||
{
|
||||
int p=4;
|
||||
|
||||
/*factor out powers of 4, powers of 2, then any remaining primes */
|
||||
do {
|
||||
while (n % p) {
|
||||
switch (p) {
|
||||
case 4: p = 2; break;
|
||||
case 2: p = 3; break;
|
||||
default: p += 2; break;
|
||||
}
|
||||
if (p>32000 || (spx_int32_t)p*(spx_int32_t)p > n)
|
||||
p = n; /* no more factors, skip to end */
|
||||
}
|
||||
n /= p;
|
||||
*facbuf++ = p;
|
||||
*facbuf++ = n;
|
||||
} while (n > 1);
|
||||
}
|
||||
/*
|
||||
*
|
||||
* User-callable function to allocate all necessary storage space for the fft.
|
||||
*
|
||||
* The return value is a contiguous block of memory, allocated with malloc. As such,
|
||||
* It can be freed with free(), rather than a kiss_fft-specific function.
|
||||
* */
|
||||
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem )
|
||||
{
|
||||
kiss_fft_cfg st=NULL;
|
||||
size_t memneeded = sizeof(struct kiss_fft_state)
|
||||
+ sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/
|
||||
|
||||
if ( lenmem==NULL ) {
|
||||
st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded );
|
||||
}else{
|
||||
if (mem != NULL && *lenmem >= memneeded)
|
||||
st = (kiss_fft_cfg)mem;
|
||||
*lenmem = memneeded;
|
||||
}
|
||||
if (st) {
|
||||
int i;
|
||||
st->nfft=nfft;
|
||||
st->inverse = inverse_fft;
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<nfft;++i) {
|
||||
spx_word32_t phase = i;
|
||||
if (!st->inverse)
|
||||
phase = -phase;
|
||||
kf_cexp2(st->twiddles+i, DIV32(SHL32(phase,17),nfft));
|
||||
}
|
||||
#else
|
||||
for (i=0;i<nfft;++i) {
|
||||
const double pi=3.14159265358979323846264338327;
|
||||
double phase = ( -2*pi /nfft ) * i;
|
||||
if (st->inverse)
|
||||
phase *= -1;
|
||||
kf_cexp(st->twiddles+i, phase );
|
||||
}
|
||||
#endif
|
||||
kf_factor(nfft,st->factors);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride)
|
||||
{
|
||||
if (fin == fout) {
|
||||
CHECKBUF(tmpbuf,ntmpbuf,st->nfft);
|
||||
kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
|
||||
speex_move(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);
|
||||
}else{
|
||||
kf_work( fout, fin, 1,in_stride, st->factors,st );
|
||||
}
|
||||
}
|
||||
|
||||
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout)
|
||||
{
|
||||
kiss_fft_stride(cfg,fin,fout,1);
|
||||
}
|
||||
|
||||
|
||||
/* not really necessary to call, but if someone is doing in-place ffts, they may want to free the
|
||||
buffers from CHECKBUF
|
||||
*/
|
||||
void kiss_fft_cleanup(void)
|
||||
{
|
||||
speex_free(scratchbuf);
|
||||
scratchbuf = NULL;
|
||||
nscratchbuf=0;
|
||||
speex_free(tmpbuf);
|
||||
tmpbuf=NULL;
|
||||
ntmpbuf=0;
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
#ifndef KISS_FFT_H
|
||||
#define KISS_FFT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
ATTENTION!
|
||||
If you would like a :
|
||||
-- a utility that will handle the caching of fft objects
|
||||
-- real-only (no imaginary time component ) FFT
|
||||
-- a multi-dimensional FFT
|
||||
-- a command-line utility to perform ffts
|
||||
-- a command-line utility to perform fast-convolution filtering
|
||||
|
||||
Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
|
||||
in the tools/ directory.
|
||||
*/
|
||||
|
||||
#ifdef USE_SIMD
|
||||
# include <xmmintrin.h>
|
||||
# define kiss_fft_scalar __m128
|
||||
#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
|
||||
#else
|
||||
#define KISS_FFT_MALLOC speex_alloc
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#include "misc.h"
|
||||
# define kiss_fft_scalar spx_int16_t
|
||||
#else
|
||||
# ifndef kiss_fft_scalar
|
||||
/* default is float */
|
||||
# define kiss_fft_scalar float
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
kiss_fft_scalar r;
|
||||
kiss_fft_scalar i;
|
||||
}kiss_fft_cpx;
|
||||
|
||||
typedef struct kiss_fft_state* kiss_fft_cfg;
|
||||
|
||||
/*
|
||||
* kiss_fft_alloc
|
||||
*
|
||||
* Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
|
||||
*
|
||||
* typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
|
||||
*
|
||||
* The return value from fft_alloc is a cfg buffer used internally
|
||||
* by the fft routine or NULL.
|
||||
*
|
||||
* If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
|
||||
* The returned value should be free()d when done to avoid memory leaks.
|
||||
*
|
||||
* The state can be placed in a user supplied buffer 'mem':
|
||||
* If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
|
||||
* then the function places the cfg in mem and the size used in *lenmem
|
||||
* and returns mem.
|
||||
*
|
||||
* If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
|
||||
* then the function returns NULL and places the minimum cfg
|
||||
* buffer size in *lenmem.
|
||||
* */
|
||||
|
||||
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
|
||||
|
||||
/*
|
||||
* kiss_fft(cfg,in_out_buf)
|
||||
*
|
||||
* Perform an FFT on a complex input buffer.
|
||||
* for a forward FFT,
|
||||
* fin should be f[0] , f[1] , ... ,f[nfft-1]
|
||||
* fout will be F[0] , F[1] , ... ,F[nfft-1]
|
||||
* Note that each element is complex and can be accessed like
|
||||
f[k].r and f[k].i
|
||||
* */
|
||||
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
|
||||
|
||||
/*
|
||||
A more generic version of the above function. It reads its input from every Nth sample.
|
||||
* */
|
||||
void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
|
||||
|
||||
/* If kiss_fft_alloc allocated a buffer, it is one contiguous
|
||||
buffer and can be simply free()d when no longer needed*/
|
||||
#define kiss_fft_free speex_free
|
||||
|
||||
/*
|
||||
Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
|
||||
your compiler output to call this before you exit.
|
||||
*/
|
||||
void kiss_fft_cleanup(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,170 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2003-2004, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "kiss_fftr.h"
|
||||
#include "_kiss_fft_guts.h"
|
||||
|
||||
struct kiss_fftr_state{
|
||||
kiss_fft_cfg substate;
|
||||
kiss_fft_cpx * tmpbuf;
|
||||
kiss_fft_cpx * super_twiddles;
|
||||
#ifdef USE_SIMD
|
||||
long pad;
|
||||
#endif
|
||||
};
|
||||
|
||||
kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
|
||||
{
|
||||
int i;
|
||||
kiss_fftr_cfg st = NULL;
|
||||
size_t subsize, memneeded;
|
||||
|
||||
if (nfft & 1) {
|
||||
speex_warning("Real FFT optimization must be even.\n");
|
||||
return NULL;
|
||||
}
|
||||
nfft >>= 1;
|
||||
|
||||
kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize);
|
||||
memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 2);
|
||||
|
||||
if (lenmem == NULL) {
|
||||
st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded);
|
||||
} else {
|
||||
if (*lenmem >= memneeded)
|
||||
st = (kiss_fftr_cfg) mem;
|
||||
*lenmem = memneeded;
|
||||
}
|
||||
if (!st)
|
||||
return NULL;
|
||||
|
||||
st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */
|
||||
st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize);
|
||||
st->super_twiddles = st->tmpbuf + nfft;
|
||||
kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<nfft;++i) {
|
||||
spx_word32_t phase = i+(nfft>>1);
|
||||
if (!inverse_fft)
|
||||
phase = -phase;
|
||||
kf_cexp2(st->super_twiddles+i, DIV32(SHL32(phase,16),nfft));
|
||||
}
|
||||
#else
|
||||
for (i=0;i<nfft;++i) {
|
||||
const double pi=3.14159265358979323846264338327;
|
||||
double phase = pi*(((double)i) /nfft + .5);
|
||||
if (!inverse_fft)
|
||||
phase = -phase;
|
||||
kf_cexp(st->super_twiddles+i, phase );
|
||||
}
|
||||
#endif
|
||||
return st;
|
||||
}
|
||||
|
||||
void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata)
|
||||
{
|
||||
/* input buffer timedata is stored row-wise */
|
||||
int k,ncfft;
|
||||
kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
|
||||
|
||||
if ( st->substate->inverse) {
|
||||
speex_error("kiss fft usage error: improper alloc\n");
|
||||
}
|
||||
|
||||
ncfft = st->substate->nfft;
|
||||
|
||||
/*perform the parallel fft of two real signals packed in real,imag*/
|
||||
kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf );
|
||||
/* The real part of the DC element of the frequency spectrum in st->tmpbuf
|
||||
* contains the sum of the even-numbered elements of the input time sequence
|
||||
* The imag part is the sum of the odd-numbered elements
|
||||
*
|
||||
* The sum of tdc.r and tdc.i is the sum of the input time sequence.
|
||||
* yielding DC of input time sequence
|
||||
* The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1...
|
||||
* yielding Nyquist bin of input time sequence
|
||||
*/
|
||||
|
||||
tdc.r = st->tmpbuf[0].r;
|
||||
tdc.i = st->tmpbuf[0].i;
|
||||
C_FIXDIV(tdc,2);
|
||||
CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i);
|
||||
CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i);
|
||||
freqdata[0].r = tdc.r + tdc.i;
|
||||
freqdata[ncfft].r = tdc.r - tdc.i;
|
||||
#ifdef USE_SIMD
|
||||
freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0);
|
||||
#else
|
||||
freqdata[ncfft].i = freqdata[0].i = 0;
|
||||
#endif
|
||||
|
||||
for ( k=1;k <= ncfft/2 ; ++k ) {
|
||||
fpk = st->tmpbuf[k];
|
||||
fpnk.r = st->tmpbuf[ncfft-k].r;
|
||||
fpnk.i = - st->tmpbuf[ncfft-k].i;
|
||||
C_FIXDIV(fpk,2);
|
||||
C_FIXDIV(fpnk,2);
|
||||
|
||||
C_ADD( f1k, fpk , fpnk );
|
||||
C_SUB( f2k, fpk , fpnk );
|
||||
C_MUL( tw , f2k , st->super_twiddles[k]);
|
||||
|
||||
freqdata[k].r = HALF_OF(f1k.r + tw.r);
|
||||
freqdata[k].i = HALF_OF(f1k.i + tw.i);
|
||||
freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r);
|
||||
freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i);
|
||||
}
|
||||
}
|
||||
|
||||
void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata)
|
||||
{
|
||||
/* input buffer timedata is stored row-wise */
|
||||
int k, ncfft;
|
||||
|
||||
if (st->substate->inverse == 0) {
|
||||
speex_error ("kiss fft usage error: improper alloc\n");
|
||||
}
|
||||
|
||||
ncfft = st->substate->nfft;
|
||||
|
||||
st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r;
|
||||
st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r;
|
||||
/*C_FIXDIV(st->tmpbuf[0],2);*/
|
||||
|
||||
for (k = 1; k <= ncfft / 2; ++k) {
|
||||
kiss_fft_cpx fk, fnkc, fek, fok, tmp;
|
||||
fk = freqdata[k];
|
||||
fnkc.r = freqdata[ncfft - k].r;
|
||||
fnkc.i = -freqdata[ncfft - k].i;
|
||||
/*C_FIXDIV( fk , 2 );
|
||||
C_FIXDIV( fnkc , 2 );*/
|
||||
|
||||
C_ADD (fek, fk, fnkc);
|
||||
C_SUB (tmp, fk, fnkc);
|
||||
C_MUL (fok, tmp, st->super_twiddles[k]);
|
||||
C_ADD (st->tmpbuf[k], fek, fok);
|
||||
C_SUB (st->tmpbuf[ncfft - k], fek, fok);
|
||||
#ifdef USE_SIMD
|
||||
st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0);
|
||||
#else
|
||||
st->tmpbuf[ncfft - k].i *= -1;
|
||||
#endif
|
||||
}
|
||||
kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#ifndef KISS_FTR_H
|
||||
#define KISS_FTR_H
|
||||
|
||||
#include "kiss_fft.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Real optimized version can save about 45% cpu time vs. complex fft of a real seq.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
typedef struct kiss_fftr_state *kiss_fftr_cfg;
|
||||
|
||||
|
||||
kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem);
|
||||
/*
|
||||
nfft must be even
|
||||
|
||||
If you don't care to allocate space, use mem = lenmem = NULL
|
||||
*/
|
||||
|
||||
|
||||
void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata);
|
||||
/*
|
||||
input timedata has nfft scalar points
|
||||
output freqdata has nfft/2+1 complex points
|
||||
*/
|
||||
|
||||
void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata);
|
||||
/*
|
||||
input freqdata has nfft/2+1 complex points
|
||||
output timedata has nfft scalar points
|
||||
*/
|
||||
|
||||
#define kiss_fftr_free speex_free
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,678 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: lbr_48k_tables.c
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
|
||||
const int dummy_epic_48k_variable=0;
|
||||
#ifdef EPIC_48K
|
||||
|
||||
const signed char gain_cdbk_ulbr[192] = {
|
||||
-31, -48, -30,
|
||||
-19, -10, -18,
|
||||
-33, -22, -45,
|
||||
-5, -56, -43,
|
||||
-30, -56, -3,
|
||||
-59, -17, -52,
|
||||
-41, -60, -58,
|
||||
-64, -47, -22,
|
||||
-30, -31, -31,
|
||||
-29, -14, -31,
|
||||
-22, -37, -58,
|
||||
-31, -44, 13,
|
||||
-37, 0, 1,
|
||||
-46, -55, -35,
|
||||
-56, -14, -53,
|
||||
-8, 1, -36,
|
||||
-29, -15, -27,
|
||||
-29, -39, -28,
|
||||
-43, -5, 3,
|
||||
-51, -27, -54,
|
||||
10, -46, -36,
|
||||
3, -3, -42,
|
||||
-27, 16, -22,
|
||||
-34, -52, 13,
|
||||
-31, -21, -28,
|
||||
-34, -45, -40,
|
||||
-20, -48, 4,
|
||||
-40, -27, 16,
|
||||
-6, 11, -44,
|
||||
-35, 12, -5,
|
||||
19, -33, -37,
|
||||
-29, 18, -32,
|
||||
-29, -23, -19,
|
||||
16, -47, -28,
|
||||
-34, -30, 17,
|
||||
-20, 2, -26,
|
||||
-38, -40, -36,
|
||||
15, -14, -40,
|
||||
-39, 14, -9,
|
||||
-15, 25, -39,
|
||||
-26, 19, -32,
|
||||
-39, 17, -14,
|
||||
10, -36, -26,
|
||||
14, -13, -40,
|
||||
-29, -21, -12,
|
||||
-8, 19, -39,
|
||||
-36, -18, 15,
|
||||
-32, -38, -38,
|
||||
-19, 4, -23,
|
||||
-38, -7, 11,
|
||||
9, -10, -39,
|
||||
-37, 24, -19,
|
||||
-34, -5, -8,
|
||||
-20, 23, -41,
|
||||
-4, 17, -31,
|
||||
-17, -26, -26,
|
||||
-24, 28, -36,
|
||||
-7, 15, -39,
|
||||
-42, 16, -11,
|
||||
-29, 14, -6,
|
||||
-36, 28, -27,
|
||||
-21, 5, -26,
|
||||
11, -9, -39,
|
||||
-38, -7, 13,
|
||||
};
|
||||
|
||||
|
||||
const signed char exc_12_32_table[384] = {
|
||||
34, 55, 9, 55, 4, 44, -2, 25, 4, -6, 13, -22,
|
||||
20, 26, -13, -56, -37, 18, 5, 28, 4, 10, 6, -7,
|
||||
37, -24, -31, 22, 12, -6, -4, -7, 2, 0, -3, -2,
|
||||
-16, -13, -1, 9, -2, 4, 6, 5, -3, 3, 8, -1,
|
||||
-1, -6, -2, -1, 8, 24, 19, 33, -73, -53, 6, -18,
|
||||
14, 7, 11, 8, -33, -94, -5, 7, 0, 44, 1, 19,
|
||||
-9, -7, -34, -16, 8, 2, 5, 0, 3, 1, -2, 3,
|
||||
-22, 6, -2, 12, 16, 30, 39, 25, 25, 2, 10, -2,
|
||||
-1, -40, -6, -51, -5, -48, -9, -33, -14, -1, -24, 15,
|
||||
104, 39, 12, -9, -20, -12, -30, -10, -31, -7, -30, -8,
|
||||
-71, -53, -4, -11, 9, -10, 7, -10, 10, -1, 11, 8,
|
||||
24, 14, 6, -3, 10, 8, 8, 11, -6, 11, 0, -2,
|
||||
-6, -2, 1, -1, -3, 8, -41, 27, 57, -7, 11, -16,
|
||||
-61, 50, 10, -10, 4, -13, 14, -7, 1, 5, -4, 4,
|
||||
0, 2, -1, -2, -1, 1, 1, 0, -1, -1, -2, -3,
|
||||
-3, -15, 69, 60, 10, -10, -10, -29, -21, -7, -16, 2,
|
||||
24, -32, 24, -18, -14, -2, -11, 11, -6, 10, 1, 3,
|
||||
24, -10, 14, 18, -13, 17, -16, 4, -3, -21, -3, -11,
|
||||
-19, 12, -14, 26, 20, -9, 24, -15, 18, 1, -32, -2,
|
||||
-1, 8, -3, 4, 11, -47, 7, 46, -4, -10, -10, -2,
|
||||
-24, 29, -33, 6, -20, -3, 0, -12, 5, -30, 8, -13,
|
||||
28, 9, 5, -11, 0, -14, -13, -22, -12, -8, -4, 1,
|
||||
-6, 28, 45, -18, -31, -5, 1, 2, 1, 5, 0, -3,
|
||||
-19, -10, 10, 27, 8, -16, -28, -9, 2, -5, 8, -1,
|
||||
100, -49, 4, -43, 25, -7, 1, 9, -13, 13, -18, 13,
|
||||
-1, -1, 0, 2, -2, -8, 9, -46, -7, 70, 23, 7,
|
||||
-103, 20, 8, 42, -5, 21, -4, 4, 1, -8, 16, -8,
|
||||
3, 3, 8, 4, 7, -3, -3, -4, 9, 6, 2, 13,
|
||||
6, 3, -15, 11, -43, 31, 40, -13, 12, -21, -2, -3,
|
||||
-10, -9, 16, -35, 31, -3, -12, 8, -34, 7, 12, 22,
|
||||
-3, -4, -7, -12, 24, 53, -19, -43, 4, -3, -4, 6,
|
||||
-18, -30, -58, -17, -11, 17, 23, 34, 30, 28, 28, 15,
|
||||
};
|
||||
|
||||
|
||||
const signed char cdbk_lsp_vlbr[5120]={
|
||||
23, 34, 108, 100, 102, 82, 69, 48, 52, 25,
|
||||
0, -37, -55, -78, -111, -79, 58, 57, 45, 32,
|
||||
27, -9, -12, -14, -41, -29, -17, -41, 44, 35,
|
||||
-24, -68, -72, 61, 100, 73, 100, 80, 70, 37,
|
||||
12, -5, 22, 11, -10, -40, -33, -17, 19, 12,
|
||||
-20, -57, -94, -92, 56, 71, 48, 31, 22, -5,
|
||||
41, 28, 6, -6, -12, -39, -18, -16, -30, -23,
|
||||
65, 54, 41, 28, 23, 9, 26, 18, 22, 6,
|
||||
17, -16, -33, -54, -87, -79, 8, -8, 44, 35,
|
||||
-20, -62, -78, 22, 78, 47, 44, 33, 26, 14,
|
||||
8, 1, 45, 47, 72, 68, 55, 31, 36, 17,
|
||||
-27, -68, -86, -65, -10, 23, 8, -22, -31, 25,
|
||||
-4, -38, -55, -68, -96, -118, -39, 30, 28, 31,
|
||||
-21, -66, -47, 99, 91, 68, 78, 56, 64, 36,
|
||||
33, 22, 13, -13, -36, -22, 44, 37, 54, 33,
|
||||
-31, -76, -106, -100, -5, 21, 7, -17, 13, 48,
|
||||
-26, -65, -84, -84, -46, 67, 97, 66, 58, 31,
|
||||
-20, -52, -32, -20, 3, 16, 27, 40, 54, 29,
|
||||
-6, -35, -56, -64, -8, -31, -36, 21, 26, -3,
|
||||
32, 23, 1, -23, -19, -44, -45, -7, 10, -10,
|
||||
-24, -55, 2, 67, 72, 85, 90, 74, 77, 45,
|
||||
-21, -58, -45, -49, 16, 34, 13, -15, -16, 16,
|
||||
8, -31, -34, -61, -83, 10, 24, 8, 56, 25,
|
||||
-8, -49, -74, -95, -123, -77, 6, 40, 46, 42,
|
||||
-21, -60, -59, -34, -12, 27, 8, -19, -48, -17,
|
||||
-25, -66, -78, -73, -81, -16, 14, 0, -2, 33,
|
||||
78, 79, 69, 49, 44, 32, 50, 44, 46, 22,
|
||||
24, 9, -4, -18, -37, -56, 22, 34, 22, 11,
|
||||
-19, -59, -85, -41, 46, 72, 60, 33, 29, -3,
|
||||
-21, -66, -70, 65, 92, 57, 61, 41, 40, 23,
|
||||
-4, -41, -60, -72, -102, -106, 4, 56, 57, 31,
|
||||
-5, -48, -62, -91, -109, 1, 76, 54, 72, 39,
|
||||
-21, -61, -86, -46, -34, -39, 42, 25, 15, 12,
|
||||
5, -16, -36, -56, 5, 18, 11, 13, 52, 23,
|
||||
12, -6, 30, 40, 59, 40, 27, 8, 19, 6,
|
||||
25, 8, -9, -19, -25, -53, -40, -38, -46, -4,
|
||||
-17, -59, -83, 2, 58, 29, 18, -2, -17, -5,
|
||||
-35, -80, -111, -117, -41, -9, 14, 23, 36, 56,
|
||||
48, 67, 93, 71, 77, 91, 110, 95, 83, 47,
|
||||
-25, -62, -97, -93, 76, 96, 73, 52, 61, 28,
|
||||
-9, -55, -46, 49, 33, 8, 1, -25, 28, 23,
|
||||
-10, -47, -60, -45, -62, -58, 56, 57, 48, 28,
|
||||
34, 12, -9, 0, 34, 4, 6, 11, 3, -18,
|
||||
21, -9, -16, -13, -39, -41, 14, -8, 33, 28,
|
||||
-7, -49, -61, 15, 34, 3, 2, -13, -28, -17,
|
||||
-14, -50, -46, -65, -76, -13, -10, -29, -30, 22,
|
||||
-28, -68, -97, -98, -8, 38, 36, 26, 25, 15,
|
||||
6, -33, -9, 1, -28, -11, -19, -24, 61, 36,
|
||||
-15, -60, -19, 81, 58, 52, 42, 28, 66, 36,
|
||||
-15, -52, -71, -15, 11, -13, 38, 28, 11, -4,
|
||||
34, 1, -9, -27, -57, -19, 36, 6, 14, 0,
|
||||
-1, -43, -14, 16, -12, -5, -14, -29, -33, -32,
|
||||
-13, -57, -75, -100, -111, 1, 2, 13, 48, 33,
|
||||
12, 16, 100, 85, 69, 49, 40, 29, 46, 23,
|
||||
-4, -26, -41, -44, -7, -26, -39, -27, 18, 0,
|
||||
-4, -47, -51, 17, 7, -19, 13, -10, -16, 9,
|
||||
-24, -63, -93, -53, 25, 14, 73, 51, 35, 8,
|
||||
-34, -77, -106, -83, -51, -47, 2, 12, 41, 53,
|
||||
-13, -47, -67, -44, 42, 20, 24, 33, 21, -3,
|
||||
11, -15, -29, -51, -79, -88, 22, 56, 43, 20,
|
||||
11, -22, -37, -1, 61, 40, 28, 24, 22, -6,
|
||||
-3, -33, -50, -66, -93, -100, -16, -16, 3, 41,
|
||||
-18, -58, -82, -5, 95, 78, 56, 39, 30, 1,
|
||||
-6, -47, -28, -26, -36, 49, 55, 51, 71, 35,
|
||||
-6, -50, -42, -4, -32, -1, -1, -18, 67, 40,
|
||||
-23, -63, -56, -48, -32, 0, -14, -43, -46, 25,
|
||||
-17, -61, -63, 13, -1, 28, 23, 10, 67, 36,
|
||||
45, 92, 124, 111, 108, 86, 77, 56, 57, 28,
|
||||
50, 35, 13, 3, -2, -32, 3, 14, 6, -8,
|
||||
12, -17, -24, -42, -67, -23, 67, 49, 64, 38,
|
||||
-21, -60, -90, -45, 32, 6, 7, -3, -15, 9,
|
||||
-16, -62, -73, 50, 46, 18, 7, -13, 63, 39,
|
||||
19, -16, -19, 20, 5, -15, 16, -9, 5, 8,
|
||||
-11, -46, -42, -39, -55, -68, -62, -27, -18, 23,
|
||||
-23, -61, -67, -71, -29, 44, 32, 10, -15, -12,
|
||||
-6, -45, -43, -40, -67, -22, 42, 19, 61, 38,
|
||||
9, -13, -38, -37, 40, 30, 15, 9, 11, -16,
|
||||
0, -18, -29, -34, -17, -44, -50, -3, 47, 15,
|
||||
-3, -46, -26, 20, -10, 16, 20, -2, 43, 18,
|
||||
-23, -46, 46, 91, 99, 100, 99, 79, 72, 42,
|
||||
-1, -44, -33, -36, -56, 22, 17, 4, 71, 37,
|
||||
0, -38, -49, 0, -1, -30, -21, -35, -44, -6,
|
||||
-32, -74, -101, -98, -14, -21, -23, 7, 26, 45,
|
||||
8, -28, -44, -63, -96, -84, 34, 21, 13, 23,
|
||||
10, -24, -38, -17, -29, -53, -16, -41, -14, 23,
|
||||
-19, -61, -76, -12, 97, 99, 79, 60, 59, 25,
|
||||
5, -11, -26, -54, -26, -8, -13, 3, 25, 4,
|
||||
17, 16, 4, -24, -1, 42, 60, 63, 70, 37,
|
||||
10, -27, -22, -43, -62, -7, -16, 10, 75, 40,
|
||||
-26, -64, -96, -106, -3, 73, 73, 46, 55, 29,
|
||||
-2, -45, -43, 45, 46, 17, 37, 10, 30, 32,
|
||||
21, -2, -18, -28, -47, -63, -38, -56, -3, 27,
|
||||
-17, -48, -9, 9, 3, 28, 50, 58, 73, 44,
|
||||
8, -14, -32, -56, -81, -106, -35, 41, 53, 26,
|
||||
1, -38, -51, -66, -100, -61, 32, 17, 66, 42,
|
||||
17, 5, -6, -21, -26, -52, -36, 23, 56, 22,
|
||||
6, -20, -31, -22, -19, -48, 16, 38, 22, -2,
|
||||
-25, -67, -93, -51, 82, 62, 71, 69, 63, 35,
|
||||
-12, -51, -71, -60, -76, -91, -14, 41, 35, 20,
|
||||
-16, -31, 22, 32, 55, 80, 98, 91, 85, 49,
|
||||
-21, -63, -92, -6, 57, 27, 36, 11, 60, 39,
|
||||
-7, -45, -67, -81, -114, -110, 0, 24, 23, 45,
|
||||
-18, -55, -61, -56, -60, -64, -32, -2, 58, 36,
|
||||
-3, -33, -51, -24, 19, -10, -19, 4, 14, -15,
|
||||
-19, -59, -81, -12, 7, -12, 36, 16, 48, 36,
|
||||
17, -13, -32, -49, -78, -95, -1, -3, -10, 25,
|
||||
15, 5, 41, 59, 108, 101, 103, 81, 70, 35,
|
||||
-14, -52, -37, 15, 93, 83, 66, 50, 47, 15,
|
||||
-3, -31, -49, -52, -9, -31, -10, 37, 62, 27,
|
||||
-15, -56, -82, -17, 75, 56, 36, 22, 7, -16,
|
||||
-24, -63, -93, -84, 25, 94, 98, 65, 60, 31,
|
||||
-2, -45, -39, -61, -61, 48, 35, 32, 54, 18,
|
||||
-19, -51, -45, -57, -28, -8, 10, 14, 38, 26,
|
||||
-2, -46, -38, 45, 26, 22, 48, 21, 63, 40,
|
||||
-22, -61, -73, -75, -67, -31, 13, 18, 51, 34,
|
||||
-12, -2, -1, -17, -3, -27, -3, 6, -1, -15,
|
||||
-16, -59, -78, 10, 36, 9, 4, -18, 33, 22,
|
||||
-25, -62, -97, -107, 39, 87, 69, 46, 42, 12,
|
||||
11, -7, -30, -36, 19, 2, -10, -7, -4, -24,
|
||||
11, -8, 25, 28, 28, 5, -4, -10, 5, -2,
|
||||
-10, -48, -37, -17, -38, -9, -2, -19, -30, -22,
|
||||
-23, -61, -79, -81, -2, 15, -4, 17, 20, 2,
|
||||
25, -14, -3, -10, -38, 1, 14, -14, -9, -27,
|
||||
2, -18, -38, -36, -11, -39, -36, -28, -36, -11,
|
||||
32, 59, 127, 124, 127, 108, 91, 68, 64, 34,
|
||||
3, -32, -37, -10, -25, -46, 12, 1, -17, -24,
|
||||
-29, -69, -102, -100, 2, -7, 11, 14, 1, 31,
|
||||
30, -6, -4, -16, -44, -5, 3, -9, 66, 40,
|
||||
-9, -45, -52, -5, 37, 19, 26, 6, 51, 32,
|
||||
-31, -73, -96, -45, -25, -37, -15, -16, 32, 39,
|
||||
3, -15, 18, 21, 28, 33, 58, 58, 69, 42,
|
||||
-31, -73, -99, -99, -48, 14, 21, 5, 2, 39,
|
||||
7, -35, -20, 29, 2, -8, -8, -28, 38, 26,
|
||||
-5, -39, -64, -36, 15, -15, -11, -21, -23, 5,
|
||||
-8, -51, -56, 15, -1, -14, -8, -31, 36, 22,
|
||||
-8, -53, -68, -98, -101, 42, 49, 38, 41, 12,
|
||||
10, -27, -22, 4, -23, -21, 30, -1, 22, 26,
|
||||
-13, -56, -42, 31, 9, -1, -10, -2, 22, -4,
|
||||
15, 8, 56, 57, 45, 55, 57, 46, 72, 44,
|
||||
-7, -53, -26, 53, 21, 17, 0, 0, 74, 41,
|
||||
3, -18, -2, 0, 19, 17, 42, 36, 47, 26,
|
||||
24, -7, -23, -34, -62, -60, 6, -22, 18, 25,
|
||||
-11, -42, -46, -61, -83, -99, -67, -11, 28, 39,
|
||||
30, -3, -10, -1, -24, -30, -1, -28, 15, 18,
|
||||
19, -15, -10, -6, -35, -26, 33, 10, 56, 39,
|
||||
-13, -53, -82, -42, 53, 37, 18, 10, -3, -21,
|
||||
-21, -60, -89, -46, 89, 94, 71, 46, 42, 9,
|
||||
-2, -34, -44, -46, -64, -84, -1, 37, 16, 0,
|
||||
-17, -51, -65, -64, -7, -17, -29, -11, 52, 27,
|
||||
22, -15, -16, -39, -55, 26, 36, 21, 62, 28,
|
||||
-2, -26, -38, -49, -55, -80, -75, 8, 20, 9,
|
||||
-6, -47, -61, -82, -103, -17, -15, -25, 53, 40,
|
||||
-8, -47, -66, -18, 56, 43, 25, 29, 39, 3,
|
||||
-27, -66, -86, -69, -50, -59, -34, -1, 19, 42,
|
||||
3, -20, 2, 21, 72, 57, 52, 36, 31, 7,
|
||||
-12, -49, -61, -13, -1, -33, 5, 37, 26, 2,
|
||||
-27, -69, -92, -62, 2, 43, 88, 67, 64, 36,
|
||||
0, -40, -4, -6, -20, 43, 33, 25, 50, 20,
|
||||
14, -20, -30, -44, -73, -37, -24, -47, 26, 20,
|
||||
31, 53, 111, 118, 127, 126, 121, 99, 85, 46,
|
||||
-14, -45, -51, -39, 24, 5, -6, 17, 46, 14,
|
||||
-4, -43, -45, -70, -63, 8, 14, 58, 78, 39,
|
||||
-8, -47, -66, -84, -114, -55, 10, -8, 32, 40,
|
||||
28, 22, 42, 26, 8, -21, -16, -6, 22, 10,
|
||||
24, 10, 34, 31, 35, 31, 46, 39, 59, 36,
|
||||
-4, -43, -62, -10, 20, -14, 2, 14, -6, -19,
|
||||
-21, -62, -89, -22, 62, 33, 30, 16, 15, 15,
|
||||
0, -22, -31, -45, -58, -80, -66, 13, 68, 34,
|
||||
-16, -45, -6, 7, -6, -17, -14, -15, 2, 2,
|
||||
10, -5, -22, -38, -40, -70, -60, -15, -23, 0,
|
||||
22, -11, -22, -39, -67, -25, 30, 5, 58, 37,
|
||||
-21, -47, 6, 43, 37, 45, 65, 66, 73, 43,
|
||||
2, -25, -40, -53, -72, -94, -35, 24, 9, 8,
|
||||
-3, 0, -3, -9, 4, -23, -10, 20, 43, 14,
|
||||
-2, -41, -60, -9, 57, 32, 17, 16, 6, -19,
|
||||
1, -31, -36, -36, -54, -68, -77, -75, 21, 37,
|
||||
-19, -32, 79, 90, 92, 81, 67, 47, 52, 28,
|
||||
-6, -36, -57, -62, 27, 40, 21, 11, 9, -19,
|
||||
-10, -47, -49, -59, -74, -18, -14, -30, 25, 18,
|
||||
-23, -69, -82, 60, 66, 40, 75, 54, 65, 38,
|
||||
-19, -57, -92, -68, 66, 58, 34, 18, 1, -16,
|
||||
-29, -68, -99, -88, -37, -38, 13, 8, 5, 40,
|
||||
-22, -63, -75, 14, 15, 7, 75, 58, 59, 34,
|
||||
-23, -62, -82, -39, -31, -53, -27, 5, -3, 20,
|
||||
13, -26, -20, 22, 2, -3, 35, 13, 54, 39,
|
||||
32, 5, -13, -22, -45, -58, -1, -20, -19, 7,
|
||||
30, 46, 70, 55, 89, 88, 91, 67, 56, 28,
|
||||
-13, -50, -63, -25, -28, -50, -23, -32, -34, 19,
|
||||
-13, -54, -65, -9, -20, -37, 29, 6, 11, 25,
|
||||
0, -40, -55, -78, -107, -25, 47, 20, 34, 16,
|
||||
-20, -58, -96, -103, 38, 43, 27, 30, 15, -1,
|
||||
-16, -49, -52, -66, -80, -57, -44, -39, 6, 38,
|
||||
0, -38, 5, 13, -8, 23, 24, 1, 7, -9,
|
||||
-18, -56, -64, -7, 38, 13, 11, 32, 28, 0,
|
||||
14, -3, -20, -17, 4, -26, -34, -8, 19, -9,
|
||||
-23, -60, -83, -38, -8, -32, 11, 19, -1, -5,
|
||||
-5, -47, -12, 56, 38, 22, 18, -8, -5, -8,
|
||||
18, -4, -24, -16, 27, 2, -6, 5, 25, -5,
|
||||
13, 0, -19, -35, -23, -45, -59, -30, 19, 3,
|
||||
19, -12, -23, 1, -7, -35, -14, -32, -23, 4,
|
||||
-23, -64, -67, -22, -27, -5, -5, -20, 20, 5,
|
||||
20, 11, 83, 92, 85, 89, 69, 53, 80, 48,
|
||||
15, -2, -21, -29, -18, -48, -52, -12, -11, -21,
|
||||
-6, -38, -55, -68, -9, 33, 22, 19, 25, -1,
|
||||
-8, -46, -49, -67, -64, 16, 8, -6, 32, 15,
|
||||
3, -25, -46, -46, 39, 50, 34, 21, 46, 14,
|
||||
8, -33, -37, -68, -82, 31, 34, 13, 19, -6,
|
||||
33, 0, 5, -7, -32, 2, 22, -3, 35, 17,
|
||||
-23, -62, -91, -64, 6, 3, 36, 26, 7, -3,
|
||||
-12, -54, -60, 26, 46, 16, 30, 22, 8, -4,
|
||||
-23, -61, -40, 31, 58, 73, 88, 77, 74, 41,
|
||||
-2, -42, -49, 13, 5, -15, 22, -4, 26, 27,
|
||||
-13, -54, -39, 18, 2, -8, -12, 34, 56, 23,
|
||||
-20, -31, 27, 23, 24, 28, 39, 33, 47, 27,
|
||||
36, 17, -4, -20, -30, -61, -8, 20, 0, -15,
|
||||
-10, -51, -72, -82, -111, -73, 34, 25, 19, 38,
|
||||
-10, -45, -63, -55, -46, -75, -45, 34, 34, 12,
|
||||
6, -18, 29, 26, 7, -9, 0, 5, 38, 22,
|
||||
-7, -52, -16, 69, 43, 26, 23, 2, 51, 34,
|
||||
-12, -51, -59, -78, -88, 15, 20, 0, -14, 12,
|
||||
-3, -36, -59, -45, 60, 49, 28, 20, 16, -13,
|
||||
-28, -70, -90, 9, 67, 48, 90, 77, 70, 38,
|
||||
-10, -39, -58, -54, 15, -12, 3, 35, 27, -3,
|
||||
12, -1, 28, 29, 55, 53, 80, 65, 51, 23,
|
||||
-17, -61, -39, 74, 56, 43, 75, 51, 58, 36,
|
||||
-30, -71, -93, -43, -29, -26, 4, -19, -14, 37,
|
||||
3, -13, -31, -38, 11, -5, -22, -11, 43, 14,
|
||||
-25, -65, -80, -79, -71, 3, 37, 32, 20, 9,
|
||||
-20, -60, -77, -26, 18, 43, 44, 24, 22, -3,
|
||||
-4, -42, -22, -19, -45, -32, -35, -39, -46, 1,
|
||||
-25, -59, -27, -10, -7, -4, 7, 13, 25, 12,
|
||||
8, -25, -32, -47, -74, -32, 27, 6, 25, 7,
|
||||
41, 40, 62, 64, 64, 50, 54, 42, 49, 25,
|
||||
-21, -63, -88, -21, 16, -3, -4, -26, 57, 38,
|
||||
8, -25, -34, 2, -8, -28, 2, -22, 12, 23,
|
||||
-19, -49, 10, 71, 84, 71, 66, 48, 42, 22,
|
||||
-20, -58, -89, -57, 62, 44, 33, 36, 25, -1,
|
||||
-22, -55, -27, 1, 43, 37, 46, 50, 51, 26,
|
||||
1, -38, -46, 22, 34, 4, 20, -2, 3, 9,
|
||||
-4, -42, -49, -75, -89, -24, -25, 19, 71, 39,
|
||||
5, -28, -45, -43, -63, -75, -17, -38, 14, 30,
|
||||
-4, -36, -62, -59, -29, -43, -4, -16, 11, 23,
|
||||
-19, -57, -82, -39, 26, 2, -2, 20, 11, -10,
|
||||
-28, -68, -92, -70, 9, -1, -15, -30, 11, 31,
|
||||
1, -22, -41, -49, -30, -58, -48, 8, 4, -9,
|
||||
38, 41, 108, 115, 96, 98, 103, 84, 86, 51,
|
||||
15, 1, 58, 46, 26, 6, 16, 18, 41, 24,
|
||||
4, -34, -14, -27, -42, 20, 18, 2, 23, 1,
|
||||
-22, -59, -83, -70, -22, -42, -26, 29, 29, 15,
|
||||
-14, -34, 11, -1, -21, -35, -3, 1, 29, 16,
|
||||
-16, -57, -78, -7, 17, -13, 8, -13, -6, 22,
|
||||
-22, -32, -21, -20, 20, -4, 10, 13, 12, -4,
|
||||
8, -30, -30, -46, -71, -4, 3, -11, 4, -11,
|
||||
16, 5, -15, -21, 3, -23, -25, -19, -28, -32,
|
||||
-28, -68, -98, -101, -34, 19, 71, 52, 49, 30,
|
||||
-18, -57, -82, -56, -56, -66, 15, 12, 1, 29,
|
||||
-21, -62, -76, -27, -33, -38, 18, 30, 54, 32,
|
||||
3, -36, -10, -17, -34, -3, -8, 32, 63, 27,
|
||||
1, -30, -44, -20, -13, -49, -25, 3, -14, -18,
|
||||
-26, -68, -80, -46, -28, 17, 42, 37, 58, 34,
|
||||
30, 26, 57, 55, 49, 25, 16, 3, 24, 11,
|
||||
35, 35, 67, 57, 60, 82, 114, 103, 93, 55,
|
||||
18, -8, -23, -32, -53, -68, 15, 11, -6, -7,
|
||||
-2, -43, -29, 0, -28, -5, -5, -15, 25, -1,
|
||||
4, -13, -35, -45, 14, -6, -2, 19, 16, -9,
|
||||
-30, -72, -93, -93, -73, -10, -15, 6, 30, 45,
|
||||
-23, -58, -50, -55, -74, -60, -23, 0, 6, 21,
|
||||
-4, -40, -63, -24, 7, -19, 4, -18, 27, 28,
|
||||
-12, 1, 88, 76, 74, 88, 93, 90, 80, 44,
|
||||
-13, -59, -43, 52, 27, 21, 15, 12, 42, 11,
|
||||
22, -14, -17, -33, -57, -4, 5, -18, 40, 18,
|
||||
-3, -23, -43, -44, 8, -16, -14, -4, -20, -29,
|
||||
35, 45, 75, 82, 111, 117, 125, 105, 89, 51,
|
||||
-3, -38, -57, -30, 79, 71, 48, 33, 33, 0,
|
||||
-17, -62, -57, 66, 67, 35, 29, 5, 22, 17,
|
||||
3, -31, -34, -21, -44, -49, 42, 23, 24, 26,
|
||||
-23, -62, -74, -49, -30, -30, -37, -50, 9, 35,
|
||||
-17, -57, -71, -81, -45, 61, 58, 37, 31, 9,
|
||||
3, -7, 28, 14, -2, 0, 40, 41, 58, 33,
|
||||
-11, -51, -74, -17, 40, 12, 8, 13, -4, -22,
|
||||
-16, -46, -31, -35, -49, -49, -26, -9, -7, -7,
|
||||
17, -9, -24, -41, -68, -73, 38, 33, 19, 16,
|
||||
-15, -50, -47, -16, -24, -21, 59, 56, 53, 30,
|
||||
-14, -54, -57, 2, -17, -33, -34, -21, 4, -4,
|
||||
-23, -62, -93, -72, 48, 31, 21, 6, 3, 17,
|
||||
-18, -63, -79, 44, 68, 36, 45, 20, 57, 37,
|
||||
-29, -72, -99, -111, -86, -31, 7, 25, 39, 55,
|
||||
-14, -49, -53, -63, -80, -31, 24, 13, 1, -1,
|
||||
-9, -45, -55, -27, -31, -63, -23, 25, 13, -5,
|
||||
-20, -61, -80, 7, 44, 16, 54, 40, 32, 17,
|
||||
24, 7, -8, -43, -62, -54, -11, 7, 35, 27,
|
||||
-12, -55, -59, -48, -69, -4, -1, -12, 68, 39,
|
||||
-12, -31, 52, 63, 53, 34, 29, 22, 36, 19,
|
||||
-26, -66, -97, -79, 50, 41, 40, 48, 54, 28,
|
||||
-2, -37, -41, -2, -11, -30, 29, 16, 4, -2,
|
||||
40, 49, 56, 37, 39, 40, 64, 59, 67, 39,
|
||||
11, -5, 20, 14, 25, 16, 25, 22, 37, 17,
|
||||
-3, -43, -46, -10, -35, -38, -35, -39, 67, 43,
|
||||
-7, -47, -33, -39, -60, -12, -18, 11, 43, 11,
|
||||
-25, -65, -91, -76, -91, -81, 0, 13, 34, 50,
|
||||
-9, -50, -52, 17, 0, -4, 43, 18, 63, 42,
|
||||
-8, -15, 15, 41, 56, 35, 51, 45, 51, 29,
|
||||
0, -14, -24, -36, -43, -70, -39, 27, 33, 5,
|
||||
-25, -62, -81, -66, -12, -26, -16, -4, -13, 21,
|
||||
-29, -68, -60, -24, -3, 11, 18, 19, 30, 20,
|
||||
1, -35, -42, -30, -57, -51, 13, -17, 3, 22,
|
||||
-8, -27, -12, -2, -7, -21, 36, 41, 34, 12,
|
||||
-17, -56, -62, -72, -73, -17, -26, 9, 16, 13,
|
||||
11, -21, -37, -3, 16, -17, 1, -3, -18, -19,
|
||||
15, -20, -19, -22, -49, -30, -7, -29, 3, -2,
|
||||
17, -4, 11, 6, 51, 40, 36, 34, 48, 22,
|
||||
-19, -55, -29, 37, 68, 49, 45, 33, 42, 23,
|
||||
7, -30, -22, 3, -22, -36, -36, -54, 20, 22,
|
||||
20, 2, -15, -39, -59, -85, -10, 37, 21, 2,
|
||||
-15, -54, -77, -54, 74, 70, 48, 32, 51, 20,
|
||||
-25, -64, -70, -75, -52, 17, 6, -20, -30, 26,
|
||||
-13, -55, -15, 39, 16, 42, 30, 33, 62, 28,
|
||||
-21, -56, -30, -35, 6, 13, -4, -29, 33, 27,
|
||||
-17, -55, -75, -31, 3, -28, -26, 16, 18, -4,
|
||||
-13, -44, -60, -52, -9, -36, -38, 1, -9, -9,
|
||||
-12, -50, -77, -70, 43, 47, 28, 13, 43, 16,
|
||||
-13, -57, -80, -104, -113, -30, 43, 45, 52, 39,
|
||||
3, -28, -42, -37, -58, -67, 23, 4, 38, 33,
|
||||
-21, -64, -74, -22, 43, 83, 81, 56, 62, 32,
|
||||
34, 26, 23, 9, 14, 17, 26, 16, 37, 19,
|
||||
-5, -48, -49, -75, -65, 9, -6, 41, 45, 15,
|
||||
32, 30, 63, 83, 90, 91, 100, 84, 85, 52,
|
||||
-19, -54, -68, -71, 11, 30, 13, 1, 63, 37,
|
||||
44, 76, 99, 87, 117, 113, 103, 77, 64, 32,
|
||||
-16, -45, -12, 30, 27, 15, 57, 49, 42, 22,
|
||||
9, -15, -31, -28, -36, -61, -13, -18, -33, -5,
|
||||
-12, -55, -8, 82, 64, 47, 42, 21, 27, 9,
|
||||
-15, -56, -74, -12, -19, -28, 7, -16, 53, 38,
|
||||
-7, -45, -64, -55, -74, -80, 35, 45, 24, 15,
|
||||
-25, -48, -34, -42, -6, -27, -9, 9, 13, -7,
|
||||
-25, -65, -84, -35, 30, 14, 24, 39, 48, 28,
|
||||
-22, -62, -86, -51, 64, 104, 94, 61, 62, 31,
|
||||
16, -15, -25, -28, -55, -56, -10, -23, 52, 36,
|
||||
10, -10, -22, -46, -71, -92, -45, -13, 16, 26,
|
||||
-22, -65, -84, 17, 85, 55, 66, 48, 55, 31,
|
||||
-1, -38, -33, -25, -49, -15, 18, -10, 41, 30,
|
||||
-3, -24, -47, -60, -30, -46, -17, -13, -27, 1,
|
||||
-7, -41, -61, -54, -50, -78, -28, 5, -2, 20,
|
||||
17, -12, -27, -4, 8, -27, -5, 23, 14, -12,
|
||||
-36, -81, -111, -75, -17, -9, 9, 9, 39, 49,
|
||||
-13, -59, -54, 68, 51, 32, 35, 14, 64, 38,
|
||||
-11, -44, -69, -57, 11, -11, -5, 3, -16, -15,
|
||||
34, 36, 41, 16, -8, -24, 11, 23, 48, 28,
|
||||
-17, -42, 8, 17, 45, 69, 71, 55, 49, 23,
|
||||
3, -30, -46, -64, -95, -109, 2, 39, 19, 19,
|
||||
25, -13, -7, 16, -11, -5, 8, -11, 52, 33,
|
||||
-8, -37, -57, -60, 13, 7, -14, -4, 20, -7,
|
||||
7, -31, 9, 44, 20, 22, 29, 10, 52, 31,
|
||||
3, -22, -36, -53, -80, -77, -35, -41, 54, 41,
|
||||
-21, -59, -87, -83, 12, 69, 57, 36, 32, 2,
|
||||
6, -14, -34, -42, -4, -32, -27, 10, 4, -20,
|
||||
-11, -56, -59, 25, 8, -5, -9, -26, 68, 43,
|
||||
22, 13, 40, 39, 73, 81, 95, 88, 82, 45,
|
||||
-18, -62, -79, 28, 60, 28, 29, 3, 23, 25,
|
||||
6, -31, -39, -55, -85, -32, 7, -17, 48, 30,
|
||||
7, -24, -42, -8, 39, 10, 7, 11, 1, -20,
|
||||
-1, -36, -26, -30, -48, 2, 46, 26, 35, 14,
|
||||
-17, -57, -56, -10, -4, 26, 22, 6, -4, -16,
|
||||
-18, -55, -59, -67, -86, -50, 3, 29, 29, 16,
|
||||
-25, -61, -33, 2, 26, 25, 23, 10, 24, 16,
|
||||
26, 15, -8, -20, 6, -21, -16, 3, 0, -22,
|
||||
13, -17, -26, -12, -31, -48, 15, -3, 1, 14,
|
||||
4, -27, -33, -21, -29, -53, -52, -64, -42, 22,
|
||||
-11, -41, -42, -40, -42, -64, 0, 48, 50, 19,
|
||||
-13, -47, -42, -56, -50, 10, 3, -9, -30, -16,
|
||||
-4, -47, -12, 14, -13, 21, 13, 6, 73, 40,
|
||||
-15, -50, -63, -41, -31, -55, -60, -13, 28, 15,
|
||||
-6, -50, -56, -81, -95, 30, 29, 21, 71, 35,
|
||||
-14, -58, -65, 37, 40, 9, 18, -10, -4, 20,
|
||||
31, 33, 79, 106, 119, 103, 100, 77, 64, 33,
|
||||
14, 7, 56, 81, 97, 85, 85, 61, 45, 20,
|
||||
-24, -66, -74, -51, -17, 16, 5, -21, 22, 26,
|
||||
-1, -25, -38, -24, -2, -35, -26, 21, 34, 1,
|
||||
20, 15, 75, 59, 39, 26, 48, 43, 50, 29,
|
||||
26, 1, -15, -4, -9, -38, 9, 2, -9, -8,
|
||||
20, 14, 19, 13, 2, -16, 24, 25, 19, 3,
|
||||
-8, -41, -58, -78, -109, -106, -27, 9, 53, 46,
|
||||
17, 5, -13, -25, -24, -54, -20, 2, -21, -25,
|
||||
-11, -50, -48, 19, 10, -7, 46, 26, 24, 17,
|
||||
-28, -68, -69, -50, -49, -33, -7, 10, 20, 21,
|
||||
4, -36, -21, 38, 19, 1, 25, -3, 20, 22,
|
||||
-18, -58, -87, -44, 82, 73, 49, 31, 19, -7,
|
||||
-21, -61, -78, -44, -58, -66, -9, -23, 10, 40,
|
||||
-25, -66, -76, -33, -33, 6, 16, -6, -21, 5,
|
||||
-27, -69, -77, 5, -2, -7, 6, 9, 24, 6,
|
||||
1, -41, -41, -58, -79, 25, 69, 43, 68, 36,
|
||||
-28, -67, -85, -71, -34, 0, 14, 12, -2, 4,
|
||||
-2, -33, -55, -37, 37, 25, 6, 6, 29, -4,
|
||||
-8, -25, -11, -9, 40, 23, 17, 25, 37, 12,
|
||||
-21, -27, 52, 60, 47, 58, 76, 70, 69, 38,
|
||||
23, 15, 22, -8, -32, -50, -10, 3, 31, 21,
|
||||
-10, -44, -67, -61, -29, -54, 8, 39, 21, 4,
|
||||
31, 18, 30, 36, 46, 28, 50, 42, 35, 13,
|
||||
-21, -57, -24, -16, -15, 14, 3, -25, -17, 20,
|
||||
23, 6, 24, 35, 90, 72, 64, 55, 55, 23,
|
||||
7, -28, -42, -19, -36, -50, -15, -40, 29, 28,
|
||||
-21, -59, -66, -59, -6, 85, 83, 53, 54, 26,
|
||||
2, -20, -42, -52, -27, -49, 5, 9, -9, -8,
|
||||
-18, -56, -84, -72, 24, 51, 32, 20, 13, -10,
|
||||
-13, -53, -64, -39, -63, -40, 24, 0, 34, 29,
|
||||
0, -31, -45, -63, -90, -53, 3, -18, -9, 24,
|
||||
-13, -57, -71, 27, 19, -3, 25, -3, 45, 35,
|
||||
12, -9, -26, -40, -51, -78, -24, 11, -9, -6,
|
||||
-12, -49, -45, -33, -50, -48, -46, -52, 2, 25,
|
||||
-14, -56, -84, -108, -122, -50, 4, 22, 42, 53,
|
||||
-6, -44, -54, -28, -41, -61, 19, 25, 6, 1,
|
||||
-32, -75, -95, -38, -1, -15, 7, 14, 23, 23,
|
||||
11, 12, 37, 30, 38, 51, 80, 80, 82, 47,
|
||||
-19, -56, -69, -82, -98, -64, -29, 2, 28, 42,
|
||||
-18, -49, 3, 34, 41, 39, 32, 18, 21, 7,
|
||||
-8, 23, 39, 30, 30, 27, 41, 36, 44, 23,
|
||||
-16, -49, -69, -46, 1, -27, 41, 48, 35, 15,
|
||||
6, -32, -36, 5, -17, -30, 2, -16, 51, 35,
|
||||
-23, -64, -91, -21, 71, 44, 52, 44, 40, 21,
|
||||
-22, -55, -40, -20, 62, 52, 38, 29, 27, 5,
|
||||
-27, -69, -75, -6, -8, 3, -2, -30, -42, 13,
|
||||
2, -29, -42, -10, 29, 2, 15, 30, 26, 0,
|
||||
-27, -69, -85, -75, -54, -8, -14, -31, 16, 42,
|
||||
-2, -44, -54, -75, -101, -6, 4, -3, 32, 13,
|
||||
7, -3, -22, -43, -14, -27, -24, -11, -14, -12,
|
||||
-18, -57, -85, -66, 47, 86, 75, 45, 42, 10,
|
||||
18, 3, 39, 76, 80, 48, 48, 41, 44, 21,
|
||||
-13, -51, -73, -22, -15, -41, 3, -4, -22, 3,
|
||||
-10, -50, -63, -9, -23, -42, -6, -30, 11, 28,
|
||||
15, -11, -29, -39, -57, -71, -23, -40, -33, 20,
|
||||
-2, -40, -48, -5, -21, -25, 31, 7, 53, 35,
|
||||
-19, -63, -72, 39, 34, 16, 37, 17, 54, 31,
|
||||
-18, -49, -28, -27, -40, -29, 4, 4, 19, 11,
|
||||
-1, -43, -41, 24, 15, -12, -4, -31, -4, 23,
|
||||
-11, -46, -79, -74, 34, 21, 9, 15, 3, -13,
|
||||
-16, -51, -56, -55, 8, 62, 50, 30, 43, 14,
|
||||
-1, -25, -27, -32, -46, -62, -66, -36, 53, 32,
|
||||
-12, -49, -77, -50, 2, -21, 23, 6, 14, 21,
|
||||
-5, -47, -58, -77, -105, -14, 30, 9, 73, 44,
|
||||
-24, -52, -4, 10, 13, 13, 27, 27, 42, 24,
|
||||
-10, -38, -27, -15, -24, -52, -53, 1, 14, -6,
|
||||
-17, -45, -13, 2, 19, 53, 83, 79, 76, 43,
|
||||
-21, -62, -86, -48, 40, 17, 14, -9, 40, 30,
|
||||
-1, -32, -51, -33, -3, -35, 2, 17, -2, -12,
|
||||
-21, -60, -85, -70, 33, 73, 58, 37, 67, 36,
|
||||
-1, -45, -39, 37, 17, 3, 18, -8, 53, 35,
|
||||
-8, -47, -65, -61, -87, -93, 9, 9, 2, 33,
|
||||
-13, -55, -56, -19, -29, 14, 17, 6, 55, 28,
|
||||
5, 1, -7, -23, -26, -56, -39, 14, 11, -13,
|
||||
-28, -69, -89, -74, -83, -45, 1, 0, 16, 45,
|
||||
-3, 5, 91, 104, 119, 111, 97, 76, 72, 39,
|
||||
19, 5, -12, -34, -41, -72, -67, 14, 21, 1,
|
||||
-17, -49, 15, 27, 13, 6, 2, 12, 27, 10,
|
||||
-10, -30, 18, 36, 93, 87, 87, 69, 58, 26,
|
||||
37, 32, 64, 54, 53, 67, 78, 73, 80, 48,
|
||||
48, 46, 38, 9, -1, 8, 47, 44, 58, 33,
|
||||
-23, -61, -88, -76, 27, 14, 9, 36, 36, 10,
|
||||
-24, -66, -88, -97, -55, 20, 19, 16, 52, 31,
|
||||
4, -16, -1, -8, 2, 0, 15, 13, 29, 14,
|
||||
-9, -44, -66, -72, 8, 32, 37, 38, 46, 16,
|
||||
-22, -65, -62, 30, 22, 51, 57, 45, 68, 38,
|
||||
-4, -42, -53, -33, -54, -53, -4, -18, 62, 40,
|
||||
-5, -37, -61, -41, 35, 15, -2, -3, -12, -28,
|
||||
-18, -65, -55, 90, 80, 49, 44, 21, 59, 36,
|
||||
5, -16, -31, -32, -37, -62, -19, -11, 9, 16,
|
||||
-22, -60, -67, -51, -61, -35, -5, -18, -27, 24,
|
||||
-18, -55, -39, -42, -40, 20, 25, 6, 6, 7,
|
||||
0, -25, -42, -50, -59, -84, -31, -13, -22, 17,
|
||||
-32, -73, -100, -89, -21, -10, 18, 38, 31, 23,
|
||||
-15, -54, -57, -13, -18, -41, -32, 17, 50, 21,
|
||||
-16, -57, -71, -10, -8, -26, -38, -47, 42, 25,
|
||||
-17, -58, -82, -7, 33, 3, 30, 11, 13, 24,
|
||||
-23, -61, -97, -83, 82, 81, 57, 39, 31, 2,
|
||||
26, 32, 104, 86, 62, 55, 77, 70, 74, 43,
|
||||
-8, -29, -33, -52, -74, -73, -17, 14, 39, 25,
|
||||
-21, -60, -68, -22, 43, 37, 51, 54, 64, 36,
|
||||
-5, -30, -50, -52, 22, 7, 10, 13, 0, -20,
|
||||
-15, -53, -61, -34, -50, -25, 15, 6, 0, -14,
|
||||
-10, -51, -60, 20, 77, 50, 34, 22, 8, -8,
|
||||
-8, -45, -52, -59, -76, -35, -43, -49, 47, 40,
|
||||
41, 44, 53, 40, 41, 30, 38, 31, 46, 24,
|
||||
19, 3, -15, -26, -16, -45, -13, 24, 18, -5,
|
||||
-3, -39, -54, -35, -49, -70, 2, -6, -19, 15,
|
||||
-13, -53, -36, 6, -3, 45, 50, 30, 33, 10,
|
||||
15, -25, -16, -4, -32, 7, 23, 6, 67, 36,
|
||||
-21, -58, -87, -71, 10, -12, -16, 19, 10, 0,
|
||||
9, -15, -6, 25, 31, 7, 30, 28, 20, 2,
|
||||
2, -28, -42, -50, -67, -75, 12, 12, -4, 8,
|
||||
-17, -63, -58, 56, 49, 36, 60, 38, 37, 14,
|
||||
-13, -48, -38, -29, -44, -25, -20, -33, 38, 20,
|
||||
2, -37, -42, -1, -18, -42, 3, -17, -19, 12,
|
||||
-20, -60, -73, -7, 12, -13, -22, -38, 4, 10,
|
||||
-8, -41, -63, -65, 42, 63, 45, 31, 31, 0,
|
||||
-4, -46, -38, -9, -35, 15, 50, 27, 67, 39,
|
||||
3, -7, -13, -34, -51, -47, 9, 39, 54, 29,
|
||||
-29, -71, -89, -52, -39, -6, 3, 2, 38, 28,
|
||||
-14, -42, -13, -15, -19, 0, 20, 12, 37, 25,
|
||||
11, -26, -24, -40, -65, -11, -13, -27, 65, 37,
|
||||
0, -31, -46, -17, -21, -45, 11, -2, 25, 24,
|
||||
51, 91, 102, 87, 85, 63, 57, 42, 48, 23,
|
||||
-4, -34, -56, -70, -10, -14, 4, 18, 3, -8,
|
||||
-23, -59, -39, -44, -42, -14, -10, -23, -4, 17,
|
||||
-2, 4, 35, 63, 69, 75, 82, 63, 78, 48,
|
||||
-17, -55, -60, -3, -4, -19, 4, -4, -18, -29,
|
||||
2, -20, -36, -50, -32, -59, -16, 30, 16, -6,
|
||||
-12, -47, 24, 68, 45, 46, 41, 32, 65, 37,
|
||||
-4, -40, -54, -67, -96, -66, -9, -25, 42, 38,
|
||||
-15, 13, 58, 58, 84, 104, 119, 104, 89, 51,
|
||||
-15, -24, -9, -24, -27, -50, -7, 28, 29, 6,
|
||||
-7, -33, -35, -49, -65, -53, -37, -10, 33, 14,
|
||||
31, 19, 46, 72, 67, 45, 83, 68, 63, 41,
|
||||
-14, -53, -59, -17, 55, 79, 64, 39, 43, 10,
|
||||
};
|
||||
|
||||
const signed char cdbk_lsp2_vlbr[160]={
|
||||
-20, -30, -24, 17, 7, -13, -21, 61, 56, 16,
|
||||
12, 1, 10, 77, 32, 3, 7, 3, -25, -31,
|
||||
-4, 2, -36, -83, 18, 5, -5, 5, 11, 23,
|
||||
-2, -1, -11, -12, -20, -28, 68, 50, -17, -20,
|
||||
5, 2, 1, 20, 17, 4, -52, -66, 36, 24,
|
||||
-4, -10, 7, -15, -32, 80, 37, 8, -13, -29,
|
||||
33, 37, 28, 15, 8, 14, 35, 18, 50, 36,
|
||||
-4, -1, 4, -7, 3, 3, -11, -58, -75, 13,
|
||||
13, 21, 24, -11, -12, -38, -72, 33, 15, -12,
|
||||
-44, -17, 83, 21, 2, 7, 0, 4, 0, -1,
|
||||
-25, -42, -51, 33, 20, 15, 30, -13, 9, 32,
|
||||
6, 2, -8, 7, -38, -77, 6, -13, -7, 32,
|
||||
48, 57, 32, -12, -10, -4, 2, -15, -29, -29,
|
||||
2, 10, -9, -16, 79, 44, 7, 12, -5, -18,
|
||||
-23, -29, -35, -3, -3, -18, -34, -3, -39, -50,
|
||||
-5, -10, -8, -37, -76, 11, -4, -19, 30, 16,
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,53 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file lpc.h
|
||||
@brief Functions for LPC (Linear Prediction Coefficients) analysis
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LPC_H
|
||||
#define LPC_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
void _spx_autocorr(
|
||||
const spx_word16_t * x, /* in: [0...n-1] samples x */
|
||||
spx_word16_t *ac, /* out: [0...lag-1] ac values */
|
||||
int lag, int n);
|
||||
|
||||
spx_word32_t /* returns minimum mean square error */
|
||||
_spx_lpc(
|
||||
spx_coef_t * lpc, /* [0...p-1] LPC coefficients */
|
||||
const spx_word16_t * ac, /* in: [0...p] autocorrelation values */
|
||||
int p
|
||||
);
|
||||
|
||||
|
||||
#endif
|
|
@ -1,131 +0,0 @@
|
|||
/* Copyright (C) 2005 Analog Devices */
|
||||
/**
|
||||
@file lpc_bfin.h
|
||||
@author Jean-Marc Valin
|
||||
@brief Functions for LPC (Linear Prediction Coefficients) analysis (Blackfin version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_SPEEX_AUTOCORR
|
||||
void _spx_autocorr(
|
||||
const spx_word16_t *x, /* in: [0...n-1] samples x */
|
||||
spx_word16_t *ac, /* out: [0...lag-1] ac values */
|
||||
int lag,
|
||||
int n
|
||||
)
|
||||
{
|
||||
spx_word32_t d;
|
||||
const spx_word16_t *xs;
|
||||
int i, j;
|
||||
spx_word32_t ac0=1;
|
||||
spx_word32_t ac32[11], *ac32top;
|
||||
int shift, ac_shift;
|
||||
ac32top = ac32+lag-1;
|
||||
int lag_1, N_lag;
|
||||
int nshift;
|
||||
lag_1 = lag-1;
|
||||
N_lag = n-lag_1;
|
||||
for (j=0;j<n;j++)
|
||||
ac0 = ADD32(ac0,SHR32(MULT16_16(x[j],x[j]),8));
|
||||
ac0 = ADD32(ac0,n);
|
||||
shift = 8;
|
||||
while (shift && ac0<0x40000000)
|
||||
{
|
||||
shift--;
|
||||
ac0 <<= 1;
|
||||
}
|
||||
ac_shift = 18;
|
||||
while (ac_shift && ac0<0x40000000)
|
||||
{
|
||||
ac_shift--;
|
||||
ac0 <<= 1;
|
||||
}
|
||||
|
||||
xs = x+lag-1;
|
||||
nshift = -shift;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"P2 = %0;\n\t"
|
||||
"I0 = P2;\n\t" /* x in I0 */
|
||||
"B0 = P2;\n\t" /* x in B0 */
|
||||
"R0 = %3;\n\t" /* len in R0 */
|
||||
"P3 = %3;\n\t" /* len in R0 */
|
||||
"P4 = %4;\n\t" /* nb_pitch in R0 */
|
||||
"R1 = R0 << 1;\n\t" /* number of bytes in x */
|
||||
"L0 = R1;\n\t"
|
||||
"P0 = %1;\n\t"
|
||||
"P1 = %2;\n\t"
|
||||
"B1 = P1;\n\t"
|
||||
"R4 = %5;\n\t"
|
||||
"L1 = 0;\n\t" /*Disable looping on I1*/
|
||||
|
||||
"r0 = [I0++];\n\t"
|
||||
"R2 = 0;R3=0;"
|
||||
"LOOP pitch%= LC0 = P4 >> 1;\n\t"
|
||||
"LOOP_BEGIN pitch%=;\n\t"
|
||||
"I1 = P0;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"R1 = [I1++];\n\t"
|
||||
"LOOP inner_prod%= LC1 = P3 >> 1;\n\t"
|
||||
"LOOP_BEGIN inner_prod%=;\n\t"
|
||||
"A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t"
|
||||
"A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t"
|
||||
"LOOP_END inner_prod%=;\n\t"
|
||||
"A0 = ASHIFT A0 by R4.L;\n\t"
|
||||
"A1 = ASHIFT A1 by R4.L;\n\t"
|
||||
|
||||
"R2 = A0, R3 = A1;\n\t"
|
||||
"[P1--] = R2;\n\t"
|
||||
"[P1--] = R3;\n\t"
|
||||
"P0 += 4;\n\t"
|
||||
"LOOP_END pitch%=;\n\t"
|
||||
: : "m" (xs), "m" (x), "m" (ac32top), "m" (N_lag), "m" (lag_1), "m" (nshift)
|
||||
: "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "R4", "I0", "I1", "L0", "L1", "B0", "B1", "memory"
|
||||
);
|
||||
d=0;
|
||||
for (j=0;j<n;j++)
|
||||
{
|
||||
d = ADD32(d,SHR32(MULT16_16(x[j],x[j]), shift));
|
||||
}
|
||||
ac32[0] = d;
|
||||
|
||||
for (i=0;i<lag;i++)
|
||||
{
|
||||
d=0;
|
||||
for (j=i;j<lag_1;j++)
|
||||
{
|
||||
d = ADD32(d,SHR32(MULT16_16(x[j],x[j-i]), shift));
|
||||
}
|
||||
if (i)
|
||||
ac32[i] += d;
|
||||
ac[i] = SHR32(ac32[i], ac_shift);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
/*
|
||||
Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
|
||||
Technische Universitaet Berlin
|
||||
|
||||
Any use of this software is permitted provided that this notice is not
|
||||
removed and that neither the authors nor the Technische Universitaet Berlin
|
||||
are deemed to have made any representations as to the suitability of this
|
||||
software for any purpose nor are held responsible for any defects of
|
||||
this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
||||
|
||||
As a matter of courtesy, the authors request to be informed about uses
|
||||
this software has found, about bugs in this software, and about any
|
||||
improvements that may be of general interest.
|
||||
|
||||
Berlin, 28.11.1994
|
||||
Jutta Degener
|
||||
Carsten Bormann
|
||||
|
||||
|
||||
Code modified by Jean-Marc Valin
|
||||
|
||||
Speex License:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "lpc.h"
|
||||
|
||||
#ifdef BFIN_ASM
|
||||
#include "lpc_bfin.h"
|
||||
#endif
|
||||
|
||||
/* LPC analysis
|
||||
*
|
||||
* The next two functions calculate linear prediction coefficients
|
||||
* and/or the related reflection coefficients from the first P_MAX+1
|
||||
* values of the autocorrelation function.
|
||||
*/
|
||||
|
||||
/* Invented by N. Levinson in 1947, modified by J. Durbin in 1959.
|
||||
*/
|
||||
|
||||
/* returns minimum mean square error */
|
||||
spx_word32_t _spx_lpc(
|
||||
spx_coef_t *lpc, /* out: [0...p-1] LPC coefficients */
|
||||
const spx_word16_t *ac, /* in: [0...p] autocorrelation values */
|
||||
int p
|
||||
)
|
||||
{
|
||||
int i, j;
|
||||
spx_word16_t r;
|
||||
spx_word16_t error = ac[0];
|
||||
|
||||
if (ac[0] == 0)
|
||||
{
|
||||
for (i = 0; i < p; i++)
|
||||
lpc[i] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < p; i++) {
|
||||
|
||||
/* Sum up this iteration's reflection coefficient */
|
||||
spx_word32_t rr = NEG32(SHL32(EXTEND32(ac[i + 1]),13));
|
||||
for (j = 0; j < i; j++)
|
||||
rr = SUB32(rr,MULT16_16(lpc[j],ac[i - j]));
|
||||
#ifdef FIXED_POINT
|
||||
r = DIV32_16(rr+PSHR32(error,1),ADD16(error,8));
|
||||
#else
|
||||
r = rr/(error+.003*ac[0]);
|
||||
#endif
|
||||
/* Update LPC coefficients and total error */
|
||||
lpc[i] = r;
|
||||
for (j = 0; j < i>>1; j++)
|
||||
{
|
||||
spx_word16_t tmp = lpc[j];
|
||||
lpc[j] = MAC16_16_P13(lpc[j],r,lpc[i-1-j]);
|
||||
lpc[i-1-j] = MAC16_16_P13(lpc[i-1-j],r,tmp);
|
||||
}
|
||||
if (i & 1)
|
||||
lpc[j] = MAC16_16_P13(lpc[j],lpc[j],r);
|
||||
|
||||
error = SUB16(error,MULT16_16_Q13(r,MULT16_16_Q13(error,r)));
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
/* Compute the autocorrelation
|
||||
* ,--,
|
||||
* ac(i) = > x(n) * x(n-i) for all n
|
||||
* `--'
|
||||
* for lags between 0 and lag-1, and x == 0 outside 0...n-1
|
||||
*/
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_AUTOCORR
|
||||
void _spx_autocorr(
|
||||
const spx_word16_t *x, /* in: [0...n-1] samples x */
|
||||
spx_word16_t *ac, /* out: [0...lag-1] ac values */
|
||||
int lag,
|
||||
int n
|
||||
)
|
||||
{
|
||||
spx_word32_t d;
|
||||
int i, j;
|
||||
spx_word32_t ac0=1;
|
||||
int shift, ac_shift;
|
||||
|
||||
for (j=0;j<n;j++)
|
||||
ac0 = ADD32(ac0,SHR32(MULT16_16(x[j],x[j]),8));
|
||||
ac0 = ADD32(ac0,n);
|
||||
shift = 8;
|
||||
while (shift && ac0<0x40000000)
|
||||
{
|
||||
shift--;
|
||||
ac0 <<= 1;
|
||||
}
|
||||
ac_shift = 18;
|
||||
while (ac_shift && ac0<0x40000000)
|
||||
{
|
||||
ac_shift--;
|
||||
ac0 <<= 1;
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<lag;i++)
|
||||
{
|
||||
d=0;
|
||||
for (j=i;j<n;j++)
|
||||
{
|
||||
d = ADD32(d,SHR32(MULT16_16(x[j],x[j-i]), shift));
|
||||
}
|
||||
|
||||
ac[i] = SHR32(d, ac_shift);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
/* Compute the autocorrelation
|
||||
* ,--,
|
||||
* ac(i) = > x(n) * x(n-i) for all n
|
||||
* `--'
|
||||
* for lags between 0 and lag-1, and x == 0 outside 0...n-1
|
||||
*/
|
||||
void _spx_autocorr(
|
||||
const spx_word16_t *x, /* in: [0...n-1] samples x */
|
||||
float *ac, /* out: [0...lag-1] ac values */
|
||||
int lag,
|
||||
int n
|
||||
)
|
||||
{
|
||||
float d;
|
||||
int i;
|
||||
while (lag--)
|
||||
{
|
||||
for (i = lag, d = 0; i < n; i++)
|
||||
d += x[i] * x[i-lag];
|
||||
ac[lag] = d;
|
||||
}
|
||||
ac[0] += 10;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,656 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
Original copyright
|
||||
FILE........: lsp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
Heavily modified by Jean-Marc Valin (c) 2002-2006 (fixed-point,
|
||||
optimizations, additional functions, ...)
|
||||
|
||||
This file contains functions for converting Linear Prediction
|
||||
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
|
||||
LSP coefficients are not in radians format but in the x domain of the
|
||||
unit circle.
|
||||
|
||||
Speex License:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
Introduction to Line Spectrum Pairs (LSPs)
|
||||
------------------------------------------
|
||||
|
||||
LSPs are used to encode the LPC filter coefficients {ak} for
|
||||
transmission over the channel. LSPs have several properties (like
|
||||
less sensitivity to quantisation noise) that make them superior to
|
||||
direct quantisation of {ak}.
|
||||
|
||||
A(z) is a polynomial of order lpcrdr with {ak} as the coefficients.
|
||||
|
||||
A(z) is transformed to P(z) and Q(z) (using a substitution and some
|
||||
algebra), to obtain something like:
|
||||
|
||||
A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1)
|
||||
|
||||
As you can imagine A(z) has complex zeros all over the z-plane. P(z)
|
||||
and Q(z) have the very neat property of only having zeros _on_ the
|
||||
unit circle. So to find them we take a test point z=exp(jw) and
|
||||
evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0
|
||||
and pi.
|
||||
|
||||
The zeros (roots) of P(z) also happen to alternate, which is why we
|
||||
swap coefficients as we find roots. So the process of finding the
|
||||
LSP frequencies is basically finding the roots of 5th order
|
||||
polynomials.
|
||||
|
||||
The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence
|
||||
the name Line Spectrum Pairs (LSPs).
|
||||
|
||||
To convert back to ak we just evaluate (1), "clocking" an impulse
|
||||
thru it lpcrdr times gives us the impulse response of A(z) which is
|
||||
{ak}.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include "lsp.h"
|
||||
#include "stack_alloc.h"
|
||||
#include "math_approx.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
#define FREQ_SCALE 16384
|
||||
|
||||
/*#define ANGLE2X(a) (32768*cos(((a)/8192.)))*/
|
||||
#define ANGLE2X(a) (SHL16(spx_cos(a),2))
|
||||
|
||||
/*#define X2ANGLE(x) (acos(.00006103515625*(x))*LSP_SCALING)*/
|
||||
#define X2ANGLE(x) (spx_acos(x))
|
||||
|
||||
#ifdef BFIN_ASM
|
||||
#include "lsp_bfin.h"
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/*#define C1 0.99940307
|
||||
#define C2 -0.49558072
|
||||
#define C3 0.03679168*/
|
||||
|
||||
#define FREQ_SCALE 1.
|
||||
#define ANGLE2X(a) (spx_cos(a))
|
||||
#define X2ANGLE(x) (acos(x))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: cheb_poly_eva()
|
||||
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function evaluates a series of Chebyshev polynomials
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
#ifndef OVERRIDE_CHEB_POLY_EVA
|
||||
static inline spx_word32_t cheb_poly_eva(
|
||||
spx_word16_t *coef, /* P or Q coefs in Q13 format */
|
||||
spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */
|
||||
int m, /* LPC order/2 */
|
||||
char *stack
|
||||
)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t b0, b1;
|
||||
spx_word32_t sum;
|
||||
|
||||
/*Prevents overflows*/
|
||||
if (x>16383)
|
||||
x = 16383;
|
||||
if (x<-16383)
|
||||
x = -16383;
|
||||
|
||||
/* Initialise values */
|
||||
b1=16384;
|
||||
b0=x;
|
||||
|
||||
/* Evaluate Chebyshev series formulation usin g iterative approach */
|
||||
sum = ADD32(EXTEND32(coef[m]), EXTEND32(MULT16_16_P14(coef[m-1],x)));
|
||||
for(i=2;i<=m;i++)
|
||||
{
|
||||
spx_word16_t tmp=b0;
|
||||
b0 = SUB16(MULT16_16_Q13(x,b0), b1);
|
||||
b1 = tmp;
|
||||
sum = ADD32(sum, EXTEND32(MULT16_16_P14(coef[m-i],b0)));
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
static float cheb_poly_eva(spx_word32_t *coef, spx_word16_t x, int m, char *stack)
|
||||
{
|
||||
int k;
|
||||
float b0, b1, tmp;
|
||||
|
||||
/* Initial conditions */
|
||||
b0=0; /* b_(m+1) */
|
||||
b1=0; /* b_(m+2) */
|
||||
|
||||
x*=2;
|
||||
|
||||
/* Calculate the b_(k) */
|
||||
for(k=m;k>0;k--)
|
||||
{
|
||||
tmp=b0; /* tmp holds the previous value of b0 */
|
||||
b0=x*b0-b1+coef[m-k]; /* b0 holds its new value based on b0 and b1 */
|
||||
b1=tmp; /* b1 holds the previous value of b0 */
|
||||
}
|
||||
|
||||
return(-b1+.5*x*b0+coef[m]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lpc_to_lsp()
|
||||
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LPC coefficients to LSP
|
||||
coefficients.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#define SIGN_CHANGE(a,b) (((a)&0x70000000)^((b)&0x70000000)||(b==0))
|
||||
#else
|
||||
#define SIGN_CHANGE(a,b) (((a)*(b))<0.0)
|
||||
#endif
|
||||
|
||||
|
||||
int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack)
|
||||
/* float *a lpc coefficients */
|
||||
/* int lpcrdr order of LPC coefficients (10) */
|
||||
/* float *freq LSP frequencies in the x domain */
|
||||
/* int nb number of sub-intervals (4) */
|
||||
/* float delta grid spacing interval (0.02) */
|
||||
|
||||
|
||||
{
|
||||
spx_word16_t temp_xr,xl,xr,xm=0;
|
||||
spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/;
|
||||
int i,j,m,flag,k;
|
||||
VARDECL(spx_word32_t *Q); /* ptrs for memory allocation */
|
||||
VARDECL(spx_word32_t *P);
|
||||
VARDECL(spx_word16_t *Q16); /* ptrs for memory allocation */
|
||||
VARDECL(spx_word16_t *P16);
|
||||
spx_word32_t *px; /* ptrs of respective P'(z) & Q'(z) */
|
||||
spx_word32_t *qx;
|
||||
spx_word32_t *p;
|
||||
spx_word32_t *q;
|
||||
spx_word16_t *pt; /* ptr used for cheb_poly_eval()
|
||||
whether P' or Q' */
|
||||
int roots=0; /* DR 8/2/94: number of roots found */
|
||||
flag = 1; /* program is searching for a root when,
|
||||
1 else has found one */
|
||||
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynomials */
|
||||
|
||||
/* Allocate memory space for polynomials */
|
||||
ALLOC(Q, (m+1), spx_word32_t);
|
||||
ALLOC(P, (m+1), spx_word32_t);
|
||||
|
||||
/* determine P'(z)'s and Q'(z)'s coefficients where
|
||||
P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
|
||||
|
||||
px = P; /* initialise ptrs */
|
||||
qx = Q;
|
||||
p = px;
|
||||
q = qx;
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
*px++ = LPC_SCALING;
|
||||
*qx++ = LPC_SCALING;
|
||||
for(i=0;i<m;i++){
|
||||
*px++ = SUB32(ADD32(EXTEND32(a[i]),EXTEND32(a[lpcrdr-i-1])), *p++);
|
||||
*qx++ = ADD32(SUB32(EXTEND32(a[i]),EXTEND32(a[lpcrdr-i-1])), *q++);
|
||||
}
|
||||
px = P;
|
||||
qx = Q;
|
||||
for(i=0;i<m;i++)
|
||||
{
|
||||
/*if (fabs(*px)>=32768)
|
||||
speex_warning_int("px", *px);
|
||||
if (fabs(*qx)>=32768)
|
||||
speex_warning_int("qx", *qx);*/
|
||||
*px = PSHR32(*px,2);
|
||||
*qx = PSHR32(*qx,2);
|
||||
px++;
|
||||
qx++;
|
||||
}
|
||||
/* The reason for this lies in the way cheb_poly_eva() is implemented for fixed-point */
|
||||
P[m] = PSHR32(P[m],3);
|
||||
Q[m] = PSHR32(Q[m],3);
|
||||
#else
|
||||
*px++ = LPC_SCALING;
|
||||
*qx++ = LPC_SCALING;
|
||||
for(i=0;i<m;i++){
|
||||
*px++ = (a[i]+a[lpcrdr-1-i]) - *p++;
|
||||
*qx++ = (a[i]-a[lpcrdr-1-i]) + *q++;
|
||||
}
|
||||
px = P;
|
||||
qx = Q;
|
||||
for(i=0;i<m;i++){
|
||||
*px = 2**px;
|
||||
*qx = 2**qx;
|
||||
px++;
|
||||
qx++;
|
||||
}
|
||||
#endif
|
||||
|
||||
px = P; /* re-initialise ptrs */
|
||||
qx = Q;
|
||||
|
||||
/* now that we have computed P and Q convert to 16 bits to
|
||||
speed up cheb_poly_eval */
|
||||
|
||||
ALLOC(P16, m+1, spx_word16_t);
|
||||
ALLOC(Q16, m+1, spx_word16_t);
|
||||
|
||||
for (i=0;i<m+1;i++)
|
||||
{
|
||||
P16[i] = P[i];
|
||||
Q16[i] = Q[i];
|
||||
}
|
||||
|
||||
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
|
||||
Keep alternating between the two polynomials as each zero is found */
|
||||
|
||||
xr = 0; /* initialise xr to zero */
|
||||
xl = FREQ_SCALE; /* start at point xl = 1 */
|
||||
|
||||
for(j=0;j<lpcrdr;j++){
|
||||
if(j&1) /* determines whether P' or Q' is eval. */
|
||||
pt = Q16;
|
||||
else
|
||||
pt = P16;
|
||||
|
||||
psuml = cheb_poly_eva(pt,xl,m,stack); /* evals poly. at xl */
|
||||
flag = 1;
|
||||
while(flag && (xr >= -FREQ_SCALE)){
|
||||
spx_word16_t dd;
|
||||
/* Modified by JMV to provide smaller steps around x=+-1 */
|
||||
#ifdef FIXED_POINT
|
||||
dd = MULT16_16_Q15(delta,SUB16(FREQ_SCALE, MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000)));
|
||||
if (psuml<512 && psuml>-512)
|
||||
dd = PSHR16(dd,1);
|
||||
#else
|
||||
dd=delta*(1-.9*xl*xl);
|
||||
if (fabs(psuml)<.2)
|
||||
dd *= .5;
|
||||
#endif
|
||||
xr = SUB16(xl, dd); /* interval spacing */
|
||||
psumr = cheb_poly_eva(pt,xr,m,stack);/* poly(xl-delta_x) */
|
||||
temp_psumr = psumr;
|
||||
temp_xr = xr;
|
||||
|
||||
/* if no sign change increment xr and re-evaluate poly(xr). Repeat til
|
||||
sign change.
|
||||
if a sign change has occurred the interval is bisected and then
|
||||
checked again for a sign change which determines in which
|
||||
interval the zero lies in.
|
||||
If there is no sign change between poly(xm) and poly(xl) set interval
|
||||
between xm and xr else set interval between xl and xr and repeat till
|
||||
root is located within the specified limits */
|
||||
|
||||
if(SIGN_CHANGE(psumr,psuml))
|
||||
{
|
||||
roots++;
|
||||
|
||||
psumm=psuml;
|
||||
for(k=0;k<=nb;k++){
|
||||
#ifdef FIXED_POINT
|
||||
xm = ADD16(PSHR16(xl,1),PSHR16(xr,1)); /* bisect the interval */
|
||||
#else
|
||||
xm = .5*(xl+xr); /* bisect the interval */
|
||||
#endif
|
||||
psumm=cheb_poly_eva(pt,xm,m,stack);
|
||||
/*if(psumm*psuml>0.)*/
|
||||
if(!SIGN_CHANGE(psumm,psuml))
|
||||
{
|
||||
psuml=psumm;
|
||||
xl=xm;
|
||||
} else {
|
||||
psumr=psumm;
|
||||
xr=xm;
|
||||
}
|
||||
}
|
||||
|
||||
/* once zero is found, reset initial interval to xr */
|
||||
freq[j] = X2ANGLE(xm);
|
||||
xl = xm;
|
||||
flag = 0; /* reset flag for next search */
|
||||
}
|
||||
else{
|
||||
psuml=temp_psumr;
|
||||
xl=temp_xr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(roots);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lsp_to_lpc()
|
||||
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
Converts LSP coefficients to LPC coefficients.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
|
||||
/* float *freq array of LSP frequencies in the x domain */
|
||||
/* float *ak array of LPC coefficients */
|
||||
/* int lpcrdr order of LPC coefficients */
|
||||
{
|
||||
int i,j;
|
||||
spx_word32_t xout1,xout2,xin;
|
||||
spx_word32_t mult, a;
|
||||
VARDECL(spx_word16_t *freqn);
|
||||
VARDECL(spx_word32_t **xp);
|
||||
VARDECL(spx_word32_t *xpmem);
|
||||
VARDECL(spx_word32_t **xq);
|
||||
VARDECL(spx_word32_t *xqmem);
|
||||
int m = lpcrdr>>1;
|
||||
|
||||
/*
|
||||
|
||||
Reconstruct P(z) and Q(z) by cascading second order polynomials
|
||||
in form 1 - 2cos(w)z(-1) + z(-2), where w is the LSP frequency.
|
||||
In the time domain this is:
|
||||
|
||||
y(n) = x(n) - 2cos(w)x(n-1) + x(n-2)
|
||||
|
||||
This is what the ALLOCS below are trying to do:
|
||||
|
||||
int xp[m+1][lpcrdr+1+2]; // P matrix in QIMP
|
||||
int xq[m+1][lpcrdr+1+2]; // Q matrix in QIMP
|
||||
|
||||
These matrices store the output of each stage on each row. The
|
||||
final (m-th) row has the output of the final (m-th) cascaded
|
||||
2nd order filter. The first row is the impulse input to the
|
||||
system (not written as it is known).
|
||||
|
||||
The version below takes advantage of the fact that a lot of the
|
||||
outputs are zero or known, for example if we put an inpulse
|
||||
into the first section the "clock" it 10 times only the first 3
|
||||
outputs samples are non-zero (it's an FIR filter).
|
||||
*/
|
||||
|
||||
ALLOC(xp, (m+1), spx_word32_t*);
|
||||
ALLOC(xpmem, (m+1)*(lpcrdr+1+2), spx_word32_t);
|
||||
|
||||
ALLOC(xq, (m+1), spx_word32_t*);
|
||||
ALLOC(xqmem, (m+1)*(lpcrdr+1+2), spx_word32_t);
|
||||
|
||||
for(i=0; i<=m; i++) {
|
||||
xp[i] = xpmem + i*(lpcrdr+1+2);
|
||||
xq[i] = xqmem + i*(lpcrdr+1+2);
|
||||
}
|
||||
|
||||
/* work out 2cos terms in Q14 */
|
||||
|
||||
ALLOC(freqn, lpcrdr, spx_word16_t);
|
||||
for (i=0;i<lpcrdr;i++)
|
||||
freqn[i] = ANGLE2X(freq[i]);
|
||||
|
||||
#define QIMP 21 /* scaling for impulse */
|
||||
|
||||
xin = SHL32(EXTEND32(1), (QIMP-1)); /* 0.5 in QIMP format */
|
||||
|
||||
/* first col and last non-zero values of each row are trivial */
|
||||
|
||||
for(i=0;i<=m;i++) {
|
||||
xp[i][1] = 0;
|
||||
xp[i][2] = xin;
|
||||
xp[i][2+2*i] = xin;
|
||||
xq[i][1] = 0;
|
||||
xq[i][2] = xin;
|
||||
xq[i][2+2*i] = xin;
|
||||
}
|
||||
|
||||
/* 2nd row (first output row) is trivial */
|
||||
|
||||
xp[1][3] = -MULT16_32_Q14(freqn[0],xp[0][2]);
|
||||
xq[1][3] = -MULT16_32_Q14(freqn[1],xq[0][2]);
|
||||
|
||||
xout1 = xout2 = 0;
|
||||
|
||||
/* now generate remaining rows */
|
||||
|
||||
for(i=1;i<m;i++) {
|
||||
|
||||
for(j=1;j<2*(i+1)-1;j++) {
|
||||
mult = MULT16_32_Q14(freqn[2*i],xp[i][j+1]);
|
||||
xp[i+1][j+2] = ADD32(SUB32(xp[i][j+2], mult), xp[i][j]);
|
||||
mult = MULT16_32_Q14(freqn[2*i+1],xq[i][j+1]);
|
||||
xq[i+1][j+2] = ADD32(SUB32(xq[i][j+2], mult), xq[i][j]);
|
||||
}
|
||||
|
||||
/* for last col xp[i][j+2] = xq[i][j+2] = 0 */
|
||||
|
||||
mult = MULT16_32_Q14(freqn[2*i],xp[i][j+1]);
|
||||
xp[i+1][j+2] = SUB32(xp[i][j], mult);
|
||||
mult = MULT16_32_Q14(freqn[2*i+1],xq[i][j+1]);
|
||||
xq[i+1][j+2] = SUB32(xq[i][j], mult);
|
||||
}
|
||||
|
||||
/* process last row to extra a{k} */
|
||||
|
||||
for(j=1;j<=lpcrdr;j++) {
|
||||
int shift = QIMP-13;
|
||||
|
||||
/* final filter sections */
|
||||
a = PSHR32(xp[m][j+2] + xout1 + xq[m][j+2] - xout2, shift);
|
||||
xout1 = xp[m][j+2];
|
||||
xout2 = xq[m][j+2];
|
||||
|
||||
/* hard limit ak's to +/- 32767 */
|
||||
|
||||
if (a < -32767) a = -32767;
|
||||
if (a > 32767) a = 32767;
|
||||
ak[j-1] = (short)a;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
|
||||
/* float *freq array of LSP frequencies in the x domain */
|
||||
/* float *ak array of LPC coefficients */
|
||||
/* int lpcrdr order of LPC coefficients */
|
||||
|
||||
|
||||
{
|
||||
int i,j;
|
||||
float xout1,xout2,xin1,xin2;
|
||||
VARDECL(float *Wp);
|
||||
float *pw,*n1,*n2,*n3,*n4=NULL;
|
||||
VARDECL(float *x_freq);
|
||||
int m = lpcrdr>>1;
|
||||
|
||||
ALLOC(Wp, 4*m+2, float);
|
||||
pw = Wp;
|
||||
|
||||
/* initialise contents of array */
|
||||
|
||||
for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
|
||||
*pw++ = 0.0;
|
||||
}
|
||||
|
||||
/* Set pointers up */
|
||||
|
||||
pw = Wp;
|
||||
xin1 = 1.0;
|
||||
xin2 = 1.0;
|
||||
|
||||
ALLOC(x_freq, lpcrdr, float);
|
||||
for (i=0;i<lpcrdr;i++)
|
||||
x_freq[i] = ANGLE2X(freq[i]);
|
||||
|
||||
/* reconstruct P(z) and Q(z) by cascading second order
|
||||
polynomials in form 1 - 2xz(-1) +z(-2), where x is the
|
||||
LSP coefficient */
|
||||
|
||||
for(j=0;j<=lpcrdr;j++){
|
||||
int i2=0;
|
||||
for(i=0;i<m;i++,i2+=2){
|
||||
n1 = pw+(i*4);
|
||||
n2 = n1 + 1;
|
||||
n3 = n2 + 1;
|
||||
n4 = n3 + 1;
|
||||
xout1 = xin1 - 2.f*x_freq[i2] * *n1 + *n2;
|
||||
xout2 = xin2 - 2.f*x_freq[i2+1] * *n3 + *n4;
|
||||
*n2 = *n1;
|
||||
*n4 = *n3;
|
||||
*n1 = xin1;
|
||||
*n3 = xin2;
|
||||
xin1 = xout1;
|
||||
xin2 = xout2;
|
||||
}
|
||||
xout1 = xin1 + *(n4+1);
|
||||
xout2 = xin2 - *(n4+2);
|
||||
if (j>0)
|
||||
ak[j-1] = (xout1 + xout2)*0.5f;
|
||||
*(n4+1) = xin1;
|
||||
*(n4+2) = xin2;
|
||||
|
||||
xin1 = 0.0;
|
||||
xin2 = 0.0;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
/*Makes sure the LSPs are stable*/
|
||||
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t m = margin;
|
||||
spx_word16_t m2 = 25736-margin;
|
||||
|
||||
if (lsp[0]<m)
|
||||
lsp[0]=m;
|
||||
if (lsp[len-1]>m2)
|
||||
lsp[len-1]=m2;
|
||||
for (i=1;i<len-1;i++)
|
||||
{
|
||||
if (lsp[i]<lsp[i-1]+m)
|
||||
lsp[i]=lsp[i-1]+m;
|
||||
|
||||
if (lsp[i]>lsp[i+1]-m)
|
||||
lsp[i]= SHR16(lsp[i],1) + SHR16(lsp[i+1]-m,1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t tmp = DIV32_16(SHL32(EXTEND32(1 + subframe),14),nb_subframes);
|
||||
spx_word16_t tmp2 = 16384-tmp;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
interp_lsp[i] = MULT16_16_P14(tmp2,old_lsp[i]) + MULT16_16_P14(tmp,new_lsp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*Makes sure the LSPs are stable*/
|
||||
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin)
|
||||
{
|
||||
int i;
|
||||
if (lsp[0]<LSP_SCALING*margin)
|
||||
lsp[0]=LSP_SCALING*margin;
|
||||
if (lsp[len-1]>LSP_SCALING*(M_PI-margin))
|
||||
lsp[len-1]=LSP_SCALING*(M_PI-margin);
|
||||
for (i=1;i<len-1;i++)
|
||||
{
|
||||
if (lsp[i]<lsp[i-1]+LSP_SCALING*margin)
|
||||
lsp[i]=lsp[i-1]+LSP_SCALING*margin;
|
||||
|
||||
if (lsp[i]>lsp[i+1]-LSP_SCALING*margin)
|
||||
lsp[i]= .5f* (lsp[i] + lsp[i+1]-LSP_SCALING*margin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
|
||||
{
|
||||
int i;
|
||||
float tmp = (1.0f + subframe)/nb_subframes;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
interp_lsp[i] = (1-tmp)*old_lsp[i] + tmp*new_lsp[i];
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,64 +0,0 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
Original Copyright
|
||||
FILE........: AK2LSPD.H
|
||||
TYPE........: Turbo C header file
|
||||
COMPANY.....: Voicetronix
|
||||
AUTHOR......: James Whitehall
|
||||
DATE CREATED: 21/11/95
|
||||
|
||||
Modified by Jean-Marc Valin
|
||||
|
||||
This file contains functions for converting Linear Prediction
|
||||
Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
|
||||
LSP coefficients are not in radians format but in the x domain of the
|
||||
unit circle.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
@file lsp.h
|
||||
@brief Line Spectral Pair (LSP) functions.
|
||||
*/
|
||||
/* Speex License:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __AK2LSPD__
|
||||
#define __AK2LSPD__
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
|
||||
void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
|
||||
|
||||
/*Added by JMV*/
|
||||
void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
|
||||
|
||||
void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
|
||||
|
||||
#endif /* __AK2LSPD__ */
|
|
@ -1,89 +0,0 @@
|
|||
/* Copyright (C) 2006 David Rowe */
|
||||
/**
|
||||
@file lsp_bfin.h
|
||||
@author David Rowe
|
||||
@brief LSP routines optimised for the Blackfin
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_CHEB_POLY_EVA
|
||||
#ifdef OVERRIDE_CHEB_POLY_EVA
|
||||
static inline spx_word32_t cheb_poly_eva(
|
||||
spx_word16_t *coef, /* P or Q coefs in Q13 format */
|
||||
spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */
|
||||
int m, /* LPC order/2 */
|
||||
char *stack
|
||||
)
|
||||
{
|
||||
spx_word32_t sum;
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"P0 = %2;\n\t" /* P0: coef[m], coef[m-1],..., coef[0] */
|
||||
"R4 = 8192;\n\t" /* R4: rounding constant */
|
||||
"R2 = %1;\n\t" /* R2: x */
|
||||
|
||||
"R5 = -16383;\n\t"
|
||||
"R2 = MAX(R2,R5);\n\t"
|
||||
"R5 = 16383;\n\t"
|
||||
"R2 = MIN(R2,R5);\n\t"
|
||||
|
||||
"R3 = W[P0--] (X);\n\t" /* R3: sum */
|
||||
"R5 = W[P0--] (X);\n\t"
|
||||
"R5 = R5.L * R2.L (IS);\n\t"
|
||||
"R5 = R5 + R4;\n\t"
|
||||
"R5 >>>= 14;\n\t"
|
||||
"R3 = R3 + R5;\n\t"
|
||||
|
||||
"R0 = R2;\n\t" /* R0: b0 */
|
||||
"R1 = 16384;\n\t" /* R1: b1 */
|
||||
"LOOP cpe%= LC0 = %3;\n\t"
|
||||
"LOOP_BEGIN cpe%=;\n\t"
|
||||
"P1 = R0;\n\t"
|
||||
"R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t"
|
||||
"R0 >>>= 13;\n\t"
|
||||
"R0 = R0 - R1;\n\t"
|
||||
"R1 = P1;\n\t"
|
||||
"R5 = R5.L * R0.L (IS);\n\t"
|
||||
"R5 = R5 + R4;\n\t"
|
||||
"R5 >>>= 14;\n\t"
|
||||
"R3 = R3 + R5;\n\t"
|
||||
"LOOP_END cpe%=;\n\t"
|
||||
"%0 = R3;\n\t"
|
||||
: "=&d" (sum)
|
||||
: "a" (x), "a" (&coef[m]), "a" (m-1)
|
||||
: "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1"
|
||||
);
|
||||
return sum;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,360 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: lsp_tables_nb.c
|
||||
Codebooks for LSPs in narrowband CELP mode
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const signed char cdbk_nb[640]={
|
||||
30,19,38,34,40,32,46,43,58,43,
|
||||
5,-18,-25,-40,-33,-55,-52,20,34,28,
|
||||
-20,-63,-97,-92,61,53,47,49,53,75,
|
||||
-14,-53,-77,-79,0,-3,-5,19,22,26,
|
||||
-9,-53,-55,66,90,72,85,68,74,52,
|
||||
-4,-41,-58,-31,-18,-31,27,32,30,18,
|
||||
24,3,8,5,-12,-3,26,28,74,63,
|
||||
-2,-39,-67,-77,-106,-74,59,59,73,65,
|
||||
44,40,71,72,82,83,98,88,89,60,
|
||||
-6,-31,-47,-48,-13,-39,-9,7,2,79,
|
||||
-1,-39,-60,-17,87,81,65,50,45,19,
|
||||
-21,-67,-91,-87,-41,-50,7,18,39,74,
|
||||
10,-31,-28,39,24,13,23,5,56,45,
|
||||
29,10,-5,-13,-11,-35,-18,-8,-10,-8,
|
||||
-25,-71,-77,-21,2,16,50,63,87,87,
|
||||
5,-32,-40,-51,-68,0,12,6,54,34,
|
||||
5,-12,32,52,68,64,69,59,65,45,
|
||||
14,-16,-31,-40,-65,-67,41,49,47,37,
|
||||
-11,-52,-75,-84,-4,57,48,42,42,33,
|
||||
-11,-51,-68,-6,13,0,8,-8,26,32,
|
||||
-23,-53,0,36,56,76,97,105,111,97,
|
||||
-1,-28,-39,-40,-43,-54,-44,-40,-18,35,
|
||||
16,-20,-19,-28,-42,29,47,38,74,45,
|
||||
3,-29,-48,-62,-80,-104,-33,56,59,59,
|
||||
10,17,46,72,84,101,117,123,123,106,
|
||||
-7,-33,-49,-51,-70,-67,-27,-31,70,67,
|
||||
-16,-62,-85,-20,82,71,86,80,85,74,
|
||||
-19,-58,-75,-45,-29,-33,-18,-25,45,57,
|
||||
-12,-42,-5,12,28,36,52,64,81,82,
|
||||
13,-9,-27,-28,22,3,2,22,26,6,
|
||||
-6,-44,-51,2,15,10,48,43,49,34,
|
||||
-19,-62,-84,-89,-102,-24,8,17,61,68,
|
||||
39,24,23,19,16,-5,12,15,27,15,
|
||||
-8,-44,-49,-60,-18,-32,-28,52,54,62,
|
||||
-8,-48,-77,-70,66,101,83,63,61,37,
|
||||
-12,-50,-75,-64,33,17,13,25,15,77,
|
||||
1,-42,-29,72,64,46,49,31,61,44,
|
||||
-8,-47,-54,-46,-30,19,20,-1,-16,0,
|
||||
16,-12,-18,-9,-26,-27,-10,-22,53,45,
|
||||
-10,-47,-75,-82,-105,-109,8,25,49,77,
|
||||
50,65,114,117,124,118,115,96,90,61,
|
||||
-9,-45,-63,-60,-75,-57,8,11,20,29,
|
||||
0,-35,-49,-43,40,47,35,40,55,38,
|
||||
-24,-76,-103,-112,-27,3,23,34,52,75,
|
||||
8,-29,-43,12,63,38,35,29,24,8,
|
||||
25,11,1,-15,-18,-43,-7,37,40,21,
|
||||
-20,-56,-19,-19,-4,-2,11,29,51,63,
|
||||
-2,-44,-62,-75,-89,30,57,51,74,51,
|
||||
50,46,68,64,65,52,63,55,65,43,
|
||||
18,-9,-26,-35,-55,-69,3,6,8,17,
|
||||
-15,-61,-86,-97,1,86,93,74,78,67,
|
||||
-1,-38,-66,-48,48,39,29,25,17,-1,
|
||||
13,13,29,39,50,51,69,82,97,98,
|
||||
-2,-36,-46,-27,-16,-30,-13,-4,-7,-4,
|
||||
25,-5,-11,-6,-25,-21,33,12,31,29,
|
||||
-8,-38,-52,-63,-68,-89,-33,-1,10,74,
|
||||
-2,-15,59,91,105,105,101,87,84,62,
|
||||
-7,-33,-50,-35,-54,-47,25,17,82,81,
|
||||
-13,-56,-83,21,58,31,42,25,72,65,
|
||||
-24,-66,-91,-56,9,-2,21,10,69,75,
|
||||
2,-24,11,22,25,28,38,34,48,33,
|
||||
7,-29,-26,17,15,-1,14,0,-2,0,
|
||||
-6,-41,-67,6,-2,-9,19,2,85,74,
|
||||
-22,-67,-84,-71,-50,3,11,-9,2,62};
|
||||
|
||||
const signed char cdbk_nb_low1[320]={
|
||||
-34,-52,-15,45,2,
|
||||
23,21,52,24,-33,
|
||||
-9,-1,9,-44,-41,
|
||||
-13,-17,44,22,-17,
|
||||
-6,-4,-1,22,38,
|
||||
26,16,2,50,27,
|
||||
-35,-34,-9,-41,6,
|
||||
0,-16,-34,51,8,
|
||||
-14,-31,-49,15,-33,
|
||||
45,49,33,-11,-37,
|
||||
-62,-54,45,11,-5,
|
||||
-72,11,-1,-12,-11,
|
||||
24,27,-11,-43,46,
|
||||
43,33,-12,-9,-1,
|
||||
1,-4,-23,-57,-71,
|
||||
11,8,16,17,-8,
|
||||
-20,-31,-41,53,48,
|
||||
-16,3,65,-24,-8,
|
||||
-23,-32,-37,-32,-49,
|
||||
-10,-17,6,38,5,
|
||||
-9,-17,-46,8,52,
|
||||
3,6,45,40,39,
|
||||
-7,-6,-34,-74,31,
|
||||
8,1,-16,43,68,
|
||||
-11,-19,-31,4,6,
|
||||
0,-6,-17,-16,-38,
|
||||
-16,-30,2,9,-39,
|
||||
-16,-1,43,-10,48,
|
||||
3,3,-16,-31,-3,
|
||||
62,68,43,13,3,
|
||||
-10,8,20,-56,12,
|
||||
12,-2,-18,22,-15,
|
||||
-40,-36,1,7,41,
|
||||
0,1,46,-6,-62,
|
||||
-4,-12,-2,-11,-83,
|
||||
-13,-2,91,33,-10,
|
||||
0,4,-11,-16,79,
|
||||
32,37,14,9,51,
|
||||
-21,-28,-56,-34,0,
|
||||
21,9,-26,11,28,
|
||||
-42,-54,-23,-2,-15,
|
||||
31,30,8,-39,-66,
|
||||
-39,-36,31,-28,-40,
|
||||
-46,35,40,22,24,
|
||||
33,48,23,-34,14,
|
||||
40,32,17,27,-3,
|
||||
25,26,-13,-61,-17,
|
||||
11,4,31,60,-6,
|
||||
-26,-41,-64,13,16,
|
||||
-26,54,31,-11,-23,
|
||||
-9,-11,-34,-71,-21,
|
||||
-34,-35,55,50,29,
|
||||
-22,-27,-50,-38,57,
|
||||
33,42,57,48,26,
|
||||
11,0,-49,-31,26,
|
||||
-4,-14,5,78,37,
|
||||
17,0,-49,-12,-23,
|
||||
26,14,2,2,-43,
|
||||
-17,-12,10,-8,-4,
|
||||
8,18,12,-6,20,
|
||||
-12,-6,-13,-25,34,
|
||||
15,40,49,7,8,
|
||||
13,20,20,-19,-22,
|
||||
-2,-8,2,51,-51};
|
||||
|
||||
const signed char cdbk_nb_low2[320]={
|
||||
-6,53,-21,-24,4,
|
||||
26,17,-4,-37,25,
|
||||
17,-36,-13,31,3,
|
||||
-6,27,15,-10,31,
|
||||
28,26,-10,-10,-40,
|
||||
16,-7,15,13,41,
|
||||
-9,0,-4,50,-6,
|
||||
-7,14,38,22,0,
|
||||
-48,2,1,-13,-19,
|
||||
32,-3,-60,11,-17,
|
||||
-1,-24,-34,-1,35,
|
||||
-5,-27,28,44,13,
|
||||
25,15,42,-11,15,
|
||||
51,35,-36,20,8,
|
||||
-4,-12,-29,19,-47,
|
||||
49,-15,-4,16,-29,
|
||||
-39,14,-30,4,25,
|
||||
-9,-5,-51,-14,-3,
|
||||
-40,-32,38,5,-9,
|
||||
-8,-4,-1,-22,71,
|
||||
-3,14,26,-18,-22,
|
||||
24,-41,-25,-24,6,
|
||||
23,19,-10,39,-26,
|
||||
-27,65,45,2,-7,
|
||||
-26,-8,22,-12,16,
|
||||
15,16,-35,-5,33,
|
||||
-21,-8,0,23,33,
|
||||
34,6,21,36,6,
|
||||
-7,-22,8,-37,-14,
|
||||
31,38,11,-4,-3,
|
||||
-39,-32,-8,32,-23,
|
||||
-6,-12,16,20,-28,
|
||||
-4,23,13,-52,-1,
|
||||
22,6,-33,-40,-6,
|
||||
4,-62,13,5,-26,
|
||||
35,39,11,2,57,
|
||||
-11,9,-20,-28,-33,
|
||||
52,-5,-6,-2,22,
|
||||
-14,-16,-48,35,1,
|
||||
-58,20,13,33,-1,
|
||||
-74,56,-18,-22,-31,
|
||||
12,6,-14,4,-2,
|
||||
-9,-47,10,-3,29,
|
||||
-17,-5,61,14,47,
|
||||
-12,2,72,-39,-17,
|
||||
92,64,-53,-51,-15,
|
||||
-30,-38,-41,-29,-28,
|
||||
27,9,36,9,-35,
|
||||
-42,81,-21,20,25,
|
||||
-16,-5,-17,-35,21,
|
||||
15,-28,48,2,-2,
|
||||
9,-19,29,-40,30,
|
||||
-18,-18,18,-16,-57,
|
||||
15,-20,-12,-15,-37,
|
||||
-15,33,-39,21,-22,
|
||||
-13,35,11,13,-38,
|
||||
-63,29,23,-27,32,
|
||||
18,3,-26,42,33,
|
||||
-64,-66,-17,16,56,
|
||||
2,36,3,31,21,
|
||||
-41,-39,8,-57,14,
|
||||
37,-2,19,-36,-19,
|
||||
-23,-29,-16,1,-3,
|
||||
-8,-10,31,64,-65};
|
||||
|
||||
const signed char cdbk_nb_high1[320]={
|
||||
-26,-8,29,21,4,
|
||||
19,-39,33,-7,-36,
|
||||
56,54,48,40,29,
|
||||
-4,-24,-42,-66,-43,
|
||||
-60,19,-2,37,41,
|
||||
-10,-37,-60,-64,18,
|
||||
-22,77,73,40,25,
|
||||
4,19,-19,-66,-2,
|
||||
11,5,21,14,26,
|
||||
-25,-86,-4,18,1,
|
||||
26,-37,10,37,-1,
|
||||
24,-12,-59,-11,20,
|
||||
-6,34,-16,-16,42,
|
||||
19,-28,-51,53,32,
|
||||
4,10,62,21,-12,
|
||||
-34,27,4,-48,-48,
|
||||
-50,-49,31,-7,-21,
|
||||
-42,-25,-4,-43,-22,
|
||||
59,2,27,12,-9,
|
||||
-6,-16,-8,-32,-58,
|
||||
-16,-29,-5,41,23,
|
||||
-30,-33,-46,-13,-10,
|
||||
-38,52,52,1,-17,
|
||||
-9,10,26,-25,-6,
|
||||
33,-20,53,55,25,
|
||||
-32,-5,-42,23,21,
|
||||
66,5,-28,20,9,
|
||||
75,29,-7,-42,-39,
|
||||
15,3,-23,21,6,
|
||||
11,1,-29,14,63,
|
||||
10,54,26,-24,-51,
|
||||
-49,7,-23,-51,15,
|
||||
-66,1,60,25,10,
|
||||
0,-30,-4,-15,17,
|
||||
19,59,40,4,-5,
|
||||
33,6,-22,-58,-70,
|
||||
-5,23,-6,60,44,
|
||||
-29,-16,-47,-29,52,
|
||||
-19,50,28,16,35,
|
||||
31,36,0,-21,6,
|
||||
21,27,22,42,7,
|
||||
-66,-40,-8,7,19,
|
||||
46,0,-4,60,36,
|
||||
45,-7,-29,-6,-32,
|
||||
-39,2,6,-9,33,
|
||||
20,-51,-34,18,-6,
|
||||
19,6,11,5,-19,
|
||||
-29,-2,42,-11,-45,
|
||||
-21,-55,57,37,2,
|
||||
-14,-67,-16,-27,-38,
|
||||
69,48,19,2,-17,
|
||||
20,-20,-16,-34,-17,
|
||||
-25,-61,10,73,45,
|
||||
16,-40,-64,-17,-29,
|
||||
-22,56,17,-39,8,
|
||||
-11,8,-25,-18,-13,
|
||||
-19,8,54,57,36,
|
||||
-17,-26,-4,6,-21,
|
||||
40,42,-4,20,31,
|
||||
53,10,-34,-53,31,
|
||||
-17,35,0,15,-6,
|
||||
-20,-63,-73,22,25,
|
||||
29,17,8,-29,-39,
|
||||
-69,18,15,-15,-5};
|
||||
|
||||
const signed char cdbk_nb_high2[320]={
|
||||
11,47,16,-9,-46,
|
||||
-32,26,-64,34,-5,
|
||||
38,-7,47,20,2,
|
||||
-73,-99,-3,-45,20,
|
||||
70,-52,15,-6,-7,
|
||||
-82,31,21,47,51,
|
||||
39,-3,9,0,-41,
|
||||
-7,-15,-54,2,0,
|
||||
27,-31,9,-45,-22,
|
||||
-38,-24,-24,8,-33,
|
||||
23,5,50,-36,-17,
|
||||
-18,-51,-2,13,19,
|
||||
43,12,-15,-12,61,
|
||||
38,38,7,13,0,
|
||||
6,-1,3,62,9,
|
||||
27,22,-33,38,-35,
|
||||
-9,30,-43,-9,-32,
|
||||
-1,4,-4,1,-5,
|
||||
-11,-8,38,31,11,
|
||||
-10,-42,-21,-37,1,
|
||||
43,15,-13,-35,-19,
|
||||
-18,15,23,-26,59,
|
||||
1,-21,53,8,-41,
|
||||
-50,-14,-28,4,21,
|
||||
25,-28,-40,5,-40,
|
||||
-41,4,51,-33,-8,
|
||||
-8,1,17,-60,12,
|
||||
25,-41,17,34,43,
|
||||
19,45,7,-37,24,
|
||||
-15,56,-2,35,-10,
|
||||
48,4,-47,-2,5,
|
||||
-5,-54,5,-3,-33,
|
||||
-10,30,-2,-44,-24,
|
||||
-38,9,-9,42,4,
|
||||
6,-56,44,-16,9,
|
||||
-40,-26,18,-20,10,
|
||||
28,-41,-21,-4,13,
|
||||
-18,32,-30,-3,37,
|
||||
15,22,28,50,-40,
|
||||
3,-29,-64,7,51,
|
||||
-19,-11,17,-27,-40,
|
||||
-64,24,-12,-7,-27,
|
||||
3,37,48,-1,2,
|
||||
-9,-38,-34,46,1,
|
||||
27,-6,19,-13,26,
|
||||
10,34,20,25,40,
|
||||
50,-6,-7,30,9,
|
||||
-24,0,-23,71,-61,
|
||||
22,58,-34,-4,2,
|
||||
-49,-33,25,30,-8,
|
||||
-6,-16,77,2,38,
|
||||
-8,-35,-6,-30,56,
|
||||
78,31,33,-20,13,
|
||||
-39,20,22,4,21,
|
||||
-8,4,-6,10,-83,
|
||||
-41,9,-25,-43,15,
|
||||
-7,-12,-34,-39,-37,
|
||||
-33,19,30,16,-33,
|
||||
42,-25,25,-68,44,
|
||||
-15,-11,-4,23,50,
|
||||
14,4,-39,-43,20,
|
||||
-30,60,9,-20,7,
|
||||
16,19,-33,37,29,
|
||||
16,-35,7,38,-27};
|
|
@ -1,854 +0,0 @@
|
|||
/* Copyright (C) 2002-2006 Jean-Marc Valin
|
||||
File: ltp.c
|
||||
Long-Term Prediction functions
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include "ltp.h"
|
||||
#include "stack_alloc.h"
|
||||
#include "filters.h"
|
||||
#include <speex/speex_bits.h>
|
||||
#include "math_approx.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _USE_SSE
|
||||
#include "ltp_sse.h"
|
||||
#elif defined (ARM4_ASM) || defined(ARM5E_ASM)
|
||||
#include "ltp_arm4.h"
|
||||
#elif defined (BFIN_ASM)
|
||||
#include "ltp_bfin.h"
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_INNER_PROD
|
||||
spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
|
||||
{
|
||||
spx_word32_t sum=0;
|
||||
len >>= 2;
|
||||
while(len--)
|
||||
{
|
||||
spx_word32_t part=0;
|
||||
part = MAC16_16(part,*x++,*y++);
|
||||
part = MAC16_16(part,*x++,*y++);
|
||||
part = MAC16_16(part,*x++,*y++);
|
||||
part = MAC16_16(part,*x++,*y++);
|
||||
/* HINT: If you had a 40-bit accumulator, you could shift only at the end */
|
||||
sum = ADD32(sum,SHR32(part,6));
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_PITCH_XCORR
|
||||
#if 0 /* HINT: Enable this for machines with enough registers (i.e. not x86) */
|
||||
void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
for (i=0;i<nb_pitch;i+=4)
|
||||
{
|
||||
/* Compute correlation*/
|
||||
/*corr[nb_pitch-1-i]=inner_prod(x, _y+i, len);*/
|
||||
spx_word32_t sum1=0;
|
||||
spx_word32_t sum2=0;
|
||||
spx_word32_t sum3=0;
|
||||
spx_word32_t sum4=0;
|
||||
const spx_word16_t *y = _y+i;
|
||||
const spx_word16_t *x = _x;
|
||||
spx_word16_t y0, y1, y2, y3;
|
||||
/*y0=y[0];y1=y[1];y2=y[2];y3=y[3];*/
|
||||
y0=*y++;
|
||||
y1=*y++;
|
||||
y2=*y++;
|
||||
y3=*y++;
|
||||
for (j=0;j<len;j+=4)
|
||||
{
|
||||
spx_word32_t part1;
|
||||
spx_word32_t part2;
|
||||
spx_word32_t part3;
|
||||
spx_word32_t part4;
|
||||
part1 = MULT16_16(*x,y0);
|
||||
part2 = MULT16_16(*x,y1);
|
||||
part3 = MULT16_16(*x,y2);
|
||||
part4 = MULT16_16(*x,y3);
|
||||
x++;
|
||||
y0=*y++;
|
||||
part1 = MAC16_16(part1,*x,y1);
|
||||
part2 = MAC16_16(part2,*x,y2);
|
||||
part3 = MAC16_16(part3,*x,y3);
|
||||
part4 = MAC16_16(part4,*x,y0);
|
||||
x++;
|
||||
y1=*y++;
|
||||
part1 = MAC16_16(part1,*x,y2);
|
||||
part2 = MAC16_16(part2,*x,y3);
|
||||
part3 = MAC16_16(part3,*x,y0);
|
||||
part4 = MAC16_16(part4,*x,y1);
|
||||
x++;
|
||||
y2=*y++;
|
||||
part1 = MAC16_16(part1,*x,y3);
|
||||
part2 = MAC16_16(part2,*x,y0);
|
||||
part3 = MAC16_16(part3,*x,y1);
|
||||
part4 = MAC16_16(part4,*x,y2);
|
||||
x++;
|
||||
y3=*y++;
|
||||
|
||||
sum1 = ADD32(sum1,SHR32(part1,6));
|
||||
sum2 = ADD32(sum2,SHR32(part2,6));
|
||||
sum3 = ADD32(sum3,SHR32(part3,6));
|
||||
sum4 = ADD32(sum4,SHR32(part4,6));
|
||||
}
|
||||
corr[nb_pitch-1-i]=sum1;
|
||||
corr[nb_pitch-2-i]=sum2;
|
||||
corr[nb_pitch-3-i]=sum3;
|
||||
corr[nb_pitch-4-i]=sum4;
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<nb_pitch;i++)
|
||||
{
|
||||
/* Compute correlation*/
|
||||
corr[nb_pitch-1-i]=inner_prod(_x, _y+i, len);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_COMPUTE_PITCH_ERROR
|
||||
static inline spx_word32_t compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control)
|
||||
{
|
||||
spx_word32_t sum = 0;
|
||||
sum = ADD32(sum,MULT16_16(MULT16_16_16(g[0],pitch_control),C[0]));
|
||||
sum = ADD32(sum,MULT16_16(MULT16_16_16(g[1],pitch_control),C[1]));
|
||||
sum = ADD32(sum,MULT16_16(MULT16_16_16(g[2],pitch_control),C[2]));
|
||||
sum = SUB32(sum,MULT16_16(MULT16_16_16(g[0],g[1]),C[3]));
|
||||
sum = SUB32(sum,MULT16_16(MULT16_16_16(g[2],g[1]),C[4]));
|
||||
sum = SUB32(sum,MULT16_16(MULT16_16_16(g[2],g[0]),C[5]));
|
||||
sum = SUB32(sum,MULT16_16(MULT16_16_16(g[0],g[0]),C[6]));
|
||||
sum = SUB32(sum,MULT16_16(MULT16_16_16(g[1],g[1]),C[7]));
|
||||
sum = SUB32(sum,MULT16_16(MULT16_16_16(g[2],g[2]),C[8]));
|
||||
return sum;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_OPEN_LOOP_NBEST_PITCH
|
||||
void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack)
|
||||
{
|
||||
int i,j,k;
|
||||
VARDECL(spx_word32_t *best_score);
|
||||
VARDECL(spx_word32_t *best_ener);
|
||||
spx_word32_t e0;
|
||||
VARDECL(spx_word32_t *corr);
|
||||
VARDECL(spx_word32_t *energy);
|
||||
#ifdef FIXED_POINT
|
||||
int scaledown = 0;
|
||||
#endif
|
||||
|
||||
ALLOC(best_score, N, spx_word32_t);
|
||||
ALLOC(best_ener, N, spx_word32_t);
|
||||
ALLOC(corr, end-start+1, spx_word32_t);
|
||||
ALLOC(energy, end-start+2, spx_word32_t);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
best_score[i]=-1;
|
||||
best_ener[i]=0;
|
||||
pitch[i]=start;
|
||||
}
|
||||
#ifdef FIXED_POINT
|
||||
for (i=-end;i<len;i++)
|
||||
{
|
||||
if (ABS16(sw[i])>16383)
|
||||
{
|
||||
scaledown=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* If the weighted input is close to saturation, then we scale it down */
|
||||
if (scaledown)
|
||||
{
|
||||
for (i=-end;i<len;i++)
|
||||
{
|
||||
sw[i]=SHR16(sw[i],1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
energy[0]=inner_prod(sw-start, sw-start, len);
|
||||
e0=inner_prod(sw, sw, len);
|
||||
for (i=start;i<end;i++)
|
||||
{
|
||||
/* Update energy for next pitch*/
|
||||
energy[i-start+1] = SUB32(ADD32(energy[i-start],SHR32(MULT16_16(sw[-i-1],sw[-i-1]),6)), SHR32(MULT16_16(sw[-i+len-1],sw[-i+len-1]),6));
|
||||
if (energy[i-start+1] < 0)
|
||||
energy[i-start+1] = 0;
|
||||
}
|
||||
|
||||
pitch_xcorr(sw, sw-end, corr, len, end-start+1, stack);
|
||||
#ifdef FIXED_POINT
|
||||
/* If we scaled weighted input down, we need to scale it up again (OK, so we've just lost the LSB, who cares?) */
|
||||
if (scaledown)
|
||||
{
|
||||
for (i=-end;i<len;i++)
|
||||
{
|
||||
sw[i]=SHL16(sw[i],1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* FIXME: Fixed-point and floating-point code should be merged */
|
||||
#ifdef FIXED_POINT
|
||||
{
|
||||
VARDECL(spx_word16_t *corr16);
|
||||
VARDECL(spx_word16_t *ener16);
|
||||
ALLOC(corr16, end-start+1, spx_word16_t);
|
||||
ALLOC(ener16, end-start+1, spx_word16_t);
|
||||
/* Normalize to 180 so we can square it and it still fits in 16 bits */
|
||||
normalize16(corr, corr16, 180, end-start+1);
|
||||
normalize16(energy, ener16, 180, end-start+1);
|
||||
|
||||
for (i=start;i<=end;i++)
|
||||
{
|
||||
spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]);
|
||||
/* Instead of dividing the tmp by the energy, we multiply on the other side */
|
||||
if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start])))
|
||||
{
|
||||
/* We can safely put it last and then check */
|
||||
best_score[N-1]=tmp;
|
||||
best_ener[N-1]=ener16[i-start]+1;
|
||||
pitch[N-1]=i;
|
||||
/* Check if it comes in front of others */
|
||||
for (j=0;j<N-1;j++)
|
||||
{
|
||||
if (MULT16_16(tmp,best_ener[j])>MULT16_16(best_score[j],ADD16(1,ener16[i-start])))
|
||||
{
|
||||
for (k=N-1;k>j;k--)
|
||||
{
|
||||
best_score[k]=best_score[k-1];
|
||||
best_ener[k]=best_ener[k-1];
|
||||
pitch[k]=pitch[k-1];
|
||||
}
|
||||
best_score[j]=tmp;
|
||||
best_ener[j]=ener16[i-start]+1;
|
||||
pitch[j]=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (i=start;i<=end;i++)
|
||||
{
|
||||
float tmp = corr[i-start]*corr[i-start];
|
||||
if (tmp*best_ener[N-1]>best_score[N-1]*(1+energy[i-start]))
|
||||
{
|
||||
for (j=0;j<N;j++)
|
||||
{
|
||||
if (tmp*best_ener[j]>best_score[j]*(1+energy[i-start]))
|
||||
{
|
||||
for (k=N-1;k>j;k--)
|
||||
{
|
||||
best_score[k]=best_score[k-1];
|
||||
best_ener[k]=best_ener[k-1];
|
||||
pitch[k]=pitch[k-1];
|
||||
}
|
||||
best_score[j]=tmp;
|
||||
best_ener[j]=energy[i-start]+1;
|
||||
pitch[j]=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Compute open-loop gain */
|
||||
if (gain)
|
||||
{
|
||||
for (j=0;j<N;j++)
|
||||
{
|
||||
spx_word16_t g;
|
||||
i=pitch[j];
|
||||
g = DIV32(corr[i-start], 10+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
|
||||
/* FIXME: g = max(g,corr/energy) */
|
||||
if (g<0)
|
||||
g = 0;
|
||||
gain[j]=g;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_PITCH_GAIN_SEARCH_3TAP_VQ
|
||||
static int pitch_gain_search_3tap_vq(
|
||||
const signed char *gain_cdbk,
|
||||
int gain_cdbk_size,
|
||||
spx_word16_t *C16,
|
||||
spx_word16_t max_gain
|
||||
)
|
||||
{
|
||||
const signed char *ptr=gain_cdbk;
|
||||
int best_cdbk=0;
|
||||
spx_word32_t best_sum=-VERY_LARGE32;
|
||||
spx_word32_t sum=0;
|
||||
spx_word16_t g[3];
|
||||
spx_word16_t pitch_control=64;
|
||||
spx_word16_t gain_sum;
|
||||
int i;
|
||||
|
||||
for (i=0;i<gain_cdbk_size;i++) {
|
||||
|
||||
ptr = gain_cdbk+4*i;
|
||||
g[0]=ADD16((spx_word16_t)ptr[0],32);
|
||||
g[1]=ADD16((spx_word16_t)ptr[1],32);
|
||||
g[2]=ADD16((spx_word16_t)ptr[2],32);
|
||||
gain_sum = (spx_word16_t)ptr[3];
|
||||
|
||||
sum = compute_pitch_error(C16, g, pitch_control);
|
||||
|
||||
if (sum>best_sum && gain_sum<=max_gain) {
|
||||
best_sum=sum;
|
||||
best_cdbk=i;
|
||||
}
|
||||
}
|
||||
|
||||
return best_cdbk;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
|
||||
static spx_word32_t pitch_gain_search_3tap(
|
||||
const spx_word16_t target[], /* Target vector */
|
||||
const spx_coef_t ak[], /* LPCs for this subframe */
|
||||
const spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
|
||||
const spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
|
||||
spx_sig_t exc[], /* Excitation */
|
||||
const signed char *gain_cdbk,
|
||||
int gain_cdbk_size,
|
||||
int pitch, /* Pitch value */
|
||||
int p, /* Number of LPC coeffs */
|
||||
int nsf, /* Number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
const spx_word16_t *exc2,
|
||||
const spx_word16_t *r,
|
||||
spx_word16_t *new_target,
|
||||
int *cdbk_index,
|
||||
int plc_tuning,
|
||||
spx_word32_t cumul_gain,
|
||||
int scaledown
|
||||
)
|
||||
{
|
||||
int i,j;
|
||||
VARDECL(spx_word16_t *tmp1);
|
||||
VARDECL(spx_word16_t *e);
|
||||
spx_word16_t *x[3];
|
||||
spx_word32_t corr[3];
|
||||
spx_word32_t A[3][3];
|
||||
spx_word16_t gain[3];
|
||||
spx_word32_t err;
|
||||
spx_word16_t max_gain=128;
|
||||
int best_cdbk=0;
|
||||
|
||||
ALLOC(tmp1, 3*nsf, spx_word16_t);
|
||||
ALLOC(e, nsf, spx_word16_t);
|
||||
|
||||
if (cumul_gain > 262144)
|
||||
max_gain = 31;
|
||||
|
||||
x[0]=tmp1;
|
||||
x[1]=tmp1+nsf;
|
||||
x[2]=tmp1+2*nsf;
|
||||
|
||||
for (j=0;j<nsf;j++)
|
||||
new_target[j] = target[j];
|
||||
|
||||
{
|
||||
VARDECL(spx_mem_t *mm);
|
||||
int pp=pitch-1;
|
||||
ALLOC(mm, p, spx_mem_t);
|
||||
for (j=0;j<nsf;j++)
|
||||
{
|
||||
if (j-pp<0)
|
||||
e[j]=exc2[j-pp];
|
||||
else if (j-pp-pitch<0)
|
||||
e[j]=exc2[j-pp-pitch];
|
||||
else
|
||||
e[j]=0;
|
||||
}
|
||||
#ifdef FIXED_POINT
|
||||
/* Scale target and excitation down if needed (avoiding overflow) */
|
||||
if (scaledown)
|
||||
{
|
||||
for (j=0;j<nsf;j++)
|
||||
e[j] = SHR16(e[j],1);
|
||||
for (j=0;j<nsf;j++)
|
||||
new_target[j] = SHR16(new_target[j],1);
|
||||
}
|
||||
#endif
|
||||
for (j=0;j<p;j++)
|
||||
mm[j] = 0;
|
||||
iir_mem16(e, ak, e, nsf, p, mm, stack);
|
||||
for (j=0;j<p;j++)
|
||||
mm[j] = 0;
|
||||
filter_mem16(e, awk1, awk2, e, nsf, p, mm, stack);
|
||||
for (j=0;j<nsf;j++)
|
||||
x[2][j] = e[j];
|
||||
}
|
||||
for (i=1;i>=0;i--)
|
||||
{
|
||||
spx_word16_t e0=exc2[-pitch-1+i];
|
||||
#ifdef FIXED_POINT
|
||||
/* Scale excitation down if needed (avoiding overflow) */
|
||||
if (scaledown)
|
||||
e0 = SHR16(e0,1);
|
||||
#endif
|
||||
x[i][0]=MULT16_16_Q14(r[0], e0);
|
||||
for (j=0;j<nsf-1;j++)
|
||||
x[i][j+1]=ADD32(x[i+1][j],MULT16_16_P14(r[j+1], e0));
|
||||
}
|
||||
|
||||
for (i=0;i<3;i++)
|
||||
corr[i]=inner_prod(x[i],new_target,nsf);
|
||||
for (i=0;i<3;i++)
|
||||
for (j=0;j<=i;j++)
|
||||
A[i][j]=A[j][i]=inner_prod(x[i],x[j],nsf);
|
||||
|
||||
{
|
||||
spx_word32_t C[9];
|
||||
#ifdef FIXED_POINT
|
||||
spx_word16_t C16[9];
|
||||
#else
|
||||
spx_word16_t *C16=C;
|
||||
#endif
|
||||
C[0]=corr[2];
|
||||
C[1]=corr[1];
|
||||
C[2]=corr[0];
|
||||
C[3]=A[1][2];
|
||||
C[4]=A[0][1];
|
||||
C[5]=A[0][2];
|
||||
C[6]=A[2][2];
|
||||
C[7]=A[1][1];
|
||||
C[8]=A[0][0];
|
||||
|
||||
/*plc_tuning *= 2;*/
|
||||
if (plc_tuning<2)
|
||||
plc_tuning=2;
|
||||
if (plc_tuning>30)
|
||||
plc_tuning=30;
|
||||
#ifdef FIXED_POINT
|
||||
C[0] = SHL32(C[0],1);
|
||||
C[1] = SHL32(C[1],1);
|
||||
C[2] = SHL32(C[2],1);
|
||||
C[3] = SHL32(C[3],1);
|
||||
C[4] = SHL32(C[4],1);
|
||||
C[5] = SHL32(C[5],1);
|
||||
C[6] = MAC16_32_Q15(C[6],MULT16_16_16(plc_tuning,655),C[6]);
|
||||
C[7] = MAC16_32_Q15(C[7],MULT16_16_16(plc_tuning,655),C[7]);
|
||||
C[8] = MAC16_32_Q15(C[8],MULT16_16_16(plc_tuning,655),C[8]);
|
||||
normalize16(C, C16, 32767, 9);
|
||||
#else
|
||||
C[6]*=.5*(1+.02*plc_tuning);
|
||||
C[7]*=.5*(1+.02*plc_tuning);
|
||||
C[8]*=.5*(1+.02*plc_tuning);
|
||||
#endif
|
||||
|
||||
best_cdbk = pitch_gain_search_3tap_vq(gain_cdbk, gain_cdbk_size, C16, max_gain);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4]);
|
||||
gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4+1]);
|
||||
gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*4+2]);
|
||||
/*printf ("%d %d %d %d\n",gain[0],gain[1],gain[2], best_cdbk);*/
|
||||
#else
|
||||
gain[0] = 0.015625*gain_cdbk[best_cdbk*4] + .5;
|
||||
gain[1] = 0.015625*gain_cdbk[best_cdbk*4+1]+ .5;
|
||||
gain[2] = 0.015625*gain_cdbk[best_cdbk*4+2]+ .5;
|
||||
#endif
|
||||
*cdbk_index=best_cdbk;
|
||||
}
|
||||
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i]=0;
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
int j;
|
||||
int tmp1, tmp3;
|
||||
int pp=pitch+1-i;
|
||||
tmp1=nsf;
|
||||
if (tmp1>pp)
|
||||
tmp1=pp;
|
||||
for (j=0;j<tmp1;j++)
|
||||
exc[j]=MAC16_16(exc[j],SHL16(gain[2-i],7),exc2[j-pp]);
|
||||
tmp3=nsf;
|
||||
if (tmp3>pp+pitch)
|
||||
tmp3=pp+pitch;
|
||||
for (j=tmp1;j<tmp3;j++)
|
||||
exc[j]=MAC16_16(exc[j],SHL16(gain[2-i],7),exc2[j-pp-pitch]);
|
||||
}
|
||||
for (i=0;i<nsf;i++)
|
||||
{
|
||||
spx_word32_t tmp = ADD32(ADD32(MULT16_16(gain[0],x[2][i]),MULT16_16(gain[1],x[1][i])),
|
||||
MULT16_16(gain[2],x[0][i]));
|
||||
new_target[i] = SUB16(new_target[i], EXTRACT16(PSHR32(tmp,6)));
|
||||
}
|
||||
err = inner_prod(new_target, new_target, nsf);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
|
||||
int pitch_search_3tap(
|
||||
spx_word16_t target[], /* Target vector */
|
||||
spx_word16_t *sw,
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
|
||||
spx_sig_t exc[], /* Excitation */
|
||||
const void *par,
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
int p, /* Number of LPC coeffs */
|
||||
int nsf, /* Number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_word16_t *exc2,
|
||||
spx_word16_t *r,
|
||||
int complexity,
|
||||
int cdbk_offset,
|
||||
int plc_tuning,
|
||||
spx_word32_t *cumul_gain
|
||||
)
|
||||
{
|
||||
int i,j;
|
||||
int cdbk_index, pitch=0, best_gain_index=0;
|
||||
VARDECL(spx_sig_t *best_exc);
|
||||
VARDECL(spx_word16_t *new_target);
|
||||
VARDECL(spx_word16_t *best_target);
|
||||
int best_pitch=0;
|
||||
spx_word32_t err, best_err=-1;
|
||||
int N;
|
||||
const ltp_params *params;
|
||||
const signed char *gain_cdbk;
|
||||
int gain_cdbk_size;
|
||||
int scaledown=0;
|
||||
|
||||
VARDECL(int *nbest);
|
||||
|
||||
params = (const ltp_params*) par;
|
||||
gain_cdbk_size = 1<<params->gain_bits;
|
||||
gain_cdbk = params->gain_cdbk + 4*gain_cdbk_size*cdbk_offset;
|
||||
|
||||
N=complexity;
|
||||
if (N>10)
|
||||
N=10;
|
||||
if (N<1)
|
||||
N=1;
|
||||
|
||||
ALLOC(nbest, N, int);
|
||||
params = (const ltp_params*) par;
|
||||
|
||||
if (end<start)
|
||||
{
|
||||
speex_bits_pack(bits, 0, params->pitch_bits);
|
||||
speex_bits_pack(bits, 0, params->gain_bits);
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i]=0;
|
||||
return start;
|
||||
}
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
/* Check if we need to scale everything down in the pitch search to avoid overflows */
|
||||
for (i=0;i<nsf;i++)
|
||||
{
|
||||
if (ABS16(target[i])>16383)
|
||||
{
|
||||
scaledown=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i=-end;i<nsf;i++)
|
||||
{
|
||||
if (ABS16(exc2[i])>16383)
|
||||
{
|
||||
scaledown=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (N>end-start+1)
|
||||
N=end-start+1;
|
||||
if (end != start)
|
||||
open_loop_nbest_pitch(sw, start, end, nsf, nbest, NULL, N, stack);
|
||||
else
|
||||
nbest[0] = start;
|
||||
|
||||
ALLOC(best_exc, nsf, spx_sig_t);
|
||||
ALLOC(new_target, nsf, spx_word16_t);
|
||||
ALLOC(best_target, nsf, spx_word16_t);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
pitch=nbest[i];
|
||||
for (j=0;j<nsf;j++)
|
||||
exc[j]=0;
|
||||
err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, gain_cdbk, gain_cdbk_size, pitch, p, nsf,
|
||||
bits, stack, exc2, r, new_target, &cdbk_index, plc_tuning, *cumul_gain, scaledown);
|
||||
if (err<best_err || best_err<0)
|
||||
{
|
||||
for (j=0;j<nsf;j++)
|
||||
best_exc[j]=exc[j];
|
||||
for (j=0;j<nsf;j++)
|
||||
best_target[j]=new_target[j];
|
||||
best_err=err;
|
||||
best_pitch=pitch;
|
||||
best_gain_index=cdbk_index;
|
||||
}
|
||||
}
|
||||
/*printf ("pitch: %d %d\n", best_pitch, best_gain_index);*/
|
||||
speex_bits_pack(bits, best_pitch-start, params->pitch_bits);
|
||||
speex_bits_pack(bits, best_gain_index, params->gain_bits);
|
||||
#ifdef FIXED_POINT
|
||||
*cumul_gain = MULT16_32_Q13(SHL16(params->gain_cdbk[4*best_gain_index+3],8), MAX32(1024,*cumul_gain));
|
||||
#else
|
||||
*cumul_gain = 0.03125*MAX32(1024,*cumul_gain)*params->gain_cdbk[4*best_gain_index+3];
|
||||
#endif
|
||||
/*printf ("%f\n", cumul_gain);*/
|
||||
/*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/
|
||||
for (i=0;i<nsf;i++)
|
||||
exc[i]=best_exc[i];
|
||||
for (i=0;i<nsf;i++)
|
||||
target[i]=best_target[i];
|
||||
#ifdef FIXED_POINT
|
||||
/* Scale target back up if needed */
|
||||
if (scaledown)
|
||||
{
|
||||
for (i=0;i<nsf;i++)
|
||||
target[i]=SHL16(target[i],1);
|
||||
}
|
||||
#endif
|
||||
return pitch;
|
||||
}
|
||||
|
||||
void pitch_unquant_3tap(
|
||||
spx_word16_t exc[], /* Input excitation */
|
||||
spx_word32_t exc_out[], /* Output excitation */
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
const void *par,
|
||||
int nsf, /* Number of samples in subframe */
|
||||
int *pitch_val,
|
||||
spx_word16_t *gain_val,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int count_lost,
|
||||
int subframe_offset,
|
||||
spx_word16_t last_pitch_gain,
|
||||
int cdbk_offset
|
||||
)
|
||||
{
|
||||
int i;
|
||||
int pitch;
|
||||
int gain_index;
|
||||
spx_word16_t gain[3];
|
||||
const signed char *gain_cdbk;
|
||||
int gain_cdbk_size;
|
||||
const ltp_params *params;
|
||||
|
||||
params = (const ltp_params*) par;
|
||||
gain_cdbk_size = 1<<params->gain_bits;
|
||||
gain_cdbk = params->gain_cdbk + 4*gain_cdbk_size*cdbk_offset;
|
||||
|
||||
pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits);
|
||||
pitch += start;
|
||||
gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits);
|
||||
/*printf ("decode pitch: %d %d\n", pitch, gain_index);*/
|
||||
#ifdef FIXED_POINT
|
||||
gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4]);
|
||||
gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4+1]);
|
||||
gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*4+2]);
|
||||
#else
|
||||
gain[0] = 0.015625*gain_cdbk[gain_index*4]+.5;
|
||||
gain[1] = 0.015625*gain_cdbk[gain_index*4+1]+.5;
|
||||
gain[2] = 0.015625*gain_cdbk[gain_index*4+2]+.5;
|
||||
#endif
|
||||
|
||||
if (count_lost && pitch > subframe_offset)
|
||||
{
|
||||
spx_word16_t gain_sum;
|
||||
if (1) {
|
||||
#ifdef FIXED_POINT
|
||||
spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : SHR16(last_pitch_gain,1);
|
||||
if (tmp>62)
|
||||
tmp=62;
|
||||
#else
|
||||
spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : 0.5 * last_pitch_gain;
|
||||
if (tmp>.95)
|
||||
tmp=.95;
|
||||
#endif
|
||||
gain_sum = gain_3tap_to_1tap(gain);
|
||||
|
||||
if (gain_sum > tmp)
|
||||
{
|
||||
spx_word16_t fact = DIV32_16(SHL32(EXTEND32(tmp),14),gain_sum);
|
||||
for (i=0;i<3;i++)
|
||||
gain[i]=MULT16_16_Q14(fact,gain[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*pitch_val = pitch;
|
||||
gain_val[0]=gain[0];
|
||||
gain_val[1]=gain[1];
|
||||
gain_val[2]=gain[2];
|
||||
gain[0] = SHL16(gain[0],7);
|
||||
gain[1] = SHL16(gain[1],7);
|
||||
gain[2] = SHL16(gain[2],7);
|
||||
for (i=0;i<nsf;i++)
|
||||
exc_out[i]=0;
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
int j;
|
||||
int tmp1, tmp3;
|
||||
int pp=pitch+1-i;
|
||||
tmp1=nsf;
|
||||
if (tmp1>pp)
|
||||
tmp1=pp;
|
||||
for (j=0;j<tmp1;j++)
|
||||
exc_out[j]=MAC16_16(exc_out[j],gain[2-i],exc[j-pp]);
|
||||
tmp3=nsf;
|
||||
if (tmp3>pp+pitch)
|
||||
tmp3=pp+pitch;
|
||||
for (j=tmp1;j<tmp3;j++)
|
||||
exc_out[j]=MAC16_16(exc_out[j],gain[2-i],exc[j-pp-pitch]);
|
||||
}
|
||||
/*for (i=0;i<nsf;i++)
|
||||
exc[i]=PSHR32(exc32[i],13);*/
|
||||
}
|
||||
|
||||
|
||||
/** Forced pitch delay and gain */
|
||||
int forced_pitch_quant(
|
||||
spx_word16_t target[], /* Target vector */
|
||||
spx_word16_t *sw,
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
|
||||
spx_sig_t exc[], /* Excitation */
|
||||
const void *par,
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
int p, /* Number of LPC coeffs */
|
||||
int nsf, /* Number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_word16_t *exc2,
|
||||
spx_word16_t *r,
|
||||
int complexity,
|
||||
int cdbk_offset,
|
||||
int plc_tuning,
|
||||
spx_word32_t *cumul_gain
|
||||
)
|
||||
{
|
||||
int i;
|
||||
VARDECL(spx_sig_t *res);
|
||||
ALLOC(res, nsf, spx_sig_t);
|
||||
#ifdef FIXED_POINT
|
||||
if (pitch_coef>63)
|
||||
pitch_coef=63;
|
||||
#else
|
||||
if (pitch_coef>.99)
|
||||
pitch_coef=.99;
|
||||
#endif
|
||||
for (i=0;i<nsf&&i<start;i++)
|
||||
{
|
||||
exc[i]=MULT16_16(SHL16(pitch_coef, 7),exc2[i-start]);
|
||||
}
|
||||
for (;i<nsf;i++)
|
||||
{
|
||||
exc[i]=MULT16_32_Q15(SHL16(pitch_coef, 9),exc[i-start]);
|
||||
}
|
||||
syn_percep_zero(exc, ak, awk1, awk2, res, nsf, p, stack);
|
||||
for (i=0;i<nsf;i++)
|
||||
target[i]=EXTRACT16(SATURATE(SUB32(EXTEND32(target[i]),PSHR32(res[i],SIG_SHIFT-1)),32700));
|
||||
return start;
|
||||
}
|
||||
|
||||
/** Unquantize forced pitch delay and gain */
|
||||
void forced_pitch_unquant(
|
||||
spx_word16_t exc[], /* Input excitation */
|
||||
spx_word32_t exc_out[], /* Output excitation */
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
const void *par,
|
||||
int nsf, /* Number of samples in subframe */
|
||||
int *pitch_val,
|
||||
spx_word16_t *gain_val,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int count_lost,
|
||||
int subframe_offset,
|
||||
spx_word16_t last_pitch_gain,
|
||||
int cdbk_offset
|
||||
)
|
||||
{
|
||||
int i;
|
||||
#ifdef FIXED_POINT
|
||||
if (pitch_coef>63)
|
||||
pitch_coef=63;
|
||||
#else
|
||||
if (pitch_coef>.99)
|
||||
pitch_coef=.99;
|
||||
#endif
|
||||
for (i=0;i<nsf;i++)
|
||||
{
|
||||
exc_out[i]=MULT16_16(exc[i-start],SHL16(pitch_coef,7));
|
||||
exc[i] = PSHR(exc_out[i],13);
|
||||
}
|
||||
*pitch_val = start;
|
||||
gain_val[0]=gain_val[2]=0;
|
||||
gain_val[1] = pitch_coef;
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file ltp.h
|
||||
@brief Long-Term Prediction functions
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <speex/speex_bits.h>
|
||||
#include "misc.h"
|
||||
|
||||
/** LTP parameters. */
|
||||
typedef struct {
|
||||
const signed char *gain_cdbk;
|
||||
int gain_bits;
|
||||
int pitch_bits;
|
||||
} ltp_params;
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1)))
|
||||
#else
|
||||
#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2]))
|
||||
#endif
|
||||
|
||||
spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len);
|
||||
void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack);
|
||||
|
||||
void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack);
|
||||
|
||||
|
||||
/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
|
||||
int pitch_search_3tap(
|
||||
spx_word16_t target[], /* Target vector */
|
||||
spx_word16_t *sw,
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
|
||||
spx_sig_t exc[], /* Overlapping codebook */
|
||||
const void *par,
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
int p, /* Number of LPC coeffs */
|
||||
int nsf, /* Number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_word16_t *exc2,
|
||||
spx_word16_t *r,
|
||||
int complexity,
|
||||
int cdbk_offset,
|
||||
int plc_tuning,
|
||||
spx_word32_t *cumul_gain
|
||||
);
|
||||
|
||||
/*Unquantize adaptive codebook and update pitch contribution*/
|
||||
void pitch_unquant_3tap(
|
||||
spx_word16_t exc[], /* Input excitation */
|
||||
spx_word32_t exc_out[], /* Output excitation */
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
const void *par,
|
||||
int nsf, /* Number of samples in subframe */
|
||||
int *pitch_val,
|
||||
spx_word16_t *gain_val,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int lost,
|
||||
int subframe_offset,
|
||||
spx_word16_t last_pitch_gain,
|
||||
int cdbk_offset
|
||||
);
|
||||
|
||||
/** Forced pitch delay and gain */
|
||||
int forced_pitch_quant(
|
||||
spx_word16_t target[], /* Target vector */
|
||||
spx_word16_t *sw,
|
||||
spx_coef_t ak[], /* LPCs for this subframe */
|
||||
spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
|
||||
spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
|
||||
spx_sig_t exc[], /* Excitation */
|
||||
const void *par,
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
int p, /* Number of LPC coeffs */
|
||||
int nsf, /* Number of samples in subframe */
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
spx_word16_t *exc2,
|
||||
spx_word16_t *r,
|
||||
int complexity,
|
||||
int cdbk_offset,
|
||||
int plc_tuning,
|
||||
spx_word32_t *cumul_gain
|
||||
);
|
||||
|
||||
/** Unquantize forced pitch delay and gain */
|
||||
void forced_pitch_unquant(
|
||||
spx_word16_t exc[], /* Input excitation */
|
||||
spx_word32_t exc_out[], /* Output excitation */
|
||||
int start, /* Smallest pitch value allowed */
|
||||
int end, /* Largest pitch value allowed */
|
||||
spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
|
||||
const void *par,
|
||||
int nsf, /* Number of samples in subframe */
|
||||
int *pitch_val,
|
||||
spx_word16_t *gain_val,
|
||||
SpeexBits *bits,
|
||||
char *stack,
|
||||
int lost,
|
||||
int subframe_offset,
|
||||
spx_word16_t last_pitch_gain,
|
||||
int cdbk_offset
|
||||
);
|
|
@ -1,188 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file ltp_arm4.h
|
||||
@brief Long-Term Prediction functions (ARM4 version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_INNER_PROD
|
||||
spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
|
||||
{
|
||||
spx_word32_t sum1=0,sum2=0;
|
||||
spx_word16_t *deadx, *deady;
|
||||
int deadlen, dead1, dead2, dead3, dead4, dead5, dead6;
|
||||
__asm__ __volatile__ (
|
||||
"\tldrsh %5, [%0], #2 \n"
|
||||
"\tldrsh %6, [%1], #2 \n"
|
||||
".inner_prod_loop%=:\n"
|
||||
"\tsub %7, %7, %7\n"
|
||||
"\tsub %10, %10, %10\n"
|
||||
|
||||
"\tldrsh %8, [%0], #2 \n"
|
||||
"\tldrsh %9, [%1], #2 \n"
|
||||
"\tmla %7, %5, %6, %7\n"
|
||||
"\tldrsh %5, [%0], #2 \n"
|
||||
"\tldrsh %6, [%1], #2 \n"
|
||||
"\tmla %10, %8, %9, %10\n"
|
||||
"\tldrsh %8, [%0], #2 \n"
|
||||
"\tldrsh %9, [%1], #2 \n"
|
||||
"\tmla %7, %5, %6, %7\n"
|
||||
"\tldrsh %5, [%0], #2 \n"
|
||||
"\tldrsh %6, [%1], #2 \n"
|
||||
"\tmla %10, %8, %9, %10\n"
|
||||
|
||||
"\tldrsh %8, [%0], #2 \n"
|
||||
"\tldrsh %9, [%1], #2 \n"
|
||||
"\tmla %7, %5, %6, %7\n"
|
||||
"\tldrsh %5, [%0], #2 \n"
|
||||
"\tldrsh %6, [%1], #2 \n"
|
||||
"\tmla %10, %8, %9, %10\n"
|
||||
"\tldrsh %8, [%0], #2 \n"
|
||||
"\tldrsh %9, [%1], #2 \n"
|
||||
"\tmla %7, %5, %6, %7\n"
|
||||
"\tldrsh %5, [%0], #2 \n"
|
||||
"\tldrsh %6, [%1], #2 \n"
|
||||
"\tmla %10, %8, %9, %10\n"
|
||||
|
||||
"\tsubs %4, %4, #1\n"
|
||||
"\tadd %2, %2, %7, asr #5\n"
|
||||
"\tadd %3, %3, %10, asr #5\n"
|
||||
"\tbne .inner_prod_loop%=\n"
|
||||
: "=r" (deadx), "=r" (deady), "=r" (sum1), "=r" (sum2), "=r" (deadlen),
|
||||
"=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6)
|
||||
: "0" (x), "1" (y), "2" (sum1), "3" (sum2), "4" (len>>3)
|
||||
: "cc"
|
||||
);
|
||||
return (sum1+sum2)>>1;
|
||||
}
|
||||
|
||||
#define OVERRIDE_PITCH_XCORR
|
||||
void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
|
||||
{
|
||||
int i,j;
|
||||
for (i=0;i<nb_pitch;i+=4)
|
||||
{
|
||||
/* Compute correlation*/
|
||||
//corr[nb_pitch-1-i]=inner_prod(x, _y+i, len);
|
||||
spx_word32_t sum1=0;
|
||||
spx_word32_t sum2=0;
|
||||
spx_word32_t sum3=0;
|
||||
spx_word32_t sum4=0;
|
||||
const spx_word16_t *y = _y+i;
|
||||
const spx_word16_t *x = _x;
|
||||
spx_word32_t y0, y1, y2, y3;
|
||||
y0=*y++;
|
||||
y1=*y++;
|
||||
y2=*y++;
|
||||
y3=*y++;
|
||||
for (j=0;j<len;j+=4)
|
||||
{
|
||||
spx_word32_t part1, part2, part3, part4, x0;
|
||||
spx_word32_t dead1;
|
||||
__asm__ __volatile__ (
|
||||
#ifdef SHORTCUTS
|
||||
"\tldrsh %10, [%8], #4 \n"
|
||||
"\tmul %4, %10, %0 \n"
|
||||
"\tldrsh %15, [%8], #4 \n"
|
||||
"\tmul %5, %10, %1 \n"
|
||||
"\tldrsh %0, [%9], #2 \n"
|
||||
"\tmul %6, %10, %2 \n"
|
||||
"\tldrsh %1, [%9], #2 \n"
|
||||
"\tmul %7, %10, %3 \n"
|
||||
|
||||
|
||||
"\tmla %4, %15, %2, %4 \n"
|
||||
"\tldrsh %2, [%9], #2 \n"
|
||||
"\tmla %5, %15, %3, %5 \n"
|
||||
"\tldrsh %3, [%9], #2 \n"
|
||||
"\tmla %6, %15, %0, %6 \n"
|
||||
"\tmla %7, %15, %1, %7 \n"
|
||||
|
||||
#else
|
||||
"\tldrsh %10, [%8], #2 \n"
|
||||
"\tmul %4, %10, %0 \n"
|
||||
"\tmul %5, %10, %1 \n"
|
||||
"\tmul %6, %10, %2 \n"
|
||||
"\tmul %7, %10, %3 \n"
|
||||
|
||||
"\tldrsh %10, [%8], #2 \n"
|
||||
"\tldrsh %0, [%9], #2 \n"
|
||||
"\tmla %4, %10, %1, %4 \n"
|
||||
"\tmla %5, %10, %2, %5 \n"
|
||||
"\tmla %6, %10, %3, %6 \n"
|
||||
"\tmla %7, %10, %0, %7 \n"
|
||||
|
||||
"\tldrsh %10, [%8], #2 \n"
|
||||
"\tldrsh %1, [%9], #2 \n"
|
||||
"\tmla %4, %10, %2, %4 \n"
|
||||
"\tmla %5, %10, %3, %5 \n"
|
||||
"\tmla %6, %10, %0, %6 \n"
|
||||
"\tmla %7, %10, %1, %7 \n"
|
||||
|
||||
"\tldrsh %10, [%8], #2 \n"
|
||||
"\tldrsh %2, [%9], #2 \n"
|
||||
"\tmla %4, %10, %3, %4 \n"
|
||||
"\tmla %5, %10, %0, %5 \n"
|
||||
"\tmla %6, %10, %1, %6 \n"
|
||||
"\tmla %7, %10, %2, %7 \n"
|
||||
|
||||
"\tldrsh %3, [%9], #2 \n"
|
||||
#endif
|
||||
|
||||
"\tldr %10, %11 \n"
|
||||
"\tldr %15, %12 \n"
|
||||
"\tadd %4, %10, %4, asr #6 \n"
|
||||
"\tstr %4, %11 \n"
|
||||
"\tldr %10, %13 \n"
|
||||
"\tadd %5, %15, %5, asr #6 \n"
|
||||
"\tstr %5, %12 \n"
|
||||
"\tldr %15, %14 \n"
|
||||
"\tadd %6, %10, %6, asr #6 \n"
|
||||
"\tadd %7, %15, %7, asr #6 \n"
|
||||
"\tstr %6, %13 \n"
|
||||
"\tstr %7, %14 \n"
|
||||
|
||||
: "=r" (y0), "=r" (y1), "=r" (y2), "=r" (y3),
|
||||
"=r" (part1), "=r" (part2), "=r" (part3), "=r" (part4),
|
||||
"=r" (x), "=r" (y), "=r" (x0),
|
||||
"=m" (sum1), "=m" (sum2), "=m" (sum3), "=m" (sum4), "=r" (dead1)
|
||||
: "0" (y0), "1" (y1), "2" (y2), "3" (y3),
|
||||
"8" (x), "9" (y),
|
||||
"11" (sum1), "12" (sum2), "13" (sum3), "14" (sum4)
|
||||
: "cc", "memory"
|
||||
);
|
||||
}
|
||||
corr[nb_pitch-1-i]=sum1;
|
||||
corr[nb_pitch-2-i]=sum2;
|
||||
corr[nb_pitch-3-i]=sum3;
|
||||
corr[nb_pitch-4-i]=sum4;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,419 +0,0 @@
|
|||
/* Copyright (C) 2005 Analog Devices */
|
||||
/**
|
||||
@file ltp_bfin.h
|
||||
@author Jean-Marc Valin
|
||||
@brief Long-Term Prediction functions (Blackfin version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_INNER_PROD
|
||||
spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
|
||||
{
|
||||
spx_word32_t sum=0;
|
||||
__asm__ __volatile__ (
|
||||
"P0 = %3;\n\t"
|
||||
"P1 = %1;\n\t"
|
||||
"P2 = %2;\n\t"
|
||||
"I0 = P1;\n\t"
|
||||
"I1 = P2;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
"L1 = 0;\n\t"
|
||||
"A0 = 0;\n\t"
|
||||
"R0.L = W[I0++] || R1.L = W[I1++];\n\t"
|
||||
"LOOP inner%= LC0 = P0;\n\t"
|
||||
"LOOP_BEGIN inner%=;\n\t"
|
||||
"A0 += R0.L*R1.L (IS) || R0.L = W[I0++] || R1.L = W[I1++];\n\t"
|
||||
"LOOP_END inner%=;\n\t"
|
||||
"A0 += R0.L*R1.L (IS);\n\t"
|
||||
"A0 = A0 >>> 6;\n\t"
|
||||
"R0 = A0;\n\t"
|
||||
"%0 = R0;\n\t"
|
||||
: "=m" (sum)
|
||||
: "m" (x), "m" (y), "d" (len-1)
|
||||
: "P0", "P1", "P2", "R0", "R1", "A0", "I0", "I1", "L0", "L1", "R3"
|
||||
);
|
||||
return sum;
|
||||
}
|
||||
|
||||
#define OVERRIDE_PITCH_XCORR
|
||||
void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
|
||||
{
|
||||
corr += nb_pitch - 1;
|
||||
__asm__ __volatile__ (
|
||||
"P2 = %0;\n\t"
|
||||
"I0 = P2;\n\t" /* x in I0 */
|
||||
"B0 = P2;\n\t" /* x in B0 */
|
||||
"R0 = %3;\n\t" /* len in R0 */
|
||||
"P3 = %3;\n\t"
|
||||
"P3 += -2;\n\t" /* len in R0 */
|
||||
"P4 = %4;\n\t" /* nb_pitch in R0 */
|
||||
"R1 = R0 << 1;\n\t" /* number of bytes in x */
|
||||
"L0 = R1;\n\t"
|
||||
"P0 = %1;\n\t"
|
||||
|
||||
"P1 = %2;\n\t"
|
||||
"B1 = P1;\n\t"
|
||||
"L1 = 0;\n\t" /*Disable looping on I1*/
|
||||
|
||||
"r0 = [I0++];\n\t"
|
||||
"LOOP pitch%= LC0 = P4 >> 1;\n\t"
|
||||
"LOOP_BEGIN pitch%=;\n\t"
|
||||
"I1 = P0;\n\t"
|
||||
"A1 = A0 = 0;\n\t"
|
||||
"R1 = [I1++];\n\t"
|
||||
"LOOP inner_prod%= LC1 = P3 >> 1;\n\t"
|
||||
"LOOP_BEGIN inner_prod%=;\n\t"
|
||||
"A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t"
|
||||
"A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R1.H = W[I1++] || R0 = [I0++];\n\t"
|
||||
"LOOP_END inner_prod%=;\n\t"
|
||||
"A1 += R0.L*R1.H, A0 += R0.L*R1.L (IS) || R1.L = W[I1++];\n\t"
|
||||
"A1 += R0.H*R1.L, A0 += R0.H*R1.H (IS) || R0 = [I0++];\n\t"
|
||||
"A0 = A0 >>> 6;\n\t"
|
||||
"A1 = A1 >>> 6;\n\t"
|
||||
"R2 = A0, R3 = A1;\n\t"
|
||||
"[P1--] = r2;\n\t"
|
||||
"[P1--] = r3;\n\t"
|
||||
"P0 += 4;\n\t"
|
||||
"LOOP_END pitch%=;\n\t"
|
||||
"L0 = 0;\n\t"
|
||||
: : "m" (_x), "m" (_y), "m" (corr), "m" (len), "m" (nb_pitch)
|
||||
: "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "I0", "I1", "L0", "L1", "B0", "B1", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
#define OVERRIDE_COMPUTE_PITCH_ERROR
|
||||
static inline spx_word32_t compute_pitch_error(spx_word16_t *C, spx_word16_t *g, spx_word16_t pitch_control)
|
||||
{
|
||||
spx_word32_t sum;
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"A0 = 0;\n\t"
|
||||
|
||||
"R0 = W[%1++];\n\t"
|
||||
"R1.L = %2.L*%5.L (IS);\n\t"
|
||||
"A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %3.L*%5.L (IS);\n\t"
|
||||
"A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %4.L*%5.L (IS);\n\t"
|
||||
"A0 += R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %2.L*%3.L (IS);\n\t"
|
||||
"A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %4.L*%3.L (IS);\n\t"
|
||||
"A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %4.L*%2.L (IS);\n\t"
|
||||
"A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %2.L*%2.L (IS);\n\t"
|
||||
"A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %3.L*%3.L (IS);\n\t"
|
||||
"A0 -= R1.L*R0.L (IS) || R0 = W[%1++];\n\t"
|
||||
|
||||
"R1.L = %4.L*%4.L (IS);\n\t"
|
||||
"A0 -= R1.L*R0.L (IS);\n\t"
|
||||
|
||||
"%0 = A0;\n\t"
|
||||
: "=&D" (sum), "=a" (C)
|
||||
: "d" (g[0]), "d" (g[1]), "d" (g[2]), "d" (pitch_control), "1" (C)
|
||||
: "R0", "R1", "R2", "A0"
|
||||
);
|
||||
return sum;
|
||||
}
|
||||
|
||||
#define OVERRIDE_OPEN_LOOP_NBEST_PITCH
|
||||
#ifdef OVERRIDE_OPEN_LOOP_NBEST_PITCH
|
||||
void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack)
|
||||
{
|
||||
int i,j,k;
|
||||
VARDECL(spx_word32_t *best_score);
|
||||
VARDECL(spx_word32_t *best_ener);
|
||||
spx_word32_t e0;
|
||||
VARDECL(spx_word32_t *corr);
|
||||
VARDECL(spx_word32_t *energy);
|
||||
|
||||
ALLOC(best_score, N, spx_word32_t);
|
||||
ALLOC(best_ener, N, spx_word32_t);
|
||||
ALLOC(corr, end-start+1, spx_word32_t);
|
||||
ALLOC(energy, end-start+2, spx_word32_t);
|
||||
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
best_score[i]=-1;
|
||||
best_ener[i]=0;
|
||||
pitch[i]=start;
|
||||
}
|
||||
|
||||
energy[0]=inner_prod(sw-start, sw-start, len);
|
||||
e0=inner_prod(sw, sw, len);
|
||||
|
||||
/* energy update -------------------------------------*/
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
" P0 = %0;\n\t"
|
||||
" I1 = %1;\n\t"
|
||||
" L1 = 0;\n\t"
|
||||
" I2 = %2;\n\t"
|
||||
" L2 = 0;\n\t"
|
||||
" R2 = [P0++];\n\t"
|
||||
" R3 = 0;\n\t"
|
||||
" LSETUP (eu1, eu2) LC1 = %3;\n\t"
|
||||
"eu1: R1.L = W [I1--] || R0.L = W [I2--] ;\n\t"
|
||||
" R1 = R1.L * R1.L (IS);\n\t"
|
||||
" R0 = R0.L * R0.L (IS);\n\t"
|
||||
" R1 >>>= 6;\n\t"
|
||||
" R1 = R1 + R2;\n\t"
|
||||
" R0 >>>= 6;\n\t"
|
||||
" R1 = R1 - R0;\n\t"
|
||||
" R2 = MAX(R1,R3);\n\t"
|
||||
"eu2: [P0++] = R2;\n\t"
|
||||
: : "d" (energy), "d" (&sw[-start-1]), "d" (&sw[-start+len-1]),
|
||||
"a" (end-start)
|
||||
: "P0", "I1", "I2", "R0", "R1", "R2", "R3"
|
||||
#if (__GNUC__ == 4)
|
||||
, "LC1"
|
||||
#endif
|
||||
);
|
||||
|
||||
pitch_xcorr(sw, sw-end, corr, len, end-start+1, stack);
|
||||
|
||||
/* FIXME: Fixed-point and floating-point code should be merged */
|
||||
{
|
||||
VARDECL(spx_word16_t *corr16);
|
||||
VARDECL(spx_word16_t *ener16);
|
||||
ALLOC(corr16, end-start+1, spx_word16_t);
|
||||
ALLOC(ener16, end-start+1, spx_word16_t);
|
||||
/* Normalize to 180 so we can square it and it still fits in 16 bits */
|
||||
normalize16(corr, corr16, 180, end-start+1);
|
||||
normalize16(energy, ener16, 180, end-start+1);
|
||||
|
||||
if (N == 1) {
|
||||
/* optimised asm to handle N==1 case */
|
||||
__asm__ __volatile__
|
||||
(
|
||||
" I0 = %1;\n\t" /* I0: corr16[] */
|
||||
" L0 = 0;\n\t"
|
||||
" I1 = %2;\n\t" /* I1: energy */
|
||||
" L1 = 0;\n\t"
|
||||
" R2 = -1;\n\t" /* R2: best score */
|
||||
" R3 = 0;\n\t" /* R3: best energy */
|
||||
" P0 = %4;\n\t" /* P0: best pitch */
|
||||
" P1 = %4;\n\t" /* P1: counter */
|
||||
" LSETUP (sl1, sl2) LC1 = %3;\n\t"
|
||||
"sl1: R0.L = W [I0++] || R1.L = W [I1++];\n\t"
|
||||
" R0 = R0.L * R0.L (IS);\n\t"
|
||||
" R1 += 1;\n\t"
|
||||
" R4 = R0.L * R3.L;\n\t"
|
||||
" R5 = R2.L * R1.L;\n\t"
|
||||
" cc = R5 < R4;\n\t"
|
||||
" if cc R2 = R0;\n\t"
|
||||
" if cc R3 = R1;\n\t"
|
||||
" if cc P0 = P1;\n\t"
|
||||
"sl2: P1 += 1;\n\t"
|
||||
" %0 = P0;\n\t"
|
||||
: "=&d" (pitch[0])
|
||||
: "a" (corr16), "a" (ener16), "a" (end+1-start), "d" (start)
|
||||
: "P0", "P1", "I0", "I1", "R0", "R1", "R2", "R3", "R4", "R5"
|
||||
#if (__GNUC__ == 4)
|
||||
, "LC1"
|
||||
#endif
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
for (i=start;i<=end;i++)
|
||||
{
|
||||
spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]);
|
||||
/* Instead of dividing the tmp by the energy, we multiply on the other side */
|
||||
if (MULT16_16(tmp,best_ener[N-1])>MULT16_16(best_score[N-1],ADD16(1,ener16[i-start])))
|
||||
{
|
||||
/* We can safely put it last and then check */
|
||||
best_score[N-1]=tmp;
|
||||
best_ener[N-1]=ener16[i-start]+1;
|
||||
pitch[N-1]=i;
|
||||
/* Check if it comes in front of others */
|
||||
for (j=0;j<N-1;j++)
|
||||
{
|
||||
if (MULT16_16(tmp,best_ener[j])>MULT16_16(best_score[j],ADD16(1,ener16[i-start])))
|
||||
{
|
||||
for (k=N-1;k>j;k--)
|
||||
{
|
||||
best_score[k]=best_score[k-1];
|
||||
best_ener[k]=best_ener[k-1];
|
||||
pitch[k]=pitch[k-1];
|
||||
}
|
||||
best_score[j]=tmp;
|
||||
best_ener[j]=ener16[i-start]+1;
|
||||
pitch[j]=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute open-loop gain */
|
||||
if (gain)
|
||||
{
|
||||
for (j=0;j<N;j++)
|
||||
{
|
||||
spx_word16_t g;
|
||||
i=pitch[j];
|
||||
g = DIV32(corr[i-start], 10+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
|
||||
/* FIXME: g = max(g,corr/energy) */
|
||||
if (g<0)
|
||||
g = 0;
|
||||
gain[j]=g;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define OVERRIDE_PITCH_GAIN_SEARCH_3TAP_VQ
|
||||
#ifdef OVERRIDE_PITCH_GAIN_SEARCH_3TAP_VQ
|
||||
static int pitch_gain_search_3tap_vq(
|
||||
const signed char *gain_cdbk,
|
||||
int gain_cdbk_size,
|
||||
spx_word16_t *C16,
|
||||
spx_word16_t max_gain
|
||||
)
|
||||
{
|
||||
const signed char *ptr=gain_cdbk;
|
||||
int best_cdbk=0;
|
||||
spx_word32_t best_sum=-VERY_LARGE32;
|
||||
spx_word32_t sum=0;
|
||||
spx_word16_t g[3];
|
||||
spx_word16_t pitch_control=64;
|
||||
spx_word16_t gain_sum;
|
||||
int i;
|
||||
|
||||
/* fast asm version of VQ codebook search */
|
||||
|
||||
__asm__ __volatile__
|
||||
(
|
||||
|
||||
" P0 = %2;\n\t" /* P0: ptr to gain_cdbk */
|
||||
" L1 = 0;\n\t" /* no circ addr for L1 */
|
||||
" %0 = 0;\n\t" /* %0: best_sum */
|
||||
" %1 = 0;\n\t" /* %1: best_cbdk */
|
||||
" P1 = 0;\n\t" /* P1: loop counter */
|
||||
" R5 = 64;\n\t" /* R5: pitch_control */
|
||||
|
||||
" LSETUP (pgs1, pgs2) LC1 = %4;\n\t"
|
||||
"pgs1: R2 = B [P0++] (X);\n\t" /* R2: g[0] */
|
||||
" R3 = B [P0++] (X);\n\t" /* R3: g[1] */
|
||||
" R4 = B [P0++] (X);\n\t" /* R4: g[2] */
|
||||
" R2 += 32;\n\t"
|
||||
" R3 += 32;\n\t"
|
||||
" R4 += 32;\n\t"
|
||||
|
||||
" R0 = B [P0++] (X);\n\t"
|
||||
" B0 = R0;\n\t" /* BO: gain_sum */
|
||||
|
||||
/* compute_pitch_error() -------------------------------*/
|
||||
|
||||
" I1 = %3;\n\t" /* I1: ptr to C */
|
||||
" A0 = 0;\n\t"
|
||||
|
||||
" R0.L = W[I1++];\n\t"
|
||||
" R1.L = R2.L*R5.L (IS);\n\t"
|
||||
" A0 += R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R3.L*R5.L (IS);\n\t"
|
||||
" A0 += R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R4.L*R5.L (IS);\n\t"
|
||||
" A0 += R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R2.L*R3.L (IS);\n\t"
|
||||
" A0 -= R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R4.L*R3.L (IS);\n\t"
|
||||
" A0 -= R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R4.L*R2.L (IS);\n\t"
|
||||
" A0 -= R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R2.L*R2.L (IS);\n\t"
|
||||
" A0 -= R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R3.L*R3.L (IS);\n\t"
|
||||
" A0 -= R1.L*R0.L (IS) || R0.L = W[I1++];\n\t"
|
||||
|
||||
" R1.L = R4.L*R4.L (IS);\n\t"
|
||||
" R0 = (A0 -= R1.L*R0.L) (IS);\n\t"
|
||||
|
||||
/*
|
||||
Re-arrange the if-then to code efficiently on the Blackfin:
|
||||
|
||||
if (sum>best_sum && gain_sum<=max_gain) ------ (1)
|
||||
|
||||
if (sum>best_sum && !(gain_sum>max_gain)) ------ (2)
|
||||
|
||||
if (max_gain<=gain_sum) { ------ (3)
|
||||
sum = -VERY_LARGE32;
|
||||
}
|
||||
if (best_sum<=sum)
|
||||
|
||||
The blackin cc instructions are all of the form:
|
||||
|
||||
cc = x < y (or cc = x <= y)
|
||||
*/
|
||||
" R1 = B0\n\t"
|
||||
" R2 = %5\n\t"
|
||||
" R3 = %6\n\t"
|
||||
" cc = R2 <= R1;\n\t"
|
||||
" if cc R0 = R3;\n\t"
|
||||
" cc = %0 <= R0;\n\t"
|
||||
" if cc %0 = R0;\n\t"
|
||||
" if cc %1 = P1;\n\t"
|
||||
|
||||
"pgs2: P1 += 1;\n\t"
|
||||
|
||||
: "=&d" (best_sum), "=&d" (best_cdbk)
|
||||
: "a" (gain_cdbk), "a" (C16), "a" (gain_cdbk_size), "a" (max_gain),
|
||||
"b" (-VERY_LARGE32)
|
||||
: "R0", "R1", "R2", "R3", "R4", "R5", "P0",
|
||||
"P1", "I1", "L1", "A0", "B0"
|
||||
#if (__GNUC__ == 4)
|
||||
, "LC1"
|
||||
#endif
|
||||
);
|
||||
|
||||
return best_cdbk;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file ltp_sse.h
|
||||
@brief Long-Term Prediction functions (SSE version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#define OVERRIDE_INNER_PROD
|
||||
float inner_prod(const float *a, const float *b, int len)
|
||||
{
|
||||
int i;
|
||||
float ret;
|
||||
__m128 sum = _mm_setzero_ps();
|
||||
for (i=0;i<(len>>2);i+=2)
|
||||
{
|
||||
sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0)));
|
||||
sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4)));
|
||||
a += 8;
|
||||
b += 8;
|
||||
}
|
||||
sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
|
||||
sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
|
||||
_mm_store_ss(&ret, sum);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define OVERRIDE_PITCH_XCORR
|
||||
void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack)
|
||||
{
|
||||
int i, offset;
|
||||
VARDECL(__m128 *x);
|
||||
VARDECL(__m128 *y);
|
||||
int N, L;
|
||||
N = len>>2;
|
||||
L = nb_pitch>>2;
|
||||
ALLOC(x, N, __m128);
|
||||
ALLOC(y, N+L, __m128);
|
||||
for (i=0;i<N;i++)
|
||||
x[i] = _mm_loadu_ps(_x+(i<<2));
|
||||
for (offset=0;offset<4;offset++)
|
||||
{
|
||||
for (i=0;i<N+L;i++)
|
||||
y[i] = _mm_loadu_ps(_y+(i<<2)+offset);
|
||||
for (i=0;i<L;i++)
|
||||
{
|
||||
int j;
|
||||
__m128 sum, *xx, *yy;
|
||||
sum = _mm_setzero_ps();
|
||||
yy = y+i;
|
||||
xx = x;
|
||||
for (j=0;j<N;j+=2)
|
||||
{
|
||||
sum = _mm_add_ps(sum, _mm_mul_ps(xx[0], yy[0]));
|
||||
sum = _mm_add_ps(sum, _mm_mul_ps(xx[1], yy[1]));
|
||||
xx += 2;
|
||||
yy += 2;
|
||||
}
|
||||
sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
|
||||
sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
|
||||
_mm_store_ss(corr+nb_pitch-1-(i<<2)-offset, sum);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,291 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: math_approx.c
|
||||
Various math approximation functions for Speex
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "math_approx.h"
|
||||
#include "misc.h"
|
||||
|
||||
spx_int16_t spx_ilog2(spx_uint32_t x)
|
||||
{
|
||||
int r=0;
|
||||
if (x>=(spx_int32_t)65536)
|
||||
{
|
||||
x >>= 16;
|
||||
r += 16;
|
||||
}
|
||||
if (x>=256)
|
||||
{
|
||||
x >>= 8;
|
||||
r += 8;
|
||||
}
|
||||
if (x>=16)
|
||||
{
|
||||
x >>= 4;
|
||||
r += 4;
|
||||
}
|
||||
if (x>=4)
|
||||
{
|
||||
x >>= 2;
|
||||
r += 2;
|
||||
}
|
||||
if (x>=2)
|
||||
{
|
||||
r += 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
spx_int16_t spx_ilog4(spx_uint32_t x)
|
||||
{
|
||||
int r=0;
|
||||
if (x>=(spx_int32_t)65536)
|
||||
{
|
||||
x >>= 16;
|
||||
r += 8;
|
||||
}
|
||||
if (x>=256)
|
||||
{
|
||||
x >>= 8;
|
||||
r += 4;
|
||||
}
|
||||
if (x>=16)
|
||||
{
|
||||
x >>= 4;
|
||||
r += 2;
|
||||
}
|
||||
if (x>=4)
|
||||
{
|
||||
r += 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */
|
||||
/*#define C0 3634
|
||||
#define C1 21173
|
||||
#define C2 -12627
|
||||
#define C3 4215*/
|
||||
|
||||
/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25659*x^3 (for .25 < x < 1) */
|
||||
#define C0 3634
|
||||
#define C1 21173
|
||||
#define C2 -12627
|
||||
#define C3 4204
|
||||
|
||||
spx_word16_t spx_sqrt(spx_word32_t x)
|
||||
{
|
||||
int k;
|
||||
spx_word32_t rt;
|
||||
k = spx_ilog4(x)-6;
|
||||
x = VSHR32(x, (k<<1));
|
||||
rt = ADD16(C0, MULT16_16_Q14(x, ADD16(C1, MULT16_16_Q14(x, ADD16(C2, MULT16_16_Q14(x, (C3)))))));
|
||||
rt = VSHR32(rt,7-k);
|
||||
return rt;
|
||||
}
|
||||
|
||||
/* log(x) ~= -2.18151 + 4.20592*x - 2.88938*x^2 + 0.86535*x^3 (for .5 < x < 1) */
|
||||
|
||||
|
||||
#define A1 16469
|
||||
#define A2 2242
|
||||
#define A3 1486
|
||||
|
||||
spx_word16_t spx_acos(spx_word16_t x)
|
||||
{
|
||||
int s=0;
|
||||
spx_word16_t ret;
|
||||
spx_word16_t sq;
|
||||
if (x<0)
|
||||
{
|
||||
s=1;
|
||||
x = NEG16(x);
|
||||
}
|
||||
x = SUB16(16384,x);
|
||||
|
||||
x = x >> 1;
|
||||
sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3))))));
|
||||
ret = spx_sqrt(SHL32(EXTEND32(sq),13));
|
||||
|
||||
/*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/
|
||||
if (s)
|
||||
ret = SUB16(25736,ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#define K1 8192
|
||||
#define K2 -4096
|
||||
#define K3 340
|
||||
#define K4 -10
|
||||
|
||||
spx_word16_t spx_cos(spx_word16_t x)
|
||||
{
|
||||
spx_word16_t x2;
|
||||
|
||||
if (x<12868)
|
||||
{
|
||||
x2 = MULT16_16_P13(x,x);
|
||||
return ADD32(K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2))))));
|
||||
} else {
|
||||
x = SUB16(25736,x);
|
||||
x2 = MULT16_16_P13(x,x);
|
||||
return SUB32(-K1, MULT16_16_P13(x2, ADD32(K2, MULT16_16_P13(x2, ADD32(K3, MULT16_16_P13(K4, x2))))));
|
||||
}
|
||||
}
|
||||
|
||||
#define L1 32767
|
||||
#define L2 -7651
|
||||
#define L3 8277
|
||||
#define L4 -626
|
||||
|
||||
static inline spx_word16_t _spx_cos_pi_2(spx_word16_t x)
|
||||
{
|
||||
spx_word16_t x2;
|
||||
|
||||
x2 = MULT16_16_P15(x,x);
|
||||
return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2))))))));
|
||||
}
|
||||
|
||||
spx_word16_t spx_cos_norm(spx_word32_t x)
|
||||
{
|
||||
x = x&0x0001ffff;
|
||||
if (x>SHL32(EXTEND32(1), 16))
|
||||
x = SUB32(SHL32(EXTEND32(1), 17),x);
|
||||
if (x&0x00007fff)
|
||||
{
|
||||
if (x<SHL32(EXTEND32(1), 15))
|
||||
{
|
||||
return _spx_cos_pi_2(EXTRACT16(x));
|
||||
} else {
|
||||
return NEG32(_spx_cos_pi_2(EXTRACT16(65536-x)));
|
||||
}
|
||||
} else {
|
||||
if (x&0x0000ffff)
|
||||
return 0;
|
||||
else if (x&0x0001ffff)
|
||||
return -32767;
|
||||
else
|
||||
return 32767;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
K0 = 1
|
||||
K1 = log(2)
|
||||
K2 = 3-4*log(2)
|
||||
K3 = 3*log(2) - 2
|
||||
*/
|
||||
#define D0 16384
|
||||
#define D1 11356
|
||||
#define D2 3726
|
||||
#define D3 1301
|
||||
/* Input in Q11 format, output in Q16 */
|
||||
static spx_word32_t spx_exp2(spx_word16_t x)
|
||||
{
|
||||
int integer;
|
||||
spx_word16_t frac;
|
||||
integer = SHR16(x,11);
|
||||
if (integer>14)
|
||||
return 0x7fffffff;
|
||||
else if (integer < -15)
|
||||
return 0;
|
||||
frac = SHL16(x-SHL16(integer,11),3);
|
||||
frac = ADD16(D0, MULT16_16_Q14(frac, ADD16(D1, MULT16_16_Q14(frac, ADD16(D2 , MULT16_16_Q14(D3,frac))))));
|
||||
return VSHR32(EXTEND32(frac), -integer-2);
|
||||
}
|
||||
|
||||
/* Input in Q11 format, output in Q16 */
|
||||
spx_word32_t spx_exp(spx_word16_t x)
|
||||
{
|
||||
if (x>21290)
|
||||
return 0x7fffffff;
|
||||
else if (x<-21290)
|
||||
return 0;
|
||||
else
|
||||
return spx_exp2(MULT16_16_P14(23637,x));
|
||||
}
|
||||
#define M1 32767
|
||||
#define M2 -21
|
||||
#define M3 -11943
|
||||
#define M4 4936
|
||||
|
||||
static inline spx_word16_t spx_atan01(spx_word16_t x)
|
||||
{
|
||||
return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x)))))));
|
||||
}
|
||||
|
||||
/* Input in Q15, output in Q14 */
|
||||
spx_word16_t spx_atan(spx_word32_t x)
|
||||
{
|
||||
if (x <= 32767)
|
||||
{
|
||||
return SHR16(spx_atan01(x),1);
|
||||
} else {
|
||||
int e = spx_ilog2(x);
|
||||
if (e>=29)
|
||||
return 25736;
|
||||
x = DIV32_16(SHL32(EXTEND32(32767),29-e), EXTRACT16(SHR32(x, e-14)));
|
||||
return SUB16(25736, SHR16(spx_atan01(x),1));
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#define C1 0.9999932946f
|
||||
#define C2 -0.4999124376f
|
||||
#define C3 0.0414877472f
|
||||
#define C4 -0.0012712095f
|
||||
|
||||
|
||||
#define SPX_PI_2 1.5707963268
|
||||
spx_word16_t spx_cos(spx_word16_t x)
|
||||
{
|
||||
if (x<SPX_PI_2)
|
||||
{
|
||||
x *= x;
|
||||
return C1 + x*(C2+x*(C3+C4*x));
|
||||
} else {
|
||||
x = M_PI-x;
|
||||
x *= x;
|
||||
return NEG16(C1 + x*(C2+x*(C3+C4*x)));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file math_approx.h
|
||||
@brief Various math approximation functions for Speex
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MATH_APPROX_H
|
||||
#define MATH_APPROX_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
spx_word16_t spx_cos(spx_word16_t x);
|
||||
spx_int16_t spx_ilog2(spx_uint32_t x);
|
||||
spx_int16_t spx_ilog4(spx_uint32_t x);
|
||||
#ifdef FIXED_POINT
|
||||
spx_word16_t spx_sqrt(spx_word32_t x);
|
||||
spx_word16_t spx_acos(spx_word16_t x);
|
||||
spx_word32_t spx_exp(spx_word16_t x);
|
||||
spx_word16_t spx_cos_norm(spx_word32_t x);
|
||||
|
||||
/* Input in Q15, output in Q14 */
|
||||
spx_word16_t spx_atan(spx_word32_t x);
|
||||
|
||||
#else
|
||||
|
||||
#define spx_sqrt sqrt
|
||||
#define spx_acos acos
|
||||
#define spx_exp exp
|
||||
#define spx_cos_norm(x) (cos((.5f*M_PI)*(x)))
|
||||
#define spx_atan atan
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,948 +0,0 @@
|
|||
/* Copyright (C) 2003-2007 Jean-Marc Valin
|
||||
|
||||
File: mdf.c
|
||||
Echo canceller based on the MDF algorithm (see below)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
The echo canceller is based on the MDF algorithm described in:
|
||||
|
||||
J. S. Soo, K. K. Pang Multidelay block frequency adaptive filter,
|
||||
IEEE Trans. Acoust. Speech Signal Process., Vol. ASSP-38, No. 2,
|
||||
February 1990.
|
||||
|
||||
We use the Alternatively Updated MDF (AUMDF) variant. Robustness to
|
||||
double-talk is achieved using a variable learning rate as described in:
|
||||
|
||||
Valin, J.-M., On Adjusting the Learning Rate in Frequency Domain Echo
|
||||
Cancellation With Double-Talk. To appear in IEEE Transactions on Audio,
|
||||
Speech and Language Processing, 2006.
|
||||
http://people.xiph.org/~jm/papers/valin_taslp2006.pdf
|
||||
|
||||
There is no explicit double-talk detection, but a continuous variation
|
||||
in the learning rate based on residual echo, double-talk and background
|
||||
noise.
|
||||
|
||||
About the fixed-point version:
|
||||
All the signals are represented with 16-bit words. The filter weights
|
||||
are represented with 32-bit words, but only the top 16 bits are used
|
||||
in most cases. The lower 16 bits are completely unreliable (due to the
|
||||
fact that the update is done only on the top bits), but help in the
|
||||
adaptation -- probably by removing a "threshold effect" due to
|
||||
quantization (rounding going to zero) when the gradient is small.
|
||||
|
||||
Another kludge that seems to work good: when performing the weight
|
||||
update, we only move half the way toward the "goal" this seems to
|
||||
reduce the effect of quantization noise in the update phase. This
|
||||
can be seen as applying a gradient descent on a "soft constraint"
|
||||
instead of having a hard constraint.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
#include "speex/speex_echo.h"
|
||||
#include "fftwrap.h"
|
||||
#include "pseudofloat.h"
|
||||
#include "math_approx.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#define WEIGHT_SHIFT 11
|
||||
#define NORMALIZE_SCALEDOWN 5
|
||||
#define NORMALIZE_SCALEUP 3
|
||||
#else
|
||||
#define WEIGHT_SHIFT 0
|
||||
#endif
|
||||
|
||||
/* If enabled, the transition between blocks is smooth, so there isn't any blocking
|
||||
aftifact when adapting. The cost is an extra FFT and a matrix-vector multiply */
|
||||
#define SMOOTH_BLOCKS
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
static const spx_float_t MIN_LEAK = {16777, -19};
|
||||
#define TOP16(x) ((x)>>16)
|
||||
#else
|
||||
static const spx_float_t MIN_LEAK = .032f;
|
||||
#define TOP16(x) (x)
|
||||
#endif
|
||||
|
||||
|
||||
#define PLAYBACK_DELAY 2
|
||||
|
||||
void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *Yout, int len);
|
||||
|
||||
|
||||
/** Speex echo cancellation state. */
|
||||
struct SpeexEchoState_ {
|
||||
int frame_size; /**< Number of samples processed each time */
|
||||
int window_size;
|
||||
int M;
|
||||
int cancel_count;
|
||||
int adapted;
|
||||
int saturated;
|
||||
int screwed_up;
|
||||
spx_int32_t sampling_rate;
|
||||
spx_word16_t spec_average;
|
||||
spx_word16_t beta0;
|
||||
spx_word16_t beta_max;
|
||||
spx_word32_t sum_adapt;
|
||||
spx_word16_t leak_estimate;
|
||||
|
||||
spx_word16_t *e; /* scratch */
|
||||
spx_word16_t *x;
|
||||
spx_word16_t *X;
|
||||
spx_word16_t *input; /* scratch */
|
||||
spx_word16_t *y; /* scratch */
|
||||
spx_word16_t *last_y;
|
||||
spx_word16_t *Y; /* scratch */
|
||||
spx_word16_t *E;
|
||||
spx_word32_t *PHI; /* scratch */
|
||||
spx_word32_t *W;
|
||||
spx_word32_t *power;
|
||||
spx_float_t *power_1;
|
||||
spx_word16_t *wtmp; /* scratch */
|
||||
#ifdef FIXED_POINT
|
||||
spx_word16_t *wtmp2; /* scratch */
|
||||
#endif
|
||||
spx_word32_t *Rf; /* scratch */
|
||||
spx_word32_t *Yf; /* scratch */
|
||||
spx_word32_t *Xf; /* scratch */
|
||||
spx_word32_t *Eh;
|
||||
spx_word32_t *Yh;
|
||||
spx_float_t Pey;
|
||||
spx_float_t Pyy;
|
||||
spx_word16_t *window;
|
||||
spx_word16_t *prop;
|
||||
void *fft_table;
|
||||
spx_word16_t memX, memD, memE;
|
||||
spx_word16_t preemph;
|
||||
spx_word16_t notch_radius;
|
||||
spx_mem_t notch_mem[2];
|
||||
|
||||
/* NOTE: If you only use speex_echo_cancel() and want to save some memory, remove this */
|
||||
spx_int16_t *play_buf;
|
||||
int play_buf_pos;
|
||||
int play_buf_started;
|
||||
};
|
||||
|
||||
static inline void filter_dc_notch16(const spx_int16_t *in, spx_word16_t radius, spx_word16_t *out, int len, spx_mem_t *mem)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t den2;
|
||||
#ifdef FIXED_POINT
|
||||
den2 = MULT16_16_Q15(radius,radius) + MULT16_16_Q15(QCONST16(.7,15),MULT16_16_Q15(32767-radius,32767-radius));
|
||||
#else
|
||||
den2 = radius*radius + .7*(1-radius)*(1-radius);
|
||||
#endif
|
||||
/*printf ("%d %d %d %d %d %d\n", num[0], num[1], num[2], den[0], den[1], den[2]);*/
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
spx_word16_t vin = in[i];
|
||||
spx_word32_t vout = mem[0] + SHL32(EXTEND32(vin),15);
|
||||
#ifdef FIXED_POINT
|
||||
mem[0] = mem[1] + SHL32(SHL32(-EXTEND32(vin),15) + MULT16_32_Q15(radius,vout),1);
|
||||
#else
|
||||
mem[0] = mem[1] + 2*(-vin + radius*vout);
|
||||
#endif
|
||||
mem[1] = SHL32(EXTEND32(vin),15) - MULT16_32_Q15(den2,vout);
|
||||
out[i] = SATURATE32(PSHR32(MULT16_32_Q15(radius,vout),15),32767);
|
||||
}
|
||||
}
|
||||
|
||||
static inline spx_word32_t mdf_inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
|
||||
{
|
||||
spx_word32_t sum=0;
|
||||
len >>= 1;
|
||||
while(len--)
|
||||
{
|
||||
spx_word32_t part=0;
|
||||
part = MAC16_16(part,*x++,*y++);
|
||||
part = MAC16_16(part,*x++,*y++);
|
||||
/* HINT: If you had a 40-bit accumulator, you could shift only at the end */
|
||||
sum = ADD32(sum,SHR32(part,6));
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/** Compute power spectrum of a half-complex (packed) vector */
|
||||
static inline void power_spectrum(const spx_word16_t *X, spx_word32_t *ps, int N)
|
||||
{
|
||||
int i, j;
|
||||
ps[0]=MULT16_16(X[0],X[0]);
|
||||
for (i=1,j=1;i<N-1;i+=2,j++)
|
||||
{
|
||||
ps[j] = MULT16_16(X[i],X[i]) + MULT16_16(X[i+1],X[i+1]);
|
||||
}
|
||||
ps[j]=MULT16_16(X[i],X[i]);
|
||||
}
|
||||
|
||||
/** Compute cross-power spectrum of a half-complex (packed) vectors and add to acc */
|
||||
#ifdef FIXED_POINT
|
||||
static inline void spectral_mul_accum(const spx_word16_t *X, const spx_word32_t *Y, spx_word16_t *acc, int N, int M)
|
||||
{
|
||||
int i,j;
|
||||
spx_word32_t tmp1=0,tmp2=0;
|
||||
for (j=0;j<M;j++)
|
||||
{
|
||||
tmp1 = MAC16_16(tmp1, X[j*N],TOP16(Y[j*N]));
|
||||
}
|
||||
acc[0] = PSHR32(tmp1,WEIGHT_SHIFT);
|
||||
for (i=1;i<N-1;i+=2)
|
||||
{
|
||||
tmp1 = tmp2 = 0;
|
||||
for (j=0;j<M;j++)
|
||||
{
|
||||
tmp1 = SUB32(MAC16_16(tmp1, X[j*N+i],TOP16(Y[j*N+i])), MULT16_16(X[j*N+i+1],TOP16(Y[j*N+i+1])));
|
||||
tmp2 = MAC16_16(MAC16_16(tmp2, X[j*N+i+1],TOP16(Y[j*N+i])), X[j*N+i], TOP16(Y[j*N+i+1]));
|
||||
}
|
||||
acc[i] = PSHR32(tmp1,WEIGHT_SHIFT);
|
||||
acc[i+1] = PSHR32(tmp2,WEIGHT_SHIFT);
|
||||
}
|
||||
tmp1 = tmp2 = 0;
|
||||
for (j=0;j<M;j++)
|
||||
{
|
||||
tmp1 = MAC16_16(tmp1, X[(j+1)*N-1],TOP16(Y[(j+1)*N-1]));
|
||||
}
|
||||
acc[N-1] = PSHR32(tmp1,WEIGHT_SHIFT);
|
||||
}
|
||||
#else
|
||||
static inline void spectral_mul_accum(const spx_word16_t *X, const spx_word32_t *Y, spx_word16_t *acc, int N, int M)
|
||||
{
|
||||
int i,j;
|
||||
for (i=0;i<N;i++)
|
||||
acc[i] = 0;
|
||||
for (j=0;j<M;j++)
|
||||
{
|
||||
acc[0] += X[0]*Y[0];
|
||||
for (i=1;i<N-1;i+=2)
|
||||
{
|
||||
acc[i] += (X[i]*Y[i] - X[i+1]*Y[i+1]);
|
||||
acc[i+1] += (X[i+1]*Y[i] + X[i]*Y[i+1]);
|
||||
}
|
||||
acc[i] += X[i]*Y[i];
|
||||
X += N;
|
||||
Y += N;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Compute weighted cross-power spectrum of a half-complex (packed) vector with conjugate */
|
||||
static inline void weighted_spectral_mul_conj(const spx_float_t *w, const spx_float_t p, const spx_word16_t *X, const spx_word16_t *Y, spx_word32_t *prod, int N)
|
||||
{
|
||||
int i, j;
|
||||
spx_float_t W;
|
||||
W = FLOAT_AMULT(p, w[0]);
|
||||
prod[0] = FLOAT_MUL32(W,MULT16_16(X[0],Y[0]));
|
||||
for (i=1,j=1;i<N-1;i+=2,j++)
|
||||
{
|
||||
W = FLOAT_AMULT(p, w[j]);
|
||||
prod[i] = FLOAT_MUL32(W,MAC16_16(MULT16_16(X[i],Y[i]), X[i+1],Y[i+1]));
|
||||
prod[i+1] = FLOAT_MUL32(W,MAC16_16(MULT16_16(-X[i+1],Y[i]), X[i],Y[i+1]));
|
||||
}
|
||||
W = FLOAT_AMULT(p, w[j]);
|
||||
prod[i] = FLOAT_MUL32(W,MULT16_16(X[i],Y[i]));
|
||||
}
|
||||
|
||||
|
||||
/** Creates a new echo canceller state */
|
||||
SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length)
|
||||
{
|
||||
int i,N,M;
|
||||
SpeexEchoState *st = (SpeexEchoState *)speex_alloc(sizeof(SpeexEchoState));
|
||||
|
||||
st->frame_size = frame_size;
|
||||
st->window_size = 2*frame_size;
|
||||
N = st->window_size;
|
||||
M = st->M = (filter_length+st->frame_size-1)/frame_size;
|
||||
st->cancel_count=0;
|
||||
st->sum_adapt = 0;
|
||||
st->saturated = 0;
|
||||
st->screwed_up = 0;
|
||||
/* This is the default sampling rate */
|
||||
st->sampling_rate = 8000;
|
||||
st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);
|
||||
#ifdef FIXED_POINT
|
||||
st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);
|
||||
st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);
|
||||
#else
|
||||
st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
|
||||
st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
|
||||
#endif
|
||||
st->leak_estimate = 0;
|
||||
|
||||
st->fft_table = spx_fft_init(N);
|
||||
|
||||
st->e = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->x = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->input = (spx_word16_t*)speex_alloc(st->frame_size*sizeof(spx_word16_t));
|
||||
st->y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->last_y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->Yf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
|
||||
st->Rf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
|
||||
st->Xf = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
|
||||
st->Yh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
|
||||
st->Eh = (spx_word32_t*)speex_alloc((st->frame_size+1)*sizeof(spx_word32_t));
|
||||
|
||||
st->X = (spx_word16_t*)speex_alloc((M+1)*N*sizeof(spx_word16_t));
|
||||
st->Y = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->E = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->W = (spx_word32_t*)speex_alloc(M*N*sizeof(spx_word32_t));
|
||||
st->PHI = (spx_word32_t*)speex_alloc(N*sizeof(spx_word32_t));
|
||||
st->power = (spx_word32_t*)speex_alloc((frame_size+1)*sizeof(spx_word32_t));
|
||||
st->power_1 = (spx_float_t*)speex_alloc((frame_size+1)*sizeof(spx_float_t));
|
||||
st->window = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
st->prop = (spx_word16_t*)speex_alloc(M*sizeof(spx_word16_t));
|
||||
st->wtmp = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
#ifdef FIXED_POINT
|
||||
st->wtmp2 = (spx_word16_t*)speex_alloc(N*sizeof(spx_word16_t));
|
||||
for (i=0;i<N>>1;i++)
|
||||
{
|
||||
st->window[i] = (16383-SHL16(spx_cos(DIV32_16(MULT16_16(25736,i<<1),N)),1));
|
||||
st->window[N-i-1] = st->window[i];
|
||||
}
|
||||
#else
|
||||
for (i=0;i<N;i++)
|
||||
st->window[i] = .5-.5*cos(2*M_PI*i/N);
|
||||
#endif
|
||||
for (i=0;i<=st->frame_size;i++)
|
||||
st->power_1[i] = FLOAT_ONE;
|
||||
for (i=0;i<N*M;i++)
|
||||
st->W[i] = 0;
|
||||
{
|
||||
spx_word32_t sum = 0;
|
||||
/* Ratio of ~10 between adaptation rate of first and last block */
|
||||
spx_word16_t decay = SHR32(spx_exp(NEG16(DIV32_16(QCONST16(2.4,11),M))),1);
|
||||
st->prop[0] = QCONST16(.7, 15);
|
||||
sum = EXTEND32(st->prop[0]);
|
||||
for (i=1;i<M;i++)
|
||||
{
|
||||
st->prop[i] = MULT16_16_Q15(st->prop[i-1], decay);
|
||||
sum = ADD32(sum, EXTEND32(st->prop[i]));
|
||||
}
|
||||
for (i=M-1;i>=0;i--)
|
||||
{
|
||||
st->prop[i] = DIV32(MULT16_16(QCONST16(.8,15), st->prop[i]),sum);
|
||||
}
|
||||
}
|
||||
|
||||
st->memX=st->memD=st->memE=0;
|
||||
st->preemph = QCONST16(.9,15);
|
||||
if (st->sampling_rate<12000)
|
||||
st->notch_radius = QCONST16(.9, 15);
|
||||
else if (st->sampling_rate<24000)
|
||||
st->notch_radius = QCONST16(.982, 15);
|
||||
else
|
||||
st->notch_radius = QCONST16(.992, 15);
|
||||
|
||||
st->notch_mem[0] = st->notch_mem[1] = 0;
|
||||
st->adapted = 0;
|
||||
st->Pey = st->Pyy = FLOAT_ONE;
|
||||
|
||||
st->play_buf = (spx_int16_t*)speex_alloc((PLAYBACK_DELAY+1)*st->frame_size*sizeof(spx_int16_t));
|
||||
st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
|
||||
st->play_buf_started = 0;
|
||||
|
||||
return st;
|
||||
}
|
||||
|
||||
/** Resets echo canceller state */
|
||||
void speex_echo_state_reset(SpeexEchoState *st)
|
||||
{
|
||||
int i, M, N;
|
||||
st->cancel_count=0;
|
||||
st->screwed_up = 0;
|
||||
N = st->window_size;
|
||||
M = st->M;
|
||||
for (i=0;i<N*M;i++)
|
||||
st->W[i] = 0;
|
||||
for (i=0;i<N*(M+1);i++)
|
||||
st->X[i] = 0;
|
||||
for (i=0;i<=st->frame_size;i++)
|
||||
{
|
||||
st->power[i] = 0;
|
||||
st->power_1[i] = FLOAT_ONE;
|
||||
st->Eh[i] = 0;
|
||||
st->Yh[i] = 0;
|
||||
}
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
{
|
||||
st->last_y[i] = 0;
|
||||
}
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
st->E[i] = 0;
|
||||
st->x[i] = 0;
|
||||
}
|
||||
st->notch_mem[0] = st->notch_mem[1] = 0;
|
||||
st->memX=st->memD=st->memE=0;
|
||||
|
||||
st->saturated = 0;
|
||||
st->adapted = 0;
|
||||
st->sum_adapt = 0;
|
||||
st->Pey = st->Pyy = FLOAT_ONE;
|
||||
for (i=0;i<3*st->frame_size;i++)
|
||||
st->play_buf[i] = 0;
|
||||
st->play_buf_pos = PLAYBACK_DELAY*st->frame_size;
|
||||
st->play_buf_started = 0;
|
||||
|
||||
}
|
||||
|
||||
/** Destroys an echo canceller state */
|
||||
void speex_echo_state_destroy(SpeexEchoState *st)
|
||||
{
|
||||
spx_fft_destroy(st->fft_table);
|
||||
|
||||
speex_free(st->e);
|
||||
speex_free(st->x);
|
||||
speex_free(st->input);
|
||||
speex_free(st->y);
|
||||
speex_free(st->last_y);
|
||||
speex_free(st->Yf);
|
||||
speex_free(st->Rf);
|
||||
speex_free(st->Xf);
|
||||
speex_free(st->Yh);
|
||||
speex_free(st->Eh);
|
||||
|
||||
speex_free(st->X);
|
||||
speex_free(st->Y);
|
||||
speex_free(st->E);
|
||||
speex_free(st->W);
|
||||
speex_free(st->PHI);
|
||||
speex_free(st->power);
|
||||
speex_free(st->power_1);
|
||||
speex_free(st->window);
|
||||
speex_free(st->prop);
|
||||
speex_free(st->wtmp);
|
||||
#ifdef FIXED_POINT
|
||||
speex_free(st->wtmp2);
|
||||
#endif
|
||||
speex_free(st->play_buf);
|
||||
speex_free(st);
|
||||
}
|
||||
|
||||
void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out)
|
||||
{
|
||||
int i;
|
||||
/*speex_warning_int("capture with fill level ", st->play_buf_pos/st->frame_size);*/
|
||||
st->play_buf_started = 1;
|
||||
if (st->play_buf_pos>=st->frame_size)
|
||||
{
|
||||
speex_echo_cancellation(st, rec, st->play_buf, out);
|
||||
st->play_buf_pos -= st->frame_size;
|
||||
for (i=0;i<st->play_buf_pos;i++)
|
||||
st->play_buf[i] = st->play_buf[i+st->frame_size];
|
||||
} else {
|
||||
speex_warning("No playback frame available (your application is buggy and/or got xruns)");
|
||||
if (st->play_buf_pos!=0)
|
||||
{
|
||||
speex_warning("internal playback buffer corruption?");
|
||||
st->play_buf_pos = 0;
|
||||
}
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
out[i] = rec[i];
|
||||
}
|
||||
}
|
||||
|
||||
void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play)
|
||||
{
|
||||
/*speex_warning_int("playback with fill level ", st->play_buf_pos/st->frame_size);*/
|
||||
if (!st->play_buf_started)
|
||||
{
|
||||
speex_warning("discarded first playback frame");
|
||||
return;
|
||||
}
|
||||
if (st->play_buf_pos<=PLAYBACK_DELAY*st->frame_size)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
st->play_buf[st->play_buf_pos+i] = play[i];
|
||||
st->play_buf_pos += st->frame_size;
|
||||
if (st->play_buf_pos <= (PLAYBACK_DELAY-1)*st->frame_size)
|
||||
{
|
||||
speex_warning("Auto-filling the buffer (your application is buggy and/or got xruns)");
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
st->play_buf[st->play_buf_pos+i] = play[i];
|
||||
st->play_buf_pos += st->frame_size;
|
||||
}
|
||||
} else {
|
||||
speex_warning("Had to discard a playback frame (your application is buggy and/or got xruns)");
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs echo cancellation on a frame */
|
||||
void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out, spx_int32_t *Yout)
|
||||
{
|
||||
speex_echo_cancellation(st, in, far_end, out);
|
||||
}
|
||||
|
||||
/** Performs echo cancellation on a frame (deprecated, last arg now ignored) */
|
||||
void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *in, const spx_int16_t *far_end, spx_int16_t *out)
|
||||
{
|
||||
int i,j;
|
||||
int N,M;
|
||||
spx_word32_t Syy,See,Sxx,Sdd;
|
||||
spx_word32_t Sey;
|
||||
spx_word16_t ss, ss_1;
|
||||
spx_float_t Pey = FLOAT_ONE, Pyy=FLOAT_ONE;
|
||||
spx_float_t alpha, alpha_1;
|
||||
spx_word16_t RER;
|
||||
spx_word32_t tmp32;
|
||||
|
||||
N = st->window_size;
|
||||
M = st->M;
|
||||
st->cancel_count++;
|
||||
#ifdef FIXED_POINT
|
||||
ss=DIV32_16(11469,M);
|
||||
ss_1 = SUB16(32767,ss);
|
||||
#else
|
||||
ss=.35/M;
|
||||
ss_1 = 1-ss;
|
||||
#endif
|
||||
|
||||
filter_dc_notch16(in, st->notch_radius, st->input, st->frame_size, st->notch_mem);
|
||||
/* Copy input data to buffer and apply pre-emphasis */
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
{
|
||||
spx_word32_t tmp32;
|
||||
st->x[i] = st->x[i+st->frame_size];
|
||||
tmp32 = SUB32(EXTEND32(far_end[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memX)));
|
||||
#ifdef FIXED_POINT
|
||||
/* If saturation occurs here, we need to freeze adaptation for M+1 frames (not just one) */
|
||||
if (tmp32 > 32767)
|
||||
{
|
||||
tmp32 = 32767;
|
||||
st->saturated = M+1;
|
||||
}
|
||||
if (tmp32 < -32767)
|
||||
{
|
||||
tmp32 = -32767;
|
||||
st->saturated = M+1;
|
||||
}
|
||||
#endif
|
||||
st->x[i+st->frame_size] = EXTRACT16(tmp32);
|
||||
st->memX = far_end[i];
|
||||
|
||||
tmp32 = SUB32(EXTEND32(st->input[i]), EXTEND32(MULT16_16_P15(st->preemph, st->memD)));
|
||||
#ifdef FIXED_POINT
|
||||
if (tmp32 > 32767)
|
||||
{
|
||||
tmp32 = 32767;
|
||||
if (st->saturated == 0)
|
||||
st->saturated = 1;
|
||||
}
|
||||
if (tmp32 < -32767)
|
||||
{
|
||||
tmp32 = -32767;
|
||||
if (st->saturated == 0)
|
||||
st->saturated = 1;
|
||||
}
|
||||
#endif
|
||||
st->memD = st->input[i];
|
||||
st->input[i] = tmp32;
|
||||
}
|
||||
|
||||
/* Shift memory: this could be optimized eventually*/
|
||||
for (j=M-1;j>=0;j--)
|
||||
{
|
||||
for (i=0;i<N;i++)
|
||||
st->X[(j+1)*N+i] = st->X[j*N+i];
|
||||
}
|
||||
|
||||
/* Convert x (far end) to frequency domain */
|
||||
spx_fft(st->fft_table, st->x, &st->X[0]);
|
||||
|
||||
#ifdef SMOOTH_BLOCKS
|
||||
spectral_mul_accum(st->X, st->W, st->Y, N, M);
|
||||
spx_ifft(st->fft_table, st->Y, st->e);
|
||||
#endif
|
||||
|
||||
/* Compute weight gradient */
|
||||
if (st->saturated == 0)
|
||||
{
|
||||
for (j=M-1;j>=0;j--)
|
||||
{
|
||||
weighted_spectral_mul_conj(st->power_1, FLOAT_SHL(PSEUDOFLOAT(st->prop[j]),-15), &st->X[(j+1)*N], st->E, st->PHI, N);
|
||||
for (i=0;i<N;i++)
|
||||
st->W[j*N+i] = ADD32(st->W[j*N+i], st->PHI[i]);
|
||||
|
||||
}
|
||||
} else {
|
||||
st->saturated--;
|
||||
}
|
||||
|
||||
/* Update weight to prevent circular convolution (MDF / AUMDF) */
|
||||
for (j=0;j<M;j++)
|
||||
{
|
||||
/* This is a variant of the Alternatively Updated MDF (AUMDF) */
|
||||
/* Remove the "if" to make this an MDF filter */
|
||||
if (j==0 || st->cancel_count%(M-1) == j-1)
|
||||
{
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<N;i++)
|
||||
st->wtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],NORMALIZE_SCALEDOWN+16));
|
||||
spx_ifft(st->fft_table, st->wtmp2, st->wtmp);
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
{
|
||||
st->wtmp[i]=0;
|
||||
}
|
||||
for (i=st->frame_size;i<N;i++)
|
||||
{
|
||||
st->wtmp[i]=SHL16(st->wtmp[i],NORMALIZE_SCALEUP);
|
||||
}
|
||||
spx_fft(st->fft_table, st->wtmp, st->wtmp2);
|
||||
/* The "-1" in the shift is a sort of kludge that trades less efficient update speed for decrease noise */
|
||||
for (i=0;i<N;i++)
|
||||
st->W[j*N+i] -= SHL32(EXTEND32(st->wtmp2[i]),16+NORMALIZE_SCALEDOWN-NORMALIZE_SCALEUP-1);
|
||||
#else
|
||||
spx_ifft(st->fft_table, &st->W[j*N], st->wtmp);
|
||||
for (i=st->frame_size;i<N;i++)
|
||||
{
|
||||
st->wtmp[i]=0;
|
||||
}
|
||||
spx_fft(st->fft_table, st->wtmp, &st->W[j*N]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute filter response Y */
|
||||
spectral_mul_accum(st->X, st->W, st->Y, N, M);
|
||||
spx_ifft(st->fft_table, st->Y, st->y);
|
||||
|
||||
|
||||
/* Compute error signal (for the output with de-emphasis) */
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
{
|
||||
spx_word32_t tmp_out;
|
||||
#ifdef SMOOTH_BLOCKS
|
||||
spx_word16_t y = MULT16_16_Q15(st->window[i+st->frame_size],st->e[i+st->frame_size]) + MULT16_16_Q15(st->window[i],st->y[i+st->frame_size]);
|
||||
tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(y));
|
||||
#else
|
||||
tmp_out = SUB32(EXTEND32(st->input[i]), EXTEND32(st->y[i+st->frame_size]));
|
||||
#endif
|
||||
|
||||
/* Saturation */
|
||||
if (tmp_out>32767)
|
||||
tmp_out = 32767;
|
||||
else if (tmp_out<-32768)
|
||||
tmp_out = -32768;
|
||||
tmp_out = ADD32(tmp_out, EXTEND32(MULT16_16_P15(st->preemph, st->memE)));
|
||||
/* This is an arbitrary test for saturation in the microphone signal */
|
||||
if (in[i] <= -32000 || in[i] >= 32000)
|
||||
{
|
||||
tmp_out = 0;
|
||||
if (st->saturated == 0)
|
||||
st->saturated = 1;
|
||||
}
|
||||
out[i] = (spx_int16_t)tmp_out;
|
||||
st->memE = tmp_out;
|
||||
}
|
||||
|
||||
/* Compute error signal (filter update version) */
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
{
|
||||
st->e[i] = 0;
|
||||
st->e[i+st->frame_size] = st->input[i] - st->y[i+st->frame_size];
|
||||
}
|
||||
|
||||
/* Compute a bunch of correlations */
|
||||
Sey = mdf_inner_prod(st->e+st->frame_size, st->y+st->frame_size, st->frame_size);
|
||||
See = mdf_inner_prod(st->e+st->frame_size, st->e+st->frame_size, st->frame_size);
|
||||
Syy = mdf_inner_prod(st->y+st->frame_size, st->y+st->frame_size, st->frame_size);
|
||||
Sxx = mdf_inner_prod(st->x+st->frame_size, st->x+st->frame_size, st->frame_size);
|
||||
Sdd = mdf_inner_prod(st->input, st->input, st->frame_size);
|
||||
|
||||
/* Do some sanity check */
|
||||
if (!(Syy>=0 && Sxx>=0 && See >= 0)
|
||||
#ifndef FIXED_POINT
|
||||
|| !(See < N*1e9 && Syy < N*1e9 && Sxx < N*1e9)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* Things have gone really bad */
|
||||
st->screwed_up += 50;
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
out[i] = 0;
|
||||
} else if (SHR32(See, 2) > ADD32(Sdd, SHR32(MULT16_16(N, 100),6)))
|
||||
{
|
||||
/* AEC seems to add lots of echo instead of removing it, let's see if it will improve */
|
||||
st->screwed_up++;
|
||||
} else {
|
||||
/* Everything's fine */
|
||||
st->screwed_up=0;
|
||||
}
|
||||
if (st->screwed_up>=50)
|
||||
{
|
||||
speex_warning("The echo canceller started acting funny and got slapped (reset). It swears it will behave now.");
|
||||
speex_echo_state_reset(st);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add a small noise floor to make sure not to have problems when dividing */
|
||||
See = MAX32(See, SHR32(MULT16_16(N, 100),6));
|
||||
|
||||
/* Convert error to frequency domain */
|
||||
spx_fft(st->fft_table, st->e, st->E);
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
st->y[i] = 0;
|
||||
spx_fft(st->fft_table, st->y, st->Y);
|
||||
|
||||
/* Compute power spectrum of far end (X), error (E) and filter response (Y) */
|
||||
power_spectrum(st->E, st->Rf, N);
|
||||
power_spectrum(st->Y, st->Yf, N);
|
||||
power_spectrum(st->X, st->Xf, N);
|
||||
|
||||
/* Smooth far end energy estimate over time */
|
||||
for (j=0;j<=st->frame_size;j++)
|
||||
st->power[j] = MULT16_32_Q15(ss_1,st->power[j]) + 1 + MULT16_32_Q15(ss,st->Xf[j]);
|
||||
|
||||
/* Enable this to compute the power based only on the tail (would need to compute more
|
||||
efficiently to make this really useful */
|
||||
if (0)
|
||||
{
|
||||
float scale2 = .5f/M;
|
||||
for (j=0;j<=st->frame_size;j++)
|
||||
st->power[j] = 100;
|
||||
for (i=0;i<M;i++)
|
||||
{
|
||||
power_spectrum(&st->X[i*N], st->Xf, N);
|
||||
for (j=0;j<=st->frame_size;j++)
|
||||
st->power[j] += scale2*st->Xf[j];
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute filtered spectra and (cross-)correlations */
|
||||
for (j=st->frame_size;j>=0;j--)
|
||||
{
|
||||
spx_float_t Eh, Yh;
|
||||
Eh = PSEUDOFLOAT(st->Rf[j] - st->Eh[j]);
|
||||
Yh = PSEUDOFLOAT(st->Yf[j] - st->Yh[j]);
|
||||
Pey = FLOAT_ADD(Pey,FLOAT_MULT(Eh,Yh));
|
||||
Pyy = FLOAT_ADD(Pyy,FLOAT_MULT(Yh,Yh));
|
||||
#ifdef FIXED_POINT
|
||||
st->Eh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Eh[j]), st->spec_average, st->Rf[j]);
|
||||
st->Yh[j] = MAC16_32_Q15(MULT16_32_Q15(SUB16(32767,st->spec_average),st->Yh[j]), st->spec_average, st->Yf[j]);
|
||||
#else
|
||||
st->Eh[j] = (1-st->spec_average)*st->Eh[j] + st->spec_average*st->Rf[j];
|
||||
st->Yh[j] = (1-st->spec_average)*st->Yh[j] + st->spec_average*st->Yf[j];
|
||||
#endif
|
||||
}
|
||||
|
||||
Pyy = FLOAT_SQRT(Pyy);
|
||||
Pey = FLOAT_DIVU(Pey,Pyy);
|
||||
|
||||
/* Compute correlation updatete rate */
|
||||
tmp32 = MULT16_32_Q15(st->beta0,Syy);
|
||||
if (tmp32 > MULT16_32_Q15(st->beta_max,See))
|
||||
tmp32 = MULT16_32_Q15(st->beta_max,See);
|
||||
alpha = FLOAT_DIV32(tmp32, See);
|
||||
alpha_1 = FLOAT_SUB(FLOAT_ONE, alpha);
|
||||
/* Update correlations (recursive average) */
|
||||
st->Pey = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pey) , FLOAT_MULT(alpha,Pey));
|
||||
st->Pyy = FLOAT_ADD(FLOAT_MULT(alpha_1,st->Pyy) , FLOAT_MULT(alpha,Pyy));
|
||||
if (FLOAT_LT(st->Pyy, FLOAT_ONE))
|
||||
st->Pyy = FLOAT_ONE;
|
||||
/* We don't really hope to get better than 33 dB (MIN_LEAK-3dB) attenuation anyway */
|
||||
if (FLOAT_LT(st->Pey, FLOAT_MULT(MIN_LEAK,st->Pyy)))
|
||||
st->Pey = FLOAT_MULT(MIN_LEAK,st->Pyy);
|
||||
if (FLOAT_GT(st->Pey, st->Pyy))
|
||||
st->Pey = st->Pyy;
|
||||
/* leak_estimate is the linear regression result */
|
||||
st->leak_estimate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIVU(st->Pey, st->Pyy),14));
|
||||
/* This looks like a stupid bug, but it's right (because we convert from Q14 to Q15) */
|
||||
if (st->leak_estimate > 16383)
|
||||
st->leak_estimate = 32767;
|
||||
else
|
||||
st->leak_estimate = SHL16(st->leak_estimate,1);
|
||||
/*printf ("%f\n", st->leak_estimate);*/
|
||||
|
||||
/* Compute Residual to Error Ratio */
|
||||
#ifdef FIXED_POINT
|
||||
tmp32 = MULT16_32_Q15(st->leak_estimate,Syy);
|
||||
tmp32 = ADD32(SHR32(Sxx,13), ADD32(tmp32, SHL32(tmp32,1)));
|
||||
/* Check for y in e (lower bound on RER) */
|
||||
{
|
||||
spx_float_t bound = PSEUDOFLOAT(Sey);
|
||||
bound = FLOAT_DIVU(FLOAT_MULT(bound, bound), PSEUDOFLOAT(ADD32(1,Syy)));
|
||||
if (FLOAT_GT(bound, PSEUDOFLOAT(See)))
|
||||
tmp32 = See;
|
||||
else if (tmp32 < FLOAT_EXTRACT32(bound))
|
||||
tmp32 = FLOAT_EXTRACT32(bound);
|
||||
}
|
||||
if (tmp32 > SHR32(See,1))
|
||||
tmp32 = SHR32(See,1);
|
||||
RER = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32,See),15));
|
||||
#else
|
||||
RER = (.0001*Sxx + 3.*MULT16_32_Q15(st->leak_estimate,Syy)) / See;
|
||||
/* Check for y in e (lower bound on RER) */
|
||||
if (RER < Sey*Sey/(1+See*Syy))
|
||||
RER = Sey*Sey/(1+See*Syy);
|
||||
if (RER > .5)
|
||||
RER = .5;
|
||||
#endif
|
||||
|
||||
/* We consider that the filter has had minimal adaptation if the following is true*/
|
||||
if (!st->adapted && st->sum_adapt > QCONST32(M,15))
|
||||
{
|
||||
st->adapted = 1;
|
||||
}
|
||||
|
||||
if (st->adapted)
|
||||
{
|
||||
for (i=0;i<=st->frame_size;i++)
|
||||
{
|
||||
spx_word32_t r, e;
|
||||
/* Compute frequency-domain adaptation mask */
|
||||
r = MULT16_32_Q15(st->leak_estimate,SHL32(st->Yf[i],3));
|
||||
e = SHL32(st->Rf[i],3)+1;
|
||||
#ifdef FIXED_POINT
|
||||
if (r>SHR32(e,1))
|
||||
r = SHR32(e,1);
|
||||
#else
|
||||
if (r>.5*e)
|
||||
r = .5*e;
|
||||
#endif
|
||||
r = MULT16_32_Q15(QCONST16(.7,15),r) + MULT16_32_Q15(QCONST16(.3,15),(spx_word32_t)(MULT16_32_Q15(RER,e)));
|
||||
/*st->power_1[i] = adapt_rate*r/(e*(1+st->power[i]));*/
|
||||
st->power_1[i] = FLOAT_SHL(FLOAT_DIV32_FLOAT(r,FLOAT_MUL32U(e,st->power[i]+10)),WEIGHT_SHIFT+16);
|
||||
}
|
||||
} else {
|
||||
/* Temporary adaption rate if filter is not yet adapted enough */
|
||||
spx_word16_t adapt_rate=0;
|
||||
|
||||
if (Sxx > SHR32(MULT16_16(N, 1000),6))
|
||||
{
|
||||
tmp32 = MULT16_32_Q15(QCONST16(.25f, 15), Sxx);
|
||||
#ifdef FIXED_POINT
|
||||
if (tmp32 > SHR32(See,2))
|
||||
tmp32 = SHR32(See,2);
|
||||
#else
|
||||
if (tmp32 > .25*See)
|
||||
tmp32 = .25*See;
|
||||
#endif
|
||||
adapt_rate = FLOAT_EXTRACT16(FLOAT_SHL(FLOAT_DIV32(tmp32, See),15));
|
||||
}
|
||||
for (i=0;i<=st->frame_size;i++)
|
||||
st->power_1[i] = FLOAT_SHL(FLOAT_DIV32(EXTEND32(adapt_rate),ADD32(st->power[i],10)),WEIGHT_SHIFT+1);
|
||||
|
||||
|
||||
/* How much have we adapted so far? */
|
||||
st->sum_adapt = ADD32(st->sum_adapt,adapt_rate);
|
||||
}
|
||||
|
||||
/* Save residual echo so it can be used by the nonlinear processor */
|
||||
if (st->adapted)
|
||||
{
|
||||
/* If the filter is adapted, take the filtered echo */
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
st->last_y[i] = st->last_y[st->frame_size+i];
|
||||
for (i=0;i<st->frame_size;i++)
|
||||
st->last_y[st->frame_size+i] = in[i]-out[i];
|
||||
} else {
|
||||
/* If filter isn't adapted yet, all we can do is take the far end signal directly */
|
||||
for (i=0;i<N;i++)
|
||||
st->last_y[i] = st->x[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Compute spectrum of estimated echo for use in an echo post-filter */
|
||||
void speex_echo_get_residual(SpeexEchoState *st, spx_word32_t *residual_echo, int len)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t leak2;
|
||||
int N;
|
||||
|
||||
N = st->window_size;
|
||||
|
||||
/* Apply hanning window (should pre-compute it)*/
|
||||
for (i=0;i<N;i++)
|
||||
st->y[i] = MULT16_16_Q15(st->window[i],st->last_y[i]);
|
||||
|
||||
/* Compute power spectrum of the echo */
|
||||
spx_fft(st->fft_table, st->y, st->Y);
|
||||
power_spectrum(st->Y, residual_echo, N);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
if (st->leak_estimate > 16383)
|
||||
leak2 = 32767;
|
||||
else
|
||||
leak2 = SHL16(st->leak_estimate, 1);
|
||||
#else
|
||||
if (st->leak_estimate>.5)
|
||||
leak2 = 1;
|
||||
else
|
||||
leak2 = 2*st->leak_estimate;
|
||||
#endif
|
||||
/* Estimate residual echo */
|
||||
for (i=0;i<=st->frame_size;i++)
|
||||
residual_echo[i] = (spx_int32_t)MULT16_32_Q15(leak2,residual_echo[i]);
|
||||
|
||||
}
|
||||
|
||||
int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr)
|
||||
{
|
||||
switch(request)
|
||||
{
|
||||
|
||||
case SPEEX_ECHO_GET_FRAME_SIZE:
|
||||
(*(int*)ptr) = st->frame_size;
|
||||
break;
|
||||
case SPEEX_ECHO_SET_SAMPLING_RATE:
|
||||
st->sampling_rate = (*(int*)ptr);
|
||||
st->spec_average = DIV32_16(SHL32(EXTEND32(st->frame_size), 15), st->sampling_rate);
|
||||
#ifdef FIXED_POINT
|
||||
st->beta0 = DIV32_16(SHL32(EXTEND32(st->frame_size), 16), st->sampling_rate);
|
||||
st->beta_max = DIV32_16(SHL32(EXTEND32(st->frame_size), 14), st->sampling_rate);
|
||||
#else
|
||||
st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
|
||||
st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
|
||||
#endif
|
||||
if (st->sampling_rate<12000)
|
||||
st->notch_radius = QCONST16(.9, 15);
|
||||
else if (st->sampling_rate<24000)
|
||||
st->notch_radius = QCONST16(.982, 15);
|
||||
else
|
||||
st->notch_radius = QCONST16(.992, 15);
|
||||
break;
|
||||
case SPEEX_ECHO_GET_SAMPLING_RATE:
|
||||
(*(int*)ptr) = st->sampling_rate;
|
||||
break;
|
||||
default:
|
||||
speex_warning_int("Unknown speex_echo_ctl request: ", request);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin
|
||||
File medfilter.c
|
||||
Median filter
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#include "medfilter.h"
|
||||
#include "misc.h"
|
||||
|
||||
MedianFilter *median_filter_new(int N)
|
||||
{
|
||||
MedianFilter *f = (MedianFilter*)speex_alloc(sizeof(MedianFilter));
|
||||
f->N = N;
|
||||
f->ids = (int*)speex_alloc(sizeof(int)*N);
|
||||
f->val = (float*)speex_alloc(sizeof(float)*N);
|
||||
f->filled = 0;
|
||||
return f;
|
||||
}
|
||||
|
||||
void median_filter_update(MedianFilter *f, float val)
|
||||
{
|
||||
int i=0;
|
||||
int insert = 0;
|
||||
while (insert<f->filled && f->val[insert] < val)
|
||||
{
|
||||
insert++;
|
||||
}
|
||||
if (f->filled == f->N)
|
||||
{
|
||||
int remove;
|
||||
for (remove=0;remove<f->N;remove++)
|
||||
if (f->ids[remove] == 0)
|
||||
break;
|
||||
if (insert>remove)
|
||||
insert--;
|
||||
if (insert > remove)
|
||||
{
|
||||
for (i=remove;i<insert;i++)
|
||||
{
|
||||
f->val[i] = f->val[i+1];
|
||||
f->ids[i] = f->ids[i+1];
|
||||
}
|
||||
} else if (insert < remove)
|
||||
{
|
||||
for (i=remove;i>insert;i--)
|
||||
{
|
||||
f->val[i] = f->val[i-1];
|
||||
f->ids[i] = f->ids[i-1];
|
||||
}
|
||||
}
|
||||
for (i=0;i<f->filled;i++)
|
||||
f->ids[i]--;
|
||||
} else {
|
||||
for (i=f->filled;i>insert;i--)
|
||||
{
|
||||
f->val[i] = f->val[i-1];
|
||||
f->ids[i] = f->ids[i-1];
|
||||
}
|
||||
f->filled++;
|
||||
}
|
||||
f->val[insert]=val;
|
||||
f->ids[insert]=f->filled-1;
|
||||
}
|
||||
|
||||
float median_filter_get(MedianFilter *f)
|
||||
{
|
||||
return f->val[f->filled>>1];
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/* Copyright (C) 2004 Jean-Marc Valin */
|
||||
/**
|
||||
@file medfilter.h
|
||||
@brief Median filter
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MEDFILTER_H
|
||||
#define MEDFILTER_H
|
||||
|
||||
/** Median filter. */
|
||||
typedef struct {
|
||||
int N;
|
||||
int filled;
|
||||
int *ids;
|
||||
float *val;
|
||||
} MedianFilter;
|
||||
|
||||
MedianFilter *median_filter_new(int N);
|
||||
void median_filter_update(MedianFilter *f, float val);
|
||||
float median_filter_get(MedianFilter *f);
|
||||
|
||||
#endif
|
|
@ -1,225 +0,0 @@
|
|||
/* Copyright (C) 2002-2005 Jean-Marc Valin
|
||||
File: misc.c
|
||||
Various utility routines for Speex
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef USER_MISC
|
||||
#include "user_misc.h"
|
||||
#endif
|
||||
|
||||
#ifdef BFIN_ASM
|
||||
#include "misc_bfin.h"
|
||||
#endif
|
||||
|
||||
#ifndef RELEASE
|
||||
void print_vec(float *vec, int len, char *name)
|
||||
{
|
||||
int i;
|
||||
printf ("%s ", name);
|
||||
for (i=0;i<len;i++)
|
||||
printf (" %f", vec[i]);
|
||||
printf ("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_DEBUG
|
||||
long long spx_mips=0;
|
||||
#endif
|
||||
|
||||
|
||||
spx_uint32_t be_int(spx_uint32_t i)
|
||||
{
|
||||
spx_uint32_t ret=i;
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
ret = i>>24;
|
||||
ret += (i>>8)&0x0000ff00;
|
||||
ret += (i<<8)&0x00ff0000;
|
||||
ret += (i<<24);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
spx_uint32_t le_int(spx_uint32_t i)
|
||||
{
|
||||
spx_uint32_t ret=i;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
ret = i>>24;
|
||||
ret += (i>>8)&0x0000ff00;
|
||||
ret += (i<<8)&0x00ff0000;
|
||||
ret += (i<<24);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if BYTES_PER_CHAR == 2
|
||||
void speex_memcpy_bytes(char *dst, char *src, int nbytes)
|
||||
{
|
||||
int i;
|
||||
int nchars = nbytes/BYTES_PER_CHAR;
|
||||
for (i=0;i<nchars;i++)
|
||||
dst[i]=src[i];
|
||||
if (nbytes & 1) {
|
||||
/* copy in the last byte */
|
||||
int last_i = nchars;
|
||||
char last_dst_char = dst[last_i];
|
||||
char last_src_char = src[last_i];
|
||||
last_dst_char &= 0xff00;
|
||||
last_dst_char |= (last_src_char & 0x00ff);
|
||||
dst[last_i] = last_dst_char;
|
||||
}
|
||||
}
|
||||
void speex_memset_bytes(char *dst, char c, int nbytes)
|
||||
{
|
||||
int i;
|
||||
spx_int16_t cc = ((c << 8) | c);
|
||||
int nchars = nbytes/BYTES_PER_CHAR;
|
||||
for (i=0;i<nchars;i++)
|
||||
dst[i]=cc;
|
||||
if (nbytes & 1) {
|
||||
/* copy in the last byte */
|
||||
int last_i = nchars;
|
||||
char last_dst_char = dst[last_i];
|
||||
last_dst_char &= 0xff00;
|
||||
last_dst_char |= (c & 0x00ff);
|
||||
dst[last_i] = last_dst_char;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void speex_memcpy_bytes(char *dst, char *src, int nbytes)
|
||||
{
|
||||
memcpy(dst, src, nbytes);
|
||||
}
|
||||
void speex_memset_bytes(char *dst, char src, int nbytes)
|
||||
{
|
||||
memset(dst, src, nbytes);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_ALLOC
|
||||
void *speex_alloc (int size)
|
||||
{
|
||||
return calloc(size,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH
|
||||
void *speex_alloc_scratch (int size)
|
||||
{
|
||||
return calloc(size,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_REALLOC
|
||||
void *speex_realloc (void *ptr, int size)
|
||||
{
|
||||
return realloc(ptr, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_FREE
|
||||
void speex_free (void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_FREE_SCRATCH
|
||||
void speex_free_scratch (void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_MOVE
|
||||
void *speex_move (void *dest, void *src, int n)
|
||||
{
|
||||
return memmove(dest,src,n);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_ERROR
|
||||
void speex_error(const char *str)
|
||||
{
|
||||
fprintf (stderr, "Fatal error: %s\n", str);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_WARNING
|
||||
void speex_warning(const char *str)
|
||||
{
|
||||
fprintf (stderr, "warning: %s\n", str);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_WARNING_INT
|
||||
void speex_warning_int(const char *str, int val)
|
||||
{
|
||||
fprintf (stderr, "warning: %s %d\n", str, val);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
|
||||
{
|
||||
spx_word32_t res;
|
||||
*seed = 1664525 * *seed + 1013904223;
|
||||
res = MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
|
||||
return PSHR32(SUB32(res, SHR(res, 3)),14);
|
||||
}
|
||||
#else
|
||||
spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
|
||||
{
|
||||
const unsigned int jflone = 0x3f800000;
|
||||
const unsigned int jflmsk = 0x007fffff;
|
||||
union {int i; float f;} ran;
|
||||
*seed = 1664525 * *seed + 1013904223;
|
||||
ran.i = jflone | (jflmsk & *seed);
|
||||
ran.f -= 1.5;
|
||||
return 3.4642*std*ran.f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OVERRIDE_SPEEX_PUTC
|
||||
void _speex_putc(int ch, void *file)
|
||||
{
|
||||
FILE *f = (FILE *)file;
|
||||
fprintf(f, "%c", ch);
|
||||
}
|
||||
#endif
|
|
@ -1,122 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file misc.h
|
||||
@brief Various compatibility routines for Speex
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#ifndef SPEEX_VERSION
|
||||
#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */
|
||||
#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */
|
||||
#define SPEEX_MICRO_VERSION 13 /**< Micro Speex version. */
|
||||
#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */
|
||||
#define SPEEX_VERSION "speex-1.2beta1" /**< Speex version string. */
|
||||
#endif
|
||||
|
||||
/* A couple test to catch stupid option combinations */
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
#ifdef _USE_SSE
|
||||
#error SSE is only for floating-point
|
||||
#endif
|
||||
#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM))
|
||||
#error Make up your mind. What CPU do you have?
|
||||
#endif
|
||||
#ifdef VORBIS_PSYCHO
|
||||
#error Vorbis-psy model currently not implemented in fixed-point
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)
|
||||
#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?
|
||||
#endif
|
||||
#ifdef FIXED_POINT_DEBUG
|
||||
#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#include "arch.h"
|
||||
|
||||
#ifndef RELEASE
|
||||
/** Print a named vector to stdout */
|
||||
void print_vec(float *vec, int len, char *name);
|
||||
#endif
|
||||
|
||||
/** Convert big endian */
|
||||
spx_uint32_t be_int(spx_uint32_t i);
|
||||
/** Convert little endian */
|
||||
spx_uint32_t le_int(spx_uint32_t i);
|
||||
|
||||
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
|
||||
void *speex_alloc (int size);
|
||||
|
||||
/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
|
||||
void *speex_alloc_scratch (int size);
|
||||
|
||||
/** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
|
||||
void *speex_realloc (void *ptr, int size);
|
||||
|
||||
/** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
|
||||
void speex_free (void *ptr);
|
||||
|
||||
/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
|
||||
void speex_free_scratch (void *ptr);
|
||||
|
||||
/** Speex wrapper for mem_move */
|
||||
void *speex_move (void *dest, void *src, int n);
|
||||
|
||||
/** Speex wrapper for memcpy */
|
||||
void speex_memcpy_bytes(char *dst, char *src, int nbytes);
|
||||
|
||||
/** Speex wrapper for memset */
|
||||
void speex_memset_bytes(char *dst, char src, int nbytes);
|
||||
|
||||
/** Print error message to stderr */
|
||||
void speex_error(const char *str);
|
||||
|
||||
/** Print warning message to stderr */
|
||||
void speex_warning(const char *str);
|
||||
|
||||
/** Print warning message with integer argument to stderr */
|
||||
void speex_warning_int(const char *str, int val);
|
||||
|
||||
/** Generate a random number */
|
||||
spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed);
|
||||
|
||||
/** Speex wrapper for putc */
|
||||
void _speex_putc(int ch, void *file);
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
/* Copyright (C) 2005 Analog Devices */
|
||||
/**
|
||||
@file misc_bfin.h
|
||||
@author Jean-Marc Valin
|
||||
@brief Various compatibility routines for Speex (Blackfin version)
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OVERRIDE_SPEEX_MOVE
|
||||
void *speex_move (void *dest, void *src, int n)
|
||||
{
|
||||
__asm__ __volatile__
|
||||
(
|
||||
"L0 = 0;\n\t"
|
||||
"I0 = %0;\n\t"
|
||||
"R0 = [I0++];\n\t"
|
||||
"LOOP move%= LC0 = %2;\n\t"
|
||||
"LOOP_BEGIN move%=;\n\t"
|
||||
"[%1++] = R0 || R0 = [I0++];\n\t"
|
||||
"LOOP_END move%=;\n\t"
|
||||
"[%1++] = R0;\n\t"
|
||||
: "=a" (src), "=a" (dest)
|
||||
: "a" ((n>>2)-1), "0" (src), "1" (dest)
|
||||
: "R0", "I0", "L0", "memory"
|
||||
);
|
||||
return dest;
|
||||
}
|
|
@ -1,673 +0,0 @@
|
|||
/* Copyright (C) 2002-2006 Jean-Marc Valin
|
||||
File: modes.c
|
||||
|
||||
Describes the different modes of the codec
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "modes.h"
|
||||
#include "ltp.h"
|
||||
#include "quant_lsp.h"
|
||||
#include "cb_search.h"
|
||||
#include "sb_celp.h"
|
||||
#include "nb_celp.h"
|
||||
#include "vbr.h"
|
||||
#include "misc.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define MAX_IN_SAMPLES 640
|
||||
|
||||
const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
|
||||
|
||||
/* Extern declarations for all codebooks we use here */
|
||||
extern const signed char gain_cdbk_nb[];
|
||||
extern const signed char gain_cdbk_lbr[];
|
||||
extern const signed char hexc_table[];
|
||||
extern const signed char exc_5_256_table[];
|
||||
extern const signed char exc_5_64_table[];
|
||||
extern const signed char exc_8_128_table[];
|
||||
extern const signed char exc_10_32_table[];
|
||||
extern const signed char exc_10_16_table[];
|
||||
extern const signed char exc_20_32_table[];
|
||||
extern const signed char hexc_10_32_table[];
|
||||
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
static const ltp_params ltp_params_nb = {
|
||||
gain_cdbk_nb,
|
||||
7,
|
||||
7
|
||||
};
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
static const ltp_params ltp_params_vlbr = {
|
||||
gain_cdbk_lbr,
|
||||
5,
|
||||
0
|
||||
};
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
static const ltp_params ltp_params_lbr = {
|
||||
gain_cdbk_lbr,
|
||||
5,
|
||||
7
|
||||
};
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
static const ltp_params ltp_params_med = {
|
||||
gain_cdbk_lbr,
|
||||
5,
|
||||
7
|
||||
};
|
||||
|
||||
/* Split-VQ innovation parameters for very low bit-rate narrowband */
|
||||
static const split_cb_params split_cb_nb_vlbr = {
|
||||
10, /*subvect_size*/
|
||||
4, /*nb_subvect*/
|
||||
exc_10_16_table, /*shape_cb*/
|
||||
4, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
/* Split-VQ innovation parameters for very low bit-rate narrowband */
|
||||
static const split_cb_params split_cb_nb_ulbr = {
|
||||
20, /*subvect_size*/
|
||||
2, /*nb_subvect*/
|
||||
exc_20_32_table, /*shape_cb*/
|
||||
5, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
/* Split-VQ innovation parameters for low bit-rate narrowband */
|
||||
static const split_cb_params split_cb_nb_lbr = {
|
||||
10, /*subvect_size*/
|
||||
4, /*nb_subvect*/
|
||||
exc_10_32_table, /*shape_cb*/
|
||||
5, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
/* Split-VQ innovation parameters narrowband */
|
||||
static const split_cb_params split_cb_nb = {
|
||||
5, /*subvect_size*/
|
||||
8, /*nb_subvect*/
|
||||
exc_5_64_table, /*shape_cb*/
|
||||
6, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
/* Split-VQ innovation parameters narrowband */
|
||||
static const split_cb_params split_cb_nb_med = {
|
||||
8, /*subvect_size*/
|
||||
5, /*nb_subvect*/
|
||||
exc_8_128_table, /*shape_cb*/
|
||||
7, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
/* Split-VQ innovation for low-band wideband */
|
||||
static const split_cb_params split_cb_sb = {
|
||||
5, /*subvect_size*/
|
||||
8, /*nb_subvect*/
|
||||
exc_5_256_table, /*shape_cb*/
|
||||
8, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
#ifndef DISABLE_WIDEBAND
|
||||
|
||||
/* Split-VQ innovation for high-band wideband */
|
||||
static const split_cb_params split_cb_high = {
|
||||
8, /*subvect_size*/
|
||||
5, /*nb_subvect*/
|
||||
hexc_table, /*shape_cb*/
|
||||
7, /*shape_bits*/
|
||||
1,
|
||||
};
|
||||
|
||||
|
||||
/* Split-VQ innovation for high-band wideband */
|
||||
static const split_cb_params split_cb_high_lbr = {
|
||||
10, /*subvect_size*/
|
||||
4, /*nb_subvect*/
|
||||
hexc_10_32_table, /*shape_cb*/
|
||||
5, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* 2150 bps "vocoder-like" mode for comfort noise */
|
||||
static const SpeexSubmode nb_submode1 = {
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* LSP quantization */
|
||||
lsp_quant_lbr,
|
||||
lsp_unquant_lbr,
|
||||
/* No pitch quantization */
|
||||
forced_pitch_quant,
|
||||
forced_pitch_unquant,
|
||||
NULL,
|
||||
/* No innovation quantization (noise only) */
|
||||
noise_codebook_quant,
|
||||
noise_codebook_unquant,
|
||||
NULL,
|
||||
-1,
|
||||
43
|
||||
};
|
||||
|
||||
/* 3.95 kbps very low bit-rate mode */
|
||||
static const SpeexSubmode nb_submode8 = {
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_lbr,
|
||||
lsp_unquant_lbr,
|
||||
/*No pitch quantization*/
|
||||
forced_pitch_quant,
|
||||
forced_pitch_unquant,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb_ulbr,
|
||||
QCONST16(.5,15),
|
||||
79
|
||||
};
|
||||
|
||||
/* 5.95 kbps very low bit-rate mode */
|
||||
static const SpeexSubmode nb_submode2 = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_lbr,
|
||||
lsp_unquant_lbr,
|
||||
/*No pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_vlbr,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb_vlbr,
|
||||
QCONST16(.6,15),
|
||||
119
|
||||
};
|
||||
|
||||
/* 8 kbps low bit-rate mode */
|
||||
static const SpeexSubmode nb_submode3 = {
|
||||
-1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_lbr,
|
||||
lsp_unquant_lbr,
|
||||
/*Pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_lbr,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb_lbr,
|
||||
QCONST16(.55,15),
|
||||
160
|
||||
};
|
||||
|
||||
/* 11 kbps medium bit-rate mode */
|
||||
static const SpeexSubmode nb_submode4 = {
|
||||
-1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_lbr,
|
||||
lsp_unquant_lbr,
|
||||
/*Pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_med,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb_med,
|
||||
QCONST16(.45,15),
|
||||
220
|
||||
};
|
||||
|
||||
/* 15 kbps high bit-rate mode */
|
||||
static const SpeexSubmode nb_submode5 = {
|
||||
-1,
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_nb,
|
||||
lsp_unquant_nb,
|
||||
/*Pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_nb,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb,
|
||||
QCONST16(.3,15),
|
||||
300
|
||||
};
|
||||
|
||||
/* 18.2 high bit-rate mode */
|
||||
static const SpeexSubmode nb_submode6 = {
|
||||
-1,
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_nb,
|
||||
lsp_unquant_nb,
|
||||
/*Pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_nb,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_sb,
|
||||
QCONST16(.2,15),
|
||||
364
|
||||
};
|
||||
|
||||
/* 24.6 kbps high bit-rate mode */
|
||||
static const SpeexSubmode nb_submode7 = {
|
||||
-1,
|
||||
0,
|
||||
3,
|
||||
1,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_nb,
|
||||
lsp_unquant_nb,
|
||||
/*Pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_nb,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb,
|
||||
QCONST16(.1,15),
|
||||
492
|
||||
};
|
||||
|
||||
|
||||
/* Default mode for narrowband */
|
||||
static const SpeexNBMode nb_mode = {
|
||||
160, /*frameSize*/
|
||||
40, /*subframeSize*/
|
||||
10, /*lpcSize*/
|
||||
17, /*pitchStart*/
|
||||
144, /*pitchEnd*/
|
||||
#ifdef FIXED_POINT
|
||||
29491, 19661, /* gamma1, gamma2 */
|
||||
#else
|
||||
0.9, 0.6, /* gamma1, gamma2 */
|
||||
#endif
|
||||
.012, /*lag_factor*/
|
||||
QCONST16(.0002,15), /*lpc_floor*/
|
||||
#ifdef EPIC_48K
|
||||
0,
|
||||
#endif
|
||||
{NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7,
|
||||
&nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
5,
|
||||
{1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
|
||||
};
|
||||
|
||||
|
||||
/* Default mode for narrowband */
|
||||
const SpeexMode speex_nb_mode = {
|
||||
&nb_mode,
|
||||
nb_mode_query,
|
||||
"narrowband",
|
||||
0,
|
||||
4,
|
||||
&nb_encoder_init,
|
||||
&nb_encoder_destroy,
|
||||
&nb_encode,
|
||||
&nb_decoder_init,
|
||||
&nb_decoder_destroy,
|
||||
&nb_decode,
|
||||
&nb_encoder_ctl,
|
||||
&nb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
/* Wideband part */
|
||||
|
||||
static const SpeexSubmode wb_submode1 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*No innovation quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
-1,
|
||||
36
|
||||
};
|
||||
|
||||
|
||||
static const SpeexSubmode wb_submode2 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
NULL,
|
||||
#else
|
||||
&split_cb_high_lbr,
|
||||
#endif
|
||||
-1,
|
||||
112
|
||||
};
|
||||
|
||||
|
||||
static const SpeexSubmode wb_submode3 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
NULL,
|
||||
#else
|
||||
&split_cb_high,
|
||||
#endif
|
||||
-1,
|
||||
192
|
||||
};
|
||||
|
||||
static const SpeexSubmode wb_submode4 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
NULL,
|
||||
#else
|
||||
&split_cb_high,
|
||||
#endif
|
||||
-1,
|
||||
352
|
||||
};
|
||||
|
||||
|
||||
/* Split-band wideband CELP mode*/
|
||||
static const SpeexSBMode sb_wb_mode = {
|
||||
&speex_nb_mode,
|
||||
160, /*frameSize*/
|
||||
40, /*subframeSize*/
|
||||
8, /*lpcSize*/
|
||||
640, /*bufSize*/
|
||||
#ifdef FIXED_POINT
|
||||
29491, 19661, /* gamma1, gamma2 */
|
||||
#else
|
||||
0.9, 0.6, /* gamma1, gamma2 */
|
||||
#endif
|
||||
.012, /*lag_factor*/
|
||||
QCONST16(.0002,15), /*lpc_floor*/
|
||||
0.9,
|
||||
{NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
|
||||
3,
|
||||
{1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
|
||||
{1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
|
||||
vbr_hb_thresh,
|
||||
5
|
||||
};
|
||||
|
||||
|
||||
const SpeexMode speex_wb_mode = {
|
||||
&sb_wb_mode,
|
||||
wb_mode_query,
|
||||
"wideband (sub-band CELP)",
|
||||
1,
|
||||
4,
|
||||
&sb_encoder_init,
|
||||
&sb_encoder_destroy,
|
||||
&sb_encode,
|
||||
&sb_decoder_init,
|
||||
&sb_decoder_destroy,
|
||||
&sb_decode,
|
||||
&sb_encoder_ctl,
|
||||
&sb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* "Ultra-wideband" mode stuff */
|
||||
|
||||
|
||||
|
||||
/* Split-band "ultra-wideband" (32 kbps) CELP mode*/
|
||||
static const SpeexSBMode sb_uwb_mode = {
|
||||
&speex_wb_mode,
|
||||
320, /*frameSize*/
|
||||
80, /*subframeSize*/
|
||||
8, /*lpcSize*/
|
||||
1280, /*bufSize*/
|
||||
#ifdef FIXED_POINT
|
||||
29491, 19661, /* gamma1, gamma2 */
|
||||
#else
|
||||
0.9, 0.6, /* gamma1, gamma2 */
|
||||
#endif
|
||||
.012, /*lag_factor*/
|
||||
QCONST16(.0002,15), /*lpc_floor*/
|
||||
0.7,
|
||||
{NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
1,
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
vbr_uhb_thresh,
|
||||
2
|
||||
};
|
||||
|
||||
|
||||
const SpeexMode speex_uwb_mode = {
|
||||
&sb_uwb_mode,
|
||||
wb_mode_query,
|
||||
"ultra-wideband (sub-band CELP)",
|
||||
2,
|
||||
4,
|
||||
&sb_encoder_init,
|
||||
&sb_encoder_destroy,
|
||||
&sb_encode,
|
||||
&sb_decoder_init,
|
||||
&sb_decoder_destroy,
|
||||
&sb_decode,
|
||||
&sb_encoder_ctl,
|
||||
&sb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef EPIC_48K
|
||||
|
||||
extern const signed char gain_cdbk_ulbr[];
|
||||
extern const signed char exc_12_32_table[];
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
static const ltp_params ltp_params_48k = {
|
||||
gain_cdbk_ulbr,
|
||||
3,
|
||||
0
|
||||
};
|
||||
|
||||
static const split_cb_params split_cb_nb_48k = {
|
||||
12, /*subvect_size*/
|
||||
4, /*nb_subvect*/
|
||||
exc_12_32_table, /*shape_cb*/
|
||||
5, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
/* 4.8 kbps very low bit-rate mode */
|
||||
static const SpeexSubmode nb_48k_submode = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_48k,
|
||||
lsp_unquant_48k,
|
||||
/*No pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_48k,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb_48k,
|
||||
#ifdef FIXED_POINT
|
||||
22938, 16384, 11796, 18022,
|
||||
#else
|
||||
0.7, 0.5, .36, .55,
|
||||
#endif
|
||||
144
|
||||
};
|
||||
|
||||
|
||||
/* Special, non-standard 4.8 kbps mode */
|
||||
static const SpeexNBMode nb_48k_mode = {
|
||||
240, /*frameSize*/
|
||||
48, /*subframeSize*/
|
||||
10, /*lpcSize*/
|
||||
640, /*bufSize*/
|
||||
17, /*pitchStart*/
|
||||
144, /*pitchEnd*/
|
||||
0.9, /*gamma1*/
|
||||
0.6, /*gamma2*/
|
||||
.01, /*lag_factor*/
|
||||
QCONST16(.0003,15), /*lpc_floor*/
|
||||
1,
|
||||
{NULL, NULL, &nb_48k_submode, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
2,
|
||||
{2,2,2,2,2,2,2,2,2,2,2}
|
||||
};
|
||||
|
||||
|
||||
/* Default mode for narrowband */
|
||||
const SpeexMode speex_nb_48k_mode = {
|
||||
&nb_48k_mode,
|
||||
nb_mode_query,
|
||||
"narrowband 4.8 kbps",
|
||||
1000,
|
||||
4,
|
||||
&nb_encoder_init,
|
||||
&nb_encoder_destroy,
|
||||
&nb_encode,
|
||||
&nb_decoder_init,
|
||||
&nb_decoder_destroy,
|
||||
&nb_decode,
|
||||
&nb_encoder_ctl,
|
||||
&nb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
int speex_mode_query(const SpeexMode *mode, int request, void *ptr)
|
||||
{
|
||||
return mode->query(mode->mode, request, ptr);
|
||||
}
|
||||
|
||||
const SpeexMode * speex_lib_get_mode (int mode)
|
||||
{
|
||||
#ifdef EPIC_48K
|
||||
if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode;
|
||||
#endif
|
||||
|
||||
if (mode < 0 || mode > SPEEX_NB_MODES) return NULL;
|
||||
|
||||
return speex_mode_list[mode];
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
/* Copyright (C) 2002-2006 Jean-Marc Valin */
|
||||
/**
|
||||
@file modes.h
|
||||
@brief Describes the different modes of the codec
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MODES_H
|
||||
#define MODES_H
|
||||
|
||||
#include <speex/speex.h>
|
||||
#include <speex/speex_bits.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define NB_SUBMODES 16
|
||||
#define NB_SUBMODE_BITS 4
|
||||
|
||||
#define SB_SUBMODES 8
|
||||
#define SB_SUBMODE_BITS 3
|
||||
|
||||
|
||||
/** Quantizes LSPs */
|
||||
typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *);
|
||||
|
||||
/** Decodes quantized LSPs */
|
||||
typedef void (*lsp_unquant_func)(spx_lsp_t *, int, SpeexBits *);
|
||||
|
||||
|
||||
/** Long-term predictor quantization */
|
||||
typedef int (*ltp_quant_func)(spx_word16_t *, spx_word16_t *, spx_coef_t *, spx_coef_t *,
|
||||
spx_coef_t *, spx_sig_t *, const void *, int, int, spx_word16_t,
|
||||
int, int, SpeexBits*, char *, spx_word16_t *, spx_word16_t *, int, int, int, spx_word32_t *);
|
||||
|
||||
/** Long-term un-quantize */
|
||||
typedef void (*ltp_unquant_func)(spx_word16_t *, spx_word32_t *, int, int, spx_word16_t, const void *, int, int *,
|
||||
spx_word16_t *, SpeexBits*, char*, int, int, spx_word16_t, int);
|
||||
|
||||
|
||||
/** Innovation quantization function */
|
||||
typedef void (*innovation_quant_func)(spx_word16_t *, spx_coef_t *, spx_coef_t *, spx_coef_t *, const void *, int, int,
|
||||
spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int);
|
||||
|
||||
/** Innovation unquantization function */
|
||||
typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *, spx_int32_t *);
|
||||
|
||||
/** Description of a Speex sub-mode (wither narrowband or wideband */
|
||||
typedef struct SpeexSubmode {
|
||||
int lbr_pitch; /**< Set to -1 for "normal" modes, otherwise encode pitch using a global pitch and allowing a +- lbr_pitch variation (for low not-rates)*/
|
||||
int forced_pitch_gain; /**< Use the same (forced) pitch gain for all sub-frames */
|
||||
int have_subframe_gain; /**< Number of bits to use as sub-frame innovation gain */
|
||||
int double_codebook; /**< Apply innovation quantization twice for higher quality (and higher bit-rate)*/
|
||||
/*LSP functions*/
|
||||
lsp_quant_func lsp_quant; /**< LSP quantization function */
|
||||
lsp_unquant_func lsp_unquant; /**< LSP unquantization function */
|
||||
|
||||
/*Lont-term predictor functions*/
|
||||
ltp_quant_func ltp_quant; /**< Long-term predictor (pitch) quantizer */
|
||||
ltp_unquant_func ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */
|
||||
const void *ltp_params; /**< Pitch parameters (options) */
|
||||
|
||||
/*Quantization of innovation*/
|
||||
innovation_quant_func innovation_quant; /**< Innovation quantization */
|
||||
innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */
|
||||
const void *innovation_params; /**< Innovation quantization parameters*/
|
||||
|
||||
spx_word16_t comb_gain; /**< Gain of enhancer comb filter */
|
||||
|
||||
int bits_per_frame; /**< Number of bits per frame after encoding*/
|
||||
} SpeexSubmode;
|
||||
|
||||
/** Struct defining the encoding/decoding mode*/
|
||||
typedef struct SpeexNBMode {
|
||||
int frameSize; /**< Size of frames used for encoding */
|
||||
int subframeSize; /**< Size of sub-frames used for encoding */
|
||||
int lpcSize; /**< Order of LPC filter */
|
||||
int pitchStart; /**< Smallest pitch value allowed */
|
||||
int pitchEnd; /**< Largest pitch value allowed */
|
||||
|
||||
spx_word16_t gamma1; /**< Perceptual filter parameter #1 */
|
||||
spx_word16_t gamma2; /**< Perceptual filter parameter #2 */
|
||||
float lag_factor; /**< Lag-windowing parameter */
|
||||
spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */
|
||||
|
||||
#ifdef EPIC_48K
|
||||
int lbr48k; /**< 1 for the special 4.8 kbps mode */
|
||||
#endif
|
||||
|
||||
const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
|
||||
int defaultSubmode; /**< Default sub-mode to use when encoding */
|
||||
int quality_map[11]; /**< Mode corresponding to each quality setting */
|
||||
} SpeexNBMode;
|
||||
|
||||
|
||||
/** Struct defining the encoding/decoding mode for SB-CELP (wideband) */
|
||||
typedef struct SpeexSBMode {
|
||||
const SpeexMode *nb_mode; /**< Embedded narrowband mode */
|
||||
int frameSize; /**< Size of frames used for encoding */
|
||||
int subframeSize; /**< Size of sub-frames used for encoding */
|
||||
int lpcSize; /**< Order of LPC filter */
|
||||
int bufSize; /**< Signal buffer size in encoder */
|
||||
spx_word16_t gamma1; /**< Perceptual filter parameter #1 */
|
||||
spx_word16_t gamma2; /**< Perceptual filter parameter #1 */
|
||||
float lag_factor; /**< Lag-windowing parameter */
|
||||
spx_word16_t lpc_floor; /**< Noise floor for LPC analysis */
|
||||
float folding_gain;
|
||||
|
||||
const SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
|
||||
int defaultSubmode; /**< Default sub-mode to use when encoding */
|
||||
int low_quality_map[11]; /**< Mode corresponding to each quality setting */
|
||||
int quality_map[11]; /**< Mode corresponding to each quality setting */
|
||||
const float (*vbr_thresh)[11];
|
||||
int nb_modes;
|
||||
} SpeexSBMode;
|
||||
|
||||
int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits);
|
||||
int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out);
|
||||
|
||||
int nb_mode_query(const void *mode, int request, void *ptr);
|
||||
int wb_mode_query(const void *mode, int request, void *ptr);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,205 +0,0 @@
|
|||
/* Copyright (C) 2002-2006 Jean-Marc Valin */
|
||||
/**
|
||||
@file nb_celp.h
|
||||
@brief Narrowband CELP encoder/decoder
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef NB_CELP_H
|
||||
#define NB_CELP_H
|
||||
|
||||
#include "modes.h"
|
||||
#include <speex/speex_bits.h>
|
||||
#include <speex/speex_callbacks.h>
|
||||
#include "vbr.h"
|
||||
#include "filters.h"
|
||||
|
||||
#ifdef VORBIS_PSYCHO
|
||||
#include "vorbis_psy.h"
|
||||
#endif
|
||||
|
||||
/**Structure representing the full state of the narrowband encoder*/
|
||||
typedef struct EncState {
|
||||
const SpeexMode *mode; /**< Mode corresponding to the state */
|
||||
int first; /**< Is this the first frame? */
|
||||
int frameSize; /**< Size of frames */
|
||||
int subframeSize; /**< Size of sub-frames */
|
||||
int nbSubframes; /**< Number of sub-frames */
|
||||
int windowSize; /**< Analysis (LPC) window length */
|
||||
int lpcSize; /**< LPC order */
|
||||
int min_pitch; /**< Minimum pitch value allowed */
|
||||
int max_pitch; /**< Maximum pitch value allowed */
|
||||
|
||||
spx_word32_t cumul_gain; /**< Product of previously used pitch gains (Q10) */
|
||||
int bounded_pitch; /**< Next frame should not rely on previous frames for pitch */
|
||||
int ol_pitch; /**< Open-loop pitch */
|
||||
int ol_voiced; /**< Open-loop voiced/non-voiced decision */
|
||||
int *pitch;
|
||||
|
||||
#ifdef EPIC_48K
|
||||
int lbr_48k;
|
||||
#endif
|
||||
|
||||
#ifdef VORBIS_PSYCHO
|
||||
VorbisPsy *psy;
|
||||
float *psy_window;
|
||||
float *curve;
|
||||
float *old_curve;
|
||||
#endif
|
||||
|
||||
spx_word16_t gamma1; /**< Perceptual filter: A(z/gamma1) */
|
||||
spx_word16_t gamma2; /**< Perceptual filter: A(z/gamma2) */
|
||||
float lag_factor; /**< Lag windowing Gaussian width */
|
||||
spx_word16_t lpc_floor; /**< Noise floor multiplier for A[0] in LPC analysis*/
|
||||
char *stack; /**< Pseudo-stack allocation for temporary memory */
|
||||
spx_word16_t *winBuf; /**< Input buffer (original signal) */
|
||||
spx_word16_t *excBuf; /**< Excitation buffer */
|
||||
spx_word16_t *exc; /**< Start of excitation frame */
|
||||
spx_word16_t *swBuf; /**< Weighted signal buffer */
|
||||
spx_word16_t *sw; /**< Start of weighted signal frame */
|
||||
const spx_word16_t *window; /**< Temporary (Hanning) window */
|
||||
spx_word16_t *lagWindow; /**< Window applied to auto-correlation */
|
||||
spx_lsp_t *old_lsp; /**< LSPs for previous frame */
|
||||
spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */
|
||||
spx_mem_t *mem_sp; /**< Filter memory for signal synthesis */
|
||||
spx_mem_t *mem_sw; /**< Filter memory for perceptually-weighted signal */
|
||||
spx_mem_t *mem_sw_whole; /**< Filter memory for perceptually-weighted signal (whole frame)*/
|
||||
spx_mem_t *mem_exc; /**< Filter memory for excitation (whole frame) */
|
||||
spx_mem_t *mem_exc2; /**< Filter memory for excitation (whole frame) */
|
||||
spx_mem_t mem_hp[2]; /**< High-pass filter memory */
|
||||
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
|
||||
spx_sig_t *innov_save; /**< If non-NULL, innovation is copied here */
|
||||
|
||||
VBRState *vbr; /**< State of the VBR data */
|
||||
float vbr_quality; /**< Quality setting for VBR encoding */
|
||||
float relative_quality; /**< Relative quality that will be needed by VBR */
|
||||
spx_int32_t vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
|
||||
spx_int32_t vbr_max; /**< Max bit-rate allowed in VBR mode */
|
||||
int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */
|
||||
int dtx_enabled; /**< 1 for enabling DTX, 0 otherwise */
|
||||
int dtx_count; /**< Number of consecutive DTX frames */
|
||||
spx_int32_t abr_enabled; /**< ABR setting (in bps), 0 if off */
|
||||
float abr_drift;
|
||||
float abr_drift2;
|
||||
float abr_count;
|
||||
int complexity; /**< Complexity setting (0-10 from least complex to most complex) */
|
||||
spx_int32_t sampling_rate;
|
||||
int plc_tuning;
|
||||
int encode_submode;
|
||||
const SpeexSubmode * const *submodes; /**< Sub-mode data */
|
||||
int submodeID; /**< Activated sub-mode */
|
||||
int submodeSelect; /**< Mode chosen by the user (may differ from submodeID if VAD is on) */
|
||||
int isWideband; /**< Is this used as part of the embedded wideband codec */
|
||||
int highpass_enabled; /**< Is the input filter enabled */
|
||||
} EncState;
|
||||
|
||||
/**Structure representing the full state of the narrowband decoder*/
|
||||
typedef struct DecState {
|
||||
const SpeexMode *mode; /**< Mode corresponding to the state */
|
||||
int first; /**< Is this the first frame? */
|
||||
int count_lost; /**< Was the last frame lost? */
|
||||
int frameSize; /**< Size of frames */
|
||||
int subframeSize; /**< Size of sub-frames */
|
||||
int nbSubframes; /**< Number of sub-frames */
|
||||
int lpcSize; /**< LPC order */
|
||||
int min_pitch; /**< Minimum pitch value allowed */
|
||||
int max_pitch; /**< Maximum pitch value allowed */
|
||||
spx_int32_t sampling_rate;
|
||||
|
||||
#ifdef EPIC_48K
|
||||
int lbr_48k;
|
||||
#endif
|
||||
|
||||
spx_word16_t last_ol_gain; /**< Open-loop gain for previous frame */
|
||||
|
||||
char *stack; /**< Pseudo-stack allocation for temporary memory */
|
||||
spx_word16_t *excBuf; /**< Excitation buffer */
|
||||
spx_word16_t *exc; /**< Start of excitation frame */
|
||||
spx_lsp_t *old_qlsp; /**< Quantized LSPs for previous frame */
|
||||
spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs */
|
||||
spx_mem_t *mem_sp; /**< Filter memory for synthesis signal */
|
||||
spx_mem_t mem_hp[2]; /**< High-pass filter memory */
|
||||
spx_word32_t *pi_gain; /**< Gain of LPC filter at theta=pi (fe/2) */
|
||||
spx_sig_t *innov_save; /** If non-NULL, innovation is copied here */
|
||||
|
||||
/* This is used in packet loss concealment */
|
||||
int last_pitch; /**< Pitch of last correctly decoded frame */
|
||||
spx_word16_t last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
|
||||
spx_word16_t pitch_gain_buf[3]; /**< Pitch gain of last decoded frames */
|
||||
int pitch_gain_buf_idx; /**< Tail of the buffer */
|
||||
spx_int32_t seed; /** Seed used for random number generation */
|
||||
|
||||
int encode_submode;
|
||||
const SpeexSubmode * const *submodes; /**< Sub-mode data */
|
||||
int submodeID; /**< Activated sub-mode */
|
||||
int lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */
|
||||
SpeexCallback speex_callbacks[SPEEX_MAX_CALLBACKS];
|
||||
|
||||
SpeexCallback user_callback;
|
||||
|
||||
/*Vocoder data*/
|
||||
spx_word16_t voc_m1;
|
||||
spx_word32_t voc_m2;
|
||||
float voc_mean;
|
||||
int voc_offset;
|
||||
|
||||
int dtx_enabled;
|
||||
int isWideband; /**< Is this used as part of the embedded wideband codec */
|
||||
int highpass_enabled; /**< Is the input filter enabled */
|
||||
} DecState;
|
||||
|
||||
/** Initializes encoder state*/
|
||||
void *nb_encoder_init(const SpeexMode *m);
|
||||
|
||||
/** De-allocates encoder state resources*/
|
||||
void nb_encoder_destroy(void *state);
|
||||
|
||||
/** Encodes one frame*/
|
||||
int nb_encode(void *state, void *in, SpeexBits *bits);
|
||||
|
||||
|
||||
/** Initializes decoder state*/
|
||||
void *nb_decoder_init(const SpeexMode *m);
|
||||
|
||||
/** De-allocates decoder state resources*/
|
||||
void nb_decoder_destroy(void *state);
|
||||
|
||||
/** Decodes one frame*/
|
||||
int nb_decode(void *state, SpeexBits *bits, void *out);
|
||||
|
||||
/** ioctl-like function for controlling a narrowband encoder */
|
||||
int nb_encoder_ctl(void *state, int request, void *ptr);
|
||||
|
||||
/** ioctl-like function for controlling a narrowband decoder */
|
||||
int nb_decoder_ctl(void *state, int request, void *ptr);
|
||||
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,369 +0,0 @@
|
|||
/* Copyright (C) 2005 Jean-Marc Valin */
|
||||
/**
|
||||
@file pseudofloat.h
|
||||
@brief Pseudo-floating point
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef PSEUDOFLOAT_H
|
||||
#define PSEUDOFLOAT_H
|
||||
|
||||
#include "misc.h"
|
||||
#include "math_approx.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
typedef struct {
|
||||
spx_int16_t m;
|
||||
spx_int16_t e;
|
||||
} spx_float_t;
|
||||
|
||||
static const spx_float_t FLOAT_ZERO = {0,0};
|
||||
static const spx_float_t FLOAT_ONE = {16384,-14};
|
||||
static const spx_float_t FLOAT_HALF = {16384,-15};
|
||||
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
static inline spx_float_t PSEUDOFLOAT(spx_int32_t x)
|
||||
{
|
||||
int e=0;
|
||||
int sign=0;
|
||||
if (x<0)
|
||||
{
|
||||
sign = 1;
|
||||
x = -x;
|
||||
}
|
||||
if (x==0)
|
||||
{
|
||||
spx_float_t r = {0,0};
|
||||
return r;
|
||||
}
|
||||
e = spx_ilog2(ABS32(x))-14;
|
||||
x = VSHR32(x, e);
|
||||
if (sign)
|
||||
{
|
||||
spx_float_t r;
|
||||
r.m = -x;
|
||||
r.e = e;
|
||||
return r;
|
||||
}
|
||||
else
|
||||
{
|
||||
spx_float_t r;
|
||||
r.m = x;
|
||||
r.e = e;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline spx_float_t FLOAT_ADD(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
spx_float_t r;
|
||||
if (a.m==0)
|
||||
return b;
|
||||
else if (b.m==0)
|
||||
return a;
|
||||
if ((a).e > (b).e)
|
||||
{
|
||||
r.m = ((a).m>>1) + ((b).m>>MIN(15,(a).e-(b).e+1));
|
||||
r.e = (a).e+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.m = ((b).m>>1) + ((a).m>>MIN(15,(b).e-(a).e+1));
|
||||
r.e = (b).e+1;
|
||||
}
|
||||
if (r.m>0)
|
||||
{
|
||||
if (r.m<16384)
|
||||
{
|
||||
r.m<<=1;
|
||||
r.e-=1;
|
||||
}
|
||||
} else {
|
||||
if (r.m>-16384)
|
||||
{
|
||||
r.m<<=1;
|
||||
r.e-=1;
|
||||
}
|
||||
}
|
||||
/*printf ("%f + %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline spx_float_t FLOAT_SUB(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
spx_float_t r;
|
||||
if (a.m==0)
|
||||
return b;
|
||||
else if (b.m==0)
|
||||
return a;
|
||||
if ((a).e > (b).e)
|
||||
{
|
||||
r.m = ((a).m>>1) - ((b).m>>MIN(15,(a).e-(b).e+1));
|
||||
r.e = (a).e+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.m = ((a).m>>MIN(15,(b).e-(a).e+1)) - ((b).m>>1);
|
||||
r.e = (b).e+1;
|
||||
}
|
||||
if (r.m>0)
|
||||
{
|
||||
if (r.m<16384)
|
||||
{
|
||||
r.m<<=1;
|
||||
r.e-=1;
|
||||
}
|
||||
} else {
|
||||
if (r.m>-16384)
|
||||
{
|
||||
r.m<<=1;
|
||||
r.e-=1;
|
||||
}
|
||||
}
|
||||
/*printf ("%f + %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline int FLOAT_LT(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
if (a.m==0)
|
||||
return b.m>0;
|
||||
else if (b.m==0)
|
||||
return a.m<0;
|
||||
if ((a).e > (b).e)
|
||||
return ((a).m>>1) < ((b).m>>MIN(15,(a).e-(b).e+1));
|
||||
else
|
||||
return ((b).m>>1) > ((a).m>>MIN(15,(b).e-(a).e+1));
|
||||
|
||||
}
|
||||
|
||||
static inline int FLOAT_GT(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
return FLOAT_LT(b,a);
|
||||
}
|
||||
|
||||
static inline spx_float_t FLOAT_MULT(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
spx_float_t r;
|
||||
r.m = (spx_int16_t)((spx_int32_t)(a).m*(b).m>>15);
|
||||
r.e = (a).e+(b).e+15;
|
||||
if (r.m>0)
|
||||
{
|
||||
if (r.m<16384)
|
||||
{
|
||||
r.m<<=1;
|
||||
r.e-=1;
|
||||
}
|
||||
} else {
|
||||
if (r.m>-16384)
|
||||
{
|
||||
r.m<<=1;
|
||||
r.e-=1;
|
||||
}
|
||||
}
|
||||
/*printf ("%f * %f = %f\n", REALFLOAT(a), REALFLOAT(b), REALFLOAT(r));*/
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline spx_float_t FLOAT_AMULT(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
spx_float_t r;
|
||||
r.m = (spx_int16_t)((spx_int32_t)(a).m*(b).m>>15);
|
||||
r.e = (a).e+(b).e+15;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
static inline spx_float_t FLOAT_SHL(spx_float_t a, int b)
|
||||
{
|
||||
spx_float_t r;
|
||||
r.m = a.m;
|
||||
r.e = a.e+b;
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline spx_int16_t FLOAT_EXTRACT16(spx_float_t a)
|
||||
{
|
||||
if (a.e<0)
|
||||
return EXTRACT16((EXTEND32(a.m)+(EXTEND32(1)<<(-a.e-1)))>>-a.e);
|
||||
else
|
||||
return a.m<<a.e;
|
||||
}
|
||||
|
||||
static inline spx_int32_t FLOAT_EXTRACT32(spx_float_t a)
|
||||
{
|
||||
if (a.e<0)
|
||||
return (EXTEND32(a.m)+(EXTEND32(1)<<(-a.e-1)))>>-a.e;
|
||||
else
|
||||
return EXTEND32(a.m)<<a.e;
|
||||
}
|
||||
|
||||
static inline spx_int32_t FLOAT_MUL32(spx_float_t a, spx_word32_t b)
|
||||
{
|
||||
return VSHR32(MULT16_32_Q15(a.m, b),-a.e-15);
|
||||
}
|
||||
|
||||
static inline spx_float_t FLOAT_MUL32U(spx_word32_t a, spx_word32_t b)
|
||||
{
|
||||
int e1, e2;
|
||||
spx_float_t r;
|
||||
if (a==0 || b==0)
|
||||
{
|
||||
return FLOAT_ZERO;
|
||||
}
|
||||
e1 = spx_ilog2(ABS32(a));
|
||||
a = VSHR32(a, e1-14);
|
||||
e2 = spx_ilog2(ABS32(b));
|
||||
b = VSHR32(b, e2-14);
|
||||
r.m = MULT16_16_Q15(a,b);
|
||||
r.e = e1+e2-13;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Do NOT attempt to divide by a negative number */
|
||||
static inline spx_float_t FLOAT_DIV32_FLOAT(spx_word32_t a, spx_float_t b)
|
||||
{
|
||||
int e=0;
|
||||
spx_float_t r;
|
||||
if (a==0)
|
||||
{
|
||||
return FLOAT_ZERO;
|
||||
}
|
||||
e = spx_ilog2(ABS32(a))-spx_ilog2(b.m-1)-15;
|
||||
a = VSHR32(a, e);
|
||||
if (ABS32(a)>=SHL32(EXTEND32(b.m-1),15))
|
||||
{
|
||||
a >>= 1;
|
||||
e++;
|
||||
}
|
||||
r.m = DIV32_16(a,b.m);
|
||||
r.e = e-b.e;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/* Do NOT attempt to divide by a negative number */
|
||||
static inline spx_float_t FLOAT_DIV32(spx_word32_t a, spx_word32_t b)
|
||||
{
|
||||
int e0=0,e=0;
|
||||
spx_float_t r;
|
||||
if (a==0)
|
||||
{
|
||||
return FLOAT_ZERO;
|
||||
}
|
||||
if (b>32767)
|
||||
{
|
||||
e0 = spx_ilog2(b)-14;
|
||||
b = VSHR32(b, e0);
|
||||
e0 = -e0;
|
||||
}
|
||||
e = spx_ilog2(ABS32(a))-spx_ilog2(b-1)-15;
|
||||
a = VSHR32(a, e);
|
||||
if (ABS32(a)>=SHL32(EXTEND32(b-1),15))
|
||||
{
|
||||
a >>= 1;
|
||||
e++;
|
||||
}
|
||||
e += e0;
|
||||
r.m = DIV32_16(a,b);
|
||||
r.e = e;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Do NOT attempt to divide by a negative number */
|
||||
static inline spx_float_t FLOAT_DIVU(spx_float_t a, spx_float_t b)
|
||||
{
|
||||
int e=0;
|
||||
spx_int32_t num;
|
||||
spx_float_t r;
|
||||
if (b.m<=0)
|
||||
{
|
||||
speex_warning_int("Attempted to divide by", b.m);
|
||||
return FLOAT_ONE;
|
||||
}
|
||||
num = a.m;
|
||||
a.m = ABS16(a.m);
|
||||
while (a.m >= b.m)
|
||||
{
|
||||
e++;
|
||||
a.m >>= 1;
|
||||
}
|
||||
num = num << (15-e);
|
||||
r.m = DIV32_16(num,b.m);
|
||||
r.e = a.e-b.e-15+e;
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline spx_float_t FLOAT_SQRT(spx_float_t a)
|
||||
{
|
||||
spx_float_t r;
|
||||
spx_int32_t m;
|
||||
m = SHL32(EXTEND32(a.m), 14);
|
||||
r.e = a.e - 14;
|
||||
if (r.e & 1)
|
||||
{
|
||||
r.e -= 1;
|
||||
m <<= 1;
|
||||
}
|
||||
r.e >>= 1;
|
||||
r.m = spx_sqrt(m);
|
||||
return r;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define spx_float_t float
|
||||
#define FLOAT_ZERO 0.f
|
||||
#define FLOAT_ONE 1.f
|
||||
#define FLOAT_HALF 0.5f
|
||||
#define PSEUDOFLOAT(x) (x)
|
||||
#define FLOAT_MULT(a,b) ((a)*(b))
|
||||
#define FLOAT_AMULT(a,b) ((a)*(b))
|
||||
#define FLOAT_MUL32(a,b) ((a)*(b))
|
||||
#define FLOAT_DIV32(a,b) ((a)/(b))
|
||||
#define FLOAT_EXTRACT16(a) (a)
|
||||
#define FLOAT_EXTRACT32(a) (a)
|
||||
#define FLOAT_ADD(a,b) ((a)+(b))
|
||||
#define FLOAT_SUB(a,b) ((a)-(b))
|
||||
#define REALFLOAT(x) (x)
|
||||
#define FLOAT_DIV32_FLOAT(a,b) ((a)/(b))
|
||||
#define FLOAT_MUL32U(a,b) ((a)*(b))
|
||||
#define FLOAT_SHL(a,b) (a)
|
||||
#define FLOAT_LT(a,b) ((a)<(b))
|
||||
#define FLOAT_GT(a,b) ((a)>(b))
|
||||
#define FLOAT_DIVU(a,b) ((a)/(b))
|
||||
#define FLOAT_SQRT(a) (spx_sqrt(a))
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,447 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin
|
||||
File: quant_lsp.c
|
||||
LSP vector quantization
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "quant_lsp.h"
|
||||
#include <math.h>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef BFIN_ASM
|
||||
#include "quant_lsp_bfin.h"
|
||||
#endif
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
|
||||
#define LSP_LINEAR(i) (SHL16(i+1,11))
|
||||
#define LSP_LINEAR_HIGH(i) (ADD16(MULT16_16_16(i,2560),6144))
|
||||
#define LSP_DIV_256(x) (SHL16((spx_word16_t)x, 5))
|
||||
#define LSP_DIV_512(x) (SHL16((spx_word16_t)x, 4))
|
||||
#define LSP_DIV_1024(x) (SHL16((spx_word16_t)x, 3))
|
||||
#define LSP_PI 25736
|
||||
|
||||
#else
|
||||
|
||||
#define LSP_LINEAR(i) (.25*(i)+.25)
|
||||
#define LSP_LINEAR_HIGH(i) (.3125*(i)+.75)
|
||||
#define LSP_SCALE 256.
|
||||
#define LSP_DIV_256(x) (0.0039062*(x))
|
||||
#define LSP_DIV_512(x) (0.0019531*(x))
|
||||
#define LSP_DIV_1024(x) (0.00097656*(x))
|
||||
#define LSP_PI M_PI
|
||||
|
||||
#endif
|
||||
|
||||
static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order)
|
||||
{
|
||||
int i;
|
||||
spx_word16_t tmp1, tmp2;
|
||||
for (i=0;i<order;i++)
|
||||
{
|
||||
if (i==0)
|
||||
tmp1 = qlsp[i];
|
||||
else
|
||||
tmp1 = qlsp[i]-qlsp[i-1];
|
||||
if (i==order-1)
|
||||
tmp2 = LSP_PI-qlsp[i];
|
||||
else
|
||||
tmp2 = qlsp[i+1]-qlsp[i];
|
||||
if (tmp2<tmp1)
|
||||
tmp1 = tmp2;
|
||||
#ifdef FIXED_POINT
|
||||
quant_weight[i] = DIV32_16(81920,ADD16(300,tmp1));
|
||||
#else
|
||||
quant_weight[i] = 10/(.04+tmp1);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Note: x is modified*/
|
||||
#ifndef OVERRIDE_LSP_QUANT
|
||||
static int lsp_quant(spx_word16_t *x, const signed char *cdbk, int nbVec, int nbDim)
|
||||
{
|
||||
int i,j;
|
||||
spx_word32_t dist;
|
||||
spx_word16_t tmp;
|
||||
spx_word32_t best_dist=VERY_LARGE32;
|
||||
int best_id=0;
|
||||
const signed char *ptr=cdbk;
|
||||
for (i=0;i<nbVec;i++)
|
||||
{
|
||||
dist=0;
|
||||
for (j=0;j<nbDim;j++)
|
||||
{
|
||||
tmp=SUB16(x[j],SHL16((spx_word16_t)*ptr++,5));
|
||||
dist=MAC16_16(dist,tmp,tmp);
|
||||
}
|
||||
if (dist<best_dist)
|
||||
{
|
||||
best_dist=dist;
|
||||
best_id=i;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0;j<nbDim;j++)
|
||||
x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
|
||||
|
||||
return best_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Note: x is modified*/
|
||||
#ifndef OVERRIDE_LSP_WEIGHT_QUANT
|
||||
static int lsp_weight_quant(spx_word16_t *x, spx_word16_t *weight, const signed char *cdbk, int nbVec, int nbDim)
|
||||
{
|
||||
int i,j;
|
||||
spx_word32_t dist;
|
||||
spx_word16_t tmp;
|
||||
spx_word32_t best_dist=VERY_LARGE32;
|
||||
int best_id=0;
|
||||
const signed char *ptr=cdbk;
|
||||
for (i=0;i<nbVec;i++)
|
||||
{
|
||||
dist=0;
|
||||
for (j=0;j<nbDim;j++)
|
||||
{
|
||||
tmp=SUB16(x[j],SHL16((spx_word16_t)*ptr++,5));
|
||||
dist=MAC16_32_Q15(dist,weight[j],MULT16_16(tmp,tmp));
|
||||
}
|
||||
if (dist<best_dist)
|
||||
{
|
||||
best_dist=dist;
|
||||
best_id=i;
|
||||
}
|
||||
}
|
||||
|
||||
for (j=0;j<nbDim;j++)
|
||||
x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
|
||||
return best_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i;
|
||||
int id;
|
||||
spx_word16_t quant_weight[10];
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i];
|
||||
|
||||
compute_quant_weights(qlsp, quant_weight, order);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=SUB16(qlsp[i],LSP_LINEAR(i));
|
||||
|
||||
#ifndef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = LSP_SCALE*qlsp[i];
|
||||
#endif
|
||||
id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]*=2;
|
||||
|
||||
id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low1, NB_CDBK_SIZE_LOW1, 5);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
for (i=0;i<5;i++)
|
||||
qlsp[i]*=2;
|
||||
|
||||
id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low2, NB_CDBK_SIZE_LOW2, 5);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
for (i=5;i<10;i++)
|
||||
qlsp[i]*=2;
|
||||
|
||||
id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high2, NB_CDBK_SIZE_HIGH2, 5);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=PSHR16(qlsp[i],2);
|
||||
#else
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=qlsp[i] * .00097656;
|
||||
#endif
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i]-qlsp[i];
|
||||
}
|
||||
|
||||
void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i, id;
|
||||
for (i=0;i<order;i++)
|
||||
lsp[i]=LSP_LINEAR(i);
|
||||
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<10;i++)
|
||||
lsp[i] = ADD32(lsp[i], LSP_DIV_256(cdbk_nb[id*10+i]));
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<5;i++)
|
||||
lsp[i] = ADD16(lsp[i], LSP_DIV_512(cdbk_nb_low1[id*5+i]));
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<5;i++)
|
||||
lsp[i] = ADD32(lsp[i], LSP_DIV_1024(cdbk_nb_low2[id*5+i]));
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<5;i++)
|
||||
lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_512(cdbk_nb_high1[id*5+i]));
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<5;i++)
|
||||
lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_1024(cdbk_nb_high2[id*5+i]));
|
||||
}
|
||||
|
||||
|
||||
void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i;
|
||||
int id;
|
||||
spx_word16_t quant_weight[10];
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i];
|
||||
|
||||
compute_quant_weights(qlsp, quant_weight, order);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=SUB16(qlsp[i],LSP_LINEAR(i));
|
||||
#ifndef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=qlsp[i]*LSP_SCALE;
|
||||
#endif
|
||||
id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]*=2;
|
||||
|
||||
id = lsp_weight_quant(qlsp, quant_weight, cdbk_nb_low1, NB_CDBK_SIZE_LOW1, 5);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = PSHR16(qlsp[i],1);
|
||||
#else
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = qlsp[i]*0.0019531;
|
||||
#endif
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i]-qlsp[i];
|
||||
}
|
||||
|
||||
void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i, id;
|
||||
for (i=0;i<order;i++)
|
||||
lsp[i]=LSP_LINEAR(i);
|
||||
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<10;i++)
|
||||
lsp[i] += LSP_DIV_256(cdbk_nb[id*10+i]);
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<5;i++)
|
||||
lsp[i] += LSP_DIV_512(cdbk_nb_low1[id*5+i]);
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<5;i++)
|
||||
lsp[i+5] += LSP_DIV_512(cdbk_nb_high1[id*5+i]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
|
||||
{
|
||||
speex_error("Wideband and Ultra-wideband are disabled");
|
||||
}
|
||||
void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
|
||||
{
|
||||
speex_error("Wideband and Ultra-wideband are disabled");
|
||||
}
|
||||
#else
|
||||
extern const signed char high_lsp_cdbk[];
|
||||
extern const signed char high_lsp_cdbk2[];
|
||||
|
||||
|
||||
void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i;
|
||||
int id;
|
||||
spx_word16_t quant_weight[10];
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i];
|
||||
|
||||
compute_quant_weights(qlsp, quant_weight, order);
|
||||
|
||||
/* quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
|
||||
quant_weight[order-1] = 10/(qlsp[order-1]-qlsp[order-2]);
|
||||
for (i=1;i<order-1;i++)
|
||||
{
|
||||
tmp1 = 10/(qlsp[i]-qlsp[i-1]);
|
||||
tmp2 = 10/(qlsp[i+1]-qlsp[i]);
|
||||
quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
|
||||
}*/
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=SUB16(qlsp[i],LSP_LINEAR_HIGH(i));
|
||||
#ifndef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = qlsp[i]*LSP_SCALE;
|
||||
#endif
|
||||
id = lsp_quant(qlsp, high_lsp_cdbk, 64, order);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]*=2;
|
||||
|
||||
id = lsp_weight_quant(qlsp, quant_weight, high_lsp_cdbk2, 64, order);
|
||||
speex_bits_pack(bits, id, 6);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = PSHR16(qlsp[i],1);
|
||||
#else
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = qlsp[i]*0.0019531;
|
||||
#endif
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i]-qlsp[i];
|
||||
}
|
||||
|
||||
void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
|
||||
{
|
||||
|
||||
int i, id;
|
||||
for (i=0;i<order;i++)
|
||||
lsp[i]=LSP_LINEAR_HIGH(i);
|
||||
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<order;i++)
|
||||
lsp[i] += LSP_DIV_256(high_lsp_cdbk[id*order+i]);
|
||||
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 6);
|
||||
for (i=0;i<order;i++)
|
||||
lsp[i] += LSP_DIV_512(high_lsp_cdbk2[id*order+i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef EPIC_48K
|
||||
|
||||
extern const signed char cdbk_lsp_vlbr[5120];
|
||||
extern const signed char cdbk_lsp2_vlbr[160];
|
||||
|
||||
void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i;
|
||||
int id;
|
||||
spx_word16_t quant_weight[10];
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i];
|
||||
|
||||
compute_quant_weights(qlsp, quant_weight, order);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=SUB16(qlsp[i],LSP_SCALING*(.25*i+.3125));
|
||||
#ifndef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i] = qlsp[i]*LSP_SCALE;
|
||||
#endif
|
||||
|
||||
id = lsp_quant(qlsp, cdbk_lsp_vlbr, 512, order);
|
||||
speex_bits_pack(bits, id, 9);
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]*=4;
|
||||
|
||||
id = lsp_weight_quant(qlsp, quant_weight, cdbk_lsp2_vlbr, 16, 10);
|
||||
speex_bits_pack(bits, id, 4);
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=PSHR(qlsp[i],2);
|
||||
#else
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=qlsp[i]*0.00097655;
|
||||
#endif
|
||||
|
||||
for (i=0;i<order;i++)
|
||||
qlsp[i]=lsp[i]-qlsp[i];
|
||||
}
|
||||
|
||||
void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits)
|
||||
{
|
||||
int i, id;
|
||||
for (i=0;i<order;i++)
|
||||
lsp[i]=LSP_SCALING*(.25*i+.3125);
|
||||
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 9);
|
||||
for (i=0;i<10;i++)
|
||||
lsp[i] += LSP_SCALING*0.0039062*cdbk_lsp_vlbr[id*10+i];
|
||||
|
||||
id=speex_bits_unpack_unsigned(bits, 4);
|
||||
for (i=0;i<10;i++)
|
||||
lsp[i] += LSP_SCALING*0.00097655*cdbk_lsp2_vlbr[id*10+i];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,83 +0,0 @@
|
|||
/* Copyright (C) 2002 Jean-Marc Valin */
|
||||
/**
|
||||
@file quant_lsp.h
|
||||
@brief LSP vector quantization
|
||||
*/
|
||||
/*
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef QUANT_LSP_H
|
||||
#define QUANT_LSP_H
|
||||
|
||||
#include <speex/speex_bits.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define MAX_LSP_SIZE 20
|
||||
|
||||
#define NB_CDBK_SIZE 64
|
||||
#define NB_CDBK_SIZE_LOW1 64
|
||||
#define NB_CDBK_SIZE_LOW2 64
|
||||
#define NB_CDBK_SIZE_HIGH1 64
|
||||
#define NB_CDBK_SIZE_HIGH2 64
|
||||
|
||||
/*Narrowband codebooks*/
|
||||
extern const signed char cdbk_nb[];
|
||||
extern const signed char cdbk_nb_low1[];
|
||||
extern const signed char cdbk_nb_low2[];
|
||||
extern const signed char cdbk_nb_high1[];
|
||||
extern const signed char cdbk_nb_high2[];
|
||||
|
||||
/* Quantizes narrowband LSPs with 30 bits */
|
||||
void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
|
||||
|
||||
/* Decodes quantized narrowband LSPs */
|
||||
void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits);
|
||||
|
||||
/* Quantizes low bit-rate narrowband LSPs with 18 bits */
|
||||
void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
|
||||
|
||||
/* Decodes quantized low bit-rate narrowband LSPs */
|
||||
void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits);
|
||||
|
||||
/* Quantizes high-band LSPs with 12 bits */
|
||||
void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
|
||||
|
||||
/* Decodes high-band LSPs */
|
||||
void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits);
|
||||
|
||||
#ifdef EPIC_48K
|
||||
/* Quantizes narrowband LSPs with 14 bits */
|
||||
void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
|
||||
|
||||
/* Decodes quantized narrowband LSPs (14 bits) */
|
||||
void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue