git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10732 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West committed 2008-12-12 16:01:36 +00:00
1 parent c6be72ff0f
commit 1220bbcff2
104 files changed
+70864

No files matched your search

+147
View File
@@ -0,0 +1,147 @@
##
## g722_1 - a library for the ITU G.722.1 and Annex C codecs
##
## Makefile.am -- Process this file with automake to produce Makefile.in
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the Lesser GNU General Public License version 2.1, as
## published by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Id: Makefile.am,v 1.10 2008/10/16 15:46:12 steveu Exp $
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = g722_1/version.h.in \
libg722_1.dsp \
libg722_1.sln \
libg722_1.vcproj \
msvc/gettimeofday.c \
msvc/inttypes.h \
msvc/tgmath.h \
msvc/unistd.h \
msvc/sys/time.h \
msvc/g722_1.def \
msvc/msvcproj.head \
msvc/msvcproj.foot \
msvc/vc8proj.head \
msvc/vc8proj.foot
INCLUDES = -I$(top_builddir)
lib_LTLIBRARIES = libg722_1.la
libg722_1_la_SOURCES = basop32.c \
bitstream.c \
coef2sam.c \
common.c \
commonf.c \
dct4.c \
dct4_a.c \
dct4_s.c \
decoder.c \
decoderf.c \
encoder.c \
encoderf.c \
huff_tab.c \
sam2coef.c \
tables.c
libg722_1_la_LDFLAGS = -version-info @G722_1_LT_CURRENT@:@G722_1_LT_REVISION@:@G722_1_LT_AGE@ $(COMP_VENDOR_LDFLAGS)
nobase_include_HEADERS = g722_1/g722_1.h \
g722_1/version.h
nodist_include_HEADERS = g722_1.h
noinst_HEADERS = basop32.h \
bitstream.h \
coef2sam.h \
dct4.h \
dct4_a.h \
dct4_s.h \
defs.h \
huff_tab.h \
sam2coef.h \
tables.h
noinst_PROGRAMS = make_dct4_tables \
make_tables
dct4.$(OBJEXT): dct4.h
dct4.lo: dct4.h
dct4.h: make_dct4_tables$(EXEEXT)
./make_dct4_tables$(EXEEXT) >dct4.h
#coef2sam.h: make_tables$(EXEEXT)
# ./make_tables$(EXEEXT) coef2sam >coef2samx.h
#sam2coef.h: make_tables$(EXEEXT)
# ./make_tables$(EXEEXT) sam2coef >sam2coefx.h
DSP = libg722_1.dsp
VCPROJ = libg722_1.vcproj
WIN32SOURCES = $(libg722_1_la_SOURCES) msvc/gettimeofday.c
WIN32HEADERS = $(nobase_include_HEADERS) g722_1.h
DSPOUT = | awk '{printf("%s\r\n", $$0)}' >> $(DSP)
VCPROJOUT = | awk '{printf("%s\r\n", $$0)}' >> $(VCPROJ)
$(DSP): msvc/msvcproj.head msvc/msvcproj.foot Makefile.am
echo "creating $(DSP)"
@(cp $(srcdir)/msvc/msvcproj.head $(DSP); \
echo "# Begin Group \"Source Files\"" $(DSPOUT); \
for file in $(WIN32SOURCES); do \
echo "# Begin Source File" $(DSPOUT); \
echo "" $(DSPOUT); \
echo "SOURCE=.\\"$$file $(DSPOUT); \
echo "# End Source File" $(DSPOUT); \
done; \
echo "# End Group" $(DSPOUT); \
echo "# Begin Group \"Header Files\"" $(DSPOUT); \
for file in $(WIN32HEADERS); do \
echo "# Begin Source File" $(DSPOUT); \
echo "" $(DSPOUT); \
echo "SOURCE=.\\"$$file $(DSPOUT); \
echo "# End Source File" $(DSPOUT); \
done; \
echo "# End Group" $(DSPOUT); \
cat $(srcdir)/msvc/msvcproj.foot $(DSPOUT) )
$(VCPROJ): msvc/vc8proj.head msvc/vc8proj.foot Makefile.am
echo "creating $(VCPROJ)"
@(cp $(srcdir)/msvc/vc8proj.head $(VCPROJ); \
for file in $(WIN32SOURCES); do \
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \
done; \
echo "</Filter><Filter Name=\"Header Files\">" $(VCPROJOUT); \
for file in $(WIN32HEADERS); do \
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \
done; \
cat $(srcdir)/msvc/vc8proj.foot $(VCPROJOUT) )
g722_1/version.h:
NOWDATE=`date --utc +"%Y%m%d"` ; \
NOWTIME=`date --utc +"%H%M%S"` ; \
sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \
<g722_1/version.h.in >g722_1/version.h
dist-hook:
NOWDATE=`date --utc +"%Y%m%d"` ; \
NOWTIME=`date --utc +"%H%M%S"` ; \
sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \
<g722_1/version.h.in >g722_1/version.h
+727
View File
@@ -0,0 +1,727 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
noinst_PROGRAMS = make_dct4_tables$(EXEEXT) make_tables$(EXEEXT)
subdir = src
DIST_COMMON = $(nobase_include_HEADERS) $(noinst_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/g722_1.h.in $(top_srcdir)/config-h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/config/ax_compiler_vendor.m4 \
$(top_srcdir)/config/ax_check_real_file.m4 \
$(top_srcdir)/config/ax_fixed_point_machine.m4 \
$(top_srcdir)/config/ax_misaligned_access_fails.m4 \
$(top_srcdir)/config/ax_c99_features.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = g722_1.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" \
"$(DESTDIR)$(includedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libg722_1_la_LIBADD =
am_libg722_1_la_OBJECTS = basop32.lo bitstream.lo coef2sam.lo \
common.lo commonf.lo dct4.lo dct4_a.lo dct4_s.lo decoder.lo \
decoderf.lo encoder.lo encoderf.lo huff_tab.lo sam2coef.lo \
tables.lo
libg722_1_la_OBJECTS = $(am_libg722_1_la_OBJECTS)
PROGRAMS = $(noinst_PROGRAMS)
make_dct4_tables_SOURCES = make_dct4_tables.c
make_dct4_tables_OBJECTS = make_dct4_tables.$(OBJEXT)
make_dct4_tables_LDADD = $(LDADD)
make_tables_SOURCES = make_tables.c
make_tables_OBJECTS = make_tables.$(OBJEXT)
make_tables_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libg722_1_la_SOURCES) make_dct4_tables.c make_tables.c
DIST_SOURCES = $(libg722_1_la_SOURCES) make_dct4_tables.c \
make_tables.c
nobase_includeHEADERS_INSTALL = $(install_sh_DATA)
nodist_includeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(nobase_include_HEADERS) $(nodist_include_HEADERS) \
$(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
COMP_VENDOR_CFLAGS = @COMP_VENDOR_CFLAGS@
COMP_VENDOR_LDFLAGS = @COMP_VENDOR_LDFLAGS@
COND_DOC_FALSE = @COND_DOC_FALSE@
COND_DOC_TRUE = @COND_DOC_TRUE@
COND_MMX_FALSE = @COND_MMX_FALSE@
COND_MMX_TRUE = @COND_MMX_TRUE@
COND_SSE2_FALSE = @COND_SSE2_FALSE@
COND_SSE2_TRUE = @COND_SSE2_TRUE@
COND_SSE3_FALSE = @COND_SSE3_FALSE@
COND_SSE3_TRUE = @COND_SSE3_TRUE@
COND_SSE4A_FALSE = @COND_SSE4A_FALSE@
COND_SSE4A_TRUE = @COND_SSE4A_TRUE@
COND_SSE4_1_FALSE = @COND_SSE4_1_FALSE@
COND_SSE4_1_TRUE = @COND_SSE4_1_TRUE@
COND_SSE4_2_FALSE = @COND_SSE4_2_FALSE@
COND_SSE4_2_TRUE = @COND_SSE4_2_TRUE@
COND_SSE5_FALSE = @COND_SSE5_FALSE@
COND_SSE5_TRUE = @COND_SSE5_TRUE@
COND_SSE_FALSE = @COND_SSE_FALSE@
COND_SSE_TRUE = @COND_SSE_TRUE@
COND_TESTDATA_FALSE = @COND_TESTDATA_FALSE@
COND_TESTDATA_TRUE = @COND_TESTDATA_TRUE@
COND_TESTS_FALSE = @COND_TESTS_FALSE@
COND_TESTS_TRUE = @COND_TESTS_TRUE@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
G722_1_LT_AGE = @G722_1_LT_AGE@
G722_1_LT_CURRENT = @G722_1_LT_CURRENT@
G722_1_LT_REVISION = @G722_1_LT_REVISION@
G722_1_USE_FIXED_POINT = @G722_1_USE_FIXED_POINT@
G722_1_VECTORS_FOR_TESTS = @G722_1_VECTORS_FOR_TESTS@
GREP = @GREP@
INSERT_INTTYPES_HEADER = @INSERT_INTTYPES_HEADER@
INSERT_MATH_HEADER = @INSERT_MATH_HEADER@
INSERT_STDINT_HEADER = @INSERT_STDINT_HEADER@
INSERT_TGMATH_HEADER = @INSERT_TGMATH_HEADER@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
NMEDIT = @NMEDIT@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TESTLIBS = @TESTLIBS@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = g722_1/version.h.in \
libg722_1.dsp \
libg722_1.sln \
libg722_1.vcproj \
msvc/gettimeofday.c \
msvc/inttypes.h \
msvc/tgmath.h \
msvc/unistd.h \
msvc/sys/time.h \
msvc/g722_1.def \
msvc/msvcproj.head \
msvc/msvcproj.foot \
msvc/vc8proj.head \
msvc/vc8proj.foot
INCLUDES = -I$(top_builddir)
lib_LTLIBRARIES = libg722_1.la
libg722_1_la_SOURCES = basop32.c \
bitstream.c \
coef2sam.c \
common.c \
commonf.c \
dct4.c \
dct4_a.c \
dct4_s.c \
decoder.c \
decoderf.c \
encoder.c \
encoderf.c \
huff_tab.c \
sam2coef.c \
tables.c
libg722_1_la_LDFLAGS = -version-info @G722_1_LT_CURRENT@:@G722_1_LT_REVISION@:@G722_1_LT_AGE@ $(COMP_VENDOR_LDFLAGS)
nobase_include_HEADERS = g722_1/g722_1.h \
g722_1/version.h
nodist_include_HEADERS = g722_1.h
noinst_HEADERS = basop32.h \
bitstream.h \
coef2sam.h \
dct4.h \
dct4_a.h \
dct4_s.h \
defs.h \
huff_tab.h \
sam2coef.h \
tables.h
#coef2sam.h: make_tables$(EXEEXT)
# ./make_tables$(EXEEXT) coef2sam >coef2samx.h
#sam2coef.h: make_tables$(EXEEXT)
# ./make_tables$(EXEEXT) sam2coef >sam2coefx.h
DSP = libg722_1.dsp
VCPROJ = libg722_1.vcproj
WIN32SOURCES = $(libg722_1_la_SOURCES) msvc/gettimeofday.c
WIN32HEADERS = $(nobase_include_HEADERS) g722_1.h
DSPOUT = | awk '{printf("%s\r\n", $$0)}' >> $(DSP)
VCPROJOUT = | awk '{printf("%s\r\n", $$0)}' >> $(VCPROJ)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(top_srcdir)/config-h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status src/config.h
$(top_srcdir)/config-h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
g722_1.h: $(top_builddir)/config.status $(srcdir)/g722_1.h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libg722_1.la: $(libg722_1_la_OBJECTS) $(libg722_1_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libg722_1_la_LDFLAGS) $(libg722_1_la_OBJECTS) $(libg722_1_la_LIBADD) $(LIBS)
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
make_dct4_tables$(EXEEXT): $(make_dct4_tables_OBJECTS) $(make_dct4_tables_DEPENDENCIES)
@rm -f make_dct4_tables$(EXEEXT)
$(LINK) $(make_dct4_tables_LDFLAGS) $(make_dct4_tables_OBJECTS) $(make_dct4_tables_LDADD) $(LIBS)
make_tables$(EXEEXT): $(make_tables_OBJECTS) $(make_tables_DEPENDENCIES)
@rm -f make_tables$(EXEEXT)
$(LINK) $(make_tables_LDFLAGS) $(make_tables_OBJECTS) $(make_tables_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basop32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitstream.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coef2sam.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commonf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dct4.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dct4_a.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dct4_s.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decoder.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decoderf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoder.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoderf.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/huff_tab.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/make_dct4_tables.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/make_tables.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sam2coef.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tables.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-nobase_includeHEADERS: $(nobase_include_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)"
@$(am__vpath_adj_setup) \
list='$(nobase_include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
$(am__vpath_adj) \
echo " $(nobase_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
$(nobase_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
done
uninstall-nobase_includeHEADERS:
@$(NORMAL_UNINSTALL)
@$(am__vpath_adj_setup) \
list='$(nobase_include_HEADERS)'; for p in $$list; do \
$(am__vpath_adj) \
echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
rm -f "$(DESTDIR)$(includedir)/$$f"; \
done
install-nodist_includeHEADERS: $(nodist_include_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)"
@list='$(nodist_include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(nodist_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
$(nodist_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
done
uninstall-nodist_includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(nodist_include_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
rm -f "$(DESTDIR)$(includedir)/$$f"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(mkdir_p) $(distdir)/.. $(distdir)/g722_1 $(distdir)/msvc $(distdir)/msvc/sys
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) config.h
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-nobase_includeHEADERS \
install-nodist_includeHEADERS
install-exec-am: install-libLTLIBRARIES
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
uninstall-nobase_includeHEADERS \
uninstall-nodist_includeHEADERS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
dist-hook distclean distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-libLTLIBRARIES \
install-man install-nobase_includeHEADERS \
install-nodist_includeHEADERS install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS \
uninstall-nodist_includeHEADERS
dct4.$(OBJEXT): dct4.h
dct4.lo: dct4.h
dct4.h: make_dct4_tables$(EXEEXT)
./make_dct4_tables$(EXEEXT) >dct4.h
$(DSP): msvc/msvcproj.head msvc/msvcproj.foot Makefile.am
echo "creating $(DSP)"
@(cp $(srcdir)/msvc/msvcproj.head $(DSP); \
echo "# Begin Group \"Source Files\"" $(DSPOUT); \
for file in $(WIN32SOURCES); do \
echo "# Begin Source File" $(DSPOUT); \
echo "" $(DSPOUT); \
echo "SOURCE=.\\"$$file $(DSPOUT); \
echo "# End Source File" $(DSPOUT); \
done; \
echo "# End Group" $(DSPOUT); \
echo "# Begin Group \"Header Files\"" $(DSPOUT); \
for file in $(WIN32HEADERS); do \
echo "# Begin Source File" $(DSPOUT); \
echo "" $(DSPOUT); \
echo "SOURCE=.\\"$$file $(DSPOUT); \
echo "# End Source File" $(DSPOUT); \
done; \
echo "# End Group" $(DSPOUT); \
cat $(srcdir)/msvc/msvcproj.foot $(DSPOUT) )
$(VCPROJ): msvc/vc8proj.head msvc/vc8proj.foot Makefile.am
echo "creating $(VCPROJ)"
@(cp $(srcdir)/msvc/vc8proj.head $(VCPROJ); \
for file in $(WIN32SOURCES); do \
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \
done; \
echo "</Filter><Filter Name=\"Header Files\">" $(VCPROJOUT); \
for file in $(WIN32HEADERS); do \
echo "<File RelativePath=\""$$file"\"></File>" $(VCPROJOUT); \
done; \
cat $(srcdir)/msvc/vc8proj.foot $(VCPROJOUT) )
g722_1/version.h:
NOWDATE=`date --utc +"%Y%m%d"` ; \
NOWTIME=`date --utc +"%H%M%S"` ; \
sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \
<g722_1/version.h.in >g722_1/version.h
dist-hook:
NOWDATE=`date --utc +"%Y%m%d"` ; \
NOWTIME=`date --utc +"%H%M%S"` ; \
sed 's/$$G722_1_RELEASE_DATE/'$$NOWDATE'/;s/$$G722_1_RELEASE_TIME/'$$NOWTIME'/' \
<g722_1/version.h.in >g722_1/version.h
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+190
View File
@@ -0,0 +1,190 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* basop32.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: basop32.c,v 1.5 2008/09/22 13:08:31 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#if defined(G722_1_USE_FIXED_POINT)
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include "basop32.h"
int16_t shl(int16_t var1, int16_t var2)
{
int32_t result;
if (var2 < 0)
{
if (var2 < -16)
var2 = -16;
return shr(var1, (int16_t) -var2);
}
result = (int32_t) var1*((int32_t) 1 << var2);
if ((var2 > 15 && var1 != 0) || (result != (int32_t) ((int16_t) result)))
return (var1 > 0) ? INT16_MAX : INT16_MIN;
return (int16_t) result;
}
/*- End of function --------------------------------------------------------*/
int16_t shr(int16_t var1, int16_t var2)
{
if (var2 < 0)
{
if (var2 < -16)
var2 = -16;
return shl(var1, (int16_t) -var2);
}
if (var2 >= 15)
return (var1 < 0) ? -1 : 0;
if (var1 < 0)
return ~((~var1) >> var2);
return var1 >> var2;
}
/*- End of function --------------------------------------------------------*/
int32_t L_add(int32_t L_var1, int32_t L_var2)
{
int32_t L_var_out;
L_var_out = L_var1 + L_var2;
if (((L_var1 ^ L_var2) & INT32_MIN) == 0)
{
if ((L_var_out ^ L_var1) & INT32_MIN)
return (L_var1 < 0) ? INT32_MIN : INT32_MAX;
}
return L_var_out;
}
/*- End of function --------------------------------------------------------*/
int32_t L_sub(int32_t L_var1, int32_t L_var2)
{
int32_t L_var_out;
L_var_out = L_var1 - L_var2;
if (((L_var1 ^ L_var2) & INT32_MIN) != 0)
{
if ((L_var_out ^ L_var1) & INT32_MIN)
return (L_var1 < 0L) ? INT32_MIN : INT32_MAX;
}
return L_var_out;
}
/*- End of function --------------------------------------------------------*/
int32_t L_shl(int32_t L_var1, int16_t var2)
{
if (var2 <= 0)
{
if (var2 < -32)
var2 = -32;
return L_shr(L_var1, -var2);
}
for ( ; var2 > 0; var2--)
{
if (L_var1 > (int32_t) 0X3fffffffL)
return INT32_MAX;
if (L_var1 < (int32_t) 0xc0000000L)
return INT32_MIN;
L_var1 *= 2;
}
return L_var1;
}
/*- End of function --------------------------------------------------------*/
int32_t L_shr(int32_t L_var1, int16_t var2)
{
if (var2 < 0)
{
if (var2 < -32)
var2 = -32;
return L_shl(L_var1, (int16_t) -var2);
}
if (var2 >= 31)
return (L_var1 < 0L) ? -1 : 0;
if (L_var1 < 0)
return ~((~L_var1) >> var2);
return L_var1 >> var2;
}
/*- End of function --------------------------------------------------------*/
/*! \brief Find the bit position of the highest set bit in a word
\param bits The word to be searched
\return The bit number of the highest set bit, or -1 if the word is zero. */
static __inline__ int top_bit(unsigned int bits)
{
int res;
#if defined(__i386__) || defined(__x86_64__)
__asm__ (" xorl %[res],%[res];\n"
" decl %[res];\n"
" bsrl %[bits],%[res]\n"
: [res] "=&r" (res)
: [bits] "rm" (bits));
return res;
#elif defined(__ppc__) || defined(__powerpc__)
__asm__ ("cntlzw %[res],%[bits];\n"
: [res] "=&r" (res)
: [bits] "r" (bits));
return 31 - res;
#else
if (bits == 0)
return -1;
res = 0;
if (bits & 0xFFFF0000)
{
bits &= 0xFFFF0000;
res += 16;
}
if (bits & 0xFF00FF00)
{
bits &= 0xFF00FF00;
res += 8;
}
if (bits & 0xF0F0F0F0)
{
bits &= 0xF0F0F0F0;
res += 4;
}
if (bits & 0xCCCCCCCC)
{
bits &= 0xCCCCCCCC;
res += 2;
}
if (bits & 0xAAAAAAAA)
{
bits &= 0xAAAAAAAA;
res += 1;
}
return res;
#endif
}
/*- End of function --------------------------------------------------------*/
int16_t norm_s(int16_t var1)
{
if (var1 == 0)
return 0;
if (var1 < 0)
var1 = ~var1;
return (14 - top_bit(var1));
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+118
View File
@@ -0,0 +1,118 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* basops32.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: basop32.h,v 1.3 2008/09/22 13:08:31 steveu Exp $
*/
#if !defined(BASOP32_H_DEFINED)
#define BASOP32_H_DEFINED
int32_t L_add(int32_t L_var1, int32_t L_var2);
static __inline__ int16_t saturate(int32_t amp)
{
int16_t amp16;
/* Hopefully this is optimised for the common case - not clipping */
amp16 = (int16_t) amp;
if (amp == amp16)
return amp16;
if (amp > INT16_MAX)
return INT16_MAX;
return INT16_MIN;
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t xround(int32_t L_var1)
{
return (int16_t) (L_add(L_var1, (int32_t) 0x00008000L) >> 16);
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t abs_s(int16_t var1)
{
if (var1 == INT16_MIN)
return INT16_MAX;
return abs(var1);
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t add(int16_t var1, int16_t var2)
{
return saturate((int32_t) var1 + var2);
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t sub(int16_t var1, int16_t var2)
{
return saturate((int32_t) var1 - var2);
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t mult(int16_t var1, int16_t var2)
{
return saturate(((int32_t) var1*(int32_t) var2) >> 15);
}
/*- End of function --------------------------------------------------------*/
static __inline__ int32_t L_mult0(int16_t var1, int16_t var2)
{
return (int32_t) var1*(int32_t) var2;
}
/*- End of function --------------------------------------------------------*/
static __inline__ int32_t L_mac0(int32_t L_var3, int16_t var1, int16_t var2)
{
return L_add(L_var3, L_mult0(var1, var2));
}
/*- End of function --------------------------------------------------------*/
static __inline__ int32_t L_mult(int16_t var1, int16_t var2)
{
int32_t L_var_out;
L_var_out = (int32_t) var1*(int32_t) var2;
if (L_var_out == (int32_t) 0x40000000L)
return INT32_MAX;
return L_var_out << 1;
}
/*- End of function --------------------------------------------------------*/
static __inline__ int16_t negate(int16_t var1)
{
if (var1 == INT16_MIN)
return INT16_MAX;
return -var1;
}
/*- End of function --------------------------------------------------------*/
static __inline__ int32_t L_mac(int32_t L_var3, int16_t var1, int16_t var2)
{
return L_add(L_var3, L_mult(var1, var2));
}
/*- End of function --------------------------------------------------------*/
int16_t shl(int16_t var1, int16_t var2); /* Short shift left, 1 */
int16_t shr(int16_t var1, int16_t var2); /* Short shift right, 1 */
int32_t L_sub(int32_t L_var1, int32_t L_var2); /* Long sub, 2 */
int32_t L_shl(int32_t L_var1, int16_t var2); /* Long shift left, 2 */
int32_t L_shr(int32_t L_var1, int16_t var2); /* Long shift right, 2*/
int16_t norm_s(int16_t var1); /* Short norm, 15 */
int16_t div_s(int16_t var1, int16_t var2); /* Short division, 18 */
int16_t norm_l(int32_t L_var1); /* Long norm, 30 */
#endif
/*- End of file ------------------------------------------------------------*/
+113
View File
@@ -0,0 +1,113 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* bitstream.c
*
* Copyright (C) 2006 Steve Underwood
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: bitstream.c,v 1.2 2008/10/17 13:18:21 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "g722_1/g722_1.h"
#include "bitstream.h"
void g722_1_bitstream_put(g722_1_bitstream_state_t *s, uint8_t **c, uint32_t value, int bits)
{
if (bits < 32)
value &= ((1 << bits) - 1);
if (bits > 24)
{
/* We can't deal with this many bits in one go. Split up the operation */
bits -= 8;
s->bitstream = (s->bitstream << bits) | (value >> 8);
s->residue += bits;
while (s->residue >= 8)
{
s->residue -= 8;
*(*c)++ = (uint8_t) ((s->bitstream >> s->residue) & 0xFF);
}
bits = 8;
value &= 0xFF;
}
s->bitstream = (s->bitstream << bits) | value;
s->residue += bits;
while (s->residue >= 8)
{
s->residue -= 8;
*(*c)++ = (uint8_t) ((s->bitstream >> s->residue) & 0xFF);
}
}
/*- End of function --------------------------------------------------------*/
uint32_t g722_1_bitstream_get(g722_1_bitstream_state_t *s, const uint8_t **c, int bits)
{
uint32_t x;
if (bits > 24)
{
/* We can't deal with this many bits in one go. Split up the operation */
while (s->residue < 24)
{
s->bitstream = (s->bitstream << 8) | ((uint32_t) *(*c)++);
s->residue += 8;
}
s->residue -= 24;
bits -= 24;
x = ((s->bitstream >> s->residue) & 0xFFFFFF) << bits;
while (s->residue < bits)
{
s->bitstream = (s->bitstream << 8) | ((uint32_t) *(*c)++);
s->residue += 8;
}
s->residue -= bits;
x |= (s->bitstream >> s->residue) & ((1 << bits) - 1);
}
else
{
while (s->residue < bits)
{
s->bitstream = (s->bitstream << 8) | ((uint32_t) *(*c)++);
s->residue += 8;
}
s->residue -= bits;
x = (s->bitstream >> s->residue) & ((1 << bits) - 1);
}
return x;
}
/*- End of function --------------------------------------------------------*/
void g722_1_bitstream_flush(g722_1_bitstream_state_t *s, uint8_t **c)
{
if (s->residue > 0)
{
*(*c)++ = (uint8_t) ((s->bitstream << (8 - s->residue)) & 0xFF);
s->residue = 0;
}
}
/*- End of function --------------------------------------------------------*/
g722_1_bitstream_state_t *g722_1_bitstream_init(g722_1_bitstream_state_t *s)
{
if (s == NULL)
return NULL;
s->bitstream = 0;
s->residue = 0;
return s;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+65
View File
@@ -0,0 +1,65 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* bitstream.h
*
* Copyright (C) 2006 Steve Underwood
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: bitstream.h,v 1.2 2008/10/17 13:18:21 steveu Exp $
*/
/*! \file */
#if !defined(_G722_1_BITSTREAM_H_)
#define _G722_1_BITSTREAM_H_
#if 0
/*! Bitstream handler state */
typedef struct
{
/*! The bit stream. */
uint32_t bitstream;
/*! The residual bits in bitstream. */
int residue;
} g722_1_bitstream_state_t;
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
/*! \brief Put a chunk of bits into the output buffer.
\param s A pointer to the bitstream context.
\param c A pointer to the bitstream output buffer.
\param value The value to be pushed into the output buffer.
\param bits The number of bits of value to be pushed. 1 to 32 bits is valid. */
void g722_1_bitstream_put(g722_1_bitstream_state_t *s, uint8_t **c, uint32_t value, int bits);
/*! \brief Get a chunk of bits from the input buffer.
\param s A pointer to the bitstream context.
\param c A pointer to the bitstream input buffer.
\param bits The number of bits of value to be grabbed. 1 to 32 bits is valid.
\return The value retrieved from the input buffer. */
uint32_t g722_1_bitstream_get(g722_1_bitstream_state_t *s, const uint8_t **c, int bits);
/*! \brief Flush any residual bit to the output buffer.
\param s A pointer to the bitstream context.
\param c A pointer to the bitstream output buffer. */
void g722_1_bitstream_flush(g722_1_bitstream_state_t *s, uint8_t **c);
/*! \brief Initialise a bitstream context.
\param s A pointer to the bitstream context.
\return A pointer to the bitstream context. */
g722_1_bitstream_state_t *g722_1_bitstream_init(g722_1_bitstream_state_t *s);
#if defined(__cplusplus)
}
#endif
#endif
/*- End of file ------------------------------------------------------------*/
+143
View File
@@ -0,0 +1,143 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* coef2sam.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: coef2sam.c,v 1.10 2008/10/02 11:43:54 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "coef2sam.h"
/*************************************************************************************
Purpose: Convert Reversed MLT (Modulated Lapped Transform) Coefficients to Samples
The "Reversed MLT" is an overlapped block transform which uses even symmetry
on the left, odd symmetry on the right and a Type IV DCT as the block transform.
It is thus similar to a MLT which uses odd symmetry on the left, even symmetry
on the right and a Type IV DST as the block transform. In fact, it is equivalent
to reversing the order of the samples, performing an MLT and then negating all
the even-numbered coefficients.
***************************************************************************/
#if defined(G722_1_USE_FIXED_POINT)
void rmlt_coefs_to_samples(int16_t coefs[],
int16_t old_samples[],
int16_t out_samples[],
int dct_length,
int16_t mag_shift)
{
int i;
int half_dct_length;
int last;
int16_t new_samples[MAX_DCT_LENGTH];
const int16_t *win;
int32_t sum;
half_dct_length = dct_length >> 1;
/* Perform a Type IV (inverse) DCT on the coefficients */
dct_type_iv_s(coefs, new_samples, dct_length);
if (mag_shift > 0)
{
for (i = 0; i < dct_length; i++)
new_samples[i] = shr(new_samples[i], mag_shift);
}
else if (mag_shift < 0)
{
mag_shift = negate(mag_shift);
for (i = 0; i < dct_length; i++)
new_samples[i] = shl(new_samples[i], mag_shift);
}
if (dct_length == DCT_LENGTH)
win = rmlt_to_samples_window;
else
win = max_rmlt_to_samples_window;
last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
/* Get the first half of the windowed samples */
sum = 0L;
sum = L_mac(sum, win[i], new_samples[last - i]);
sum = L_mac(sum, win[dct_length - i - 1], old_samples[i]);
out_samples[i] = xround(L_shl(sum, 2));
/* Get the second half of the windowed samples */
sum = 0L;
sum = L_mac(sum, win[half_dct_length + i], new_samples[i]);
sum = L_mac(sum, negate(win[last - i]), old_samples[last - i]);
out_samples[half_dct_length + i] = xround(L_shl(sum, 2));
}
/* Save the second half of the new samples for
next time, when they will be the old samples. */
for (i = 0; i < half_dct_length; i++)
old_samples[i] = new_samples[half_dct_length + i];
}
/*- End of function --------------------------------------------------------*/
#else
void rmlt_coefs_to_samples(float coefs[],
float old_samples[],
float out_samples[],
int dct_length)
{
int i;
int half_dct_length;
int last;
float new_samples[MAX_DCT_LENGTH];
const float *win;
float sum;
half_dct_length = dct_length >> 1;
/* Perform a Type IV (inverse) DCT on the coefficients */
dct_type_iv(coefs, new_samples, dct_length);
if (dct_length == DCT_LENGTH)
win = rmlt_to_samples_window;
else
win = max_rmlt_to_samples_window;
last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
/* Get the first half of the windowed samples */
sum = win[i]*new_samples[last - i];
sum += win[dct_length - i - 1]*old_samples[i];
out_samples[i] = sum;
/* Get the second half of the windowed samples */
sum = win[half_dct_length + i]*new_samples[i];
sum -= win[last - i]*old_samples[last - i];
out_samples[half_dct_length + i] = sum;
}
/* Save the second half of the new samples for next time, when they will
be the old samples. */
for (i = 0; i < half_dct_length; i++)
old_samples[i] = new_samples[half_dct_length + i];
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
File diff suppressed because it is too large. Load diff
+420
View File
@@ -0,0 +1,420 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* common.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: common.c,v 1.6 2008/09/30 14:06:39 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "huff_tab.h"
#include "tables.h"
#if defined(G722_1_USE_FIXED_POINT)
static void compute_raw_pow_categories(int16_t *power_categories,
int16_t *rms_index,
int16_t number_of_regions,
int16_t offset);
/****************************************************************************************
Function: categorize
Syntax: void categorize(int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t rms_index,
int16_t power_categories,
int16_t category_balances)
inputs: number_of_regions
num_categorization_control_possibilities
number_of_available_bits
rms_index[MAX_NUMBER_OF_REGIONS]
outputs: power_categories[MAX_NUMBER_OF_REGIONS]
category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES-1]
Description: Computes a series of categorizations
WMOPS: 7kHz | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.14 | 0.14
-------|--------------|----------------
MAX | 0.15 | 0.15
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.42 | 0.45 | 0.48
-------|--------------|----------------|----------------
MAX | 0.47 | 0.52 | 0.52
-------|--------------|----------------|----------------
****************************************************************************************/
void categorize(int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t *rms_index,
int16_t *power_categories,
int16_t *category_balances)
{
int16_t offset;
int16_t temp;
int16_t frame_size;
/* At higher bit rates, there is an increase for most categories in average bit
consumption per region. We compensate for this by pretending we have fewer
available bits. */
if (number_of_regions == NUMBER_OF_REGIONS)
frame_size = DCT_LENGTH;
else
frame_size = MAX_DCT_LENGTH;
temp = sub(number_of_available_bits, frame_size);
if (temp > 0)
{
number_of_available_bits = sub(number_of_available_bits, frame_size);
number_of_available_bits = (int16_t) L_mult0(number_of_available_bits, 5);
number_of_available_bits = shr(number_of_available_bits, 3);
number_of_available_bits = add(number_of_available_bits, frame_size);
}
/* calculate the offset using the original category assignments */
offset = calc_offset(rms_index, number_of_regions, number_of_available_bits);
/* compute the power categories based on the uniform offset */
compute_raw_pow_categories(power_categories, rms_index, number_of_regions,offset);
/* adjust the category assignments */
/* compute the new power categories and category balances */
comp_powercat_and_catbalance(power_categories ,category_balances, rms_index, number_of_available_bits, number_of_regions, num_categorization_control_possibilities, offset);
}
/*- End of function --------------------------------------------------------*/
/***************************************************************************
Function: comp_powercat_and_catbalance
Syntax: void comp_powercat_and_catbalance(int16_t *power_categories,
int16_t *category_balances,
int16_t *rms_index,
int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t offset)
inputs: *rms_index
number_of_available_bits
number_of_regions
num_categorization_control_possibilities
offset
outputs: *power_categories
*category_balances
Description: Computes the power_categories and the category balances
WMOPS: 7kHz | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.10 | 0.10
-------|--------------|----------------
MAX | 0.11 | 0.11
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.32 | 0.35 | 0.38
-------|--------------|----------------|----------------
MAX | 0.38 | 0.42 | 0.43
-------|--------------|----------------|----------------
***************************************************************************/
void comp_powercat_and_catbalance(int16_t *power_categories,
int16_t *category_balances,
int16_t *rms_index,
int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t offset)
{
int16_t expected_number_of_code_bits;
int16_t region;
int16_t max_region;
int16_t j;
int16_t max_rate_categories[MAX_NUMBER_OF_REGIONS];
int16_t min_rate_categories[MAX_NUMBER_OF_REGIONS];
int16_t temp_category_balances[2*MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES];
int16_t raw_max;
int16_t raw_min;
int16_t raw_max_index;
int16_t raw_min_index;
int16_t max_rate_pointer;
int16_t min_rate_pointer;
int16_t max;
int16_t min;
int16_t itemp0;
int16_t itemp1;
int16_t min_plus_max;
int16_t two_x_number_of_available_bits;
int16_t temp;
expected_number_of_code_bits = 0;
raw_max_index = 0;
raw_min_index = 0;
for (region = 0; region < number_of_regions; region++)
expected_number_of_code_bits = add(expected_number_of_code_bits, expected_bits_table[power_categories[region]]);
for (region = 0; region < number_of_regions; region++)
{
max_rate_categories[region] = power_categories[region];
min_rate_categories[region] = power_categories[region];
}
max = expected_number_of_code_bits;
min = expected_number_of_code_bits;
max_rate_pointer = num_categorization_control_possibilities;
min_rate_pointer = num_categorization_control_possibilities;
for (j = 0; j < num_categorization_control_possibilities - 1; j++)
{
min_plus_max = add(max, min);
two_x_number_of_available_bits = shl(number_of_available_bits, 1);
temp = sub(min_plus_max, two_x_number_of_available_bits);
if (temp <= 0)
{
raw_min = 99;
/* Search from lowest freq regions to highest for best */
/* region to reassign to a higher bit rate category. */
for (region = 0; region < number_of_regions; region++)
{
if (max_rate_categories[region] > 0)
{
itemp0 = shl(max_rate_categories[region], 1);
itemp1 = sub(offset, rms_index[region]);
itemp0 = sub(itemp1, itemp0);
temp = sub(itemp0, raw_min);
if (temp < 0)
{
raw_min = itemp0;
raw_min_index = region;
}
}
}
max_rate_pointer = sub(max_rate_pointer, 1);
temp_category_balances[max_rate_pointer] = raw_min_index;
max = sub(max,expected_bits_table[max_rate_categories[raw_min_index]]);
max_rate_categories[raw_min_index] = sub(max_rate_categories[raw_min_index], 1);
max = add(max,expected_bits_table[max_rate_categories[raw_min_index]]);
}
else
{
raw_max = -99;
/* Search from highest freq regions to lowest for best region to reassign to
a lower bit rate category. */
max_region = sub(number_of_regions, 1);
for (region = max_region; region >= 0; region--)
{
temp = sub(min_rate_categories[region], (NUM_CATEGORIES - 1));
if (temp < 0)
{
itemp0 = shl(min_rate_categories[region], 1);
itemp1 = sub(offset, rms_index[region]);
itemp0 = sub(itemp1, itemp0);
temp = sub(itemp0, raw_max);
if (temp > 0)
{
raw_max = itemp0;
raw_max_index = region;
}
}
}
temp_category_balances[min_rate_pointer] = raw_max_index;
min_rate_pointer = add(min_rate_pointer, 1);
min = sub(min, expected_bits_table[min_rate_categories[raw_max_index]]);
min_rate_categories[raw_max_index] = add(min_rate_categories[raw_max_index], 1);
min = add(min, expected_bits_table[min_rate_categories[raw_max_index]]);
}
}
for (region = 0; region < number_of_regions; region++)
power_categories[region] = max_rate_categories[region];
for (j = 0; j < num_categorization_control_possibilities - 1; j++)
category_balances[j] = temp_category_balances[max_rate_pointer++];
}
/*- End of function --------------------------------------------------------*/
/***************************************************************************
Function: calc_offset
Syntax: offset=calc_offset(int16_t *rms_index,int16_t number_of_regions,int16_t available_bits)
input: int16_t *rms_index
int16_t number_of_regions
int16_t available_bits
output: int16_t offset
Description: Calculates the the category offset. This is the shift required
To get the most out of the number of available bits. A binary
type search is used to find the offset.
WMOPS: 7kHz | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.04 | 0.04
-------|--------------|----------------
MAX | 0.04 | 0.04
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.08 | 0.08 | 0.08
-------|--------------|----------------|----------------
MAX | 0.09 | 0.09 | 0.09
-------|--------------|----------------|----------------
***************************************************************************/
int16_t calc_offset(int16_t *rms_index,int16_t number_of_regions,int16_t available_bits)
{
int16_t answer;
int16_t delta;
int16_t test_offset;
int16_t region,j;
int16_t power_cats[MAX_NUMBER_OF_REGIONS];
int16_t bits;
int16_t offset;
int16_t temp;
/* initialize vars */
answer = -32;
delta = 32;
do
{
test_offset = add(answer, delta);
/* obtain a category for each region */
/* using the test offset */
for (region = 0; region < number_of_regions; region++)
{
j = sub(test_offset, rms_index[region]);
j = shr(j, 1);
/* Ensure j is between 0 and NUM_CAT-1 */
if (j < 0)
j = 0;
temp = sub(j, NUM_CATEGORIES - 1);
if (temp > 0)
j = sub(NUM_CATEGORIES, 1);
power_cats[region] = j;
}
bits = 0;
/* compute the number of bits that will be used given the cat assignments */
for (region = 0; region < number_of_regions; region++)
bits = add(bits, expected_bits_table[power_cats[region]]);
/* If (bits > available_bits - 32) then divide the offset region for the bin search */
offset = sub(available_bits, 32);
temp = sub(bits, offset);
if (temp >= 0)
answer = test_offset;
delta = shr(delta, 1);
}
while (delta > 0);
return answer;
}
/*- End of function --------------------------------------------------------*/
/***************************************************************************
Function: compute_raw_pow_categories
Syntax: void compute_raw_pow_categories(int16_t *power_categories,
int16_t *rms_index,
int16_t number_of_regions,
int16_t offset)
inputs: *rms_index
number_of_regions
offset
outputs: *power_categories
Description: This function computes the power categories given the offset
This is kind of redundant since they were already computed
in calc_offset to determine the offset.
WMOPS: | 24kbit | 32kbit
-------|--------------|----------------
AVG | 0.01 | 0.01
-------|--------------|----------------
MAX | 0.01 | 0.01
-------|--------------|----------------
14kHz | 24kbit | 32kbit | 48kbit
-------|--------------|----------------|----------------
AVG | 0.01 | 0.01 | 0.01
-------|--------------|----------------|----------------
MAX | 0.01 | 0.01 | 0.01
-------|--------------|----------------|----------------
***************************************************************************/
static void compute_raw_pow_categories(int16_t *power_categories, int16_t *rms_index, int16_t number_of_regions, int16_t offset)
{
int16_t region;
int16_t j;
int16_t temp;
for (region = 0; region < number_of_regions; region++)
{
j = sub(offset, rms_index[region]);
j = shr(j, 1);
/* make sure j is between 0 and NUM_CAT-1 */
if (j < 0)
j = 0;
temp = sub(j, (NUM_CATEGORIES - 1));
if (temp > 0)
j = sub(NUM_CATEGORIES, 1);
power_categories[region] = j;
}
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+199
View File
@@ -0,0 +1,199 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* commonf.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: commonf.c,v 1.11 2008/09/30 14:06:39 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <math.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "tables.h"
#include "huff_tab.h"
#if !defined(G722_1_USE_FIXED_POINT)
/****************************************************************************************
Description: Computes a series of categorizations
****************************************************************************************/
void categorize(int number_of_regions,
int number_of_available_bits,
int rms_index[MAX_NUMBER_OF_REGIONS],
int power_categories[MAX_NUMBER_OF_REGIONS],
int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1])
{
int region;
int i;
int expected_number_of_code_bits;
int delta;
int offset;
int test_offset;
int num_categorization_control_possibilities;
int max_rate_categories[MAX_NUMBER_OF_REGIONS];
int min_rate_categories[MAX_NUMBER_OF_REGIONS];
int temp_category_balances[2*MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES];
int raw_max;
int raw_min;
int raw_max_index;
int raw_min_index;
int max_rate_pointer;
int min_rate_pointer;
int max;
int min;
int itemp0;
if (number_of_regions == NUMBER_OF_REGIONS)
num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
else
num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
/* At higher bit rates, there is an increase for most categories in average bit
consumption per region. We compensate for this by pretending we have fewer
available bits.
*/
if (number_of_regions == NUMBER_OF_REGIONS)
{
if (number_of_available_bits > FRAME_SIZE)
number_of_available_bits = FRAME_SIZE + (((number_of_available_bits - FRAME_SIZE)*5) >> 3);
}
else if (number_of_regions == MAX_NUMBER_OF_REGIONS)
{
if (number_of_available_bits > MAX_FRAME_SIZE)
number_of_available_bits = MAX_FRAME_SIZE + (((number_of_available_bits - MAX_FRAME_SIZE)*5) >> 3);
}
offset = -32;
delta = 32;
do
{
test_offset = offset + delta;
for (region = 0; region < number_of_regions; region++)
{
i = (test_offset - rms_index[region]) >> 1;
if (i < 0)
i = 0;
else if (i > NUM_CATEGORIES - 1)
i = NUM_CATEGORIES - 1;
power_categories[region] = i;
}
expected_number_of_code_bits = 0;
for (region = 0; region < number_of_regions; region++)
expected_number_of_code_bits += expected_bits_table[power_categories[region]];
if (expected_number_of_code_bits >= number_of_available_bits - 32)
offset = test_offset;
delta >>= 1;
}
while (delta > 0);
for (region = 0; region < number_of_regions; region++)
{
i = (offset - rms_index[region]) >> 1;
if (i < 0)
i = 0;
else if (i > NUM_CATEGORIES - 1)
i = NUM_CATEGORIES - 1;
power_categories[region] = i;
}
expected_number_of_code_bits = 0;
for (region = 0; region < number_of_regions; region++)
expected_number_of_code_bits += expected_bits_table[power_categories[region]];
for (region = 0; region < number_of_regions; region++)
{
max_rate_categories[region] = power_categories[region];
min_rate_categories[region] = power_categories[region];
}
max = expected_number_of_code_bits;
min = expected_number_of_code_bits;
max_rate_pointer = num_categorization_control_possibilities;
min_rate_pointer = num_categorization_control_possibilities;
raw_min_index = 0;
raw_max_index = 0;
for (i = 0; i < num_categorization_control_possibilities - 1; i++)
{
if (max + min <= 2*number_of_available_bits)
{
raw_min = 99;
/* Search from lowest freq regions to highest for best region to reassign to
a higher bit rate category. */
for (region = 0; region < number_of_regions; region++)
{
if (max_rate_categories[region] > 0)
{
itemp0 = offset - rms_index[region] - 2*max_rate_categories[region];
if (itemp0 < raw_min)
{
raw_min = itemp0;
raw_min_index = region;
}
}
}
max_rate_pointer--;
temp_category_balances[max_rate_pointer] = raw_min_index;
max -= expected_bits_table[max_rate_categories[raw_min_index]];
max_rate_categories[raw_min_index] -= 1;
max += expected_bits_table[max_rate_categories[raw_min_index]];
}
else
{
raw_max = -99;
/* Search from highest freq regions to lowest for best region to reassign to
a lower bit rate category. */
for (region = number_of_regions - 1; region >= 0; region--)
{
if (min_rate_categories[region] < NUM_CATEGORIES - 1)
{
itemp0 = offset - rms_index[region] - 2*min_rate_categories[region];
if (itemp0 > raw_max)
{
raw_max = itemp0;
raw_max_index = region;
}
}
}
temp_category_balances[min_rate_pointer] = raw_max_index;
min_rate_pointer++;
min -= expected_bits_table[min_rate_categories[raw_max_index]];
min_rate_categories[raw_max_index]++;
min += expected_bits_table[min_rate_categories[raw_max_index]];
}
}
for (i = 0; i < number_of_regions; i++)
power_categories[i] = max_rate_categories[i];
for (i = 0; i < num_categorization_control_possibilities - 1; i++)
category_balances[i] = temp_category_balances[max_rate_pointer++];
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+220
View File
@@ -0,0 +1,220 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* dct4.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4.c,v 1.8 2008/09/29 16:09:26 steveu Exp $
*/
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <memory.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#if !defined(G722_1_USE_FIXED_POINT)
typedef struct
{
float cosine;
float minus_sine;
} cos_msin_t;
#include "dct4.h"
static const cos_msin_t *cos_msin_table[] =
{
cos_msin_5,
cos_msin_10,
cos_msin_20,
cos_msin_40,
cos_msin_80,
cos_msin_160,
cos_msin_320,
cos_msin_640
};
/*********************************************************************************
Description: Discrete Cosine Transform, Type IV
*********************************************************************************/
void dct_type_iv(float input[], float output[], int dct_length)
{
float buffer_a[MAX_DCT_LENGTH];
float buffer_b[MAX_DCT_LENGTH];
float buffer_c[MAX_DCT_LENGTH];
float *in_ptr;
float *in_ptr_low;
float *in_ptr_high;
float *next_in_base;
float *out_ptr_low;
float *out_ptr_high;
float *next_out_base;
float *out_buffer;
float *in_buffer;
float *buffer_swap;
float *fptr0;
const float *fptr2;
const float *core_a;
float in_val_low;
float in_val_high;
float cos_even;
float cos_odd;
float msin_even;
float msin_odd;
float sum;
const cos_msin_t **table_ptr_ptr;
const cos_msin_t *cos_msin_ptr;
int set_span;
int set_count;
int set_count_log;
int pairs_left;
int sets_left;
int i;
int k;
int dct_length_log;
if (dct_length == MAX_DCT_LENGTH)
{
core_a = max_dct_core_a;
dct_length_log = MAX_DCT_LENGTH_LOG;
}
else
{
core_a = dct_core_a;
dct_length_log = DCT_LENGTH_LOG;
}
/* Do the sum/difference butterflies, the first part of
converting one N-point transform into N/2 two-point
transforms, where N = 1 << dct_length_log. */
in_buffer = input;
out_buffer = buffer_a;
for (set_count_log = 0; set_count_log <= dct_length_log - 2; set_count_log++)
{
/* Initialization for the loop over sets at the current size */
set_span = dct_length >> set_count_log;
set_count = 1 << set_count_log;
in_ptr = in_buffer;
next_out_base = out_buffer;
/* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up output pointers for the current set */
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
/* Loop over all the butterflies in the current set */
do
{
in_val_low = *in_ptr++;
in_val_high = *in_ptr++;
*out_ptr_low++ = in_val_low + in_val_high;
*--out_ptr_high = in_val_low - in_val_high;
}
while (out_ptr_low < out_ptr_high);
}
/* Decide which buffers to use as input and output next time.
Except for the first time (when the input buffer is the
subroutine input) we just alternate the local buffers. */
in_buffer = out_buffer;
if (out_buffer == buffer_a)
out_buffer = buffer_b;
else
out_buffer = buffer_a;
}
/* Do dct_size/10 ten-point transforms */
fptr0 = in_buffer;
buffer_swap = buffer_c;
for (pairs_left = 1 << (dct_length_log - 1); pairs_left > 0; pairs_left--)
{
fptr2 = core_a;
for (k = 0; k < CORE_SIZE; k++)
{
sum = 0;
for (i = 0; i < CORE_SIZE; i++)
sum += fptr0[i]*fptr2[i];
fptr2 += CORE_SIZE;
buffer_swap[k] = sum;
}
fptr0 += CORE_SIZE;
buffer_swap += CORE_SIZE;
}
memcpy(in_buffer, buffer_c, dct_length*sizeof(float));
table_ptr_ptr = cos_msin_table;
/* Perform rotation butterflies */
for (set_count_log = dct_length_log - 2; set_count_log >= 0; set_count_log--)
{
/* Initialization for the loop over sets at the current size */
set_span = dct_length >> set_count_log;
set_count = 1 << set_count_log;
next_in_base = in_buffer;
if (set_count_log == 0)
next_out_base = output;
else
next_out_base = out_buffer;
++table_ptr_ptr;
/* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up the pointers for the current set */
in_ptr_low = next_in_base;
in_ptr_high = in_ptr_low + (set_span >> 1);
next_in_base += set_span;
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
cos_msin_ptr = *table_ptr_ptr;
/* Loop over all the butterfly pairs in the current set */
do
{
cos_even = (*cos_msin_ptr).cosine;
msin_even = (*cos_msin_ptr++).minus_sine;
*out_ptr_low++ = cos_even * *in_ptr_low - msin_even * *in_ptr_high;
*--out_ptr_high = msin_even * *in_ptr_low++ + cos_even * *in_ptr_high++;
cos_odd = (*cos_msin_ptr).cosine;
msin_odd = (*cos_msin_ptr++).minus_sine;
*out_ptr_low++ = cos_odd * *in_ptr_low + msin_odd * *in_ptr_high;
*--out_ptr_high = msin_odd * *in_ptr_low++ - cos_odd * *in_ptr_high++;
}
while (out_ptr_low < out_ptr_high);
}
/* Swap input and output buffers for next time */
buffer_swap = in_buffer;
in_buffer = out_buffer;
out_buffer = buffer_swap;
}
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
File diff suppressed because it is too large. Load diff
+280
View File
@@ -0,0 +1,280 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* dct4_a.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_a.c,v 1.8 2008/09/30 14:06:39 steveu Exp $
*/
/*********************************************************************************
* Filename: dct_type_iv_a.c
*
* Purpose: Discrete Cosine Transform, Type IV used for MLT
*
* The basis functions are
*
* cos(PI*(t+0.5)*(k+0.5)/block_length)
*
* for time t and basis function number k. Due to the symmetry of the expression
* in t and k, it is clear that the forward and inverse transforms are the same.
*
*********************************************************************************/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#if defined(G722_1_USE_FIXED_POINT)
#include "dct4_a.h"
/*********************************************************************************
Function: dct_type_iv_a
Syntax: void dct_type_iv_a (input, output, dct_length)
int16_t input[], output[], dct_length;
Description: Discrete Cosine Transform, Type IV used for MLT
*********************************************************************************/
void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length)
{
int16_t buffer_a[MAX_DCT_LENGTH];
int16_t buffer_b[MAX_DCT_LENGTH];
int16_t buffer_c[MAX_DCT_LENGTH];
int16_t *in_ptr;
int16_t *in_ptr_low;
int16_t *in_ptr_high;
int16_t *next_in_base;
int16_t *out_ptr_low;
int16_t *out_ptr_high;
int16_t *next_out_base;
int16_t *out_buffer;
int16_t *in_buffer;
int16_t *buffer_swap;
int16_t in_val_low;
int16_t in_val_high;
int16_t out_val_low;
int16_t out_val_high;
int16_t in_low_even;
int16_t in_low_odd;
int16_t in_high_even;
int16_t in_high_odd;
int16_t out_low_even;
int16_t out_low_odd;
int16_t out_high_even;
int16_t out_high_odd;
int16_t *pair_ptr;
int16_t cos_even;
int16_t cos_odd;
int16_t msin_even;
int16_t msin_odd;
int16_t neg_cos_odd;
int16_t neg_msin_even;
int32_t sum;
int16_t set_span;
int16_t set_count;
int16_t set_count_log;
int16_t pairs_left;
int16_t sets_left;
int16_t i;
int16_t k;
int16_t index;
const cos_msin_t **table_ptr_ptr;
const cos_msin_t *cos_msin_ptr;
int16_t temp;
int32_t acca;
int16_t dct_length_log;
/* Do the sum/difference butterflies, the first part of */
/* converting one N-point transform into N/2 two-point */
/* transforms, where N = 1 << DCT_LENGTH_LOG. = 64/128 */
if (dct_length == DCT_LENGTH)
{
dct_length_log = DCT_LENGTH_LOG;
/* Add bias offsets */
for (i = 0; i < dct_length; i++)
input[i] = add(input[i], anal_bias[i]);
}
else
{
dct_length_log = MAX_DCT_LENGTH_LOG;
}
index = 0L;
in_buffer = input;
out_buffer = buffer_a;
temp = sub(dct_length_log, 2);
for (set_count_log = 0; set_count_log <= temp; set_count_log++)
{
/* Initialization for the loop over sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
set_span = shr(dct_length, set_count_log);
set_count = shl(1, set_count_log);
in_ptr = in_buffer;
next_out_base = out_buffer;
/* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up output pointers for the current set */
out_ptr_low = next_out_base;
next_out_base = next_out_base + set_span;
out_ptr_high = next_out_base;
/* Loop over all the butterflies in the current set */
do
{
in_val_low = *in_ptr++;
in_val_high = *in_ptr++;
acca = L_add(in_val_low, in_val_high);
acca = L_shr(acca, 1);
out_val_low = (int16_t) acca;
acca = L_sub(in_val_low, in_val_high);
acca = L_shr(acca, 1);
out_val_high = (int16_t) acca;
*out_ptr_low++ = out_val_low;
*--out_ptr_high = out_val_high;
}
while (out_ptr_low < out_ptr_high);
}
/* Decide which buffers to use as input and output next time. */
/* Except for the first time (when the input buffer is the */
/* subroutine input) we just alternate the local buffers. */
in_buffer = out_buffer;
if (out_buffer == buffer_a)
out_buffer = buffer_b;
else
out_buffer = buffer_a;
index = add(index, 1);
}
/* Do N/2 two-point transforms, */
/* where N = 1 << DCT_LENGTH_LOG */
pair_ptr = in_buffer;
buffer_swap = buffer_c;
temp = sub(dct_length_log, 1);
temp = shl(1, temp);
for (pairs_left = temp; pairs_left > 0; pairs_left--)
{
for (k = 0; k < CORE_SIZE; k++)
{
sum = 0L;
for (i = 0; i < CORE_SIZE; i++)
sum = L_mac(sum, pair_ptr[i], dct_core_a[i][k]);
buffer_swap[k] = xround(sum);
}
/* Address arithmetic */
pair_ptr += CORE_SIZE;
buffer_swap += CORE_SIZE;
}
for (i = 0; i < dct_length; i++)
in_buffer[i] = buffer_c[i];
table_ptr_ptr = a_cos_msin_table;
/* Perform rotation butterflies */
temp = sub(dct_length_log, 2);
for (set_count_log = temp; set_count_log >= 0; set_count_log--)
{
/* Initialization for the loop over sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
set_span = shr(dct_length, set_count_log);
set_count = shl(1, set_count_log);
next_in_base = in_buffer;
next_out_base = (set_count_log == 0) ? output : out_buffer;
/* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up the pointers for the current set */
in_ptr_low = next_in_base;
temp = shr(set_span, 1);
/* Address arithmetic */
in_ptr_high = in_ptr_low + temp;
next_in_base += set_span;
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
cos_msin_ptr = *table_ptr_ptr;
/* Loop over all the butterfly pairs in the current set */
do
{
/* Address arithmetic */
in_low_even = *in_ptr_low++;
in_low_odd = *in_ptr_low++;
in_high_even = *in_ptr_high++;
in_high_odd = *in_ptr_high++;
cos_even = cos_msin_ptr[0].cosine;
msin_even = cos_msin_ptr[0].minus_sine;
cos_odd = cos_msin_ptr[1].cosine;
msin_odd = cos_msin_ptr[1].minus_sine;
cos_msin_ptr += 2;
sum = 0L;
sum = L_mac(sum, cos_even, in_low_even);
neg_msin_even = negate(msin_even);
sum = L_mac(sum, neg_msin_even, in_high_even);
out_low_even = xround(sum);
sum = 0L;
sum = L_mac(sum, msin_even,in_low_even);
sum = L_mac(sum, cos_even, in_high_even);
out_high_even = xround(sum);
sum = 0L;
sum = L_mac(sum, cos_odd, in_low_odd);
sum = L_mac(sum, msin_odd, in_high_odd);
out_low_odd = xround(sum);
sum = 0L;
sum = L_mac(sum, msin_odd, in_low_odd);
neg_cos_odd = negate(cos_odd);
sum = L_mac(sum, neg_cos_odd, in_high_odd);
out_high_odd = xround(sum);
*out_ptr_low++ = out_low_even;
*--out_ptr_high = out_high_even;
*out_ptr_low++ = out_low_odd;
*--out_ptr_high = out_high_odd;
}
while (out_ptr_low < out_ptr_high);
}
/* Swap input and output buffers for next time */
buffer_swap = in_buffer;
in_buffer = out_buffer;
out_buffer = buffer_swap;
table_ptr_ptr++;
}
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+738
View File
@@ -0,0 +1,738 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* dct4_a.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_a.h,v 1.4 2008/09/25 15:56:31 steveu Exp $
*/
typedef struct
{
int16_t cosine;
int16_t minus_sine;
} cos_msin_t;
static const cos_msin_t a_cos_msin_2[10] =
{
{29805, -1171},
{29621, -3506},
{29255, -5819},
{28708, -8097},
{27984, -10324},
{27088, -12488},
{26025, -14575},
{24801, -16572},
{23425, -18466},
{21903, -20247}
};
static const cos_msin_t a_cos_msin_4[20] =
{
{29822, -586},
{29776, -1756},
{29684, -2924},
{29547, -4087},
{29364, -5244},
{29135, -6392},
{28862, -7531},
{28544, -8659},
{28182, -9773},
{27776, -10871},
{27328, -11954},
{26838, -13017},
{26306, -14061},
{25734, -15083},
{25122, -16081},
{24471, -17055},
{23783, -18003},
{23057, -18923},
{22297, -19813},
{21502, -20673}
};
static const cos_msin_t a_cos_msin_8[40] =
{
{29827, -293},
{29815, -878},
{29792, -1464},
{29758, -2048},
{29712, -2632},
{29654, -3215},
{29586, -3797},
{29505, -4377},
{29414, -4955},
{29311, -5532},
{29196, -6106},
{29071, -6678},
{28934, -7248},
{28786, -7814},
{28627, -8378},
{28457, -8938},
{28276, -9495},
{28084, -10049},
{27882, -10598},
{27668, -11144},
{27444, -11685},
{27209, -12221},
{26964, -12753},
{26709, -13280},
{26443, -13802},
{26167, -14318},
{25881, -14829},
{25584, -15335},
{25278, -15834},
{24963, -16327},
{24637, -16814},
{24302, -17295},
{23958, -17769},
{23605, -18236},
{23242, -18695},
{22871, -19148},
{22490, -19594},
{22101, -20031},
{21704, -20461},
{21298, -20884}
};
static const cos_msin_t a_cos_msin_16[80] =
{
{29828, -146},
{29825, -439},
{29819, -732},
{29811, -1025},
{29799, -1317},
{29785, -1610},
{29767, -1902},
{29747, -2194},
{29724, -2486},
{29698, -2778},
{29670, -3069},
{29638, -3360},
{29604, -3651},
{29567, -3942},
{29526, -4232},
{29483, -4521},
{29438, -4811},
{29389, -5099},
{29338, -5388},
{29283, -5676},
{29226, -5963},
{29166, -6249},
{29103, -6535},
{29038, -6821},
{28969, -7106},
{28898, -7390},
{28824, -7673},
{28748, -7956},
{28668, -8237},
{28586, -8518},
{28501, -8799},
{28413, -9078},
{28323, -9357},
{28229, -9634},
{28133, -9911},
{28035, -10187},
{27933, -10461},
{27829, -10735},
{27723, -11008},
{27613, -11279},
{27501, -11550},
{27387, -11819},
{27269, -12088},
{27149, -12355},
{27027, -12621},
{26901, -12885},
{26774, -13149},
{26643, -13411},
{26510, -13672},
{26375, -13932},
{26237, -14190},
{26096, -14447},
{25953, -14702},
{25807, -14956},
{25659, -15209},
{25509, -15460},
{25356, -15710},
{25200, -15958},
{25043, -16205},
{24882, -16450},
{24720, -16693},
{24554, -16935},
{24387, -17175},
{24217, -17414},
{24045, -17651},
{23871, -17886},
{23694, -18119},
{23515, -18351},
{23334, -18581},
{23150, -18809},
{22964, -19036},
{22776, -19260},
{22586, -19483},
{22394, -19704},
{22199, -19923},
{22003, -20140},
{21804, -20355},
{21603, -20568},
{21400, -20779},
{21195, -20988}
};
static const cos_msin_t a_cos_msin_32[160] =
{
{29828, -73},
{29827, -220},
{29826, -366},
{29824, -512},
{29821, -659},
{29817, -805},
{29813, -952},
{29808, -1098},
{29802, -1244},
{29796, -1390},
{29789, -1537},
{29781, -1683},
{29772, -1829},
{29763, -1975},
{29753, -2121},
{29742, -2267},
{29730, -2413},
{29718, -2559},
{29705, -2705},
{29692, -2851},
{29677, -2997},
{29662, -3142},
{29646, -3288},
{29630, -3433},
{29613, -3579},
{29595, -3724},
{29576, -3869},
{29557, -4014},
{29537, -4159},
{29516, -4304},
{29494, -4449},
{29472, -4594},
{29449, -4738},
{29426, -4883},
{29401, -5027},
{29376, -5172},
{29351, -5316},
{29324, -5460},
{29297, -5604},
{29269, -5747},
{29241, -5891},
{29211, -6034},
{29181, -6178},
{29151, -6321},
{29119, -6464},
{29087, -6607},
{29054, -6749},
{29021, -6892},
{28987, -7034},
{28952, -7177},
{28916, -7319},
{28880, -7460},
{28843, -7602},
{28805, -7744},
{28767, -7885},
{28728, -8026},
{28688, -8167},
{28648, -8308},
{28607, -8448},
{28565, -8589},
{28522, -8729},
{28479, -8869},
{28435, -9008},
{28391, -9148},
{28346, -9287},
{28300, -9426},
{28253, -9565},
{28206, -9703},
{28158, -9842},
{28109, -9980},
{28060, -10118},
{28010, -10255},
{27959, -10393},
{27908, -10530},
{27856, -10667},
{27803, -10803},
{27750, -10940},
{27696, -11076},
{27641, -11212},
{27586, -11347},
{27529, -11482},
{27473, -11617},
{27415, -11752},
{27357, -11886},
{27299, -12021},
{27239, -12154},
{27179, -12288},
{27119, -12421},
{27057, -12554},
{26996, -12687},
{26933, -12819},
{26870, -12951},
{26806, -13083},
{26741, -13215},
{26676, -13346},
{26610, -13476},
{26544, -13607},
{26477, -13737},
{26409, -13867},
{26340, -13996},
{26271, -14125},
{26202, -14254},
{26132, -14383},
{26061, -14511},
{25989, -14638},
{25917, -14766},
{25844, -14893},
{25771, -15020},
{25697, -15146},
{25622, -15272},
{25547, -15397},
{25471, -15523},
{25394, -15648},
{25317, -15772},
{25239, -15896},
{25161, -16020},
{25082, -16143},
{25003, -16266},
{24923, -16389},
{24842, -16511},
{24760, -16632},
{24678, -16754},
{24596, -16875},
{24513, -16995},
{24429, -17115},
{24345, -17235},
{24260, -17354},
{24174, -17473},
{24088, -17592},
{24002, -17710},
{23914, -17827},
{23827, -17945},
{23738, -18061},
{23649, -18178},
{23560, -18293},
{23470, -18409},
{23379, -18524},
{23288, -18638},
{23196, -18752},
{23104, -18866},
{23011, -18979},
{22917, -19092},
{22824, -19204},
{22729, -19316},
{22634, -19427},
{22538, -19538},
{22442, -19649},
{22345, -19759},
{22248, -19868},
{22150, -19977},
{22052, -20086},
{21953, -20194},
{21854, -20301},
{21754, -20408},
{21653, -20515},
{21552, -20621},
{21451, -20726},
{21349, -20831},
{21246, -20936},
{21143, -21040}
};
static const cos_msin_t a_cos_msin_64[320] =
{
{29827, -34},
{29827, -106},
{29827, -177},
{29827, -249},
{29826, -320},
{29825, -392},
{29824, -463},
{29823, -535},
{29821, -606},
{29819, -678},
{29818, -750},
{29816, -821},
{29814, -893},
{29812, -964},
{29809, -1035},
{29807, -1106},
{29804, -1177},
{29801, -1249},
{29797, -1320},
{29795, -1392},
{29791, -1463},
{29787, -1535},
{29784, -1606},
{29780, -1678},
{29776, -1749},
{29771, -1820},
{29767, -1892},
{29763, -1963},
{29758, -2035},
{29753, -2106},
{29748, -2177},
{29742, -2249},
{29737, -2320},
{29731, -2391},
{29726, -2462},
{29719, -2534},
{29713, -2605},
{29707, -2676},
{29701, -2747},
{29694, -2819},
{29686, -2890},
{29680, -2961},
{29673, -3032},
{29665, -3103},
{29658, -3174},
{29650, -3245},
{29643, -3316},
{29635, -3387},
{29626, -3459},
{29618, -3529},
{29610, -3600},
{29601, -3671},
{29592, -3742},
{29583, -3813},
{29574, -3884},
{29564, -3955},
{29554, -4026},
{29544, -4097},
{29535, -4167},
{29525, -4238},
{29514, -4309},
{29504, -4380},
{29493, -4450},
{29483, -4521},
{29472, -4591},
{29461, -4662},
{29450, -4733},
{29439, -4803},
{29427, -4874},
{29415, -4944},
{29403, -5015},
{29391, -5085},
{29379, -5155},
{29366, -5226},
{29353, -5296},
{29341, -5367},
{29328, -5438},
{29314, -5508},
{29301, -5578},
{29289, -5648},
{29274, -5718},
{29260, -5788},
{29247, -5858},
{29232, -5928},
{29218, -5998},
{29204, -6068},
{29188, -6139},
{29175, -6209},
{29159, -6279},
{29145, -6348},
{29128, -6418},
{29114, -6488},
{29097, -6557},
{29082, -6627},
{29066, -6697},
{29050, -6767},
{29034, -6837},
{29017, -6906},
{29001, -6975},
{28984, -7045},
{28966, -7114},
{28950, -7184},
{28933, -7254},
{28915, -7323},
{28897, -7392},
{28880, -7461},
{28862, -7530},
{28843, -7600},
{28825, -7669},
{28807, -7738},
{28788, -7806},
{28769, -7875},
{28751, -7944},
{28732, -8014},
{28712, -8082},
{28692, -8151},
{28672, -8219},
{28653, -8289},
{28633, -8357},
{28613, -8425},
{28593, -8494},
{28572, -8563},
{28551, -8632},
{28531, -8700},
{28510, -8768},
{28488, -8837},
{28468, -8905},
{28447, -8973},
{28425, -9041},
{28403, -9109},
{28381, -9177},
{28359, -9245},
{28336, -9313},
{28315, -9381},
{28292, -9448},
{28269, -9517},
{28246, -9584},
{28223, -9652},
{28200, -9720},
{28176, -9787},
{28153, -9854},
{28129, -9922},
{28105, -9990},
{28082, -10056},
{28057, -10124},
{28032, -10191},
{28009, -10258},
{27984, -10326},
{27959, -10392},
{27934, -10460},
{27909, -10526},
{27883, -10593},
{27858, -10661},
{27832, -10727},
{27807, -10794},
{27780, -10860},
{27754, -10927},
{27728, -10993},
{27701, -11059},
{27676, -11126},
{27648, -11192},
{27622, -11259},
{27595, -11324},
{27567, -11391},
{27540, -11456},
{27512, -11523},
{27484, -11588},
{27456, -11655},
{27429, -11720},
{27401, -11786},
{27372, -11852},
{27344, -11917},
{27315, -11982},
{27286, -12049},
{27257, -12114},
{27229, -12179},
{27199, -12244},
{27169, -12309},
{27140, -12375},
{27110, -12439},
{27080, -12505},
{27050, -12570},
{27019, -12634},
{26990, -12699},
{26958, -12764},
{26928, -12828},
{26897, -12892},
{26866, -12956},
{26835, -13021},
{26804, -13086},
{26773, -13149},
{26741, -13214},
{26709, -13278},
{26677, -13342},
{26645, -13406},
{26613, -13470},
{26581, -13534},
{26549, -13597},
{26515, -13661},
{26483, -13725},
{26450, -13788},
{26417, -13851},
{26384, -13915},
{26350, -13978},
{26316, -14041},
{26283, -14103},
{26248, -14166},
{26215, -14229},
{26180, -14292},
{26146, -14355},
{26112, -14417},
{26077, -14480},
{26042, -14543},
{26008, -14605},
{25972, -14667},
{25937, -14730},
{25901, -14792},
{25866, -14854},
{25830, -14916},
{25794, -14977},
{25759, -15039},
{25723, -15101},
{25687, -15162},
{25650, -15224},
{25613, -15286},
{25577, -15347},
{25540, -15408},
{25503, -15470},
{25465, -15531},
{25428, -15592},
{25391, -15653},
{25353, -15714},
{25315, -15774},
{25277, -15834},
{25240, -15895},
{25201, -15956},
{25162, -16016},
{25124, -16076},
{25086, -16136},
{25047, -16196},
{25008, -16256},
{24969, -16316},
{24930, -16375},
{24891, -16436},
{24851, -16496},
{24811, -16555},
{24772, -16615},
{24732, -16674},
{24692, -16732},
{24652, -16791},
{24612, -16852},
{24572, -16911},
{24531, -16969},
{24490, -17027},
{24449, -17086},
{24408, -17145},
{24367, -17203},
{24325, -17261},
{24284, -17320},
{24242, -17379},
{24200, -17436},
{24158, -17494},
{24116, -17552},
{24075, -17610},
{24032, -17668},
{23990, -17725},
{23947, -17782},
{23904, -17840},
{23862, -17897},
{23819, -17954},
{23775, -18011},
{23732, -18068},
{23689, -18125},
{23645, -18181},
{23602, -18238},
{23558, -18294},
{23514, -18351},
{23470, -18407},
{23426, -18464},
{23381, -18520},
{23337, -18576},
{23293, -18632},
{23248, -18688},
{23202, -18743},
{23158, -18799},
{23112, -18854},
{23068, -18910},
{23022, -18964},
{22977, -19020},
{22931, -19074},
{22885, -19129},
{22839, -19185},
{22793, -19239},
{22747, -19294},
{22700, -19348},
{22655, -19403},
{22607, -19457},
{22561, -19511},
{22514, -19565},
{22467, -19619},
{22421, -19673},
{22373, -19726},
{22326, -19780},
{22279, -19834},
{22230, -19887},
{22183, -19940},
{22135, -19993},
{22087, -20047},
{22039, -20099},
{21991, -20152},
{21942, -20205},
{21894, -20257},
{21845, -20309},
{21797, -20362},
{21748, -20413},
{21699, -20466},
{21650, -20518},
{21601, -20570},
{21551, -20621},
{21502, -20674}
};
static const cos_msin_t *a_cos_msin_table[] =
{
a_cos_msin_2,
a_cos_msin_4,
a_cos_msin_8,
a_cos_msin_16,
a_cos_msin_32,
a_cos_msin_64
};
static const int16_t dct_core_a[10][10] =
{
{ 10453, 10196, 9688, 8941, 7973, 6810, 5479, 4013, 2448, 823 },
{ 10196, 7973, 4013, -823, -5479, -8941, -10453, -9688, -6810, -2448 },
{ 9688 , 4013, -4013, -9688, -9688, -4013, 4013, 9688, 9688, 4013 },
{ 8941 , -823, -9688, -7973, 2448, 10196, 6810, -4013, -10453, -5479 },
{ 7973 , -5479, -9688, 2448, 10453, 823, -10196, -4013, 8941, 6810 },
{ 6810 , -8941, -4013, 10196, 823, -10453, 2448, 9688, -5479, -7973 },
{ 5479 , -10453, 4013, 6810, -10196, 2448, 7973, -9688, 823, 8941 },
{ 4013 , -9688, 9688, -4013, -4013, 9688, -9688, 4013, 4013, -9688 },
{ 2448 , -6810, 9688, -10453, 8941, -5479, 823, 4013, -7973, 10196 },
{ 823 , -2448, 4013, -5479, 6810, -7973, 8941, -9688, 10196, -10453 }
};
static const int16_t anal_bias[320] =
{
1, 1, 3, 1, 4, 1, 3, -2, 4, 3,
4, 1, 3, 0, 2, -3, 0, 0, 2, 2,
4, 1, 1, -5, 4, 1, 2, -1, 0, -1,
1, -2, 0, 2, 2, 2, 4, 1, 3, 0,
5, 3, 2, 0, 3, 0, 1, -4, 1, 1,
2, 0, 4, 0, 1, -4, 6, 1, 3, -1,
1, 0, 0, -4, 1, 1, 3, 1, 3, 2,
4, -2, 4, 3, 5, 1, 3, 0, 1, -3,
1, 1, 2, 0, 4, 1, 2, -4, 4, 2,
2, -1, 1, -1, 1, -4, 0, 0, 3, 0,
5, 2, 3, -1, 6, 2, 5, 0, 4, 0,
1, -3, 1, 0, 3, 0, 4, 0, 1, -3,
4, 1, 3, -1, 1, -2, 1, -4, 0, 1,
2, 1, 3, 2, 2, -2, 4, 3, 3, 0,
3, 0, 0, -2, 1, 0, 2, 0, 5, -1,
1, -3, 4, 2, 2, 0, 2, -3, 1, -4,
-1, 1, 2, 2, 4, 1, 3, -1, 5, 2,
2, 0, 3, -1, 2, -3, 0, 1, 2, 2,
4, 0, 1, -5, 5, 1, 3, 0, 2, -1,
0, -2, 1, 2, 2, 2, 4, 1, 0, 0,
4, 2, 4, 1, 4, -1, 1, -4, 0, 1,
3, 1, 5, 1, 1, -2, 4, 0, 2, 0,
2, -1, 0, -2, 0, 1, 1, 1, 4, 2,
3, -2, 5, 4, 4, 0, 3, 0, 3, -4,
1, 2, 2, 0, 4, 1, 0, -3, 4, 2,
3, -1, 1, -1, 1, -4, 0, 2, 3, 1,
4, 1, 3, 0, 3, 3, 4, 1, 2, 0,
1, -3, 2, 2, 2, 1, 5, 0, 1, -4,
4, 1, 3, -2, 3, -1, 0, -2, 0, 2,
2, 0, 5, 1, 4, -1, 4, 3, 4, 1,
3, 0, 1, -4, 2, 0, 3, 1, 5, 0,
1, -5, 5, 2, 2, 0, 0, 0, 0, -4
};
+330
View File
@@ -0,0 +1,330 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* dct4_s.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_s.c,v 1.8 2008/09/30 14:06:39 steveu Exp $
*/
/********************************************************************************
* Filename: dct_type_iv_s.c
*
* Purpose: Discrete Cosine Transform, Type IV used for inverse MLT
*
* The basis functions are
*
* cos(PI*(t+0.5)*(k+0.5)/block_length)
*
* for time t and basis function number k. Due to the symmetry of the expression
* in t and k, it is clear that the forward and inverse transforms are the same.
*
*********************************************************************************/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#if defined(G722_1_USE_FIXED_POINT)
#include "dct4_s.h"
/********************************************************************************
Function: dct_type_iv_s
Syntax: void dct_type_iv_s (int16_t *input,int16_t *output,int16_t dct_length)
Description: Discrete Cosine Transform, Type IV used for inverse MLT
********************************************************************************/
void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length)
{
int16_t buffer_a[MAX_DCT_LENGTH];
int16_t buffer_b[MAX_DCT_LENGTH];
int16_t buffer_c[MAX_DCT_LENGTH];
int16_t *in_ptr;
int16_t *in_ptr_low;
int16_t *in_ptr_high;
int16_t *next_in_base;
int16_t *out_ptr_low;
int16_t *out_ptr_high;
int16_t *next_out_base;
int16_t *out_buffer;
int16_t *in_buffer;
int16_t *buffer_swap;
int16_t in_val_low;
int16_t in_val_high;
int16_t out_val_low;
int16_t out_val_high;
int16_t in_low_even;
int16_t in_low_odd;
int16_t in_high_even;
int16_t in_high_odd;
int16_t out_low_even;
int16_t out_low_odd;
int16_t out_high_even;
int16_t out_high_odd;
int16_t *pair_ptr;
int16_t cos_even;
int16_t cos_odd;
int16_t msin_even;
int16_t msin_odd;
int16_t set_span;
int16_t set_count;
int16_t set_count_log;
int16_t pairs_left;
int16_t sets_left;
int16_t i;
int16_t k;
int16_t index;
int16_t dummy;
int32_t sum;
const cos_msin_t **table_ptr_ptr;
const cos_msin_t *cos_msin_ptr;
int32_t acca;
int16_t temp;
int16_t dct_length_log;
const int16_t *dither_ptr;
/* Do the sum/difference butterflies, the first part of */
/* converting one N-point transform into 32 - 10 point transforms */
/* transforms, where N = 1 << DCT_LENGTH_LOG. */
if (dct_length == DCT_LENGTH)
{
dct_length_log = DCT_LENGTH_LOG;
dither_ptr = dither;
}
else
{
dct_length_log = MAX_DCT_LENGTH_LOG;
dither_ptr = max_dither;
}
in_buffer = input;
out_buffer = buffer_a;
index = 0;
i = 0;
for (set_count_log = 0; set_count_log <= dct_length_log - 2; set_count_log++)
{
/* Initialization for the loop over sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
set_span = shr(dct_length, set_count_log);
set_count = shl(1, set_count_log);
in_ptr = in_buffer;
next_out_base = out_buffer;
/* Loop over all the sets of this size */
temp = sub(index, 1);
if (temp < 0)
{
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up output pointers for the current set */
/* pointer arithmetic */
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
/* Loop over all the butterflies in the current set */
do
{
in_val_low = *in_ptr++;
in_val_high = *in_ptr++;
/* BEST METHOD OF GETTING RID OF BIAS, BUT COMPUTATIONALLY UNPLEASANT */
/* ALTERNATIVE METHOD, SMEARS BIAS OVER THE ENTIRE FRAME, COMPUTATIONALLY SIMPLEST. */
/* IF THIS WORKS, IT'S PREFERABLE */
dummy = add(in_val_low, dither_ptr[i++]);
acca = L_add(dummy, in_val_high);
out_val_low = (int16_t) L_shr(acca, 1);
dummy = add(in_val_low, dither_ptr[i++]);
acca = L_add(dummy, -in_val_high);
out_val_high = (int16_t) L_shr(acca, 1);
*out_ptr_low++ = out_val_low;
*--out_ptr_high = out_val_high;
/* this involves comparison of pointers */
/* pointer arithmetic */
}
while (out_ptr_low < out_ptr_high);
}
}
else
{
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up output pointers for the current set */
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
/* Loop over all the butterflies in the current set */
do
{
in_val_low = *in_ptr++;
in_val_high = *in_ptr++;
out_val_low = add(in_val_low, in_val_high);
out_val_high = add(in_val_low, negate(in_val_high));
*out_ptr_low++ = out_val_low;
*--out_ptr_high = out_val_high;
}
while (out_ptr_low < out_ptr_high);
}
}
/* Decide which buffers to use as input and output next time. */
/* Except for the first time (when the input buffer is the */
/* subroutine input) we just alternate the local buffers. */
in_buffer = out_buffer;
if (out_buffer == buffer_a)
out_buffer = buffer_b;
else
out_buffer = buffer_a;
index = add(index, 1);
}
/* Do 32 - 10 point transforms */
pair_ptr = in_buffer;
buffer_swap = buffer_c;
for (pairs_left = 1 << (dct_length_log - 1); pairs_left > 0; pairs_left--)
{
for (k = 0; k < CORE_SIZE; k++)
{
sum = 0L;
for (i = 0; i < CORE_SIZE; i++)
sum = L_mac(sum, pair_ptr[i], dct_core_s[i][k]);
buffer_swap[k] = xround(sum);
}
pair_ptr += CORE_SIZE;
buffer_swap += CORE_SIZE;
}
for (i = 0; i < dct_length; i++)
in_buffer[i] = buffer_c[i];
table_ptr_ptr = s_cos_msin_table;
/* Perform rotation butterflies */
index = 0;
for (set_count_log = dct_length_log - 2; set_count_log >= 0; set_count_log--)
{
/* Initialization for the loop over sets at the current size */
/* set_span = 1 << (DCT_LENGTH_LOG - set_count_log); */
set_span = shr(dct_length, set_count_log);
set_count = shl(1, set_count_log);
next_in_base = in_buffer;
if (set_count_log == 0)
next_out_base = output;
else
next_out_base = out_buffer;
/* Loop over all the sets of this size */
for (sets_left = set_count; sets_left > 0; sets_left--)
{
/* Set up the pointers for the current set */
in_ptr_low = next_in_base;
temp = shr(set_span, 1);
in_ptr_high = in_ptr_low + temp;
next_in_base += set_span;
out_ptr_low = next_out_base;
next_out_base += set_span;
out_ptr_high = next_out_base;
cos_msin_ptr = *table_ptr_ptr;
/* Loop over all the butterfly pairs in the current set */
do
{
in_low_even = *in_ptr_low++;
in_low_odd = *in_ptr_low++;
in_high_even = *in_ptr_high++;
in_high_odd = *in_ptr_high++;
cos_even = cos_msin_ptr[0].cosine;
msin_even = cos_msin_ptr[0].minus_sine;
cos_odd = cos_msin_ptr[1].cosine;
msin_odd = cos_msin_ptr[1].minus_sine;
cos_msin_ptr += 2;
sum = 0L;
sum = L_mac(sum, cos_even, in_low_even);
sum = L_mac(sum, negate(msin_even), in_high_even);
out_low_even = xround(L_shl(sum, 1));
sum = 0L;
sum = L_mac(sum, msin_even, in_low_even);
sum = L_mac(sum, cos_even, in_high_even);
out_high_even = xround(L_shl(sum, 1));
sum = 0L;
sum = L_mac(sum, cos_odd, in_low_odd);
sum = L_mac(sum, msin_odd, in_high_odd);
out_low_odd = xround(L_shl(sum, 1));
sum = 0L;
sum = L_mac(sum, msin_odd, in_low_odd);
sum = L_mac(sum, negate(cos_odd), in_high_odd);
out_high_odd = xround(L_shl(sum, 1));
*out_ptr_low++ = out_low_even;
*--out_ptr_high = out_high_even;
*out_ptr_low++ = out_low_odd;
*--out_ptr_high = out_high_odd;
}
while (out_ptr_low < out_ptr_high);
}
/* Swap input and output buffers for next time */
buffer_swap = in_buffer;
in_buffer = out_buffer;
out_buffer = buffer_swap;
index = add(index, 1);
table_ptr_ptr++;
}
/* ADD IN BIAS FOR OUTPUT */
if (dct_length == DCT_LENGTH)
{
for (i = 0; i < 320; i++)
{
sum = L_add(output[i], syn_bias_7khz[i]);
acca = L_sub(sum, 32767);
if (acca > 0)
sum = 32767L;
acca = L_add(sum, 32768L);
if (acca < 0)
sum = -32768L;
output[i] = (int16_t) sum;
}
}
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+870
View File
@@ -0,0 +1,870 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* dct4_s.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: dct4_s.h,v 1.4 2008/09/25 15:56:31 steveu Exp $
*/
typedef struct
{
int16_t cosine;
int16_t minus_sine;
} cos_msin_t;
/***************************************************************************
The dct_core_s table was generated by the following code
for (i = 0; i < 10; ++i)
{
for (k = 0; k < 10; ++k)
{
dct_core_s[i][k] = (short) (FTOI(((.9*32768.)*cos(3.1415926*(k+0.5)*(i+0.5)/10.))));
}
}
***************************************************************************/
static const int16_t dct_core_s[10][10] =
{
{ 29400, 28676, 27246, 25145, 22425, 19153, 15409, 11286, 6885, 2314},
{ 28676, 22425, 11286, -2314, -15409, -25145, -29400, -27246, -19153, -6885},
{ 27246, 11286, -11286, -27246, -27246, -11286, 11286, 27246, 27246, 11286},
{ 25145, -2314, -27246, -22425, 6885, 28676, 19153, -11286, -29400, -15409},
{ 22425, -15409, -27246, 6885, 29400, 2314, -28676, -11286, 25145, 19153},
{ 19153, -25145, -11286, 28676, 2314, -29400, 6885, 27246, -15409, -22425},
{ 15409, -29400, 11286, 19153, -28676, 6885, 22425, -27246, 2314, 25145},
{ 11286, -27246, 27246, -11286, -11286, 27246, -27246, 11286, 11286, -27246},
{ 6885, -19153, 27246, -29400, 25145, -15409, 2314, 11286, -22425, 28676},
{ 2314, -6885, 11286, -15409, 19153, -22425, 25145, -27246, 28676, -29400}
};
static const int16_t syn_bias_7khz[DCT_LENGTH] =
{
-4, 4, -5, -2, 0, -4, 6, 2, -2, -4,
-3, 3, 0, 0, -2, 4, 0, 0, 3, -6,
8, 5, 4, 5, -8, 0, -2, 0, 0, -3,
3, 0, 0, 0, 1, -1, -2, 0, 0, 2,
-2, -5, -2, 3, 2, -1, -1, -6, 3, 1,
-7, 4, 4, 0, 1, 4, 1, 0, 1, -5,
-1, 1, -6, 0, -1, -1, 3, 0, -2, 1,
2, -4, 0, 9, 0, -3, 1, 1, 1, 0,
-3, -2, -1, -4, -2, 0, 5, 2, -3, 5,
0, -2, 4, 4, 0, -6, -4, 2, 0, 0,
0, -1, -1, -2, 0, 6, 1, 0, 0, -1,
0, -4, -1, 0, -4, 1, -1, -5, 0, 1,
2, 4, 0, -8, -4, 0, -2, -2, 2, 5,
-3, -1, 1, -4, 0, 0, 0, -1, -3, 0,
-5, -4, 0, -2, 0, 7, 1, 0, 5, -2,
-1, 2, 2, -2, 3, 7, -3, 4, 1, -4,
0, 0, 3, -7, -5, 0, 0, 4, 0, -2,
-1, 0, -5, 0, 2, 0, 11, 5, -1, 0,
2, 2, -2, -2, 5, 4, -3, 1, 0, -2,
1, 3, 2, 0, 1, 0, 0, 0, 5, 6,
-2, -1, 0, 2, 3, 2, 0, -3, 4, 5,
0, -1, 0, 3, 1, -2, -3, -2, -1, 2,
-1, -1, -2, -7, 4, 6, -5, -6, -3, -4,
0, 2, -5, -2, 3, 0, 0, 0, 2, -2,
-4, 3, 3, 1, 0, 0, 4, -1, 8, 13,
1, 2, 0, 2, 0, -1, 4, -3, 1, 0,
-1, 3, 0, 0, -5, 0, 6, 2, 4, 5,
2, -1, -1, 3, 6, 1, 1, 2, -4, 0,
-1, -6, -2, -2, 2, 1, 2, 6, 2, 0,
-2, -2, 0, -1, 2, 0, 0, 3, -2, 1,
3, 1, 2, -1, -2, 2, 2, -4, 0, 0,
-3, 0, -4, -3, 6, 7, 2, 2, 0, -3
};
static const int16_t dither[DCT_LENGTH] =
{
1, 0, 0, 0, 1, 0, 0, 1, 1, 1,
1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 0, 1, 1, 0, 0, 0,
1, 0, 0, 1, 0, 1, 0, 0, 1, 0,
1, 0, 0, 0, 1, 0, 1, 0, 0, 0,
1, 1, 1, 1, 1, 0, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0, 1,
1, 1, 1, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 0, 0, 1, 0, 1,
0, 0, 1, 1, 0, 1, 0, 1, 1, 1,
1, 0, 0, 0, 0, 1, 1, 1, 1, 1,
0, 0, 0, 1, 0, 1, 0, 0, 0, 1,
1, 1, 0, 0, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 0, 1, 1, 1, 0,
1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
1, 1, 0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 0, 1, 1, 0, 0, 1, 1, 1,
1, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 0, 0, 1, 1, 0, 1, 1, 0, 0,
1, 1, 1, 0, 1, 1, 0, 1, 0, 1,
0, 0, 1, 1, 1, 1, 1, 1, 0, 1,
0, 1, 1, 1, 1, 0, 1, 1, 1, 0,
1, 1, 1, 0, 1, 1, 1, 0, 1, 0,
1, 1, 0, 0, 1, 0, 0, 1, 0, 1,
0, 1, 1, 0, 1, 0, 1, 0, 1, 1,
1, 0, 1, 0, 1, 0, 1, 1, 1, 1,
0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
1, 0, 0, 0, 1, 0, 0, 1, 0, 1,
1, 0, 1, 1, 0, 0, 1, 1, 0, 1,
1, 0, 1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 1, 0, 1, 0, 0, 0, 1, 0
};
static const int16_t max_dither[MAX_DCT_LENGTH] =
{
1, 0, 1, 0, 1, 1, 0, 1, 0, 1,
1, 1, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 0, 1, 1, 0, 0, 0, 1,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
1, 1, 1, 0, 1, 0, 1, 1, 1, 1,
0, 1, 0, 1, 1, 1, 1, 1, 1, 0,
1, 0, 1, 1, 0, 1, 0, 0, 0, 1,
0, 1, 1, 1, 1, 1, 0, 1, 1, 0,
0, 0, 1, 1, 0, 0, 0, 1, 1, 1,
1, 0, 1, 1, 1, 1, 1, 0, 0, 0,
1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
0, 1, 1, 1, 1, 1, 1, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0, 0, 1, 0,
0, 1, 0, 1, 0, 0, 0, 0, 1, 0,
1, 0, 0, 1, 0, 1, 0, 0, 0, 1,
0, 1, 0, 0, 1, 1, 1, 1, 0, 1,
1, 0, 0, 0, 1, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 1, 1, 0, 1,
1, 0, 0, 1, 1, 1, 1, 0, 1, 1,
1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 1, 1, 0,
1, 1, 0, 0, 0, 0, 1, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 0, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 0,
1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
0, 0, 1, 1, 0, 1, 0, 1, 0, 1,
0, 0, 1, 1, 1, 1, 1, 1, 0, 1,
0, 1, 1, 1, 0, 1, 0, 1, 0, 0,
0, 1, 0, 1, 1, 0, 0, 0, 1, 0,
1, 1, 0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 1, 1, 1, 1, 0, 0, 1, 1,
1, 1, 1, 0, 1, 0, 0, 0, 1, 0,
0, 1, 1, 1, 0, 1, 0, 1, 0, 0,
1, 1, 0, 1, 0, 1, 1, 0, 0, 0,
0, 1, 1, 0, 1, 1, 1, 0, 1, 1,
0, 0, 1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 0, 0, 0, 1, 1, 1, 1, 0,
0, 1, 0, 1, 0, 1, 1, 0, 1, 0,
1, 1, 1, 0, 0, 1, 1, 0, 0, 1,
0, 1, 0, 0, 0, 1, 1, 0, 0, 1,
0, 0, 1, 1, 0, 1, 0, 1, 0, 1,
1, 1, 0, 1, 0, 0, 1, 1, 0, 0,
1, 0, 1, 0, 1, 0, 0, 1, 0, 0,
0, 1, 0, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 0, 0, 0, 1, 1, 1, 0,
1, 1, 1, 0, 1, 1, 1, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0, 0, 1,
0, 0, 0, 1, 1, 0, 0, 1, 0, 1,
1, 1, 1, 1, 0, 0, 1, 0, 1, 0,
0, 1, 0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 0, 1, 0, 0, 1, 0, 1,
1, 0, 1, 0, 1, 1, 0, 0, 1, 1,
1, 1, 1, 0, 1, 0, 0, 1, 1, 1,
0, 1, 0, 1, 0, 1, 0, 0, 0, 1,
1, 0, 0, 1, 0, 0, 1, 1, 0, 1,
1, 0, 1, 0, 1, 1, 0, 0, 1, 1,
0, 0, 0, 1, 0, 1, 1, 1, 0, 0,
1, 0, 1, 0, 1, 1, 0, 0, 0, 1,
1, 0, 1, 0, 0, 1, 1, 1, 0, 1,
0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
0, 1, 0, 1, 0, 0, 1, 0, 1, 0,
0, 1, 1, 1, 1, 0, 0, 0, 1, 0,
0, 1, 0, 1, 0, 1, 0, 0, 0, 0
};
/********************************************************************************
The s_cos_min tables were generated by the following code:
double angle, scale;
int index;
for (index = 0;index < length;index++)
{
angle = scale * ((double)index + 0.5);
table[index].cosine = (short) (FTOI((18427)* cos(angle)));
table[index].minus_sine = (short) (FTOI((18427)*(-sin(angle))));
}
********************************************************************************/
static const cos_msin_t s_cos_msin_2[DCT_LENGTH_DIV_32] =
{
{18413, -723},
{18299, -2166},
{18073, -3595},
{17735, -5002},
{17288, -6378},
{16734, -7715},
{16077, -9004},
{15321, -10237},
{14471, -11408},
{13531, -12508}
};
static const cos_msin_t s_cos_msin_4[DCT_LENGTH_DIV_16] =
{
{18423, -362},
{18395, -1085},
{18338, -1806},
{18253, -2525},
{18140, -3239},
{17999, -3949},
{17830, -4653},
{17634, -5349},
{17410, -6037},
{17159, -6716},
{16883, -7385},
{16580, -8042},
{16251, -8686},
{15898, -9318},
{15520, -9935},
{15118, -10536},
{14692, -11122},
{14244, -11690},
{13774, -12240},
{13283, -12772}
};
static const cos_msin_t s_cos_msin_8[DCT_LENGTH_DIV_8] =
{
{18426, -181},
{18419, -543},
{18405, -904},
{18384, -1265},
{18355, -1626},
{18320, -1986},
{18277, -2345},
{18228, -2704},
{18171, -3061},
{18107, -3417},
{18037, -3772},
{17959, -4126},
{17875, -4477},
{17783, -4827},
{17685, -5176},
{17580, -5522},
{17468, -5866},
{17350, -6208},
{17225, -6547},
{17093, -6884},
{16954, -7219},
{16809, -7550},
{16658, -7879},
{16500, -8204},
{16336, -8526},
{16165, -8846},
{15988, -9161},
{15805, -9473},
{15616, -9782},
{15421, -10087},
{15220, -10387},
{15013, -10684},
{14801, -10977},
{14582, -11265},
{14358, -11550},
{14129, -11829},
{13894, -12104},
{13654, -12375},
{13408, -12641},
{13157, -12901}
};
static const cos_msin_t s_cos_msin_16[DCT_LENGTH_DIV_4] =
{
{18427, -90},
{18425, -271},
{18421, -452},
{18416, -633},
{18409, -814},
{18400, -995},
{18389, -1175},
{18377, -1356},
{18363, -1536},
{18347, -1716},
{18329, -1896},
{18310, -2076},
{18288, -2256},
{18265, -2435},
{18241, -2614},
{18214, -2793},
{18186, -2972},
{18156, -3150},
{18124, -3328},
{18090, -3506},
{18055, -3684},
{18018, -3861},
{17979, -4037},
{17939, -4214},
{17897, -4390},
{17853, -4565},
{17807, -4740},
{17760, -4915},
{17710, -5089},
{17660, -5262},
{17607, -5436},
{17553, -5608},
{17497, -5780},
{17439, -5952},
{17380, -6123},
{17319, -6293},
{17257, -6463},
{17192, -6632},
{17126, -6800},
{17059, -6968},
{16990, -7135},
{16919, -7302},
{16846, -7467},
{16772, -7632},
{16696, -7797},
{16619, -7960},
{16540, -8123},
{16459, -8285},
{16377, -8446},
{16294, -8607},
{16208, -8766},
{16121, -8925},
{16033, -9083},
{15943, -9240},
{15852, -9396},
{15759, -9551},
{15664, -9705},
{15568, -9858},
{15471, -10011},
{15372, -10162},
{15271, -10313},
{15169, -10462},
{15066, -10610},
{14961, -10758},
{14854, -10904},
{14747, -11049},
{14637, -11194},
{14527, -11337},
{14415, -11479},
{14301, -11620},
{14187, -11760},
{14071, -11898},
{13953, -12036},
{13834, -12172},
{13714, -12308},
{13593, -12442},
{13470, -12575},
{13346, -12706},
{13220, -12837},
{13094, -12966}
};
static const cos_msin_t s_cos_msin_32[DCT_LENGTH_DIV_2] =
{
{18427, -45},
{18427, -136},
{18426, -226},
{18424, -317},
{18423, -407},
{18420, -497},
{18418, -588},
{18415, -678},
{18411, -769},
{18407, -859},
{18403, -949},
{18398, -1040},
{18392, -1130},
{18387, -1220},
{18380, -1310},
{18374, -1401},
{18367, -1491},
{18359, -1581},
{18351, -1671},
{18343, -1761},
{18334, -1851},
{18324, -1941},
{18315, -2031},
{18305, -2121},
{18294, -2211},
{18283, -2301},
{18271, -2390},
{18259, -2480},
{18247, -2570},
{18234, -2659},
{18221, -2749},
{18207, -2838},
{18193, -2927},
{18178, -3017},
{18163, -3106},
{18148, -3195},
{18132, -3284},
{18116, -3373},
{18099, -3462},
{18082, -3551},
{18064, -3639},
{18046, -3728},
{18027, -3816},
{18009, -3905},
{17989, -3993},
{17969, -4081},
{17949, -4170},
{17928, -4258},
{17907, -4346},
{17886, -4434},
{17864, -4521},
{17841, -4609},
{17818, -4696},
{17795, -4784},
{17772, -4871},
{17747, -4958},
{17723, -5045},
{17698, -5132},
{17672, -5219},
{17647, -5306},
{17620, -5392},
{17594, -5479},
{17567, -5565},
{17539, -5651},
{17511, -5737},
{17483, -5823},
{17454, -5909},
{17425, -5994},
{17395, -6080},
{17365, -6165},
{17335, -6250},
{17304, -6335},
{17272, -6420},
{17241, -6505},
{17208, -6590},
{17176, -6674},
{17143, -6758},
{17110, -6842},
{17076, -6926},
{17042, -7010},
{17007, -7093},
{16972, -7177},
{16937, -7260},
{16901, -7343},
{16864, -7426},
{16828, -7509},
{16791, -7591},
{16753, -7674},
{16715, -7756},
{16677, -7838},
{16638, -7919},
{16599, -8001},
{16560, -8082},
{16520, -8164},
{16480, -8245},
{16439, -8325},
{16398, -8406},
{16357, -8486},
{16315, -8567},
{16272, -8647},
{16230, -8726},
{16187, -8806},
{16143, -8885},
{16100, -8964},
{16055, -9043},
{16011, -9122},
{15966, -9200},
{15920, -9279},
{15875, -9357},
{15829, -9435},
{15782, -9512},
{15735, -9589},
{15688, -9667},
{15640, -9744},
{15592, -9820},
{15544, -9897},
{15495, -9973},
{15446, -10049},
{15396, -10124},
{15347, -10200},
{15296, -10275},
{15246, -10350},
{15195, -10425},
{15143, -10499},
{15092, -10573},
{15040, -10647},
{14987, -10721},
{14934, -10794},
{14881, -10868},
{14828, -10941},
{14774, -11013},
{14719, -11086},
{14665, -11158},
{14610, -11230},
{14555, -11301},
{14499, -11372},
{14443, -11444},
{14387, -11514},
{14330, -11585},
{14273, -11655},
{14216, -11725},
{14158, -11795},
{14100, -11864},
{14041, -11933},
{13983, -12002},
{13924, -12070},
{13864, -12138},
{13804, -12206},
{13744, -12274},
{13684, -12341},
{13623, -12408},
{13562, -12475},
{13501, -12541},
{13439, -12608},
{13377, -12673},
{13314, -12739},
{13252, -12804},
{13189, -12869},
{13125, -12934},
{13062, -12998}
};
static const cos_msin_t s_cos_msin_64[DCT_LENGTH] =
{
{18426, -21},
{18426, -66},
{18426, -110},
{18426, -154},
{18425, -198},
{18425, -242},
{18424, -286},
{18424, -331},
{18423, -374},
{18421, -419},
{18421, -463},
{18419, -507},
{18418, -552},
{18417, -595},
{18415, -639},
{18414, -684},
{18412, -728},
{18410, -772},
{18408, -816},
{18406, -860},
{18404, -904},
{18402, -949},
{18400, -992},
{18397, -1037},
{18394, -1081},
{18392, -1125},
{18389, -1169},
{18387, -1213},
{18384, -1257},
{18380, -1301},
{18378, -1345},
{18374, -1389},
{18371, -1433},
{18367, -1477},
{18364, -1521},
{18360, -1566},
{18356, -1609},
{18352, -1653},
{18348, -1697},
{18344, -1742},
{18339, -1785},
{18335, -1829},
{18331, -1873},
{18326, -1917},
{18322, -1961},
{18317, -2005},
{18312, -2049},
{18307, -2092},
{18302, -2137},
{18297, -2180},
{18292, -2224},
{18286, -2268},
{18281, -2312},
{18275, -2356},
{18270, -2399},
{18264, -2443},
{18258, -2487},
{18252, -2531},
{18246, -2574},
{18240, -2618},
{18233, -2662},
{18227, -2706},
{18220, -2749},
{18214, -2793},
{18207, -2836},
{18200, -2880},
{18193, -2924},
{18186, -2967},
{18179, -3011},
{18172, -3055},
{18164, -3098},
{18157, -3142},
{18149, -3185},
{18141, -3229},
{18134, -3272},
{18126, -3316},
{18118, -3359},
{18109, -3403},
{18101, -3446},
{18094, -3489},
{18085, -3533},
{18076, -3576},
{18068, -3619},
{18059, -3663},
{18050, -3706},
{18041, -3749},
{18032, -3792},
{18023, -3836},
{18014, -3879},
{18005, -3922},
{17995, -3965},
{17986, -4008},
{17975, -4051},
{17966, -4094},
{17956, -4138},
{17946, -4180},
{17936, -4224},
{17926, -4266},
{17916, -4309},
{17905, -4353},
{17895, -4395},
{17884, -4438},
{17874, -4481},
{17863, -4524},
{17852, -4567},
{17841, -4609},
{17830, -4652},
{17819, -4695},
{17807, -4738},
{17796, -4780},
{17784, -4823},
{17772, -4865},
{17761, -4908},
{17749, -4951},
{17738, -4993},
{17725, -5036},
{17713, -5078},
{17701, -5121},
{17689, -5163},
{17676, -5205},
{17664, -5248},
{17651, -5290},
{17638, -5333},
{17626, -5375},
{17613, -5417},
{17599, -5459},
{17586, -5501},
{17573, -5544},
{17560, -5586},
{17546, -5627},
{17533, -5670},
{17519, -5712},
{17505, -5753},
{17492, -5795},
{17478, -5837},
{17464, -5879},
{17450, -5921},
{17435, -5963},
{17421, -6005},
{17406, -6046},
{17392, -6088},
{17377, -6130},
{17363, -6172},
{17348, -6213},
{17333, -6254},
{17318, -6296},
{17303, -6338},
{17288, -6379},
{17272, -6420},
{17257, -6462},
{17241, -6503},
{17225, -6545},
{17210, -6586},
{17194, -6627},
{17178, -6668},
{17162, -6709},
{17145, -6750},
{17130, -6791},
{17113, -6832},
{17097, -6874},
{17080, -6915},
{17064, -6956},
{17047, -6996},
{17030, -7037},
{17013, -7078},
{16996, -7119},
{16979, -7159},
{16962, -7200},
{16945, -7241},
{16927, -7281},
{16910, -7322},
{16892, -7362},
{16874, -7403},
{16856, -7444},
{16838, -7484},
{16821, -7524},
{16802, -7564},
{16784, -7605},
{16766, -7645},
{16748, -7685},
{16729, -7725},
{16711, -7765},
{16692, -7805},
{16674, -7845},
{16654, -7885},
{16635, -7925},
{16616, -7964},
{16597, -8004},
{16578, -8044},
{16559, -8084},
{16539, -8124},
{16520, -8164},
{16500, -8203},
{16480, -8242},
{16461, -8282},
{16441, -8322},
{16421, -8361},
{16401, -8400},
{16380, -8440},
{16360, -8479},
{16340, -8518},
{16319, -8557},
{16299, -8597},
{16278, -8635},
{16257, -8674},
{16237, -8713},
{16215, -8752},
{16195, -8791},
{16173, -8829},
{16152, -8868},
{16131, -8907},
{16110, -8946},
{16088, -8985},
{16067, -9023},
{16045, -9061},
{16023, -9100},
{16001, -9138},
{15979, -9176},
{15957, -9215},
{15935, -9253},
{15913, -9291},
{15891, -9329},
{15868, -9367},
{15846, -9405},
{15823, -9443},
{15800, -9481},
{15778, -9519},
{15755, -9557},
{15732, -9595},
{15709, -9632},
{15686, -9670},
{15662, -9708},
{15639, -9745},
{15615, -9782},
{15592, -9820},
{15569, -9857},
{15544, -9894},
{15521, -9932},
{15497, -9969},
{15473, -10006},
{15449, -10043},
{15425, -10080},
{15401, -10117},
{15377, -10154},
{15352, -10191},
{15327, -10227},
{15303, -10264},
{15278, -10301},
{15254, -10337},
{15229, -10374},
{15204, -10411},
{15180, -10447},
{15154, -10483},
{15129, -10519},
{15104, -10556},
{15078, -10592},
{15053, -10628},
{15027, -10664},
{15002, -10700},
{14976, -10736},
{14950, -10772},
{14924, -10808},
{14898, -10844},
{14872, -10879},
{14846, -10915},
{14820, -10950},
{14794, -10985},
{14767, -11021},
{14741, -11056},
{14714, -11092},
{14687, -11127},
{14661, -11162},
{14635, -11197},
{14607, -11232},
{14581, -11267},
{14554, -11302},
{14526, -11337},
{14499, -11372},
{14472, -11407},
{14444, -11441},
{14417, -11476},
{14389, -11511},
{14362, -11545},
{14334, -11579},
{14306, -11614},
{14278, -11648},
{14251, -11682},
{14222, -11716},
{14194, -11750},
{14166, -11784},
{14137, -11818},
{14109, -11852},
{14081, -11886},
{14053, -11919},
{14023, -11953},
{13995, -11987},
{13966, -12020},
{13937, -12054},
{13909, -12087},
{13879, -12120},
{13851, -12153},
{13821, -12187},
{13792, -12220},
{13763, -12253},
{13733, -12286},
{13704, -12319},
{13674, -12351},
{13645, -12385},
{13615, -12417},
{13585, -12450},
{13555, -12482},
{13525, -12514},
{13495, -12546},
{13465, -12579},
{13435, -12611},
{13405, -12644},
{13374, -12676},
{13345, -12708},
{13314, -12739},
{13283, -12772}
};
static const cos_msin_t *s_cos_msin_table[] =
{
s_cos_msin_2,
s_cos_msin_4,
s_cos_msin_8,
s_cos_msin_16,
s_cos_msin_32,
s_cos_msin_64
};
/*- End of file ------------------------------------------------------------*/
+721
View File
@@ -0,0 +1,721 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* decoder.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: decoder.c,v 1.21 2008/11/21 15:30:22 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "tables.h"
#include "huff_tab.h"
#include "bitstream.h"
int16_t get_rand(g722_1_rand_t *randobj)
{
int16_t random_word;
int32_t acca;
acca = randobj->seed0 + randobj->seed3;
random_word = (int16_t) acca;
if ((random_word & 32768L) != 0)
random_word++;
randobj->seed3 = randobj->seed2;
randobj->seed2 = randobj->seed1;
randobj->seed1 = randobj->seed0;
randobj->seed0 = random_word;
return random_word;
}
/*- End of function --------------------------------------------------------*/
#if defined(G722_1_USE_FIXED_POINT)
static void test_for_frame_errors(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int *frame_error_flag,
int16_t categorization_control,
int16_t *absolute_region_power_index);
static void error_handling(int16_t number_of_coefs,
int16_t number_of_valid_coefs,
int *frame_error_flag,
int16_t *decoder_mlt_coefs,
int16_t *old_decoder_mlt_coefs,
int16_t *p_mag_shift,
int16_t *p_old_mag_shift);
static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t *decoder_region_standard_deviation,
int16_t *dedecoder_power_categories,
int16_t *dedecoder_mlt_coefs);
static void decode_envelope(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t *decoder_region_standard_deviation,
int16_t *absolute_region_power_index,
int16_t *p_mag_shift);
static void rate_adjust_categories(int16_t categorization_control,
int16_t *decoder_power_categories,
int16_t *decoder_category_balances);
static int16_t index_to_array(int16_t index, int16_t *array, int16_t category);
static void decoder(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t decoder_mlt_coefs[],
int16_t *p_mag_shift,
int16_t *p_old_mag_shift,
int16_t old_decoder_mlt_coefs[],
int frame_error_flag);
/***************************************************************************
Description: Decodes the out_words into mlt coefs using G.722.1 Annex C
***************************************************************************/
void decoder(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t decoder_mlt_coefs[],
int16_t *p_mag_shift,
int16_t *p_old_mag_shift,
int16_t old_decoder_mlt_coefs[],
int frame_error_flag)
{
int16_t decoder_region_standard_deviation[MAX_NUMBER_OF_REGIONS];
int16_t absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
int16_t decoder_power_categories[MAX_NUMBER_OF_REGIONS];
int16_t decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1];
uint16_t categorization_control;
int16_t num_categorization_control_bits;
int16_t num_categorization_control_possibilities;
int16_t number_of_coefs;
int16_t number_of_valid_coefs;
number_of_valid_coefs = number_of_regions*REGION_SIZE;
/* Get some parameters based solely on the bitstream style */
if (number_of_regions == NUMBER_OF_REGIONS)
{
number_of_coefs = DCT_LENGTH;
num_categorization_control_bits = NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
}
else
{
number_of_coefs = MAX_DCT_LENGTH;
num_categorization_control_bits = MAX_NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
}
if (frame_error_flag == 0)
{
/* Convert the bits to absolute region power index and decoder_region_standard_deviation */
decode_envelope(s,
number_of_regions,
decoder_region_standard_deviation,
absolute_region_power_index,
p_mag_shift);
/* Fill the categorization_control with NUM_CATEGORIZATION_CONTROL_BITS */
categorization_control = g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), num_categorization_control_bits);
s->number_of_bits_left -= num_categorization_control_bits;
/* Obtain decoder power categories and category balances */
/* Based on the absolute region power index */
categorize(s->number_of_bits_left,
number_of_regions,
num_categorization_control_possibilities,
absolute_region_power_index,
decoder_power_categories,
decoder_category_balances);
/* Perform adjustmaents to the power categories and category balances based on the cat control */
rate_adjust_categories(categorization_control,
decoder_power_categories,
decoder_category_balances);
/* Decode the quantized bits into mlt coefs */
decode_vector_quantized_mlt_indices(s,
number_of_regions,
decoder_region_standard_deviation,
decoder_power_categories,
decoder_mlt_coefs);
test_for_frame_errors(s,
number_of_regions,
num_categorization_control_possibilities,
&frame_error_flag,
categorization_control,
absolute_region_power_index);
}
/* Perform error handling operations */
error_handling(number_of_coefs,
number_of_valid_coefs,
&frame_error_flag,
decoder_mlt_coefs,
old_decoder_mlt_coefs,
p_mag_shift,
p_old_mag_shift);
}
/*- End of function --------------------------------------------------------*/
/***************************************************************************
Description: Recover differential_region_power_index from code bits
***************************************************************************/
static void decode_envelope(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t *decoder_region_standard_deviation,
int16_t *absolute_region_power_index,
int16_t *p_mag_shift)
{
int16_t region;
int16_t i;
int16_t index;
int16_t differential_region_power_index[MAX_NUMBER_OF_REGIONS];
int16_t max_index;
int16_t temp;
int16_t temp1;
int16_t temp2;
int32_t acca;
/* Get 5 bits from the current code word */
index = g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 5);
s->number_of_bits_left -= 5;
/* ESF_ADJUSTMENT_TO_RMS_INDEX compensates for the current (9/30/96)
IMLT being scaled to high by the ninth power of sqrt(2). */
differential_region_power_index[0] = sub(index, ESF_ADJUSTMENT_TO_RMS_INDEX);
/* Obtain differential_region_power_index */
for (region = 1; region < number_of_regions; region++)
{
index = 0;
do
{
if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
index = differential_region_power_decoder_tree[region][index][0];
else
index = differential_region_power_decoder_tree[region][index][1];
s->number_of_bits_left--;
}
while (index > 0);
differential_region_power_index[region] = negate(index);
}
/* Reconstruct absolute_region_power_index[] from differential_region_power_index[]. */
absolute_region_power_index[0] = differential_region_power_index[0];
for (region = 1; region < number_of_regions; region++)
{
acca = L_add(absolute_region_power_index[region - 1], differential_region_power_index[region]);
acca = L_add(acca, DRP_DIFF_MIN);
absolute_region_power_index[region] = (int16_t) acca;
}
/* Reconstruct decoder_region_standard_deviation[] from absolute_region_power_index[]. */
/* DEBUG!!!! - This integer method jointly computes the mag_shift
and the standard deviations already mag_shift compensated. It
relies on REGION_POWER_STEPSIZE_DB being exactly 3.010299957 db
or a square root of 2 change in standard deviation. If
REGION_POWER_STEPSIZE_DB changes, this software must be reworked. */
temp = 0;
max_index = 0;
for (region = 0; region < number_of_regions; region++)
{
acca = L_add(absolute_region_power_index[region], REGION_POWER_TABLE_NUM_NEGATIVES);
i = (int16_t) acca;
temp1 = sub(i, max_index);
if (temp1 > 0)
max_index = i;
temp = add(temp, int_region_standard_deviation_table[i]);
}
i = 9;
temp1 = sub(temp, 8);
temp2 = sub(max_index, 28);
while ((i >= 0) && ((temp1 >= 0) || (temp2 > 0)))
{
i = sub(i, 1);
temp = shr(temp, 1);
max_index = sub(max_index, 2);
temp1 = sub(temp, 8);
temp2 = sub(max_index, 28);
}
*p_mag_shift = i;
temp = (int16_t ) (REGION_POWER_TABLE_NUM_NEGATIVES + (*p_mag_shift * 2));
for (region = 0; region < number_of_regions; region++)
{
acca = L_add(absolute_region_power_index[region], temp);
i = (int16_t) acca;
decoder_region_standard_deviation[region] = int_region_standard_deviation_table[i];
}
}
/*- End of function --------------------------------------------------------*/
/* Adjust the power categories based on the categorization control */
static void rate_adjust_categories(int16_t categorization_control,
int16_t *decoder_power_categories,
int16_t *decoder_category_balances)
{
int16_t i;
int16_t region;
i = 0;
while (categorization_control > 0)
{
region = decoder_category_balances[i++];
decoder_power_categories[region]++;
categorization_control = sub(categorization_control, 1);
}
}
/*- End of function --------------------------------------------------------*/
/* Decode MLT coefficients */
static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t *decoder_region_standard_deviation,
int16_t *decoder_power_categories,
int16_t *decoder_mlt_coefs)
{
const int16_t noise_fill_factor[3] =
{
5793, 8192, 23170
};
int j;
int16_t standard_deviation;
int16_t *decoder_mlt_ptr;
int16_t decoder_mlt_value;
int16_t noifillpos;
int16_t noifillneg;
int16_t region;
int16_t category;
int16_t n;
int16_t k[MAX_VECTOR_DIMENSION];
int16_t vec_dim;
int16_t num_vecs;
int16_t index;
int16_t signs_index;
int16_t bit;
int16_t num_sign_bits;
int16_t ran_out_of_bits_flag;
int16_t random_word;
int16_t temp;
int32_t acca;
const int16_t *decoder_table_ptr;
ran_out_of_bits_flag = 0;
for (region = 0; region < number_of_regions; region++)
{
category = (int16_t) decoder_power_categories[region];
acca = L_mult0(region, REGION_SIZE);
index = (int16_t) acca;
decoder_mlt_ptr = &decoder_mlt_coefs[index];
standard_deviation = decoder_region_standard_deviation[region];
temp = sub(category, 7);
if (temp < 0)
{
/* Get the proper table of decoder tables, vec_dim, and num_vecs for the cat */
decoder_table_ptr = table_of_decoder_tables[category];
vec_dim = vector_dimension[category];
num_vecs = number_of_vectors[category];
for (n = 0; n < num_vecs; n++)
{
index = 0;
/* Get index */
do
{
if (s->number_of_bits_left <= 0)
{
ran_out_of_bits_flag = 1;
break;
}
if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
{
temp = shl(index, 1);
index = (int16_t) *(decoder_table_ptr + temp);
}
else
{
temp = shl(index, 1);
index = (int16_t) *(decoder_table_ptr + temp + 1);
}
s->number_of_bits_left--;
}
while (index > 0);
if (ran_out_of_bits_flag != 0)
break;
index = negate(index);
/* convert index into array used to access the centroid table */
/* get the number of sign bits in the index */
num_sign_bits = index_to_array(index, k, category);
if (s->number_of_bits_left >= num_sign_bits)
{
signs_index = 0;
bit = 0;
if (num_sign_bits != 0)
{
signs_index = g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), num_sign_bits);
s->number_of_bits_left -= num_sign_bits;
bit = 1 << (num_sign_bits - 1);
}
for (j = 0; j < vec_dim; j++)
{
acca = L_mult0(standard_deviation, mlt_quant_centroid[category][k[j]]);
acca = L_shr(acca, 12);
decoder_mlt_value = (int16_t) acca;
if (decoder_mlt_value != 0)
{
if ((signs_index & bit) == 0)
decoder_mlt_value = negate(decoder_mlt_value);
bit = shr(bit, 1);
}
*decoder_mlt_ptr++ = decoder_mlt_value;
}
}
else
{
ran_out_of_bits_flag = 1;
break;
}
}
/* If ran out of bits during decoding do noise fill for remaining regions. */
/* DEBUG!! - For now also redo all of last region with all noise fill. */
if (ran_out_of_bits_flag != 0)
{
for (j = region + 1; j < number_of_regions; j++)
decoder_power_categories[j] = 7;
category = 7;
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
}
}
if (category == (NUM_CATEGORIES - 3) || category == (NUM_CATEGORIES - 2))
{
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
noifillpos = mult(standard_deviation, noise_fill_factor[category - 5]);
noifillneg = negate(noifillpos);
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
if (*decoder_mlt_ptr == 0)
{
*decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos;
random_word = shr(random_word, 1);
}
/* pointer arithmetic */
decoder_mlt_ptr++;
}
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
if (*decoder_mlt_ptr == 0)
{
*decoder_mlt_ptr = ((random_word & 1) == 0) ? noifillneg : noifillpos;
random_word = shr(random_word,1);
}
/* pointer arithmetic */
decoder_mlt_ptr++;
}
}
if (category == NUM_CATEGORIES - 1)
{
index = sub(category, 5);
noifillpos = mult(standard_deviation, noise_fill_factor[index]);
noifillneg = negate(noifillpos);
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
*decoder_mlt_ptr++ = ((random_word & 1) == 0) ? noifillneg : noifillpos;
random_word >>= 1;
}
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
decoder_mlt_ptr[j] = ((random_word & 1) == 0) ? noifillneg : noifillpos;
random_word >>= 1;
}
}
}
if (ran_out_of_bits_flag)
s->number_of_bits_left = -1;
}
/*- End of function --------------------------------------------------------*/
/* Compute an array of sign bits with the length of the category vector
Returns the number of sign bits and the array */
static int16_t index_to_array(int16_t index, int16_t *array, int16_t category)
{
int16_t j;
int16_t q;
int16_t p;
int16_t number_of_non_zero;
int16_t max_bin_plus_one;
int16_t inverse_of_max_bin_plus_one;
number_of_non_zero = 0;
p = index;
max_bin_plus_one = max_bin[category] + 1;
inverse_of_max_bin_plus_one = max_bin_plus_one_inverse[category];
for (j = vector_dimension[category] - 1; j >= 0; j--)
{
q = (p*inverse_of_max_bin_plus_one) >> 15;
array[j] = p - q*max_bin_plus_one;
p = q;
if (array[j] != 0)
number_of_non_zero++;
}
return number_of_non_zero;
}
/*- End of function --------------------------------------------------------*/
/* Tests for error conditions and sets the frame_error_flag accordingly */
static void test_for_frame_errors(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int *frame_error_flag,
int16_t categorization_control,
int16_t *absolute_region_power_index)
{
int i;
/* Test for bit stream errors. */
if (s->number_of_bits_left > 0)
{
while (s->number_of_bits_left > 0)
{
if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
*frame_error_flag = 1;
s->number_of_bits_left--;
}
}
else
{
if (categorization_control < num_categorization_control_possibilities - 1)
{
if (s->number_of_bits_left < 0)
*frame_error_flag |= 2;
}
}
/* Checks to ensure that absolute_region_power_index is within range */
/* The error flag is set if it is out of range */
for (i = 0; i < number_of_regions; i++)
{
if ((absolute_region_power_index[i] + ESF_ADJUSTMENT_TO_RMS_INDEX > 31)
||
(absolute_region_power_index[i] + ESF_ADJUSTMENT_TO_RMS_INDEX < -8))
{
*frame_error_flag |= 4;
break;
}
}
}
/*- End of function --------------------------------------------------------*/
static void error_handling(int16_t number_of_coefs,
int16_t number_of_valid_coefs,
int *frame_error_flag,
int16_t *decoder_mlt_coefs,
int16_t *old_decoder_mlt_coefs,
int16_t *p_mag_shift,
int16_t *p_old_mag_shift)
{
int i;
/* If both the current and previous frames are errored,
set the mlt coefficients to 0. If only the current frame
is errored, repeat the previous frame's MLT coefficients. */
if (*frame_error_flag)
{
for (i = 0; i < number_of_valid_coefs; i++)
decoder_mlt_coefs[i] = old_decoder_mlt_coefs[i];
for (i = 0; i < number_of_valid_coefs; i++)
old_decoder_mlt_coefs[i] = 0;
*p_mag_shift = *p_old_mag_shift;
*p_old_mag_shift = 0;
}
else
{
/* Store in case the next frame has errors. */
for (i = 0; i < number_of_valid_coefs; i++)
old_decoder_mlt_coefs[i] = decoder_mlt_coefs[i];
*p_old_mag_shift = *p_mag_shift;
}
/* Zero out the upper 1/8 of the spectrum. */
for (i = number_of_valid_coefs; i < number_of_coefs; i++)
decoder_mlt_coefs[i] = 0;
}
/*- End of function --------------------------------------------------------*/
int g722_1_decode(g722_1_decode_state_t *s, int16_t amp[], const uint8_t g722_1_data[], int len)
{
int16_t decoder_mlt_coefs[MAX_DCT_LENGTH];
int16_t mag_shift;
int i;
int j;
for (i = 0, j = 0; j < len; i += s->frame_size, j += s->number_of_bits_per_frame/8)
{
g722_1_bitstream_init(&s->bitstream);
s->code_ptr = &g722_1_data[j];
s->number_of_bits_left = s->number_of_bits_per_frame;
/* Process the out_words into decoder_mlt_coefs */
decoder(s,
s->number_of_regions,
decoder_mlt_coefs,
&mag_shift,
&s->old_mag_shift,
s->old_decoder_mlt_coefs,
0);
/* Convert the decoder_mlt_coefs to samples */
rmlt_coefs_to_samples(decoder_mlt_coefs, s->old_samples, amp + i, s->frame_size, mag_shift);
}
return i;
}
/*- End of function --------------------------------------------------------*/
int g722_1_fillin(g722_1_decode_state_t *s, int16_t amp[], const uint8_t g722_1_data[], int len)
{
int16_t decoder_mlt_coefs[MAX_DCT_LENGTH];
int16_t mag_shift;
int i;
int j;
for (i = 0, j = 0; j < len; i += s->frame_size, j += s->number_of_bits_per_frame/8)
{
g722_1_bitstream_init(&s->bitstream);
s->code_ptr = &g722_1_data[j];
s->number_of_bits_left = s->number_of_bits_per_frame;
/* Process the out_words into decoder MLT coefs */
decoder(s,
s->number_of_regions,
decoder_mlt_coefs,
&mag_shift,
&s->old_mag_shift,
s->old_decoder_mlt_coefs,
1);
/* Convert the decoder MLT coefs to samples */
rmlt_coefs_to_samples(decoder_mlt_coefs, s->old_samples, amp + i, s->frame_size, mag_shift);
i += s->frame_size;
break;
}
return i;
}
/*- End of function --------------------------------------------------------*/
#endif
int g722_1_decode_set_rate(g722_1_decode_state_t *s, int bit_rate)
{
if ((bit_rate < 16000) || (bit_rate > 48000) || ((bit_rate%800) != 0))
return -1;
s->bit_rate = bit_rate;
s->number_of_bits_per_frame = (int16_t) ((s->bit_rate)/50);
s->bytes_per_frame = s->number_of_bits_per_frame/8;
return 0;
}
/*- End of function --------------------------------------------------------*/
g722_1_decode_state_t *g722_1_decode_init(g722_1_decode_state_t *s, int bit_rate, int sample_rate)
{
#if !defined(G722_1_USE_FIXED_POINT)
int i;
#endif
if ((bit_rate < 16000) || (bit_rate > 48000) || ((bit_rate%800) != 0))
return NULL;
if (sample_rate != G722_1_SAMPLE_RATE_16000 && sample_rate != G722_1_SAMPLE_RATE_32000)
return NULL;
if (s == NULL)
{
if ((s = (g722_1_decode_state_t *) malloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
#if !defined(G722_1_USE_FIXED_POINT)
/* Initialize the coefs history */
for (i = 0; i < s->frame_size; i++)
s->old_decoder_mlt_coefs[i] = 0.0f;
for (i = 0; i < (s->frame_size >> 1); i++)
s->old_samples[i] = 0.0f;
#endif
s->sample_rate = sample_rate;
if (sample_rate == G722_1_SAMPLE_RATE_16000)
{
s->number_of_regions = NUMBER_OF_REGIONS;
s->frame_size = MAX_FRAME_SIZE >> 1;
}
else
{
s->number_of_regions = MAX_NUMBER_OF_REGIONS;
s->frame_size = MAX_FRAME_SIZE;
}
s->bit_rate = bit_rate;
s->number_of_bits_per_frame = s->bit_rate/50;
s->bytes_per_frame = s->number_of_bits_per_frame/8;
/* Initialize the random number generator */
s->randobj.seed0 = 1;
s->randobj.seed1 = 1;
s->randobj.seed2 = 1;
s->randobj.seed3 = 1;
return s;
}
/*- End of function --------------------------------------------------------*/
int g722_1_decode_release(g722_1_decode_state_t *s)
{
free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+653
View File
@@ -0,0 +1,653 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* decoder.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: decoderf.c,v 1.22 2008/11/21 15:30:22 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "huff_tab.h"
#include "tables.h"
#include "bitstream.h"
#if !defined(G722_1_USE_FIXED_POINT)
static void test_for_frame_errors(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int *frame_error_flag,
int16_t categorization_control,
int *absolute_region_power_index);
static void error_handling(int number_of_coefs,
int number_of_valid_coefs,
int *frame_error_flag,
float *decoder_mlt_coefs,
float *old_decoder_mlt_coefs);
static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s,
int number_of_regions,
float decoder_region_standard_deviation[MAX_NUMBER_OF_REGIONS],
int decoder_power_categories[MAX_NUMBER_OF_REGIONS],
float decoder_mlt_coefs[MAX_DCT_LENGTH],
int rmlt_scale_factor);
static void decode_envelope(g722_1_decode_state_t *s,
int number_of_regions,
float decoder_region_standard_deviation[MAX_NUMBER_OF_REGIONS],
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS]);
static void rate_adjust_categories(int rate_control,
int decoder_power_categories[MAX_NUMBER_OF_REGIONS],
int decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]);
static int index_to_array(int index,
int array[MAX_VECTOR_DIMENSION],
int category);
static void decoder(g722_1_decode_state_t *s,
float decoder_mlt_coefs[MAX_DCT_LENGTH],
float old_decoder_mlt_coefs[MAX_DCT_LENGTH],
int frame_error_flag);
/* Decode the bitstream into MLT coefs using G.722.1 Annex C */
static void decoder(g722_1_decode_state_t *s,
float decoder_mlt_coefs[MAX_DCT_LENGTH],
float old_decoder_mlt_coefs[MAX_DCT_LENGTH],
int frame_error_flag)
{
float decoder_region_standard_deviation[MAX_NUMBER_OF_REGIONS];
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
int decoder_power_categories[MAX_NUMBER_OF_REGIONS];
int decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1];
int rate_control;
int num_categorization_control_bits;
int num_categorization_control_possibilities;
int number_of_coefs;
int number_of_valid_coefs;
int rmlt_scale_factor;
number_of_valid_coefs = s->number_of_regions*REGION_SIZE;
/* Get some parameters based solely on the bitstream style */
if (s->number_of_regions == NUMBER_OF_REGIONS)
{
number_of_coefs = FRAME_SIZE;
num_categorization_control_bits = NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
rmlt_scale_factor = (int) INTEROP_RMLT_SCALE_FACTOR_7;
}
else
{
number_of_coefs = MAX_FRAME_SIZE;
num_categorization_control_bits = MAX_NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
rmlt_scale_factor = (int) INTEROP_RMLT_SCALE_FACTOR_14;
}
if (frame_error_flag == 0)
{
decode_envelope(s,
s->number_of_regions,
decoder_region_standard_deviation,
absolute_region_power_index);
rate_control = g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), num_categorization_control_bits);
s->number_of_bits_left -= num_categorization_control_bits;
categorize(s->number_of_regions,
s->number_of_bits_left,
absolute_region_power_index,
decoder_power_categories,
decoder_category_balances);
rate_adjust_categories(rate_control,
decoder_power_categories,
decoder_category_balances);
decode_vector_quantized_mlt_indices(s,
s->number_of_regions,
decoder_region_standard_deviation,
decoder_power_categories,
decoder_mlt_coefs,
rmlt_scale_factor);
test_for_frame_errors(s,
s->number_of_regions,
num_categorization_control_possibilities,
&frame_error_flag,
rate_control,
absolute_region_power_index);
}
error_handling(number_of_coefs,
number_of_valid_coefs,
&frame_error_flag,
decoder_mlt_coefs,
old_decoder_mlt_coefs);
}
/*- End of function --------------------------------------------------------*/
/* Recover differential_region_power_index from code bits */
static void decode_envelope(g722_1_decode_state_t *s,
int number_of_regions,
float decoder_region_standard_deviation[MAX_NUMBER_OF_REGIONS],
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS])
{
int region;
int i;
int index;
int differential_region_power_index[MAX_NUMBER_OF_REGIONS];
/* Recover differential_region_power_index[] from code_bits[]. */
index = g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 5);
s->number_of_bits_left -= 5;
/* ESF_ADJUSTMENT_TO_RMS_INDEX compensates for the current (9/30/96)
IMLT being scaled too high by the ninth power of sqrt(2). */
differential_region_power_index[0] = index - ESF_ADJUSTMENT_TO_RMS_INDEX;
for (region = 1; region < number_of_regions; region++)
{
index = 0;
do
{
if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
index = differential_region_power_decoder_tree[region][index][0];
else
index = differential_region_power_decoder_tree[region][index][1];
s->number_of_bits_left--;
}
while (index > 0);
differential_region_power_index[region] = -index;
}
/* Reconstruct absolute_region_power_index[] from differential_region_power_index[]. */
absolute_region_power_index[0] = differential_region_power_index[0];
for (region = 1; region < number_of_regions; region++)
{
absolute_region_power_index[region] = absolute_region_power_index[region - 1]
+ differential_region_power_index[region]
+ DRP_DIFF_MIN;
}
/* Reconstruct decoder_region_standard_deviation[] from absolute_region_power_index[]. */
for (region = 0; region < number_of_regions; region++)
{
i = absolute_region_power_index[region] + REGION_POWER_TABLE_NUM_NEGATIVES;
decoder_region_standard_deviation[region] = region_standard_deviation_table[i];
}
}
/*- End of function --------------------------------------------------------*/
/* Adjust the power categories based on the categorization control */
static void rate_adjust_categories(int rate_control,
int decoder_power_categories[MAX_NUMBER_OF_REGIONS],
int decoder_category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1])
{
int i;
int region;
i = 0;
while (rate_control > 0)
{
region = decoder_category_balances[i++];
decoder_power_categories[region]++;
rate_control--;
}
}
/*- End of function --------------------------------------------------------*/
/* Decode MLT coefficients */
static void decode_vector_quantized_mlt_indices(g722_1_decode_state_t *s,
int number_of_regions,
float decoder_region_standard_deviation[MAX_NUMBER_OF_REGIONS],
int decoder_power_categories[MAX_NUMBER_OF_REGIONS],
float decoder_mlt_coefs[MAX_DCT_LENGTH],
int rmlt_scale_factor)
{
static const float noise_fill_factor_cat5[20] =
{
0.70711f, 0.6179f, 0.5005f, 0.3220f,
0.17678f, 0.17678f, 0.17678f, 0.17678f,
0.17678f, 0.17678f, 0.17678f, 0.17678f,
0.17678f, 0.17678f, 0.17678f, 0.17678f,
0.17678f, 0.17678f, 0.17678f, 0.17678f
};
static const float noise_fill_factor_cat6[20] =
{
0.70711f, 0.5686f, 0.3563f, 0.25f,
0.25f, 0.25f, 0.25f, 0.25f,
0.25f, 0.25f, 0.25f, 0.25f,
0.25f, 0.25f, 0.25f, 0.25f,
0.25f, 0.25f, 0.25f, 0.25f
};
float standard_deviation;
float *decoder_mlt_ptr;
float decoder_mlt_value;
float temp1;
float noifillpos;
float noifillneg;
int region;
int category;
int j;
int n;
int k[MAX_VECTOR_DIMENSION];
int vec_dim;
int num_vecs;
int index;
int signs_index;
int bit;
int num_sign_bits;
int num_bits;
int ran_out_of_bits_flag;
int random_word;
const int16_t *decoder_table_ptr;
ran_out_of_bits_flag = 0;
for (region = 0; region < number_of_regions; region++)
{
category = decoder_power_categories[region];
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
standard_deviation = decoder_region_standard_deviation[region];
if (category < NUM_CATEGORIES - 1)
{
decoder_table_ptr = table_of_decoder_tables[category];
vec_dim = vector_dimension[category];
num_vecs = number_of_vectors[category];
for (n = 0; n < num_vecs; n++)
{
num_bits = 0;
index = 0;
do
{
if (s->number_of_bits_left <= 0)
{
ran_out_of_bits_flag = 1;
break;
}
if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
index = *(decoder_table_ptr + 2*index);
else
index = *(decoder_table_ptr + 2*index + 1);
s->number_of_bits_left--;
}
while (index > 0);
if (ran_out_of_bits_flag == 1)
break;
index = -index;
num_sign_bits = index_to_array(index, k, category);
if (s->number_of_bits_left >= num_sign_bits)
{
signs_index = 0;
bit = 0;
if (num_sign_bits != 0)
{
signs_index = g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), num_sign_bits);
s->number_of_bits_left -= num_sign_bits;
bit = 1 << (num_sign_bits - 1);
}
for (j = 0; j < vec_dim; j++)
{
/* This was changed to for fixed point interop
A scale factor is used to adjust the decoded mlt value. */
decoder_mlt_value = standard_deviation
* mlt_quant_centroid[category][k[j]]
* (float) rmlt_scale_factor;
if (decoder_mlt_value != 0)
{
if ((signs_index & bit) == 0)
decoder_mlt_value *= -1;
bit >>= 1;
}
*decoder_mlt_ptr++ = decoder_mlt_value;
}
}
else
{
ran_out_of_bits_flag = 1;
break;
}
}
/* If ran out of bits during decoding do noise fill for remaining regions. */
if (ran_out_of_bits_flag == 1)
{
for (j = region + 1; j < number_of_regions; j++)
decoder_power_categories[j] = NUM_CATEGORIES - 1;
category = NUM_CATEGORIES - 1;
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
}
}
if (category == NUM_CATEGORIES - 3)
{
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
n = 0;
for (j = 0; j < REGION_SIZE; j++)
{
if (*decoder_mlt_ptr != 0)
{
n++;
if (fabs(*decoder_mlt_ptr) > (2.0*(float) rmlt_scale_factor*standard_deviation))
n += 3;
}
decoder_mlt_ptr++;
}
if (n > 19)
n = 19;
temp1 = noise_fill_factor_cat5[n];
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
/* noifillpos = standard_deviation * 0.17678; */
noifillpos = standard_deviation*temp1;
noifillneg = -noifillpos;
/* This assumes region_size = 20 */
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
if (*decoder_mlt_ptr == 0)
{
temp1 = noifillpos;
if ((random_word & 1) == 0)
temp1 = noifillneg;
*decoder_mlt_ptr = temp1*(float) rmlt_scale_factor;
random_word >>= 1;
}
decoder_mlt_ptr++;
}
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
if (*decoder_mlt_ptr == 0)
{
temp1 = noifillpos;
if ((random_word & 1) == 0)
temp1 = noifillneg;
*decoder_mlt_ptr = temp1*(float) rmlt_scale_factor;
random_word >>= 1;
}
decoder_mlt_ptr++;
}
}
if (category == NUM_CATEGORIES - 2)
{
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
n = 0;
for (j = 0; j < REGION_SIZE; j++)
{
if (*decoder_mlt_ptr++ != 0)
n++;
}
temp1 = noise_fill_factor_cat6[n];
decoder_mlt_ptr = &decoder_mlt_coefs[region*REGION_SIZE];
noifillpos = standard_deviation*temp1;
noifillneg = -noifillpos;
/* This assumes region_size = 20 */
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
if (*decoder_mlt_ptr == 0)
{
temp1 = noifillpos;
if ((random_word & 1) == 0)
temp1 = noifillneg;
*decoder_mlt_ptr = temp1*(float) rmlt_scale_factor;
random_word >>= 1;
}
decoder_mlt_ptr++;
}
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
if (*decoder_mlt_ptr == 0)
{
temp1 = noifillpos;
if ((random_word & 1) == 0)
temp1 = noifillneg;
*decoder_mlt_ptr = temp1*(float) rmlt_scale_factor;
random_word >>= 1;
}
decoder_mlt_ptr++;
}
}
if (category == NUM_CATEGORIES - 1)
{
noifillpos = standard_deviation*0.70711;
noifillneg = -noifillpos;
/* This assumes region_size = 20 */
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
temp1 = ((random_word & 1) == 0) ? noifillneg : noifillpos;
*decoder_mlt_ptr++ = temp1*(float) rmlt_scale_factor;
random_word >>= 1;
}
random_word = get_rand(&s->randobj);
for (j = 0; j < 10; j++)
{
temp1 = ((random_word & 1) == 0) ? noifillneg : noifillpos;
decoder_mlt_ptr[j] = temp1*(float) rmlt_scale_factor;
random_word >>= 1;
}
}
}
if (ran_out_of_bits_flag)
s->number_of_bits_left = -1;
}
/*- End of function --------------------------------------------------------*/
/* Compute an array of sign bits with the length of the category vector
Returns the number of sign bits and the array */
static int index_to_array(int index, int array[MAX_VECTOR_DIMENSION], int category)
{
int j;
int q;
int p;
int number_of_non_zero;
int max_bin_plus_one;
int inverse_of_max_bin_plus_one;
number_of_non_zero = 0;
p = index;
max_bin_plus_one = max_bin[category] + 1;
inverse_of_max_bin_plus_one = max_bin_plus_one_inverse[category];
for (j = vector_dimension[category] - 1; j >= 0; j--)
{
q = (p*inverse_of_max_bin_plus_one) >> 15;
array[j] = p - q*max_bin_plus_one;
p = q;
if (array[j] != 0)
number_of_non_zero++;
}
return number_of_non_zero;
}
/*- End of function --------------------------------------------------------*/
/* Tests for error conditions and sets the frame_error_flag accordingly */
static void test_for_frame_errors(g722_1_decode_state_t *s,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int *frame_error_flag,
int16_t categorization_control,
int *absolute_region_power_index)
{
int i;
/* Test for bit stream errors. */
if (s->number_of_bits_left > 0)
{
while (s->number_of_bits_left > 0)
{
if (g722_1_bitstream_get(&s->bitstream, &(s->code_ptr), 1) == 0)
*frame_error_flag = 1;
s->number_of_bits_left--;
}
}
else
{
if (categorization_control < num_categorization_control_possibilities - 1)
{
if (s->number_of_bits_left < 0)
*frame_error_flag |= 2;
}
}
/* Checks to ensure that absolute_region_power_index is within range */
/* The error flag is set if it is out of range */
for (i = 0; i < number_of_regions; i++)
{
if ((absolute_region_power_index[i] + ESF_ADJUSTMENT_TO_RMS_INDEX > 31)
||
(absolute_region_power_index[i] + ESF_ADJUSTMENT_TO_RMS_INDEX < -8))
{
*frame_error_flag |= 4;
break;
}
}
}
/*- End of function --------------------------------------------------------*/
static void error_handling(int number_of_coefs,
int number_of_valid_coefs,
int *frame_error_flag,
float *decoder_mlt_coefs,
float *old_decoder_mlt_coefs)
{
int i;
/* If both the current and previous frames are errored,
set the mlt coefficients to 0. If only the current frame
is errored, repeat the previous frame's MLT coefficients. */
if (*frame_error_flag)
{
for (i = 0; i < number_of_valid_coefs; i++)
decoder_mlt_coefs[i] = old_decoder_mlt_coefs[i];
for (i = 0; i < number_of_valid_coefs; i++)
old_decoder_mlt_coefs[i] = 0.0f;
}
else
{
/* Store in case the next frame has errors. */
for (i = 0; i < number_of_valid_coefs; i++)
old_decoder_mlt_coefs[i] = decoder_mlt_coefs[i];
}
/* Zero out the upper 1/8 of the spectrum. */
for (i = number_of_valid_coefs; i < number_of_coefs; i++)
decoder_mlt_coefs[i] = 0.0f;
}
/*- End of function --------------------------------------------------------*/
int g722_1_decode(g722_1_decode_state_t *s, int16_t amp[], const uint8_t g722_1_data[], int len)
{
float decoder_mlt_coefs[MAX_DCT_LENGTH];
float famp[MAX_FRAME_SIZE];
float ftemp;
int i;
int j;
int k;
for (i = 0, j = 0; j < len; i += s->frame_size, j += s->number_of_bits_per_frame/8)
{
g722_1_bitstream_init(&s->bitstream);
s->code_ptr = &g722_1_data[j];
s->number_of_bits_left = s->number_of_bits_per_frame;
/* Process the out_words into decoder_mlt_coefs */
decoder(s,
decoder_mlt_coefs,
s->old_decoder_mlt_coefs,
0);
/* Convert the decoder_mlt_coefs to samples */
rmlt_coefs_to_samples(decoder_mlt_coefs, s->old_samples, famp, s->frame_size);
for (k = 0; k < s->frame_size; k++)
{
ftemp = famp[k];
if (ftemp >= 0.0)
amp[k + i] = (ftemp < 32767.0) ? (int) (ftemp + 0.5) : 32767;
else
amp[k + i] = (ftemp > -32768.0) ? (int) (ftemp - 0.5) : -32768;
}
}
return i;
}
/*- End of function --------------------------------------------------------*/
int g722_1_fillin(g722_1_decode_state_t *s, int16_t amp[], const uint8_t g722_1_data[], int len)
{
float decoder_mlt_coefs[MAX_DCT_LENGTH];
float famp[MAX_FRAME_SIZE];
float ftemp;
int i;
int j;
int k;
for (i = 0, j = 0; j < len; i += s->frame_size, j += s->number_of_bits_per_frame/8)
{
g722_1_bitstream_init(&s->bitstream);
s->code_ptr = &g722_1_data[j];
s->number_of_bits_left = s->number_of_bits_per_frame;
/* Process the out_words into decoder MLT_coefs */
decoder(s,
decoder_mlt_coefs,
s->old_decoder_mlt_coefs,
1);
/* Convert the decoder MLT coefs to samples */
rmlt_coefs_to_samples(decoder_mlt_coefs, s->old_samples, famp, s->frame_size);
for (k = 0; k < s->frame_size; k++)
{
ftemp = famp[k];
if (ftemp >= 0.0)
amp[k + i] = (ftemp < 32767.0) ? (int) (ftemp + 0.5) : 32767;
else
amp[k + i] = (ftemp > -32768.0) ? (int) (ftemp - 0.5) : -32768;
}
}
return i;
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+144
View File
@@ -0,0 +1,144 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* defs.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: defs.h,v 1.16 2008/10/01 15:31:10 steveu Exp $
*/
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define FRAME_SIZE (MAX_FRAME_SIZE >> 1)
#define DCT_LENGTH (MAX_DCT_LENGTH >> 1)
#define NUM_CATEGORIES 8
#define REGION_POWER_TABLE_SIZE 64
#define REGION_POWER_TABLE_NUM_NEGATIVES 24
#define NUM_CATEGORIZATION_CONTROL_BITS 4
#define NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 16
#define MAX_NUM_CATEGORIZATION_CONTROL_BITS 5
#define MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES 32
/* region_size = (BLOCK_SIZE * 0.875)/NUMBER_OF_REGIONS; */
#define REGION_SIZE 20
#define NUMBER_OF_REGIONS 14
#define MAX_NUMBER_OF_REGIONS 28
/* This value has been changed for fixed point interop */
#define ESF_ADJUSTMENT_TO_RMS_INDEX (9-2)
#define MAX_DCT_LENGTH_LOG 7
#define DCT_LENGTH_LOG 6
#define CORE_SIZE 10
#if defined(G722_1_USE_FIXED_POINT)
#include "basop32.h"
#define DCT_LENGTH_DIV_2 160
#define DCT_LENGTH_DIV_4 80
#define DCT_LENGTH_DIV_8 40
#define DCT_LENGTH_DIV_16 20
#define DCT_LENGTH_DIV_32 10
#define DCT_LENGTH_DIV_64 5
void adjust_abs_region_power_index(int16_t *absolute_region_power_index, int16_t *mlt_coefs, int16_t number_of_regions);
int16_t samples_to_rmlt_coefs(const int16_t new_samples[],
int16_t history[],
int16_t coefs[],
int dct_length);
void rmlt_coefs_to_samples(int16_t *coefs,
int16_t *old_samples,
int16_t *out_samples,
int dct_length,
int16_t mag_shift);
void rmlt_coefs_to_samples(int16_t *coefs,
int16_t *old_samples,
int16_t *out_samples,
int dct_length,
int16_t mag_shift);
void categorize(int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t *rms_index,
int16_t *power_categories,
int16_t *category_balances);
int16_t calc_offset(int16_t *rms_index, int16_t number_of_regions, int16_t available_bits);
void comp_powercat_and_catbalance(int16_t *power_categories,
int16_t *category_balances,
int16_t *rms_index,
int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t offset);
void dct_type_iv_a(int16_t input[], int16_t output[], int dct_length);
void dct_type_iv_s(int16_t input[], int16_t output[], int dct_length);
#else
#define PI 3.141592653589793238462
#define ENCODER_SCALE_FACTOR 18318.0f
#define REGION_SIZE_INVERSE (1.0f/20.0f)
/* The MLT output is incorrectly scaled by the factor
product of ENCODER_SCALE_FACTOR and sqrt(160.)
This is now (9/30/96) 1.0/2^(4.5) or 1/22.627.
In the current implementation this product
must be an integer power of sqrt(2). The
integer power is ESF_ADJUSTMENT_TO_RMS_INDEX.
The -2 is to conform with the range defined in the spec. */
/* Scale factor used to match fixed point model results. */
#define INTEROP_RMLT_SCALE_FACTOR_7 22.0f
#define INTEROP_RMLT_SCALE_FACTOR_14 33.0f
void categorize(int number_of_regions,
int number_of_available_bits,
int rms_index[MAX_NUMBER_OF_REGIONS],
int power_categories[MAX_NUMBER_OF_REGIONS],
int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1]);
void samples_to_rmlt_coefs(const float new_samples[],
float old_samples[],
float coefs[],
int dct_length);
void rmlt_coefs_to_samples(float coefs[],
float old_samples[],
float out_samples[],
int dct_length);
void dct_type_iv(float input[], float output[], int dct_length);
#endif
int16_t get_rand(g722_1_rand_t *randobj);
/*- End of file ------------------------------------------------------------*/
+712
View File
@@ -0,0 +1,712 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* encoder.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: encoder.c,v 1.26 2008/11/21 15:30:22 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "huff_tab.h"
#include "tables.h"
#include "bitstream.h"
#if defined(G722_1_USE_FIXED_POINT)
static int16_t compute_region_powers(int16_t *mlt_coefs,
int16_t mag_shift,
int16_t *drp_num_bits,
uint16_t *drp_code_bits,
int16_t *absolute_region_power_index,
int16_t number_of_regions);
static void vector_quantize_mlts(int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t *mlt_coefs,
int16_t *absolute_region_power_index,
int16_t *power_categories,
int16_t *category_balances,
int16_t *p_categorization_control,
int16_t *region_mlt_bit_counts,
uint32_t *region_mlt_bits);
static int16_t vector_huffman(int16_t category,
int16_t power_index,
int16_t *raw_mlt_ptr,
uint32_t *word_ptr);
static void bits_to_words(g722_1_encode_state_t *s,
uint32_t *region_mlt_bits,
int16_t *region_mlt_bit_counts,
int16_t *drp_num_bits,
uint16_t *drp_code_bits,
uint8_t *out_code,
int16_t categorization_control,
int16_t number_of_regions,
int16_t num_categorization_control_bits,
int16_t number_of_bits_per_frame);
static void encoder(g722_1_encode_state_t *s,
int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t *mlt_coefs,
int16_t mag_shift,
uint8_t *g722_1_data);
/* Stuff the bits into words for output */
static void bits_to_words(g722_1_encode_state_t *s,
uint32_t *region_mlt_bits,
int16_t *region_mlt_bit_counts,
int16_t *drp_num_bits,
uint16_t *drp_code_bits,
uint8_t *out_code,
int16_t categorization_control,
int16_t number_of_regions,
int16_t num_categorization_control_bits,
int16_t number_of_bits_per_frame)
{
int16_t region;
int16_t region_bit_count;
uint32_t *in_word_ptr;
uint32_t current_code;
int16_t current_bits;
int16_t bit_count;
/* First set up the categorization control bits to look like one more set of region power bits. */
drp_num_bits[number_of_regions] = num_categorization_control_bits;
drp_code_bits[number_of_regions] = categorization_control;
bit_count = 0;
/* These code bits are right justified. */
for (region = 0; region <= number_of_regions; region++)
{
g722_1_bitstream_put(&s->bitstream, &out_code, drp_code_bits[region], drp_num_bits[region]);
bit_count += drp_num_bits[region];
}
/* These code bits are left justified. */
for (region = 0; (region < number_of_regions) && (bit_count < number_of_bits_per_frame); region++)
{
in_word_ptr = &region_mlt_bits[4*region];
region_bit_count = region_mlt_bit_counts[region];
while ((region_bit_count > 0) && (bit_count < number_of_bits_per_frame))
{
current_bits = MIN(32, region_bit_count);
current_code = *in_word_ptr++;
current_code >>= (32 - current_bits);
g722_1_bitstream_put(&s->bitstream, &out_code, current_code, current_bits);
bit_count += current_bits;
region_bit_count -= current_bits;
}
}
/* Fill out with 1's. */
while (bit_count < number_of_bits_per_frame)
{
current_bits = MIN(32, number_of_bits_per_frame - bit_count);
g722_1_bitstream_put(&s->bitstream, &out_code, 0xFFFFFFFF, current_bits);
bit_count += current_bits;
}
g722_1_bitstream_flush(&s->bitstream, &out_code);
}
/*- End of function --------------------------------------------------------*/
/* Encode the MLT coefs into out_words using G.722.1 Annex C */
static void encoder(g722_1_encode_state_t *s,
int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t *mlt_coefs,
int16_t mag_shift,
uint8_t *g722_1_data)
{
int16_t num_categorization_control_bits;
int16_t num_categorization_control_possibilities;
int16_t number_of_bits_per_frame;
int16_t number_of_envelope_bits;
int16_t categorization_control;
int16_t region;
int16_t absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
int16_t power_categories[MAX_NUMBER_OF_REGIONS];
int16_t category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1];
int16_t drp_num_bits[MAX_NUMBER_OF_REGIONS + 1];
uint16_t drp_code_bits[MAX_NUMBER_OF_REGIONS + 1];
int16_t region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS];
uint32_t region_mlt_bits[4*MAX_NUMBER_OF_REGIONS];
int16_t mag_shift_offset;
int16_t temp;
/* Initialize variables */
if (number_of_regions == NUMBER_OF_REGIONS)
{
num_categorization_control_bits = NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
}
else
{
num_categorization_control_bits = MAX_NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
}
number_of_bits_per_frame = number_of_available_bits;
for (region = 0; region < number_of_regions; region++)
region_mlt_bit_counts[region] = 0;
/* Estimate power envelope. */
number_of_envelope_bits = compute_region_powers(mlt_coefs,
mag_shift,
drp_num_bits,
drp_code_bits,
absolute_region_power_index,
number_of_regions);
/* Adjust number of available bits based on power envelope estimate */
temp = sub(number_of_available_bits, number_of_envelope_bits);
number_of_available_bits = sub(temp, num_categorization_control_bits);
/* Get categorizations */
categorize(number_of_available_bits,
number_of_regions,
num_categorization_control_possibilities,
absolute_region_power_index,
power_categories,
category_balances);
/* Adjust absolute_region_category_index[] for mag_shift.
This assumes that REGION_POWER_STEPSIZE_DB is defined
to be exactly 3.010299957 or 20.0 times log base 10
of square root of 2. */
mag_shift_offset = (mag_shift << 1) + REGION_POWER_TABLE_NUM_NEGATIVES;
for (region = 0; region < number_of_regions; region++)
absolute_region_power_index[region] += mag_shift_offset;
/* Adjust the absolute power region index based on the mlt coefs */
adjust_abs_region_power_index(absolute_region_power_index, mlt_coefs, number_of_regions);
/* Quantize and code the mlt coefficients based on categorizations */
vector_quantize_mlts(number_of_available_bits,
number_of_regions,
num_categorization_control_possibilities,
mlt_coefs,
absolute_region_power_index,
power_categories,
category_balances,
&categorization_control,
region_mlt_bit_counts,
region_mlt_bits);
/* Stuff bits into words */
bits_to_words(s,
region_mlt_bits,
region_mlt_bit_counts,
drp_num_bits,
drp_code_bits,
g722_1_data,
categorization_control,
number_of_regions,
num_categorization_control_bits,
number_of_bits_per_frame);
}
/*- End of function --------------------------------------------------------*/
/* Adjust the absolute power index */
void adjust_abs_region_power_index(int16_t *absolute_region_power_index,
int16_t *mlt_coefs,
int16_t number_of_regions)
{
int16_t n;
int16_t i;
int16_t region;
int16_t *raw_mlt_ptr;
int32_t acca;
int16_t temp;
for (region = 0; region < number_of_regions; region++)
{
n = sub(absolute_region_power_index[region], 39);
n = shr(n, 1);
if (n > 0)
{
temp = (int16_t) L_mult0(region, REGION_SIZE);
raw_mlt_ptr = &mlt_coefs[temp];
for (i = 0; i < REGION_SIZE; i++)
{
acca = L_shl(*raw_mlt_ptr, 16);
acca = L_add(acca, 32768L);
acca = L_shr(acca, n);
acca = L_shr(acca, 16);
*raw_mlt_ptr++ = (int16_t) acca;
}
temp = sub(absolute_region_power_index[region], shl(n, 1));
absolute_region_power_index[region] = temp;
}
}
}
/*- End of function --------------------------------------------------------*/
/* Compute the power for each of the regions */
static int16_t compute_region_powers(int16_t *mlt_coefs,
int16_t mag_shift,
int16_t *drp_num_bits,
uint16_t *drp_code_bits,
int16_t *absolute_region_power_index,
int16_t number_of_regions)
{
int16_t *input_ptr;
int32_t long_accumulator;
int16_t itemp1;
int16_t power_shift;
int16_t region;
int16_t j;
int16_t differential_region_power_index[MAX_NUMBER_OF_REGIONS];
int16_t number_of_bits;
int32_t acca;
int16_t temp;
int16_t temp1;
int16_t temp2;
input_ptr = mlt_coefs;
for (region = 0; region < number_of_regions; region++)
{
long_accumulator = 0;
for (j = 0; j < REGION_SIZE; j++)
{
itemp1 = *input_ptr++;
long_accumulator = L_mac0(long_accumulator, itemp1, itemp1);
}
power_shift = 0;
acca = long_accumulator & 0x7FFF0000L;
while (acca > 0)
{
long_accumulator = L_shr(long_accumulator, 1);
acca = long_accumulator & 0x7FFF0000L;
power_shift = add(power_shift, 1);
}
acca = L_sub(long_accumulator, 32767);
temp = add(power_shift, 15);
while (acca <= 0 && temp >= 0)
{
long_accumulator = L_shl(long_accumulator, 1);
acca = L_sub(long_accumulator, 32767);
power_shift--;
temp = add(power_shift, 15);
}
long_accumulator = L_shr(long_accumulator, 1);
/* 28963 corresponds to square root of 2 times REGION_SIZE(20). */
acca = L_sub(long_accumulator, 28963);
if (acca >= 0)
power_shift = add(power_shift, 1);
acca = mag_shift;
acca = L_shl(acca, 1);
acca = L_sub(power_shift, acca);
acca = L_add(35, acca);
acca = L_sub(acca, REGION_POWER_TABLE_NUM_NEGATIVES);
absolute_region_power_index[region] = (int16_t) acca;
}
/* Before we differentially encode the quantized region powers, adjust upward the
valleys to make sure all the peaks can be accurately represented. */
temp = sub(number_of_regions, 2);
for (region = temp; region >= 0; region--)
{
temp1 = sub(absolute_region_power_index[region + 1], DRP_DIFF_MAX);
temp2 = sub(absolute_region_power_index[region], temp1);
if (temp2 < 0)
absolute_region_power_index[region] = temp1;
}
/* The MLT is currently scaled too low by the factor
ENCODER_SCALE_FACTOR(=18318)/32768 * (1./sqrt(160).
This is the ninth power of 1 over the square root of 2.
So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9)
to drp_code_bits[0]. */
/* drp_code_bits[0] can range from 1 to 31. 0 is used only as an escape sequence. */
temp1 = sub(1, ESF_ADJUSTMENT_TO_RMS_INDEX);
temp2 = sub(absolute_region_power_index[0], temp1);
if (temp2 < 0)
absolute_region_power_index[0] = temp1;
temp1 = sub(31, ESF_ADJUSTMENT_TO_RMS_INDEX);
temp2 = sub(absolute_region_power_index[0], temp1);
if (temp2 > 0)
absolute_region_power_index[0] = temp1;
differential_region_power_index[0] = absolute_region_power_index[0];
number_of_bits = 5;
drp_num_bits[0] = 5;
drp_code_bits[0] = (uint16_t) add(absolute_region_power_index[0], ESF_ADJUSTMENT_TO_RMS_INDEX);
/* Lower limit the absolute region power indices to -8 and upper limit them to 31. Such extremes
may be mathematically impossible anyway. */
for (region = 1; region < number_of_regions; region++)
{
temp1 = -8 - ESF_ADJUSTMENT_TO_RMS_INDEX;
if (absolute_region_power_index[region] < temp1)
absolute_region_power_index[region] = temp1;
temp1 = 31 - ESF_ADJUSTMENT_TO_RMS_INDEX;
if (absolute_region_power_index[region] > temp1)
absolute_region_power_index[region] = temp1;
}
for (region = 1; region < number_of_regions; region++)
{
j = sub(absolute_region_power_index[region], absolute_region_power_index[region - 1]);
if (j < DRP_DIFF_MIN)
j = DRP_DIFF_MIN;
j -= DRP_DIFF_MIN;
differential_region_power_index[region] = j;
temp = absolute_region_power_index[region - 1] + differential_region_power_index[region];
temp += DRP_DIFF_MIN;
absolute_region_power_index[region] = temp;
number_of_bits += differential_region_power_bits[region][j];
drp_num_bits[region] = differential_region_power_bits[region][j];
drp_code_bits[region] = differential_region_power_codes[region][j];
}
return number_of_bits;
}
/*- End of function --------------------------------------------------------*/
/* Scalar quantized vector Huffman coding (SQVH) */
static void vector_quantize_mlts(int16_t number_of_available_bits,
int16_t number_of_regions,
int16_t num_categorization_control_possibilities,
int16_t *mlt_coefs,
int16_t *absolute_region_power_index,
int16_t *power_categories,
int16_t *category_balances,
int16_t *p_categorization_control,
int16_t *region_mlt_bit_counts,
uint32_t *region_mlt_bits)
{
int16_t *raw_mlt_ptr;
int16_t region;
int16_t category;
int16_t total_mlt_bits;
int16_t temp;
total_mlt_bits = 0;
/* Start in the middle of the categorization control range. */
temp = (num_categorization_control_possibilities >> 1) - 1;
for (*p_categorization_control = 0; *p_categorization_control < temp; (*p_categorization_control)++)
{
region = category_balances[*p_categorization_control];
power_categories[region]++;
}
for (region = 0; region < number_of_regions; region++)
{
category = power_categories[region];
temp = (int16_t) L_mult0(region, REGION_SIZE);
raw_mlt_ptr = &mlt_coefs[temp];
if (category < (NUM_CATEGORIES - 1))
{
region_mlt_bit_counts[region] = vector_huffman(category,
absolute_region_power_index[region],
raw_mlt_ptr,
&region_mlt_bits[shl(region, 2)]);
}
else
{
region_mlt_bit_counts[region] = 0;
}
total_mlt_bits += region_mlt_bit_counts[region];
}
/* If too few bits... */
while (total_mlt_bits < number_of_available_bits
&&
*p_categorization_control > 0)
{
(*p_categorization_control)--;
region = category_balances[*p_categorization_control];
power_categories[region]--;
total_mlt_bits -= region_mlt_bit_counts[region];
category = power_categories[region];
raw_mlt_ptr = &mlt_coefs[region*REGION_SIZE];
if (category < (NUM_CATEGORIES - 1))
{
region_mlt_bit_counts[region] = vector_huffman(category,
absolute_region_power_index[region],
raw_mlt_ptr,
&region_mlt_bits[shl(region, 2)]);
}
else
{
region_mlt_bit_counts[region] = 0;
}
total_mlt_bits += region_mlt_bit_counts[region];
}
/* If too many bits... */
/* Set up for while loop test */
while (total_mlt_bits > number_of_available_bits
&&
*p_categorization_control < (num_categorization_control_possibilities - 1))
{
region = category_balances[*p_categorization_control];
power_categories[region]++;
total_mlt_bits -= region_mlt_bit_counts[region];
category = power_categories[region];
temp = (int16_t) L_mult0(region, REGION_SIZE);
raw_mlt_ptr = &mlt_coefs[temp];
if (category < (NUM_CATEGORIES - 1))
{
region_mlt_bit_counts[region] = vector_huffman(category,
absolute_region_power_index[region],
raw_mlt_ptr,
&region_mlt_bits[shl(region, 2)]);
}
else
{
region_mlt_bit_counts[region] = 0;
}
total_mlt_bits += region_mlt_bit_counts[region];
(*p_categorization_control)++;
}
}
/*- End of function --------------------------------------------------------*/
/* Huffman encoding for each region based on category and power_index */
static int16_t vector_huffman(int16_t category,
int16_t power_index,
int16_t *raw_mlt_ptr,
uint32_t *word_ptr)
{
int16_t inv_of_step_size_times_std_dev;
int16_t j;
int16_t n;
int16_t k;
int16_t number_of_region_bits;
int16_t number_of_non_zero;
int16_t vec_dim;
int16_t num_vecs;
int16_t kmax;
int16_t kmax_plus_one;
int16_t index,signs_index;
const int16_t *bitcount_table_ptr;
const uint16_t *code_table_ptr;
int32_t code_bits;
int16_t number_of_code_bits;
uint32_t current_word;
int16_t current_word_bits_free;
int32_t acca;
int32_t accb;
int16_t temp;
int16_t mytemp;
int16_t myacca;
/* Initialize variables */
vec_dim = vector_dimension[category];
num_vecs = number_of_vectors[category];
kmax = max_bin[category];
kmax_plus_one = add(kmax, 1);
current_word = 0L;
current_word_bits_free = 32;
number_of_region_bits = 0;
/* Set up table pointers */
bitcount_table_ptr = table_of_bitcount_tables[category];
code_table_ptr = table_of_code_tables[category];
/* Compute inverse of step size * standard deviation */
acca = L_mult(step_size_inverse_table[category], standard_deviation_inverse_table[power_index]);
acca = L_shr(acca, 1);
acca = L_add(acca, 4096);
acca = L_shr(acca, 13);
mytemp = acca & 0x3;
acca = L_shr(acca, 2);
inv_of_step_size_times_std_dev = (int16_t) acca;
for (n = 0; n < num_vecs; n++)
{
index = 0;
signs_index = 0;
number_of_non_zero = 0;
for (j = 0; j < vec_dim; j++)
{
k = abs_s(*raw_mlt_ptr);
acca = L_mult(k, inv_of_step_size_times_std_dev);
acca = L_shr(acca, 1);
myacca = (int16_t) L_mult(k, mytemp);
myacca = (int16_t) L_shr(myacca, 1);
myacca = (int16_t) L_add(myacca, int_dead_zone_low_bits[category]);
myacca = (int16_t) L_shr(myacca, 2);
acca = L_add(acca, int_dead_zone[category]);
acca = L_add(acca, myacca);
acca = L_shr(acca, 13);
k = (int16_t) acca;
if (k != 0)
{
number_of_non_zero = add(number_of_non_zero, 1);
signs_index = shl(signs_index, 1);
if (*raw_mlt_ptr > 0)
signs_index = add(signs_index, 1);
temp = sub(k, kmax);
if (temp > 0)
k = kmax;
}
acca = L_shr(L_mult(index, (kmax_plus_one)), 1);
index = (int16_t) acca;
index = add(index, k);
raw_mlt_ptr++;
}
code_bits = *(code_table_ptr + index);
number_of_code_bits = add((*(bitcount_table_ptr + index)), number_of_non_zero);
number_of_region_bits = add(number_of_region_bits, number_of_code_bits);
acca = code_bits << number_of_non_zero;
accb = signs_index;
acca = L_add(acca, accb);
code_bits = acca;
/* MSB of codebits is transmitted first. */
j = current_word_bits_free - number_of_code_bits;
if (j >= 0)
{
acca = code_bits << j;
current_word = L_add(current_word, acca);
current_word_bits_free = j;
}
else
{
j = negate(j);
acca = L_shr(code_bits, j);
current_word = L_add(current_word, acca);
*word_ptr++ = current_word;
current_word_bits_free = 32 - j;
current_word = code_bits << current_word_bits_free;
}
}
*word_ptr++ = current_word;
return number_of_region_bits;
}
/*- End of function --------------------------------------------------------*/
int g722_1_encode(g722_1_encode_state_t *s, uint8_t g722_1_data[], const int16_t amp[], int len)
{
int16_t mlt_coefs[MAX_FRAME_SIZE];
int16_t mag_shift;
int i;
int j;
for (i = 0, j = 0; i < len; i += s->frame_size, j += s->bytes_per_frame)
{
mag_shift = samples_to_rmlt_coefs(amp + i, s->history, mlt_coefs, s->frame_size);
encoder(s,
s->number_of_bits_per_frame,
s->number_of_regions,
mlt_coefs,
(uint16_t) mag_shift,
&g722_1_data[j]);
}
return j;
}
/*- End of function --------------------------------------------------------*/
#endif
int g722_1_encode_set_rate(g722_1_encode_state_t *s, int bit_rate)
{
if ((bit_rate < 16000) || (bit_rate > 48000) || ((bit_rate%800) != 0))
return -1;
s->bit_rate = bit_rate;
s->number_of_bits_per_frame = s->bit_rate/50;
s->bytes_per_frame = s->number_of_bits_per_frame/8;
return 0;
}
/*- End of function --------------------------------------------------------*/
g722_1_encode_state_t *g722_1_encode_init(g722_1_encode_state_t *s, int bit_rate, int sample_rate)
{
#if !defined(G722_1_USE_FIXED_POINT)
int i;
#endif
if ((bit_rate < 16000) || (bit_rate > 48000) || ((bit_rate%800) != 0))
return NULL;
if (sample_rate != G722_1_SAMPLE_RATE_16000 && sample_rate != G722_1_SAMPLE_RATE_32000)
return NULL;
if (s == NULL)
{
if ((s = (g722_1_encode_state_t *) malloc(sizeof(*s))) == NULL)
return NULL;
}
memset(s, 0, sizeof(*s));
#if !defined(G722_1_USE_FIXED_POINT)
for (i = 0; i < MAX_FRAME_SIZE; i++)
s->history[i] = 0.0f;
/* Scaling factor for fixed point interop */
if (sample_rate == G722_1_SAMPLE_RATE_16000)
s->scale_factor = 1.0f/INTEROP_RMLT_SCALE_FACTOR_7;
else
s->scale_factor = 1.0f/INTEROP_RMLT_SCALE_FACTOR_14;
#endif
s->sample_rate = sample_rate;
if (sample_rate == G722_1_SAMPLE_RATE_16000)
{
s->number_of_regions = NUMBER_OF_REGIONS;
s->frame_size = MAX_FRAME_SIZE >> 1;
}
else
{
s->number_of_regions = MAX_NUMBER_OF_REGIONS;
s->frame_size = MAX_FRAME_SIZE;
}
s->bit_rate = bit_rate;
s->number_of_bits_per_frame = (int16_t) ((s->bit_rate)/50);
s->bytes_per_frame = s->number_of_bits_per_frame/8;
return s;
}
/*- End of function --------------------------------------------------------*/
int g722_1_encode_release(g722_1_encode_state_t *s)
{
free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+520
View File
@@ -0,0 +1,520 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* encoder.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: encoderf.c,v 1.22 2008/11/21 15:30:22 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "huff_tab.h"
#include "tables.h"
#include "bitstream.h"
#if !defined(G722_1_USE_FIXED_POINT)
static int compute_region_powers(int number_of_regions,
float mlt_coefs[MAX_DCT_LENGTH],
int drp_num_bits[MAX_NUMBER_OF_REGIONS],
int drp_code_bits[MAX_NUMBER_OF_REGIONS],
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS]);
static int vector_huffman(int category,
int power_index,
float *raw_mlt_ptr,
int32_t *word_ptr);
static void vector_quantize_mlts(int number_of_regions,
int num_categorization_control_possibilities,
int number_of_available_bits,
float mlt_coefs[MAX_DCT_LENGTH],
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS],
int power_categories[MAX_NUMBER_OF_REGIONS],
int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1],
int *p_rate_control,
int region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS],
int32_t region_mlt_bits[4*MAX_NUMBER_OF_REGIONS]);
static void encoder(g722_1_encode_state_t *s,
int number_of_available_bits,
int number_of_regions,
float mlt_coefs[MAX_DCT_LENGTH],
uint8_t g722_1_data[MAX_BITS_PER_FRAME/8]);
/* Stuff the bits into words for output */
static void bits_to_words(g722_1_encode_state_t *s,
int32_t *region_mlt_bits,
int *region_mlt_bit_counts,
int *drp_num_bits,
int *drp_code_bits,
uint8_t *out_code,
int categorization_control,
int number_of_regions,
int num_categorization_control_bits,
int number_of_bits_per_frame)
{
int region;
int region_bit_count;
int32_t *in_word_ptr;
uint32_t current_code;
int current_bits;
int bit_count;
/* First set up the categorization control bits to look like one more set of region power bits. */
drp_num_bits[number_of_regions] = num_categorization_control_bits;
drp_code_bits[number_of_regions] = categorization_control;
bit_count = 0;
/* These code bits are right justified. */
for (region = 0; region <= number_of_regions; region++)
{
g722_1_bitstream_put(&s->bitstream, &out_code, drp_code_bits[region], drp_num_bits[region]);
bit_count += drp_num_bits[region];
}
/* These code bits are left justified. */
for (region = 0; (region < number_of_regions) && (bit_count < number_of_bits_per_frame); region++)
{
in_word_ptr = &region_mlt_bits[4*region];
region_bit_count = region_mlt_bit_counts[region];
while ((region_bit_count > 0) && (bit_count < number_of_bits_per_frame))
{
current_bits = MIN(32, region_bit_count);
current_code = *in_word_ptr++;
current_code >>= (32 - current_bits);
g722_1_bitstream_put(&s->bitstream, &out_code, current_code, current_bits);
bit_count += current_bits;
region_bit_count -= current_bits;
}
}
/* Fill out with 1's. */
while (bit_count < number_of_bits_per_frame)
{
current_bits = MIN(32, number_of_bits_per_frame - bit_count);
g722_1_bitstream_put(&s->bitstream, &out_code, 0xFFFFFFFF, current_bits);
bit_count += current_bits;
}
g722_1_bitstream_flush(&s->bitstream, &out_code);
}
/*- End of function --------------------------------------------------------*/
/* Encode the MLT coefs into out_words using G.722.1 Annex C */
static void encoder(g722_1_encode_state_t *s,
int number_of_available_bits,
int number_of_regions,
float mlt_coefs[MAX_DCT_LENGTH],
uint8_t g722_1_data[MAX_BITS_PER_FRAME/8])
{
int num_categorization_control_bits;
int num_categorization_control_possibilities;
int number_of_bits_per_frame;
int number_of_envelope_bits;
int rate_control;
int region;
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS];
int power_categories[MAX_NUMBER_OF_REGIONS];
int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1];
int drp_num_bits[MAX_NUMBER_OF_REGIONS + 1];
int drp_code_bits[MAX_NUMBER_OF_REGIONS + 1];
int region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS];
int32_t region_mlt_bits[4*MAX_NUMBER_OF_REGIONS];
/* Initialize variables. */
if (number_of_regions == NUMBER_OF_REGIONS)
{
num_categorization_control_bits = NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
}
else
{
num_categorization_control_bits = MAX_NUM_CATEGORIZATION_CONTROL_BITS;
num_categorization_control_possibilities = MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES;
}
number_of_bits_per_frame = number_of_available_bits;
/* Estimate power envelope. */
number_of_envelope_bits = compute_region_powers(number_of_regions,
mlt_coefs,
drp_num_bits,
drp_code_bits,
absolute_region_power_index);
number_of_available_bits -= number_of_envelope_bits;
number_of_available_bits -= num_categorization_control_bits;
categorize(number_of_regions,
number_of_available_bits,
absolute_region_power_index,
power_categories,
category_balances);
/* Adjust absolute_region_category_index[] for mag_shift.
This assumes that REGION_POWER_STEPSIZE_DB is defined
to be exactly 3.010299957 or 20.0 times log base 10
of square root of 2. */
for (region = 0; region < number_of_regions; region++)
{
absolute_region_power_index[region] += REGION_POWER_TABLE_NUM_NEGATIVES;
region_mlt_bit_counts[region] = 0;
}
vector_quantize_mlts(number_of_regions,
num_categorization_control_possibilities,
number_of_available_bits,
mlt_coefs,
absolute_region_power_index,
power_categories,
category_balances,
&rate_control,
region_mlt_bit_counts,
region_mlt_bits);
/* Stuff bits into words */
bits_to_words(s,
region_mlt_bits,
region_mlt_bit_counts,
drp_num_bits,
drp_code_bits,
g722_1_data,
rate_control,
number_of_regions,
num_categorization_control_bits,
number_of_bits_per_frame);
}
/*- End of function --------------------------------------------------------*/
/* Compute the power for each of the regions */
static int compute_region_powers(int number_of_regions,
float mlt_coefs[MAX_DCT_LENGTH],
int drp_num_bits[MAX_NUMBER_OF_REGIONS],
int drp_code_bits[MAX_NUMBER_OF_REGIONS],
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS])
{
float *input_ptr;
int iterations;
float ftemp0;
float ftemp1;
int index;
int index_min;
int index_max;
int region;
int j;
int differential_region_power_index[MAX_NUMBER_OF_REGIONS];
int number_of_bits;
input_ptr = mlt_coefs;
for (region = 0; region < number_of_regions; region++)
{
ftemp0 = 0.0f;
for (j = 0; j < REGION_SIZE; j++)
{
ftemp1 = *input_ptr++;
ftemp0 += ftemp1*ftemp1;
}
ftemp0 *= REGION_SIZE_INVERSE;
index_min = 0;
index_max = REGION_POWER_TABLE_SIZE;
for (iterations = 0; iterations < 6; iterations++)
{
index = (index_min + index_max) >> 1;
if (ftemp0 < region_power_table_boundary[index - 1])
index_max = index;
else
index_min = index;
}
absolute_region_power_index[region] = index_min - REGION_POWER_TABLE_NUM_NEGATIVES;
}
/* Before we differentially encode the quantized region powers, adjust upward the
valleys to make sure all the peaks can be accurately represented. */
for (region = number_of_regions - 2; region >= 0; region--)
{
if (absolute_region_power_index[region] < absolute_region_power_index[region+1] - DRP_DIFF_MAX)
absolute_region_power_index[region] = absolute_region_power_index[region+1] - DRP_DIFF_MAX;
}
/* The MLT is currently scaled too low by the factor
ENCODER_SCALE_FACTOR(=18318)/32768 * (1./sqrt(160).
This is the ninth power of 1 over the square root of 2.
So later we will add ESF_ADJUSTMENT_TO_RMS_INDEX (now 9)
to drp_code_bits[0]. */
/* drp_code_bits[0] can range from 1 to 31. 0 will be used only as an escape sequence. */
if (absolute_region_power_index[0] < 1 - ESF_ADJUSTMENT_TO_RMS_INDEX)
absolute_region_power_index[0] = 1 - ESF_ADJUSTMENT_TO_RMS_INDEX;
if (absolute_region_power_index[0] > 31 - ESF_ADJUSTMENT_TO_RMS_INDEX)
absolute_region_power_index[0] = 31 - ESF_ADJUSTMENT_TO_RMS_INDEX;
differential_region_power_index[0] = absolute_region_power_index[0];
number_of_bits = 5;
drp_num_bits[0] = 5;
drp_code_bits[0] = absolute_region_power_index[0] + ESF_ADJUSTMENT_TO_RMS_INDEX;
/* Lower limit the absolute region power indices to -8 and upper limit them to 31. Such extremes
may be mathematically impossible anyway.*/
for (region = 1; region < number_of_regions; region++)
{
if (absolute_region_power_index[region] < -8 - ESF_ADJUSTMENT_TO_RMS_INDEX)
absolute_region_power_index[region] = -8 - ESF_ADJUSTMENT_TO_RMS_INDEX;
if (absolute_region_power_index[region] > 31 - ESF_ADJUSTMENT_TO_RMS_INDEX)
absolute_region_power_index[region] = 31 - ESF_ADJUSTMENT_TO_RMS_INDEX;
}
for (region = 1; region < number_of_regions; region++)
{
j = absolute_region_power_index[region] - absolute_region_power_index[region - 1];
if (j < DRP_DIFF_MIN)
j = DRP_DIFF_MIN;
j -= DRP_DIFF_MIN;
differential_region_power_index[region] = j;
absolute_region_power_index[region] = absolute_region_power_index[region - 1]
+ differential_region_power_index[region]
+ DRP_DIFF_MIN;
number_of_bits += differential_region_power_bits[region][j];
drp_num_bits[region] = differential_region_power_bits[region][j];
drp_code_bits[region] = differential_region_power_codes[region][j];
}
return number_of_bits;
}
/*- End of function --------------------------------------------------------*/
/* Scalar quantized vector Huffman coding (SQVH) */
static void vector_quantize_mlts(int number_of_regions,
int num_categorization_control_possibilities,
int number_of_available_bits,
float mlt_coefs[MAX_DCT_LENGTH],
int absolute_region_power_index[MAX_NUMBER_OF_REGIONS],
int power_categories[MAX_NUMBER_OF_REGIONS],
int category_balances[MAX_NUM_CATEGORIZATION_CONTROL_POSSIBILITIES - 1],
int *p_rate_control,
int region_mlt_bit_counts[MAX_NUMBER_OF_REGIONS],
int32_t region_mlt_bits[4*MAX_NUMBER_OF_REGIONS])
{
float *raw_mlt_ptr;
int region;
int category;
int total_mlt_bits;
total_mlt_bits = 0;
/* Start in the middle of the rate control range. */
for (*p_rate_control = 0; *p_rate_control < ((num_categorization_control_possibilities >> 1) - 1); (*p_rate_control)++)
{
region = category_balances[*p_rate_control];
power_categories[region]++;
}
for (region = 0; region < number_of_regions; region++)
{
category = power_categories[region];
raw_mlt_ptr = &mlt_coefs[region*REGION_SIZE];
if (category < NUM_CATEGORIES - 1)
{
region_mlt_bit_counts[region] = vector_huffman(category,
absolute_region_power_index[region],
raw_mlt_ptr,
&region_mlt_bits[4*region]);
}
else
{
region_mlt_bit_counts[region] = 0;
}
total_mlt_bits += region_mlt_bit_counts[region];
}
/* If too few bits... */
while ((total_mlt_bits < number_of_available_bits) && (*p_rate_control > 0))
{
(*p_rate_control)--;
region = category_balances[*p_rate_control];
power_categories[region]--;
total_mlt_bits -= region_mlt_bit_counts[region];
category = power_categories[region];
raw_mlt_ptr = &mlt_coefs[region*REGION_SIZE];
if (category < NUM_CATEGORIES - 1)
{
region_mlt_bit_counts[region] = vector_huffman(category,
absolute_region_power_index[region],
raw_mlt_ptr,
&region_mlt_bits[4*region]);
}
else
{
region_mlt_bit_counts[region] = 0;
}
total_mlt_bits += region_mlt_bit_counts[region];
}
/* If too many bits... */
while ((total_mlt_bits > number_of_available_bits) && (*p_rate_control < num_categorization_control_possibilities - 1))
{
region = category_balances[*p_rate_control];
power_categories[region]++;
total_mlt_bits -= region_mlt_bit_counts[region];
category = power_categories[region];
raw_mlt_ptr = &mlt_coefs[region*REGION_SIZE];
if (category < NUM_CATEGORIES - 1)
{
region_mlt_bit_counts[region] = vector_huffman(category,
absolute_region_power_index[region],
raw_mlt_ptr,
&region_mlt_bits[4*region]);
}
else
{
region_mlt_bit_counts[region] = 0;
}
total_mlt_bits += region_mlt_bit_counts[region];
(*p_rate_control)++;
}
}
/*- End of function --------------------------------------------------------*/
/* Huffman encoding for each region based on category and power_index */
static int vector_huffman(int category,
int power_index,
float *raw_mlt_ptr,
int32_t *word_ptr)
{
float inv_of_step_size_times_std_dev;
int j;
int n;
int k;
int number_of_region_bits;
int number_of_non_zero;
int vec_dim;
int num_vecs;
int kmax;
int kmax_plus_one;
int index;
int signs_index;
const int16_t *bitcount_table_ptr;
const uint16_t *code_table_ptr;
int code_bits;
int number_of_code_bits;
int current_word;
int current_word_bits_free;
vec_dim = vector_dimension[category];
num_vecs = number_of_vectors[category];
kmax = max_bin[category];
kmax_plus_one = kmax + 1;
current_word = 0;
current_word_bits_free = 32;
number_of_region_bits = 0;
bitcount_table_ptr = table_of_bitcount_tables[category];
code_table_ptr = table_of_code_tables[category];
inv_of_step_size_times_std_dev = step_size_inverse_table[category]
* standard_deviation_inverse_table[power_index];
for (n = 0; n < num_vecs; n++)
{
index = 0;
signs_index = 0;
number_of_non_zero = 0;
for (j = 0; j < vec_dim; j++)
{
k = (int) (fabs(*raw_mlt_ptr) * inv_of_step_size_times_std_dev + dead_zone[category]);
if (k != 0)
{
number_of_non_zero++;
signs_index <<= 1;
if (*raw_mlt_ptr > 0)
signs_index++;
if (k > kmax)
k = kmax;
}
index = index*(kmax_plus_one) + k;
raw_mlt_ptr++;
}
code_bits = *(code_table_ptr + index);
number_of_code_bits = *(bitcount_table_ptr + index) + number_of_non_zero;
number_of_region_bits += number_of_code_bits;
code_bits = (code_bits << number_of_non_zero) + signs_index;
/* MSB of codebits is transmitted first. */
j = current_word_bits_free - number_of_code_bits;
if (j >= 0)
{
current_word += code_bits << j;
current_word_bits_free = j;
}
else
{
j = -j;
current_word += code_bits >> j;
*word_ptr++ = current_word;
current_word_bits_free = 32 - j;
current_word = code_bits << current_word_bits_free;
}
}
*word_ptr++ = current_word;
return number_of_region_bits;
}
/*- End of function --------------------------------------------------------*/
int g722_1_encode(g722_1_encode_state_t *s, uint8_t g722_1_data[], const int16_t amp[], int len)
{
float mlt_coefs[MAX_FRAME_SIZE];
float famp[MAX_FRAME_SIZE];
int i;
int j;
int k;
for (i = 0, j = 0; i < len; i += s->frame_size, j += s->bytes_per_frame)
{
for (k = 0; k < s->frame_size; k++)
famp[k] = amp[k + i];
samples_to_rmlt_coefs(famp, s->history, mlt_coefs, s->frame_size);
/* This is for fixed point interop */
for (k = 0; k < s->frame_size; k++)
mlt_coefs[k] *= s->scale_factor;
encoder(s,
s->number_of_bits_per_frame,
s->number_of_regions,
mlt_coefs,
&g722_1_data[j]);
}
return j;
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
+31
View File
@@ -0,0 +1,31 @@
/*
* g722_1 - a library for the G.722.1 codec
*
* g722_1.h - The head guy amongst the headers
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* $Id: g722_1.h.in,v 1.1.1.1 2008/09/20 09:47:17 steveu Exp $
*/
/*! \file */
#if !defined(_G722_1_H_)
#define _G722_1_H_
@G722_1_USE_FIXED_POINT@
#include <stdlib.h>
@INSERT_INTTYPES_HEADER@
#include <string.h>
#include <limits.h>
#include <time.h>
@INSERT_MATH_HEADER@
#include <g722_1/g722_1.h>
#endif
/*- End of file ------------------------------------------------------------*/
+194
View File
@@ -0,0 +1,194 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* g722_1.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: g722_1.h,v 1.14 2008/10/17 13:18:21 steveu Exp $
*/
#if !defined(_G722_1_G722_1_H_)
#define _G722_1_G722_1_H_
typedef enum
{
/*! \brief Basic G.722.1 sampling rate */
G722_1_SAMPLE_RATE_16000 = 16000,
/*! \brief G.722.1 Annex C sampling rate */
G722_1_SAMPLE_RATE_32000 = 32000
} g722_1_sample_rates_t;
typedef enum
{
/*! \brief Bit rate usable at either sampling rate. */
G722_1_BIT_RATE_24000 = 24000,
/*! \brief Bit rate usable at either sampling rate. */
G722_1_BIT_RATE_32000 = 32000,
/*! \brief Bit rate usable at 32000 samples per second. */
G722_1_BIT_RATE_48000 = 48000
} g722_1_bit_rates_t;
#define MAX_SAMPLE_RATE 32000
/* Frames are 20ms */
#define MAX_FRAME_SIZE (MAX_SAMPLE_RATE/50)
#define MAX_DCT_LENGTH 640
/* Max bit rate is 48000 bits/sec. */
#define MAX_BITS_PER_FRAME 960
#define NUMBER_OF_REGIONS 14
#define MAX_NUMBER_OF_REGIONS 28
/*! Bitstream handler state */
typedef struct
{
/*! The bit stream. */
uint32_t bitstream;
/*! The residual bits in bitstream. */
int residue;
} g722_1_bitstream_state_t;
typedef struct
{
int16_t code_bit_count; /* bit count of the current word */
int16_t current_word; /* current word in the bitstream being processed */
uint16_t *code_word_ptr; /* pointer to the bitstream */
} g722_1_bitstream_t;
typedef struct
{
int16_t seed0;
int16_t seed1;
int16_t seed2;
int16_t seed3;
} g722_1_rand_t;
typedef struct
{
int bit_rate;
int sample_rate;
int frame_size;
int number_of_regions;
int number_of_bits_per_frame;
int bytes_per_frame;
int number_of_16bit_words_per_frame;
#if defined(G722_1_USE_FIXED_POINT)
int16_t history[MAX_FRAME_SIZE];
#else
float history[MAX_FRAME_SIZE];
float scale_factor;
#endif
g722_1_bitstream_state_t bitstream;
} g722_1_encode_state_t;
typedef struct
{
int bit_rate;
int sample_rate;
int frame_size;
int number_of_regions;
int number_of_bits_per_frame;
int bytes_per_frame;
int number_of_16bit_words_per_frame;
int16_t words;
int16_t old_mag_shift;
#if defined(G722_1_USE_FIXED_POINT)
int16_t old_decoder_mlt_coefs[MAX_DCT_LENGTH];
int16_t old_samples[MAX_DCT_LENGTH >> 1];
#else
float old_decoder_mlt_coefs[MAX_DCT_LENGTH];
float old_samples[MAX_DCT_LENGTH >> 1];
#endif
g722_1_bitstream_t bitobj;
g722_1_bitstream_state_t bitstream;
const uint8_t *code_ptr;
int16_t number_of_bits_left;
g722_1_rand_t randobj;
} g722_1_decode_state_t;
#if defined(__cplusplus)
extern "C"
{
#endif
/*! Initialise a G.722.1 encode context.
\param s The G.722.1 encode context.
\param bit_rate The required bit rate for the G.722.1 data.
The valid rates are 48000, 32000 and 24000.
\param sample_rate The required sampling rate.
The valid rates are 16000 and 32000.
\return A pointer to the G.722.1 encode context, or NULL for error. */
g722_1_encode_state_t *g722_1_encode_init(g722_1_encode_state_t *s, int bit_rate, int sample_rate);
/*! Release a G.722.1 encode context.
\param s The G.722.1 encode context.
\return 0. */
int g722_1_encode_release(g722_1_encode_state_t *s);
/*! Encode a buffer of linear PCM data to G.722.1
\param s The G.722.1 encode context.
\param g722_1_data The G.722.1 data produced.
\param amp The audio sample buffer.
\param len The number of samples in the buffer.
\return The number of bytes of G.722.1 data produced. */
int g722_1_encode(g722_1_encode_state_t *s, uint8_t g722_1_data[], const int16_t amp[], int len);
/*! Change the bit rate for an G.722.1 decode context.
\param s The G.722.1 decode context.
\param bit_rate The required bit rate for the G.722.1 data.
The valid rates are 48000, 32000 and 24000.
\return 0 for OK, or -1 for a bad parameter. */
int g722_1_encode_set_rate(g722_1_encode_state_t *s, int bit_rate);
/*! Initialise a G.722.1 decode context.
\param s The G.722.1 decode context.
\param bit_rate The required bit rate for the G.722.1 data.
The valid rates are 48000, 32000 and 24000.
\param sample_rate The required sampling rate.
The valid rates are 16000 and 32000.
\return A pointer to the G.722.1 decode context, or NULL for error. */
g722_1_decode_state_t *g722_1_decode_init(g722_1_decode_state_t *s, int bit_rate, int sample_rate);
/*! Release a G.722.1 decode context.
\param s The G.722.1 decode context.
\return 0. */
int g722_1_decode_release(g722_1_decode_state_t *s);
/*! Decode a buffer of G.722.1 data to linear PCM.
\param s The G.722.1 decode context.
\param amp The audio sample buffer.
\param g722_1_data
\param len
\return The number of samples returned. */
int g722_1_decode(g722_1_decode_state_t *s, int16_t amp[], const uint8_t g722_1_data[], int len);
/*! Produce linear PCM data to fill in where received G.722.1 data is missing.
\param s The G.722.1 decode context.
\param amp The audio sample buffer.
\param g722_1_data
\param len
\return The number of samples returned. */
int g722_1_fillin(g722_1_decode_state_t *s, int16_t amp[], const uint8_t g722_1_data[], int len);
/*! Change the bit rate for an G.722.1 decode context.
\param s The G.722.1 decode context.
\param bit_rate The required bit rate for the G.722.1 data.
The valid rates are 48000, 32000 and 24000.
\return 0 for OK, or -1 for a bad parameter. */
int g722_1_decode_set_rate(g722_1_decode_state_t *s, int bit_rate);
#if defined(__cplusplus)
}
#endif
#endif
/*- End of file ------------------------------------------------------------*/
+25
View File
@@ -0,0 +1,25 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* version.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: version.h.in,v 1.2 2008/09/20 16:52:51 steveu Exp $
*/
#if !defined(_G722_1_VERSION_H_)
#define _G722_1_VERSION_H_
/* The date and time of the version are in UTC form. */
#define G722_1_RELEASE_DATE 20081121
#define G722_1_RELEASE_TIME 153216
#endif
/*- End of file ------------------------------------------------------------*/
+25
View File
@@ -0,0 +1,25 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* version.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: version.h.in,v 1.2 2008/09/20 16:52:51 steveu Exp $
*/
#if !defined(_G722_1_VERSION_H_)
#define _G722_1_VERSION_H_
/* The date and time of the version are in UTC form. */
#define G722_1_RELEASE_DATE $G722_1_RELEASE_DATE
#define G722_1_RELEASE_TIME $G722_1_RELEASE_TIME
#endif
/*- End of file ------------------------------------------------------------*/
+630
View File
@@ -0,0 +1,630 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* huff_tab.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: huff_tab.c,v 1.7 2008/09/30 14:06:40 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "huff_tab.h"
const int16_t differential_region_power_bits[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS] =
{
{99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99},
{ 4, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 5, 7, 8, 9, 11, 11, 12, 12, 12, 12},
{10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 7, 9, 11, 12, 13, 15, 15, 15, 16, 16},
{12, 10, 8, 6, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 5, 5, 7, 9, 11, 13, 14, 14},
{13, 10, 9, 9, 7, 7, 5, 5, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 9, 11, 13, 13, 13},
{12, 13, 10, 8, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 6, 7, 9, 11, 14, 14},
{12, 11, 9, 8, 8, 7, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 7, 8, 10, 13, 14, 14},
{15, 16, 15, 12, 10, 8, 6, 5, 4, 3, 3, 3, 2, 3, 4, 5, 5, 7, 9, 11, 13, 16, 16, 16},
{14, 14, 11, 10, 9, 7, 7, 5, 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 9, 9, 12, 14, 15, 15},
{ 9, 9, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 13},
{14, 12, 10, 8, 6, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 8, 8, 9, 11, 14, 14, 14},
{13, 10, 9, 8, 6, 6, 5, 4, 4, 4, 3, 3, 2, 3, 4, 5, 6, 8, 9, 9, 11, 12, 14, 14},
{16, 13, 12, 11, 9, 6, 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 7, 8, 10, 14, 16, 16, 16},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14},
{13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}
};
const uint16_t differential_region_power_codes[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 38, 18, 10, 7, 6, 3, 2, 0, 1, 7, 6, 5, 4, 11, 78, 158, 318, 1278, 1279, 2552, 2553, 2554, 2555},
{ 36, 8, 3, 5, 0, 1, 7, 6, 4, 3, 2, 5, 3, 4, 5, 19, 74, 150, 302, 1213, 1214, 1215, 2424, 2425},
{ 2582, 644, 160, 41, 5, 11, 7, 5, 4, 1, 0, 6, 4, 7, 3, 6, 4, 21, 81, 323, 1290, 5167, 10332, 10333},
{ 2940, 366, 181, 180, 47, 46, 27, 10, 8, 5, 1, 0, 3, 7, 4, 9, 12, 26, 44, 182, 734, 2941, 2942, 2943},
{ 3982, 7967, 994, 249, 63, 26, 19, 18, 14, 8, 6, 1, 0, 2, 5, 7, 12, 30, 27, 125, 496, 1990, 15932, 15933},
{ 3254, 1626, 407, 206, 202, 100, 30, 14, 3, 5, 3, 0, 2, 4, 2, 13, 24, 31, 102, 207, 812, 6511, 13020, 13021},
{ 1110, 2216, 1111, 139, 35, 9, 3, 20, 11, 4, 2, 1, 3, 3, 1, 0, 21, 5, 16, 68, 276, 2217, 2218, 2219},
{ 1013, 1014, 127, 62, 29, 6, 4, 16, 0, 1, 3, 2, 3, 1, 5, 9, 17, 5, 28, 30, 252, 1015, 2024, 2025},
{ 381, 380, 372, 191, 94, 44, 16, 10, 7, 3, 1, 0, 2, 6, 9, 17, 45, 92, 187, 746, 1494, 2991, 5980, 5981},
{ 3036, 758, 188, 45, 43, 10, 4, 3, 6, 4, 2, 0, 3, 7, 11, 20, 42, 44, 46, 95, 378, 3037, 3038, 3039},
{ 751, 92, 45, 20, 26, 4, 12, 7, 4, 0, 4, 1, 3, 5, 5, 3, 27, 21, 44, 47, 186, 374, 1500, 1501},
{45572U, 5697, 2849, 1425, 357, 45, 23, 6, 10, 7, 2, 2, 3, 0, 4, 6, 7, 88, 179, 713, 11392, 45573U, 45574U, 45575U},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021},
{ 2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}
};
const int16_t differential_region_power_decoder_tree[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS - 1][2] =
{
{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}},
{{ 1, 2}, { 3, 4}, { 5, 6}, { 7, 8}, { 9, 10}, { 11,-12}, {-11,-10}, { -8, -9}, { -7, -6}, {-13, 12}, { -5, -4}, { 0, 13}, { -3,-14}, { -2, 14}, { -1, 15}, {-15, 16}, {-16, 17}, {-17, 18}, { 19, 20}, { 21, 22}, {-18,-19}, {-20,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, { 7, 8}, {-10, -9}, { -8,-11}, { -7, -6}, { 9, -5}, { 10,-12}, { -4, 11}, {-13, -3}, { 12, -2}, { 13,-14}, { -1, 14}, { 15,-15}, { 0, 16}, {-16, 17}, {-17, 18}, {-18, 19}, { 20, 21}, { 22,-19}, {-20,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, { 7, 8}, { 9, 10}, {-12, 11}, {-11,-13}, {-10, -9}, { 12,-14}, { -8, -7}, {-15, -6}, { 13, -5}, {-16, -4}, { 14,-17}, { 15, -3}, { 16,-18}, { -2, 17}, { 18,-19}, { -1, 19}, {-20, 20}, { 0, 21}, { 22,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, {-11,-10}, { 7,-12}, { 8, -9}, { 9,-13}, {-14, 10}, { -8,-15}, {-16, 11}, { -7, 12}, {-17, -6}, { 13, 14}, {-18, 15}, { -5, -4}, { 16, 17}, { -3, -2}, {-19, 18}, { -1, 19}, {-20, 20}, { 21, 22}, { 0,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, {-12,-11}, {-13, 7}, { 8,-14}, {-10, 9}, { 10,-15}, { -9, 11}, { -8, 12}, {-16, 13}, { -7, -6}, {-17, 14}, { -5,-18}, { 15, -4}, { 16,-19}, { 17, -3}, {-20, 18}, { -2, 19}, {-21, 20}, { 0, 21}, { 22, -1}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, {-11, 7}, {-12,-10}, {-13, -9}, { 8, 9}, {-14, -8}, { 10,-15}, { -7, 11}, {-16, 12}, { -6,-17}, { 13, 14}, { -5, 15}, {-18, 16}, { -4, 17}, { -3,-19}, { 18, -2}, {-20, 19}, { -1, 20}, { 0, 21}, { 22,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5,-12}, { 6,-11}, {-10,-13}, { -9, 7}, { 8,-14}, { 9, -8}, {-15, 10}, { -7,-16}, { 11, -6}, { 12,-17}, { 13, -5}, {-18, 14}, { 15, -4}, {-19, 16}, { 17, -3}, {-20, 18}, { 19, 20}, { 21, 22}, { 0, -2}, { -1,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5,-12}, { 6,-13}, {-11,-10}, { 7,-14}, { 8, -9}, { 9,-15}, { -8, 10}, { -7,-16}, { 11, 12}, { -6,-17}, { -5, 13}, { 14, 15}, {-18, -4}, {-19, 16}, { -3, 17}, { 18, -2}, {-20, 19}, { 20, 21}, { 22, 0}, { -1,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, {-11,-10}, {-12, -9}, { 7, 8}, {-13, -8}, { 9,-14}, { -7, 10}, { -6,-15}, { 11, 12}, { -5,-16}, { 13, 14}, {-17, 15}, { -4, 16}, { 17,-18}, { 18, -3}, { -2, 19}, { -1, 0}, {-19, 20}, {-20, 21}, { 22,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5, 6}, {-11, 7}, {-10,-12}, { -9, 8}, { -8,-13}, { 9, -7}, { 10,-14}, { -6, 11}, {-15, 12}, { -5, 13}, {-16, -4}, { 14, 15}, {-17, -3}, {-18, 16}, { 17,-19}, { -2, 18}, {-20, 19}, { -1, 20}, { 21, 22}, { 0,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5,-12}, { 6,-11}, { 7, 8}, {-10,-13}, { -9, 9}, { -8,-14}, { 10, -7}, { 11,-15}, { -6, 12}, { -5, 13}, { -4,-16}, { 14, 15}, { -3,-17}, { 16, 17}, {-18, -2}, { 18,-19}, { -1, 19}, {-20, 20}, {-21, 21}, { 22, 0}, {-22,-23}},
{{ 1, 2}, { 3, 4}, { 5,-12}, {-13, 6}, {-11, 7}, {-14, 8}, {-10, 9}, {-15, -9}, { -8, 10}, { -7,-16}, { 11, -6}, { 12, -5}, {-17, 13}, { 14,-18}, { 15, -4}, { 16,-19}, { 17, -3}, { 18, -2}, { 19, -1}, {-20, 20}, { 21, 22}, { 0,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}},
{{ 1, 2}, { 3, 4}, {-12, 5}, {-11,-13}, { 6,-14}, {-10, 7}, { 8,-15}, { -9, 9}, {-16, 10}, { -8,-17}, { 11, 12}, { -7,-18}, { -6, 13}, { 14, -5}, { 15,-19}, { -4, 16}, {-20, 17}, { 18, 19}, { 20, 21}, { 22, 0}, { -1, -3}, { -2,-21}, {-22,-23}}
};
#if defined(G722_1_USE_FIXED_POINT)
const int16_t mlt_quant_centroid[NUM_CATEGORIES][MAX_NUM_BINS] =
{
{ 0, 1606, 3119, 4586, 6049, 7502, 8941, 10406, 11851, 13292, 14736, 16146, 17566, 19351, 0, 0},
{ 0, 2229, 4341, 6401, 8471, 10531, 12583, 14588, 16673, 18924, 0, 0, 0, 0, 0, 0},
{ 0, 3055, 5998, 8929, 11806, 14680, 17680, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 4121, 8192, 12259, 16322, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 5413, 11071, 16315, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 6785, 14300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 8044, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 8019, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
#else
const float mlt_quant_centroid[NUM_CATEGORIES - 1][MAX_NUM_BINS] =
{
{ 0.0f, 0.392f, 0.761f, 1.120f, 1.477f, 1.832f, 2.183f, 2.541f, 2.893f, 3.245f, 3.598f, 3.942f, 4.288f, 4.724f, 0.0f, 0.0f},
{ 0.0f, 0.544f, 1.060f, 1.563f, 2.068f, 2.571f, 3.072f, 3.562f, 4.070f, 4.620f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{ 0.0f, 0.746f, 1.464f, 2.180f, 2.882f, 3.584f, 4.316f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{ 0.0f, 1.006f, 2.000f, 2.993f, 3.985f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{ 0.0f, 1.321f, 2.703f, 3.983f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{ 0.0f, 1.657f, 3.491f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
{ 0.0f, 1.964f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}
};
#endif
const int16_t expected_bits_table[NUM_CATEGORIES] =
{
52, 47, 43, 37, 29, 22, 16, 0
};
const int16_t mlt_sqvh_bitcount_category_0[196] =
{
1, 4, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 11, 11, 4, 5,
6, 7, 7, 8, 8, 9, 9, 9, 9, 10, 11, 11, 5, 6, 7, 8,
8, 9, 9, 9, 9, 10, 10, 10, 11, 12, 6, 7, 8, 9, 9, 9,
9, 10, 10, 10, 10, 11, 12, 13, 7, 7, 8, 9, 9, 9, 10, 10,
10, 10, 11, 11, 12, 13, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
11, 12, 13, 14, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13,
13, 15, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 14, 15,
9, 9, 9, 10, 10, 10, 11, 11, 12, 13, 12, 14, 15, 16, 9, 9,
10, 10, 10, 10, 11, 12, 12, 14, 14, 16, 16, 16, 9, 9, 10, 10,
11, 11, 12, 13, 13, 14, 14, 15, 15, 16, 10, 10, 10, 11, 11, 12,
12, 13, 15, 15, 16, 14, 15, 15, 11, 11, 11, 12, 13, 13, 13, 15,
16, 16, 16, 16, 14, 15, 11, 11, 12, 13, 13, 14, 15, 16, 16, 16,
16, 16, 16, 14
};
const uint16_t mlt_sqvh_code_category_0[196] =
{
1, 2, 1, 24, 14, 51, 9, 68, 110, 26, 218, 54, 154, 761, 3, 10,
22, 8, 58, 22, 71, 16, 30, 50, 213, 75, 94, 632, 15, 18, 52, 23,
107, 5, 54, 63, 239, 46, 276, 271, 851, 252, 28, 10, 12, 1, 22, 133,
191, 55, 105, 278, 317, 554, 310, 276, 32, 50, 94, 20, 187, 219, 13, 268,
473, 445, 145, 849, 1277, 623, 1, 14, 0, 55, 238, 121, 120, 269, 318, 530,
639, 1117, 509, 556, 24, 78, 51, 153, 62, 308, 16, 25, 68, 1058, 428, 277,
2233, 1114, 92, 108, 141, 223, 270, 381, 24, 212, 760, 35, 1063, 279, 1717, 3439,
7, 21, 152, 73, 309, 310, 95, 944, 1890, 2232, 1891, 5107, 10213, 4981, 61, 62,
9, 79, 474, 475, 848, 1059, 1056, 1716, 139, 4978, 4983, 4983, 140, 186, 76, 444,
144, 633, 1057, 838, 2237, 4472, 4473, 10212, 10212, 4983, 74, 78, 311, 213, 850, 1062,
1119, 508, 276, 277, 4982, 4473, 10212, 10212, 208, 70, 555, 418, 68, 510, 2552, 1115,
4980, 4979, 4982, 4982, 4473, 10212, 215, 71, 253, 511, 839, 1718, 2488, 6876, 6877, 4979,
4979, 4982, 4982, 4473
};
const int16_t mlt_sqvh_bitcount_category_1[100] =
{
1, 4, 5, 6, 7, 8, 8, 9, 10, 10, 4, 5, 6, 7, 7, 8,
8, 9, 9, 11, 5, 5, 6, 7, 8, 8, 9, 9, 10, 11, 6, 6,
7, 8, 8, 9, 9, 10, 11, 12, 7, 7, 8, 8, 9, 9, 10, 11,
11, 13, 8, 8, 8, 9, 9, 10, 10, 11, 12, 14, 8, 8, 8, 9,
10, 11, 11, 12, 13, 15, 9, 9, 9, 10, 11, 12, 12, 14, 14, 14,
9, 9, 9, 10, 11, 12, 14, 16, 14, 14, 10, 10, 11, 12, 13, 14,
16, 16, 16, 14
};
const uint16_t mlt_sqvh_code_category_1[100] =
{
1, 2, 11, 27, 31, 9, 120, 31, 275, 310, 1, 0, 12, 5, 33, 54,
102, 111, 246, 448, 10, 14, 31, 39, 59, 100, 114, 202, 485, 969, 24, 26,
36, 52, 103, 30, 120, 242, 69, 1244, 35, 32, 14, 61, 113, 117, 233, 486,
487, 2491, 13, 12, 69, 110, 149, 35, 495, 449, 1978, 7751, 76, 75, 122, 136,
213, 68, 623, 930, 3959, 9961, 115, 16, 107, 225, 424, 850, 1936, 7916, 4981, 4981,
148, 154, 243, 407, 988, 851, 7750,19920, 7916, 4981, 406, 274, 464, 931, 3874, 7917,
19921,19920,19920, 7916
};
const int16_t mlt_sqvh_bitcount_category_2[49] =
{
1, 4, 5, 7, 8, 9, 10, 3, 4, 5, 7, 8, 9, 10, 5, 5,
6, 7, 8, 10, 10, 7, 6, 7, 8, 9, 10, 12, 8, 8, 8, 9,
10, 12, 14, 8, 9, 9, 10, 11, 15, 16, 9, 10, 11, 12, 13, 16,
15
};
const uint16_t mlt_sqvh_code_category_2[49] =
{
1, 0, 10, 11, 28, 62, 363, 3, 2, 9, 8, 24, 53, 352, 7, 8,
13, 25, 89, 74, 355, 10, 23, 24, 29, 55, 354, 1449, 25, 19, 30, 52,
108, 438, 5793, 91, 36, 63, 353, 725, 11584, 23170, 180, 75, 218, 439, 2897, 23171,
11584
};
const int16_t mlt_sqvh_bitcount_category_3[625] =
{
2, 4, 6, 8, 10, 5, 5, 6, 8, 10, 7, 8, 8, 10, 12, 9,
9, 10, 12, 15, 10, 11, 13, 16, 16, 5, 6, 8, 10, 11, 5, 6,
8, 10, 12, 7, 7, 8, 10, 13, 9, 9, 10, 12, 15, 12, 11, 13,
16, 16, 7, 9, 10, 12, 15, 7, 8, 10, 12, 13, 9, 9, 11, 13,
16, 11, 11, 12, 14, 16, 12, 12, 14, 16, 14, 9, 11, 12, 16, 16,
9, 10, 13, 15, 16, 10, 11, 12, 16, 16, 13, 13, 16, 16, 16, 16,
16, 15, 16, 16, 11, 13, 16, 16, 15, 11, 13, 15, 16, 16, 13, 13,
16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 4, 6, 8,
10, 13, 6, 6, 8, 10, 13, 9, 8, 10, 12, 16, 10, 10, 11, 15,
16, 13, 12, 14, 16, 16, 5, 6, 8, 11, 13, 6, 6, 8, 10, 13,
8, 8, 9, 11, 14, 10, 10, 12, 12, 16, 13, 12, 13, 15, 16, 7,
8, 9, 12, 16, 7, 8, 10, 12, 14, 9, 9, 10, 13, 16, 11, 10,
12, 15, 16, 13, 13, 16, 16, 15, 9, 11, 13, 16, 16, 9, 10, 12,
15, 16, 10, 11, 13, 16, 16, 13, 12, 16, 16, 16, 16, 16, 16, 16,
16, 11, 13, 16, 16, 16, 11, 13, 16, 16, 16, 12, 13, 15, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 8, 11, 13, 16, 8,
8, 10, 12, 16, 11, 10, 11, 13, 16, 12, 13, 13, 15, 16, 16, 16,
14, 16, 15, 6, 8, 10, 13, 16, 8, 8, 10, 12, 16, 10, 10, 11,
13, 16, 13, 12, 13, 16, 16, 14, 14, 14, 16, 16, 8, 9, 11, 13,
16, 8, 9, 11, 16, 14, 10, 10, 12, 15, 16, 12, 12, 13, 16, 16,
15, 16, 16, 16, 16, 10, 12, 15, 16, 16, 10, 12, 12, 14, 16, 12,
12, 13, 16, 16, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 12, 15,
15, 16, 16, 13, 13, 16, 16, 14, 14, 16, 16, 16, 16, 16, 16, 16,
16, 16, 14, 15, 16, 16, 16, 8, 10, 13, 15, 16, 10, 11, 13, 16,
16, 13, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
8, 10, 11, 15, 16, 9, 10, 12, 16, 16, 12, 12, 15, 16, 16, 16,
14, 16, 16, 16, 16, 16, 16, 16, 16, 9, 11, 14, 16, 16, 10, 11,
13, 16, 16, 14, 13, 14, 16, 16, 16, 15, 15, 16, 16, 16, 16, 16,
16, 16, 11, 13, 16, 16, 16, 11, 13, 15, 16, 16, 13, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16,
14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 9, 13, 16, 16, 16, 11, 13, 16, 16, 16, 14, 15,
16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 9, 13, 15,
15, 16, 12, 13, 14, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 11, 13, 15, 16, 16, 12, 14, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16
};
const uint16_t mlt_sqvh_code_category_3[625] =
{
3, 8, 46, 145, 228, 4, 8, 47, 28, 455, 89, 2, 180, 5, 1335, 250,
12, 644, 1311, 139, 729, 251, 870, 2172, 2211, 5, 23, 112, 334, 1469, 21, 3,
5, 111, 2014, 88, 79, 152, 124, 2685, 297, 48, 110, 1310, 149, 501, 1231, 153,
2267, 2569, 57, 13, 653, 2587, 143, 75, 124, 118, 2611, 5242, 61, 50, 253, 3633,
2216, 476, 39, 57, 1926, 2236, 2586, 1329, 1920, 2566, 1926, 296, 233, 2590, 2240, 2217,
253, 613, 867, 144, 318, 614, 252, 2589, 2242, 2218, 872, 866, 2187, 2296, 2155, 2568,
2227, 150, 2567, 2296, 199, 2686, 2160, 2290,19145, 232, 2680, 128, 2192, 2212, 2684, 793,
2281, 2223, 2242, 1934, 2165, 2146, 2291, 2296, 2222, 2189, 2187, 2296, 2296, 6, 4, 82,
725, 3632, 15, 21, 56, 599, 148, 3, 162, 42, 411, 2301, 735, 654, 930, 137,
2586, 869, 1334, 1931, 2300, 2213, 9, 22, 146, 1290, 5240, 5, 12, 53, 630, 875,
80, 9, 8, 86, 2002, 210, 117, 56, 2019, 2162, 146, 397, 868, 131, 2151, 77,
160, 365, 2610, 2252, 59, 54, 41, 2591, 1928, 226, 14, 121, 5792, 2295, 1197, 728,
408, 130, 2157, 3635, 155, 2573, 2587, 130, 314, 64, 144, 2173, 2176, 115, 30, 409,
153, 2590, 631, 26, 4787, 2221, 2174, 2683, 1863, 2572, 319, 2150, 2177, 2194, 2571, 2257,
319, 65, 145, 2251, 2156, 2161, 909, 864, 2193, 2197, 2246, 2588, 5797, 156, 2258, 2221,
2158, 2199, 2214, 2152, 319, 2188, 2264, 2572, 319, 319, 30, 117, 219, 865, 2263, 147,
127, 239, 410, 2247, 27, 324, 1468, 2681, 2180, 1328, 5241, 147, 142, 2237, 2241, 2245,
1921, 2262, 142, 41, 11, 505, 2682, 2591, 0, 26, 229, 2015, 2577, 464, 98, 87,
5243, 2166, 149, 2016, 5244, 2190, 2198, 9573,11598,11599, 2235, 2190, 144, 298, 1004, 5245,
2277, 156, 104, 254, 2560, 1922, 612, 325, 2017, 129, 2588, 2608, 1330, 871, 2144, 2145,
132, 2147, 2148, 2149, 2144, 119, 1331, 133, 2153, 2154, 211, 58, 2609, 1923, 2159, 510,
163, 5246, 2163, 2164, 1924, 134, 2167, 2168, 2168, 2169, 2170, 2171, 2168, 2168, 1332, 135,
136, 2175, 2153, 150, 873, 2178, 2179, 1923, 1925, 2181, 2182, 2183, 2163, 2184, 2185, 2186,
2168, 2168, 1924, 134, 2167, 2168, 2168, 58, 326, 2687, 138, 2191, 31, 66, 874, 2195,
2196, 151, 152, 1927, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2205,
55, 103, 1230, 140, 2215, 118, 15, 1333, 2219, 2220, 2018, 511, 141, 2224, 2225, 2226,
1929, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2229, 366, 1005, 1930, 2238, 2239, 12, 1006,
5247, 2243, 2244, 1932, 3634, 1933, 2248, 2249, 2250, 145, 146, 2253, 2253, 2254, 2255, 2256,
2253, 2253, 1291, 5793, 2259, 2260, 2261, 477, 5794, 147, 2265, 2266, 5795, 2268, 2269, 2270,
2270, 2271, 2272, 2273, 2274, 2274, 2275, 2276, 2273, 2274, 2274, 148, 2278, 2279, 2280, 2260,
1935, 2282, 2283, 2284, 2265, 2285, 2286, 2287, 2270, 2270, 2288, 2289, 2273, 2274, 2274, 2271,
2272, 2273, 2274, 2274, 233, 5796, 2292, 2293, 2294, 1292, 3724, 2297, 2298, 2299, 2000, 151,
2302, 2303, 2200, 152, 2561, 2562, 2563, 2205, 2564, 2565, 2204, 2205, 2205, 363, 154, 154,
155, 2570, 59, 3725, 2001, 2574, 2575, 2576, 157, 2578, 2579, 2224, 2580, 2581, 2582, 2583,
2229, 2584, 2585, 2228, 2229, 2229, 654, 5798, 158, 2589, 2238, 2392, 2003, 2592, 2593, 2243,
2594, 2595, 2596, 2597, 2248, 2598, 2599, 2600, 2253, 2253, 2250, 145, 146, 2253, 2253, 2601,
2602, 2603, 2604, 2260, 2605, 2606, 2607, 6336, 2265, 6337, 6338, 6339, 2270, 2270, 6340, 6341,
2273, 2274, 2274, 2271, 2272, 2273, 2274, 2274, 6342, 6343, 2259, 2260, 2260,38288U,38289U, 147,
2265, 2265, 5795, 2268, 2269, 2270, 2270, 2271, 2272, 2273, 2274, 2274, 2271, 2272, 2273, 2274,
2274
};
const int16_t mlt_sqvh_bitcount_category_4[256] =
{
2, 4, 7, 10, 4, 5, 7, 10, 7, 8, 10, 14, 11, 11, 15, 15,
4, 5, 9, 12, 5, 5, 8, 12, 8, 7, 10, 15, 11, 11, 15, 15,
7, 9, 12, 15, 8, 8, 12, 15, 10, 10, 13, 15, 14, 14, 15, 13,
11, 13, 15, 15, 11, 13, 15, 15, 14, 15, 15, 13, 15, 15, 13, 13,
4, 5, 9, 13, 5, 6, 9, 13, 9, 9, 11, 15, 14, 13, 15, 15,
4, 6, 9, 12, 5, 6, 9, 13, 9, 8, 11, 15, 13, 12, 15, 15,
7, 9, 12, 15, 7, 8, 11, 15, 10, 10, 14, 15, 14, 15, 15, 14,
10, 12, 15, 15, 11, 13, 15, 15, 15, 15, 15, 14, 15, 15, 14, 14,
6, 9, 13, 14, 8, 9, 12, 15, 12, 12, 15, 15, 15, 15, 15, 15,
7, 9, 13, 15, 8, 9, 12, 15, 11, 12, 15, 15, 15, 15, 15, 15,
9, 11, 15, 15, 9, 11, 15, 15, 14, 14, 15, 15, 15, 15, 15, 15,
14, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 14, 14, 15, 15,
9, 12, 15, 15, 12, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
10, 12, 15, 15, 12, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 15, 15, 14, 14, 15, 15
};
const uint16_t mlt_sqvh_code_category_4[256] =
{
1, 2, 4, 572, 10, 0, 69, 712, 91, 10, 46, 9182, 1426, 1430, 30172, 30194,
9, 28, 22, 2258, 16, 25, 142, 2179, 15, 111, 719, 1521, 1131, 1437, 1520, 30196,
88, 283, 3803, 30193, 13, 236, 2856, 30166, 545, 951, 5709, 1522, 3241, 9180, 30179, 5709,
1088, 4356, 30410, 30175, 1146, 377, 30162, 30163, 8715, 30176, 30165, 5709, 30197, 30184, 5709, 5709,
1, 23, 28, 5710, 26, 14, 29, 7538, 102, 103, 1429, 1524, 3237, 7060, 30401, 30201,
15, 13, 470, 3768, 24, 15, 281, 5747, 24, 181, 1128, 30206, 5711, 3531, 30156, 30158,
116, 100, 2260, 30187, 119, 234, 1764, 30171, 716, 883, 9183, 30164, 3236, 1528, 30180, 9183,
885, 2870, 1532, 30160, 1431, 5708, 30192, 30205, 30402, 30168, 30173, 9183, 30157, 30161, 9183, 9183,
54, 25, 1621, 15211, 180, 287, 2261, 30198, 808, 811, 30411, 30413, 30414, 22986, 22987, 30411,
24, 273, 376, 30159, 137, 280, 2871, 1523, 1768, 2259, 1525, 30167, 1526, 30169, 30170, 1525,
443, 1434, 1527, 30174, 474, 1769, 30177, 30178, 3238, 3239, 30181, 30181, 30182, 30183, 30181, 30181,
3240, 30185, 30186, 1527, 9181, 30188, 30189, 30177, 30190, 30191, 30181, 30181, 3238, 3239, 30181, 30181,
440, 2857, 1529, 30195, 2294, 7061, 1530, 30199, 30200, 1531, 30202, 30411, 30203, 30204, 30411, 30411,
203, 2872, 30207, 30400, 189, 11492, 30403, 30404, 30405, 30406, 30407, 1525, 30408, 30409, 1525, 1525,
8714, 1533, 30412, 1527, 1534, 1535, 30415, 30177, 30416, 30417, 30181, 30181, 3238, 3239, 30181, 30181,
30418, 30419, 1527, 1527, 30420, 30421, 30177, 30177, 3238, 3239, 30181, 30181, 3238, 3239, 30181, 30181
};
const int16_t mlt_sqvh_bitcount_category_5[243] =
{
2, 4, 8, 4, 5, 9, 9, 10, 14, 4, 6, 11, 5, 6, 12, 10,
11, 15, 9, 11, 15, 10, 13, 15, 14, 15, 6, 4, 6, 12, 6, 7,
12, 12, 12, 15, 5, 7, 13, 6, 7, 13, 12, 13, 15, 10, 12, 15,
11, 13, 15, 15, 15, 7, 8, 13, 15, 11, 12, 15, 15, 15, 7, 10,
13, 15, 12, 15, 15, 15, 15, 7, 15, 15, 7, 15, 15, 7, 6, 7,
7, 4, 5, 11, 5, 7, 12, 11, 12, 15, 6, 7, 13, 7, 8, 14,
12, 14, 15, 11, 13, 15, 12, 13, 15, 15, 15, 8, 5, 6, 13, 7,
8, 15, 12, 14, 15, 6, 8, 14, 7, 8, 15, 14, 15, 15, 12, 12,
15, 12, 13, 15, 15, 15, 8, 9, 13, 15, 12, 13, 15, 15, 15, 8,
11, 13, 15, 13, 13, 15, 15, 15, 8, 14, 15, 8, 15, 15, 8, 7,
8, 8, 8, 10, 15, 11, 12, 15, 15, 15, 7, 10, 12, 15, 12, 13,
15, 15, 15, 8, 14, 15, 7, 15, 15, 8, 7, 8, 8, 8, 12, 15,
12, 13, 15, 15, 15, 8, 11, 13, 15, 13, 15, 15, 15, 15, 8, 15,
15, 8, 15, 15, 8, 7, 8, 8, 14, 15, 6, 15, 15, 8, 7, 8,
8, 15, 15, 8, 15, 15, 8, 7, 8, 8, 6, 8, 8, 7, 8, 8,
7, 8, 8
};
const uint16_t mlt_sqvh_code_category_5[243] =
{
0, 5, 220, 10, 16, 443, 390, 391, 14333, 11, 26, 1566, 26, 54, 3135, 508,
1558, 28581, 255, 1782, 28599, 885, 6208, 28578, 14335, 28579, 54, 9, 35, 3129, 27, 68,
3537, 1562, 3568, 28610, 25, 62, 4078, 58, 118, 7763, 3107, 7758, 28563, 778, 3131, 28598,
780, 7123, 28630, 28593, 28586, 118, 243, 6210, 28614, 1018, 3567, 28601, 28611, 28570, 68, 388,
6256, 28619, 1559, 28562, 28606, 28565, 28591, 118, 28594, 28571, 62, 28618, 28590, 118, 58, 118,
118, 4, 28, 1781, 31, 60, 3134, 1938, 3882, 28574, 25, 96, 7757, 49, 126, 14244,
3883, 14334, 28613, 1769, 4077, 28602, 3106, 7756, 28582, 28621, 28566, 126, 14, 61, 4079, 61,
138, 28491, 3536, 8153, 28573, 49, 96, 12442, 119, 240, 28490, 12443, 28560, 28561, 3111, 3580,
28564, 3130, 7759, 28567, 28568, 28569, 240, 444, 6209, 28572, 3569, 6211, 28575, 28576, 28577, 138,
778, 7760, 28580, 7761, 7762, 28583, 28584, 28585, 240, 14319, 28587, 96, 28588, 28589, 240, 119,
240, 240, 139, 968, 28592, 1554, 3581, 28595, 28596, 28597, 60, 971, 3560, 28600, 3582, 7132,
28603, 28604, 28605, 126, 14332, 28607, 96, 28608, 28609, 126, 49, 126, 126, 241, 1558, 28612,
1563, 6257, 28615, 28616, 28617, 138, 1559, 7133, 28620, 6220, 28622, 28623, 28624, 28625, 240, 28626,
28627, 96, 28628, 28629, 240, 119, 240, 240, 8152, 28631, 61, 28632, 28633, 138, 61, 138,
138, 28634, 28635, 96, 28636, 28637, 240, 119, 240, 240, 49, 96, 96, 119, 240, 240,
119, 240, 240
};
const int16_t mlt_sqvh_bitcount_category_6[32] =
{
1, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8, 6, 9, 8, 10,
4, 6, 7, 8, 6, 9, 8, 11, 6, 9, 8, 10, 8, 10, 9, 11
};
const uint16_t mlt_sqvh_code_category_6[32] =
{
1, 2, 4, 2, 5, 29, 24, 101, 3, 31, 28, 105, 3, 5, 102, 424,
1, 30, 0, 107, 27, 200, 103, 806, 1, 4, 104, 402, 3, 425, 213, 807
};
const int16_t *table_of_bitcount_tables[NUM_CATEGORIES - 1] =
{
mlt_sqvh_bitcount_category_0,
mlt_sqvh_bitcount_category_1,
mlt_sqvh_bitcount_category_2,
mlt_sqvh_bitcount_category_3,
mlt_sqvh_bitcount_category_4,
mlt_sqvh_bitcount_category_5,
mlt_sqvh_bitcount_category_6
};
const uint16_t *table_of_code_tables[NUM_CATEGORIES - 1] =
{
mlt_sqvh_code_category_0,
mlt_sqvh_code_category_1,
mlt_sqvh_code_category_2,
mlt_sqvh_code_category_3,
mlt_sqvh_code_category_4,
mlt_sqvh_code_category_5,
mlt_sqvh_code_category_6
};
const int16_t mlt_decoder_tree_category_0[180][2] =
{
{ 1, 0}, { 2, 3}, { 4, 5}, { 6, 7}, { 8, 9}, { -1, -14}, { 10, 11}, { 12, 13},
{ 14, 15}, { 16, 17}, { 18, 19}, { -15, 20}, { 21, 22}, { 23, -28}, { 24, -2}, { 25, 26},
{ 27, 28}, { 29, 30}, { 31, 32}, { -29, 33}, { -16, 34}, { -3, 35}, { 36, 37}, { -42, 38},
{ 39, 40}, { 41, 42}, { 43, 44}, { -17, 45}, { -43, 46}, { 47, 48}, { -4, 49}, { -56, 50},
{ 51, 52}, { 53, 54}, { 55, 56}, { -57, -5}, { -30, 57}, { 58, 59}, { -18, 60}, { 61, -70},
{ 62, 63}, { 64, -6}, { 65, 66}, { -44, 67}, { -71, 68}, { 69, 70}, { -19, -31}, { -84, 71},
{ 72, 73}, { 74, 75}, { 76, 77}, { -7, 78}, { 79, -20}, { 80, 81}, { -85, 82}, { -98, 83},
{ -58, 84}, { 85, -32}, { -99, 86}, { -8, 87}, { 88, 89}, { -72, -45}, { 90, -33}, { 91,-112},
{ -21, 92}, { -59,-113}, { -46, 93}, { -9, 94}, { -22, 95}, { 96, 97}, { 98, 99}, { -23, -86},
{ 100, 101}, { -34, -73}, { 102,-126}, {-127, -35}, { 103, -47}, { 104, 105}, { 106, 107}, {-140,-100},
{-114, -87}, { 108, 109}, { 110, 111}, {-141, -60}, { 112, -48}, { 113, -24}, { -10, -61}, { 114,-101},
{ 115, 116}, { -74, -36}, { 117,-128}, { 118, -62}, { 119, 120}, { -37, 121}, { -11, -49}, { -88, 122},
{ 123,-115}, {-154, -25}, {-142, 124}, {-155,-129}, { 125, -50}, { 126, 127}, { -76, -75}, { 128, 129},
{ -63, -77}, {-102, -39}, { -38, 130}, { -51, 131}, { -89,-116}, {-117,-156}, { 132, -52}, { -78, 133},
{ 134,-103}, { 135, 136}, {-143, -65}, { 137, -64}, {-130,-131}, { -90, 138}, {-104, -91}, { -92, 139},
{-169,-183}, { -26,-118}, { 140, 141}, {-144, -66}, { -12, 142}, {-168, 143}, {-105,-157}, { 144,-182},
{ 145, 146}, { -79, 147}, { -53,-170}, { 148, 149}, { -27,-145}, { 150, -80}, {-106, -13}, {-132, -67},
{-158, -40}, {-119, 151}, { 152,-107}, { 153, 154}, { -41,-184}, { 155, 156}, { -54, 157}, {-171, 158},
{ -94, 159}, {-134,-146}, { -93,-133}, {-159,-108}, { 160, -81}, { 161,-160}, { 162, -68}, {-120,-122},
{-172, 163}, { -55, -95}, { 164,-109}, {-161, -82}, {-173,-185}, { 165, -69}, {-147,-186}, { 166, 167},
{-121, -96}, { 168,-148}, {-174, 169}, { 170,-136}, { -83, 171}, { 172, 173}, {-135,-110}, {-187, 174},
{-149,-150}, { 175,-123}, {-162,-163}, { -97,-175}, {-188, 176}, { 177, 178}, { 179,-111}, {-151,-124},
{-137,-177}, {-176,-125}, {-164,-138}, {-189,-190},
};
const int16_t mlt_decoder_tree_category_1[93][2] =
{
{ 1, 0}, { 2, 3}, { 4, 5}, { 6, 7}, { 8, -10}, { -1, 9}, { 10, 11}, { 12, 13},
{ -11, 14}, { 15, 16}, { 17, 18}, { -20, -2}, { 19, 20}, { -21, 21}, { 22, 23}, { -12, 24},
{ 25, 26}, { 27, 28}, { 29, 30}, { -30, 31}, { -31, -3}, { 32, -22}, { 33, -13}, { 34, 35},
{ 36, 37}, { 38, 39}, { 40, -4}, { -41, -14}, { 41, -40}, { -32, 42}, { 43, -23}, { 44, 45},
{ 46, 47}, { 48, -5}, { -51, -50}, { -42, 49}, { -33, 50}, { -15, 51}, { 52, 53}, { 54, -24},
{ 55, -43}, { 56, -52}, { 57, -61}, { -60, 58}, { -25, 59}, { -16, -34}, { -6, 60}, { -62, 61},
{ -71, 62}, { -35, -7}, { 63, -72}, { -53, -17}, { 64, -44}, { -26, -70}, { 65, -45}, { -36, 66},
{ -63, 67}, { -80, -54}, { -81, 68}, { -27, 69}, { 70, -82}, { -18, 71}, { 72, -55}, { 73, -64},
{ 74, -73}, { 75, -46}, { -37, 76}, { -91, -8}, { -9, 77}, { -90, -83}, { 78, -28}, { 79, -56},
{ -65, -38}, { -74, 80}, { -19, -57}, { -92, 81}, { -47, -48}, { 82, -66}, { 83, -29}, { -84, 84},
{ -75, -85}, { -67, -93}, { -39, 85}, { -76, 86}, { -58, 87}, { 88, -49}, { -94, 89}, { 90, -68},
{ 91, -78}, { -86, -59}, { -77, -95}, { 92, -69}, { -87, -96},
};
const int16_t mlt_decoder_tree_category_2[47][2] =
{
{ 1, 0}, { 2, 3}, { 4, 5}, { 6, -7}, { -1, 7}, { -8, 8}, { 9, 10}, { 11, 12},
{ 13, -14}, { -15, -9}, { -2, 14}, { 15, 16}, { 17, 18}, { 19, -16}, { 20, -22}, { -10, 21},
{ -21, -3}, { 22, 23}, { 24, 25}, { -23, -17}, { 26, 27}, { 28, -29}, { -11, -28}, { 29, 30},
{ -4, -24}, { -30, 31}, { 32, -18}, { 33, -35}, { -36, 34}, { -31, -12}, { 35, -25}, { -5, -37},
{ 36, 37}, { -42, 38}, { -19, -43}, { -32, 39}, { -13, -38}, { -26, -20}, { 40, -6}, { -44, 41},
{ 42, -39}, { -33, -45}, { 43, -27}, { 44, -46}, { 45, -34}, { -40, 46}, { -41, -47},
};
const int16_t mlt_decoder_tree_category_3[519][2] =
{
{ 1, 2}, { 3, 4}, { 5, 0}, { 6, 7}, { 8, 9}, { 10, 11}, { 12, 13}, { 14, 15},
{ 16, 17}, {-125, 18}, { -1, 19}, { 20, 21}, { 22, 23}, { 24, 25}, { -5, -25}, { 26, 27},
{ -6,-150}, { 28, 29}, { 30, 31}, { 32, 33}, { 34, -30}, { 35, 36}, { 37, 38}, { 39, -31},
{-126,-155}, { 40, 41}, {-156, 42}, { 43,-130}, { 44,-131}, {-151, -26}, { 45, 46}, {-250, 47},
{ 48, 49}, { 50, 51}, { 52,-275}, { 53, 54}, { -2, -7}, { 55, 56}, { 57, 58}, { 59, 60},
{ 61, 62}, { 63, 64}, { 65, 66}, { 67, 68}, { 69, 70}, { 71, -50}, { 72,-180}, { 73, 74},
{ 75, 76}, { 77, -55}, { 78,-175}, { 79, -36}, { 80, 81}, { -35, -10}, { 82, 83}, {-280, 84},
{ -11, 85}, { 86, -32}, { 87, 88}, { 89,-161}, { 90,-276}, { 91, 92}, {-281, 93}, { -8, 94},
{ 95, 96}, { 97,-157}, {-181,-400}, {-132, 98}, {-375, 99}, {-160, 100}, {-127, 101}, { -27, 102},
{ 103,-251}, { -56, 104}, { 105,-256}, {-300, -3}, {-152,-255}, { 106, 107}, { -37, 108}, {-305, 109},
{-176, 110}, {-136, 111}, { -12, 112}, { 113, 114}, { 115,-135}, { 116, 117}, {-162, 118}, { -16, -51},
{-186, 119}, { 120, 121}, { 122, 123}, { -41, 124}, { -61, 125}, { 126, 127}, { 128, 129}, { 130, -60},
{ 131, 132}, {-306, 133}, { 134,-205}, {-405, 135}, { 136, 137}, { 138, 139}, {-185, 140}, { 141,-500},
{ -15, 142}, { 143, -80}, { -75, -40}, {-301, 144}, { 145, 146}, {-200, 147}, { 148, 149}, { 150, 151},
{ 152,-525}, { 153,-177}, {-425, 154}, { 155, -13}, {-430, 156}, { 157,-406}, { 158, 159}, {-206,-380},
{ 160, 161}, { 162, 163}, { 164,-182}, {-137, 165}, {-286, 166}, { 167,-401}, { 168, 169}, { -42, -33},
{ 170,-166}, { -57,-325}, { 171,-187}, { -38, 172}, { 173, 174}, {-165,-330}, { -4,-282}, { 175,-257},
{-261,-311}, {-376, 176}, { 177, 178}, { -28, 179}, { 180, -9}, {-285, 181}, { 182, 183}, { 184,-277},
{ 185,-133}, {-310, -81}, { -85, 186}, {-158,-210}, { -17, 187}, { 188, 189}, { 190, -52}, {-141, 191},
{ 192,-128}, {-191, -20}, { 193,-140}, { 194, 195}, {-211,-260}, { 196, 197}, { 198, 199}, { 200, -66},
{-201,-225}, {-381, 201}, { 202, 203}, { 204, 205}, { 206, 207}, {-163,-287}, { 208,-100}, { 209, 210},
{ 211, 212}, { 213,-252}, {-105, -76}, { 214, 215}, { 216, -21}, { -86, -62}, {-307, 217}, { -65,-455},
{-550, 218}, { 219, 220}, { 221, 222}, { 223, 224}, { 225,-230}, {-142, 226}, {-302,-426}, {-431, 227},
{ 228, 229}, { 230,-190}, {-402, -46}, {-153,-450}, {-505, 231}, { 232, 233}, { 234, 235}, { 236, 237},
{ 238, 239}, {-262, -29}, { 240, 241}, { 242, 243}, {-167, -67}, {-331,-530}, { 244, 245}, { 246, 247},
{ 248, 249}, { 250, 251}, { 252, 253}, { 254, 255}, { 256, 257}, { 258, 259}, { 260, 261}, { 262,-336},
{ 263,-171}, {-192,-207}, {-258,-138}, { 264, 265}, { 266, 267}, { 268, 269}, { 270, 271}, { 272, 273},
{ 274, -45}, {-335,-411}, { -43, -18}, {-265, -71}, {-316,-326}, {-350,-407}, {-146, -14}, { 275, 276},
{ 277, 278}, { 279, 280}, { 281,-216}, { -34,-283}, {-291,-312}, {-410,-168}, {-555, 282}, { -70, -53},
{-235, -87}, { -77,-183}, {-315,-332}, {-178, -58}, { 283, 284}, { 285, 286}, { 287, 288}, { 289, 290},
{ 291, 292}, { 293, 294}, { 295, 296}, { 297, 298}, {-202,-226}, {-170,-267}, {-134,-290}, {-355,-385},
{-386, -47}, {-526,-196}, { 299, 300}, { 301, 302}, { 303, 304}, { 305, 306}, { 307, 308}, { 309, 310},
{ 311, 312}, { 313, 314}, { 315, 316}, { 317, 318}, { 319, 320}, { 321, 322}, { 323, 324}, { 325,-111},
{-231,-253}, { -91, -82}, {-172,-145}, { -22,-317}, { -90,-356}, {-382,-159}, { 326, 327}, { 328, 329},
{ 330, 331}, { 332, 333}, { 334, 335}, {-106,-263}, {-278,-215}, {-110, -39}, {-101,-377}, {-129, -63},
{-436,-195}, {-506,-531}, { 336,-212}, {-154,-266}, { -59,-288}, {-292,-303}, {-337,-432}, {-188,-451},
{-456,-460}, {-501,-236}, {-551, 337}, { 338, 339}, { 340, 341}, { 342, 343}, { 344, 345}, { 346, 347},
{ 348, 349}, { 350, 351}, { 352, 353}, { 354, 355}, { 356, 357}, { 358, 359}, { 360, 361}, { 362, 363},
{ 364, 365}, { 366, 367}, { 368, 369}, { 370, 371}, { 372, 373}, { 374, 375}, { 376, 377}, { 378, 379},
{ 380, 381}, { 382, 383}, { 384, 385}, { 386, 387}, { 388, 389}, { 390, 391}, { 392, 393}, { 394, 395},
{ 396, 397}, { 398, 399}, { 400, 401}, { 402, 403}, { 404, 405}, { 406, 407}, { -72,-272}, {-309,-333},
{-340,-360}, { -68,-387}, {-184,-416}, {-427,-147}, {-435,-437}, {-115,-480}, {-510,-532}, {-164,-556},
{ 408,-295}, {-296,-297}, {-107,-313}, {-193,-173}, {-320,-327}, {-341,-351}, {-352,-143}, {-378, -19},
{-403,-412}, {-268, -54}, { -83,-441}, {-442,-457}, {-475, -44}, { -97,-511}, {-515,-208}, {-527,-528},
{-237,-536}, {-552, 409}, { 410, 411}, { 412, 413}, { 414, 415}, { 416, 417}, { 418, 419}, { 420, 421},
{ 422, 423}, { 424, 425}, { 426, 427}, { 428, 429}, { 430, 431}, { 432, 433}, { 434, 435}, { 436, 437},
{ 438, 439}, { 440, 441}, { 442, 443}, { 444, 445}, { 446, 447}, { 448, 449}, { 450, 451}, { 452, 453},
{ 454, 455}, { 456, 457}, { 458, 459}, { 460, 461}, { 462, 463}, { 464, 465}, { 466, 467}, { 468, 469},
{ 470, 471}, { 472, 473}, { 474, 475}, { 476, 477}, { 478, 479}, { 480, 481}, { 482, 483}, { 484, 485},
{ 486, 487}, { 488, 489}, { 490, 491}, { 492, 493}, { 494, 495}, { 496, 497}, { 498, 499}, { 500, 501},
{ 502, 503}, { 504, 505}, { 506, 507}, { 508, 509}, { 510, 511}, { 512, 513}, { 514, 515}, { 516, 517},
{ 518,-104}, { -84,-218}, {-318,-319}, {-117,-321}, {-322,-323}, {-219,-174}, {-243,-328}, {-329, -94},
{-228,-194}, {-240,-334}, {-102,-229}, {-169,-338}, {-339,-116}, {-289,-342}, {-343,-345}, {-346,-347},
{ -23,-203}, {-214,-353}, {-204,-220}, {-357,-358}, {-264,-361}, {-362,-363}, {-365,-366}, {-367, -92},
{-245,-121}, {-293,-379}, {-108,-232}, {-221,-383}, {-384,-233}, {-294,-241}, {-388,-389}, {-390,-391},
{-392,-393}, {-394,-395}, {-396,-397}, {-398, -24}, {-109,-149}, {-242,-404}, { -64, -79}, { -89,-408},
{-409,-213}, {-120,-113}, {-413,-414}, {-415, -96}, {-417,-418}, {-419,-420}, {-421,-422}, {-423,-298},
{ -69,-269}, {-428,-429}, { -78,-270}, { -88,-433}, {-434,-271}, {-234,-259}, {-438,-439}, {-440,-227},
{-179,-443}, {-445,-446}, {-447,-223}, {-238,-452}, {-453,-454}, {-273,-254}, {-246,-458}, {-459, -48},
{-461,-462}, {-463,-465}, {-466,-467}, {-468,-470}, {-471,-304}, {-476,-477}, {-478,-112}, {-481,-482},
{-483,-485}, {-486,-487}, {-490,-491}, {-103,-118}, {-502,-503}, {-504,-189}, { -93,-507}, {-508,-509},
{-148,-139}, {-512,-513}, {-308,-516}, {-517,-518}, {-520,-521}, { -73, -98}, { -95, -49}, {-529,-222},
{-217,-197}, {-533,-534}, {-535,-284}, {-537,-538}, {-540,-541}, {-542,-543}, {-545,-546}, {-144,-198},
{-314,-553}, {-209,-279}, {-557,-558}, {-560,-561}, {-562,-563}, {-565,-566}, {-567,-575}, {-576,-577},
{-578,-580}, {-581,-582}, {-583,-585}, {-586,-587}, {-590,-591}, {-600,-601}, {-605,-606},
};
const int16_t mlt_decoder_tree_category_4[208][2] =
{
{ 1, 2}, { 3, 0}, { 4, 5}, { 6, 7}, { 8, 9}, { 10, 11}, { 12, -64}, { -1, 13},
{ 14, -16}, { -4, 15}, { 16, 17}, { 18, -80}, { -5, 19}, { 20, 21}, { -20, 22}, { 23, -65},
{ -84, -21}, { -68, 24}, { -17, 25}, { 26, 27}, { 28, -81}, { -69, -85}, { 29, 30}, { 31, 32},
{-128, 33}, { 34, 35}, { -2, 36}, { 37, 38}, {-144, 39}, { 40, -6}, { 41, 42}, { -32, 43},
{ 44, -8}, { 45, -25}, { -96, 46}, { 47,-100}, { -9, 48}, { 49, -36}, { 50, -24}, { 51, 52},
{ 53,-148}, { 54, 55}, { -22, 56}, { 57, 58}, {-132, -89}, { 59, 60}, {-101, 61}, { -37, 62},
{ -18, 63}, { -88,-129}, { -66, -70}, { -97, 64}, { -72, -73}, { 65,-145}, {-149, -86}, { 66, -33},
{ 67,-133}, { 68, 69}, { 70, 71}, {-192, 72}, { 73,-160}, { -82, 74}, {-164, 75}, { -10, 76},
{ 77,-208}, { 78, -40}, { 79, 80}, { -3, 81}, { -7, 82}, { 83, 84}, {-104, 85}, { 86, -26},
{ 87,-105}, { 88,-112}, { 89, 90}, { 91, -41}, { 92, 93}, { 94, 95}, { -48, 96}, { -90, 97},
{ 98, -28}, { -52, 99}, { -12, 100}, { 101, -74}, { -13,-116}, {-161, 102}, { 103, -29}, {-102, 104},
{-152,-165}, { 105, 106}, { 107, 108}, { 109, 110}, { 111,-212}, { 112, 113}, {-136, 114}, { 115,-137},
{ 116, -23}, { -19,-153}, { -98,-134}, {-196, 117}, { 118, 119}, { -38,-193}, {-113,-150}, {-209, 120},
{ 121, -93}, { -83, 122}, { 123, 124}, { 125, 126}, { 127, 128}, { 129, 130}, { 131, -34}, {-146, -53},
{ 132, 133}, { 134, 135}, { 136, 137}, { 138,-130}, { -49, 139}, { 140, 141}, {-117, -42}, { -67, -92},
{ 142, -87}, { -77,-197}, { -71, 143}, { 144, 145}, { 146, 147}, { 148, 149}, { 150, 151}, { 152, 153},
{ 154, 155}, { 156, 157}, { 158, 159}, { 160, 161}, { 162, 163}, { 164, 165}, { 166, 167}, { 168, 169},
{-108, -76}, {-168,-169}, {-176, -44}, {-224, -56}, { -45,-180}, { -11,-106}, {-213, 170}, { 171, 172},
{ 173, 174}, { 175, 176}, { 177, 178}, { 179, 180}, { 181, 182}, { 183, 184}, { 185, 186}, { 187, 188},
{ 189, 190}, { 191, 192}, { 193, 194}, { 195, 196}, { 197, 198}, { 199, 200}, { 201, 202}, { 203, 204},
{ 205, 206}, { 207,-131}, { -30, -27}, { -43,-151}, { -75,-154}, {-156,-162}, {-109,-194}, {-198,-201},
{-114,-225}, {-228,-229}, {-141,-142}, { -94,-124}, { -95,-147}, {-115,-125}, { -54, -55}, {-107, -58},
{ -39,-155}, {-121,-157}, {-158,-103}, { -14,-122}, {-163, -51}, { -57,-166}, {-167, -46}, {-110,-170},
{-172,-173}, { -61,-177}, {-178, -99}, {-181,-182}, {-184,-185}, {-118, -35}, { -15,-195}, { -31, -60},
{-135,-199}, {-200, -79}, {-202,-204}, {-205,-119}, { -91,-210}, {-211, -78}, {-120,-214}, {-215,-216},
{-217,-218}, {-220,-221}, { -50,-138}, {-226,-139}, {-140,-230}, {-232,-233}, {-240,-241}, {-244,-245},
};
const int16_t mlt_decoder_tree_category_5[191][2] =
{
{ 1, 2}, { 0, 3}, { 4, 5}, { 6, 7}, { 8, 9}, { 10, 11}, { -81, -1}, { 12, 13},
{ 14, -27}, { -3, -9}, { 15, 16}, { 17, 18}, { 19, 20}, {-108, 21}, { -4, 22}, { 23, -36},
{ -12, 24}, { -82, 25}, { 26, -84}, { 27, -90}, { -10, -30}, { 28, 29}, { 30, -28}, { 31,-117},
{ -13, 32}, { -39, 33}, { 34,-109}, { 35, -93}, { -85,-111}, { -37, 36}, { -31, 37}, { -91, 38},
{ 39, 40}, { -40,-120}, { 41, 42}, {-118, 43}, { -94, 44}, {-112,-162}, { 45, 46}, { -2, 47},
{ 48, 49}, {-121,-189}, { 50, -54}, { 51, 52}, { 53, -18}, { 54, 55}, { -6, 56}, { 57, -5},
{-135, 58}, { 59, 60}, { 61, 62}, { -63, 63}, { 64, -7}, { -15, 65}, { 66, 67}, { -45, 68},
{ 69, 70}, { 71, -21}, { 72, 73}, { 74, 75}, { 76, 77}, {-163, 78}, { 79,-171}, {-144, 80},
{ -48, 81}, { -57, 82}, { 83, 84}, {-165, 85}, { -16,-198}, { 86, 87}, { -11, 88}, { 89, -99},
{ 90, -83}, { -19, 91}, { 92, 93}, { 94, 95}, { 96, 97}, { 98, 99}, { -87, 100}, { 101, 102},
{-190, -66}, { -33,-192}, { 103, 104}, { 105, 106}, {-102, -42}, { 107,-126}, { 108, -29}, {-129, -46},
{ -86, -14}, {-114, -32}, {-172, 109}, { 110, -58}, { -34,-138}, { 111, 112}, { 113, 114}, { 115, 116},
{ 117, 118}, { 119, 120}, {-127,-166}, {-174, 121}, { 122, 123}, { 124, 125}, { -88, -96}, { 126,-100},
{ -38,-110}, { -22,-136}, { -55,-139}, {-201, 127}, { -64,-193}, { 128, -49}, {-175,-199}, { 129, 130},
{ 131, 132}, { 133, 134}, { 135, 136}, { 137, 138}, { 139, 140}, { 141, 142}, { 143, 144}, { 145, 146},
{ 147, 148}, { 149, 150}, {-103, -92}, { -43,-130}, {-145,-147}, {-148, -41}, {-216,-115}, {-119,-123},
{ -95, 151}, { 152, 153}, { 154, 155}, { 156, 157}, { 158, 159}, { 160, 161}, { 162, 163}, { 164, 165},
{ 166, 167}, { 168, 169}, { 170, 171}, { 172, 173}, { 174, 175}, { 176, 177}, { 178, 179}, { 180, 181},
{ 182, 183}, { 184, 185}, { 186, 187}, { 188, 189}, { 190,-153}, {-180, -8}, { -97, -24}, {-122,-113},
{-124,-125}, { -67, -44}, {-128, -69}, {-106,-131}, {-132,-133}, { -61, -73}, {-137,-116}, { -89,-140},
{-141,-142}, { -23, -25}, {-146, -17}, {-104,-149}, {-150,-151}, { -52,-154}, {-156,-157}, { -76, -70},
{-164, -51}, { -72,-167}, {-168,-169}, { -47, -20}, {-173, -59}, {-101,-176}, {-177,-178}, { -68,-181},
{-183,-184}, { -35, -60}, {-191, -98}, { -56,-194}, {-195,-196}, { -75, -65}, {-200,-105}, {-202,-203},
{-204,-205}, {-207,-208}, {-210,-211}, { -50,-217}, {-219,-220}, {-225,-226}, {-228,-229},
};
const int16_t mlt_decoder_tree_category_6[31][2] =
{
{ 1, 0}, { 2, 3}, { 4, 5}, { 6, 7}, { 8, -16}, { -1, -8}, { -2, -4}, { 9, 10},
{ 11, 12}, { 13, 14}, { 15, 16}, { 17, -24}, { -3, -12}, { -6, 18}, { 19, -20}, { -10, -5},
{ -17, -9}, { -18, 20}, { 21, 22}, { 23, 24}, { 25, -28}, { 26, -7}, { -14, -22}, { -26, -11},
{ 27, -19}, { -25, -13}, { -21, 28}, { 29, -30}, { -27, 30}, { -15, -29}, { -23, -31},
};
const int16_t *table_of_decoder_tables[NUM_CATEGORIES - 1] =
{
(const int16_t *) mlt_decoder_tree_category_0,
(const int16_t *) mlt_decoder_tree_category_1,
(const int16_t *) mlt_decoder_tree_category_2,
(const int16_t *) mlt_decoder_tree_category_3,
(const int16_t *) mlt_decoder_tree_category_4,
(const int16_t *) mlt_decoder_tree_category_5,
(const int16_t *) mlt_decoder_tree_category_6
};
/*- End of file ------------------------------------------------------------*/
+45
View File
@@ -0,0 +1,45 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* huff_tab.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: huff_tab.h,v 1.4 2008/09/30 14:06:40 steveu Exp $
*/
#define REGION_POWER_STEPSIZE_DB 3.010299957
#define ABS_REGION_POWER_LEVELS 32
#define DIFF_REGION_POWER_LEVELS 24
#define DRP_DIFF_MIN -12
#define DRP_DIFF_MAX 11
#define MAX_NUM_BINS 16
#define MAX_VECTOR_INDICES 625
#define MAX_VECTOR_DIMENSION 5
extern const int16_t differential_region_power_bits[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS];
extern const uint16_t differential_region_power_codes[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS];
extern const int16_t differential_region_power_decoder_tree[MAX_NUMBER_OF_REGIONS][DIFF_REGION_POWER_LEVELS - 1][2];
#if defined(G722_1_USE_FIXED_POINT)
extern const int16_t mlt_quant_centroid[NUM_CATEGORIES][MAX_NUM_BINS];
#else
extern const float mlt_quant_centroid[NUM_CATEGORIES - 1][MAX_NUM_BINS];
#endif
extern const int16_t expected_bits_table[NUM_CATEGORIES];
extern const int16_t *table_of_bitcount_tables[NUM_CATEGORIES - 1];
extern const uint16_t *table_of_code_tables[NUM_CATEGORIES - 1];
extern const int16_t *table_of_decoder_tables[NUM_CATEGORIES - 1];
/*- End of file ------------------------------------------------------------*/
+179
View File
@@ -0,0 +1,179 @@
# Microsoft Developer Studio Project File - Name="g722_1" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=g722_1 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "g722_1.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "g722_1.mak" CFG="g722_1 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "g722_1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "g722_1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "g722_1 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "." /I "..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /D "_WINDLL" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib ws2_32.lib winmm.lib /nologo /dll /map /debug /machine:I386 /out:"Release/libg722_1.dll"
!ELSEIF "$(CFG)" == "g722_1 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "." /I "..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /FR /FD /GZ /c
# SUBTRACT CPP /WX /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib ws2_32.lib winmm.lib /nologo /dll /incremental:no /map /debug /machine:I386 /out:"Debug/libg722_1.dll" /pdbtype:sept
# SUBTRACT LINK32 /nodefaultlib
!ENDIF
# Begin Target
# Name "g722_1 - Win32 Release"
# Name "g722_1 - Win32 Debug"
# Begin Group "Source Files"
# Begin Source File
SOURCE=.\basop32.c
# End Source File
# Begin Source File
SOURCE=.\bitstream.c
# End Source File
# Begin Source File
SOURCE=.\coef2sam.c
# End Source File
# Begin Source File
SOURCE=.\common.c
# End Source File
# Begin Source File
SOURCE=.\commonf.c
# End Source File
# Begin Source File
SOURCE=.\dct4.c
# End Source File
# Begin Source File
SOURCE=.\dct4_a.c
# End Source File
# Begin Source File
SOURCE=.\dct4_s.c
# End Source File
# Begin Source File
SOURCE=.\decoder.c
# End Source File
# Begin Source File
SOURCE=.\decoderf.c
# End Source File
# Begin Source File
SOURCE=.\encoder.c
# End Source File
# Begin Source File
SOURCE=.\encoderf.c
# End Source File
# Begin Source File
SOURCE=.\huff_tab.c
# End Source File
# Begin Source File
SOURCE=.\sam2coef.c
# End Source File
# Begin Source File
SOURCE=.\tables.c
# End Source File
# Begin Source File
SOURCE=.\msvc/gettimeofday.c
# End Source File
# End Group
# Begin Group "Header Files"
# Begin Source File
SOURCE=.\g722_1/g722_1.h
# End Source File
# Begin Source File
SOURCE=.\g722_1/version.h
# End Source File
# Begin Source File
SOURCE=.\g722_1.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
+29
View File
@@ -0,0 +1,29 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libg722_1", "libg722_1.vcproj", "{CF70F278-3364-4395-A2E1-23501C9B8AD2}"
ProjectSection(ProjectDependencies) = postProject
{1CED5987-A529-46DC-B30F-870D85FF9C94} = {1CED5987-A529-46DC-B30F-870D85FF9C94}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "at_dictionary_gen", "src\msvc\at_dictionary_gen.vcproj", "{1CED5987-A529-46DC-B30F-870D85FF9C94}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF70F278-3364-4395-A2E1-23501C9B8AD2}.Debug|Win32.ActiveCfg = Debug|Win32
{CF70F278-3364-4395-A2E1-23501C9B8AD2}.Debug|Win32.Build.0 = Debug|Win32
{CF70F278-3364-4395-A2E1-23501C9B8AD2}.Release|Win32.ActiveCfg = Release|Win32
{CF70F278-3364-4395-A2E1-23501C9B8AD2}.Release|Win32.Build.0 = Release|Win32
{1CED5987-A529-46DC-B30F-870D85FF9C94}.Debug|Win32.ActiveCfg = Debug|Win32
{1CED5987-A529-46DC-B30F-870D85FF9C94}.Debug|Win32.Build.0 = Debug|Win32
{1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|Win32.ActiveCfg = Release|Win32
{1CED5987-A529-46DC-B30F-870D85FF9C94}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+211
View File
@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C"
Version="9.00"
Name="libg722_1"
ProjectGUID="{CF70F278-3364-4395-A2E1-23501C9B8AD2}"
RootNamespace="libg722_1"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src; src\g722_1; src\msvc"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBG722_1_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_TGMATH_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
ModuleDefinitionFile="src/msvc/g722_1.def"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="src; src\g722_1; src\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBG722_1_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_TGMATH_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
ModuleDefinitionFile="src/msvc/g722_1.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File RelativePath="basop32.c"></File>
<File RelativePath="bitstream.c"></File>
<File RelativePath="coef2sam.c"></File>
<File RelativePath="common.c"></File>
<File RelativePath="commonf.c"></File>
<File RelativePath="dct4.c"></File>
<File RelativePath="dct4_a.c"></File>
<File RelativePath="dct4_s.c"></File>
<File RelativePath="decoder.c"></File>
<File RelativePath="decoderf.c"></File>
<File RelativePath="encoder.c"></File>
<File RelativePath="encoderf.c"></File>
<File RelativePath="huff_tab.c"></File>
<File RelativePath="sam2coef.c"></File>
<File RelativePath="tables.c"></File>
<File RelativePath="msvc/gettimeofday.c"></File>
</Filter><Filter Name="Header Files">
<File RelativePath="g722_1/g722_1.h"></File>
<File RelativePath="g722_1/version.h"></File>
<File RelativePath="g722_1.h"></File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+104
View File
@@ -0,0 +1,104 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* make_dct4_tables.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: make_dct4_tables.c,v 1.2 2008/10/02 11:43:54 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include "g722_1/g722_1.h"
#define PI 3.141592653589793238462
#include "defs.h"
static void set_up_one_table(int length)
{
int index;
double angle;
double scale;
scale = PI/(double) (4*length);
printf("static const cos_msin_t cos_msin_%d[%d] =\n", length, length);
printf("{\n");
for (index = 0; index < length - 1; index++)
{
angle = scale*((double) index + 0.5);
printf(" {%.15e, %.15e},\n", cos(angle), -sin(angle));
}
angle = scale*((double) index + 0.5);
printf(" {%.15e, %.15e}\n", cos(angle), -sin(angle));
printf("};\n\n");
}
/*- End of function --------------------------------------------------------*/
int main(int argc, char *argv[])
{
int length_log;
int i;
int k;
int dct_size;
double scale;
dct_size = MAX_DCT_LENGTH;
length_log = 0;
while ((dct_size & 1) == 0)
{
length_log++;
dct_size >>= 1;
}
scale = sqrt(2.0/MAX_DCT_LENGTH);
printf("static const float max_dct_core_a[] =\n");
printf("{\n");
for (k = 0; k < 10; ++k)
{
for (i = 0; i < 10; ++i)
{
printf(" %22.15e%s\n",
cos(PI*(k + 0.5) * (i + 0.5)/10.0)*scale,
(k == 9 && i == 9) ? "" : ",");
}
}
printf("};\n\n");
scale = sqrt(2.0/DCT_LENGTH);
printf("static const float dct_core_a[] =\n");
printf("{\n");
for (k = 0; k < 10; ++k)
{
for (i = 0; i < 10; ++i)
{
printf(" %22.15e%s\n",
cos(PI*(k + 0.5) * (i + 0.5)/10.0)*scale,
(k == 9 && i == 9) ? "" : ",");
}
}
printf("};\n\n");
for (i = 0; i <= length_log; i++)
set_up_one_table(dct_size << i);
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+291
View File
@@ -0,0 +1,291 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* make_tables.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: make_tables.c,v 1.5 2008/11/21 15:30:22 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "huff_tab.h"
#if defined(PI)
#undef PI
#endif
#define PI 3.141592653589793238462
/* These may have been defined in the main header for the codec, so we clear out
any pre-existing definitions here. */
#if defined(ENCODER_SCALE_FACTOR)
#undef ENCODER_SCALE_FACTOR
#endif
#if defined(DECODER_SCALE_FACTOR)
#undef DECODER_SCALE_FACTOR
#endif
#define ENCODER_SCALE_FACTOR 18318.0
#define DECODER_SCALE_FACTOR 18096.0
#define REGION_POWER_TABLE_SIZE 64
#define NUM_CATEGORIES 8
#define MAX_DCT_LENGTH 640
#if defined(G722_1_USE_FIXED_POINT)
int16_t int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE];
int16_t standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE];
#else
float region_standard_deviation_table[REGION_POWER_TABLE_SIZE];
float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE];
#endif
int16_t vector_dimension[NUM_CATEGORIES];
int16_t number_of_vectors[NUM_CATEGORIES];
/* The last category isn't really coded with scalar quantization. */
int16_t max_bin_plus_one_inverse[NUM_CATEGORIES];
const int16_t max_bin[NUM_CATEGORIES] =
{
13, 9, 6, 4, 3, 2, 1, 1
};
const float step_size[NUM_CATEGORIES] =
{
0.3536f,
0.5f,
0.7071f,
1.0f,
1.4142f,
2.0f,
2.8284f,
2.8284f
};
static void generate_sam2coef_tables(void)
{
int i;
double angle;
printf("#if defined(G722_1_USE_FIXED_POINT)\n");
printf("const int16_t samples_to_rmlt_window[DCT_LENGTH] =\n{\n");
for (i = 0; i < DCT_LENGTH; i++)
{
if (i%10 == 0)
printf(" ");
angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH;
printf("%5d,", (int) (ENCODER_SCALE_FACTOR*sin(angle)));
if (i%10 == 9)
printf("\n");
else
printf(" ");
}
printf("};\n\n");
printf("const int16_t max_samples_to_rmlt_window[MAX_DCT_LENGTH] =\n{\n");
for (i = 0; i < MAX_DCT_LENGTH; i++)
{
if (i%10 == 0)
printf(" ");
angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH;
printf("%5d,", (int) (ENCODER_SCALE_FACTOR*sin(angle)));
if (i%10 == 9)
printf("\n");
else
printf(" ");
}
printf("};\n\n");
printf("#else\n");
printf("const float samples_to_rmlt_window[DCT_LENGTH] =\n{\n");
for (i = 0; i < DCT_LENGTH; i++)
{
angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH;
printf(" %.15e,\n", sin(angle));
}
printf("};\n\n");
printf("const float max_samples_to_rmlt_window[MAX_DCT_LENGTH] =\n{\n");
for (i = 0; i < MAX_DCT_LENGTH; i++)
{
angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH;
printf(" %.15le,\n", sin(angle));
}
printf("};\n\n");
printf("#endif\n");
}
static void generate_coef2sam_tables(void)
{
int i;
double angle;
printf("#if defined(G722_1_USE_FIXED_POINT)\n");
printf("const int16_t rmlt_to_samples_window[DCT_LENGTH] =\n{\n");
for (i = 0; i < DCT_LENGTH; i++)
{
if (i%10 == 0)
printf(" ");
angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH;
printf("%5d,", (int) (DECODER_SCALE_FACTOR*sin(angle)));
if (i%10 == 9)
printf("\n");
else
printf(" ");
}
printf("};\n\n");
printf("const int16_t max_rmlt_to_samples_window[MAX_DCT_LENGTH] =\n{\n");
for (i = 0; i < MAX_DCT_LENGTH; i++)
{
if (i%10 == 0)
printf(" ");
angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH;
printf("%5d,", (int) (DECODER_SCALE_FACTOR*sin(angle)));
if (i%10 == 9)
printf("\n");
else
printf(" ");
}
printf("};\n\n");
printf("#else\n");
printf("const float rmlt_to_samples_window[DCT_LENGTH] =\n{\n");
for (i = 0; i < DCT_LENGTH; i++)
{
angle = (PI/2.0)*((double) i + 0.5)/(double) DCT_LENGTH;
printf(" %.15e,\n", sin(angle));
}
printf("};\n\n");
printf("const float max_rmlt_to_samples_window[MAX_DCT_LENGTH] =\n{\n");
for (i = 0; i < MAX_DCT_LENGTH; i++)
{
angle = (PI/2.0)*((double) i + 0.5)/(double) MAX_DCT_LENGTH;
printf(" %.15e,\n", sin(angle));
}
printf("};\n\n");
printf("#endif\n");
}
int main(int argc, char *argv[])
{
int i;
int j;
int number_of_indices;
double value;
if (strcmp(argv[1], "sam2coef") == 0)
{
generate_sam2coef_tables();
return 0;
}
if (strcmp(argv[1], "coef2sam") == 0)
{
generate_coef2sam_tables();
return 0;
}
printf("const float region_standard_deviation_table[REGION_POWER_TABLE_SIZE] =\n{\n");
for (i = 0; i < REGION_POWER_TABLE_SIZE; i++)
{
value = pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(i - REGION_POWER_TABLE_NUM_NEGATIVES));
printf(" %.15e,\n", sqrt(value));
}
printf("};\n\n");
printf("const float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] =\n{\n");
for (i = 0; i < REGION_POWER_TABLE_SIZE; i++)
{
value = pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(i - REGION_POWER_TABLE_NUM_NEGATIVES));
printf(" %.15e,\n", 1.0/sqrt(value));
}
printf("};\n\n");
printf("const int16_t max_bin_plus_one_inverse[NUM_CATEGORIES] =\n{\n");
for (i = 0; i < NUM_CATEGORIES; i++)
{
printf(" %5d,\n", max_bin[i]);
}
printf("};\n\n");
printf("const int16_t max_bin_plus_one_inverse[NUM_CATEGORIES] =\n{\n");
for (i = 0; i < NUM_CATEGORIES; i++)
{
/* Rounding up by 1.0 instead of 0.5 allows us to avoid rounding every time this is used. */
max_bin_plus_one_inverse[i] = (int) ((32768.0/(max_bin[i] + 1.0)) + 1.0);
printf(" %5d,\n", max_bin_plus_one_inverse[i]);
/* Test division for all indices. */
number_of_indices = 1;
for (j = 0; j < vector_dimension[i]; j++)
number_of_indices *= (max_bin[i] + 1);
for (j = 0; j < number_of_indices; j++)
{
if (j/(max_bin[i] + 1) != ((j*max_bin_plus_one_inverse[i]) >> 15))
printf("max_bin_plus_one_inverse ERROR!! %1d: %5d %3d\n", i, max_bin_plus_one_inverse[i], j);
}
}
printf("};\n\n");
printf("const float step_size[NUM_CATEGORIES] =\n{\n");
for (i = 0; i < NUM_CATEGORIES; i++)
{
printf(" %.15e,\n", step_size[i]);
}
printf("};\n\n");
printf("const float step_size_inverse_table[NUM_CATEGORIES] =\n{\n");
for (i = 0; i < NUM_CATEGORIES; i++)
{
printf(" %.15e,\n", 1.0/step_size[i]);
}
printf("};\n\n");
printf("const float region_power_table[REGION_POWER_TABLE_SIZE] =\n{\n");
/* region_size = (BLOCK_SIZE * 0.875)/NUMBER_OF_REGIONS; */
for (i = 0; i < REGION_POWER_TABLE_SIZE; i++)
{
value = pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(i - REGION_POWER_TABLE_NUM_NEGATIVES));
printf(" %.15e,\n", value);
}
printf("};\n\n");
printf("const float region_power_table_boundary[REGION_POWER_TABLE_SIZE - 1] =\n{\n");
for (i = 0; i < REGION_POWER_TABLE_SIZE - 1; i++)
{
value = (float) pow(10.0, 0.10*REGION_POWER_STEPSIZE_DB*(0.5 + (i - REGION_POWER_TABLE_NUM_NEGATIVES)));
printf(" %.15e,\n", value);
}
printf("};\n\n");
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/
+304
View File
@@ -0,0 +1,304 @@
EXPORTS
adsi_rx_init
adsi_rx
adsi_tx_init
adsi_send_alert_tone
adsi_put_message
adsi_next_field
adsi_add_field
async_tx_init
async_rx_init
awgn
bert_init
bert_get_bit
bert_put_bit
bert_set_report
bert_result
filter_create
filter_delete
filter_step
cfilter_create
cfilter_delete
cfilter_step
dds_phase_rate
dds_frequency
dds_scaling_dbm0
dds_scaling_dbov
dds_lookup
dds_offset
dds
dds_mod
dds_complex
dds_complex_mod
dds_phase_ratef
dds_frequencyf
dds_scaling_dbm0f
dds_scaling_dbovf
ddsf
dds_modf
dds_complexf
dds_complex_modf
echo_can_create
echo_can_free
echo_can_flush
echo_can_adaption_mode
echo_can_update
fax_rx
fax_tx
fax_set_flush_handler
fax_init
fax_release
fsk_tx_init
fsk_tx_power
fsk_tx_set_get_bit
fsk_tx
fsk_rx_signal_power
fsk_rx_signal_cutoff
fsk_rx_init
fsk_rx
fsk_rx_set_put_bit
g722_encode_init
g722_encode_release
g722_encode
g722_decode_init
g722_decode_release
g722_decode
g726_init
g726_release
crc_itu32_calc
crc_itu32_append
crc_itu32_check
crc_itu16_calc
crc_itu16_append
crc_itu16_check
hdlc_rx_init
hdlc_rx_get_stats
hdlc_tx_init
hdlc_tx_frame
hdlc_tx_preamble
ima_adpcm_init
ima_adpcm_release
span_log_test
span_log
span_log_buf
span_log_init
span_log_set_protocol
span_set_message_handler
span_set_error_handler
modem_echo_can_create
modem_echo_can_free
modem_echo_can_flush
modem_echo_can_adaption_mode
modem_echo_can_update
noise
oki_adpcm_init
oki_adpcm_release
playout_put
playout_get
playout_get_unconditional
playout_current_length
playout_next_due
playout_new
playout_free
playout_restart
plc_rx
plc_fillin
plc_init
plc_release
power_meter_init
power_meter_damping
power_meter_update
power_meter_dbm0
power_meter_dbov
power_meter_level_dbm0
power_meter_level_dbov
queue_empty
queue_free_space
queue_contents
queue_flush
queue_view
queue_read
queue_write
queue_test_msg
queue_read_msg
queue_write_msg
queue_create
queue_delete
sig_tone_init
sig_tone_rx
sig_tone_tx
super_tone_rx_make_descriptor
super_tone_rx_add_tone
super_tone_rx_add_element
super_tone_rx_init
super_tone_rx_free
super_tone_rx_segment_callback
super_tone_rx
super_tone_tx_make_step
super_tone_tx_free
super_tone_tx_init
super_tone_tx
t30_init
t30_release
t30_restart
t30_create
t30_free
t30_frametype
t30_decode_dis_dtc_dcs
t30_completion_code_to_str
t30_set_header_info
t30_set_local_ident
t30_get_sub_address
t30_get_header_info
t30_get_local_ident
t30_get_far_ident
t30_get_transfer_statistics
t30_set_phase_b_handler
t30_set_phase_d_handler
t30_set_phase_e_handler
t30_set_document_handler
t30_set_rx_file
t30_set_tx_file
t30_local_interrupt_request
t30_send_complete
t30_hdlc_accept
t30_timer_update
t31_call_event
t31_at_rx
t31_rx
t31_tx
t31_init
t31_release
t35_decode
t38_indicator
t38_data_type
t38_field_type
t38_terminal_init
t38_gateway_init
t4_rx_create
t4_rx_init
t4_rx_start_page
t4_rx_end_page
t4_rx_delete
t4_rx_end
t4_rx_set_rx_encoding
t4_rx_set_sub_address
t4_rx_set_far_ident
t4_rx_set_vendor
t4_rx_set_model
t4_tx_create
t4_tx_init
t4_tx_start_page
t4_tx_restart_page
t4_tx_end_page
t4_tx_delete
t4_tx_end
t4_tx_set_tx_encoding
t4_tx_set_min_row_bits
t4_tx_set_local_ident
t4_tx_set_header_info
t4_get_transfer_statistics
t4_encoding_to_str
time_scale_init
time_scale_rate
time_scale
make_goertzel_descriptor
goertzel_init
goertzel_update
goertzel_result
dtmf_rx_init
dtmf_rx_set_realtime_callback
dtmf_rx_parms
dtmf_rx
make_tone_descriptor
make_tone_gen_descriptor
tone_gen_init
tone_gen
dtmf_tx_init
dtmf_tx
v17_rx_init
v17_rx_restart
v17_rx_release
v17_rx_set_put_bit
v17_rx
v17_rx_equalizer_state
v17_rx_carrier_frequency
v17_rx_symbol_timing_correction
v17_rx_signal_power
v17_rx_signal_cutoff
v17_rx_set_qam_report_handler
v17_tx_power
v17_tx_init
v17_tx_restart
v17_tx_release
v17_tx_set_get_bit
v17_tx
v22bis_rx_restart
v22bis_rx
v22bis_rx_equalizer_state
v22bis_rx_carrier_frequency
v22bis_rx_symbol_timing_correction
v22bis_rx_signal_power
v22bis_rx_set_qam_report_handler
v22bis_tx
v22bis_tx_power
v22bis_restart
v22bis_init
v22bis_set_get_bit
v22bis_set_put_bit
v27ter_rx_init
v27ter_rx_restart
v27ter_rx_release
v27ter_rx_set_put_bit
v27ter_rx
v27ter_rx_equalizer_state
v27ter_rx_carrier_frequency
v27ter_rx_symbol_timing_correction
v27ter_rx_signal_power
v27ter_rx_signal_cutoff
v27ter_rx_set_qam_report_handler
v27ter_tx_power
v27ter_tx_init
v27ter_tx_restart
v27ter_tx_release
v27ter_tx_set_get_bit
v27ter_tx
v29_rx_init
v29_rx_restart
v29_rx_release
v29_rx_set_put_bit
v29_rx
v29_rx_equalizer_state
v29_rx_carrier_frequency
v29_rx_symbol_timing_correction
v29_rx_signal_power
v29_rx_signal_cutoff
v29_rx_set_qam_report_handler
v29_tx_power
v29_tx_init
v29_tx_restart
v29_tx_release
v29_tx_set_get_bit
v29_tx
lapm_dump
lapm_receive
lapm_tx
lapm_tx_iframe
v42_set_status_callback
v42_rx_bit
v42_tx_bit
v42_init
v42_restart
v42_release
v42bis_compress
v42bis_compress_flush
v42bis_decompress
v42bis_decompress_flush
v42bis_init
v42bis_release
v8_init
v8_release
v8_tx
v8_rx
v8_log_supported_modulations
+14
View File
@@ -0,0 +1,14 @@
#ifdef _MSC_VER
#pragma warning(disable:4100)
#endif
#include "windows.h"
void gettimeofday(struct timeval *tv, void *tz)
{
long int l = GetTickCount();
tv->tv_sec = l / 1000;
tv->tv_usec = (l % 1000) * 1000;
return;
}
+87
View File
@@ -0,0 +1,87 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* inttypes.h - a fudge for MSVC, which lacks this header
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2006 Michael Jerris
*
*
* This file is released in the public domain.
*
*/
#if !defined(_INTTYPES_H_)
#define _INTTYPES_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
#if (_MSC_VER >= 1400) // VC8+
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE
#endif
#ifndef _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#endif
#endif // VC8+
#include <windows.h>
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
#define inline __inline
#define __inline__ __inline
#define INT16_MAX 0x7fff
#define INT16_MIN (-INT16_MAX - 1)
#define _MMX_H_
/* disable the following warnings
* C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
* C4200: Non standard extension C zero sized array
* C4706: assignment within conditional expression
* C4244: conversion from 'type1' to 'type2', possible loss of data
* C4295: array is too small to include a terminating null character
* C4125: decimal digit terminates octal escape sequence
*/
#pragma warning(disable:4100 4200 4706 4295 4125)
#pragma comment(lib, "ws2_32.lib")
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define snprintf _snprintf
#if !defined(INFINITY)
#define INFINITY 0x7fffffff
#endif
#endif
#define PACKAGE "ilbc"
#define VERSION "0.0.1andabit"
#define INT32_MAX (2147483647)
#define INT32_MIN (-2147483647 - 1)
#define PRId8 "d"
#define PRId16 "d"
#define PRId32 "ld"
#define PRId64 "lld"
#define PRIu8 "u"
#define PRIu16 "u"
#define PRIu32 "lu"
#define PRIu64 "llu"
#ifdef __cplusplus
}
#endif
#endif
+7
View File
@@ -0,0 +1,7 @@
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
+92
View File
@@ -0,0 +1,92 @@
# Microsoft Developer Studio Project File - Name="g722_1" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=g722_1 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "g722_1.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "g722_1.mak" CFG="g722_1 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "g722_1 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "g722_1 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "g722_1 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "." /I "..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /D "_WINDLL" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib ws2_32.lib winmm.lib /nologo /dll /map /debug /machine:I386 /out:"Release/libg722_1.dll"
!ELSEIF "$(CFG)" == "g722_1 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "." /I "..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_TGMATH_H /FR /FD /GZ /c
# SUBTRACT CPP /WX /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib ws2_32.lib winmm.lib /nologo /dll /incremental:no /map /debug /machine:I386 /out:"Debug/libg722_1.dll" /pdbtype:sept
# SUBTRACT LINK32 /nodefaultlib
!ENDIF
# Begin Target
# Name "g722_1 - Win32 Release"
# Name "g722_1 - Win32 Debug"
+1
View File
@@ -0,0 +1 @@
extern void gettimeofday(struct timeval *tv, void *tz);
+84
View File
@@ -0,0 +1,84 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* tgmath.h - a fudge for MSVC, which lacks this header
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2006 Michael Jerris
*
*
* This file is released in the public domain.
*
*/
#if !defined(_TGMATH_H_)
#define _TGMATH_H_
#include <math.h>
#if !defined(M_PI)
/* C99 systems may not define M_PI */
#define M_PI 3.14159265358979323846264338327
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* A kindofa rint() for VC++ (only kindofa, because rint should be type generic,
and this one is purely float to int */
static inline long int lrintf(float a)
{
long int i;
__asm
{
fld a
fistp i
}
return i;
}
static inline long int lrint(double a)
{
long int i;
__asm
{
fld a
fistp i
}
return i;
}
static inline int rintf(float a)
{
int i;
__asm
{
fld a
fistp i
}
return i;
}
static inline int rint(double a)
{
int i;
__asm
{
fld a
fistp i
}
return i;
}
#ifdef __cplusplus
}
#endif
#endif
+31
View File
@@ -0,0 +1,31 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* inttypes.h - a fudge for MSVC, which lacks this header
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2006 Michael Jerris
*
*
* This file is released in the public domain.
*
*/
#if !defined(_INTTYPES_H_)
#define _INTTYPES_H_
#ifdef __cplusplus
extern "C" {
#endif
#define open _open
#define write _write
extern int gethostname (char *name, size_t len);
#ifdef __cplusplus
}
#endif
#endif
+11
View File
@@ -0,0 +1,11 @@
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+180
View File
@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C"
Version="9.00"
Name="libg722_1"
ProjectGUID="{CF70F278-3364-4395-A2E1-23501C9B8AD2}"
RootNamespace="libg722_1"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src; src\g722_1; src\msvc"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBG722_1_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_TGMATH_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
ModuleDefinitionFile="src/msvc/g722_1.def"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="src; src\g722_1; src\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBG722_1_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_TGMATH_H"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
ModuleDefinitionFile="src/msvc/g722_1.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
+188
View File
@@ -0,0 +1,188 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* sam2coef.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: sam2coef.c,v 1.12 2008/10/02 11:43:54 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "sam2coef.h"
/************************************************************************************
Purpose: Convert Samples to Reversed MLT (Modulated Lapped Transform) Coefficients
The "Reversed MLT" is an overlapped block transform which uses even symmetry
on the left, odd symmetry on the right and a Type IV DCT as the block transform.
It is thus similar to a MLT which uses odd symmetry on the left, even symmetry
on the right and a Type IV DST as the block transform. In fact, it is equivalent
to reversing the order of the samples, performing an MLT and then negating all
the even-numbered coefficients.
***************************************************************************/
#if defined(G722_1_USE_FIXED_POINT)
int16_t samples_to_rmlt_coefs(const int16_t new_samples[],
int16_t old_samples[],
int16_t coefs[],
int dct_length)
{
int i;
int half_dct_length;
int last;
int16_t mag_shift;
int16_t n;
int16_t windowed_data[MAX_DCT_LENGTH];
const int16_t *win;
int32_t acca;
int32_t accb;
int16_t temp;
int16_t temp1;
int16_t temp2;
half_dct_length = dct_length >> 1;
if (dct_length == DCT_LENGTH)
win = samples_to_rmlt_window;
else
win = max_samples_to_rmlt_window;
/* Get the first half of the windowed samples */
last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
acca = 0L;
acca = L_mac(acca, win[last - i], old_samples[last - i]);
acca = L_mac(acca, win[half_dct_length + i], old_samples[half_dct_length + i]);
temp = xround(acca);
windowed_data[i] = temp;
}
/* Get the second half of the windowed samples */
last = dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
acca = 0L;
acca = L_mac(acca, win[last - i], new_samples[i]);
acca = L_mac(acca, negate(win[i]), new_samples[last - i]);
temp = xround(acca);
windowed_data[half_dct_length + i] = temp;
}
/* Save the new samples for next time, when they will be the old samples. */
for (i = 0; i < dct_length; i++)
old_samples[i] = new_samples[i];
/* Calculate how many bits to shift up the input to the DCT. */
temp1 = 0;
for (i = 0; i < dct_length; i++)
{
temp2 = abs_s(windowed_data[i]);
temp = sub(temp2, temp1);
if (temp > 0)
temp1 = temp2;
}
mag_shift = 0;
temp = sub(temp1, 14000);
if (temp < 0)
{
temp = sub(temp1, 438);
temp = (temp < 0) ? add(temp1, 1) : temp1;
accb = L_mult(temp, 9587);
acca = L_shr(accb, 20);
temp = norm_s((int16_t) acca);
mag_shift = (temp == 0) ? 9 : sub(temp, 6);
}
acca = 0;
for (i = 0; i < dct_length; i++)
{
temp = abs_s(windowed_data[i]);
acca = L_add(acca, temp);
}
acca = L_shr(acca, 7);
if (temp1 < acca)
mag_shift = sub(mag_shift, 1);
if (mag_shift > 0)
{
for (i = 0; i < dct_length; i++)
windowed_data[i] = shl(windowed_data[i], mag_shift);
}
else if (mag_shift < 0)
{
n = negate(mag_shift);
for (i = 0; i < dct_length; i++)
windowed_data[i] = shr(windowed_data[i], n);
}
/* Perform a Type IV DCT on the windowed data to get the coefficients */
dct_type_iv_a(windowed_data, coefs, dct_length);
return mag_shift;
}
/*- End of function --------------------------------------------------------*/
#else
void samples_to_rmlt_coefs(const float new_samples[],
float old_samples[],
float coefs[],
int dct_length)
{
int i;
int half_dct_length;
int last;
float sum;
float windowed_data[MAX_DCT_LENGTH];
const float *win;
half_dct_length = dct_length >> 1;
if (dct_length == DCT_LENGTH)
win = samples_to_rmlt_window;
else
win = max_samples_to_rmlt_window;
/* Get the first half of the windowed samples. */
last = half_dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
sum = win[last - i]*old_samples[last - i];
sum += win[half_dct_length + i]*old_samples[half_dct_length + i];
windowed_data[i] = sum;
}
/* Get the second half of the windowed samples. */
last = dct_length - 1;
for (i = 0; i < half_dct_length; i++)
{
sum = win[last - i]*new_samples[i];
sum -= win[i]*new_samples[last - i];
windowed_data[half_dct_length + i] = sum;
}
/* Save the new samples for next time, when they will be the old samples. */
for (i = 0; i < dct_length; i++)
old_samples[i] = new_samples[i];
/* Perform a Type IV DCT on the windowed data to get the coefficients. */
dct_type_iv(windowed_data, coefs, dct_length);
}
/*- End of function --------------------------------------------------------*/
#endif
/*- End of file ------------------------------------------------------------*/
File diff suppressed because it is too large. Load diff
+416
View File
@@ -0,0 +1,416 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* table.c
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: tables.c,v 1.11 2008/09/30 14:06:40 steveu Exp $
*/
/*! \file */
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <inttypes.h>
#include <stdlib.h>
#include "g722_1/g722_1.h"
#include "defs.h"
#include "tables.h"
const int16_t vector_dimension[NUM_CATEGORIES] =
{
2, 2, 2, 4, 4, 5, 5, 1
};
const int16_t number_of_vectors[NUM_CATEGORIES] =
{
10, 10, 10, 5, 5, 4, 4, 20
};
/* The last category isn't really coded with scalar quantization. */
const int16_t max_bin[NUM_CATEGORIES] =
{
13, 9, 6, 4, 3, 2, 1, 1
};
const int16_t max_bin_plus_one_inverse[NUM_CATEGORIES] =
{
2341, 3277, 4682, 6554, 8193, 10923, 16385, 16385
};
#if defined(G722_1_USE_FIXED_POINT)
const int16_t int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 2, 3, 4, 6,
8, 11, 16, 23, 32, 45, 64, 91, 128, 181,
256, 362, 512, 724, 1024, 1448, 2048, 2896, 4096, 5793,
8192, 11585, 16384, 23170, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0
};
#else
const float region_standard_deviation_table[REGION_POWER_TABLE_SIZE] =
{
2.441406247570224e-04,
3.452669826719395e-04,
4.882812495545411e-04,
6.905339654011486e-04,
9.765624991900746e-04,
1.381067930916839e-03,
1.953124998542134e-03,
2.762135862062757e-03,
3.906249997408239e-03,
5.524271724583683e-03,
7.812499995464418e-03,
1.104854345008369e-02,
1.562499999222472e-02,
2.209708690200003e-02,
3.124999998704119e-02,
4.419417380766535e-02,
6.249999997926591e-02,
8.838834762266132e-02,
1.249999999688989e-01,
1.767766952599839e-01,
2.499999999585318e-01,
3.535533905492901e-01,
4.999999999585318e-01,
7.071067811572251e-01,
1.000000000000000e+00,
1.414213562431740e+00,
2.000000000165873e+00,
2.828427125098059e+00,
4.000000000663491e+00,
5.656854250665278e+00,
8.000000001990472e+00,
1.131370850226887e+01,
1.600000000530792e+01,
2.262741700641438e+01,
3.200000001326981e+01,
4.525483401658204e+01,
6.400000003184756e+01,
9.050966804067060e+01,
1.280000000743110e+02,
1.810193360963542e+02,
2.560000001698536e+02,
3.620386722227349e+02,
5.120000003821707e+02,
7.240773445055215e+02,
1.024000000849268e+03,
1.448154689131149e+03,
2.048000001868390e+03,
2.896309378502505e+03,
4.096000004076487e+03,
5.792618757485434e+03,
8.192000008832390e+03,
1.158523751593169e+04,
1.638400001902361e+04,
2.317047503378509e+04,
3.276800004076484e+04,
4.634095007141347e+04,
6.553600008696507e+04,
9.268190015051374e+04,
1.310720001848009e+05,
1.853638003164007e+05,
2.621440003913428e+05,
3.707276006635486e+05,
5.242880008261676e+05,
7.414552013885899e+05
};
#endif
#if defined(G722_1_USE_FIXED_POINT)
const int16_t standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] =
{
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767,
32767, 32767, 32767, 32767, 32767, 23170, 16384, 11585, 8192, 5793,
4096, 2896, 2048, 1448, 1024, 724, 512, 362, 256, 181,
128, 91, 64, 45, 32, 23, 16, 11, 8, 6,
4, 3, 2, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0
};
#else
const float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE] =
{
4.096000004076488e+03,
2.896309378502504e+03,
2.048000001868390e+03,
1.448154689131149e+03,
1.024000000849268e+03,
7.240773445055215e+02,
5.120000003821708e+02,
3.620386722227349e+02,
2.560000001698537e+02,
1.810193360963542e+02,
1.280000000743110e+02,
9.050966804067060e+01,
6.400000003184756e+01,
4.525483401658203e+01,
3.200000001326982e+01,
2.262741700641438e+01,
1.600000000530793e+01,
1.131370850226887e+01,
8.000000001990474e+00,
5.656854250665277e+00,
4.000000000663491e+00,
2.828427125098059e+00,
2.000000000165873e+00,
1.414213562431740e+00,
1.000000000000000e+00,
7.071067811572251e-01,
4.999999999585318e-01,
3.535533905492901e-01,
2.499999999585318e-01,
1.767766952599838e-01,
1.249999999688989e-01,
8.838834762266132e-02,
6.249999997926592e-02,
4.419417380766535e-02,
3.124999998704120e-02,
2.209708690200002e-02,
1.562499999222472e-02,
1.104854345008369e-02,
7.812499995464418e-03,
5.524271724583683e-03,
3.906249997408239e-03,
2.762135862062757e-03,
1.953124998542134e-03,
1.381067930916839e-03,
9.765624991900747e-04,
6.905339654011486e-04,
4.882812495545411e-04,
3.452669826719394e-04,
2.441406247570224e-04,
1.726334913216520e-04,
1.220703123683871e-04,
8.631674565366727e-05,
6.103515617913153e-05,
4.315837282325419e-05,
3.051757808703478e-05,
2.157918640983742e-05,
1.525878904225187e-05,
1.078959320402385e-05,
7.629394520493171e-06,
5.394796601564505e-06,
3.814697259930213e-06,
2.697398300558537e-06,
1.907348629806920e-06,
1.348699150167414e-06
};
#endif
#if defined(G722_1_USE_FIXED_POINT)
const int16_t step_size_inverse_table[NUM_CATEGORIES] =
{
23167,
16384,
11585,
8192,
5793,
4096,
2896,
2896
};
#else
/* The last category isn't really coded with scalar quantization. */
const float step_size[NUM_CATEGORIES] =
{
0.3536f,
0.5f,
0.7071f,
1.0f,
1.4142f,
2.0f,
2.8284f,
2.8284f
};
const float step_size_inverse_table[NUM_CATEGORIES] =
{
2.82805443e+00,
2.00000000e+00,
1.41422713e+00,
1.00000000e+00,
7.07113564e-01,
5.00000000e-01,
3.53556782e-01,
3.53556782e-01
};
#endif
#if defined(G722_1_USE_FIXED_POINT)
const int16_t int_dead_zone[NUM_CATEGORIES] =
{
2457, 2703, 2949, 3195 , 3440, 3686, 4096, 4096
};
const int16_t int_dead_zone_low_bits[NUM_CATEGORIES] =
{
2, 1, 0, 0, 3, 2, 0, 0
};
#else
const float dead_zone[NUM_CATEGORIES] =
{
0.3f,
0.33f,
0.36f,
0.39f,
0.42f,
0.45f,
0.5f,
0.5f
};
#endif
#if !defined(G722_1_USE_FIXED_POINT)
const float region_power_table[REGION_POWER_TABLE_SIZE] =
{
5.96046448e-08,
1.19209290e-07,
2.38418579e-07,
4.76837158e-07,
9.53674316e-07,
1.90734863e-06,
3.81469727e-06,
7.62939453e-06,
1.52587891e-05,
3.05175781e-05,
6.10351562e-05,
1.22070312e-04,
2.44140625e-04,
4.88281250e-04,
9.76562500e-04,
1.95312500e-03,
3.90625000e-03,
7.81250000e-03,
1.56250000e-02,
3.12500000e-02,
6.25000000e-02,
1.25000000e-01,
2.50000000e-01,
5.00000000e-01,
1.00000000e+00,
2.00000000e+00,
4.00000000e+00,
8.00000000e+00,
1.60000000e+01,
3.20000000e+01,
6.40000000e+01,
1.28000000e+02,
2.56000000e+02,
5.12000000e+02,
1.02400000e+03,
2.04800000e+03,
4.09600000e+03,
8.19200000e+03,
1.63840000e+04,
3.27680000e+04,
6.55360000e+04,
1.31072000e+05,
2.62144000e+05,
5.24288000e+05,
1.04857600e+06,
2.09715200e+06,
4.19430400e+06,
8.38860800e+06,
1.67772160e+07,
3.35544320e+07,
6.71088640e+07,
1.34217728e+08,
2.68435456e+08,
5.36870912e+08,
1.07374182e+09,
2.14748365e+09,
4.29496730e+09,
8.58993459e+09,
1.71798692e+10,
3.43597384e+10,
6.87194767e+10,
1.37438953e+11,
2.74877907e+11,
5.49755814e+11
};
const float region_power_table_boundary[REGION_POWER_TABLE_SIZE - 1] =
{
8.42936956e-08,
1.68587391e-07,
3.37174782e-07,
6.74349565e-07,
1.34869913e-06,
2.69739826e-06,
5.39479652e-06,
1.07895930e-05,
2.15791861e-05,
4.31583721e-05,
8.63167443e-05,
1.72633489e-04,
3.45266977e-04,
6.90533954e-04,
1.38106791e-03,
2.76213582e-03,
5.52427163e-03,
1.10485433e-02,
2.20970865e-02,
4.41941731e-02,
8.83883461e-02,
1.76776692e-01,
3.53553385e-01,
7.07106769e-01,
1.41421354e+00,
2.82842708e+00,
5.65685415e+00,
1.13137083e+01,
2.26274166e+01,
4.52548332e+01,
9.05096664e+01,
1.81019333e+02,
3.62038666e+02,
7.24077332e+02,
1.44815466e+03,
2.89630933e+03,
5.79261865e+03,
1.15852373e+04,
2.31704746e+04,
4.63409492e+04,
9.26818984e+04,
1.85363797e+05,
3.70727594e+05,
7.41455188e+05,
1.48291038e+06,
2.96582075e+06,
5.93164150e+06,
1.18632830e+07,
2.37265660e+07,
4.74531320e+07,
9.49062640e+07,
1.89812528e+08,
3.79625056e+08,
7.59250112e+08,
1.51850022e+09,
3.03700045e+09,
6.07400090e+09,
1.21480018e+10,
2.42960036e+10,
4.85920072e+10,
9.71840143e+10,
1.94368029e+11,
3.88736057e+11
};
#endif
/*- End of file ------------------------------------------------------------*/
+53
View File
@@ -0,0 +1,53 @@
/*
* g722_1 - a library for the G.722.1 and Annex C codecs
*
* tables.h
*
* Adapted by Steve Underwood <steveu@coppice.org> from the reference
* code supplied with ITU G.722.1, which is:
*
* © 2004 Polycom, Inc.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: tables.h,v 1.7 2008/09/26 17:37:31 steveu Exp $
*/
#define REGION_POWER_TABLE_SIZE 64
#define NUM_CATEGORIES 8
extern const int16_t vector_dimension[NUM_CATEGORIES];
extern const int16_t number_of_vectors[NUM_CATEGORIES];
/* The last category isn't really coded with scalar quantization. */
extern const int16_t max_bin[NUM_CATEGORIES];
extern const int16_t max_bin_plus_one_inverse[NUM_CATEGORIES];
#if defined(G722_1_USE_FIXED_POINT)
extern const int16_t int_region_standard_deviation_table[REGION_POWER_TABLE_SIZE];
extern const int16_t standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE];
extern const int16_t step_size_inverse_table[NUM_CATEGORIES];
extern const int16_t int_dead_zone[NUM_CATEGORIES];
extern const int16_t int_dead_zone_low_bits[NUM_CATEGORIES];
extern const int16_t samples_to_rmlt_window[DCT_LENGTH];
extern const int16_t max_samples_to_rmlt_window[MAX_DCT_LENGTH];
extern const int16_t rmlt_to_samples_window[DCT_LENGTH];
extern const int16_t max_rmlt_to_samples_window[MAX_DCT_LENGTH];
#else
extern const float region_standard_deviation_table[REGION_POWER_TABLE_SIZE];
extern const float standard_deviation_inverse_table[REGION_POWER_TABLE_SIZE];
extern const float step_size_inverse_table[NUM_CATEGORIES];
extern const float dead_zone[NUM_CATEGORIES];
extern const float samples_to_rmlt_window[DCT_LENGTH];
extern const float max_samples_to_rmlt_window[MAX_DCT_LENGTH];
extern const float rmlt_to_samples_window[DCT_LENGTH];
extern const float max_rmlt_to_samples_window[MAX_DCT_LENGTH];
extern const float step_size[NUM_CATEGORIES];
extern const float region_power_table[REGION_POWER_TABLE_SIZE];
extern const float region_power_table_boundary[REGION_POWER_TABLE_SIZE - 1];
#endif
/*- End of file ------------------------------------------------------------*/