Import Upstream version 0.9.3

This commit is contained in:
rtlhq 2022-11-30 21:49:04 +08:00
commit 174be642e2
62 changed files with 71171 additions and 0 deletions

13
AUTHORS Normal file
View File

@ -0,0 +1,13 @@
People who have contributed to libofa:
Frode Holm (frode (at) musicip (dot) com)
Stephen Pope (stp (at) create (dot) ucsb (dot) edu)
Wendell Hicken (whicken (at) musicip (dot) com)
- Initial code
Robert Kaye (rob (at) eorbit (dot) net)
- Autoconf/libtool wrapping
Eric Sandeen (sandeen (at) sgi (dot) com)
- Sent in a small patch to avoid a | vs || ambiguity

1182
COPYING Normal file

File diff suppressed because it is too large Load Diff

25
Makefile.am Normal file
View File

@ -0,0 +1,25 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
SUBDIRS = include lib examples
DIST_SUBDIRS = include lib examples
cvsclean: distclean
@echo "additonal cleanup for cvs commits"
rm -f *~ *.exe
rm -f $(PACKAGE)-$(VERSION).tar.gz
pcdir = $(libdir)/pkgconfig
pc_DATA = libofa.pc
# README.win32 config_win32.h
EXTRA_DIST = libofa.pc.in README COPYING
CLEANFILES = stamp-h

656
Makefile.in Normal file
View File

@ -0,0 +1,656 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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 = :
host_triplet = @host@
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(srcdir)/libofa.pc.in $(top_srcdir)/configure AUTHORS COPYING \
config.guess config.sub depcomp install-sh ltmain.sh missing
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = libofa.pc
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
am__installdirs = "$(DESTDIR)$(pcdir)"
pcDATA_INSTALL = $(INSTALL_DATA)
DATA = $(pc_DATA)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
SUBDIRS = include lib examples
DIST_SUBDIRS = include lib examples
pcdir = $(libdir)/pkgconfig
pc_DATA = libofa.pc
# README.win32 config_win32.h
EXTRA_DIST = libofa.pc.in README COPYING
CLEANFILES = stamp-h
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
am--refresh:
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
libofa.pc: $(top_builddir)/config.status $(srcdir)/libofa.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-pcDATA: $(pc_DATA)
@$(NORMAL_INSTALL)
test -z "$(pcdir)" || $(mkdir_p) "$(DESTDIR)$(pcdir)"
@list='$(pc_DATA)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(pcDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pcdir)/$$f'"; \
$(pcDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pcdir)/$$f"; \
done
uninstall-pcDATA:
@$(NORMAL_UNINSTALL)
@list='$(pc_DATA)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(pcdir)/$$f'"; \
rm -f "$(DESTDIR)$(pcdir)/$$f"; \
done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
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: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) config.h.in $(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: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(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)
$(am__remove_distdir)
mkdir $(distdir)
$(mkdir_p) $(distdir)/.
@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
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
$(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
$(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(AMTAR) xf - ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(DATA) config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(pcdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
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:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-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."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am: install-pcDATA
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am uninstall-pcDATA
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \
check-am clean clean-generic clean-libtool clean-recursive \
ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-generic distclean-hdr distclean-libtool \
distclean-recursive distclean-tags distcleancheck distdir \
distuninstallcheck 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-man \
install-pcDATA install-strip installcheck installcheck-am \
installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am uninstall-pcDATA
cvsclean: distclean
@echo "additonal cleanup for cvs commits"
rm -f *~ *.exe
rm -f $(PACKAGE)-$(VERSION).tar.gz
# 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:

33
README Normal file
View File

@ -0,0 +1,33 @@
README for the Open Fingerprint Architecture library "LIBOFA"
Copyright (C) 2006, MusicIP Corporation
605 E. Huntington Dr. Suite 201, Monrovia CA 91016 USA
Ph +1-626-359-9702 Fax +1-626-359-9827
This program is available as either free software or open source
software. You can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, OR under the terms of the
Adaptive Public License, as published by the Open Source Initiative
(OSI).
You must choose one or the other.
Your redistribution of any applications or code will be bound by the
terms of conditions of the license you choose.
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.
***INFORMAL NOTICES***
The APL license requires "modest attribution." If you choose this
license, any programs using this library (or derivative works from
this library as defined by the APL) must display the
connected_by_musicIP graphic during execution. If the graphic file has
not been included in the source code files you received, it can be
found at
http://www.musicip.com/connected_by_musicip.png or
http://www.musicip.com/connected_by_musicip.gif
This library is by design compatible with the MusicDNS web service.
Non-commercial access to the service is available at www.musicdns.org.

6888
aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

1465
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

68
config.h.in Normal file
View File

@ -0,0 +1,68 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Use libfftw3 */
#undef FFTW3
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of a `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Use vDSP */
#undef VDSP
/* Version number of package */
#undef VERSION
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN

1569
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

22141
configure vendored Executable file

File diff suppressed because it is too large Load Diff

115
configure.in Normal file
View File

@ -0,0 +1,115 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lib/mainprint.cpp)
AM_CONFIG_HEADER(config.h)
VERSION="0.9.3"
AM_INIT_AUTOMAKE(libofa, "$VERSION")
AM_MAINTAINER_MODE
dnl Canonicalize host.
AC_CANONICAL_HOST
case "${host_cpu}-${host_os}" in
*-beos*) os=beos; LIBS='-lbe -lroot' ;;
*-cygwin*) os=cygwin ;;
*-freebsd*) os=freebsd ;;
*-darwin*) os=darwin ;;
*-linux*) os=linux ;;
*-netbsd*) os=netbsd ;;
*-openbsd*) os=openbsd ;;
*-os2_emx*) os=os2 ;;
*-solaris*) os=solaris; LIBS='-lsocket -lnsl' ;;
*-qnx*) os=qnx; LIBS='-lsocket' ;;
*) AC_MSG_RESULT([WARNING: unknown system]) ;;
esac
AM_CONDITIONAL(DARWIN, test x$os = xdarwin)
AM_CONDITIONAL(FREEBSD, test x$os = xfreebsd)
dnl Checks for programs.
AC_PREREQ(2.52)
AC_PROG_AWK
AC_PROG_CC
AC_LIBLTDL_CONVENIENCE
AM_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
AC_PROG_CXX
AC_PROG_INSTALL
PREFIX="${prefix}"
AC_SUBST(PREFIX)
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(long)
if test "$GCC" = yes; then
dnlCFLAGS="$CFLAGS -Wall -O2"
CFLAGS="$CFLAGS -Wall -g"
fi
if test "$GXX" = yes; then
CXXFLAGS="$CXXFLAGS -Wall -g"
fi
dnl Checks for libraries.
dnl libexpat check
AC_CHECK_LIB(expat, XML_ExpatVersion,
[EXPAT_LIBS="-lexpat"], [
echo "*"
echo "* expat is needed to build this library. It is either not"
echo "* installed on your system or it is too old."
echo "* Please download it from http://expat.sourceforge.net."
echo "*"
AC_MSG_ERROR("Cannot build. Stop.")], -lexpat)
AC_SUBST(EXPAT_LIBS)
dnl libcurl check
AC_CHECK_LIB(curl, curl_global_init,
[CURL_LIBS="-lcurl"], [
echo "*"
echo "* libcurl is needed to build this library. It is either not"
echo "* installed on your system or it is too old."
echo "* Please download it http://curl.haxx.se/"
echo "*"
AC_MSG_ERROR("Cannot build. Stop.")], -lcurl)
AC_SUBST(CURL_LIBS)
dnl Support libfftw2 and vSDP and MKL (intel)
dnl FFTW for FFTW v2. FFTW3 for FFTW v3. VDSP for vDSP. MKL for MKL
dnl TODO: PREANSI for win32
if test x$os = xdarwin; then
AC_MSG_NOTICE([Using vDSP on OS X])
LIBS="$LIBS -framework Accelerate"
FFT_WRAPPER="fftlibvdsp_op.cpp"
AM_CONDITIONAL(FFTW3, false)
AM_CONDITIONAL(VDSP, true)
AC_DEFINE_UNQUOTED(VDSP, 1, Use vDSP)
else
AC_MSG_NOTICE([Using libfftw3])
AC_CHECK_LIB(fftw3, fftw_malloc,
[
LIBS="$LIBS -lfftw3"
FFT_WRAPPER="fftlibw3_op.cpp"
AM_CONDITIONAL(FFTW3, true)
AM_CONDITIONAL(VDSP, false)
AC_DEFINE_UNQUOTED(FFTW3, 1, Use libfftw3)
], [
echo "*"
echo "* libfft3 is needed to build this library."
echo "*"
AC_MSG_ERROR("Cannot build. Stop.")])
fi
AC_SUBST(FFT_WRAPPER)
dnl Checks for header files.
dnl Checks for typedefs, structures, and compiler characteristics.
AC_SUBST(CFLAGS)
AC_OUTPUT([
Makefile
include/Makefile
include/ofa1/Makefile
lib/Makefile
lib/JAMA/Makefile
lib/AFLIB/Makefile
examples/Makefile
libofa.pc],
echo timestamp > stamp-h)

526
depcomp Executable file
View File

@ -0,0 +1,526 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2004-04-25.13
# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit 0
;;
-v | --v*)
echo "depcomp $scriptversion"
exit 0
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# `libtool' can also be set to `yes' or `no'.
if test -z "$depfile"; then
base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
dir=`echo "$object" | sed 's,/.*$,/,'`
if test "$dir" = "$object"; then
dir=
fi
# FIXME: should be _deps on DOS.
depfile="$dir.deps/$base"
fi
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# Dependencies are output in .lo.d with libtool 1.4.
# They are output in .o.d with libtool 1.5.
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir.libs/$base.o.d"
tmpdepfile3="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
tmpdepfile3="$dir$base.d"
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
elif test -f "$tmpdepfile2"; then
tmpdepfile="$tmpdepfile2"
else
tmpdepfile="$tmpdepfile3"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

43
examples/COPYING Normal file
View File

@ -0,0 +1,43 @@
Public Domain (PD) 2006 MusicIP Corporation
No rights reserved.
No rights wronged. Ever.
The source code to the examples for libofa have been placed into the
Public Domain. See the dedication below for details:
----------------------------------------------------------------
Copyright-Only Dedication
(based on United States law)
or
Public Domain Certification
The person or persons who have associated work with this document
(the "Dedicator" or "Certifier") hereby either (a) certifies that,
to the best of his knowledge, the work of authorship identified is
in the public domain of the country from which the work is published,
or (b) hereby dedicates whatever copyright the dedicators holds in
the work of authorship identified below (the "Work") to the public
domain. A certifier, moreover, dedicates any copyright interest he
may have in the associated work, and for these purposes, is
described as a "dedicator" below.
A certifier has taken reasonable steps to verify the copyright
status of this work. Certifier recognizes that his good faith
efforts may not shield him from liability if in fact the work
certified is not in the public domain.
Dedicator makes this dedication for the benefit of the public at
large and to the detriment of the Dedicator's heirs and
successors. Dedicator intends this dedication to be an overt
act of relinquishment in perpetuity of all present and future
rights under copyright law, whether vested or contingent, in the
Work. Dedicator understands that such relinquishment of all
rights includes the relinquishment of all rights to enforce
(by lawsuit or otherwise) those copyrights in the Work.
Dedicator recognizes that, once placed in the public domain, the
Work may be freely reproduced, distributed, transmitted, used,
modified, built upon, or otherwise exploited by anyone for
any purpose, commercial or non-commercial, and in any way,
including by methods that have not yet been invented or conceived.

14
examples/Makefile.am Normal file
View File

@ -0,0 +1,14 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
INCLUDES = -I$(top_srcdir)/include
noinst_PROGRAMS = example
example_SOURCES = example.cpp protocol.cpp uselame.cpp wavefile.cpp protocol.h
example_LDADD = @CURL_LIBS@ @EXPAT_LIBS@ $(top_builddir)/lib/libofa.la

460
examples/Makefile.in Normal file
View File

@ -0,0 +1,460 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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@
SOURCES = $(example_SOURCES)
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 = :
host_triplet = @host@
noinst_PROGRAMS = example$(EXEEXT)
subdir = examples
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in COPYING
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(noinst_PROGRAMS)
am_example_OBJECTS = example.$(OBJEXT) protocol.$(OBJEXT) \
uselame.$(OBJEXT) wavefile.$(OBJEXT)
example_OBJECTS = $(am_example_OBJECTS)
example_DEPENDENCIES = $(top_builddir)/lib/libofa.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/example.Po ./$(DEPDIR)/protocol.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/uselame.Po ./$(DEPDIR)/wavefile.Po
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(example_SOURCES)
DIST_SOURCES = $(example_SOURCES)
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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
INCLUDES = -I$(top_srcdir)/include
example_SOURCES = example.cpp protocol.cpp uselame.cpp wavefile.cpp protocol.h
example_LDADD = @CURL_LIBS@ @EXPAT_LIBS@ $(top_builddir)/lib/libofa.la
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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 examples/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu examples/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
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
example$(EXEEXT): $(example_OBJECTS) $(example_DEPENDENCIES)
@rm -f example$(EXEEXT)
$(CXXLINK) $(example_LDFLAGS) $(example_OBJECTS) $(example_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/example.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uselame.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wavefile.Po@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
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)
@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
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
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:
-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."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
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
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstPROGRAMS ctags distclean \
distclean-compile distclean-generic 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-man \
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
# 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:

72
examples/example.cpp Normal file
View File

@ -0,0 +1,72 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Public Domain (PD) 2006 MusicIP Corporation
No rights reserved.
-------------------------------------------------------------------*/
#include "protocol.h"
AudioData* loadWaveFile(char *file);
AudioData* loadDataUsingLAME(char *file);
int main(int argc, char **argv) {
AudioData *data = 0;
// Go through each filename passed on the command line
for (int i = 1; i < argc; ++i) {
char *file = argv[i];
// Get the extension
char fext[100] = "";
char *p = strrchr(file, '.');
if ( p != NULL ) {
strcpy(fext, p+1);
// Lowercase the extension
p = fext;
while ( *p ) {
*p = tolower(*p);
p++;
}
}
if ( strstr(fext, "wav") ) {
// Process a Wave file
printf("Checking file %s\n", file);
data = loadWaveFile(file);
} else {
// Handle anything else
printf("Decoding file %s\n", file);
data = loadDataUsingLAME(file);
}
if (!data) {
printf("** Failed to load file\n");
continue;
}
// Get the fingerprint
if (!data->createPrint()) {
printf("** Failed to generate print.\n");
delete data;
continue;
}
// Get the metadata. Make sure to get your own client id
// at http://www.musicdns.org before using this in your own application.
TrackInformation *info = data->getMetadata("a7f6063296c0f1c9b75c7f511861b89b", "Example 0.9.3", true);
if (!info) {
printf("** Failed to get metadata.\n");
} else {
// Print results.
printf(" Title: %s\n", info->getTrack().c_str());
printf("Artist: %s\n", info->getArtist().c_str());
printf(" PUID: %s\n", info->getPUID().c_str());
}
delete data;
}
return 0;
}

274
examples/protocol.cpp Normal file
View File

@ -0,0 +1,274 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Public Domain (PD) 2006 MusicIP Corporation
No rights reserved.
-------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <expat.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>
using namespace std;
#include "protocol.h"
const char *url = "http://ofa.musicdns.org/ofa/1/track";
const char *userAgent = "libofa_example";
const char *unknown = "unknown";
// Lookup by fingerprint
const char *request_format =
"cid=%s&" // Client ID
"cvr=%s&" // Client Version
"fpt=%s&" // Fingerprint
"rmd=%d&" // m = 1: return metadata; m = 0: only return id
"brt=%d&" // bitrate (kbps)
"fmt=%s&" // File extension (e.g. mp3, ogg, flac)
"dur=%ld&" // Length of track (milliseconds)
"art=%s&" // Artist name. If there is none, send "unknown"
"ttl=%s&" // Track title. If there is none, send "unknown"
"alb=%s&" // Album name. If there is none, send "unknown"
"tnm=%d&" // Track number in album. If there is none, send "0"
"gnr=%s&" // Genre. If there is none, send "unknown"
"yrr=%s&" // Year. If there is none, send "0"
"enc=%s&" // Encoding. e = true: ISO-8859-15; e = false: UTF-8 (default). Optional.
"\r\n";
// Lookup by PUID (Most fields drop out)
const char *request_format2 =
"cid=%s&" // Client ID
"cvr=%s&" // Client Version
"pid=%s&" // PUID
"rmd=%d&" // m = 1: return metadata; m = 0: only return id
"brt=%d&" // bitrate (kbps)
"fmt=%s&" // File extension (e.g. mp3, ogg, flac)
"dur=%ld&" // Length of track (milliseconds)
"art=%s&" // Artist name. If there is none, send "unknown"
"ttl=%s&" // Track title. If there is none, send "unknown"
"alb=%s&" // Album name. If there is none, send "unknown"
"tnm=%d&" // Track number in album. If there is none, send "0"
"gnr=%s&" // Genre. If there is none, send "unknown"
"yrr=%s&" // Year. If there is none, send "0"
"enc=%s&" // Encoding. e = true: ISO-8859-15; e = false: UTF-8 (default). Optional.
"\r\n";
// --------------------------------------------------------------------
// HTTP POST support using standard curl calls
// --------------------------------------------------------------------
size_t data_callback(void *ptr, size_t size, size_t num, void *arg)
{
string *str = (string *)arg;
(*str) += string((const char *)ptr, size * num);
return size * num;
}
long http_post(const string &url, const string &userAgent, const string &postData, string &doc)
{
CURL *curl;
long ret = 0;
struct curl_slist *headerlist=NULL;
headerlist = curl_slist_append(headerlist, "Expect:");
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&doc);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, data_callback);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, postData.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &ret);
curl_easy_cleanup(curl);
curl_slist_free_all (headerlist);
return ret;
}
// --------------------------------------------------------------------
// XML Parsing support
// --------------------------------------------------------------------
struct ParseInfo
{
string path;
string pcdata;
TrackInformation *info;
};
void begin_element(void *data, const XML_Char *el, const XML_Char **attr)
{
map<string, string> attrs;
for(; *attr;) {
string key = string((char *)*(attr++));
string value = string((char *)*(attr++));
attrs[key] = value;
}
((ParseInfo *)data)->path += string("/") + string(el);
if (((ParseInfo *)data)->path == "/metadata/track/puid-list/puid")
((ParseInfo *)data)->info->setPUID(attrs["id"]);
((ParseInfo *)data)->pcdata = "";
}
void end_element(void *data, const XML_Char *el)
{
string::size_type pos;
if (((ParseInfo *)data)->path == "/metadata/track/title")
((ParseInfo *)data)->info->setTrack(((ParseInfo *)data)->pcdata);
if (((ParseInfo *)data)->path == "/metadata/track/artist/name")
((ParseInfo *)data)->info->setArtist(((ParseInfo *)data)->pcdata);
pos = ((ParseInfo *)data)->path.rfind("/");
if (pos != string::npos)
((ParseInfo *)data)->path = ((ParseInfo *)data)->path.substr(0, pos);
}
void pc_data(void *data, const XML_Char *charData, int len)
{
char *temp;
temp = new char[len + 1];
strncpy(temp, (char *)charData, len);
temp[len] = 0;
((ParseInfo *)data)->pcdata += string(temp);
delete temp;
}
bool parse_xml(const string &doc, TrackInformation *info, string &err)
{
ParseInfo pinfo;
err = "";
pinfo.info = info;
XML_Parser parser = XML_ParserCreate(NULL);
XML_SetUserData(parser, (void *)&pinfo);
XML_SetElementHandler(parser, ::begin_element, ::end_element);
XML_SetCharacterDataHandler(parser, ::pc_data);
int ret = XML_Parse(parser, doc.c_str(), doc.length(), 1);
if (ret)
{
XML_ParserFree(parser);
return true;
}
err = string(XML_ErrorString(XML_GetErrorCode(parser)));
char num[10];
sprintf(num, "%d", XML_GetCurrentLineNumber(parser));
err += string(" on line ") + string(num);
XML_ParserFree(parser);
return false;
}
// --------------------------------------------------------------------
// Retrieve metadata for fingerprint
// --------------------------------------------------------------------
// Returns true on success
bool retrieve_metadata(string client_key, string client_version,
TrackInformation *info, bool getMetadata)
{
if (!info)
return false;
// All metadata fields must be provided before this call if the
// information is available, as part of the Terms of Service.
// This helps create a better database for all users of the system.
//
// If the fields are not available, you can use default values.
// Here we check for fields which have no default values.
if (client_key.length() == 0)
return false;
if (client_version.length() == 0)
return false;
bool lookupByPrint = false;
if (info->getPUID().length() == 0) {
// Lookup by fingerprint
if (info->getPrint().length() == 0)
return false;
if (info->getFormat().length() == 0)
return false;
if (info->getLengthInMS() == 0)
return false;
lookupByPrint = true;
}
// Sloppily estimate the size of the resultant URL. Err on the side of making the string too big.
int bufSize = strlen(lookupByPrint ? request_format : request_format2) +
client_key.length() + client_version.length() +
(lookupByPrint ? info->getPrint().length() : info->getPUID().length()) +
16 + // getMetadata ? 1 : 0,
16 + // info->getBitrate(),
16 + //info->getFormat().c_str(),
16 + //info->getLengthInMS(),
((info->getArtist().c_str() == 0) ? strlen(unknown) : info->getArtist().length()) +
((info->getTrack().c_str() == 0) ? strlen(unknown) : info->getTrack().length()) +
((info->getAlbum().c_str() == 0) ? strlen(unknown) : info->getAlbum().length()) +
16 + // info->getTrackNum() +
((info->getGenre().c_str() == 0) ? strlen(unknown) : info->getGenre().length()) +
((info->getYear().c_str() == 0) ? 1 : info->getYear().length()) +
info->getEncoding().length();
char *buf = new char[bufSize];
sprintf(buf, lookupByPrint ? request_format : request_format2,
client_key.c_str(),
client_version.c_str(),
lookupByPrint ? info->getPrint().c_str() : info->getPUID().c_str(),
getMetadata ? 1 : 0,
info->getBitrate(),
info->getFormat().c_str(),
info->getLengthInMS(),
(info->getArtist().length() == 0) ? unknown : info->getArtist().c_str(),
(info->getTrack().length() == 0) ? unknown : info->getTrack().c_str(),
(info->getAlbum().length() == 0) ? unknown : info->getAlbum().c_str(),
info->getTrackNum(),
(info->getGenre().length() == 0) ? unknown : info->getGenre().c_str(),
(info->getYear().length() == 0) ? "0" : info->getYear().c_str(),
info->getEncoding().c_str());
string response;
// printf("request: '%s'\n", buf);
long ret = http_post(url, userAgent, buf, response);
delete [] buf;
if (ret != 200)
{
// printf("Error: %ld\n", ret);
// printf("response: %s\n\n", response.c_str());
return false;
}
// printf("response: %s\n\n", response.c_str());
unsigned int q = response.find("<?xml");
if (q != string::npos) {
response = response.substr(q);
}
string err;
if (!parse_xml(response, info, err)) {
// Clears title if it wasn't returned
info->setTrack("");
// Clears artists if it wasn't returned
info->setArtist("");
}
return true;
}

114
examples/protocol.h Normal file
View File

@ -0,0 +1,114 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Public Domain (PD) 2006 MusicIP Corporation
No rights reserved.
-------------------------------------------------------------------*/
#ifndef __PROTOCOL_H__
#define __PROTOCOL_H__
#include <string>
#include "ofa1/ofa.h"
using namespace std;
// This object must be filled out completely prior to making any
// calls to the server. On return, some fields will be filled out.
class TrackInformation {
private:
string puid;
string print;
string encoding; // All other strings must honor this encoding
int bitrate; // i.e. "192kbps", use 0 for VBR or freeformat
string format; // File extension
long length_in_ms; // In milliseconds
string artist;
string track;
string album;
int trackNum; // use 0 if not known
string genre;
string year;
public:
TrackInformation() :
bitrate(0), length_in_ms(0), trackNum(0) {}
~TrackInformation() {}
void setPrint(string p) { print = p; }
string getPrint() const { return print; }
// Only supported encodings are UTF-8 (default) and ISO-8859-15
void setEncoding(string e) { encoding = e; }
string getEncoding() const { return encoding; }
void setBitrate(int b) { bitrate = b; }
int getBitrate() const { return bitrate; }
void setFormat(string fmt) { format = fmt; }
string getFormat() const { return format; }
void setLengthInMS(long ms) { length_in_ms = ms; }
long getLengthInMS() const { return length_in_ms; }
void setArtist(string name) { artist = name; }
string getArtist() const { return artist; }
void setTrack(string name) { track = name; }
string getTrack() const { return track; }
void setAlbum(string name) { album = name; }
string getAlbum() const { return album; }
void setTrackNum(int t) { trackNum = t; }
int getTrackNum() const { return trackNum; }
void setGenre(string g) { genre = g; }
string getGenre() const { return genre; }
void setYear(string y) { year = y; }
string getYear() const { return year; }
void setPUID(string id) { puid = id; }
string getPUID() const { return puid; }
};
// Get your unique key at http://www.musicdns.org
bool retrieve_metadata(string client_key, string client_verstion,
TrackInformation *info, bool getMetadata);
class AudioData {
private:
unsigned char *samples;
int byteOrder;
long size;
int sRate;
bool stereo;
public:
TrackInformation info;
AudioData() : samples(0), size(0), sRate(0), stereo(false) {}
~AudioData() {
delete[] samples;
}
// size is number of samples (half the number of bytes)
void setData(unsigned char*_samples, int _byteOrder, long _size,
int _sRate, bool _stereo, int _ms, string _fmt) {
samples = _samples;
byteOrder = _byteOrder;
size = _size;
sRate = _sRate;
stereo = _stereo;
// These two fields are used later for the protocol layer
info.setLengthInMS(_ms);
info.setFormat(_fmt);
}
int getByteOrder() const { return byteOrder; }
long getSize() const { return size; }
int getSRate() const { return sRate; }
bool getStereo() const { return stereo; }
bool createPrint() {
const char *print = ofa_create_print(samples, byteOrder, size, sRate, stereo);
if (!print)
return false;
info.setPrint(print);
return true;
}
// Get your unique key at http://www.musicdns.org
TrackInformation *getMetadata(string client_key, string client_version,
bool metadataFlag)
{
if (!retrieve_metadata(client_key, client_version, &info, metadataFlag))
return 0;
return &info;
}
};
#endif

71
examples/uselame.cpp Normal file
View File

@ -0,0 +1,71 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Public Domain (PD) 2006 MusicIP Corporation
No rights reserved.
-------------------------------------------------------------------*/
#include "protocol.h"
#ifdef WIN32
#include "windows.h"
#else
#include <sys/wait.h>
#endif
AudioData *loadWaveFile(char *file);
// loadDataUsingLAME
//
// Opens an audio file and converts it to a temp .wav file
// Calls loadWaveFile to load the data
//
AudioData* loadDataUsingLAME(char *file) {
char *temp = "fpTemp.wav";
#ifdef WIN32
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
char * cmd = new char[1024];
sprintf(cmd,"lame --decode \"%s\" fpTemp.wav", file);
if (!CreateProcess(NULL, // No module name (use command line).
cmd, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
DETACHED_PROCESS, // Creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
return 0;
}
delete[] cmd;
DWORD result = WaitForSingleObject(pi.hProcess, 1000000 /*INFINITE*/);
#else
pid_t pid = fork();
char * flag = "--decode";
char * cmd = "lame"; // lame path
char * argv[4] = {cmd, flag, file, temp};
if (execv(cmd, (char **) argv) == -1) {
return 0;
}
int exitCode = -1;
pid = waitpid(pid, &exitCode, 0); // NYI: Implement timeout
if (exitCode != 0) {
return 0;
}
#endif
AudioData *data = loadWaveFile(temp);
unlink(temp);
return data;
}

151
examples/wavefile.cpp Normal file
View File

@ -0,0 +1,151 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Public Domain (PD) 2006 MusicIP Corporation
No rights reserved.
-------------------------------------------------------------------*/
#include "protocol.h"
#ifdef WIN32
#include "io.h"
#endif
#include <fcntl.h>
static bool readBytes(int fd, unsigned char *buf, int size) {
int ct = 0;
while (ct < size) {
unsigned char tmp[4096];
int x = size - ct;
if (x > 4096)
x = 4096;
int n = read(fd, tmp, x);
if (n <= 0) {
return false;
}
for (int i = 0; i < n; ++i) {
buf[ct + i] = tmp[i];
}
ct += n;
}
return true;
}
// This method only supports PCM/uncompressed format, with a single fmt
// chunk followed by a single data chunk
AudioData* loadWaveFile(char *file) {
int srate = 0;
int channels = 0;
int fd = open(file, O_RDONLY | 0x8000);
if (fd == -1)
return 0;
if (lseek(fd, 0L, SEEK_SET) == -1L) {
close(fd);
return 0;
}
unsigned char hdr[36];
if (!readBytes(fd, hdr, 36)) {
close(fd);
return 0;
}
if (hdr[0] != 'R' || hdr[1] != 'I' || hdr[2] != 'F' || hdr[3] != 'F') {
close(fd);
return 0;
}
// Note: bytes 4 thru 7 contain the file size - 8 bytes
if (hdr[8] != 'W' || hdr[9] != 'A' || hdr[10] != 'V' || hdr[11] != 'E') {
close(fd);
return 0;
}
if (hdr[12] != 'f' || hdr[13] != 'm' || hdr[14] != 't' || hdr[15] != ' ') {
close(fd);
return 0;
}
long extraBytes = hdr[16] + (hdr[17] << 8) + (hdr[18] << 16) + (hdr[19] << 24) - 16;
int compression = hdr[20] + (hdr[21] << 8);
// Type 1 is PCM/Uncompressed
if (compression != 1) {
close(fd);
return 0;
}
channels = hdr[22] + (hdr[23] << 8);
// Only mono or stereo PCM is supported in this example
if (channels < 1 || channels > 2) {
close(fd);
return 0;
}
// Samples per second, independent of number of channels
srate = hdr[24] + (hdr[25] << 8) + (hdr[26] << 16) + (hdr[27] << 24);
// Bytes 28-31 contain the "average bytes per second", unneeded here
// Bytes 32-33 contain the number of bytes per sample (includes channels)
// Bytes 34-35 contain the number of bits per single sample
int bits = hdr[34] + (hdr[35] << 8);
// Supporting othe sample depths will require conversion
if (bits != 16) {
close(fd);
return 0;
}
// Skip past extra bytes, if any
if (lseek(fd, 36L + extraBytes, SEEK_SET) == -1L) {
close(fd);
return 0;
}
// Start reading the next frame. Only supported frame is the data block
unsigned char b[8];
if (!readBytes(fd, b, 8)) {
close(fd);
return 0;
}
// Do we have a fact block?
if (b[0] == 'f' && b[1] == 'a' && b[2] == 'c' && b[3] == 't') {
// Skip the fact block
if (lseek(fd, 36L + extraBytes + 12L, SEEK_SET) == -1L) {
close(fd);
return 0;
}
// Read the next frame
if (!readBytes(fd, b, 8)) {
close(fd);
return 0;
}
}
// Now look for the data block
if (b[0] != 'd' || b[1] != 'a' || b[2] != 't' || b[3] != 'a') {
close(fd);
return 0;
}
long bytes = b[4] + (b[5] << 8) + (b[6] << 16) + (b[7] << 24);
long ms = (bytes/2)/(srate/1000);
if ( channels == 2 ) ms /= 2;
// No need to read the whole file, just the first 135 seconds
int sampleSize = 135;
long bytesInNSecs = sampleSize * srate * 2 * channels;
bytes = bytes > bytesInNSecs ? bytesInNSecs : bytes;
unsigned char *samples = new unsigned char[bytes];
if (!readBytes(fd, samples, bytes)) {
delete[] samples;
close(fd);
return 0;
}
close(fd);
AudioData *data = new AudioData();
data->setData(samples, OFA_LITTLE_ENDIAN, bytes/2, srate,
channels == 2 ? 1 : 0, ms, "wav");
return data;
}

11
include/Makefile.am Normal file
View File

@ -0,0 +1,11 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
SUBDIRS = ofa1

475
include/Makefile.in Normal file
View File

@ -0,0 +1,475 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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 = :
host_triplet = @host@
subdir = include
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
SUBDIRS = ofa1
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --foreign include/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign include/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
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: ctags-recursive $(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)
@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
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
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:
-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."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libtool clean-recursive ctags \
ctags-recursive distclean distclean-generic distclean-libtool \
distclean-recursive 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-man install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-libtool \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# 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:

12
include/ofa1/Makefile.am Normal file
View File

@ -0,0 +1,12 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
ofa_incdir = $(includedir)/ofa1
ofa_inc_HEADERS = ofa.h

405
include/ofa1/Makefile.in Normal file
View File

@ -0,0 +1,405 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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 = :
host_triplet = @host@
subdir = include/ofa1
DIST_COMMON = $(ofa_inc_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
am__installdirs = "$(DESTDIR)$(ofa_incdir)"
ofa_incHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(ofa_inc_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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
ofa_incdir = $(includedir)/ofa1
ofa_inc_HEADERS = ofa.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --foreign include/ofa1/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign include/ofa1/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-ofa_incHEADERS: $(ofa_inc_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(ofa_incdir)" || $(mkdir_p) "$(DESTDIR)$(ofa_incdir)"
@list='$(ofa_inc_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(ofa_incHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(ofa_incdir)/$$f'"; \
$(ofa_incHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(ofa_incdir)/$$f"; \
done
uninstall-ofa_incHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(ofa_inc_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f '$(DESTDIR)$(ofa_incdir)/$$f'"; \
rm -f "$(DESTDIR)$(ofa_incdir)/$$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)
@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
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS)
installdirs:
for dir in "$(DESTDIR)$(ofa_incdir)"; 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:
-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."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-ofa_incHEADERS
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-ofa_incHEADERS
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \
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-man install-ofa_incHEADERS \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-ofa_incHEADERS
# 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:

32
include/ofa1/ofa.h Normal file
View File

@ -0,0 +1,32 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
#ifndef _OFA_H_
#define _OFA_H_
#ifdef __cplusplus
extern "C"
{
#endif
#define OFA_LITTLE_ENDIAN (0)
#define OFA_BIG_ENDIAN (1)
/* Retrieve the version of the library */
void ofa_get_version(int *major, int *minor, int *rev);
/* This is the simplest interface required to generate fingerprints.
examples/protocol.h defines some higher level classes which can be connected
to codecs in various formats for a higher level API */
const char *ofa_create_print(unsigned char* samples, int byteOrder, long size, int sRate, int stereo);
#ifdef __cplusplus
}
#endif
#endif

325
install-sh Executable file
View File

@ -0,0 +1,325 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2004-04-01.17
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=
transform_arg=
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 -d DIRECTORIES...
In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
In the second, create the directory path DIR.
Options:
-b=TRANSFORMBASENAME
-c copy source (using $cpprog) instead of moving (using $mvprog).
-d create directories instead of installing files.
-g GROUP $chgrp installed files to GROUP.
-m MODE $chmod installed files to MODE.
-o USER $chown installed files to USER.
-s strip installed files (using $stripprog).
-t=TRANSFORM
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
-c) instcmd=$cpprog
shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit 0;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
--version) echo "$0 $scriptversion"; exit 0;;
*) # When -d is used, all remaining arguments are directories to create.
test -n "$dir_arg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
instcmd=:
chmodcmd=
else
instcmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp" || lasterr=$?
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $instcmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
# If we're going to rename the final executable, determine the name now.
if test -z "$transformarg"; then
dstfile=`basename "$dst"`
else
dstfile=`basename "$dst" $transformbasename \
| sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename.
test -z "$dstfile" && dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
# Move or copy the file name to the temp name
$doit $instcmd "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

12
lib/AFLIB/Makefile.am Normal file
View File

@ -0,0 +1,12 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
noinst_LTLIBRARIES = libaflib.la
libaflib_la_SOURCES = aflibConverter.cpp aflibConverter.h aflibConverterLargeFilter.h aflibConverterSmallFilter.h
#EXTRA_DIST = aflibConverter.h aflibConverterLargeFilter.h aflibConverterSmallFilter.h

456
lib/AFLIB/Makefile.in Normal file
View File

@ -0,0 +1,456 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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@
SOURCES = $(libaflib_la_SOURCES)
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 = :
host_triplet = @host@
subdir = lib/AFLIB
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libaflib_la_LIBADD =
am_libaflib_la_OBJECTS = aflibConverter.lo
libaflib_la_OBJECTS = $(am_libaflib_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/aflibConverter.Plo
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libaflib_la_SOURCES)
DIST_SOURCES = $(libaflib_la_SOURCES)
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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
noinst_LTLIBRARIES = libaflib.la
libaflib_la_SOURCES = aflibConverter.cpp aflibConverter.h aflibConverterLargeFilter.h aflibConverterSmallFilter.h
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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 lib/AFLIB/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/AFLIB/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_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
libaflib.la: $(libaflib_la_OBJECTS) $(libaflib_la_DEPENDENCIES)
$(CXXLINK) $(libaflib_la_LDFLAGS) $(libaflib_la_OBJECTS) $(libaflib_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aflibConverter.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
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)
@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
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
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:
-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."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
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
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
distclean-compile distclean-generic 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-man \
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
#EXTRA_DIST = aflibConverter.h aflibConverterLargeFilter.h aflibConverterSmallFilter.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:

View File

@ -0,0 +1,803 @@
/*
* Copyright: (C) 2000 Julius O. Smith
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Julius O. Smith jos@ccrma.stanford.edu
*
*/
/* This code was modified by Bruce Forsberg (forsberg@tns.net) to make it
into a C++ class
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "aflibConverter.h"
#include "aflibConverterLargeFilter.h"
#include "aflibConverterSmallFilter.h"
#include "../error_op.h" // inserted by OnePrint
//#include "aflibDebug.h"
#if (!defined(TRUE) || !defined(FALSE))
# define TRUE 1
# define FALSE 0
#endif
/*
* The configuration constants below govern
* the number of bits in the input sample and filter coefficients, the
* number of bits to the right of the binary-point for fixed-point math, etc.
*/
/* Conversion constants */
#define Nhc 8
#define Na 7
#define Np (Nhc+Na)
#define Npc (1<<Nhc)
#define Amask ((1<<Na)-1)
#define Pmask ((1<<Np)-1)
#define Nh 16
#define Nb 16
#define Nhxn 14
#define Nhg (Nh-Nhxn)
#define NLpScl 13
/* Description of constants:
*
* Npc - is the number of look-up values available for the lowpass filter
* between the beginning of its impulse response and the "cutoff time"
* of the filter. The cutoff time is defined as the reciprocal of the
* lowpass-filter cut off frequence in Hz. For example, if the
* lowpass filter were a sinc function, Npc would be the index of the
* impulse-response lookup-table corresponding to the first zero-
* crossing of the sinc function. (The inverse first zero-crossing
* time of a sinc function equals its nominal cutoff frequency in Hz.)
* Npc must be a power of 2 due to the details of the current
* implementation. The default value of 512 is sufficiently high that
* using linear interpolation to fill in between the table entries
* gives approximately 16-bit accuracy in filter coefficients.
*
* Nhc - is log base 2 of Npc.
*
* Na - is the number of bits devoted to linear interpolation of the
* filter coefficients.
*
* Np - is Na + Nhc, the number of bits to the right of the binary point
* in the integer "time" variable. To the left of the point, it indexes
* the input array (X), and to the right, it is interpreted as a number
* between 0 and 1 sample of the input X. Np must be less than 16 in
* this implementation.
*
* Nh - is the number of bits in the filter coefficients. The sum of Nh and
* the number of bits in the input data (typically 16) cannot exceed 32.
* Thus Nh should be 16. The largest filter coefficient should nearly
* fill 16 bits (32767).
*
* Nb - is the number of bits in the input data. The sum of Nb and Nh cannot
* exceed 32.
*
* Nhxn - is the number of bits to right shift after multiplying each input
* sample times a filter coefficient. It can be as great as Nh and as
* small as 0. Nhxn = Nh-2 gives 2 guard bits in the multiply-add
* accumulation. If Nhxn=0, the accumulation will soon overflow 32 bits.
*
* Nhg - is the number of guard bits in mpy-add accumulation (equal to Nh-Nhxn)
*
* NLpScl - is the number of bits allocated to the unity-gain normalization
* factor. The output of the lowpass filter is multiplied by LpScl and
* then right-shifted NLpScl bits. To avoid overflow, we must have
* Nb+Nhg+NLpScl < 32.
*/
aflibConverter::aflibConverter(
bool high_quality,
bool linear_interpolation,
bool filter_interpolation)
{
/* TODO put all these into an enum as it only makes sense to have
* one true at a time. - DAS
*/
interpFilt = filter_interpolation;
largeFilter = high_quality;
linearInterp = linear_interpolation;
_Xv = NULL;
_Yv = NULL;
_vol = 1.0;
}
aflibConverter::~aflibConverter()
{
deleteMemory();
}
void
aflibConverter::deleteMemory()
{
int i;
// Delete memory for the input and output arrays
if (_Xv != NULL)
{
for (i = 0; i < _nChans; i++)
{
delete [] _Xv[i];
_Xv[i] = NULL;
delete [] _Yv[i];
_Yv[i] = NULL;
}
delete [] _Xv;
_Xv = NULL;
delete [] _Yv;
_Yv = NULL;
}
}
void
aflibConverter::initialize(
double fac,
int channels,
double volume)
{
// This function will allow one to stream data. When a new data stream is to
// be input then this function should be called. Even if the factor and number
// of channels don't change. Otherwise each new data block sent to resample
// will be considered part of the previous data block. This function also allows
// one to specified a multiplication factor to adjust the final output. This
// applies to the small and large filter.
int i;
// Delete all previous allocated input and output buffer memory
deleteMemory();
_factor = fac;
_nChans = channels;
_initial = TRUE;
_vol = volume;
// Allocate all new memory
_Xv = new short * [_nChans];
_Yv = new short * [_nChans];
for (i = 0; i < _nChans; i++)
{
// Add extra to allow of offset of input data (Xoff in main routine)
_Xv[i] = new short[IBUFFSIZE + 256];
_Yv[i] = new short[(int)(((double)IBUFFSIZE)*_factor)];
memset(_Xv[i], 0, sizeof(short) * (IBUFFSIZE + 256));
}
}
int
aflibConverter::resample( /* number of output samples returned */
int& inCount, /* number of input samples to convert */
int outCount, /* number of output samples to compute */
short inArray[], /* input data */
short outArray[]) /* output data */
{
int Ycount;
// Use fast method with no filtering. Poor quality
if (linearInterp == TRUE)
Ycount = resampleFast(inCount,outCount,inArray,outArray);
// Use small filtering. Good qulaity
else if (largeFilter == FALSE)
Ycount = resampleWithFilter(inCount,outCount,inArray,outArray,
SMALL_FILTER_IMP, SMALL_FILTER_IMPD,
(unsigned short)(SMALL_FILTER_SCALE * _vol),
SMALL_FILTER_NMULT, SMALL_FILTER_NWING);
// Use large filtering Great quality
else
Ycount = resampleWithFilter(inCount,outCount,inArray,outArray,
LARGE_FILTER_IMP, LARGE_FILTER_IMPD,
(unsigned short)(LARGE_FILTER_SCALE * _vol),
LARGE_FILTER_NMULT, LARGE_FILTER_NWING);
_initial = FALSE;
return (Ycount);
}
int
aflibConverter::err_ret(char *s)
{
// aflib_debug("resample: %s \n\n",s); /* Display error message */
return -1;
}
int
aflibConverter::readData(
int inCount, /* _total_ number of frames in input file */
short inArray[], /* input data */
short *outPtr[], /* array receiving chan samps */
int dataArraySize, /* size of these arrays */
int Xoff, /* read into input array starting at this index */
bool init_count)
{
int i, Nsamps, c;
static unsigned int framecount; /* frames previously read */
short *ptr;
if (init_count == TRUE)
framecount = 0; /* init this too */
Nsamps = dataArraySize - Xoff; /* Calculate number of samples to get */
// Don't overrun input buffers
if (Nsamps > (inCount - (int)framecount))
{
Nsamps = inCount - framecount;
}
for (c = 0; c < _nChans; c++)
{
ptr = outPtr[c];
ptr += Xoff; /* Start at designated sample number */
for (i = 0; i < Nsamps; i++)
*ptr++ = (short) inArray[c * inCount + i + framecount];
}
framecount += Nsamps;
if ((int)framecount >= inCount) /* return index of last samp */
return (((Nsamps - (framecount - inCount)) - 1) + Xoff);
else
return 0;
}
int
aflibConverter::SrcLinear(
short X[],
short Y[],
double factor,
unsigned int *Time,
unsigned short& Nx,
unsigned short Nout)
{
short iconst;
short *Xp, *Ystart;
int v,x1,x2;
double dt; /* Step through input signal */
unsigned int dtb; /* Fixed-point version of Dt */
// unsigned int endTime; /* When Time reaches EndTime, return to user */
unsigned int start_sample, end_sample;
dt = 1.0/factor; /* Output sampling period */
dtb = (unsigned int)(dt*(1<<Np) + 0.5); /* Fixed-point representation */
start_sample = (*Time)>>Np;
Ystart = Y;
// endTime = *Time + (1<<Np)*(int)Nx;
/*
* TODO
* DAS: not sure why this was changed from *Time < endTime
* update: *Time < endTime causes seg fault. Also adds a clicking sound.
*/
while (Y - Ystart != Nout)
// while (*Time < endTime)
{
iconst = (*Time) & Pmask;
Xp = &X[(*Time)>>Np]; /* Ptr to current input sample */
x1 = *Xp++;
x2 = *Xp;
x1 *= ((1<<Np)-iconst);
x2 *= iconst;
v = x1 + x2;
*Y++ = WordToHword(v,Np); /* Deposit output */
*Time += dtb; /* Move to next sample by time increment */
}
end_sample = (*Time)>>Np;
Nx = end_sample - start_sample;
return (Y - Ystart); /* Return number of output samples */
}
int
aflibConverter::SrcUp(
short X[],
short Y[],
double factor,
unsigned int *Time,
unsigned short& Nx,
unsigned short Nout,
unsigned short Nwing,
unsigned short LpScl,
short Imp[],
short ImpD[],
bool Interp)
{
short *Xp, *Ystart;
int v;
double dt; /* Step through input signal */
unsigned int dtb; /* Fixed-point version of Dt */
// unsigned int endTime; /* When Time reaches EndTime, return to user */
unsigned int start_sample, end_sample;
dt = 1.0/factor; /* Output sampling period */
dtb = (unsigned int)(dt*(1<<Np) + 0.5); /* Fixed-point representation */
start_sample = (*Time)>>Np;
Ystart = Y;
// endTime = *Time + (1<<Np)*(int)Nx;
/*
* TODO
* DAS: not sure why this was changed from *Time < endTime
* update: *Time < endTime causes seg fault. Also adds a clicking sound.
*/
while (Y - Ystart != Nout)
// while (*Time < endTime)
{
Xp = &X[*Time>>Np]; /* Ptr to current input sample */
/* Perform left-wing inner product */
v = FilterUp(Imp, ImpD, Nwing, Interp, Xp, (short)(*Time&Pmask),-1);
/* Perform right-wing inner product */
v += FilterUp(Imp, ImpD, Nwing, Interp, Xp+1,
(short)((((*Time)^Pmask)+1)&Pmask), 1);
v >>= Nhg; /* Make guard bits */
v *= LpScl; /* Normalize for unity filter gain */
*Y++ = WordToHword(v,NLpScl); /* strip guard bits, deposit output */
*Time += dtb; /* Move to next sample by time increment */
}
end_sample = (*Time)>>Np;
Nx = end_sample - start_sample;
return (Y - Ystart); /* Return the number of output samples */
}
int
aflibConverter::SrcUD(
short X[],
short Y[],
double factor,
unsigned int *Time,
unsigned short& Nx,
unsigned short Nout,
unsigned short Nwing,
unsigned short LpScl,
short Imp[],
short ImpD[],
bool Interp)
{
short *Xp, *Ystart;
int v;
double dh; /* Step through filter impulse response */
double dt; /* Step through input signal */
// unsigned int endTime; /* When Time reaches EndTime, return to user */
unsigned int dhb, dtb; /* Fixed-point versions of Dh,Dt */
unsigned int start_sample, end_sample;
dt = 1.0/factor; /* Output sampling period */
dtb = (unsigned int)(dt*(1<<Np) + 0.5); /* Fixed-point representation */
dh = MIN(Npc, factor*Npc); /* Filter sampling period */
dhb = (unsigned int)(dh*(1<<Na) + 0.5); /* Fixed-point representation */
start_sample = (*Time)>>Np;
Ystart = Y;
// endTime = *Time + (1<<Np)*(int)Nx;
/*
* TODO
* DAS: not sure why this was changed from *Time < endTime
* update: *Time < endTime causes seg fault. Also adds a clicking sound.
*/
while (Y - Ystart != Nout)
// while (*Time < endTime)
{
Xp = &X[*Time>>Np]; /* Ptr to current input sample */
v = FilterUD(Imp, ImpD, Nwing, Interp, Xp, (short)(*Time&Pmask),
-1, dhb); /* Perform left-wing inner product */
v += FilterUD(Imp, ImpD, Nwing, Interp, Xp+1,
(short)((((*Time)^Pmask)+1)&Pmask), 1, dhb); /* Perform right-wing inner product */
v >>= Nhg; /* Make guard bits */
v *= LpScl; /* Normalize for unity filter gain */
*Y++ = WordToHword(v,NLpScl); /* strip guard bits, deposit output */
*Time += dtb; /* Move to next sample by time increment */
}
end_sample = (*Time)>>Np;
Nx = end_sample - start_sample;
return (Y - Ystart); /* Return the number of output samples */
}
int
aflibConverter::resampleFast( /* number of output samples returned */
int& inCount, /* number of input samples to convert */
int outCount, /* number of output samples to compute */
short inArray[], /* input data */
short outArray[]) /* output data */
{
unsigned int Time2; /* Current time/pos in input sample */
#if 0
unsigned short Ncreep;
#endif
unsigned short Xp, Xoff, Xread;
int OBUFFSIZE = (int)(((double)IBUFFSIZE)*_factor);
unsigned short Nout = 0, Nx, orig_Nx;
unsigned short maxOutput;
int total_inCount = 0;
int c, i, Ycount, last;
bool first_pass = TRUE;
Xoff = 10;
Nx = IBUFFSIZE - 2*Xoff; /* # of samples to process each iteration */
last = 0; /* Have not read last input sample yet */
Ycount = 0; /* Current sample and length of output file */
Xp = Xoff; /* Current "now"-sample pointer for input */
Xread = Xoff; /* Position in input array to read into */
if (_initial == TRUE)
_Time = (Xoff<<Np); /* Current-time pointer for converter */
do {
if (!last) /* If haven't read last sample yet */
{
last = readData(inCount, inArray, _Xv,
IBUFFSIZE, (int)Xread,first_pass);
first_pass = FALSE;
if (last && (last-Xoff<Nx)) { /* If last sample has been read... */
Nx = last-Xoff; /* ...calc last sample affected by filter */
if (Nx <= 0)
break;
}
}
if ((outCount-Ycount) > (OBUFFSIZE - (2*Xoff*_factor)) )
maxOutput = OBUFFSIZE - (unsigned short)(2*Xoff*_factor);
else
maxOutput = outCount-Ycount;
for (c = 0; c < _nChans; c++)
{
orig_Nx = Nx;
Time2 = _Time;
/* Resample stuff in input buffer */
Nout=SrcLinear(_Xv[c],_Yv[c],_factor,&Time2,orig_Nx,maxOutput);
}
Nx = orig_Nx;
_Time = Time2;
_Time -= (Nx<<Np); /* Move converter Nx samples back in time */
Xp += Nx; /* Advance by number of samples processed */
#if 0
Ncreep = (Time>>Np) - Xoff; /* Calc time accumulation in Time */
if (Ncreep) {
Time -= (Ncreep<<Np); /* Remove time accumulation */
Xp += Ncreep; /* and add it to read pointer */
}
#endif
for (c = 0; c < _nChans; c++)
{
for (i=0; i<IBUFFSIZE-Xp+Xoff; i++) { /* Copy part of input signal */
_Xv[c][i] = _Xv[c][i+Xp-Xoff]; /* that must be re-used */
}
}
if (last) { /* If near end of sample... */
last -= Xp; /* ...keep track were it ends */
if (!last) /* Lengthen input by 1 sample if... */
last++; /* ...needed to keep flag TRUE */
}
Xread = IBUFFSIZE - Nx; /* Pos in input buff to read new data into */
Xp = Xoff;
Ycount += Nout;
if (Ycount>outCount) {
Nout -= (Ycount-outCount);
Ycount = outCount;
}
if (Nout > OBUFFSIZE) /* Check to see if output buff overflowed */
// return err_ret("Output array overflow");
throw OnePrintError("Output array overflow"); // Added by OnePrint
for (c = 0; c < _nChans; c++)
for (i = 0; i < Nout; i++)
outArray[c * outCount + i + Ycount - Nout] = _Yv[c][i];
total_inCount += Nx;
} while (Ycount < outCount); /* Continue until done */
inCount = total_inCount;
return(Ycount); /* Return # of samples in output file */
}
int
aflibConverter::resampleWithFilter( /* number of output samples returned */
int& inCount, /* number of input samples to convert */
int outCount, /* number of output samples to compute */
short inArray[], /* input data */
short outArray[], /* output data */
short Imp[], short ImpD[],
unsigned short LpScl, unsigned short Nmult, unsigned short Nwing)
{
unsigned int Time2; /* Current time/pos in input sample */
#if 0
unsigned short Ncreep;
#endif
unsigned short Xp, Xoff, Xread;
int OBUFFSIZE = (int)(((double)IBUFFSIZE)*_factor);
unsigned short Nout = 0, Nx, orig_Nx;
unsigned short maxOutput;
int total_inCount = 0;
int c, i, Ycount, last;
bool first_pass = TRUE;
/* Account for increased filter gain when using factors less than 1 */
if (_factor < 1)
LpScl = (unsigned short)(LpScl*_factor + 0.5);
/* Calc reach of LP filter wing & give some creeping room */
Xoff = (unsigned short)(((Nmult+1)/2.0) * MAX(1.0,1.0/_factor) + 10);
if (IBUFFSIZE < 2*Xoff) /* Check input buffer size */
// return err_ret("IBUFFSIZE (or factor) is too small");
throw OnePrintError("IBUFFSIZE (or factor) is too small"); // Added by OnePrint
Nx = IBUFFSIZE - 2*Xoff; /* # of samples to process each iteration */
last = 0; /* Have not read last input sample yet */
Ycount = 0; /* Current sample and length of output file */
Xp = Xoff; /* Current "now"-sample pointer for input */
Xread = Xoff; /* Position in input array to read into */
if (_initial == TRUE)
_Time = (Xoff<<Np); /* Current-time pointer for converter */
do {
if (!last) /* If haven't read last sample yet */
{
last = readData(inCount, inArray, _Xv,
IBUFFSIZE, (int)Xread,first_pass);
first_pass = FALSE;
if (last && (last-Xoff<Nx)) { /* If last sample has been read... */
Nx = last-Xoff; /* ...calc last sample affected by filter */
if (Nx <= 0)
break;
}
}
if ( (outCount-Ycount) > (OBUFFSIZE - (2*Xoff*_factor)) )
maxOutput = OBUFFSIZE - (unsigned short)(2*Xoff*_factor);
else
maxOutput = outCount-Ycount;
for (c = 0; c < _nChans; c++)
{
orig_Nx = Nx;
Time2 = _Time;
/* Resample stuff in input buffer */
if (_factor >= 1) { /* SrcUp() is faster if we can use it */
Nout=SrcUp(_Xv[c],_Yv[c],_factor,
&Time2,Nx,maxOutput,Nwing,LpScl,Imp,ImpD,interpFilt);
}
else {
Nout=SrcUD(_Xv[c],_Yv[c],_factor,
&Time2,Nx,maxOutput,Nwing,LpScl,Imp,ImpD,interpFilt);
}
}
_Time = Time2;
_Time -= (Nx<<Np); /* Move converter Nx samples back in time */
Xp += Nx; /* Advance by number of samples processed */
#if 0
Ncreep = (Time>>Np) - Xoff; /* Calc time accumulation in Time */
if (Ncreep) {
Time -= (Ncreep<<Np); /* Remove time accumulation */
Xp += Ncreep; /* and add it to read pointer */
}
#endif
if (last) { /* If near end of sample... */
last -= Xp; /* ...keep track were it ends */
if (!last) /* Lengthen input by 1 sample if... */
last++; /* ...needed to keep flag TRUE */
}
Ycount += Nout;
if (Ycount > outCount) {
Nout -= (Ycount - outCount);
Ycount = outCount;
}
if (Nout > OBUFFSIZE) /* Check to see if output buff overflowed */
// return err_ret("Output array overflow");
throw OnePrintError("Output array overflow"); // Added by OnePrint
for (c = 0; c < _nChans; c++)
{
for (i = 0; i < Nout; i++)
{
outArray[c * outCount + i + Ycount - Nout] = _Yv[c][i];
}
}
int act_incount = (int)Nx;
for (c = 0; c < _nChans; c++)
{
for (i=0; i<IBUFFSIZE-act_incount+Xoff; i++) { /* Copy part of input signal */
_Xv[c][i] = _Xv[c][i+act_incount]; /* that must be re-used */
}
}
Xread = IBUFFSIZE - Nx; /* Pos in input buff to read new data into */
Xp = Xoff;
total_inCount += Nx;
} while (Ycount < outCount); /* Continue until done */
inCount = total_inCount;
return(Ycount); /* Return # of samples in output file */
}
int
aflibConverter::FilterUp(
short Imp[],
short ImpD[],
unsigned short Nwing,
bool Interp,
short *Xp,
short Ph,
short Inc)
{
short *Hp, *Hdp = NULL, *End;
short a = 0;
int v, t;
v=0;
Hp = &Imp[Ph>>Na];
End = &Imp[Nwing];
if (Interp)
{
Hdp = &ImpD[Ph>>Na];
a = Ph & Amask;
}
if (Inc == 1) /* If doing right wing... */
{ /* ...drop extra coeff, so when Ph is */
End--; /* 0.5, we don't do too many mult's */
if (Ph == 0) /* If the phase is zero... */
{ /* ...then we've already skipped the */
Hp += Npc; /* first sample, so we must also */
Hdp += Npc; /* skip ahead in Imp[] and ImpD[] */
}
}
if (Interp)
{
while (Hp < End)
{
t = *Hp; /* Get filter coeff */
t += (((int)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */
Hdp += Npc; /* Filter coeff differences step */
t *= *Xp; /* Mult coeff by input sample */
if (t & (1<<(Nhxn-1))) /* Round, if needed */
t += (1<<(Nhxn-1));
t >>= Nhxn; /* Leave some guard bits, but come back some */
v += t; /* The filter output */
Hp += Npc; /* Filter coeff step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
}
}
else
{
while (Hp < End)
{
t = *Hp; /* Get filter coeff */
t *= *Xp; /* Mult coeff by input sample */
if (t & (1<<(Nhxn-1))) /* Round, if needed */
t += (1<<(Nhxn-1));
t >>= Nhxn; /* Leave some guard bits, but come back some */
v += t; /* The filter output */
Hp += Npc; /* Filter coeff step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
}
}
return(v);
}
int
aflibConverter::FilterUD(
short Imp[],
short ImpD[],
unsigned short Nwing,
bool Interp,
short *Xp,
short Ph,
short Inc,
unsigned short dhb)
{
short a;
short *Hp, *Hdp, *End;
int v, t;
unsigned int Ho;
v=0;
Ho = (Ph*(unsigned int)dhb)>>Np;
End = &Imp[Nwing];
if (Inc == 1) /* If doing right wing... */
{ /* ...drop extra coeff, so when Ph is */
End--; /* 0.5, we don't do too many mult's */
if (Ph == 0) /* If the phase is zero... */
Ho += dhb; /* ...then we've already skipped the */
} /* first sample, so we must also */
/* skip ahead in Imp[] and ImpD[] */
if (Interp)
{
while ((Hp = &Imp[Ho>>Na]) < End)
{
t = *Hp; /* Get IR sample */
Hdp = &ImpD[Ho>>Na]; /* get interp (lower Na) bits from diff table*/
a = Ho & Amask; /* a is logically between 0 and 1 */
t += (((int)*Hdp)*a)>>Na; /* t is now interp'd filter coeff */
t *= *Xp; /* Mult coeff by input sample */
if (t & 1<<(Nhxn-1)) /* Round, if needed */
t += 1<<(Nhxn-1);
t >>= Nhxn; /* Leave some guard bits, but come back some */
v += t; /* The filter output */
Ho += dhb; /* IR step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
}
}
else
{
while ((Hp = &Imp[Ho>>Na]) < End)
{
t = *Hp; /* Get IR sample */
t *= *Xp; /* Mult coeff by input sample */
if (t & 1<<(Nhxn-1)) /* Round, if needed */
t += 1<<(Nhxn-1);
t >>= Nhxn; /* Leave some guard bits, but come back some */
v += t; /* The filter output */
Ho += dhb; /* IR step */
Xp += Inc; /* Input signal step. NO CHECK ON BOUNDS */
}
}
return(v);
}

238
lib/AFLIB/aflibConverter.h Normal file
View File

@ -0,0 +1,238 @@
/*
* Copyright: (C) 2000 Julius O. Smith
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Julius O. Smith jos@ccrma.stanford.edu
*
*/
/* This code was modified by Bruce Forsberg (forsberg@tns.net) to make it
into a C++ class
*/
#ifndef _AFLIBCONVERTER_H_
#define _AFLIBCONVERTER_H_
/*
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
*/
#ifndef MAX
#define MAX(x,y) ((x)>(y) ?(x):(y))
#endif
#ifndef MIN
#define MIN(x,y) ((x)<(y) ?(x):(y))
#endif
#define MAX_HWORD (32767)
#define MIN_HWORD (-32768)
#define IBUFFSIZE 4096 /* Input buffer size */
/*! \class aflibConverter
\brief Provides sample rate conversion.
This class will perform audio resampling. With the constructor you can choose the
type of resampling to be done. Simple linear interpolation can be done by setting
linear_interpolation to be TRUE in the constructor. The other two flags are
ignored if this is set. If linear_interpolation is FALSE then some form of filtering
will be done. IF high_quality is FALSE then a small filter will be performed.
If high_quality is TRUE then a large filter (higher quality) will be performed. For
both the small and large filters another parameter can be specified, filter_interpolation.
With filter_interpolation set then the filter coefficients used for both the small and
large filtering will be interpolated as well.
This class was designed to stream audio data. It also expects audio data as 16 bit values.
Each time a new stream is started some initialization needs to be done. Thus the function
initialize should be called to initialize everything. This initialize function will set
the conversion factor as well as a multiplecation factor for volume. The volume only
applies to the small and large filter. Since this filter uses a history of the audio data
it is possible for it to vary in amplitude. This allows users to scale the data. This
class will work on any number of channels. Once everything is specified then resample
should be called as many times as is necessary to process all the data. The value
inCount will be returned indicating how many inArray samples were actually used to
produce the output. This value can be used to indicate where the next block of
inArray data should start. The resample function is driven by the outCount value
specified. The inArray should contain at least:
outCount / factor + extra_samples.
extra_samples depends on the type of filtering done. As a rule of thumb 50 should be
adequate for any type of filter.
*/
class aflibData;
class aflibConverter {
public:
// Available contructors and destructors
aflibConverter (
bool high_quality,
bool linear_interpolation,
bool filter_interpolation);
~aflibConverter();
void
initialize(
double factor, /* factor = Sndout/Sndin */
int channels, /* number of sound channels */
double volume = 1.0); /* factor to multiply amplitude */
int
resample( /* number of output samples returned */
int& inCount, /* number of input samples to convert */
int outCount, /* number of output samples to compute */
short inArray[], /* input array data (length inCount * nChans) */
short outArray[]);/* output array data (length outCount * nChans) */
private:
aflibConverter();
aflibConverter(const aflibConverter& op);
const aflibConverter&
operator=(const aflibConverter& op);
int
err_ret(char *s);
void
deleteMemory();
int
readData(
int inCount, /* _total_ number of frames in input file */
short inArray[], /* input data */
short *outPtr[], /* array receiving chan samps */
int dataArraySize, /* size of these arrays */
int Xoff, /* read into input array starting at this index */
bool init_count);
inline short
WordToHword(int v, int scl)
{
short out;
int llsb = (1<<(scl-1));
v += llsb; /* round */
v >>= scl;
if (v>MAX_HWORD) {
v = MAX_HWORD;
} else if (v < MIN_HWORD) {
v = MIN_HWORD;
}
out = (short) v;
return out;
};
int
SrcLinear(
short X[],
short Y[],
double factor,
unsigned int *Time,
unsigned short& Nx,
unsigned short Nout);
int
SrcUp(
short X[],
short Y[],
double factor,
unsigned int *Time,
unsigned short& Nx,
unsigned short Nout,
unsigned short Nwing,
unsigned short LpScl,
short Imp[],
short ImpD[],
bool Interp);
int
SrcUD(
short X[],
short Y[],
double factor,
unsigned int *Time,
unsigned short& Nx,
unsigned short Nout,
unsigned short Nwing,
unsigned short LpScl,
short Imp[],
short ImpD[],
bool Interp);
int
FilterUp(
short Imp[],
short ImpD[],
unsigned short Nwing,
bool Interp,
short *Xp,
short Ph,
short Inc);
int
FilterUD(
short Imp[],
short ImpD[],
unsigned short Nwing,
bool Interp,
short *Xp,
short Ph,
short Inc,
unsigned short dhb);
int
resampleFast( /* number of output samples returned */
int& inCount, /* number of input samples to convert */
int outCount, /* number of output samples to compute */
short inArray[], /* input array data (length inCount * nChans) */
short outArray[]);/* output array data (length outCount * nChans) */
int
resampleWithFilter( /* number of output samples returned */
int& inCount, /* number of input samples to convert */
int outCount, /* number of output samples to compute */
short inArray[], /* input array data (length inCount * nChans) */
short outArray[], /* output array data (length outCount * nChans) */
short Imp[], short ImpD[],
unsigned short LpScl, unsigned short Nmult, unsigned short Nwing);
static short SMALL_FILTER_IMP[];
static short LARGE_FILTER_IMP[];
bool interpFilt;
bool largeFilter;
bool linearInterp;
short ** _Xv;
short ** _Yv;
unsigned int _Time;
double _factor;
int _nChans;
bool _initial;
double _vol;
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

9
lib/JAMA/Makefile.am Normal file
View File

@ -0,0 +1,9 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
EXTRA_DIST = jama_svd.h tnt_array1d.h tnt_array1d_utils.h tnt_array2d.h tnt_array2d_utils.h tnt_math_utils.h

331
lib/JAMA/Makefile.in Normal file
View File

@ -0,0 +1,331 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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 = :
host_triplet = @host@
subdir = lib/JAMA
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
EXTRA_DIST = jama_svd.h tnt_array1d.h tnt_array1d_utils.h tnt_array2d.h tnt_array2d_utils.h tnt_math_utils.h
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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 lib/JAMA/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu lib/JAMA/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@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
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
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:
-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."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool 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-man install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am
# 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:

532
lib/JAMA/jama_svd.h Normal file
View File

@ -0,0 +1,532 @@
#ifndef JAMA_SVD_H
#define JAMA_SVD_H
#include "tnt_array1d.h"
#include "tnt_array1d_utils.h"
#include "tnt_array2d.h"
#include "tnt_array2d_utils.h"
#include "tnt_math_utils.h"
using namespace TNT;
namespace JAMA
{
/** Singular Value Decomposition.
<P>
For an m-by-n matrix A with m >= n, the singular value decomposition is
an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and
an n-by-n orthogonal matrix V so that A = U*S*V'.
<P>
The singular values, sigma[k] = S[k][k], are ordered so that
sigma[0] >= sigma[1] >= ... >= sigma[n-1].
<P>
The singular value decompostion always exists, so the constructor will
never fail. The matrix condition number and the effective numerical
rank can be computed from this decomposition.
<p>
(Adapted from JAMA, a Java Matrix Library, developed by jointly
by the Mathworks and NIST; see http://math.nist.gov/javanumerics/jama).
*/
template <class Real>
class SVD
{
Array2D<Real> U, V;
Array1D<Real> s;
int m, n;
public:
SVD (const Array2D<Real> &Arg) {
m = Arg.dim1();
n = Arg.dim2();
int nu = min(m,n);
s = Array1D<Real>(min(m+1,n));
U = Array2D<Real>(m, nu, Real(0));
V = Array2D<Real>(n,n);
Array1D<Real> e(n);
Array1D<Real> work(m);
Array2D<Real> A(Arg.copy());
int wantu = 1; /* boolean */
int wantv = 1; /* boolean */
int i=0, j=0, k=0;
// Reduce A to bidiagonal form, storing the diagonal elements
// in s and the super-diagonal elements in e.
int nct = min(m-1,n);
int nrt = max(0,min(n-2,m));
for (k = 0; k < max(nct,nrt); k++) {
if (k < nct) {
// Compute the transformation for the k-th column and
// place the k-th diagonal in s[k].
// Compute 2-norm of k-th column without under/overflow.
s[k] = 0;
for (i = k; i < m; i++) {
s[k] = hypot(s[k],A[i][k]);
}
if (s[k] != 0.0) {
if (A[k][k] < 0.0) {
s[k] = -s[k];
}
for (i = k; i < m; i++) {
A[i][k] /= s[k];
}
A[k][k] += 1.0;
}
s[k] = -s[k];
}
for (j = k+1; j < n; j++) {
if ((k < nct) && (s[k] != 0.0)) {
// Apply the transformation.
double t = 0;
for (i = k; i < m; i++) {
t += A[i][k]*A[i][j];
}
t = -t/A[k][k];
for (i = k; i < m; i++) {
A[i][j] += (Real)t*A[i][k];
}
}
// Place the k-th row of A into e for the
// subsequent calculation of the row transformation.
e[j] = A[k][j];
}
if (wantu & (k < nct)) {
// Place the transformation in U for subsequent back
// multiplication.
for (i = k; i < m; i++) {
U[i][k] = A[i][k];
}
}
if (k < nrt) {
// Compute the k-th row transformation and place the
// k-th super-diagonal in e[k].
// Compute 2-norm without under/overflow.
e[k] = 0;
for (i = k+1; i < n; i++) {
e[k] = hypot(e[k],e[i]);
}
if (e[k] != 0.0) {
if (e[k+1] < 0.0) {
e[k] = -e[k];
}
for (i = k+1; i < n; i++) {
e[i] /= e[k];
}
e[k+1] += 1.0;
}
e[k] = -e[k];
if ((k+1 < m) & (e[k] != 0.0)) {
// Apply the transformation.
for (i = k+1; i < m; i++) {
work[i] = 0.0;
}
for (j = k+1; j < n; j++) {
for (i = k+1; i < m; i++) {
work[i] += e[j]*A[i][j];
}
}
for (j = k+1; j < n; j++) {
double t = -e[j]/e[k+1];
for (i = k+1; i < m; i++) {
A[i][j] += (Real)t*work[i];
}
}
}
if (wantv) {
// Place the transformation in V for subsequent
// back multiplication.
for (i = k+1; i < n; i++) {
V[i][k] = e[i];
}
}
}
}
// Set up the final bidiagonal matrix or order p.
int p = min(n,m+1);
if (nct < n) {
s[nct] = A[nct][nct];
}
if (m < p) {
s[p-1] = 0.0;
}
if (nrt+1 < p) {
e[nrt] = A[nrt][p-1];
}
e[p-1] = 0.0;
// If required, generate U.
if (wantu) {
for (j = nct; j < nu; j++) {
for (i = 0; i < m; i++) {
U[i][j] = 0.0;
}
U[j][j] = 1.0;
}
for (k = nct-1; k >= 0; k--) {
if (s[k] != 0.0) {
for (j = k+1; j < nu; j++) {
double t = 0;
for (i = k; i < m; i++) {
t += U[i][k]*U[i][j];
}
t = -t/U[k][k];
for (i = k; i < m; i++) {
U[i][j] += (Real)t*U[i][k];
}
}
for (i = k; i < m; i++ ) {
U[i][k] = -U[i][k];
}
U[k][k] = (Real)1.0 + U[k][k];
for (i = 0; i < k-1; i++) {
U[i][k] = 0.0;
}
} else {
for (i = 0; i < m; i++) {
U[i][k] = 0.0;
}
U[k][k] = 1.0;
}
}
}
// If required, generate V.
if (wantv) {
for (k = n-1; k >= 0; k--) {
if ((k < nrt) & (e[k] != 0.0)) {
for (j = k+1; j < nu; j++) {
double t = 0;
for (i = k+1; i < n; i++) {
t += V[i][k]*V[i][j];
}
t = -t/V[k+1][k];
for (i = k+1; i < n; i++) {
V[i][j] += (Real)t*V[i][k];
}
}
}
for (i = 0; i < n; i++) {
V[i][k] = 0.0;
}
V[k][k] = 1.0;
}
}
// Main iteration loop for the singular values.
int pp = p-1;
int iter = 0;
double eps = pow(2.0,-52.0);
while (p > 0) {
int k=0;
int kase=0;
// Here is where a test for too many iterations would go.
// This section of the program inspects for
// negligible elements in the s and e arrays. On
// completion the variables kase and k are set as follows.
// kase = 1 if s(p) and e[k-1] are negligible and k<p
// kase = 2 if s(k) is negligible and k<p
// kase = 3 if e[k-1] is negligible, k<p, and
// s(k), ..., s(p) are not negligible (qr step).
// kase = 4 if e(p-1) is negligible (convergence).
for (k = p-2; k >= -1; k--) {
if (k == -1) {
break;
}
if (abs(e[k]) <= eps*(abs(s[k]) + abs(s[k+1]))) {
e[k] = 0.0;
break;
}
}
if (k == p-2) {
kase = 4;
} else {
int ks;
for (ks = p-1; ks >= k; ks--) {
if (ks == k) {
break;
}
double t = (ks != p ? abs(e[ks]) : 0.) +
(ks != k+1 ? abs(e[ks-1]) : 0.);
if (abs(s[ks]) <= eps*t) {
s[ks] = 0.0;
break;
}
}
if (ks == k) {
kase = 3;
} else if (ks == p-1) {
kase = 1;
} else {
kase = 2;
k = ks;
}
}
k++;
// Perform the task indicated by kase.
switch (kase) {
// Deflate negligible s(p).
case 1: {
double f = e[p-2];
e[p-2] = 0.0;
for (j = p-2; j >= k; j--) {
double t = hypot(s[j],f);
double cs = s[j]/t;
double sn = f/t;
s[j] = (Real)t;
if (j != k) {
f = -sn*e[j-1];
e[j-1] = (Real)cs*e[j-1];
}
if (wantv) {
for (i = 0; i < n; i++) {
t = cs*V[i][j] + sn*V[i][p-1];
V[i][p-1] = (Real)-sn*V[i][j] + (Real)cs*V[i][p-1];
V[i][j] = (Real)t;
}
}
}
}
break;
// Split at negligible s(k).
case 2: {
double f = e[k-1];
e[k-1] = 0.0;
for (j = k; j < p; j++) {
double t = hypot(s[j],f);
double cs = s[j]/t;
double sn = f/t;
s[j] = (Real)t;
f = -sn*e[j];
e[j] = (Real)cs*e[j];
if (wantu) {
for (i = 0; i < m; i++) {
t = cs*U[i][j] + sn*U[i][k-1];
U[i][k-1] = (Real)-sn*U[i][j] + (Real)cs*U[i][k-1];
U[i][j] = (Real)t;
}
}
}
}
break;
// Perform one qr step.
case 3: {
// Calculate the shift.
double scale = max(max(max(max(
abs(s[p-1]),abs(s[p-2])),abs(e[p-2])),
abs(s[k])),abs(e[k]));
double sp = s[p-1]/scale;
double spm1 = s[p-2]/scale;
double epm1 = e[p-2]/scale;
double sk = s[k]/scale;
double ek = e[k]/scale;
double b = ((spm1 + sp)*(spm1 - sp) + epm1*epm1)/2.0;
double c = (sp*epm1)*(sp*epm1);
double shift = 0.0;
if ((b != 0.0) || (c != 0.0)) {
shift = sqrt(b*b + c);
if (b < 0.0) {
shift = -shift;
}
shift = c/(b + shift);
}
double f = (sk + sp)*(sk - sp) + shift;
double g = sk*ek;
// Chase zeros.
for (j = k; j < p-1; j++) {
double t = hypot(f,g);
double cs = f/t;
double sn = g/t;
if (j != k) {
e[j-1] = (Real)t;
}
f = cs*s[j] + sn*e[j];
e[j] = cs*e[j] - sn*s[j];
g = sn*s[j+1];
s[j+1] = (Real)cs*s[j+1];
if (wantv) {
for (i = 0; i < n; i++) {
t = (Real)cs*V[i][j] + (Real)sn*V[i][j+1];
V[i][j+1] = (Real)-sn*V[i][j] + (Real)cs*V[i][j+1];
V[i][j] = (Real)t;
}
}
t = hypot(f,g);
cs = f/t;
sn = g/t;
s[j] = (Real)t;
f = cs*e[j] + sn*s[j+1];
s[j+1] = (Real)-sn*e[j] + (Real)cs*s[j+1];
g = sn*e[j+1];
e[j+1] = (Real)cs*e[j+1];
if (wantu && (j < m-1)) {
for (i = 0; i < m; i++) {
t = cs*U[i][j] + sn*U[i][j+1];
U[i][j+1] = (Real)-sn*U[i][j] + (Real)cs*U[i][j+1];
U[i][j] = (Real)t;
}
}
}
e[p-2] = (Real)f;
iter = iter + 1;
}
break;
// Convergence.
case 4: {
// Make the singular values positive.
if (s[k] <= 0.0) {
s[k] = (Real)(s[k] < 0.0 ? -s[k] : 0.0);
if (wantv) {
for (i = 0; i <= pp; i++) {
V[i][k] = -V[i][k];
}
}
}
// Order the singular values.
while (k < pp) {
if (s[k] >= s[k+1]) {
break;
}
double t = s[k];
s[k] = s[k+1];
s[k+1] = (Real)t;
if (wantv && (k < n-1)) {
for (i = 0; i < n; i++) {
t = V[i][k+1]; V[i][k+1] = V[i][k]; V[i][k] = (Real)t;
}
}
if (wantu && (k < m-1)) {
for (i = 0; i < m; i++) {
t = U[i][k+1]; U[i][k+1] = U[i][k]; U[i][k] = (Real)t;
}
}
k++;
}
iter = 0;
p--;
}
break;
}
}
}
void getU (Array2D<Real> &A)
{
int minm = min(m+1,n);
A = Array2D<Real>(m, minm);
for (int i=0; i<m; i++)
for (int j=0; j<minm; j++)
A[i][j] = U[i][j];
}
/* Return the right singular vectors */
void getV (Array2D<Real> &A)
{
A = V;
}
/** Return the one-dimensional array of singular values */
void getSingularValues (Array1D<Real> &x)
{
x = s;
}
/** Return the diagonal matrix of singular values
@return S
*/
void getS (Array2D<Real> &A) {
A = Array2D<Real>(n,n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
A[i][j] = 0.0;
}
A[i][i] = s[i];
}
}
/** Two norm (max(S)) */
double norm2 () {
return s[0];
}
/** Two norm of condition number (max(S)/min(S)) */
double cond () {
return s[0]/s[min(m,n)-1];
}
/** Effective numerical matrix rank
@return Number of nonnegligible singular values.
*/
int rank ()
{
double eps = pow(2.0,-52.0);
double tol = max(m,n)*s[0]*eps;
int r = 0;
for (int i = 0; i < s.dim(); i++) {
if (s[i] > tol) {
r++;
}
}
return r;
}
};
}
#endif
// JAMA_SVD_H

418
lib/JAMA/tnt_array1d.h Normal file
View File

@ -0,0 +1,418 @@
/*
*
* Template Numerical Toolkit (TNT)
*
* Mathematical and Computational Sciences Division
* National Institute of Technology,
* Gaithersburg, MD USA
*
*
* This software was developed at the National Institute of Standards and
* Technology (NIST) by employees of the Federal Government in the course
* of their official duties. Pursuant to title 17 Section 105 of the
* United States Code, this software is not subject to copyright protection
* and is in the public domain. NIST assumes no responsibility whatsoever for
* its use by other parties, and makes no guarantees, expressed or implied,
* about its quality, reliability, or any other characteristic.
*
*/
#ifndef TNT_ARRAY1D_H
#define TNT_ARRAY1D_H
#include <cstdlib>
#include <iostream>
#ifdef TNT_BOUNDS_CHECK
#include <assert.h>
#endif
namespace TNT
{
/**
Tempplated one-dimensional, numerical array which
looks like a conventional C array.
Elements are accessed via the familiar A[i] notation.
<p>
Array assignment is by reference (i.e. shallow assignment).
That is, B=A implies that the A and B point to the
same array, so modifications to the elements of A
will be reflected in B. If an independent copy
is required, then B = A.copy() can be used. Note
that this facilitates returning arrays from functions
without relying on compiler optimizations to eliminate
extensive data copying.
<p>
The indexing and layout of this array object makes
it compatible with C and C++ algorithms that utilize
the familiar C[i] notation. This includes numerous
textbooks, such as Numercial Recipes, and various
public domain codes.
<p>
This class employs its own garbage collection via
the use of reference counts. That is, whenever
an internal array storage no longer has any references
to it, it is destoryed.
*/
template <class T>
class Array1D
{
private:
T* v_;
int n_;
int *ref_count_;
void initialize_(int n);
void copy_(T* p, const T* q, int len) const;
void set_(const T& val);
void destroy_();
inline const T* begin_() const;
inline T* begin_();
public:
typedef T value_type;
Array1D();
explicit Array1D(int n);
Array1D(int n, T *a);
Array1D(int n, const T &a);
inline Array1D(const Array1D &A);
inline Array1D & operator=(const T &a);
inline Array1D & operator=(const Array1D &A);
inline Array1D & ref(const Array1D &A);
Array1D copy() const;
Array1D & inject(const Array1D & A);
inline T& operator[](int i);
inline const T& operator[](int i) const;
inline int dim1() const;
inline int dim() const;
inline int ref_count() const;
~Array1D();
};
/**
Null constructor. Creates a 0-length (NULL) array.
(Reference count is also zero.)
*/
template <class T>
Array1D<T>::Array1D() : v_(0), n_(0), ref_count_(0)
{
ref_count_ = new int;
*ref_count_ = 1;
}
/**
Copy constructor. Array data is NOT copied, but shared.
Thus, in Array1D B(A), subsequent changes to A will
be reflected in B. For an indepent copy of A, use
Array1D B(A.copy()), or B = A.copy(), instead.
*/
template <class T>
Array1D<T>::Array1D(const Array1D<T> &A) : v_(A.v_),
n_(A.n_), ref_count_(A.ref_count_)
{
(*ref_count_)++;
}
/**
Create a new array (vector) of length <b>n</b>,
WIHOUT initializing array elements.
To create an initialized array of constants, see Array1D(n,value).
<p>
This version avoids the O(n) initialization overhead and
is used just before manual assignment.
@param n the dimension (length) of the new matrix.
*/
template <class T>
Array1D<T>::Array1D(int n) : v_(0), n_(n), ref_count_(0)
{
initialize_(n);
ref_count_ = new int;
*ref_count_ = 1;
}
/**
Create a new array of length <b>n</b>, initializing array elements to
constant specified by argument. Most often used to
create an array of zeros, as in A(n, 0.0).
@param n the dimension (length) of the new matrix.
@param val the constant value to set all elements of the new array to.
*/
template <class T>
Array1D<T>::Array1D(int n, const T &val) : v_(0), n_(n) ,
ref_count_(0)
{
initialize_(n);
set_(val);
ref_count_ = new int;
*ref_count_ = 1;
}
/**
Create a new n-length array, as a view of an existing one-dimensional
C array. (Note that the storage for this pre-existing array will
never be destroyed by the Aray1DRef class.)
@param n the dimension (length) of the new matrix.
@param a the one dimensional C array to use as data storage for
the array.
*/
template <class T>
Array1D<T>::Array1D(int n, T *a) : v_(a), n_(n) ,
ref_count_(0)
{
ref_count_ = new int;
*ref_count_ = 2; /* this avoid destorying original data. */
}
/**
A[i] indexes the ith element of A. The first element is
A[0]. If TNT_BOUNDS_CHECK is defined, then the index is
checked that it falls within the array bounds.
*/
template <class T>
inline T& Array1D<T>::operator[](int i)
{
#ifdef TNT_BOUNDS_CHECK
assert(i>= 0);
assert(i < n_);
#endif
return v_[i];
}
/**
A[i] indexes the ith element of A. The first element is
A[0]. If TNT_BOUNDS_CHECK is defined, then the index is
checked that it fall within the array bounds.
*/
template <class T>
inline const T& Array1D<T>::operator[](int i) const
{
#ifdef TNT_BOUNDS_CHECK
assert(i>= 0);
assert(i < n_);
#endif
return v_[i];
}
/**
Assign all elemnts of A to a constant scalar.
*/
template <class T>
Array1D<T> & Array1D<T>::operator=(const T &a)
{
set_(a);
return *this;
}
/**
Create a new of existing matrix. Used in B = A.copy()
or in the construction of B, e.g. Array1D B(A.copy()),
to create a new array that does not share data.
*/
template <class T>
Array1D<T> Array1D<T>::copy() const
{
Array1D A( n_);
copy_(A.begin_(), begin_(), n_);
return A;
}
/**
Copy the elements to from one array to another, in place.
That is B.inject(A), both A and B must conform (i.e. have
identical row and column dimensions).
This differs from B = A.copy() in that references to B
before this assignment are also affected. That is, if
we have
<pre>
Array1D A(n);
Array1D C(n);
Array1D B(C); // elements of B and C are shared.
</pre>
then B.inject(A) affects both and C, while B=A.copy() creates
a new array B which shares no data with C or A.
@param A the array from which elements will be copied
@return an instance of the modifed array. That is, in B.inject(A),
it returns B. If A and B are not conformat, no modifications to
B are made.
*/
template <class T>
Array1D<T> & Array1D<T>::inject(const Array1D &A)
{
if (A.n_ == n_)
copy_(begin_(), A.begin_(), n_);
return *this;
}
/**
Create a reference (shallow assignment) to another existing array.
In B.ref(A), B and A shared the same data and subsequent changes
to the array elements of one will be reflected in the other.
<p>
This is what operator= calls, and B=A and B.ref(A) are equivalent
operations.
@return The new referenced array: in B.ref(A), it returns B.
*/
template <class T>
Array1D<T> & Array1D<T>::ref(const Array1D<T> &A)
{
if (this != &A)
{
(*ref_count_) --;
if ( *ref_count_ < 1)
{
destroy_();
}
n_ = A.n_;
v_ = A.v_;
ref_count_ = A.ref_count_;
(*ref_count_) ++ ;
}
return *this;
}
/**
B = A is shorthand notation for B.ref(A).
*/
template <class T>
Array1D<T> & Array1D<T>::operator=(const Array1D<T> &A)
{
return ref(A);
}
/**
@return the dimension (number of elements) of the array.
This is equivalent to dim() and dim1().
*/
template <class T>
inline int Array1D<T>::dim1() const { return n_; }
/**
@return the dimension (number of elements) of the array.
This is equivalent to dim1() and dim1().
*/
template <class T>
inline int Array1D<T>::dim() const { return n_; }
/**
@return the number of arrays that share the same storage area
as this one. (Must be at least one.)
*/
template <class T>
inline int Array1D<T>::ref_count() const
{
return *ref_count_;
}
template <class T>
Array1D<T>::~Array1D()
{
(*ref_count_) --;
if (*ref_count_ < 1)
destroy_();
}
/* private internal functions */
template <class T>
void Array1D<T>::initialize_(int n)
{
v_ = new T[n];
n_ = n;
}
template <class T>
void Array1D<T>::set_(const T& a)
{
T *begin = &(v_[0]);
T *end = begin+ n_;
for (T* p=begin; p<end; p++)
*p = a;
}
template <class T>
void Array1D<T>::copy_(T* p, const T* q, int len) const
{
T *end = p + len;
while (p<end )
*p++ = *q++;
}
template <class T>
void Array1D<T>::destroy_()
{
if (v_ != 0)
{
delete[] (v_);
}
if (ref_count_ != 0)
delete ref_count_;
}
/**
@returns location of first element, i.e. A[0] (mutable).
*/
template <class T>
const T* Array1D<T>::begin_() const { return &(v_[0]); }
/**
@returns location of first element, i.e. A[0] (mutable).
*/
template <class T>
T* Array1D<T>::begin_() { return &(v_[0]); }
} /* namespace TNT */
#endif
/* TNT_ARRAY1D_H */

View File

@ -0,0 +1,65 @@
#ifndef TNT_ARRAY1D_UTILS_H
#define TNT_ARRAY1D_UTILS_H
#include <cstdlib>
#include <cassert>
namespace TNT
{
/**
Write an array to a character outstream. Output format is one that can
be read back in via the in-stream operator: one integer
denoting the array dimension (n), followed by n elements,
one per line.
*/
template <class T>
std::ostream& operator<<(std::ostream &s, const Array1D<T> &A)
{
int N=A.dim1();
s << N << "\n";
for (int j=0; j<N; j++)
{
s << A[j] << "\n";
}
s << "\n";
return s;
}
/**
Read an array from a character stream. Input format
is one integer, denoting the dimension (n), followed
by n whitespace-separated elments. Newlines are ignored
<p>
Note: the array being read into references new memory
storage. If the intent is to fill an existing conformant
array, use <code> cin >> B; A.inject(B) ); </code>
instead or read the elements in one-a-time by hand.
@param s the charater to read from (typically <code>std::in</code>)
@param A the array to read into.
*/
template <class T>
std::istream& operator>>(std::istream &s, Array1D<T> &A)
{
int N;
s >> N;
Array1D<T> B(N);
for (int i=0; i<N; i++)
s >> B[i];
A = B;
return s;
}
} // namespace TNT
#endif

456
lib/JAMA/tnt_array2d.h Normal file
View File

@ -0,0 +1,456 @@
/*
*
* Template Numerical Toolkit (TNT): Two-dimensional numerical array
*
* Mathematical and Computational Sciences Division
* National Institute of Technology,
* Gaithersburg, MD USA
*
*
* This software was developed at the National Institute of Standards and
* Technology (NIST) by employees of the Federal Government in the course
* of their official duties. Pursuant to title 17 Section 105 of the
* United States Code, this software is not subject to copyright protection
* and is in the public domain. NIST assumes no responsibility whatsoever for
* its use by other parties, and makes no guarantees, expressed or implied,
* about its quality, reliability, or any other characteristic.
*
*/
#ifndef TNT_ARRAY2D_H
#define TNT_ARRAY2D_H
#include <cstdlib>
#include <iostream>
#ifdef TNT_BOUNDS_CHECK
#include <assert.h>
#endif
namespace TNT
{
/**
Tempplated two-dimensional, numerical array which
looks like a conventional C multiarray.
Storage corresponds to C (row-major) ordering.
Elements are accessed via A[i][j] notation.
<p>
Array assignment is by reference (i.e. shallow assignment).
That is, B=A implies that the A and B point to the
same array, so modifications to the elements of A
will be reflected in B. If an independent copy
is required, then B = A.copy() can be used. Note
that this facilitates returning arrays from functions
without relying on compiler optimizations to eliminate
extensive data copying.
<p>
The indexing and layout of this array object makes
it compatible with C and C++ algorithms that utilize
the familiar C[i][j] notation. This includes numerous
textbooks, such as Numercial Recipes, and various
public domain codes.
<p>
This class employs its own garbage collection via
the use of reference counts. That is, whenever
an internal array storage no longer has any references
to it, it is destoryed.
*/
template <class T>
class Array2D
{
private:
T** v_;
int m_;
int n_;
int *ref_count_;
void initialize_(int m, int n);
void copy_(T* p, const T* q, int len) const;
void set_(const T& val);
void destroy_();
inline const T* begin_() const;
inline T* begin_();
public:
typedef T value_type;
Array2D();
Array2D(int m, int n);
Array2D(int m, int n, T *a);
Array2D(int m, int n, const T &a);
inline Array2D(const Array2D &A);
inline Array2D & operator=(const T &a);
inline Array2D & operator=(const Array2D &A);
inline Array2D & ref(const Array2D &A);
Array2D copy() const;
Array2D & inject(const Array2D & A);
inline T* operator[](int i);
inline const T* operator[](int i) const;
inline int dim1() const;
inline int dim2() const;
inline int ref_count() const;
~Array2D();
inline void deleteObj();
};
/**
Copy constructor. Array data is NOT copied, but shared.
Thus, in Array2D B(A), subsequent changes to A will
be reflected in B. For an indepent copy of A, use
Array2D B(A.copy()), or B = A.copy(), instead.
*/
template <class T>
Array2D<T>::Array2D(const Array2D<T> &A) : v_(A.v_), m_(A.m_),
n_(A.n_), ref_count_(A.ref_count_)
{
(*ref_count_)++;
}
/**
Create a new (m x n) array, WIHOUT initializing array elements.
To create an initialized array of constants, see Array2D(m,n,value).
<p>
This version avoids the O(m*n) initialization overhead and
is used just before manual assignment.
@param m the first (row) dimension of the new matrix.
@param n the second (column) dimension of the new matrix.
*/
template <class T>
Array2D<T>::Array2D(int m, int n) : v_(0), m_(m), n_(n), ref_count_(0)
{
initialize_(m,n);
ref_count_ = new int;
*ref_count_ = 1;
}
/**
Create a new (m x n) array, initializing array elements to
constant specified by argument. Most often used to
create an array of zeros, as in A(m, n, 0.0).
@param m the first (row) dimension of the new matrix.
@param n the second (column) dimension of the new matrix.
@param val the constant value to set all elements of the new array to.
*/
template <class T>
Array2D<T>::Array2D(int m, int n, const T &val) : v_(0), m_(m), n_(n) ,
ref_count_(0)
{
initialize_(m,n);
set_(val);
ref_count_ = new int;
*ref_count_ = 1;
}
/**
Create a new (m x n) array, as a view of an existing one-dimensional
array stored in <b>C order</b>, i.e. right-most dimension varying fastest.
(Often referred to as "row-major" ordering.)
Note that the storage for this pre-existing array will
never be garbage collected by the Array2D class.
@param m the first (row) dimension of the new matrix.
@param n the second (column) dimension of the new matrix.
@param a the one dimensional C array to use as data storage for
the array.
*/
template <class T>
Array2D<T>::Array2D(int m, int n, T *a) : v_(0), m_(m), n_(n) ,
ref_count_(0)
{
T* p = a;
v_ = new T*[m];
for (int i=0; i<m; i++)
{
v_[i] = p;
p += n;
}
ref_count_ = new int;
*ref_count_ = 2; /* this avoid destorying original data. */
}
/**
Used for A[i][j] indexing. The first [] operator returns
a conventional pointer which can be dereferenced using the
same [] notation.
If TNT_BOUNDS_CHECK macro is define, the left-most index (row index)
is checked that it falls within the array bounds (via the
assert() macro.) Note that bounds checking can occur in
the row dimension, but the not column, since
this is just a C pointer.
*/
template <class T>
inline T* Array2D<T>::operator[](int i)
{
#ifdef TNT_BOUNDS_CHECK
assert(i >= 0);
assert(i < m_);
#endif
return v_[i];
}
template <class T>
inline const T* Array2D<T>::operator[](int i) const { return v_[i]; }
/**
Assign all elemnts of A to a constant scalar.
*/
template <class T>
Array2D<T> & Array2D<T>::operator=(const T &a)
{
set_(a);
return *this;
}
/**
Create a new of existing matrix. Used in B = A.copy()
or in the construction of B, e.g. Array2D B(A.copy()),
to create a new array that does not share data.
*/
template <class T>
Array2D<T> Array2D<T>::copy() const
{
Array2D A(m_, n_);
copy_(A.begin_(), begin_(), m_*n_);
return A;
}
/**
Copy the elements to from one array to another, in place.
That is B.inject(A), both A and B must conform (i.e. have
identical row and column dimensions).
This differs from B = A.copy() in that references to B
before this assignment are also affected. That is, if
we have
<pre>
Array2D A(m,n);
Array2D C(m,n);
Array2D B(C); // elements of B and C are shared.
</pre>
then B.inject(A) affects both and C, while B=A.copy() creates
a new array B which shares no data with C or A.
@param A the array from elements will be copied
@return an instance of the modifed array. That is, in B.inject(A),
it returns B. If A and B are not conformat, no modifications to
B are made.
*/
template <class T>
Array2D<T> & Array2D<T>::inject(const Array2D &A)
{
if (A.m_ == m_ && A.n_ == n_)
copy_(begin_(), A.begin_(), m_*n_);
return *this;
}
/**
Create a reference (shallow assignment) to another existing array.
In B.ref(A), B and A shared the same data and subsequent changes
to the array elements of one will be reflected in the other.
<p>
This is what operator= calls, and B=A and B.ref(A) are equivalent
operations.
@return The new referenced array: in B.ref(A), it returns B.
*/
template <class T>
Array2D<T> & Array2D<T>::ref(const Array2D<T> &A)
{
if (this != &A)
{
(*ref_count_) --;
if ( *ref_count_ < 1 )
{
destroy_();
}
m_ = A.m_;
n_ = A.n_;
v_ = A.v_;
ref_count_ = A.ref_count_;
(*ref_count_) ++ ;
}
return *this;
}
/**
B = A is shorthand notation for B.ref(A).
*/
template <class T>
Array2D<T> & Array2D<T>::operator=(const Array2D<T> &A)
{
return ref(A);
}
/**
@return the size of the first dimension of the array, i.e.
the number of rows.
*/
template <class T>
inline int Array2D<T>::dim1() const { return m_; }
/**
@return the size of the second dimension of the array, i.e.
the number of columns.
*/
template <class T>
inline int Array2D<T>::dim2() const { return n_; }
/**
@return the number of arrays that share the same storage area
as this one. (Must be at least one.)
*/
template <class T>
inline int Array2D<T>::ref_count() const
{
return *ref_count_;
}
template <class T>
Array2D<T>::~Array2D()
{
if (ref_count_ != 0)
{
(*ref_count_) --;
if (*ref_count_ < 1)
destroy_();
}
}
/* private internal functions */
template <class T>
void Array2D<T>::initialize_(int m, int n)
{
T* p = new T[m*n];
v_ = new T*[m];
for (int i=0; i<m; i++)
{
v_[i] = p;
p+=n;
}
m_ = m;
n_ = n;
}
template <class T>
void Array2D<T>::set_(const T& a)
{
T *begin = &v_[0][0];
T *end = begin+ m_*n_;
for (T* p=begin; p<end; p++)
*p = a;
}
template <class T>
void Array2D<T>::copy_(T* p, const T* q, int len) const
{
T *end = p + len;
while (p<end )
*p++ = *q++;
}
template <class T>
void Array2D<T>::destroy_()
{
if (v_ != 0)
{
delete[] (v_[0]);
delete[] (v_);
}
if (ref_count_ != 0)
delete ref_count_;
}
template <class T>
void Array2D<T>::deleteObj()
{
if (v_ != 0)
{
delete[] (v_);
}
if (ref_count_ != 0)
{
delete ref_count_;
ref_count_ = 0;
}
}
/**
@returns location of first element, i.e. A[0][0] (mutable).
*/
template <class T>
const T* Array2D<T>::begin_() const { return &(v_[0][0]); }
/**
@returns location of first element, i.e. A[0][0] (mutable).
*/
template <class T>
T* Array2D<T>::begin_() { return &(v_[0][0]); }
/**
Create a null (0x0) array.
*/
template <class T>
Array2D<T>::Array2D() : v_(0), m_(0), n_(0)
{
ref_count_ = new int;
*ref_count_ = 1;
}
} /* namespace TNT */
#endif
/* TNT_ARRAY2D_H */

View File

@ -0,0 +1,122 @@
#ifndef TNT_ARRAY2D_UTILS_H
#define TNT_ARRAY2D_UTILS_H
#include <cstdlib>
#include <cassert>
namespace TNT
{
/**
Write an array to a character outstream. Output format is one that can
be read back in via the in-stream operator: two integers
denoting the array dimensions (m x n), followed by m
lines of n elements.
*/
template <class T>
std::ostream& operator<<(std::ostream &s, const Array2D<T> &A)
{
int M=A.dim1();
int N=A.dim2();
s << M << " " << N << "\n";
for (int i=0; i<M; i++)
{
for (int j=0; j<N; j++)
{
s << A[i][j] << " ";
}
s << "\n";
}
return s;
}
/**
Read an array from a character stream. Input format
is two integers, denoting the dimensions (m x n), followed
by m*n whitespace-separated elments in "row-major" order
(i.e. right-most dimension varying fastest.) Newlines
are ignored.
<p>
Note: the array being read into references new memory
storage. If the intent is to fill an existing conformant
array, use <code> cin >> B; A.inject(B) ); </code>
instead or read the elements in one-a-time by hand.
@param s the charater to read from (typically <code>std::in</code>)
@param A the array to read into.
*/
template <class T>
std::istream& operator>>(std::istream &s, Array2D<T> &A)
{
int M, N;
s >> M >> N;
Array2D<T> B(M,N);
for (int i=0; i<M; i++)
for (int j=0; j<N; j++)
{
s >> B[i][j];
}
A = B;
return s;
}
/**
Matrix Multiply: compute C = A*B, where C[i][j]
is the dot-product of row i of A and column j of B.
@param A an (m x n) array
@param B an (n x k) array
@return the (m x k) array A*B, or a null array (0x0)
if the matrices are non-conformant (i.e. the number
of columns of A are different than the number of rows of B.)
*/
template <class T>
Array2D<T> matmult(const Array2D<T> &A, const Array2D<T> &B)
{
if (A.dim2() != B.dim1())
return Array2D<T>();
int M = A.dim1();
int N = A.dim2();
int K = B.dim2();
Array2D<T> C(M,K);
for (int i=0; i<M; i++)
for (int j=0; j<K; j++)
{
T sum = 0;
for (int k=0; k<N; k++)
sum += A[i][k] * B [k][j];
C[i][j] = sum;
}
return C;
}
} // namespace TNT
#endif

70
lib/JAMA/tnt_math_utils.h Normal file
View File

@ -0,0 +1,70 @@
#ifndef MATH_UTILS_H
#define MATH_UTILS_H
#include <math.h>
/* needed for sqrt() below */
#ifdef PREANSI
template <class _Tp>
inline const _Tp& min(const _Tp& __a, const _Tp& __b) {
return __b < __a ? __b : __a;
}
template <class _Tp>
inline const _Tp& max(const _Tp& __a, const _Tp& __b) {
return __a < __b ? __b : __a;
}
#endif
namespace TNT
{
/**
@returns hypotenuse of real (non-complex) scalars a and b by
avoiding underflow/overflow
using (a * sqrt( 1 + (b/a) * (b/a))), rather than
sqrt(a*a + b*b).
*/
template <class Real>
Real hypot(const Real &a, const Real &b)
{
if (a== 0)
return abs(b);
else
{
Real c = b/a;
return a * sqrt(1 + c*c);
}
}
/**
@returns the minimum of scalars a and b.
template <class Scalar>
Scalar min(const Scalar &a, const Scalar &b)
{
return a < b ? a : b;
}
*/
/**
@returns the maximum of scalars a and b.
template <class Scalar>
Scalar max(const Scalar &a, const Scalar &b)
{
return a > b ? a : b;
}
*/
/**
@returns the absolute value of a real (no-complex) scalar.
*/
template <class Real>
Real abs(const Real &a)
{
return (a > 0 ? a : -a);
}
}
#endif
/* MATH_UTILS_H */

44
lib/Makefile.am Normal file
View File

@ -0,0 +1,44 @@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
SUBDIRS = JAMA AFLIB
lib_LTLIBRARIES = libofa.la
INCLUDES = -I$(top_srcdir)/include
if VDSP
dist_libofa_la_SOURCES = fftlibvdsp_op.cpp fft_op.cpp frametracker_op.cpp \
mainprint.cpp signal_op.cpp trackdata_op.cpp trackframe_op.cpp \
tracklist_op.cpp
else
dist_libofa_la_SOURCES = fftlibw3_op.cpp fft_op.cpp frametracker_op.cpp \
mainprint.cpp signal_op.cpp trackdata_op.cpp trackframe_op.cpp \
tracklist_op.cpp
endif
# Here are a set of rules to help you update your library version information:
# Scheme: current:revsion:age
# 1. Start with version information of `0:0:0' for each libtool library.
# 2. Update the version information only immediately before a public release
# of your software. More frequent updates are unnecessary, and only
# guarantee that the current interface number gets larger faster.
# 3. If the library source code has changed at all since the last update,
# then increment revision (`c:r:a' becomes `c:r+1:a').
# 4. If any interfaces have been added, removed, or changed since the last
# update, increment current, and set revision to 0.
# 5. If any interfaces have been added since the last public release, then
# increment age.
# 6. If any interfaces have been removed since the last public release, then
# set age to 0.
libofa_la_LDFLAGS = -version-info 0:0:0 -no-undefined
libofa_la_LIBADD = AFLIB/libaflib.la -lm
noinst_HEADERS = error_op.h fftlib_op.h fft_op.h frametracker_op.h signal_op.h \
trackdata_op.h trackframe_op.h tracklist_op.h

625
lib/Makefile.in Normal file
View File

@ -0,0 +1,625 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 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@
SOURCES = $(dist_libofa_la_SOURCES)
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 = :
host_triplet = @host@
subdir = lib
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libofa_la_DEPENDENCIES = AFLIB/libaflib.la
am__dist_libofa_la_SOURCES_DIST = fftlibw3_op.cpp fft_op.cpp \
frametracker_op.cpp mainprint.cpp signal_op.cpp \
trackdata_op.cpp trackframe_op.cpp tracklist_op.cpp \
fftlibvdsp_op.cpp
@VDSP_FALSE@dist_libofa_la_OBJECTS = fftlibw3_op.lo fft_op.lo \
@VDSP_FALSE@ frametracker_op.lo mainprint.lo signal_op.lo \
@VDSP_FALSE@ trackdata_op.lo trackframe_op.lo tracklist_op.lo
@VDSP_TRUE@dist_libofa_la_OBJECTS = fftlibvdsp_op.lo fft_op.lo \
@VDSP_TRUE@ frametracker_op.lo mainprint.lo signal_op.lo \
@VDSP_TRUE@ trackdata_op.lo trackframe_op.lo tracklist_op.lo
libofa_la_OBJECTS = $(dist_libofa_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/fft_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/fftlibvdsp_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/fftlibw3_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/frametracker_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/mainprint.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/signal_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/trackdata_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/trackframe_op.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/tracklist_op.Plo
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(dist_libofa_la_SOURCES)
DIST_SOURCES = $(am__dist_libofa_la_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
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@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_LIBS = @CURL_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DARWIN_FALSE = @DARWIN_FALSE@
DARWIN_TRUE = @DARWIN_TRUE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXPAT_LIBS = @EXPAT_LIBS@
F77 = @F77@
FFLAGS = @FFLAGS@
FFTW3_FALSE = @FFTW3_FALSE@
FFTW3_TRUE = @FFTW3_TRUE@
FFT_WRAPPER = @FFT_WRAPPER@
FREEBSD_FALSE = @FREEBSD_FALSE@
FREEBSD_TRUE = @FREEBSD_TRUE@
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@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
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@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VDSP_FALSE = @VDSP_FALSE@
VDSP_TRUE = @VDSP_TRUE@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
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@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
# ------------------------------------------------------------------
#
# libofa -- the Open Fingerprint Architecture library
#
# Copyright (C) 2006 MusicIP Corporation
# All rights reserved.
#
#-------------------------------------------------------------------
AUTOMAKE_OPTIONS = foreign
SUBDIRS = JAMA AFLIB
lib_LTLIBRARIES = libofa.la
INCLUDES = -I$(top_srcdir)/include
@VDSP_FALSE@dist_libofa_la_SOURCES = fftlibw3_op.cpp fft_op.cpp frametracker_op.cpp \
@VDSP_FALSE@ mainprint.cpp signal_op.cpp trackdata_op.cpp trackframe_op.cpp \
@VDSP_FALSE@ tracklist_op.cpp
@VDSP_TRUE@dist_libofa_la_SOURCES = fftlibvdsp_op.cpp fft_op.cpp frametracker_op.cpp \
@VDSP_TRUE@ mainprint.cpp signal_op.cpp trackdata_op.cpp trackframe_op.cpp \
@VDSP_TRUE@ tracklist_op.cpp
# Here are a set of rules to help you update your library version information:
# Scheme: current:revsion:age
# 1. Start with version information of `0:0:0' for each libtool library.
# 2. Update the version information only immediately before a public release
# of your software. More frequent updates are unnecessary, and only
# guarantee that the current interface number gets larger faster.
# 3. If the library source code has changed at all since the last update,
# then increment revision (`c:r:a' becomes `c:r+1:a').
# 4. If any interfaces have been added, removed, or changed since the last
# update, increment current, and set revision to 0.
# 5. If any interfaces have been added since the last public release, then
# increment age.
# 6. If any interfaces have been removed since the last public release, then
# set age to 0.
libofa_la_LDFLAGS = -version-info 0:0:0 -no-undefined
libofa_la_LIBADD = AFLIB/libaflib.la -lm
noinst_HEADERS = error_op.h fftlib_op.h fft_op.h frametracker_op.h signal_op.h \
trackdata_op.h trackframe_op.h tracklist_op.h
all: all-recursive
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(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) --foreign lib/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign lib/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
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="`echo $$p | sed -e 's|^.*/||'`"; \
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)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p="`echo $$p | sed -e 's|^.*/||'`"; \
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
libofa.la: $(libofa_la_OBJECTS) $(libofa_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libofa_la_LDFLAGS) $(libofa_la_OBJECTS) $(libofa_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fft_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fftlibvdsp_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fftlibw3_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frametracker_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mainprint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signal_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trackdata_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trackframe_op.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tracklist_op.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
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: ctags-recursive $(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)
@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
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
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:
-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."
clean: clean-recursive
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am: install-libLTLIBRARIES
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libLTLIBRARIES clean-libtool \
clean-recursive ctags ctags-recursive distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-recursive 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-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-info-am uninstall-libLTLIBRARIES
# 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:

42
lib/error_op.h Normal file
View File

@ -0,0 +1,42 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "error_op.h"
// MODULE: Header for error object OnePrintError. Client can catch or ignore.
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#ifndef ERR_H_OP
#define ERR_H_OP 1
#include <string>
using namespace std;
const int NOFLCODE = -1;
const int SILENCEONLY = 1;
const int GENERALFAILURE = 2;
const int FILETOOSHORT = 10;
class OnePrintError {
public:
OnePrintError(string s) { Mes = s; ErrorCode = NOFLCODE; }
OnePrintError(string s, int code) { Mes = s; ErrorCode = code; }
OnePrintError(const int code) { ErrorCode = code; }
string GetMessage() { return Mes; }
long GetErrorCode() { return ErrorCode; }
void SetErrorCode(const int code) { ErrorCode = code; }
private:
string Mes;
int ErrorCode;
};
#endif

280
lib/fft_op.cpp Normal file
View File

@ -0,0 +1,280 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "fft_op.cpp"
// MODULE: Implementation for class FFT_op
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#include <vector>
#include <math.h>
#include "ofa1/ofa.h"
#include "fft_op.h"
#include "error_op.h"
#define ROUND(x) ((x>0)? (long)floor(x + 0.5) : (long)(ceil(x - 0.5)) )
FFT_op::FFT_op()
{
FrameSize = 0;
NumBins = 0;
NumFrames = 0;
TimeSpectra = 0;
BufSize = 0;
OutBuf = 0;
InBuf = 0;
AmpSpectWin = 0;
Hamming = 0;
Overlap = 0;
Rate = 0;
}
FFT_op::~FFT_op()
{
FFTLib_op::Destroy();
if (OutBuf)
delete[] OutBuf;
if (InBuf)
delete[] InBuf;
if (AmpSpectWin)
delete[] AmpSpectWin;
if (TimeSpectra)
delete[] TimeSpectra;
if (Hamming)
delete[] Hamming;
}
void
FFT_op::LoadSignal(Signal_op *sig)
{
Signal = sig;
Rate = Signal->GetRate();
if (TimeSpectra)
{
delete[] TimeSpectra;
TimeSpectra = 0;
}
}
void
FFT_op::SetSize(int N, bool optimize)
{
if (OutBuf)
delete[] OutBuf;
if (InBuf)
delete[] InBuf;
if (AmpSpectWin)
delete[] AmpSpectWin;
FrameSize = N;
OutBuf = new double[FrameSize+128];
InBuf = new double[FrameSize+128];
FFTLib_op::SetSize(N, optimize, InBuf, OutBuf);
SetNumBins(FrameSize/2 + 1);
AmpSpectWin = new double[GetNumBins()];
WindowInit();
}
void
FFT_op::SetStep(int step) {
if (Rate==0)
throw OnePrintError("SetStep:programming error:Rate");
if (step<=0)
throw OnePrintError("SetStep:programming error:Step");
StepSize = step;
}
void
FFT_op::WindowInit()
{
if (Hamming)
delete[] Hamming;
Hamming = new double[FrameSize];
for (int i=0; i<FrameSize; i++)
Hamming[i] = 0.54 - 0.46*cos(i*(TwoPI/(FrameSize-1)));
}
void
FFT_op::CreateBuffer(int numBins, int numFrames, bool init)
{
NumFrames = numFrames;
NumBins = numBins;
BufSize = NumFrames * NumBins;
if (TimeSpectra) delete[] TimeSpectra;
TimeSpectra = new float[BufSize];
if (init)
{
for (int i=0; i<BufSize; i++)
TimeSpectra[i] = 0;
}
}
// Mono signals only
void
FFT_op::Compute(double ovlap)
{
long i;
int j,k,m;
if (ovlap != Overlap || !TimeSpectra)
{
Overlap = ovlap;
if (TimeSpectra)
delete[] TimeSpectra;
SetStep(int(FrameSize * (1.0 - Overlap))); // # of signal samples per step
SetNumFrames(((Signal->GetLength()-FrameSize) / StepSize) + 1);
CreateBuffer(GetNumBins(), GetNumFrames()); // allocates spectrum storage
}
short* sdata = Signal->GetBuffer();
j = BufSize; // safety
// m counts # of StepSize's we've made
for (i=0, m=0; i<=Signal->GetLength()-FrameSize; i+=StepSize, m++)
{
for (j=0; j<FrameSize; j++) {
// copy and normalize samples into fft input buffer
InBuf[j] = (double)sdata[i+j]/(double)MaxSample;
}
// Do the FFT
ComputeWindow(InBuf);
// Copy resulting spectrum into the larger array
long start = m * GetNumBins();
for (j=start, k=0; k < GetNumBins(); j++, k++) {
TimeSpectra[j] = (float)AmpSpectWin[k];
}
}
// zero out remaining entries
for ( ; j<BufSize; j++)
TimeSpectra[j] = (float) 0.0;
}
// If windowing other than RECTANGULAR is in effect, the input buffer will be altered
void
FFT_op::ComputeWindow(double* in)
{
int i;
if (WindowShape == HAMMING)
{
for (i=0; i < FrameSize; i++)
in[i] *= Hamming[i];
}
FFTLib_op::ComputeFrame(FrameSize, in, OutBuf);
// Normalize
for (i=0; i < FrameSize; i++)
OutBuf[i] /= FrameSize;
// Compute amplitude spectrum for window
// We only got half the values, because the rest was thrown away in the (identical)
// complex conjugate part (negative frequencies). To get the amplitude back
// we must multiply by 2.
AmpSpectWin[0] = 2*sqrt(OutBuf[0]*OutBuf[0]); // DC component
for (int k=1; k<(FrameSize+1)/2; ++k) // (k < N/2 rounded up)
AmpSpectWin[k] = 2*sqrt(OutBuf[k]*OutBuf[k] + OutBuf[FrameSize-k]*OutBuf[FrameSize-k]);
if (FrameSize % 2 == 0) // N is even
AmpSpectWin[FrameSize/2] = 2*sqrt(OutBuf[FrameSize/2]*OutBuf[FrameSize/2]); // Nyquist freq.
}
// Resample the frames to a new reduced size
void
FFT_op::ReSample(int nBins, bool melScale)
{
double hiFreq = 8000.0; // Everything above 8 KHz is ignored
double halfFreq;
if (melScale)
halfFreq = 1000.0;
else
halfFreq = hiFreq/2;
if (GetFreqStep() > halfFreq/(nBins/2) || nBins>=GetNumBins())
throw OnePrintError("Oversampling not supported in ReSample");
int j;
float* fr;
int srcInd, curInd;
double fStep, maxAmp, curHz, srcHz;
// Pre-calculate frequencies
vector<double> freq(GetNumBins());
for (j=0; j<GetNumBins(); j++)
freq[j] = GetFreq(j);
float* tmpBuf = new float[nBins*GetNumFrames()];
// Approximate the Barks scale: 1/2 the bins from 0-halfFreq Hz, 1/2 from halfFreq-hiFreq Hz
for (long i=0; i<GetNumFrames(); i++)
{
fr = GetFrame(i);
curHz = 0;
srcInd = 0;
curInd = 0;
srcHz = freq[srcInd];
fStep = halfFreq/(nBins/2);
for (j=0; j<nBins/2; j++)
{
curHz += fStep;
maxAmp = 0;
while (srcHz < curHz)
{
if (fr[srcInd] > maxAmp) maxAmp = fr[srcInd];
srcInd++;
srcHz = freq[srcInd];
}
tmpBuf[i*nBins+j] = (float)maxAmp;
}
fStep = (hiFreq-halfFreq)/(nBins/2);
for (j=nBins/2; j<nBins; j++)
{
curHz += fStep;
maxAmp = 0;
while (srcHz < curHz)
{
if (fr[srcInd] > maxAmp) maxAmp = fr[srcInd];
srcInd++;
srcHz = freq[srcInd];
}
tmpBuf[i*nBins+j] = (float)maxAmp;
}
}
delete[] TimeSpectra;
TimeSpectra = tmpBuf;
SetNumBins(nBins);
BufSize = GetNumFrames() * GetNumBins();
}
// convert Hz to MIDI note number.
int
FFT_op::FreqToMidi(double hz)
{
const double nFact = 17.31234049067; // 12/ln(2)
double Nd;
Nd = nFact*log(hz/27.5);
return ROUND(Nd);
}

71
lib/fft_op.h Normal file
View File

@ -0,0 +1,71 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "fft_op.h"
// MODULE: Class header for FFT_op
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#ifndef __FFT_OP_H
#define __FFT_OP_H 1
#ifdef WIN32
#include "../config_win32.h"
#else
#include "../config.h"
#endif
#include "signal_op.h"
#include "fftlib_op.h"
enum { RECTANGULAR, TRIANGULAR, HAMMING };
const double TwoPI = 2.0 * 3.14159265358979324;
class FFT_op : public FFTLib_op {
public:
FFT_op();
~FFT_op();
void LoadSignal(Signal_op *sig);
void SetSize(int N, bool optimize);
void Compute(double ovlap);
void SetWindowShape(int shape) { WindowShape = shape; }
void ReSample(int nBins, bool melScale);
long GetNumFrames() const { return NumFrames; }
int GetNumBins() const { return NumBins; }
float* GetFrame(int frNum) { return &TimeSpectra[frNum * NumBins]; }
double GetFreqStep() { return (double)Rate/(GetNumBins()*2); }
double GetStepDur() const { return StepSize * 1000.0 / Rate; }
static int FreqToMidi(double hz);
private:
void CreateBuffer(int numBins, int numFrames, bool init = false);
void SetStep(int step);
void WindowInit();
void ComputeWindow(double* in);
void SetNumFrames(long numFr) { NumFrames = numFr; }
void SetNumBins(int bins) { NumBins = bins; }
double GetFreq(int step) { return step * GetFreqStep(); }
Signal_op* Signal;
double* InBuf; // Temporary holding buffer for fft input frames
double* OutBuf; // Temporary output buffer for one FFT frame
double* AmpSpectWin; // Buffer for amplitude spectrum of current frame
float* TimeSpectra; // Sequence of amp spectra for Signal, separated by NumBins
long BufSize; // Size of TimeSpectra buffer
int FrameSize; // in # of signal sample points
int StepSize; // in # of signal sample points
int NumBins; // # of spectrum points
int NumFrames; // # of analysis frames
int Rate; // Sample rate
double Overlap; // in percent (= 1 - StepSize/FrameSize)
int WindowShape; // Type of windowing
double* Hamming; // Hamming window
};
#endif

86
lib/fftlib_op.h Normal file
View File

@ -0,0 +1,86 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "fftlib_op.h"
// MODULE: Generic wrapper class for external FFT library calls
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#ifndef __FFTLIB_OP_H
#define __FFTLIB_OP_H 1
#ifdef FFTW
#include "rfftw.h"
class FFTLib_op {
protected:
FFTLib_op() { PlanF = 0; }
void Initialize(int N, bool optimize);
void Destroy();
void SetSize(int N, bool optimize, double *in, double *out);
void ComputeFrame(int N, double *in, double *out);
rfftw_plan PlanF; // Forward plan: real to complex (time to frequency)
};
#endif
#ifdef FFTW3
#include "fftw3.h"
class FFTLib_op {
protected:
FFTLib_op() { PlanF = 0; }
void Initialize(int N, bool optimize);
void Destroy();
void SetSize(int N, bool optimize, double *in, double *out);
void ComputeFrame(int N, double *in, double *out);
unsigned Flags;
fftw_plan PlanF; // Forward plan: real to complex (time to frequency)
};
#endif
#ifdef MKL
class FFTLib_op {
protected:
FFTLib_op() { WSave = 0; }
void Initialize(int N, bool optimize);
void Destroy();
void SetSize(int N, bool optimize, double *in, double *out);
void ComputeFrame(int N, double *in, double *out);
double* WSave;
};
#endif
#ifdef VDSP
#include <Accelerate/Accelerate.h>
class FFTLib_op {
protected:
FFTLib_op() { Init = false; }
void Initialize(int N, bool optimize);
void Destroy();
void SetSize(int N, bool optimize, double *in, double *out);
void ComputeFrame(int N, double *in, double *out);
private:
FFTSetupD SetupReal;
DSPDoubleSplitComplex A;
int Exp;
bool Init;
};
#endif
#endif

61
lib/fftlibvdsp_op.cpp Normal file
View File

@ -0,0 +1,61 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "fftlibvdsp_op.cpp"
// MODULE: Wrapper for Mac vDSP library calls
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#include "../config.h"
#include "fftlib_op.h"
void
FFTLib_op::Initialize(int N, bool optimize)
{
Exp = (int) log2(N);
if (Init)
{
delete[] A.realp;
delete[] A.imagp;
destroy_fftsetupD(SetupReal);
}
A.realp = new double[ N/2];
A.imagp = new double[ N/2];
SetupReal = create_fftsetupD(Exp, 0);
Init = true;
}
void
FFTLib_op::Destroy()
{
}
void
FFTLib_op::SetSize(int N, bool optimize, double *in, double *out)
{
Initialize(N, optimize);
}
void
FFTLib_op::ComputeFrame(int N, double *in, double *out)
{
ctozD ((DSPDoubleComplex*) in, 2, &A, 1, N/2 );
fft_zripD(SetupReal, &A, 1, Exp, FFT_FORWARD);
int i,j;
for (i=0; i<N/2; i++)
out[i] = A.realp[i]*0.5;
out[N/2] = A.imagp[0]*0.5;
for (i=1, j=N-1; i<N/2; i++, j--)
out[j] = A.imagp[i]*0.5;
}

60
lib/fftlibw3_op.cpp Normal file
View File

@ -0,0 +1,60 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "fftlibw3_op.cpp"
// MODULE: Wrapper for MIT FFTW ver 3.0 library calls
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#ifdef WIN32
#include "../config_win32.h"
#else
#include "../config.h"
#endif
#include "fftlib_op.h"
void
FFTLib_op::Initialize(int N, bool optimize)
{
if (optimize)
Flags = FFTW_MEASURE;
else
Flags = FFTW_ESTIMATE;
}
void
FFTLib_op::Destroy()
{
fftw_destroy_plan(PlanF);
}
void
FFTLib_op::SetSize(int N, bool optimize, double *in, double *out)
{
if (optimize)
Flags = FFTW_MEASURE;
else
Flags = FFTW_ESTIMATE;
if (PlanF != 0)
{
fftw_destroy_plan(PlanF);
PlanF = 0;
}
PlanF = fftw_plan_r2r_1d(N, in, out, FFTW_R2HC, Flags);
}
void
FFTLib_op::ComputeFrame(int N, double *in, double *out)
{
fftw_execute(PlanF);
}

183
lib/frametracker_op.cpp Normal file
View File

@ -0,0 +1,183 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "frametracker_op.cpp"
// MODULE: Implementation for class FrameTracker
// AUTHOR: Stephen Pope, Frode Holm
// DATE CREATED: 01/12/06
#include <math.h>
#include "frametracker_op.h"
#include "trackdata_op.h"
// Constructor
FrameTracker_op::FrameTracker_op(float peakT, float fThresh, float lenT, int maxTrax)
{
PeakThreshold = peakT;
FreqThreshold = fThresh;
LengthThreshold = lenT;
MaxTracks = maxTrax;
PeakWidth = 2; // width of peak interval (on one side)
BaseFr = 0;
}
// Destructor
FrameTracker_op::~FrameTracker_op()
{
BaseFr = 0;
}
void
FrameTracker_op::Compute(FFT_op& spectra)
{
double sdur = spectra.GetStepDur();
int numFrames = spectra.GetNumFrames();
// Detect the peaks in each frame
for (int i = 0; i < numFrames; i++)
{
float realTime = (float)(i * sdur);
TrackFrame_op* thePeaks = new TrackFrame_op(realTime);
FindPeaks(spectra, i, thePeaks);
Tracks.Add(thePeaks); // add the frame to the track list
}
TrackPeaks(); // Track the peaks between frames
ContinuePeaks(); // Try to extend the tracks
}
// Find the peaks in a single frame;
// use local-max detection over the min threshold
void
FrameTracker_op::FindPeaks(FFT_op& data, int frameNum, TrackFrame_op* thePeaks)
{
int numBins = data.GetNumBins();
float* frame = data.GetFrame(frameNum);
int npeak = 0;
double realTime = frameNum * data.GetStepDur();
TrackData_op* prevP = 0;
float prevPV = * frame++; // previous previous sample
float prevV = * frame++; // previous sample
float thisV = * frame++; // this sample
float nextV = * frame++; // next sample
for (int i = 4; i < (numBins - 2); i++)
{
float nextNV = * frame++; // next next sample
// check for peak relatively > PeakThreshold
bool found = (thisV > PeakThreshold) && (thisV > prevV) && (thisV > nextV);
if (found && (PeakWidth > 1)) // if using wide peaks, compare prevPV and nextNV
found = found && (thisV > prevPV) && (thisV > nextNV);
if (found)
{
// If peak detected, do cubic interpolation for index, // freq, and magnitude -- first calculate "real" index
double realIndex = ((prevV - nextV) * 0.5) / (prevV - (2.0 * thisV) + nextV);
// then interpolate the real magnitude and frequency
double realPeak = thisV - ((prevV - nextV) * 0.25 * realIndex);
double realFreq = data.GetFreqStep() * (float)(i-2);
// Add the new peak to the list and link it in
TrackData_op* thisP = new TrackData_op((float)realTime, (float)realFreq, (float)realPeak, (float)data.GetStepDur());
if (prevP != 0)
prevP->linkHigher(thisP);
prevP = thisP;
thePeaks->Add(thisP);
npeak++;
}
prevPV = prevV; // step the values to the next freq. bin
prevV = thisV;
thisV = nextV;
nextV = nextNV;
}
}
// Answer the best match for the given frequency in the given frame
TrackData_op*
FrameTracker_op::GetBestMatch(float pitch, TrackFrame_op* frame)
{
TrackData_op* match = frame->getTrackNearestFreq(pitch);
if (match != 0) { // If it's within the freq. range FreqThreshold
double frqDiff = fabs(log(match->getPitch()) - log(pitch));
if (frqDiff < FreqThreshold)
return match;
}
return 0;
}
// Track and group peaks in the given data set;
// do a running forward/backward comparison of all peaks in a track
void
FrameTracker_op::TrackPeaks()
{
TrackFrame_op* prevFr = Tracks.getBaseFrame();
TrackFrame_op* thisFr = prevFr->getNext();
TrackFrame_op* nextFr = thisFr->getNext();
TrackFrame_op* lastFr = nextFr->getNext();
while (thisFr != 0) { // Iterate over the frames trying to track peaks
TrackData_op* baseTr = prevFr->getBaseTrack();
// Try to track the previous frame's peaks into this frame
while (baseTr != 0) { // Find the best freq. match between track and current pks
float baseP = baseTr->getPitch();
TrackData_op* match = GetBestMatch(baseP, thisFr);
if (match != 0) {
baseTr->linkTo(match); // create double links
}
baseTr = baseTr->getHigher();
} // end of current frame
prevFr = thisFr;
thisFr = nextFr;
nextFr = lastFr;
if (lastFr != 0)
lastFr = lastFr->getNext();
} // end of all tracks
}
// Continue track groups, and gather track statistics
void
FrameTracker_op::ContinuePeaks()
{
TrackFrame_op* base = Tracks.getBaseFrame();
while (base != 0) { // Iterate over all frames
TrackData_op* td = base->getBaseTrack();
while (td != 0) { // Iterate over peaks in a frame
if (td->isHead()) {
float am = td->getAmplitude();
float pc = td->getPitch();
float avgA = am;
float avgP = pc;
int i = 1;
TrackData_op* tl = td->getNext();
while (tl != 0) { // Iterate forward over peaks in a track
am = tl->getAmplitude();
pc = tl->getPitch();
avgA += am;
avgP += pc;
td->setEndPitch(pc);
tl = tl->getNext();
i++;
} // end of links
td->setAvgAmplitude(avgA / (float) i);
td->setAvgPitch(avgP / (float) i);
} // end of track
td = td->getHigher(); // go to next peak in frame
} // end of frame
base = base->getNext(); // go to next frame
}
}

59
lib/frametracker_op.h Normal file
View File

@ -0,0 +1,59 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "frametracker_op.h"
// MODULE: Class header for FrameTracker_op
// AUTHOR: Stephen Pope, Frode Holm
// DATE CREATED: 01/12/06
#ifndef FRAME_TRACKER_OP_H
#define FRAME_TRACKER_OP_H 1
#include "fft_op.h"
#include "tracklist_op.h"
#include "trackdata_op.h"
class FrameTracker_op {
public:
// Constructor -- here are the defaults for the thresholds
FrameTracker_op(
float peakT = 0.001f, // min ampl for peak detection
float fThresh = 0.2, // max freq ratio for tracking between peaks
float lenT = 0.1f, // min length for track (in sec) (ignored in this version)
int maxTrax = 500); // max # of tracks at a time (ignored in this version)
~FrameTracker_op();
// Accessing
TrackList_op* getTracks() { return &Tracks; }
// The big do-it method -- run the peak-tracking
void Compute(FFT_op& spectra);
private:
TrackList_op Tracks; // list of tracked frames
float PeakThreshold; // min peak magnitude for detection
float FreqThreshold; // max step between peaks for tracking
float LengthThreshold; // shortest track
int MaxTracks; // max # of peaks to track
int PeakWidth; // min sample width for peaks (+- x)
TrackFrame_op* BaseFr;
// Private methods
void FindPeaks(FFT_op& spectra, int frameNum, TrackFrame_op* thePeaks);
TrackData_op* GetBestMatch(float pitch, TrackFrame_op* frame);
void TrackPeaks();
void ContinuePeaks();
};
#endif

328
lib/mainprint.cpp Normal file
View File

@ -0,0 +1,328 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "mainprint.cpp"
// MODULE: Top level calling code and main functions
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#include <vector>
#include "ofa1/ofa.h"
#include "signal_op.h"
#include "fft_op.h"
#include "frametracker_op.h"
#include "error_op.h"
#include "JAMA/jama_svd.h"
using namespace TNT;
using namespace JAMA;
typedef float Real;
// Print size
const int Dim = 7;
const int Res = 40;
const long SongLen = 120000; // length to analyze (ms)
const int FrameSize = 8192; // FFT framesize
void preprocessing(short* samples, long size, int sRate, bool stereo, Signal_op& sig);
void core_print(Signal_op& sig, unsigned char *out);
void pitch_print(Signal_op& sig, unsigned char *out);
char *base64encode(const char *input, int lentext);
// Retreive the version of the library
extern "C"
void ofa_get_version(int *major, int *minor, int *rev)
{
sscanf(VERSION, "%d.%d.%d", major, minor, rev);
}
// ofa_create_print is the top level function generating the fingerprint.
// NOTE THAT THE PASSED IN DATA MAY BE BYTE SWAPPED DURING THE METHOD.
// ASSUME THAT DATA IN THE INPUT BUFFER IS DESTROYED AS A SIDE-EFFECT OF
// CALLING THIS FUNCTION
//
// data: a buffer of 16-bit samples in interleaved format (if stereo), i.e. L,R,L,R, etc.
// This buffer is destroyed during processing.
// Ideally, this buffer should contain the entire song to be analyzed, but the process will only
// need the first 2min + 10sec + any silence prepending the actual audio. Since the precise silence
// interval will only be known after a couple of processing steps, the caller must make adequate
// allowance for this. Caveat emptor.
// byteOrder: OFA_LITTLE_ENDIAN, or OFA_BIG_ENDIAN - indicates the byte
// order of the data being passed in.
// size: the size of the buffer, in number of samples.
// sRate: the sample rate of the signal. This can be an arbitrary rate, as long as it can be expressed
// as an integer (in samples per second). If this is different from 44100, rate conversion will
// be performed during preprocessing, which will add significantly to the overhead.
// stereo: 1 if there are left and right channels stored, 0 if the data is mono
//
// On success, a valid text representation of the fingerprint is returned.
// The returned buffer will remain valid until the next call to ofa_create_print
extern "C"
const char *ofa_create_print(unsigned char *data, int byteOrder, long size, int sRate, int stereo)
{
short *samples = (short *) data;
#ifdef BIG_ENDIAN
if (byteOrder == OFA_LITTLE_ENDIAN) {
for (int i = 0; i < size; ++i) {
samples[i] = data[2*i+1] << 8 | data[2*i];
}
}
#else
if (byteOrder == OFA_BIG_ENDIAN) {
for (int i = 0; i < size; ++i) {
samples[i] = data[2*i] << 8 | data[2*i+1];
}
}
#endif
try {
Signal_op sig;
unsigned char bytes[Dim * Res * 2 + 5];
preprocessing(samples, size, sRate, stereo, sig);
bytes[0] = 1; // version marker
core_print(sig, bytes + 1);
pitch_print(sig, bytes + (Dim * Res * 2 + 1));
return base64encode((char*) bytes, Dim * Res * 2 + 5);
} catch (OnePrintError e) {
return 0;
}
}
void
preprocessing(short* samples, long size, int sRate, bool stereo, Signal_op& sig)
{
int ch = stereo ? 2 : 1;
long sec135 = 135 * sRate * ch;
if (size > sec135) size = sec135;
sig.Load(samples, size, sRate, stereo);
if (stereo)
sig.PrepareStereo(44100, 50);
else
sig.PrepareMono(44100, 50);
if (sig.GetDuration() > SongLen+10000)
sig.CutSignal(10000, SongLen);
}
void
core_print(Signal_op& sig, unsigned char *out)
{
FFT_op fft;
fft.LoadSignal(&sig);
fft.SetSize(FrameSize,false);
fft.SetWindowShape(HAMMING);
fft.Compute(0);
fft.ReSample(Res, true);
if (fft.GetNumFrames() < Res)
throw OnePrintError(FILETOOSHORT);
// Compute SVD
int i,j;
float* fr;
int numBins = fft.GetNumBins();
int numFrames = fft.GetNumFrames();
Array2D<Real> in2D(numFrames, numBins);
Array2D<Real> v(numBins, numBins);
// copy into Array2D
for (i = 0; i < numFrames; i++)
{
fr = fft.GetFrame(i);
for (j = 0; j < numBins; j++)
in2D[i][j] = fr[j];
}
SVD<Real> s(in2D);
s.getV(v);
int pos = 0;
for (i = 0; i < Dim; i++) {
for (j = 0; j < Res; j++) {
short value = short(v[j][i] * 32767);
out[pos++] = ((value & 0xff00) >> 8);
out[pos++] = (value & 0x00ff);
}
}
}
struct pitchPacket {
pitchPacket() { dur = 0; tracks = 0; amp = 0; }
double dur;
int tracks;
double amp;
};
void
pitch_print(Signal_op& sig, unsigned char *out)
{
if (sig.GetDuration() > 40000)
sig.CutSignal(0, 30000);
FFT_op fft;
fft.LoadSignal(&sig);
fft.SetSize(FrameSize,false);
fft.SetWindowShape(HAMMING);
fft.Compute(0.8);
FrameTracker_op fTrk(0.005f, 0.03f, 0.1f);
fTrk.Compute(fft);
vector<pitchPacket> notes(128);
double loFreq = 50;
double hiFreq = 1500;
// Collect track statistics
TrackList_op* trl = fTrk.getTracks();
TrackFrame_op* base = trl->getBaseFrame();
double dur, amp;
int avPitch;
int totalTracks = 0;
while (base != 0)
{
TrackData_op* td = base->getBaseTrack();
while (td != 0)
{
if (td->isHead() && td->getAvgPitch() > loFreq && td->getAvgPitch() < hiFreq)
{
dur = td->getDuration();
avPitch = fft.FreqToMidi(td->getAvgPitch());
amp = td->getAvgAmplitude();
notes[avPitch].dur += dur;
notes[avPitch].tracks++;
notes[avPitch].amp += amp;
totalTracks++;
}
td = td->getHigher();
}
base = base->getNext();
}
// Find the 4 most prominent notes
double maxStrength[4];
int index[4];
int i;
for (i=0; i<4; i++)
{
maxStrength[i] = 0;
index[i] = 0;
}
for (i=0; i<128; i++)
{
if (notes[i].tracks == 0) continue;
double strength = notes[i].amp + notes[i].dur/10000.0; // "linear" spread
// "manual" sort
if (strength > maxStrength[0])
{
maxStrength[3] = maxStrength[2];
maxStrength[2] = maxStrength[1];
maxStrength[1] = maxStrength[0];
maxStrength[0] = strength;
index[3] = index[2];
index[2] = index[1];
index[1] = index[0];
index[0] = i;
}
else if (strength > maxStrength[1])
{
maxStrength[3] = maxStrength[2];
maxStrength[2] = maxStrength[1];
maxStrength[1] = strength;
index[3] = index[2];
index[2] = index[1];
index[1] = i;
}
else if (strength > maxStrength[2])
{
maxStrength[3] = maxStrength[2];
maxStrength[2] = strength;
index[3] = index[2];
index[2] = i;
}
else if (strength > maxStrength[3])
{
maxStrength[3] = strength;
index[3] = i;
}
}
for (i=0; i<4; i++)
{
out[i] = index[i];
}
}
static char encodingTable[64] = {
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
};
// The return buffer is only valid until the next call to this method
char *base64encode(const char *input, int lentext) {
static char out[758];
unsigned char inbuf[3], outbuf[4];
int i, ctcopy, pos = 0, ixtext = 0;
while (true) {
int ctremaining = lentext - ixtext;
if (ctremaining <= 0)
break;
for (i = 0; i < 3; i++) {
int ix = ixtext + i;
if (ix < lentext)
inbuf[i] = (unsigned char) input[ix];
else
inbuf[i] = 0;
}
outbuf[0] = (unsigned char) ((inbuf [0] & 0xFC) >> 2);
outbuf[1] = (unsigned char) (((inbuf [0] & 0x03) << 4) | ((inbuf [1] & 0xF0) >> 4));
outbuf[2] = (unsigned char) (((inbuf [1] & 0x0F) << 2) | ((inbuf [2] & 0xC0) >> 6));
outbuf[3] = (unsigned char) (inbuf [2] & 0x3F);
switch (ctremaining) {
case 1:
ctcopy = 2;
break;
case 2:
ctcopy = 3;
break;
default:
ctcopy = 4;
break;
}
for (i = 0; i < ctcopy; i++) {
out[pos++] = encodingTable[outbuf[i]];
}
for (i = ctcopy; i < 4; i++) {
out[pos++] = '=';
}
ixtext += 3;
}
out[pos] = 0;
return out;
}

368
lib/signal_op.cpp Normal file
View File

@ -0,0 +1,368 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "signal_op.cpp"
// MODULE: Implementation for class Signal_op
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#include <math.h>
#include "signal_op.h"
#include "AFLIB/aflibConverter.h"
#include "error_op.h"
Signal_op::Signal_op()
{
Data = 0;
iOwnData = false;
NumChannels = 0;
BufSize = 0;
NumBlocks = 0;
Rate = 0;
}
Signal_op::~Signal_op()
{
if (iOwnData)
delete[] Data;
}
void
Signal_op::Load(short* samples, long size, int sRate, bool stereo)
{
Data = samples;
iOwnData = false;
NumChannels = stereo ? 2 : 1;
BufSize = size;
NumBlocks = BufSize / NumChannels;
Rate = sRate;
}
// CutSignal deletes samples from the sample buffer
void
Signal_op::CutSignal(double start, double dur)
{
int i, n;
short* samples = Data;
long startS = (long)(start * Rate / 1000.0);
long stopS = (long)(startS + dur * Rate / 1000.0);
NumBlocks = (stopS-startS);
if (NumBlocks <= 0)
throw OnePrintError("Programming error: CutSignal");
BufSize = NumBlocks * NumChannels;
short* tmpBuf = new short[BufSize];
startS *= NumChannels;
stopS *= NumChannels;
// Copy to new buffer
for (i=startS, n=0; i<stopS; i++, n++)
tmpBuf[n] = samples[i];
if (iOwnData)
delete[] Data;
Data = tmpBuf;
iOwnData = true;
}
void
Signal_op::PrepareStereo(long newRate, double silTh)
{
// Convert to mono
if (GetCrossCorrelation() < -0.98)
LMinusR();
else
LPlusR();
PrepareMono(newRate, silTh);
}
void
Signal_op::PrepareMono(long newRate, double silTh)
{
RemoveSilence(silTh, silTh);
RemoveDCOffset();
// Check for rate conversion
if (newRate != Rate)
ConvertSampleRate(newRate);
Normalize();
}
// Add left and right channels
void Signal_op::LPlusR()
{
if (NumChannels != 2)
return;
short* tmpBuf = new short[NumBlocks];
short* samples = Data;
for (long i=0, n=0; i<NumBlocks*2; i+=2, n++)
{
int sum = samples[i] + samples[i+1];
tmpBuf[n] = sum / 2;
}
if (iOwnData)
delete[] Data;
Data = tmpBuf;
iOwnData = true;
NumChannels = 1;
BufSize = NumBlocks;
}
// Subtract left and right channels.
void Signal_op::LMinusR()
{
if (NumChannels != 2)
return;
short * tmpBuf = new short[NumBlocks];
short * samples = Data;
for (long i=0, n=0; i<NumBlocks*2; i+=2, n++)
{
int sum = samples[i] - samples[i+1];
tmpBuf[n] = sum / 2;
}
if (iOwnData)
delete[] Data;
Data = tmpBuf;
iOwnData = true;
NumChannels = 1;
BufSize = NumBlocks;
}
void
Signal_op::RemoveSilence(double startTh, double endTh)
{
long i, n;
short* samples = Data;
// Truncate leading and trailing silence
long stop = NumBlocks;
int silBlock = (int) (Rate*2.2/400);
int count = 0;
long sum = 0;
long start = 0;
// Front silence removal
while (start < stop)
{
sum += abs(samples[start]);
count++;
if (count >= silBlock)
{
double av = (double)sum/silBlock;
if (av > startTh)
{
start -= count-1;
break;
}
count = 0;
sum = 0;
}
start++;
}
if (start < 0) start = 0;
// Back silence removal
count = 0;
sum = 0;
while (stop > start)
{
sum += abs(samples[stop-1]);
count++;
if (count >= silBlock)
{
double av = (double)sum/silBlock;
if (av > endTh)
{
stop += count;
break;
}
count = 0;
sum = 0;
}
stop--;
}
if (stop > NumBlocks) stop = NumBlocks;
if (stop-start <= 0)
throw OnePrintError("Signal has silence only", SILENCEONLY);
NumBlocks = (stop-start);
if (NumBlocks <= 0)
throw OnePrintError("Signal is corrupt");
BufSize = NumBlocks;
short* tmpBuf = new short[BufSize];
// Copy to new buffer
for (i=start, n=0; i<stop; i++, n++)
tmpBuf[n] = samples[i];
if (iOwnData)
delete[] Data;
Data = tmpBuf;
iOwnData = true;
}
void
Signal_op::RemoveDCOffset()
{
long len = GetLength();
short* x = Data;
double yn=0, yn1=0;
double sum = 0;
long cnt = 0;
double ramp = 1000.0; // Ramp-up time (ms)
long lim = (long) ((ramp/1000)*GetRate());
double k = 1000.0/(GetRate()*ramp);
double maxP = 0, maxN = 0;
for (long n=1; n<=len; n++)
{
yn = yn1 + k*((double)x[n-1] - yn1);
yn1 = yn;
if (n > lim*3)
{
sum += yn;
cnt++;
}
if (x[n-1] > maxP)
maxP = x[n-1];
if (x[n-1] < maxN)
maxN = x[n-1];
}
double dcOffset = sum/(double)cnt;
// Remove if greater than this
if (fabs(dcOffset) > 15) // otherwise don't bother
{
// Check to se if we have to "denormalize" to make sure there's headroom for the DC removal
double factorP=0, factorN=0, factor=0;
if (maxP - dcOffset > MaxSample)
factorP = ((double)MaxSample - dcOffset) / maxP;
if (maxN - dcOffset < MinSample)
factorN = ((double)MinSample + dcOffset) / maxN;
// only one can apply
if (factorP > 0)
factor = factorP;
else if (factorN > 0)
factor = factorN;
for (long i=0; i<len; i++)
{
double sample = (double)x[i];
if (factor > 0)
sample *= factor;
sample -= dcOffset;
// round sample
if (sample > 0)
x[i] = (short) floor(sample + 0.5);
else
x[i] = (short) ceil(sample - 0.5);
}
}
}
void
Signal_op::Normalize()
{
short* samples = Data;
long i;
int max = 0;
double factor;
for (i=0; i<NumBlocks; i++)
{
if (abs(samples[i]) > max)
max = abs(samples[i]);
}
if (max >= MaxSample) {
factor = 1;
} else {
factor = MaxSample / (double) max;
for (i=0; i<NumBlocks; i++)
{
double tmp = (double)samples[i] * factor;
// round sample
if (tmp > 0)
samples[i] = (short) floor(tmp + 0.5);
else
samples[i] = (short) ceil(tmp - 0.5);
}
}
}
// Mono signals only
void
Signal_op::ConvertSampleRate(long targetSR)
{
if (NumChannels > 1) return;
aflibConverter srConv(true, false, true); // Large filter with coefficients interpolation
double factor = (double)targetSR/(double)Rate;
long tmpSize = (long) (BufSize * factor + 2);
short* tmpBuf = new short[tmpSize];
srConv.initialize(factor, 1);
int inCount = BufSize;
int outCount = (int) (BufSize * factor);
int outRet;
outRet = srConv.resample(inCount, outCount, GetBuffer(), tmpBuf);
if (iOwnData)
delete[] Data;
Data = tmpBuf;
iOwnData = true;
Rate = targetSR;
NumBlocks = BufSize = outRet;
}
double
Signal_op::GetCrossCorrelation()
{
// Cross Channel Correlation - stereo signals only
long k;
double C12 = 0, C11 = 0, C22 = 0;
short* samples = Data;
for (k=0; k<NumBlocks*2; k+=2)
{
C12 += samples[k]*samples[k+1];
C11 += samples[k]*samples[k];
C22 += samples[k+1]*samples[k+1];
}
return C12/sqrt(C11*C22);
}

55
lib/signal_op.h Normal file
View File

@ -0,0 +1,55 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "signal_op.h"
// MODULE: Class header for Signal_op
// AUTHOR: Frode Holm
// DATE CREATED: 1/12/06
#ifndef __SIGNAL_OP_H
#define __SIGNAL_OP_H 1
const int MaxSample = 32767;
const int MinSample = -32768;
class Signal_op {
public:
Signal_op();
~Signal_op();
void Load(short* samples, long size, int sRate, bool stereo);
void CutSignal(double start, double dur);
void PrepareStereo(long rate, double silTh);
void PrepareMono(long rate, double silTh);
void LPlusR();
void LMinusR();
void RemoveSilence(double startTh, double endTh);
void RemoveDCOffset();
void Normalize();
void ConvertSampleRate(long targetSR);
double GetCrossCorrelation();
double GetDuration() { return (double) NumBlocks * 1000.0 / (double) Rate; } // In msec
short* GetBuffer() { return Data; }
long GetLength() { return NumBlocks; }
long GetRate() { return Rate; }
private:
short* Data; // buffer
bool iOwnData;
long BufSize; // Total size of Data in terms of # of data items (short or float)
long NumBlocks; // number of data blocks (= number of sample points)
long Rate; // Sample rate
int NumChannels; // number of channels
};
#endif

93
lib/trackdata_op.cpp Normal file
View File

@ -0,0 +1,93 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "trackdata_op.cpp"
// MODULE: Implementation for class TrackData
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06
#include "trackdata_op.h"
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
// Constructor
TrackData_op::TrackData_op() { /* empty */ }
TrackData_op::TrackData_op(float aTime, float frequency, float amplitude, float frDur)
{
StartTime = aTime;
EndTime = 0.0f;
Pitch = AvgPitch = EndPitch = frequency;
Amplitude = AvgAmplitude = amplitude;
FrameDur = frDur;
previous = 0;
next = 0;
higher = 0;
InTrack = false;
}
TrackData_op::~TrackData_op()
{
previous = next = higher = 0;
}
float
TrackData_op::getDuration()
{
if (isOrphan())
return FrameDur;
if ( ! (isHead()))
return (StartTime);
if (EndTime == 0.0f) {
TrackData_op* trk = getTail();
EndTime = trk->getTime() + FrameDur;
}
return (EndTime - StartTime);
}
// Extend the receiver by the argument
void
TrackData_op::linkTo(TrackData_op* tp)
{
tp->linkPrevious(this);
linkNext(tp);
InTrack = true;
tp->SetInTrack(true);
}
// Walk the links back to the head of this track
TrackData_op*
TrackData_op::getHead()
{
TrackData_op* trk;
trk = this;
while (trk->getPrev() != 0)
trk = trk->getPrev();
return trk;
}
// Walk the links forward to the tail of this track
TrackData_op*
TrackData_op::getTail()
{
TrackData_op* trk;
trk = this;
while (trk->getNext() != 0)
trk = trk->getNext();
return trk;
}

85
lib/trackdata_op.h Normal file
View File

@ -0,0 +1,85 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "trackdata_op.h"
// MODULE: Specification file for track data elements
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06
#ifndef TRACK_DATA_OP_H
#define TRACK_DATA_OP_H 1
class TrackData_op {
public:
TrackData_op();
TrackData_op(float time, float frequency, float amplitude, float frDur);
~TrackData_op();
// Accessing methods
float getTime() const { return StartTime; }
float getAmplitude() const { return Amplitude; }
float getPitch() const { return Pitch;}
float getEndPitch() const { return EndPitch;}
float getAvgAmplitude() const { return AvgAmplitude; }
float getAvgPitch() const { return AvgPitch;}
void setAvgAmplitude(float val) { AvgAmplitude = val; }
void setAvgPitch(float val) { AvgPitch = val;}
void setEndPitch(float val) { EndPitch = val;}
float getDuration();
float getStartTime() const { return StartTime; }
void SetInTrack(bool in) { InTrack = in; }
bool IsInTrack() { return InTrack; }
// Data/frame/list structure
void linkTo(TrackData_op* pr);
void linkPrevious(TrackData_op* pr) { previous = pr; }
void linkNext(TrackData_op* pr) { next = pr; }
TrackData_op* getPrev() const { return previous; }
TrackData_op* getNext() const { return next; }
TrackData_op* getHigher() const { return higher; }
void linkHigher(TrackData_op* pr) { higher = pr; }
TrackData_op* getHead();
TrackData_op* getTail();
// Inquiry
bool isOrphan() const { return ((previous == 0) && (next == 0)); }
bool isHead() const { return ((previous == 0) && (next != 0)); }
bool isTail() const { return ((previous != 0) && (next == 0)); }
private:
// Instance variables
float Amplitude; // single values
float Pitch;
float StartTime;
float EndTime;
float AvgAmplitude;
float AvgPitch;
float EndPitch;
float FrameDur;
// Inter-item links
TrackData_op* previous;
TrackData_op* next;
TrackData_op* higher;
// State
bool InTrack;
};
#endif

76
lib/trackframe_op.cpp Normal file
View File

@ -0,0 +1,76 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "trackframe_op.cpp"
// MODULE: Implementation for class TrackFrame_op
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06
#include <math.h>
#include "trackdata_op.h"
#include "trackframe_op.h"
// Constructor
TrackFrame_op::TrackFrame_op(float aTime)
{
FrameTime = aTime;
NumTracks = 0;
BaseTr = 0;
NextFr = 0;
}
// Delete the list of peaks on delete
TrackFrame_op::~TrackFrame_op()
{
TrackData_op* trk = BaseTr;
while (trk != 0) {
TrackData_op* next = trk->getHigher();
delete trk;
trk = next;
}
}
// Element add/remove
void
TrackFrame_op::Add(TrackData_op* td)
{
if (NumTracks == 0)
BaseTr = td;
NumTracks++;
}
// Answer the best-match (in frequency) track to the given value
TrackData_op*
TrackFrame_op::getTrackNearestFreq(float freq)
{
double diff;
double minDiff = 10000;
TrackData_op* answer;
answer = 0;
TrackData_op* ptr = BaseTr;
// Iterate over the receiver's peaks
while (ptr != 0) {
if (!ptr->IsInTrack())
{
// Find minimum frequency difference
diff = fabs (ptr->getPitch() - freq);
if (diff < minDiff) {
minDiff = diff;
answer = ptr;
}
}
ptr = ptr->getHigher();
}
return answer;
}

44
lib/trackframe_op.h Normal file
View File

@ -0,0 +1,44 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "trackframe_op.h"
// MODULE: Specification file for composite track frame objects
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06
class TrackData_op;
class TrackFrame_op {
public:
// Constructor
TrackFrame_op(float aTime = 0.0f);
~TrackFrame_op();
// Accessing methods
void Add(TrackData_op* td);
inline TrackData_op* getBaseTrack() { return BaseTr; }
inline TrackFrame_op* getNext() { return NextFr; }
inline void setNext(TrackFrame_op* td) { NextFr = td; }
inline float getTime() { return FrameTime; }
TrackData_op* getTrackNearestFreq(float freq);
private:
// Instance variables
int NumTracks;
float FrameTime;
TrackData_op* BaseTr;
TrackFrame_op* NextFr;
};

54
lib/tracklist_op.cpp Normal file
View File

@ -0,0 +1,54 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "tracklist_op.cpp"
// MODULE: Implementation for class TrackList
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06
#include "trackdata_op.h"
#include "tracklist_op.h"
// Constructor
TrackList_op::TrackList_op()
{
NumFrames = 0;
BaseFr = 0;
LastFr = 0;
}
// Delete the list of frames on delete
TrackList_op::~TrackList_op()
{
TrackFrame_op* frm = BaseFr;
while (frm != 0) {
TrackFrame_op* next = frm->getNext();
delete frm;
frm = next;
}
}
// Element add/remove
void
TrackList_op::Add(TrackFrame_op* td)
{
if (NumFrames == 0) {
BaseFr = td;
LastFr = td;
} else {
LastFr->setNext(td);
LastFr = td;
}
NumFrames++;
}

32
lib/tracklist_op.h Normal file
View File

@ -0,0 +1,32 @@
/* ------------------------------------------------------------------
libofa -- the Open Fingerprint Architecture library
Copyright (C) 2006 MusicIP Corporation
All rights reserved.
-------------------------------------------------------------------*/
// FILE: "tracklist_op.h"
// MODULE: Specification file for composite track list objects
// AUTHOR: Stephen Pope
// DATE CREATED: 01/12/06
#include "trackframe_op.h"
class TrackList_op {
public:
// Constructor
TrackList_op();
~TrackList_op();
// Accessing methods
void Add(TrackFrame_op* td);
TrackFrame_op* getBaseFrame() { return BaseFr; }
int getSize() { return NumFrames; }
private:
int NumFrames;
TrackFrame_op* BaseFr;
TrackFrame_op* LastFr;
};

12
libofa.pc.in Normal file
View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libofa
Description: The Open Fingerprint Architecture Library
URL: http://www.musicdns.org/
Version: @VERSION@
Requires: fftw3
Libs: -L${libdir} -lofa -lexpat -lm
Cflags: -I${includedir}

6426
ltmain.sh Normal file

File diff suppressed because it is too large Load Diff

360
missing Executable file
View File

@ -0,0 +1,360 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2003-09-02.23
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# 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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
# We have makeinfo, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
fi
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End: