mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #790 from micove/Update_3rdparty
Update some of the 3rd party libraries.
This commit is contained in:
commit
e65a223c91
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,327 @@
|
||||||
|
------------------------------------------------------------------
|
||||||
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
|
README file.
|
||||||
|
|
||||||
|
This program is released under the terms of the license contained
|
||||||
|
in the file LICENSE.
|
||||||
|
------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
0.9.0
|
||||||
|
~~~~~
|
||||||
|
First version.
|
||||||
|
|
||||||
|
|
||||||
|
0.9.0a
|
||||||
|
~~~~~~
|
||||||
|
Removed 'ranlib' from Makefile, since most modern Unix-es
|
||||||
|
don't need it, or even know about it.
|
||||||
|
|
||||||
|
|
||||||
|
0.9.0b
|
||||||
|
~~~~~~
|
||||||
|
Fixed a problem with error reporting in bzip2.c. This does not effect
|
||||||
|
the library in any way. Problem is: versions 0.9.0 and 0.9.0a (of the
|
||||||
|
program proper) compress and decompress correctly, but give misleading
|
||||||
|
error messages (internal panics) when an I/O error occurs, instead of
|
||||||
|
reporting the problem correctly. This shouldn't give any data loss
|
||||||
|
(as far as I can see), but is confusing.
|
||||||
|
|
||||||
|
Made the inline declarations disappear for non-GCC compilers.
|
||||||
|
|
||||||
|
|
||||||
|
0.9.0c
|
||||||
|
~~~~~~
|
||||||
|
Fixed some problems in the library pertaining to some boundary cases.
|
||||||
|
This makes the library behave more correctly in those situations. The
|
||||||
|
fixes apply only to features (calls and parameters) not used by
|
||||||
|
bzip2.c, so the non-fixedness of them in previous versions has no
|
||||||
|
effect on reliability of bzip2.c.
|
||||||
|
|
||||||
|
In bzlib.c:
|
||||||
|
* made zero-length BZ_FLUSH work correctly in bzCompress().
|
||||||
|
* fixed bzWrite/bzRead to ignore zero-length requests.
|
||||||
|
* fixed bzread to correctly handle read requests after EOF.
|
||||||
|
* wrong parameter order in call to bzDecompressInit in
|
||||||
|
bzBuffToBuffDecompress. Fixed.
|
||||||
|
|
||||||
|
In compress.c:
|
||||||
|
* changed setting of nGroups in sendMTFValues() so as to
|
||||||
|
do a bit better on small files. This _does_ effect
|
||||||
|
bzip2.c.
|
||||||
|
|
||||||
|
|
||||||
|
0.9.5a
|
||||||
|
~~~~~~
|
||||||
|
Major change: add a fallback sorting algorithm (blocksort.c)
|
||||||
|
to give reasonable behaviour even for very repetitive inputs.
|
||||||
|
Nuked --repetitive-best and --repetitive-fast since they are
|
||||||
|
no longer useful.
|
||||||
|
|
||||||
|
Minor changes: mostly a whole bunch of small changes/
|
||||||
|
bugfixes in the driver (bzip2.c). Changes pertaining to the
|
||||||
|
user interface are:
|
||||||
|
|
||||||
|
allow decompression of symlink'd files to stdout
|
||||||
|
decompress/test files even without .bz2 extension
|
||||||
|
give more accurate error messages for I/O errors
|
||||||
|
when compressing/decompressing to stdout, don't catch control-C
|
||||||
|
read flags from BZIP2 and BZIP environment variables
|
||||||
|
decline to break hard links to a file unless forced with -f
|
||||||
|
allow -c flag even with no filenames
|
||||||
|
preserve file ownerships as far as possible
|
||||||
|
make -s -1 give the expected block size (100k)
|
||||||
|
add a flag -q --quiet to suppress nonessential warnings
|
||||||
|
stop decoding flags after --, so files beginning in - can be handled
|
||||||
|
resolved inconsistent naming: bzcat or bz2cat ?
|
||||||
|
bzip2 --help now returns 0
|
||||||
|
|
||||||
|
Programming-level changes are:
|
||||||
|
|
||||||
|
fixed syntax error in GET_LL4 for Borland C++ 5.02
|
||||||
|
let bzBuffToBuffDecompress return BZ_DATA_ERROR{_MAGIC}
|
||||||
|
fix overshoot of mode-string end in bzopen_or_bzdopen
|
||||||
|
wrapped bzlib.h in #ifdef __cplusplus ... extern "C" { ... }
|
||||||
|
close file handles under all error conditions
|
||||||
|
added minor mods so it compiles with DJGPP out of the box
|
||||||
|
fixed Makefile so it doesn't give problems with BSD make
|
||||||
|
fix uninitialised memory reads in dlltest.c
|
||||||
|
|
||||||
|
0.9.5b
|
||||||
|
~~~~~~
|
||||||
|
Open stdin/stdout in binary mode for DJGPP.
|
||||||
|
|
||||||
|
0.9.5c
|
||||||
|
~~~~~~
|
||||||
|
Changed BZ_N_OVERSHOOT to be ... + 2 instead of ... + 1. The + 1
|
||||||
|
version could cause the sorted order to be wrong in some extremely
|
||||||
|
obscure cases. Also changed setting of quadrant in blocksort.c.
|
||||||
|
|
||||||
|
0.9.5d
|
||||||
|
~~~~~~
|
||||||
|
The only functional change is to make bzlibVersion() in the library
|
||||||
|
return the correct string. This has no effect whatsoever on the
|
||||||
|
functioning of the bzip2 program or library. Added a couple of casts
|
||||||
|
so the library compiles without warnings at level 3 in MS Visual
|
||||||
|
Studio 6.0. Included a Y2K statement in the file Y2K_INFO. All other
|
||||||
|
changes are minor documentation changes.
|
||||||
|
|
||||||
|
1.0
|
||||||
|
~~~
|
||||||
|
Several minor bugfixes and enhancements:
|
||||||
|
|
||||||
|
* Large file support. The library uses 64-bit counters to
|
||||||
|
count the volume of data passing through it. bzip2.c
|
||||||
|
is now compiled with -D_FILE_OFFSET_BITS=64 to get large
|
||||||
|
file support from the C library. -v correctly prints out
|
||||||
|
file sizes greater than 4 gigabytes. All these changes have
|
||||||
|
been made without assuming a 64-bit platform or a C compiler
|
||||||
|
which supports 64-bit ints, so, except for the C library
|
||||||
|
aspect, they are fully portable.
|
||||||
|
|
||||||
|
* Decompression robustness. The library/program should be
|
||||||
|
robust to any corruption of compressed data, detecting and
|
||||||
|
handling _all_ corruption, instead of merely relying on
|
||||||
|
the CRCs. What this means is that the program should
|
||||||
|
never crash, given corrupted data, and the library should
|
||||||
|
always return BZ_DATA_ERROR.
|
||||||
|
|
||||||
|
* Fixed an obscure race-condition bug only ever observed on
|
||||||
|
Solaris, in which, if you were very unlucky and issued
|
||||||
|
control-C at exactly the wrong time, both input and output
|
||||||
|
files would be deleted.
|
||||||
|
|
||||||
|
* Don't run out of file handles on test/decompression when
|
||||||
|
large numbers of files have invalid magic numbers.
|
||||||
|
|
||||||
|
* Avoid library namespace pollution. Prefix all exported
|
||||||
|
symbols with BZ2_.
|
||||||
|
|
||||||
|
* Minor sorting enhancements from my DCC2000 paper.
|
||||||
|
|
||||||
|
* Advance the version number to 1.0, so as to counteract the
|
||||||
|
(false-in-this-case) impression some people have that programs
|
||||||
|
with version numbers less than 1.0 are in some way, experimental,
|
||||||
|
pre-release versions.
|
||||||
|
|
||||||
|
* Create an initial Makefile-libbz2_so to build a shared library.
|
||||||
|
Yes, I know I should really use libtool et al ...
|
||||||
|
|
||||||
|
* Make the program exit with 2 instead of 0 when decompression
|
||||||
|
fails due to a bad magic number (ie, an invalid bzip2 header).
|
||||||
|
Also exit with 1 (as the manual claims :-) whenever a diagnostic
|
||||||
|
message would have been printed AND the corresponding operation
|
||||||
|
is aborted, for example
|
||||||
|
bzip2: Output file xx already exists.
|
||||||
|
When a diagnostic message is printed but the operation is not
|
||||||
|
aborted, for example
|
||||||
|
bzip2: Can't guess original name for wurble -- using wurble.out
|
||||||
|
then the exit value 0 is returned, unless some other problem is
|
||||||
|
also detected.
|
||||||
|
|
||||||
|
I think it corresponds more closely to what the manual claims now.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.1
|
||||||
|
~~~~~
|
||||||
|
* Modified dlltest.c so it uses the new BZ2_ naming scheme.
|
||||||
|
* Modified makefile-msc to fix minor build probs on Win2k.
|
||||||
|
* Updated README.COMPILATION.PROBLEMS.
|
||||||
|
|
||||||
|
There are no functionality changes or bug fixes relative to version
|
||||||
|
1.0.0. This is just a documentation update + a fix for minor Win32
|
||||||
|
build problems. For almost everyone, upgrading from 1.0.0 to 1.0.1 is
|
||||||
|
utterly pointless. Don't bother.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.2
|
||||||
|
~~~~~
|
||||||
|
A bug fix release, addressing various minor issues which have appeared
|
||||||
|
in the 18 or so months since 1.0.1 was released. Most of the fixes
|
||||||
|
are to do with file-handling or documentation bugs. To the best of my
|
||||||
|
knowledge, there have been no data-loss-causing bugs reported in the
|
||||||
|
compression/decompression engine of 1.0.0 or 1.0.1.
|
||||||
|
|
||||||
|
Note that this release does not improve the rather crude build system
|
||||||
|
for Unix platforms. The general plan here is to autoconfiscate/
|
||||||
|
libtoolise 1.0.2 soon after release, and release the result as 1.1.0
|
||||||
|
or perhaps 1.2.0. That, however, is still just a plan at this point.
|
||||||
|
|
||||||
|
Here are the changes in 1.0.2. Bug-reporters and/or patch-senders in
|
||||||
|
parentheses.
|
||||||
|
|
||||||
|
* Fix an infinite segfault loop in 1.0.1 when a directory is
|
||||||
|
encountered in -f (force) mode.
|
||||||
|
(Trond Eivind Glomsrod, Nicholas Nethercote, Volker Schmidt)
|
||||||
|
|
||||||
|
* Avoid double fclose() of output file on certain I/O error paths.
|
||||||
|
(Solar Designer)
|
||||||
|
|
||||||
|
* Don't fail with internal error 1007 when fed a long stream (> 48MB)
|
||||||
|
of byte 251. Also print useful message suggesting that 1007s may be
|
||||||
|
caused by bad memory.
|
||||||
|
(noticed by Juan Pedro Vallejo, fixed by me)
|
||||||
|
|
||||||
|
* Fix uninitialised variable silly bug in demo prog dlltest.c.
|
||||||
|
(Jorj Bauer)
|
||||||
|
|
||||||
|
* Remove 512-MB limitation on recovered file size for bzip2recover
|
||||||
|
on selected platforms which support 64-bit ints. At the moment
|
||||||
|
all GCC supported platforms, and Win32.
|
||||||
|
(me, Alson van der Meulen)
|
||||||
|
|
||||||
|
* Hard-code header byte values, to give correct operation on platforms
|
||||||
|
using EBCDIC as their native character set (IBM's OS/390).
|
||||||
|
(Leland Lucius)
|
||||||
|
|
||||||
|
* Copy file access times correctly.
|
||||||
|
(Marty Leisner)
|
||||||
|
|
||||||
|
* Add distclean and check targets to Makefile.
|
||||||
|
(Michael Carmack)
|
||||||
|
|
||||||
|
* Parameterise use of ar and ranlib in Makefile. Also add $(LDFLAGS).
|
||||||
|
(Rich Ireland, Bo Thorsen)
|
||||||
|
|
||||||
|
* Pass -p (create parent dirs as needed) to mkdir during make install.
|
||||||
|
(Jeremy Fusco)
|
||||||
|
|
||||||
|
* Dereference symlinks when copying file permissions in -f mode.
|
||||||
|
(Volker Schmidt)
|
||||||
|
|
||||||
|
* Majorly simplify implementation of uInt64_qrm10.
|
||||||
|
(Bo Lindbergh)
|
||||||
|
|
||||||
|
* Check the input file still exists before deleting the output one,
|
||||||
|
when aborting in cleanUpAndFail().
|
||||||
|
(Joerg Prante, Robert Linden, Matthias Krings)
|
||||||
|
|
||||||
|
Also a bunch of patches courtesy of Philippe Troin, the Debian maintainer
|
||||||
|
of bzip2:
|
||||||
|
|
||||||
|
* Wrapper scripts (with manpages): bzdiff, bzgrep, bzmore.
|
||||||
|
|
||||||
|
* Spelling changes and minor enhancements in bzip2.1.
|
||||||
|
|
||||||
|
* Avoid race condition between creating the output file and setting its
|
||||||
|
interim permissions safely, by using fopen_output_safely().
|
||||||
|
No changes to bzip2recover since there is no issue with file
|
||||||
|
permissions there.
|
||||||
|
|
||||||
|
* do not print senseless report with -v when compressing an empty
|
||||||
|
file.
|
||||||
|
|
||||||
|
* bzcat -f works on non-bzip2 files.
|
||||||
|
|
||||||
|
* do not try to escape shell meta-characters on unix (the shell takes
|
||||||
|
care of these).
|
||||||
|
|
||||||
|
* added --fast and --best aliases for -1 -9 for gzip compatibility.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.3 (15 Feb 05)
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
Fixes some minor bugs since the last version, 1.0.2.
|
||||||
|
|
||||||
|
* Further robustification against corrupted compressed data.
|
||||||
|
There are currently no known bitstreams which can cause the
|
||||||
|
decompressor to crash, loop or access memory which does not
|
||||||
|
belong to it. If you are using bzip2 or the library to
|
||||||
|
decompress bitstreams from untrusted sources, an upgrade
|
||||||
|
to 1.0.3 is recommended. This fixes CAN-2005-1260.
|
||||||
|
|
||||||
|
* The documentation has been converted to XML, from which html
|
||||||
|
and pdf can be derived.
|
||||||
|
|
||||||
|
* Various minor bugs in the documentation have been fixed.
|
||||||
|
|
||||||
|
* Fixes for various compilation warnings with newer versions of
|
||||||
|
gcc, and on 64-bit platforms.
|
||||||
|
|
||||||
|
* The BZ_NO_STDIO cpp symbol was not properly observed in 1.0.2.
|
||||||
|
This has been fixed.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.4 (20 Dec 06)
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
Fixes some minor bugs since the last version, 1.0.3.
|
||||||
|
|
||||||
|
* Fix file permissions race problem (CAN-2005-0953).
|
||||||
|
|
||||||
|
* Avoid possible segfault in BZ2_bzclose. From Coverity's NetBSD
|
||||||
|
scan.
|
||||||
|
|
||||||
|
* 'const'/prototype cleanups in the C code.
|
||||||
|
|
||||||
|
* Change default install location to /usr/local, and handle multiple
|
||||||
|
'make install's without error.
|
||||||
|
|
||||||
|
* Sanitise file names more carefully in bzgrep. Fixes CAN-2005-0758
|
||||||
|
to the extent that applies to bzgrep.
|
||||||
|
|
||||||
|
* Use 'mktemp' rather than 'tempfile' in bzdiff.
|
||||||
|
|
||||||
|
* Tighten up a couple of assertions in blocksort.c following automated
|
||||||
|
analysis.
|
||||||
|
|
||||||
|
* Fix minor doc/comment bugs.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.5 (10 Dec 07)
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
Security fix only. Fixes CERT-FI 20469 as it applies to bzip2.
|
||||||
|
|
||||||
|
|
||||||
|
1.0.6 (6 Sept 10)
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
* Security fix for CVE-2010-0405. This was reported by Mikolaj
|
||||||
|
Izdebski.
|
||||||
|
|
||||||
|
* Make the documentation build on Ubuntu 10.04
|
|
@ -2,7 +2,7 @@
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
This program, "bzip2", the associated library "libbzip2", and all
|
This program, "bzip2", the associated library "libbzip2", and all
|
||||||
documentation, are copyright (C) 1996-2006 Julian R Seward. All
|
documentation, are copyright (C) 1996-2010 Julian R Seward. All
|
||||||
rights reserved.
|
rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -36,8 +36,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
Julian Seward, Cambridge, UK.
|
Julian Seward, jseward@bzip.org
|
||||||
jseward@bzip.org
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
|
@ -6,8 +6,8 @@ This version is fully compatible with the previous public releases.
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
|
Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
|
||||||
|
|
||||||
|
@ -177,6 +177,14 @@ WHAT'S NEW IN 1.0.4 ?
|
||||||
|
|
||||||
See the CHANGES file.
|
See the CHANGES file.
|
||||||
|
|
||||||
|
WHAT'S NEW IN 1.0.5 ?
|
||||||
|
|
||||||
|
See the CHANGES file.
|
||||||
|
|
||||||
|
WHAT'S NEW IN 1.0.6 ?
|
||||||
|
|
||||||
|
See the CHANGES file.
|
||||||
|
|
||||||
|
|
||||||
I hope you find bzip2 useful. Feel free to contact me at
|
I hope you find bzip2 useful. Feel free to contact me at
|
||||||
jseward@bzip.org
|
jseward@bzip.org
|
||||||
|
@ -203,3 +211,5 @@ Cambridge, UK.
|
||||||
30 December 2001 (bzip2, version 1.0.2pre1)
|
30 December 2001 (bzip2, version 1.0.2pre1)
|
||||||
15 February 2005 (bzip2, version 1.0.3)
|
15 February 2005 (bzip2, version 1.0.3)
|
||||||
20 December 2006 (bzip2, version 1.0.4)
|
20 December 2006 (bzip2, version 1.0.4)
|
||||||
|
10 December 2007 (bzip2, version 1.0.5)
|
||||||
|
6 Sept 2010 (bzip2, version 1.0.6)
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
@ -48,7 +48,7 @@ void BZ2_bz__AssertH__fail ( int errcode )
|
||||||
"component, you should also report this bug to the author(s)\n"
|
"component, you should also report this bug to the author(s)\n"
|
||||||
"of that program. Please make an effort to report this bug;\n"
|
"of that program. Please make an effort to report this bug;\n"
|
||||||
"timely and accurate bug reports eventually lead to higher\n"
|
"timely and accurate bug reports eventually lead to higher\n"
|
||||||
"quality software. Thanks. Julian Seward, 15 February 2005.\n\n",
|
"quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
|
||||||
errcode,
|
errcode,
|
||||||
BZ2_bzlibVersion()
|
BZ2_bzlibVersion()
|
||||||
);
|
);
|
||||||
|
@ -598,6 +598,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
|
||||||
UInt32 c_tPos = s->tPos;
|
UInt32 c_tPos = s->tPos;
|
||||||
char* cs_next_out = s->strm->next_out;
|
char* cs_next_out = s->strm->next_out;
|
||||||
unsigned int cs_avail_out = s->strm->avail_out;
|
unsigned int cs_avail_out = s->strm->avail_out;
|
||||||
|
Int32 ro_blockSize100k = s->blockSize100k;
|
||||||
/* end restore */
|
/* end restore */
|
||||||
|
|
||||||
UInt32 avail_out_INIT = cs_avail_out;
|
UInt32 avail_out_INIT = cs_avail_out;
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
/*-- General stuff. --*/
|
/*-- General stuff. --*/
|
||||||
|
|
||||||
#define BZ_VERSION "1.0.4, 20-Dec-2006"
|
#define BZ_VERSION "1.0.6, 6-Sept-2010"
|
||||||
|
|
||||||
typedef char Char;
|
typedef char Char;
|
||||||
typedef unsigned char Bool;
|
typedef unsigned char Bool;
|
||||||
|
@ -442,11 +442,15 @@ typedef
|
||||||
/*-- Macros for decompression. --*/
|
/*-- Macros for decompression. --*/
|
||||||
|
|
||||||
#define BZ_GET_FAST(cccc) \
|
#define BZ_GET_FAST(cccc) \
|
||||||
|
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
|
||||||
|
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
|
||||||
s->tPos = s->tt[s->tPos]; \
|
s->tPos = s->tt[s->tPos]; \
|
||||||
cccc = (UChar)(s->tPos & 0xff); \
|
cccc = (UChar)(s->tPos & 0xff); \
|
||||||
s->tPos >>= 8;
|
s->tPos >>= 8;
|
||||||
|
|
||||||
#define BZ_GET_FAST_C(cccc) \
|
#define BZ_GET_FAST_C(cccc) \
|
||||||
|
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
|
||||||
|
if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
|
||||||
c_tPos = c_tt[c_tPos]; \
|
c_tPos = c_tt[c_tPos]; \
|
||||||
cccc = (UChar)(c_tPos & 0xff); \
|
cccc = (UChar)(c_tPos & 0xff); \
|
||||||
c_tPos >>= 8;
|
c_tPos >>= 8;
|
||||||
|
@ -469,6 +473,8 @@ typedef
|
||||||
(((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
|
(((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
|
||||||
|
|
||||||
#define BZ_GET_SMALL(cccc) \
|
#define BZ_GET_SMALL(cccc) \
|
||||||
|
/* c_tPos is unsigned, hence test < 0 is pointless. */ \
|
||||||
|
if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
|
||||||
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
|
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
|
||||||
s->tPos = GET_LL(s->tPos);
|
s->tPos = GET_LL(s->tPos);
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
@ -381,6 +381,13 @@ Int32 BZ2_decompress ( DState* s )
|
||||||
es = -1;
|
es = -1;
|
||||||
N = 1;
|
N = 1;
|
||||||
do {
|
do {
|
||||||
|
/* Check that N doesn't get too big, so that es doesn't
|
||||||
|
go negative. The maximum value that can be
|
||||||
|
RUNA/RUNB encoded is equal to the block size (post
|
||||||
|
the initial RLE), viz, 900k, so bounding N at 2
|
||||||
|
million should guard against overflow without
|
||||||
|
rejecting any legitimate inputs. */
|
||||||
|
if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR);
|
||||||
if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
|
if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
|
||||||
if (nextSym == BZ_RUNB) es = es + (1+1) * N;
|
if (nextSym == BZ_RUNB) es = es + (1+1) * N;
|
||||||
N = N * 2;
|
N = N * 2;
|
||||||
|
@ -485,15 +492,28 @@ Int32 BZ2_decompress ( DState* s )
|
||||||
RETURN(BZ_DATA_ERROR);
|
RETURN(BZ_DATA_ERROR);
|
||||||
|
|
||||||
/*-- Set up cftab to facilitate generation of T^(-1) --*/
|
/*-- Set up cftab to facilitate generation of T^(-1) --*/
|
||||||
|
/* Check: unzftab entries in range. */
|
||||||
|
for (i = 0; i <= 255; i++) {
|
||||||
|
if (s->unzftab[i] < 0 || s->unzftab[i] > nblock)
|
||||||
|
RETURN(BZ_DATA_ERROR);
|
||||||
|
}
|
||||||
|
/* Actually generate cftab. */
|
||||||
s->cftab[0] = 0;
|
s->cftab[0] = 0;
|
||||||
for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
|
for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
|
||||||
for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
|
for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
|
||||||
|
/* Check: cftab entries in range. */
|
||||||
for (i = 0; i <= 256; i++) {
|
for (i = 0; i <= 256; i++) {
|
||||||
if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
|
if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
|
||||||
/* s->cftab[i] can legitimately be == nblock */
|
/* s->cftab[i] can legitimately be == nblock */
|
||||||
RETURN(BZ_DATA_ERROR);
|
RETURN(BZ_DATA_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Check: cftab entries non-descending. */
|
||||||
|
for (i = 1; i <= 256; i++) {
|
||||||
|
if (s->cftab[i-1] > s->cftab[i]) {
|
||||||
|
RETURN(BZ_DATA_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s->state_out_len = 0;
|
s->state_out_len = 0;
|
||||||
s->state_out_ch = 0;
|
s->state_out_ch = 0;
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
This file is part of bzip2/libbzip2, a program and library for
|
This file is part of bzip2/libbzip2, a program and library for
|
||||||
lossless, block-sorting data compression.
|
lossless, block-sorting data compression.
|
||||||
|
|
||||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
|
||||||
|
|
||||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||||
README file.
|
README file.
|
||||||
|
|
|
@ -1,349 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///
|
|
||||||
/// Win32 version of the AMD 3DNow! optimized routines for AMD K6-2/Athlon
|
|
||||||
/// processors. All 3DNow! optimized functions have been gathered into this
|
|
||||||
/// single source code file, regardless to their class or original source code
|
|
||||||
/// file, in order to ease porting the library to other compiler and processor
|
|
||||||
/// platforms.
|
|
||||||
///
|
|
||||||
/// By the way; the performance gain depends heavily on the CPU generation: On
|
|
||||||
/// K6-2 these routines provided speed-up of even 2.4 times, while on Athlon the
|
|
||||||
/// difference to the original routines stayed at unremarkable 8%! Such a small
|
|
||||||
/// improvement on Athlon is due to 3DNow can perform only two operations in
|
|
||||||
/// parallel, and obviously also the Athlon FPU is doing a very good job with
|
|
||||||
/// the standard C floating point routines! Here these routines are anyway,
|
|
||||||
/// although it might not be worth the effort to convert these to GCC platform,
|
|
||||||
/// for Athlon CPU at least. The situation is different regarding the SSE
|
|
||||||
/// optimizations though, thanks to the four parallel operations of SSE that
|
|
||||||
/// already make a difference.
|
|
||||||
///
|
|
||||||
/// This file is to be compiled in Windows platform with Microsoft Visual C++
|
|
||||||
/// Compiler. Please see '3dnow_gcc.cpp' for the gcc compiler version for all
|
|
||||||
/// GNU platforms (if file supplied).
|
|
||||||
///
|
|
||||||
/// NOTICE: If using Visual Studio 6.0, you'll need to install the "Visual C++
|
|
||||||
/// 6.0 processor pack" update to support 3DNow! instruction set. The update is
|
|
||||||
/// available for download at Microsoft Developers Network, see here:
|
|
||||||
/// http://msdn.microsoft.com/en-us/vstudio/aa718349.aspx
|
|
||||||
///
|
|
||||||
/// If the above URL is expired or removed, go to "http://msdn.microsoft.com" and
|
|
||||||
/// perform a search with keywords "processor pack".
|
|
||||||
///
|
|
||||||
/// Author : Copyright (c) Olli Parviainen
|
|
||||||
/// Author e-mail : oparviai 'at' iki.fi
|
|
||||||
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
|
|
||||||
// File revision : $Revision: 4 $
|
|
||||||
//
|
|
||||||
// $Id: 3dnow_win.cpp 63 2009-02-21 16:00:14Z oparviai $
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// License :
|
|
||||||
//
|
|
||||||
// SoundTouch audio processing library
|
|
||||||
// Copyright (c) Olli Parviainen
|
|
||||||
//
|
|
||||||
// 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 (at your option) 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "cpu_detect.h"
|
|
||||||
#include "STTypes.h"
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#error "wrong platform - this source code file is exclusively for Win32 platform"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace soundtouch;
|
|
||||||
|
|
||||||
#ifdef ALLOW_3DNOW
|
|
||||||
// 3DNow! routines available only with float sample type
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// implementation of 3DNow! optimized functions of class 'TDStretch3DNow'
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "TDStretch.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Calculates cross correlation of two buffers
|
|
||||||
double TDStretch3DNow::calcCrossCorrStereo(const float *pV1, const float *pV2) const
|
|
||||||
{
|
|
||||||
int overlapLengthLocal = overlapLength;
|
|
||||||
float corr = 0;
|
|
||||||
|
|
||||||
// Calculates the cross-correlation value between 'pV1' and 'pV2' vectors
|
|
||||||
/*
|
|
||||||
c-pseudocode:
|
|
||||||
|
|
||||||
corr = 0;
|
|
||||||
for (i = 0; i < overlapLength / 4; i ++)
|
|
||||||
{
|
|
||||||
corr += pV1[0] * pV2[0];
|
|
||||||
pV1[1] * pV2[1];
|
|
||||||
pV1[2] * pV2[2];
|
|
||||||
pV1[3] * pV2[3];
|
|
||||||
pV1[4] * pV2[4];
|
|
||||||
pV1[5] * pV2[5];
|
|
||||||
pV1[6] * pV2[6];
|
|
||||||
pV1[7] * pV2[7];
|
|
||||||
|
|
||||||
pV1 += 8;
|
|
||||||
pV2 += 8;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
_asm
|
|
||||||
{
|
|
||||||
// give prefetch hints to CPU of what data are to be needed soonish.
|
|
||||||
// give more aggressive hints on pV1 as that changes more between different calls
|
|
||||||
// while pV2 stays the same.
|
|
||||||
prefetch [pV1]
|
|
||||||
prefetch [pV2]
|
|
||||||
prefetch [pV1 + 32]
|
|
||||||
|
|
||||||
mov eax, dword ptr pV2
|
|
||||||
mov ebx, dword ptr pV1
|
|
||||||
|
|
||||||
pxor mm0, mm0
|
|
||||||
|
|
||||||
mov ecx, overlapLengthLocal
|
|
||||||
shr ecx, 2 // div by four
|
|
||||||
|
|
||||||
loop1:
|
|
||||||
movq mm1, [eax]
|
|
||||||
prefetch [eax + 32] // give a prefetch hint to CPU what data are to be needed soonish
|
|
||||||
pfmul mm1, [ebx]
|
|
||||||
prefetch [ebx + 64] // give a prefetch hint to CPU what data are to be needed soonish
|
|
||||||
|
|
||||||
movq mm2, [eax + 8]
|
|
||||||
pfadd mm0, mm1
|
|
||||||
pfmul mm2, [ebx + 8]
|
|
||||||
|
|
||||||
movq mm3, [eax + 16]
|
|
||||||
pfadd mm0, mm2
|
|
||||||
pfmul mm3, [ebx + 16]
|
|
||||||
|
|
||||||
movq mm4, [eax + 24]
|
|
||||||
pfadd mm0, mm3
|
|
||||||
pfmul mm4, [ebx + 24]
|
|
||||||
|
|
||||||
add eax, 32
|
|
||||||
pfadd mm0, mm4
|
|
||||||
add ebx, 32
|
|
||||||
|
|
||||||
dec ecx
|
|
||||||
jnz loop1
|
|
||||||
|
|
||||||
// add halfs of mm0 together and return the result.
|
|
||||||
// note: mm1 is used as a dummy parameter only, we actually don't care about it's value
|
|
||||||
pfacc mm0, mm1
|
|
||||||
movd corr, mm0
|
|
||||||
femms
|
|
||||||
}
|
|
||||||
|
|
||||||
return corr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// implementation of 3DNow! optimized functions of class 'FIRFilter'
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "FIRFilter.h"
|
|
||||||
|
|
||||||
FIRFilter3DNow::FIRFilter3DNow() : FIRFilter()
|
|
||||||
{
|
|
||||||
filterCoeffsUnalign = NULL;
|
|
||||||
filterCoeffsAlign = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FIRFilter3DNow::~FIRFilter3DNow()
|
|
||||||
{
|
|
||||||
delete[] filterCoeffsUnalign;
|
|
||||||
filterCoeffsUnalign = NULL;
|
|
||||||
filterCoeffsAlign = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// (overloaded) Calculates filter coefficients for 3DNow! routine
|
|
||||||
void FIRFilter3DNow::setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor)
|
|
||||||
{
|
|
||||||
uint i;
|
|
||||||
float fDivider;
|
|
||||||
|
|
||||||
FIRFilter::setCoefficients(coeffs, newLength, uResultDivFactor);
|
|
||||||
|
|
||||||
// Scale the filter coefficients so that it won't be necessary to scale the filtering result
|
|
||||||
// also rearrange coefficients suitably for 3DNow!
|
|
||||||
// Ensure that filter coeffs array is aligned to 16-byte boundary
|
|
||||||
delete[] filterCoeffsUnalign;
|
|
||||||
filterCoeffsUnalign = new float[2 * newLength + 4];
|
|
||||||
filterCoeffsAlign = (float *)(((uint)filterCoeffsUnalign + 15) & (uint)-16);
|
|
||||||
|
|
||||||
fDivider = (float)resultDivider;
|
|
||||||
|
|
||||||
// rearrange the filter coefficients for mmx routines
|
|
||||||
for (i = 0; i < newLength; i ++)
|
|
||||||
{
|
|
||||||
filterCoeffsAlign[2 * i + 0] =
|
|
||||||
filterCoeffsAlign[2 * i + 1] = coeffs[i + 0] / fDivider;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 3DNow!-optimized version of the filter routine for stereo sound
|
|
||||||
uint FIRFilter3DNow::evaluateFilterStereo(float *dest, const float *src, uint numSamples) const
|
|
||||||
{
|
|
||||||
float *filterCoeffsLocal = filterCoeffsAlign;
|
|
||||||
uint count = (numSamples - length) & (uint)-2;
|
|
||||||
uint lengthLocal = length / 4;
|
|
||||||
|
|
||||||
assert(length != 0);
|
|
||||||
assert(count % 2 == 0);
|
|
||||||
|
|
||||||
/* original code:
|
|
||||||
|
|
||||||
double suml1, suml2;
|
|
||||||
double sumr1, sumr2;
|
|
||||||
uint i, j;
|
|
||||||
|
|
||||||
for (j = 0; j < count; j += 2)
|
|
||||||
{
|
|
||||||
const float *ptr;
|
|
||||||
|
|
||||||
suml1 = sumr1 = 0.0;
|
|
||||||
suml2 = sumr2 = 0.0;
|
|
||||||
ptr = src;
|
|
||||||
filterCoeffsLocal = filterCoeffs;
|
|
||||||
for (i = 0; i < lengthLocal; i ++)
|
|
||||||
{
|
|
||||||
// unroll loop for efficiency.
|
|
||||||
|
|
||||||
suml1 += ptr[0] * filterCoeffsLocal[0] +
|
|
||||||
ptr[2] * filterCoeffsLocal[2] +
|
|
||||||
ptr[4] * filterCoeffsLocal[4] +
|
|
||||||
ptr[6] * filterCoeffsLocal[6];
|
|
||||||
|
|
||||||
sumr1 += ptr[1] * filterCoeffsLocal[1] +
|
|
||||||
ptr[3] * filterCoeffsLocal[3] +
|
|
||||||
ptr[5] * filterCoeffsLocal[5] +
|
|
||||||
ptr[7] * filterCoeffsLocal[7];
|
|
||||||
|
|
||||||
suml2 += ptr[8] * filterCoeffsLocal[0] +
|
|
||||||
ptr[10] * filterCoeffsLocal[2] +
|
|
||||||
ptr[12] * filterCoeffsLocal[4] +
|
|
||||||
ptr[14] * filterCoeffsLocal[6];
|
|
||||||
|
|
||||||
sumr2 += ptr[9] * filterCoeffsLocal[1] +
|
|
||||||
ptr[11] * filterCoeffsLocal[3] +
|
|
||||||
ptr[13] * filterCoeffsLocal[5] +
|
|
||||||
ptr[15] * filterCoeffsLocal[7];
|
|
||||||
|
|
||||||
ptr += 16;
|
|
||||||
filterCoeffsLocal += 8;
|
|
||||||
}
|
|
||||||
dest[0] = (float)suml1;
|
|
||||||
dest[1] = (float)sumr1;
|
|
||||||
dest[2] = (float)suml2;
|
|
||||||
dest[3] = (float)sumr2;
|
|
||||||
|
|
||||||
src += 4;
|
|
||||||
dest += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
_asm
|
|
||||||
{
|
|
||||||
mov eax, dword ptr dest
|
|
||||||
mov ebx, dword ptr src
|
|
||||||
mov edx, count
|
|
||||||
shr edx, 1
|
|
||||||
|
|
||||||
loop1:
|
|
||||||
// "outer loop" : during each round 2*2 output samples are calculated
|
|
||||||
prefetch [ebx] // give a prefetch hint to CPU what data are to be needed soonish
|
|
||||||
prefetch [filterCoeffsLocal] // give a prefetch hint to CPU what data are to be needed soonish
|
|
||||||
|
|
||||||
mov esi, ebx
|
|
||||||
mov edi, filterCoeffsLocal
|
|
||||||
pxor mm0, mm0
|
|
||||||
pxor mm1, mm1
|
|
||||||
mov ecx, lengthLocal
|
|
||||||
|
|
||||||
loop2:
|
|
||||||
// "inner loop" : during each round four FIR filter taps are evaluated for 2*2 output samples
|
|
||||||
movq mm2, [edi]
|
|
||||||
movq mm3, mm2
|
|
||||||
prefetch [edi + 32] // give a prefetch hint to CPU what data are to be needed soonish
|
|
||||||
pfmul mm2, [esi]
|
|
||||||
prefetch [esi + 32] // give a prefetch hint to CPU what data are to be needed soonish
|
|
||||||
pfmul mm3, [esi + 8]
|
|
||||||
|
|
||||||
movq mm4, [edi + 8]
|
|
||||||
movq mm5, mm4
|
|
||||||
pfadd mm0, mm2
|
|
||||||
pfmul mm4, [esi + 8]
|
|
||||||
pfadd mm1, mm3
|
|
||||||
pfmul mm5, [esi + 16]
|
|
||||||
|
|
||||||
movq mm2, [edi + 16]
|
|
||||||
movq mm6, mm2
|
|
||||||
pfadd mm0, mm4
|
|
||||||
pfmul mm2, [esi + 16]
|
|
||||||
pfadd mm1, mm5
|
|
||||||
pfmul mm6, [esi + 24]
|
|
||||||
|
|
||||||
movq mm3, [edi + 24]
|
|
||||||
movq mm7, mm3
|
|
||||||
pfadd mm0, mm2
|
|
||||||
pfmul mm3, [esi + 24]
|
|
||||||
pfadd mm1, mm6
|
|
||||||
pfmul mm7, [esi + 32]
|
|
||||||
add esi, 32
|
|
||||||
pfadd mm0, mm3
|
|
||||||
add edi, 32
|
|
||||||
pfadd mm1, mm7
|
|
||||||
|
|
||||||
dec ecx
|
|
||||||
jnz loop2
|
|
||||||
|
|
||||||
movq [eax], mm0
|
|
||||||
add ebx, 16
|
|
||||||
movq [eax + 8], mm1
|
|
||||||
add eax, 16
|
|
||||||
|
|
||||||
dec edx
|
|
||||||
jnz loop1
|
|
||||||
|
|
||||||
femms
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ALLOW_3DNOW
|
|
|
@ -0,0 +1,458 @@
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 2.1, February 1999
|
||||||
|
|
||||||
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||||
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
[This is the first released version of the Lesser GPL. It also counts
|
||||||
|
as the successor of the GNU Library Public License, version 2, hence
|
||||||
|
the version number 2.1.]
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
Licenses are intended to guarantee your freedom to share and change
|
||||||
|
free software--to make sure the software is free for all its users.
|
||||||
|
|
||||||
|
This license, the Lesser General Public License, applies to some
|
||||||
|
specially designated software packages--typically libraries--of the
|
||||||
|
Free Software Foundation and other authors who decide to use it. You
|
||||||
|
can use it too, but we suggest you first think carefully about whether
|
||||||
|
this license or the ordinary General Public License is the better
|
||||||
|
strategy to use in any particular case, based on the explanations below.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom of use,
|
||||||
|
not price. Our General Public Licenses are designed to make sure that
|
||||||
|
you have the freedom to distribute copies of free software (and charge
|
||||||
|
for this service if you wish); that you receive source code or can get
|
||||||
|
it if you want it; that you can change the software and use pieces of
|
||||||
|
it in new free programs; and that you are informed that you can do
|
||||||
|
these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
distributors to deny you these rights or to ask you to surrender these
|
||||||
|
rights. These restrictions translate to certain responsibilities for
|
||||||
|
you if you distribute copies of the library or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of the library, whether gratis
|
||||||
|
or for a fee, you must give the recipients all the rights that we gave
|
||||||
|
you. You must make sure that they, too, receive or can get the source
|
||||||
|
code. If you link other code with the library, you must provide
|
||||||
|
complete object files to the recipients, so that they can relink them
|
||||||
|
with the library after making changes to the library and recompiling
|
||||||
|
it. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
|
We protect your rights with a two-step method: (1) we copyright the
|
||||||
|
library, and (2) we offer you this license, which gives you legal
|
||||||
|
permission to copy, distribute and/or modify the library.
|
||||||
|
|
||||||
|
To protect each distributor, we want to make it very clear that
|
||||||
|
there is no warranty for the free library. Also, if the library is
|
||||||
|
modified by someone else and passed on, the recipients should know
|
||||||
|
that what they have is not the original version, so that the original
|
||||||
|
author's reputation will not be affected by problems that might be
|
||||||
|
introduced by others.
|
||||||
|
|
||||||
|
Finally, software patents pose a constant threat to the existence of
|
||||||
|
any free program. We wish to make sure that a company cannot
|
||||||
|
effectively restrict the users of a free program by obtaining a
|
||||||
|
restrictive license from a patent holder. Therefore, we insist that
|
||||||
|
any patent license obtained for a version of the library must be
|
||||||
|
consistent with the full freedom of use specified in this license.
|
||||||
|
|
||||||
|
Most GNU software, including some libraries, is covered by the
|
||||||
|
ordinary GNU General Public License. This license, the GNU Lesser
|
||||||
|
General Public License, applies to certain designated libraries, and
|
||||||
|
is quite different from the ordinary General Public License. We use
|
||||||
|
this license for certain libraries in order to permit linking those
|
||||||
|
libraries into non-free programs.
|
||||||
|
|
||||||
|
When a program is linked with a library, whether statically or using
|
||||||
|
a shared library, the combination of the two is legally speaking a
|
||||||
|
combined work, a derivative of the original library. The ordinary
|
||||||
|
General Public License therefore permits such linking only if the
|
||||||
|
entire combination fits its criteria of freedom. The Lesser General
|
||||||
|
Public License permits more lax criteria for linking other code with
|
||||||
|
the library.
|
||||||
|
|
||||||
|
We call this license the "Lesser" General Public License because it
|
||||||
|
does Less to protect the user's freedom than the ordinary General
|
||||||
|
Public License. It also provides other free software developers Less
|
||||||
|
of an advantage over competing non-free programs. These disadvantages
|
||||||
|
are the reason we use the ordinary General Public License for many
|
||||||
|
libraries. However, the Lesser license provides advantages in certain
|
||||||
|
special circumstances.
|
||||||
|
|
||||||
|
For example, on rare occasions, there may be a special need to
|
||||||
|
encourage the widest possible use of a certain library, so that it becomes
|
||||||
|
a de-facto standard. To achieve this, non-free programs must be
|
||||||
|
allowed to use the library. A more frequent case is that a free
|
||||||
|
library does the same job as widely used non-free libraries. In this
|
||||||
|
case, there is little to gain by limiting the free library to free
|
||||||
|
software only, so we use the Lesser General Public License.
|
||||||
|
|
||||||
|
In other cases, permission to use a particular library in non-free
|
||||||
|
programs enables a greater number of people to use a large body of
|
||||||
|
free software. For example, permission to use the GNU C Library in
|
||||||
|
non-free programs enables many more people to use the whole GNU
|
||||||
|
operating system, as well as its variant, the GNU/Linux operating
|
||||||
|
system.
|
||||||
|
|
||||||
|
Although the Lesser General Public License is Less protective of the
|
||||||
|
users' freedom, it does ensure that the user of a program that is
|
||||||
|
linked with the Library has the freedom and the wherewithal to run
|
||||||
|
that program using a modified version of the Library.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow. Pay close attention to the difference between a
|
||||||
|
"work based on the library" and a "work that uses the library". The
|
||||||
|
former contains code derived from the library, whereas the latter must
|
||||||
|
be combined with the library in order to run.
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License Agreement applies to any software library or other
|
||||||
|
program which contains a notice placed by the copyright holder or
|
||||||
|
other authoried party saying it may be distributed under the terms of
|
||||||
|
this Lesser General Public License (also called "this License").
|
||||||
|
Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
A "library" means a collection of software functions and/or data
|
||||||
|
prepared so as to be conveniently linked with application programs
|
||||||
|
(which use some of those functions and data) to form executables.
|
||||||
|
|
||||||
|
The "Library", below, refers to any such software library or work
|
||||||
|
which has been distributed under these terms. A "work based on the
|
||||||
|
Library" means either the Library or any derivative work under
|
||||||
|
copyright law: that is to say, a work containing the Library or a
|
||||||
|
portion of it, either verbatim or with modifications and/or translated
|
||||||
|
straightforwardly into another language. (Hereinafter, translation is
|
||||||
|
included without limitation in the term "modification".)
|
||||||
|
|
||||||
|
"Source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For a library, complete source code means
|
||||||
|
all the source code for all modules it contains, plus any associated
|
||||||
|
interface definition files, plus the scripts used to control compilation
|
||||||
|
and installation of the library.
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running a program using the Library is not restricted, and output from
|
||||||
|
such a program is covered only if its contents constitute a work based
|
||||||
|
on the Library (independent of the use of the Library in a tool for
|
||||||
|
writing it). Whether that is true depends on what the Library does
|
||||||
|
and what the program that uses the Library does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Library's
|
||||||
|
complete source code as you receive it, in any medium, provided that
|
||||||
|
you conspicuously and appropriately publish on each copy an
|
||||||
|
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||||
|
all the notices that refer to this License and to the absence of any
|
||||||
|
warranty; and distribute a copy of this License along with the
|
||||||
|
Library.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy,
|
||||||
|
and you may at your option offer warranty protection in exchange for a
|
||||||
|
fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Library or any portion
|
||||||
|
of it, thus forming a work based on the Library, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The modified work must itself be a software library.
|
||||||
|
|
||||||
|
b) You must cause the files modified to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
c) You must cause the whole of the work to be licensed at no
|
||||||
|
charge to all third parties under the terms of this License.
|
||||||
|
|
||||||
|
d) If a facility in the modified Library refers to a function or a
|
||||||
|
table of data to be supplied by an application program that uses
|
||||||
|
the facility, other than as an argument passed when the facility
|
||||||
|
is invoked, then you must make a good faith effort to ensure that,
|
||||||
|
in the event an application does not supply such function or
|
||||||
|
table, the facility still operates, and performs whatever part of
|
||||||
|
its purpose remains meaningful.
|
||||||
|
|
||||||
|
(For example, a function in a library to compute square roots has
|
||||||
|
a purpose that is entirely well-defined independent of the
|
||||||
|
application. Therefore, Subsection 2d requires that any
|
||||||
|
application-supplied function or table used by this function must
|
||||||
|
be optional: if the application does not supply it, the square
|
||||||
|
root function must still compute square roots.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Library,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Library, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote
|
||||||
|
it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Library.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Library
|
||||||
|
with the Library (or with a work based on the Library) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||||
|
License instead of this License to a given copy of the Library. To do
|
||||||
|
this, you must alter all the notices that refer to this License, so
|
||||||
|
that they refer to the ordinary GNU General Public License, version 2,
|
||||||
|
instead of to this License. (If a newer version than version 2 of the
|
||||||
|
ordinary GNU General Public License has appeared, then you can specify
|
||||||
|
that version instead if you wish.) Do not make any other change in
|
||||||
|
these notices.
|
||||||
|
|
||||||
|
Once this change is made in a given copy, it is irreversible for
|
||||||
|
that copy, so the ordinary GNU General Public License applies to all
|
||||||
|
subsequent copies and derivative works made from that copy.
|
||||||
|
|
||||||
|
This option is useful when you wish to copy part of the code of
|
||||||
|
the Library into a program that is not a library.
|
||||||
|
|
||||||
|
4. You may copy and distribute the Library (or a portion or
|
||||||
|
derivative of it, under Section 2) in object code or executable form
|
||||||
|
under the terms of Sections 1 and 2 above provided that you accompany
|
||||||
|
it with the complete corresponding machine-readable source code, which
|
||||||
|
must be distributed under the terms of Sections 1 and 2 above on a
|
||||||
|
medium customarily used for software interchange.
|
||||||
|
|
||||||
|
If distribution of object code is made by offering access to copy
|
||||||
|
from a designated place, then offering equivalent access to copy the
|
||||||
|
source code from the same place satisfies the requirement to
|
||||||
|
distribute the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
5. A program that contains no derivative of any portion of the
|
||||||
|
Library, but is designed to work with the Library by being compiled or
|
||||||
|
linked with it, is called a "work that uses the Library". Such a
|
||||||
|
work, in isolation, is not a derivative work of the Library, and
|
||||||
|
therefore falls outside the scope of this License.
|
||||||
|
|
||||||
|
However, linking a "work that uses the Library" with the Library
|
||||||
|
creates an executable that is a derivative of the Library (because it
|
||||||
|
contains portions of the Library), rather than a "work that uses the
|
||||||
|
library". The executable is therefore covered by this License.
|
||||||
|
Section 6 states terms for distribution of such executables.
|
||||||
|
|
||||||
|
When a "work that uses the Library" uses material from a header file
|
||||||
|
that is part of the Library, the object code for the work may be a
|
||||||
|
derivative work of the Library even though the source code is not.
|
||||||
|
Whether this is true is especially significant if the work can be
|
||||||
|
linked without the Library, or if the work is itself a library. The
|
||||||
|
threshold for this to be true is not precisely defined by law.
|
||||||
|
|
||||||
|
If such an object file uses only numerical parameters, data
|
||||||
|
structure layouts and accessors, and small macros and small inline
|
||||||
|
functions (ten lines or less in length), then the use of the object
|
||||||
|
file is unrestricted, regardless of whether it is legally a derivative
|
||||||
|
work. (Executables containing this object code plus portions of the
|
||||||
|
Library will still fall under Section 6.)
|
||||||
|
|
||||||
|
Otherwise, if the work is a derivative of the Library, you may
|
||||||
|
distribute the object code for the work under the terms of Section 6.
|
||||||
|
Any executables containing that work also fall under Section 6,
|
||||||
|
whether or not they are linked directly with the Library itself.
|
||||||
|
|
||||||
|
6. As an exception to the Sections above, you may also combine or
|
||||||
|
link a "work that uses the Library" with the Library to produce a
|
||||||
|
work containing portions of the Library, and distribute that work
|
||||||
|
under terms of your choice, provided that the terms permit
|
||||||
|
modification of the work for the customer's own use and reverse
|
||||||
|
engineering for debugging such modifications.
|
||||||
|
|
||||||
|
You must give prominent notice with each copy of the work that the
|
||||||
|
Library is used in it and that the Library and its use are covered by
|
||||||
|
this License. You must supply a copy of this License. If the work
|
||||||
|
during execution displays copyright notices, you must include the
|
||||||
|
copyright notice for the Library among them, as well as a reference
|
||||||
|
directing the user to the copy of this License. Also, you must do one
|
||||||
|
of these things:
|
||||||
|
|
||||||
|
a) Accompany the work with the complete corresponding
|
||||||
|
machine-readable source code for the Library including whatever
|
||||||
|
changes were used in the work (which must be distributed under
|
||||||
|
Sections 1 and 2 above); and, if the work is an executable linked
|
||||||
|
with the Library, with the complete machine-readable "work that
|
||||||
|
uses the Library", as object code and/or source code, so that the
|
||||||
|
user can modify the Library and then relink to produce a modified
|
||||||
|
executable containing the modified Library. (It is understood
|
||||||
|
that the user who changes the contents of definitions files in the
|
||||||
|
Library will not necessarily be able to recompile the application
|
||||||
|
to use the modified definitions.)
|
||||||
|
|
||||||
|
b) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (1) uses at run time a
|
||||||
|
copy of the library already present on the user's computer system,
|
||||||
|
rather than copying library functions into the executable, and (2)
|
||||||
|
will operate properly with a modified version of the library, if
|
||||||
|
the user installs one, as long as the modified version is
|
||||||
|
interface-compatible with the version that the work was made with.
|
||||||
|
|
||||||
|
c) Accompany the work with a written offer, valid for at
|
||||||
|
least three years, to give the same user the materials
|
||||||
|
specified in Subsection 6a, above, for a charge no more
|
||||||
|
than the cost of performing this distribution.
|
||||||
|
|
||||||
|
d) If distribution of the work is made by offering access to copy
|
||||||
|
from a designated place, offer equivalent access to copy the above
|
||||||
|
specified materials from the same place.
|
||||||
|
|
||||||
|
e) Verify that the user has already received a copy of these
|
||||||
|
materials or that you have already sent this user a copy.
|
||||||
|
|
||||||
|
For an executable, the required form of the "work that uses the
|
||||||
|
Library" must include any data and utility programs needed for
|
||||||
|
reproducing the executable from it. However, as a special exception,
|
||||||
|
the materials to be distributed need not include anything that is
|
||||||
|
normally distributed (in either source or binary form) with the major
|
||||||
|
components (compiler, kernel, and so on) of the operating system on
|
||||||
|
which the executable runs, unless that component itself accompanies
|
||||||
|
the executable.
|
||||||
|
|
||||||
|
It may happen that this requirement contradicts the license
|
||||||
|
restrictions of other proprietary libraries that do not normally
|
||||||
|
accompany the operating system. Such a contradiction means you cannot
|
||||||
|
use both them and the Library together in an executable that you
|
||||||
|
distribute.
|
||||||
|
|
||||||
|
7. You may place library facilities that are a work based on the
|
||||||
|
Library side-by-side in a single library together with other library
|
||||||
|
facilities not covered by this License, and distribute such a combined
|
||||||
|
library, provided that the separate distribution of the work based on
|
||||||
|
the Library and of the other library facilities is otherwise
|
||||||
|
permitted, and provided that you do these two things:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work
|
||||||
|
based on the Library, uncombined with any other library
|
||||||
|
facilities. This must be distributed under the terms of the
|
||||||
|
Sections above.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library of the fact
|
||||||
|
that part of it is a work based on the Library, and explaining
|
||||||
|
where to find the accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
8. You may not copy, modify, sublicense, link with, or distribute
|
||||||
|
the Library except as expressly provided under this License. Any
|
||||||
|
attempt otherwise to copy, modify, sublicense, link with, or
|
||||||
|
distribute the Library is void, and will automatically terminate your
|
||||||
|
rights under this License. However, parties who have received copies,
|
||||||
|
or rights, from you under this License will not have their licenses
|
||||||
|
terminated so long as such parties remain in full compliance.
|
||||||
|
|
||||||
|
9. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Library or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Library (or any work based on the
|
||||||
|
Library), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Library or works based on it.
|
||||||
|
|
||||||
|
10. Each time you redistribute the Library (or any work based on the
|
||||||
|
Library), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute, link with or modify the Library
|
||||||
|
subject to these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties with
|
||||||
|
this License.
|
||||||
|
|
||||||
|
11. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Library at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Library by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Library.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under any
|
||||||
|
particular circumstance, the balance of the section is intended to apply,
|
||||||
|
and the section as a whole is intended to apply in other circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
12. If the distribution and/or use of the Library is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Library under this License may add
|
||||||
|
an explicit geographical distribution limitation excluding those countries,
|
||||||
|
so that distribution is permitted only in or among countries not thus
|
||||||
|
excluded. In such case, this License incorporates the limitation as if
|
||||||
|
written in the body of this License.
|
||||||
|
|
||||||
|
13. The Free Software Foundation may publish revised and/or new
|
||||||
|
versions of the Lesser General Public License from time to time.
|
||||||
|
Such new versions will be similar in spirit to the present version,
|
||||||
|
but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Library
|
||||||
|
specifies a version number of this License which applies to it and
|
||||||
|
"any later version", you have the option of following the terms and
|
||||||
|
conditions either of that version or of any later version published by
|
||||||
|
the Free Software Foundation. If the Library does not specify a
|
||||||
|
license version number, you may choose any version ever published by
|
||||||
|
the Free Software Foundation.
|
||||||
|
|
||||||
|
14. If you wish to incorporate parts of the Library into other free
|
||||||
|
programs whose distribution conditions are incompatible with these,
|
||||||
|
write to the author to ask for permission. For software which is
|
||||||
|
copyrighted by the Free Software Foundation, write to the Free
|
||||||
|
Software Foundation; we sometimes make exceptions for this. Our
|
||||||
|
decision will be guided by the two goals of preserving the free status
|
||||||
|
of all derivatives of our free software and of promoting the sharing
|
||||||
|
and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||||
|
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||||
|
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||||
|
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||||
|
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||||
|
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||||
|
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||||
|
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||||
|
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||||
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||||
|
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||||
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||||
|
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||||
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||||
|
DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
|
@ -1,71 +0,0 @@
|
||||||
## Process this file with automake to create Makefile.in
|
|
||||||
##
|
|
||||||
## $Id: Makefile.am 138 2012-04-01 20:00:09Z oparviai $
|
|
||||||
##
|
|
||||||
## This file is part of SoundTouch, an audio processing library for pitch/time adjustments
|
|
||||||
##
|
|
||||||
## SoundTouch 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 of the License, or (at your option) any later
|
|
||||||
## version.
|
|
||||||
##
|
|
||||||
## SoundTouch 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
|
|
||||||
|
|
||||||
|
|
||||||
include $(top_srcdir)/config/am_include.mk
|
|
||||||
|
|
||||||
|
|
||||||
# set to something if you want other stuff to be included in the distribution tarball
|
|
||||||
EXTRA_DIST=SoundTouch.dsp SoundTouch.dsw SoundTouch.sln SoundTouch.vcproj
|
|
||||||
|
|
||||||
noinst_HEADERS=AAFilter.h cpu_detect.h cpu_detect_x86.cpp FIRFilter.h RateTransposer.h TDStretch.h PeakFinder.h
|
|
||||||
|
|
||||||
lib_LTLIBRARIES=libSoundTouch.la
|
|
||||||
#
|
|
||||||
libSoundTouch_la_SOURCES=AAFilter.cpp FIRFilter.cpp FIFOSampleBuffer.cpp RateTransposer.cpp SoundTouch.cpp TDStretch.cpp cpu_detect_x86.cpp BPMDetect.cpp PeakFinder.cpp
|
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags
|
|
||||||
AM_CXXFLAGS=-O3 -fcheck-new -I../../include
|
|
||||||
|
|
||||||
# Compile the files that need MMX and SSE individually.
|
|
||||||
libSoundTouch_la_LIBADD=libSoundTouchMMX.la libSoundTouchSSE.la
|
|
||||||
noinst_LTLIBRARIES=libSoundTouchMMX.la libSoundTouchSSE.la
|
|
||||||
libSoundTouchMMX_la_SOURCES=mmx_optimized.cpp
|
|
||||||
libSoundTouchSSE_la_SOURCES=sse_optimized.cpp
|
|
||||||
|
|
||||||
# We enable optimizations by default.
|
|
||||||
# If MMX is supported compile with -mmmx.
|
|
||||||
# Do not assume -msse is also supported.
|
|
||||||
if HAVE_MMX
|
|
||||||
libSoundTouchMMX_la_CXXFLAGS = -mmmx $(AM_CXXFLAGS)
|
|
||||||
else
|
|
||||||
libSoundTouchMMX_la_CXXFLAGS = $(AM_CXXFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# We enable optimizations by default.
|
|
||||||
# If SSE is supported compile with -msse.
|
|
||||||
if HAVE_SSE
|
|
||||||
libSoundTouchSSE_la_CXXFLAGS = -msse $(AM_CXXFLAGS)
|
|
||||||
else
|
|
||||||
libSoundTouchSSE_la_CXXFLAGS = $(AM_CXXFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Let the user disable optimizations if he wishes to.
|
|
||||||
if !X86_OPTIMIZATIONS
|
|
||||||
libSoundTouchMMX_la_CXXFLAGS = $(AM_CXXFLAGS)
|
|
||||||
libSoundTouchSSE_la_CXXFLAGS = $(AM_CXXFLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# other linking flags to add
|
|
||||||
# noinst_LTLIBRARIES = libSoundTouchOpt.la
|
|
||||||
# libSoundTouch_la_LIBADD = libSoundTouchOpt.la
|
|
||||||
# libSoundTouchOpt_la_SOURCES = mmx_optimized.cpp sse_optimized.cpp
|
|
||||||
# libSoundTouchOpt_la_CXXFLAGS = -O3 -msse -fcheck-new -I../../include
|
|
|
@ -8,15 +8,13 @@
|
||||||
<meta name="author" content="Olli Parviainen">
|
<meta name="author" content="Olli Parviainen">
|
||||||
<meta name="description"
|
<meta name="description"
|
||||||
content="Readme file for SoundTouch audio processing library">
|
content="Readme file for SoundTouch audio processing library">
|
||||||
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
|
|
||||||
<meta name="ProgId" content="FrontPage.Editor.Document">
|
|
||||||
<style> <!-- .normal { font-family: Arial }
|
<style> <!-- .normal { font-family: Arial }
|
||||||
--></style>
|
--></style>
|
||||||
</head>
|
</head>
|
||||||
<body class="normal">
|
<body class="normal">
|
||||||
<hr>
|
<hr>
|
||||||
<h1>SoundTouch audio processing library v1.7.1</h1>
|
<h1>SoundTouch audio processing library v1.9</h1>
|
||||||
<p class="normal">SoundTouch library Copyright © Olli Parviainen 2001-2012 </p>
|
<p class="normal">SoundTouch library Copyright © Olli Parviainen 2001-2015</p>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>1. Introduction </h2>
|
<h2>1. Introduction </h2>
|
||||||
<p>SoundTouch is an open-source audio processing library that allows
|
<p>SoundTouch is an open-source audio processing library that allows
|
||||||
|
@ -24,35 +22,31 @@ changing the sound tempo, pitch and playback rate parameters
|
||||||
independently from each other, i.e.:</p>
|
independently from each other, i.e.:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Sound tempo can be increased or decreased while maintaining the
|
<li> Sound tempo can be increased or decreased while maintaining the
|
||||||
original pitch </li>
|
original pitch</li>
|
||||||
<li> Sound pitch can be increased or decreased while maintaining the
|
<li> Sound pitch can be increased or decreased while maintaining the
|
||||||
original tempo </li>
|
original tempo</li>
|
||||||
<li> Change playback rate that affects both tempo and pitch at the
|
<li> Change playback rate that affects both tempo and pitch at the
|
||||||
same time </li>
|
same time</li>
|
||||||
<li> Choose any combination of tempo/pitch/rate</li>
|
<li> Choose any combination of tempo/pitch/rate</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>1.1 Contact information </h3>
|
<h3>1.1 Contact information </h3>
|
||||||
<p>Author email: oparviai 'at' iki.fi </p>
|
<p>Author email: oparviai 'at' iki.fi </p>
|
||||||
<p>SoundTouch WWW page: <a href="http://www.surina.net/soundtouch">http://www.surina.net/soundtouch</a></p>
|
<p>SoundTouch WWW page: <a href="http://soundtouch.surina.net">http://soundtouch.surina.net</a></p>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>2. Compiling SoundTouch</h2>
|
<h2>2. Compiling SoundTouch</h2>
|
||||||
<p>Before compiling, notice that you can choose the sample data format
|
<p>Before compiling, notice that you can choose the sample data format if it's
|
||||||
if it's desirable to use floating point sample data instead of 16bit
|
desirable to use floating point sample data instead of 16bit integers. See
|
||||||
integers. See section "sample data format" for more information.</p>
|
section "sample data format" for more information.</p>
|
||||||
|
<p>Also notice that SoundTouch can use OpenMP instructions for parallel
|
||||||
|
computation to accelerate the runtime processing speed in multi-core systems,
|
||||||
|
however, these improvements need to be separately enabled before compiling. See
|
||||||
|
OpenMP notes in Chapter 3 below.</p>
|
||||||
<h3>2.1. Building in Microsoft Windows</h3>
|
<h3>2.1. Building in Microsoft Windows</h3>
|
||||||
<p>Project files for Microsoft Visual C++ 6.0 and Visual C++ .NET are
|
<p>Project files for Microsoft Visual C++ are supplied with the source
|
||||||
supplied with the source code package.<br>
|
code package. Go to Microsoft WWW page to download
|
||||||
|
<a href="http://www.visualstudio.com/en-US/products/visual-studio-express-vs">
|
||||||
|
Microsoft Visual Studio Express version for free</a>.
|
||||||
</p>
|
</p>
|
||||||
<p> Please notice that SoundTouch library uses processor-specific
|
|
||||||
optimizations for Pentium III and AMD processors. Visual Studio .NET
|
|
||||||
and later versions supports the required instructions by default, but
|
|
||||||
Visual Studio 6.0 requires a processor pack upgrade to be installed in
|
|
||||||
order to support these optimizations. The processor pack upgrade can be
|
|
||||||
downloaded from Microsoft site at this URL:</p>
|
|
||||||
<p><a href="http://msdn.microsoft.com/en-us/vstudio/aa718349.aspx">http://msdn.microsoft.com/en-us/vstudio/aa718349.aspx</a></p>
|
|
||||||
<p>If the above URL is unavailable or removed, go to <a
|
|
||||||
href="http://msdn.microsoft.com/"> http://msdn.microsoft.com</a> and
|
|
||||||
perform a search with keywords "processor pack". </p>
|
|
||||||
<p>To build the binaries with Visual C++ compiler, either run
|
<p>To build the binaries with Visual C++ compiler, either run
|
||||||
"make-win.bat" script, or open the appropriate project files in source
|
"make-win.bat" script, or open the appropriate project files in source
|
||||||
code directories with Visual Studio. The final executable will appear
|
code directories with Visual Studio. The final executable will appear
|
||||||
|
@ -61,6 +55,22 @@ instead of the make-win.bat script, directories bin and lib may need to
|
||||||
be created manually to the SoundTouch package root for the final
|
be created manually to the SoundTouch package root for the final
|
||||||
executables. The make-win.bat script creates these directories
|
executables. The make-win.bat script creates these directories
|
||||||
automatically. </p>
|
automatically. </p>
|
||||||
|
<p><strong>OpenMP NOTE</strong>: If activating the OpenMP parallel computing in
|
||||||
|
the compilation, the target program will require additional vcomp dll library to
|
||||||
|
properly run. In Visual C++ 9.0 these libraries can be found in the following
|
||||||
|
folders.</p>
|
||||||
|
<ul>
|
||||||
|
<li>x86 32bit: C:\Program Files (x86)\Microsoft Visual Studio
|
||||||
|
9.0\VC\redist\x86\Microsoft.VC90.OPENMP\vcomp90.dll</li>
|
||||||
|
<li>x64 64bit: C:\Program Files (x86)\Microsoft Visual Studio
|
||||||
|
9.0\VC\redist\amd64\Microsoft.VC90.OPENMP\vcomp90.dll</li>
|
||||||
|
</ul>
|
||||||
|
<p>In Visual Studio 2008, a SP1 version may be required for these libraries. In
|
||||||
|
other VC++ versions the required library will be expectedly found in similar
|
||||||
|
"redist" location.</p>
|
||||||
|
<p>Notice that as minor demonstration of a "dll hell" phenomenon both the 32-bit
|
||||||
|
and 64-bit version of vcomp90.dll have the same filename but different contents,
|
||||||
|
thus choose the proper version to allow the program start.</p>
|
||||||
<h3>2.2. Building in Gnu platforms</h3>
|
<h3>2.2. Building in Gnu platforms</h3>
|
||||||
<p>The SoundTouch library compiles in practically any platform
|
<p>The SoundTouch library compiles in practically any platform
|
||||||
supporting GNU compiler (GCC) tools. SoundTouch requires GCC version 4.3 or later.</p>
|
supporting GNU compiler (GCC) tools. SoundTouch requires GCC version 4.3 or later.</p>
|
||||||
|
@ -92,7 +102,9 @@ Notice that "configure" file is not available before running the
|
||||||
<pre>make -</pre>
|
<pre>make -</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<p>Builds the SoundTouch library & SoundStretch utility.</p>
|
<p>Builds the SoundTouch library & SoundStretch utility. You can
|
||||||
|
optionally add "-j" switch after "make" to speed up the compilation in
|
||||||
|
multi-core systems.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr valign="top">
|
<tr valign="top">
|
||||||
|
@ -133,7 +145,7 @@ directly and remove the following definition:<blockquote>
|
||||||
<pre>#define SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS 1</pre>
|
<pre>#define SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS 1</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<h4><b>2.2.3 Compiling Shared Library / DLL version</b></h4>
|
<h4><b>2.2.3 Compiling Shared Library / DLL version in Cygwin</b></h4>
|
||||||
<p>
|
<p>
|
||||||
The GNU compilation does not automatically create a shared-library version of
|
The GNU compilation does not automatically create a shared-library version of
|
||||||
SoundTouch (.so or .dll). If such is desired, then you can create it as follows
|
SoundTouch (.so or .dll). If such is desired, then you can create it as follows
|
||||||
|
@ -147,7 +159,15 @@ sstrip SoundTouch.dll</pre>
|
||||||
<h3>2.1. Building in Android</h3>
|
<h3>2.1. Building in Android</h3>
|
||||||
<p>Android compilation instructions are within the
|
<p>Android compilation instructions are within the
|
||||||
source code package, see file "<b>source/Android-lib/README-SoundTouch-Android.html</b>"
|
source code package, see file "<b>source/Android-lib/README-SoundTouch-Android.html</b>"
|
||||||
in the package.</p>
|
in the source code package. </p>
|
||||||
|
<p>The Android compilation automatically builds separate .so library binaries
|
||||||
|
for ARM, X86 and MIPS processor architectures. For optimal device support,
|
||||||
|
include all these .so library binaries into the Android .apk application
|
||||||
|
package, so the target Android device can automatically choose the proper
|
||||||
|
library binary version to use.</p>
|
||||||
|
<p>The <strong>source/Android-lib</strong> folder includes also an Android
|
||||||
|
example application that processes WAV audio files using SoundTouch library in
|
||||||
|
Android devices.</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<h2>3. About implementation & Usage tips <h3>3.1. Supported sample data formats</h3>
|
<h2>3. About implementation & Usage tips <h3>3.1. Supported sample data formats</h3>
|
||||||
|
@ -157,7 +177,7 @@ and 32bit floating point values, the default is 32bit floating point. </p>
|
||||||
"STTypes.h" by choosing one of the following defines:</p>
|
"STTypes.h" by choosing one of the following defines:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <span style="font-weight: bold;">#define
|
<li> <span style="font-weight: bold;">#define
|
||||||
SOUNDTOUCH_INTEGER_SAMPLES</span> for 16bit signed integer </li>
|
SOUNDTOUCH_INTEGER_SAMPLES</span> for 16bit signed integer</li>
|
||||||
<li> <span style="font-weight: bold;">#define </span><span
|
<li> <span style="font-weight: bold;">#define </span><span
|
||||||
style="font-weight: bold;">SOUNDTOUCH_</span><span
|
style="font-weight: bold;">SOUNDTOUCH_</span><span
|
||||||
style="font-weight: bold;">FLOAT_SAMPLES</span> for 32bit floating
|
style="font-weight: bold;">FLOAT_SAMPLES</span> for 32bit floating
|
||||||
|
@ -183,7 +203,7 @@ the channels, which consequently would ruin the stereo effect.</p>
|
||||||
<li> Input/output processing latency for the SoundTouch processor is
|
<li> Input/output processing latency for the SoundTouch processor is
|
||||||
around 100 ms. This is when time-stretching is used. If the rate
|
around 100 ms. This is when time-stretching is used. If the rate
|
||||||
transposing effect alone is used, the latency requirement is much
|
transposing effect alone is used, the latency requirement is much
|
||||||
shorter, see section 'About algorithms'. </li>
|
shorter, see section 'About algorithms'.</li>
|
||||||
<li> Processing CD-quality sound (16bit stereo sound with 44100H
|
<li> Processing CD-quality sound (16bit stereo sound with 44100H
|
||||||
sample rate) in real-time or faster is possible starting from
|
sample rate) in real-time or faster is possible starting from
|
||||||
processors equivalent to Intel Pentium 133Mh or better, if using the
|
processors equivalent to Intel Pentium 133Mh or better, if using the
|
||||||
|
@ -217,9 +237,9 @@ is around 100 ms.</p>
|
||||||
to produce the tempo, pitch and rate controls:</p>
|
to produce the tempo, pitch and rate controls:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> <strong>'Tempo'</strong> control is implemented purely by
|
<li> <strong>'Tempo'</strong> control is implemented purely by
|
||||||
time-stretching. </li>
|
time-stretching.</li>
|
||||||
<li> <strong>'Rate</strong>' control is implemented purely by sample
|
<li> <strong>'Rate</strong>' control is implemented purely by sample
|
||||||
rate transposing. </li>
|
rate transposing.</li>
|
||||||
<li> <strong>'Pitch</strong>' control is implemented as a
|
<li> <strong>'Pitch</strong>' control is implemented as a
|
||||||
combination of time-stretching and sample rate transposing. For
|
combination of time-stretching and sample rate transposing. For
|
||||||
example, to increase pitch the audio stream is first time-stretched to
|
example, to increase pitch the audio stream is first time-stretched to
|
||||||
|
@ -343,28 +363,55 @@ function with parameter id of SETTING_USE_QUICKSEEK and value
|
||||||
<p>setSetting(SETTING_USE_QUICKSEEK, 1);</p>
|
<p>setSetting(SETTING_USE_QUICKSEEK, 1);</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p><strong>CPU-specific optimizations:</strong></p>
|
<p><strong>CPU-specific optimizations:</strong></p>
|
||||||
|
<p>Intel x86 specific SIMD optimizations are implemented using compiler
|
||||||
|
intrinsics, providing about a 3x processing speedup for x86 compatible
|
||||||
|
processors vs. non-SIMD implementation:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Intel MMX optimized routines are used with compatible CPUs when
|
<li> Intel MMX optimized routines are used with x86 CPUs when 16bit integer
|
||||||
16bit integer sample type is used. MMX optimizations are available both
|
sample type is used</li>
|
||||||
in Win32 and Gnu/x86 platforms. Compatible processors are Intel
|
<li> Intel SSE optimized routines are used with x86 CPUs when 32bit floating
|
||||||
PentiumMMX and later; AMD K6-2, Athlon and later. </li>
|
point sample type is used</li>
|
||||||
<li> Intel SSE optimized routines are used with compatible CPUs when
|
</ul>
|
||||||
floating point sample type is used. SSE optimizations are currently
|
<h3>3.5 OpenMP parallel computation</h3>
|
||||||
implemented for Win32 platform only. Processors compatible with SSE
|
<p>SoundTouch 1.9 onwards support running the algorithms parallel in several CPU
|
||||||
extension are Intel processors starting from Pentium-III, and AMD
|
cores. Based on benchmark the experienced multi-core processing speed-up gain
|
||||||
processors starting from Athlon XP. </li>
|
ranges between +30% (on a high-spec dual-core x86 Windows PC) to 215% (on a moderately low-spec
|
||||||
<li> AMD 3DNow! optimized routines are used with compatible CPUs when
|
quad-core ARM of Raspberry Pi2).</p>
|
||||||
floating point sample type is used, but SSE extension isn't supported .
|
<p>The parallel computing support is implemented using OpenMP spec 3.0
|
||||||
3DNow! optimizations are currently implemented for Win32 platform only.
|
instructions. These instructions are supported by Visual C++ 2008 and later, and
|
||||||
These optimizations are used in AMD K6-2 and Athlon (classic) CPU's;
|
GCC v4.2 and later. Compilers that do not supporting OpenMP will ignore these
|
||||||
better performing SSE routines are used with AMD processor starting
|
optimizations and routines will still work properly. Possible warnings about
|
||||||
from Athlon XP. </li>
|
unknown #pragmas are related to OpenMP support and can be safely ignored.</p>
|
||||||
|
<p>The OpenMP improvements are disabled by default, and need to be enabled by
|
||||||
|
developer during compile-time. Reason for this is that parallel processing adds
|
||||||
|
moderate runtime overhead in managing the multi-threading, so it may not be
|
||||||
|
necessary nor desirable in all applications. For example real-time processing
|
||||||
|
that is not constrained by CPU power will not benefit of speed-up provided by
|
||||||
|
the parallel processing, in the contrary it may increase power consumption due
|
||||||
|
to the increased overhead.</p>
|
||||||
|
<p>However, applications that run on low-spec multi-core CPUs and may otherwise
|
||||||
|
have possibly constrained performance will benefit of the OpenMP improvements.
|
||||||
|
This include for example multi-core embedded devices.</p>
|
||||||
|
<p>OpenMP parallel computation can be enabled before compiling SoundTouch
|
||||||
|
library as follows:</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Visual Studio</strong>: Open properties for the <strong>SoundTouch
|
||||||
|
</strong>sub-project, browse to <strong>C/C++</strong> and <strong>Language
|
||||||
|
</strong>settings. Set
|
||||||
|
there "<strong>OpenMP support</strong>" to "<strong>Yes</strong>". Alternatively add
|
||||||
|
<strong>/openmp</strong> switch to command-line
|
||||||
|
parameters</li>
|
||||||
|
<li><strong>GNU</strong>: Run the configure script with "<strong>./configure
|
||||||
|
--enable-openmp</strong>" switch, then run make as usually</li>
|
||||||
|
<li><strong>Android</strong>: Add "<strong>-fopenmp</strong>" switches to compiler & linker
|
||||||
|
options, see README-SoundTouch-Android.html in the source code package for
|
||||||
|
more detailed instructions.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<h2><a name="SoundStretch"></a>4. SoundStretch audio processing utility
|
<h2><a name="SoundStretch"></a>4. SoundStretch audio processing utility
|
||||||
</h2>
|
</h2>
|
||||||
<p>SoundStretch audio processing utility<br>
|
<p>SoundStretch audio processing utility<br>
|
||||||
Copyright (c) Olli Parviainen 2002-2012</p>
|
Copyright (c) Olli Parviainen 2002-2015</p>
|
||||||
<p>SoundStretch is a simple command-line application that can change
|
<p>SoundStretch is a simple command-line application that can change
|
||||||
tempo, pitch and playback rates of WAV sound files. This program is
|
tempo, pitch and playback rates of WAV sound files. This program is
|
||||||
intended primarily to demonstrate how the "SoundTouch" library can be
|
intended primarily to demonstrate how the "SoundTouch" library can be
|
||||||
|
@ -464,15 +511,15 @@ transposing. Gains speed but loses sound quality. </td>
|
||||||
<li> To use standard input/output pipes for processing, give "stdin"
|
<li> To use standard input/output pipes for processing, give "stdin"
|
||||||
and "stdout" as input/output filenames correspondingly. The standard
|
and "stdout" as input/output filenames correspondingly. The standard
|
||||||
input/output pipes will still carry the audio data in .wav audio file
|
input/output pipes will still carry the audio data in .wav audio file
|
||||||
format. </li>
|
format.</li>
|
||||||
<li> The numerical switches allow both integer (e.g. "-tempo=123")
|
<li> The numerical switches allow both integer (e.g. "-tempo=123")
|
||||||
and decimal (e.g. "-tempo=123.45") numbers. </li>
|
and decimal (e.g. "-tempo=123.45") numbers.</li>
|
||||||
<li> The "-naa" and/or "-quick" switches can be used to reduce CPU
|
<li> The "-naa" and/or "-quick" switches can be used to reduce CPU
|
||||||
usage while compromising some sound quality </li>
|
usage while compromising some sound quality</li>
|
||||||
<li> The BPM detection algorithm works by detecting repeating bass or
|
<li> The BPM detection algorithm works by detecting repeating bass or
|
||||||
drum patterns at low frequencies of <250Hz. A lower-than-expected
|
drum patterns at low frequencies of <250Hz. A lower-than-expected
|
||||||
BPM figure may be reported for music with uneven or complex bass
|
BPM figure may be reported for music with uneven or complex bass
|
||||||
patterns. </li>
|
patterns.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>4.2. SoundStretch usage examples </h3>
|
<h3>4.2. SoundStretch usage examples </h3>
|
||||||
<p><strong>Example 1</strong></p>
|
<p><strong>Example 1</strong></p>
|
||||||
|
@ -510,9 +557,42 @@ and estimates the BPM rate:</p>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>soundstretch stdin -bpm</pre>
|
<pre>soundstretch stdin -bpm</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
<p><strong>Example 6</strong></p>
|
||||||
|
<p>The following command tunes song from original 440Hz tuning to 432Hz tuning:
|
||||||
|
this corresponds to lowering the pitch by -0.318 semitones:</p>
|
||||||
|
<blockquote>
|
||||||
|
<pre>soundstretch original.wav output.wav -pitch=-0.318</pre>
|
||||||
|
</blockquote>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>5. Change History</h2>
|
<h2>5. Change History</h2>
|
||||||
<h3>5.1. SoundTouch library Change History </h3>
|
<h3>5.1. SoundTouch library Change History </h3>
|
||||||
|
<p><b>1.9:</b></p>
|
||||||
|
<ul>
|
||||||
|
<li>Added support for parallel computation support via OpenMP primitives for better performance in multicore systems.
|
||||||
|
Benchmarks show that achieved parallel processing speedup improvement
|
||||||
|
typically range from +30% (x86 dual-core) to +180% (ARM quad-core). The
|
||||||
|
OpenMP optimizations are disabled by default, see OpenMP notes above in this
|
||||||
|
readme file how to enabled these optimizations.</li>
|
||||||
|
<li>Android: Added support for Android devices featuring X86 and MIPS CPUs,
|
||||||
|
in addition to ARM CPUs.</li>
|
||||||
|
<li>Android: More versatile Android example application that processes WAV
|
||||||
|
audio files with SoundTouch library</li>
|
||||||
|
<li>Replaced Windows-like 'BOOL' types with native 'bool'</li>
|
||||||
|
<li>Changed documentation token to "dist_doc_DATA" in Makefile.am file</li>
|
||||||
|
<li>Miscellaneous small fixes and improvements</li>
|
||||||
|
</ul>
|
||||||
|
<p><b>1.8.0:</b></p>
|
||||||
|
<ul>
|
||||||
|
<li>Added support for multi-channel audio processing</li>
|
||||||
|
<li>Added support for <b>cubic</b> and <b>shannon</b> interpolation for rate and pitch shift effects besides
|
||||||
|
the original <b>linear</b> interpolation, to reduce aliasing at high frequencies due to interpolation.
|
||||||
|
Cubic interpolation is used as default for floating point processing, and linear interpolation for integer
|
||||||
|
processing.</li>
|
||||||
|
<li>Fixed bug in anti-alias filtering that limited stop-band attenuation to -10 dB instead of <-50dB, and
|
||||||
|
increased filter length from 32 to 64 taps to further reduce aliasing due to frequency folding.</li>
|
||||||
|
<li>Performance improvements in cross-correlation algorithm</li>
|
||||||
|
<li>Other bug and compatibility fixes</li>
|
||||||
|
</ul>
|
||||||
<p><b>1.7.1:</b></p>
|
<p><b>1.7.1:</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Added files for Android compilation
|
<li>Added files for Android compilation
|
||||||
|
@ -532,7 +612,7 @@ and estimates the BPM rate:</p>
|
||||||
<p><b>1.6.0:</b></p>
|
<p><b>1.6.0:</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Added automatic cutoff threshold adaptation to beat detection
|
<li> Added automatic cutoff threshold adaptation to beat detection
|
||||||
routine to better adapt BPM calculation to different types of music </li>
|
routine to better adapt BPM calculation to different types of music</li>
|
||||||
<li> Retired 3DNow! optimization support as 3DNow! is nowadays
|
<li> Retired 3DNow! optimization support as 3DNow! is nowadays
|
||||||
obsoleted and assembler code is nuisance to maintain</li>
|
obsoleted and assembler code is nuisance to maintain</li>
|
||||||
<li>Retired "configure" file from source code package due to
|
<li>Retired "configure" file from source code package due to
|
||||||
|
@ -552,19 +632,19 @@ sample batch sizes</li>
|
||||||
<p><strong>1.5.0:</strong></p>
|
<p><strong>1.5.0:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Added normalization to correlation calculation and improvement
|
<li> Added normalization to correlation calculation and improvement
|
||||||
automatic seek/sequence parameter calculation to improve sound quality </li>
|
automatic seek/sequence parameter calculation to improve sound quality</li>
|
||||||
<li> Bugfixes:
|
<li> Bugfixes:
|
||||||
<ul>
|
<ul>
|
||||||
<li> Fixed negative array indexing in quick seek algorithm </li>
|
<li> Fixed negative array indexing in quick seek algorithm</li>
|
||||||
<li> FIR autoalias filter running too far in processing buffer </li>
|
<li> FIR autoalias filter running too far in processing buffer</li>
|
||||||
<li> Check against zero sample count in rate transposing </li>
|
<li> Check against zero sample count in rate transposing</li>
|
||||||
<li> Fix for x86-64 support: Removed pop/push instructions from
|
<li> Fix for x86-64 support: Removed pop/push instructions from
|
||||||
the cpu detection algorithm. </li>
|
the cpu detection algorithm. </li>
|
||||||
<li> Check against empty buffers in FIFOSampleBuffer </li>
|
<li> Check against empty buffers in FIFOSampleBuffer</li>
|
||||||
<li> Other minor fixes & code cleanup</li>
|
<li> Other minor fixes & code cleanup</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li> Fixes in compilation scripts for non-Intel platforms </li>
|
<li> Fixes in compilation scripts for non-Intel platforms</li>
|
||||||
<li> Added Dynamic-Link-Library (DLL) version of SoundTouch library
|
<li> Added Dynamic-Link-Library (DLL) version of SoundTouch library
|
||||||
build, provided with Delphi/Pascal wrapper for calling the dll routines
|
build, provided with Delphi/Pascal wrapper for calling the dll routines
|
||||||
</li>
|
</li>
|
||||||
|
@ -580,86 +660,91 @@ processing more than 2048 samples at one call </li>
|
||||||
<p><strong>1.4.0:</strong></p>
|
<p><strong>1.4.0:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Improved sound quality by automatic calculation of time stretch
|
<li> Improved sound quality by automatic calculation of time stretch
|
||||||
algorithm processing parameters according to tempo setting </li>
|
algorithm processing parameters according to tempo setting</li>
|
||||||
<li> Moved BPM detection routines from SoundStretch application into
|
<li> Moved BPM detection routines from SoundStretch application into
|
||||||
SoundTouch library </li>
|
SoundTouch library</li>
|
||||||
<li> Bugfixes: Usage of uninitialied variables, GNU build scripts,
|
<li> Bugfixes: Usage of uninitialied variables, GNU build scripts,
|
||||||
compiler errors due to 'const' keyword mismatch. </li>
|
compiler errors due to 'const' keyword mismatch.</li>
|
||||||
<li> Source code cleanup</li>
|
<li> Source code cleanup</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.3.1: </strong> </p>
|
<p><strong>1.3.1: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Changed static class declaration to GCC 4.x compiler compatible
|
<li> Changed static class declaration to GCC 4.x compiler compatible
|
||||||
syntax. </li>
|
syntax.</li>
|
||||||
<li> Enabled MMX/SSE-optimized routines also for GCC compilers.
|
<li> Enabled MMX/SSE-optimized routines also for GCC compilers.
|
||||||
Earlier the MMX/SSE-optimized routines were written in
|
Earlier the MMX/SSE-optimized routines were written in
|
||||||
compiler-specific inline assembler, now these routines are migrated to
|
compiler-specific inline assembler, now these routines are migrated to
|
||||||
use compiler intrinsic syntax which allows compiling the same
|
use compiler intrinsic syntax which allows compiling the same
|
||||||
MMX/SSE-optimized source code with both Visual C++ and GCC compilers. </li>
|
MMX/SSE-optimized source code with both Visual C++ and GCC compilers.</li>
|
||||||
<li> Set floating point as the default sample format and added switch
|
<li> Set floating point as the default sample format and added switch
|
||||||
to the GNU configure script for selecting the other sample format.</li>
|
to the GNU configure script for selecting the other sample format.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.3.0: </strong> </p>
|
<p><strong>1.3.0: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Fixed tempo routine output duration inaccuracy due to rounding
|
<li> Fixed tempo routine output duration inaccuracy due to rounding
|
||||||
error </li>
|
error</li>
|
||||||
<li> Implemented separate processing routines for integer and
|
<li> Implemented separate processing routines for integer and
|
||||||
floating arithmetic to allow improvements to floating point routines
|
floating arithmetic to allow improvements to floating point routines
|
||||||
(earlier used algorithms mostly optimized for integer arithmetic also
|
(earlier used algorithms mostly optimized for integer arithmetic also
|
||||||
for floating point samples) </li>
|
for floating point samples)</li>
|
||||||
<li> Fixed a bug that distorts sound if sample rate changes during
|
<li> Fixed a bug that distorts sound if sample rate changes during
|
||||||
the sound stream </li>
|
the sound stream</li>
|
||||||
<li> Fixed a memory leak that appeared in MMX/SSE/3DNow! optimized
|
<li> Fixed a memory leak that appeared in MMX/SSE/3DNow! optimized
|
||||||
routines </li>
|
routines</li>
|
||||||
<li> Reduced redundant code pieces in MMX/SSE/3DNow! optimized
|
<li> Reduced redundant code pieces in MMX/SSE/3DNow! optimized
|
||||||
routines vs. the standard C routines. </li>
|
routines vs. the standard C routines.</li>
|
||||||
<li> MMX routine incompatibility with new gcc compiler versions </li>
|
<li> MMX routine incompatibility with new gcc compiler versions</li>
|
||||||
<li> Other miscellaneous bug fixes </li>
|
<li> Other miscellaneous bug fixes</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.2.1: </strong> </p>
|
<p><strong>1.2.1: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Added automake/autoconf scripts for GNU platforms (in courtesy
|
<li> Added automake/autoconf scripts for GNU platforms (in courtesy
|
||||||
of David Durham) </li>
|
of David Durham)</li>
|
||||||
<li> Fixed SCALE overflow bug in rate transposer routine. </li>
|
<li> Fixed SCALE overflow bug in rate transposer routine.</li>
|
||||||
<li> Fixed 64bit address space bugs. </li>
|
<li> Fixed 64bit address space bugs.</li>
|
||||||
<li> Created a 'soundtouch' namespace for SAMPLETYPE definitions.</li>
|
<li> Created a 'soundtouch' namespace for SAMPLETYPE definitions.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.2.0: </strong> </p>
|
<p><strong>1.2.0: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Added support for 32bit floating point sample data type with
|
<li> Added support for 32bit floating point sample data type with
|
||||||
SSE/3DNow! optimizations for Win32 platform (SSE/3DNow! optimizations
|
SSE/3DNow! optimizations for Win32 platform (SSE/3DNow! optimizations
|
||||||
currently not supported in GCC environment) </li>
|
currently not supported in GCC environment)</li>
|
||||||
<li> Replaced 'make-gcc' script for GNU environment by master
|
<li> Replaced 'make-gcc' script for GNU environment by master
|
||||||
Makefile </li>
|
Makefile</li>
|
||||||
<li> Added time-stretch routine configurability to SoundTouch main
|
<li> Added time-stretch routine configurability to SoundTouch main
|
||||||
class </li>
|
class</li>
|
||||||
<li> Bugfixes</li>
|
<li> Bugfixes</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.1.1: </strong> </p>
|
<p><strong>1.1.1: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Moved SoundTouch under lesser GPL license (LGPL). This allows
|
<li> Moved SoundTouch under lesser GPL license (LGPL). This allows
|
||||||
using SoundTouch library in programs that aren't released under GPL
|
using SoundTouch library in programs that aren't released under GPL
|
||||||
license. </li>
|
license.</li>
|
||||||
<li> Changed MMX routine organiation so that MMX optimized routines
|
<li> Changed MMX routine organiation so that MMX optimized routines
|
||||||
are now implemented in classes that are derived from the basic classes
|
are now implemented in classes that are derived from the basic classes
|
||||||
having the standard non-mmx routines. </li>
|
having the standard non-mmx routines.</li>
|
||||||
<li> MMX routines to support gcc version 3. </li>
|
<li> MMX routines to support gcc version 3.</li>
|
||||||
<li> Replaced windows makefiles by script using the .dsw files </li>
|
<li> Replaced windows makefiles by script using the .dsw files</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.0.1: </strong> </p>
|
<p><strong>1.0.1: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> "mmx_gcc.cpp": Added "using namespace std" and removed "return
|
<li> "mmx_gcc.cpp": Added "using namespace std" and removed "return
|
||||||
0" from a function with void return value to fix compiler errors when
|
0" from a function with void return value to fix compiler errors when
|
||||||
compiling the library in Solaris environment. </li>
|
compiling the library in Solaris environment.</li>
|
||||||
<li> Moved file "FIFOSampleBuffer.h" to "include" directory to allow
|
<li> Moved file "FIFOSampleBuffer.h" to "include" directory to allow
|
||||||
accessing the FIFOSampleBuffer class from external files. </li>
|
accessing the FIFOSampleBuffer class from external files.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.0: </strong> </p>
|
<p><strong>1.0: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Initial release </li>
|
<li> Initial release</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<h3>5.2. SoundStretch application Change History </h3>
|
<h3>5.2. SoundStretch application Change History </h3>
|
||||||
|
<p><b>1.9:</b></p>
|
||||||
|
<ul>
|
||||||
|
<li>Added support for WAV file 'fact' information chunk.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<p><b>1.7.0:</b></p>
|
<p><b>1.7.0:</b></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Bugfixes in Wavfile: exception string formatting, avoid getLengthMs() integer
|
<li>Bugfixes in Wavfile: exception string formatting, avoid getLengthMs() integer
|
||||||
|
@ -674,14 +759,14 @@ music processing.</li>
|
||||||
<p><strong>1.4.0:</strong></p>
|
<p><strong>1.4.0:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Moved BPM detection routines from SoundStretch application into
|
<li> Moved BPM detection routines from SoundStretch application into
|
||||||
SoundTouch library </li>
|
SoundTouch library</li>
|
||||||
<li> Allow using standard input/output pipes as audio processing
|
<li> Allow using standard input/output pipes as audio processing
|
||||||
input/output streams</li>
|
input/output streams</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.3.0:</strong></p>
|
<p><strong>1.3.0:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Simplified accessing WAV files with floating point sample
|
<li> Simplified accessing WAV files with floating point sample
|
||||||
format. </li>
|
format.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.2.1: </strong> </p>
|
<p><strong>1.2.1: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -689,69 +774,66 @@ format. </li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.2.0: </strong> </p>
|
<p><strong>1.2.0: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Added support for 32bit floating point sample data type </li>
|
<li> Added support for 32bit floating point sample data type</li>
|
||||||
<li> Restructured the BPM routines into separate library </li>
|
<li> Restructured the BPM routines into separate library</li>
|
||||||
<li> Fixed big-endian conversion bugs in WAV file routines (hopefully
|
<li> Fixed big-endian conversion bugs in WAV file routines (hopefully
|
||||||
:)</li>
|
:)</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.1.1: </strong> </p>
|
<p><strong>1.1.1: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Fixed bugs in WAV file reading & added byte-order conversion
|
<li> Fixed bugs in WAV file reading & added byte-order conversion
|
||||||
for big-endian processors. </li>
|
for big-endian processors.</li>
|
||||||
<li> Moved SoundStretch source code under 'example' directory to
|
<li> Moved SoundStretch source code under 'example' directory to
|
||||||
highlight difference from SoundTouch stuff. </li>
|
highlight difference from SoundTouch stuff.</li>
|
||||||
<li> Replaced windows makefiles by script using the .dsw files </li>
|
<li> Replaced windows makefiles by script using the .dsw files</li>
|
||||||
<li> Output file name isn't required if output isn't desired (e.g. if
|
<li> Output file name isn't required if output isn't desired (e.g. if
|
||||||
using the switch '-bpm' in plain format only) </li>
|
using the switch '-bpm' in plain format only)</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.1:</strong></p>
|
<p><strong>1.1:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Fixed "Release" settings in Microsoft Visual C++ project file
|
<li> Fixed "Release" settings in Microsoft Visual C++ project file
|
||||||
(.dsp) </li>
|
(.dsp)</li>
|
||||||
<li> Added beats-per-minute (BPM) detection routine and command-line
|
<li> Added beats-per-minute (BPM) detection routine and command-line
|
||||||
switch "-bpm" </li>
|
switch "-bpm"</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><strong>1.01: </strong> </p>
|
<p><strong>1.01: </strong> </p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Initial release </li>
|
<li> Initial release</li>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<h2>6. Acknowledgements </h2>
|
<h2>6. Acknowledgements </h2>
|
||||||
<p>Kudos for these people who have contributed to development or
|
<p>Kudos for these people who have contributed to development or
|
||||||
submitted bugfixes since SoundTouch v1.3.1: </p>
|
submitted bugfixes:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li> Arthur A</li>
|
<li> Arthur A</li>
|
||||||
<li> Richard Ash</li>
|
<li> Richard Ash</li>
|
||||||
<li> Stanislav Brabec</li>
|
<li> Stanislav Brabec</li>
|
||||||
<li> Christian Budde</li>
|
<li> Christian Budde</li>
|
||||||
|
<li> Chris Bryan</li>
|
||||||
<li> Jacek Caban</li>
|
<li> Jacek Caban</li>
|
||||||
<li> Brian Cameron</li>
|
<li> Brian Cameron</li>
|
||||||
<li> Jason Champion</li>
|
<li> Jason Champion</li>
|
||||||
<li> David Clark</li>
|
<li> David Clark</li>
|
||||||
<li> Patrick Colis</li>
|
<li> Patrick Colis</li>
|
||||||
<li> Miquel Colon</li>
|
<li> Miquel Colon</li>
|
||||||
|
<li> Jim Credland</li>
|
||||||
|
<li> Sandro Cumerlato</li>
|
||||||
<li> Justin Frankel</li>
|
<li> Justin Frankel</li>
|
||||||
|
<li> Masa H.</li>
|
||||||
<li> Jason Garland</li>
|
<li> Jason Garland</li>
|
||||||
<li> Takashi Iwai</li>
|
<li> Takashi Iwai</li>
|
||||||
|
<li> Thomas Klausner</li>
|
||||||
|
<li> Mathias Möhl</li>
|
||||||
<li> Yuval Naveh</li>
|
<li> Yuval Naveh</li>
|
||||||
<li> Paulo Pizarro</li>
|
<li> Paulo Pizarro</li>
|
||||||
<li> Blaise Potard</li>
|
<li> Blaise Potard</li>
|
||||||
|
<li> Michael Pruett</li>
|
||||||
|
<li> Rajeev Puran</li>
|
||||||
<li> RJ Ryan</li>
|
<li> RJ Ryan</li>
|
||||||
<li> Patrick Colis </li>
|
|
||||||
<li> Miquel Colon </li>
|
|
||||||
<li> Sandro Cumerlato</li>
|
|
||||||
<li> Justin Frankel </li>
|
|
||||||
<li> Jason Garland </li>
|
|
||||||
<li> Takashi Iwai </li>
|
|
||||||
<li> Mathias Möhl</li>
|
|
||||||
<li> Yuval Naveh </li>
|
|
||||||
<li> Paulo Pizarro </li>
|
|
||||||
<li> Blaise Potard</li>
|
|
||||||
<li> RJ Ryan </li>
|
|
||||||
<li> John Sheehy</li>
|
<li> John Sheehy</li>
|
||||||
<li> Tim Shuttleworth</li>
|
<li> Tim Shuttleworth</li>
|
||||||
|
<li> Albert Sirvent</li>
|
||||||
<li> John Stumpo</li>
|
<li> John Stumpo</li>
|
||||||
<li> Tim Shuttleworth</li>
|
|
||||||
<li> Katja Vetter</li>
|
<li> Katja Vetter</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Moral greetings to all other contributors and users also!</p>
|
<p>Moral greetings to all other contributors and users also!</p>
|
||||||
|
@ -770,8 +852,8 @@ General Public License for more details.</p>
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
|
||||||
<hr><!--
|
<hr><!--
|
||||||
$Id: README.html 168 2012-12-28 20:55:19Z oparviai $
-->
|
$Id: README.html 220 2015-05-18 17:39:26Z oparviai $
-->
|
||||||
<p>
|
<p>
|
||||||
<i>RREADME.html file updated on 28-Dec-2012</i></p>
|
<i>README.html file updated in May-2015</i></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,626 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///
|
|
||||||
/// Sample rate transposer. Changes sample rate by using linear interpolation
|
|
||||||
/// together with anti-alias filtering (first order interpolation with anti-
|
|
||||||
/// alias filtering should be quite adequate for this application)
|
|
||||||
///
|
|
||||||
/// Author : Copyright (c) Olli Parviainen
|
|
||||||
/// Author e-mail : oparviai 'at' iki.fi
|
|
||||||
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Last changed : $Date: 2011-09-02 15:56:11 -0300 (sex, 02 set 2011) $
|
|
||||||
// File revision : $Revision: 4 $
|
|
||||||
//
|
|
||||||
// $Id: RateTransposer.cpp 131 2011-09-02 18:56:11Z oparviai $
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// License :
|
|
||||||
//
|
|
||||||
// SoundTouch audio processing library
|
|
||||||
// Copyright (c) Olli Parviainen
|
|
||||||
//
|
|
||||||
// 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 (at your option) 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "RateTransposer.h"
|
|
||||||
#include "AAFilter.h"
|
|
||||||
|
|
||||||
using namespace soundtouch;
|
|
||||||
|
|
||||||
|
|
||||||
/// A linear samplerate transposer class that uses integer arithmetics.
|
|
||||||
/// for the transposing.
|
|
||||||
class RateTransposerInteger : public RateTransposer
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
int iSlopeCount;
|
|
||||||
int iRate;
|
|
||||||
SAMPLETYPE sPrevSampleL, sPrevSampleR;
|
|
||||||
|
|
||||||
virtual void resetRegisters();
|
|
||||||
|
|
||||||
virtual uint transposeStereo(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
virtual uint transposeMono(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
|
|
||||||
public:
|
|
||||||
RateTransposerInteger();
|
|
||||||
virtual ~RateTransposerInteger();
|
|
||||||
|
|
||||||
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
|
|
||||||
/// rate, larger faster rates.
|
|
||||||
virtual void setRate(float newRate);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// A linear samplerate transposer class that uses floating point arithmetics
|
|
||||||
/// for the transposing.
|
|
||||||
class RateTransposerFloat : public RateTransposer
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
float fSlopeCount;
|
|
||||||
SAMPLETYPE sPrevSampleL, sPrevSampleR;
|
|
||||||
|
|
||||||
virtual void resetRegisters();
|
|
||||||
|
|
||||||
virtual uint transposeStereo(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
virtual uint transposeMono(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
|
|
||||||
public:
|
|
||||||
RateTransposerFloat();
|
|
||||||
virtual ~RateTransposerFloat();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Operator 'new' is overloaded so that it automatically creates a suitable instance
|
|
||||||
// depending on if we've a MMX/SSE/etc-capable CPU available or not.
|
|
||||||
void * RateTransposer::operator new(size_t s)
|
|
||||||
{
|
|
||||||
ST_THROW_RT_ERROR("Error in RateTransoser::new: don't use \"new TDStretch\" directly, use \"newInstance\" to create a new instance instead!");
|
|
||||||
return newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RateTransposer *RateTransposer::newInstance()
|
|
||||||
{
|
|
||||||
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
|
|
||||||
return ::new RateTransposerInteger;
|
|
||||||
#else
|
|
||||||
return ::new RateTransposerFloat;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
RateTransposer::RateTransposer() : FIFOProcessor(&outputBuffer)
|
|
||||||
{
|
|
||||||
numChannels = 2;
|
|
||||||
bUseAAFilter = TRUE;
|
|
||||||
fRate = 0;
|
|
||||||
|
|
||||||
// Instantiates the anti-alias filter with default tap length
|
|
||||||
// of 32
|
|
||||||
pAAFilter = new AAFilter(32);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RateTransposer::~RateTransposer()
|
|
||||||
{
|
|
||||||
delete pAAFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
|
|
||||||
void RateTransposer::enableAAFilter(BOOL newMode)
|
|
||||||
{
|
|
||||||
bUseAAFilter = newMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Returns nonzero if anti-alias filter is enabled.
|
|
||||||
BOOL RateTransposer::isAAFilterEnabled() const
|
|
||||||
{
|
|
||||||
return bUseAAFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AAFilter *RateTransposer::getAAFilter()
|
|
||||||
{
|
|
||||||
return pAAFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
|
||||||
// iRate, larger faster iRates.
|
|
||||||
void RateTransposer::setRate(float newRate)
|
|
||||||
{
|
|
||||||
double fCutoff;
|
|
||||||
|
|
||||||
fRate = newRate;
|
|
||||||
|
|
||||||
// design a new anti-alias filter
|
|
||||||
if (newRate > 1.0f)
|
|
||||||
{
|
|
||||||
fCutoff = 0.5f / newRate;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fCutoff = 0.5f * newRate;
|
|
||||||
}
|
|
||||||
pAAFilter->setCutoffFreq(fCutoff);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Outputs as many samples of the 'outputBuffer' as possible, and if there's
|
|
||||||
// any room left, outputs also as many of the incoming samples as possible.
|
|
||||||
// The goal is to drive the outputBuffer empty.
|
|
||||||
//
|
|
||||||
// It's allowed for 'output' and 'input' parameters to point to the same
|
|
||||||
// memory position.
|
|
||||||
/*
|
|
||||||
void RateTransposer::flushStoreBuffer()
|
|
||||||
{
|
|
||||||
if (storeBuffer.isEmpty()) return;
|
|
||||||
|
|
||||||
outputBuffer.moveSamples(storeBuffer);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Adds 'nSamples' pcs of samples from the 'samples' memory position into
|
|
||||||
// the input of the object.
|
|
||||||
void RateTransposer::putSamples(const SAMPLETYPE *samples, uint nSamples)
|
|
||||||
{
|
|
||||||
processSamples(samples, nSamples);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes up the sample rate, causing the observed playback 'rate' of the
|
|
||||||
// sound to decrease
|
|
||||||
void RateTransposer::upsample(const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
uint count, sizeTemp, num;
|
|
||||||
|
|
||||||
// If the parameter 'uRate' value is smaller than 'SCALE', first transpose
|
|
||||||
// the samples and then apply the anti-alias filter to remove aliasing.
|
|
||||||
|
|
||||||
// First check that there's enough room in 'storeBuffer'
|
|
||||||
// (+16 is to reserve some slack in the destination buffer)
|
|
||||||
sizeTemp = (uint)((float)nSamples / fRate + 16.0f);
|
|
||||||
|
|
||||||
// Transpose the samples, store the result into the end of "storeBuffer"
|
|
||||||
count = transpose(storeBuffer.ptrEnd(sizeTemp), src, nSamples);
|
|
||||||
storeBuffer.putSamples(count);
|
|
||||||
|
|
||||||
// Apply the anti-alias filter to samples in "store output", output the
|
|
||||||
// result to "dest"
|
|
||||||
num = storeBuffer.numSamples();
|
|
||||||
count = pAAFilter->evaluate(outputBuffer.ptrEnd(num),
|
|
||||||
storeBuffer.ptrBegin(), num, (uint)numChannels);
|
|
||||||
outputBuffer.putSamples(count);
|
|
||||||
|
|
||||||
// Remove the processed samples from "storeBuffer"
|
|
||||||
storeBuffer.receiveSamples(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes down the sample rate, causing the observed playback 'rate' of the
|
|
||||||
// sound to increase
|
|
||||||
void RateTransposer::downsample(const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
uint count, sizeTemp;
|
|
||||||
|
|
||||||
// If the parameter 'uRate' value is larger than 'SCALE', first apply the
|
|
||||||
// anti-alias filter to remove high frequencies (prevent them from folding
|
|
||||||
// over the lover frequencies), then transpose.
|
|
||||||
|
|
||||||
// Add the new samples to the end of the storeBuffer
|
|
||||||
storeBuffer.putSamples(src, nSamples);
|
|
||||||
|
|
||||||
// Anti-alias filter the samples to prevent folding and output the filtered
|
|
||||||
// data to tempBuffer. Note : because of the FIR filter length, the
|
|
||||||
// filtering routine takes in 'filter_length' more samples than it outputs.
|
|
||||||
assert(tempBuffer.isEmpty());
|
|
||||||
sizeTemp = storeBuffer.numSamples();
|
|
||||||
|
|
||||||
count = pAAFilter->evaluate(tempBuffer.ptrEnd(sizeTemp),
|
|
||||||
storeBuffer.ptrBegin(), sizeTemp, (uint)numChannels);
|
|
||||||
|
|
||||||
if (count == 0) return;
|
|
||||||
|
|
||||||
// Remove the filtered samples from 'storeBuffer'
|
|
||||||
storeBuffer.receiveSamples(count);
|
|
||||||
|
|
||||||
// Transpose the samples (+16 is to reserve some slack in the destination buffer)
|
|
||||||
sizeTemp = (uint)((float)nSamples / fRate + 16.0f);
|
|
||||||
count = transpose(outputBuffer.ptrEnd(sizeTemp), tempBuffer.ptrBegin(), count);
|
|
||||||
outputBuffer.putSamples(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes sample rate by applying anti-alias filter to prevent folding.
|
|
||||||
// Returns amount of samples returned in the "dest" buffer.
|
|
||||||
// The maximum amount of samples that can be returned at a time is set by
|
|
||||||
// the 'set_returnBuffer_size' function.
|
|
||||||
void RateTransposer::processSamples(const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
uint count;
|
|
||||||
uint sizeReq;
|
|
||||||
|
|
||||||
if (nSamples == 0) return;
|
|
||||||
assert(pAAFilter);
|
|
||||||
|
|
||||||
// If anti-alias filter is turned off, simply transpose without applying
|
|
||||||
// the filter
|
|
||||||
if (bUseAAFilter == FALSE)
|
|
||||||
{
|
|
||||||
sizeReq = (uint)((float)nSamples / fRate + 1.0f);
|
|
||||||
count = transpose(outputBuffer.ptrEnd(sizeReq), src, nSamples);
|
|
||||||
outputBuffer.putSamples(count);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transpose with anti-alias filter
|
|
||||||
if (fRate < 1.0f)
|
|
||||||
{
|
|
||||||
upsample(src, nSamples);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
downsample(src, nSamples);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
|
||||||
// Returns the number of samples returned in the "dest" buffer
|
|
||||||
inline uint RateTransposer::transpose(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
if (numChannels == 2)
|
|
||||||
{
|
|
||||||
return transposeStereo(dest, src, nSamples);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return transposeMono(dest, src, nSamples);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Sets the number of channels, 1 = mono, 2 = stereo
|
|
||||||
void RateTransposer::setChannels(int nChannels)
|
|
||||||
{
|
|
||||||
assert(nChannels > 0);
|
|
||||||
if (numChannels == nChannels) return;
|
|
||||||
|
|
||||||
assert(nChannels == 1 || nChannels == 2);
|
|
||||||
numChannels = nChannels;
|
|
||||||
|
|
||||||
storeBuffer.setChannels(numChannels);
|
|
||||||
tempBuffer.setChannels(numChannels);
|
|
||||||
outputBuffer.setChannels(numChannels);
|
|
||||||
|
|
||||||
// Inits the linear interpolation registers
|
|
||||||
resetRegisters();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Clears all the samples in the object
|
|
||||||
void RateTransposer::clear()
|
|
||||||
{
|
|
||||||
outputBuffer.clear();
|
|
||||||
storeBuffer.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns nonzero if there aren't any samples available for outputting.
|
|
||||||
int RateTransposer::isEmpty() const
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
res = FIFOProcessor::isEmpty();
|
|
||||||
if (res == 0) return 0;
|
|
||||||
return storeBuffer.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// RateTransposerInteger - integer arithmetic implementation
|
|
||||||
//
|
|
||||||
|
|
||||||
/// fixed-point interpolation routine precision
|
|
||||||
#define SCALE 65536
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
RateTransposerInteger::RateTransposerInteger() : RateTransposer()
|
|
||||||
{
|
|
||||||
// Notice: use local function calling syntax for sake of clarity,
|
|
||||||
// to indicate the fact that C++ constructor can't call virtual functions.
|
|
||||||
RateTransposerInteger::resetRegisters();
|
|
||||||
RateTransposerInteger::setRate(1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RateTransposerInteger::~RateTransposerInteger()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RateTransposerInteger::resetRegisters()
|
|
||||||
{
|
|
||||||
iSlopeCount = 0;
|
|
||||||
sPrevSampleL =
|
|
||||||
sPrevSampleR = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
|
||||||
// 'Mono' version of the routine. Returns the number of samples returned in
|
|
||||||
// the "dest" buffer
|
|
||||||
uint RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
unsigned int i, used;
|
|
||||||
LONG_SAMPLETYPE temp, vol1;
|
|
||||||
|
|
||||||
if (nSamples == 0) return 0; // no samples, no work
|
|
||||||
|
|
||||||
used = 0;
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
// Process the last sample saved from the previous call first...
|
|
||||||
while (iSlopeCount <= SCALE)
|
|
||||||
{
|
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
|
||||||
temp = vol1 * sPrevSampleL + iSlopeCount * src[0];
|
|
||||||
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
|
||||||
i++;
|
|
||||||
iSlopeCount += iRate;
|
|
||||||
}
|
|
||||||
// now always (iSlopeCount > SCALE)
|
|
||||||
iSlopeCount -= SCALE;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
while (iSlopeCount > SCALE)
|
|
||||||
{
|
|
||||||
iSlopeCount -= SCALE;
|
|
||||||
used ++;
|
|
||||||
if (used >= nSamples - 1) goto end;
|
|
||||||
}
|
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
|
||||||
temp = src[used] * vol1 + iSlopeCount * src[used + 1];
|
|
||||||
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
iSlopeCount += iRate;
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
// Store the last sample for the next round
|
|
||||||
sPrevSampleL = src[nSamples - 1];
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
|
||||||
// 'Stereo' version of the routine. Returns the number of samples returned in
|
|
||||||
// the "dest" buffer
|
|
||||||
uint RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
unsigned int srcPos, i, used;
|
|
||||||
LONG_SAMPLETYPE temp, vol1;
|
|
||||||
|
|
||||||
if (nSamples == 0) return 0; // no samples, no work
|
|
||||||
|
|
||||||
used = 0;
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
// Process the last sample saved from the sPrevSampleLious call first...
|
|
||||||
while (iSlopeCount <= SCALE)
|
|
||||||
{
|
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
|
||||||
temp = vol1 * sPrevSampleL + iSlopeCount * src[0];
|
|
||||||
dest[2 * i] = (SAMPLETYPE)(temp / SCALE);
|
|
||||||
temp = vol1 * sPrevSampleR + iSlopeCount * src[1];
|
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)(temp / SCALE);
|
|
||||||
i++;
|
|
||||||
iSlopeCount += iRate;
|
|
||||||
}
|
|
||||||
// now always (iSlopeCount > SCALE)
|
|
||||||
iSlopeCount -= SCALE;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
while (iSlopeCount > SCALE)
|
|
||||||
{
|
|
||||||
iSlopeCount -= SCALE;
|
|
||||||
used ++;
|
|
||||||
if (used >= nSamples - 1) goto end;
|
|
||||||
}
|
|
||||||
srcPos = 2 * used;
|
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
|
||||||
temp = src[srcPos] * vol1 + iSlopeCount * src[srcPos + 2];
|
|
||||||
dest[2 * i] = (SAMPLETYPE)(temp / SCALE);
|
|
||||||
temp = src[srcPos + 1] * vol1 + iSlopeCount * src[srcPos + 3];
|
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)(temp / SCALE);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
iSlopeCount += iRate;
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
// Store the last sample for the next round
|
|
||||||
sPrevSampleL = src[2 * nSamples - 2];
|
|
||||||
sPrevSampleR = src[2 * nSamples - 1];
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
|
||||||
// iRate, larger faster iRates.
|
|
||||||
void RateTransposerInteger::setRate(float newRate)
|
|
||||||
{
|
|
||||||
iRate = (int)(newRate * SCALE + 0.5f);
|
|
||||||
RateTransposer::setRate(newRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// RateTransposerFloat - floating point arithmetic implementation
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
RateTransposerFloat::RateTransposerFloat() : RateTransposer()
|
|
||||||
{
|
|
||||||
// Notice: use local function calling syntax for sake of clarity,
|
|
||||||
// to indicate the fact that C++ constructor can't call virtual functions.
|
|
||||||
RateTransposerFloat::resetRegisters();
|
|
||||||
RateTransposerFloat::setRate(1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RateTransposerFloat::~RateTransposerFloat()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RateTransposerFloat::resetRegisters()
|
|
||||||
{
|
|
||||||
fSlopeCount = 0;
|
|
||||||
sPrevSampleL =
|
|
||||||
sPrevSampleR = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
|
||||||
// 'Mono' version of the routine. Returns the number of samples returned in
|
|
||||||
// the "dest" buffer
|
|
||||||
uint RateTransposerFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
unsigned int i, used;
|
|
||||||
|
|
||||||
used = 0;
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
// Process the last sample saved from the previous call first...
|
|
||||||
while (fSlopeCount <= 1.0f)
|
|
||||||
{
|
|
||||||
dest[i] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSampleL + fSlopeCount * src[0]);
|
|
||||||
i++;
|
|
||||||
fSlopeCount += fRate;
|
|
||||||
}
|
|
||||||
fSlopeCount -= 1.0f;
|
|
||||||
|
|
||||||
if (nSamples > 1)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
while (fSlopeCount > 1.0f)
|
|
||||||
{
|
|
||||||
fSlopeCount -= 1.0f;
|
|
||||||
used ++;
|
|
||||||
if (used >= nSamples - 1) goto end;
|
|
||||||
}
|
|
||||||
dest[i] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[used] + fSlopeCount * src[used + 1]);
|
|
||||||
i++;
|
|
||||||
fSlopeCount += fRate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
// Store the last sample for the next round
|
|
||||||
sPrevSampleL = src[nSamples - 1];
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
|
||||||
// 'Mono' version of the routine. Returns the number of samples returned in
|
|
||||||
// the "dest" buffer
|
|
||||||
uint RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
|
||||||
{
|
|
||||||
unsigned int srcPos, i, used;
|
|
||||||
|
|
||||||
if (nSamples == 0) return 0; // no samples, no work
|
|
||||||
|
|
||||||
used = 0;
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
// Process the last sample saved from the sPrevSampleLious call first...
|
|
||||||
while (fSlopeCount <= 1.0f)
|
|
||||||
{
|
|
||||||
dest[2 * i] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSampleL + fSlopeCount * src[0]);
|
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSampleR + fSlopeCount * src[1]);
|
|
||||||
i++;
|
|
||||||
fSlopeCount += fRate;
|
|
||||||
}
|
|
||||||
// now always (iSlopeCount > 1.0f)
|
|
||||||
fSlopeCount -= 1.0f;
|
|
||||||
|
|
||||||
if (nSamples > 1)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
while (fSlopeCount > 1.0f)
|
|
||||||
{
|
|
||||||
fSlopeCount -= 1.0f;
|
|
||||||
used ++;
|
|
||||||
if (used >= nSamples - 1) goto end;
|
|
||||||
}
|
|
||||||
srcPos = 2 * used;
|
|
||||||
|
|
||||||
dest[2 * i] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[srcPos]
|
|
||||||
+ fSlopeCount * src[srcPos + 2]);
|
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[srcPos + 1]
|
|
||||||
+ fSlopeCount * src[srcPos + 3]);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
fSlopeCount += fRate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end:
|
|
||||||
// Store the last sample for the next round
|
|
||||||
sPrevSampleL = src[2 * nSamples - 2];
|
|
||||||
sPrevSampleR = src[2 * nSamples - 1];
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
|
@ -5,112 +5,88 @@
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Devel|Win32">
|
<ProjectConfiguration Include="Devel|Win32">
|
||||||
<Configuration>Devel</Configuration>
|
<Configuration>Devel</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Devel|x64">
|
||||||
|
<Configuration>Devel</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}</ProjectGuid>
|
<ProjectGuid>{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}</ProjectGuid>
|
||||||
<RootNamespace>SoundTouch</RootNamespace>
|
|
||||||
<ProjectName>SoundTouch</ProjectName>
|
<ProjectName>SoundTouch</ProjectName>
|
||||||
|
<RootNamespace>SoundTouch</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'" Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<PlatformToolset>$(DefaultPlatformToolset)_xp</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<PlatformToolset>$(DefaultPlatformToolset)_xp</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>$(DefaultPlatformToolset)_xp</PlatformToolset>
|
<PlatformToolset>$(DefaultPlatformToolset)_xp</PlatformToolset>
|
||||||
|
<UseDebugLibraries Condition="'$(Configuration)'=='Debug'">true</UseDebugLibraries>
|
||||||
|
<UseDebugLibraries Condition="'$(Configuration)'!='Debug'">false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="PropertySheets">
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
<Import Project="..\DefaultProjectRootDir.props" />
|
<Import Project="..\DefaultProjectRootDir.props" />
|
||||||
<Import Project="..\3rdparty.props" />
|
<Import Project="..\3rdparty.props" />
|
||||||
<Import Project="..\..\common\vsprops\CodeGen_Devel.props" />
|
<Import Condition="'$(Configuration)'!='Release'" Project="..\..\common\vsprops\IncrementalLinking.props" />
|
||||||
<Import Project="..\..\common\vsprops\IncrementalLinking.props" />
|
<Import Condition="'$(Configuration)'=='Debug'" Project="..\..\common\vsprops\CodeGen_Debug.props" />
|
||||||
|
<Import Condition="'$(Configuration)'=='Devel'" Project="..\..\common\vsprops\CodeGen_Devel.props" />
|
||||||
|
<Import Condition="'$(Configuration)'=='Release'" Project="..\..\common\vsprops\CodeGen_Release.props" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
<ItemDefinitionGroup>
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\DefaultProjectRootDir.props" />
|
|
||||||
<Import Project="..\3rdparty.props" />
|
|
||||||
<Import Project="..\..\common\vsprops\CodeGen_Release.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\DefaultProjectRootDir.props" />
|
|
||||||
<Import Project="..\3rdparty.props" />
|
|
||||||
<Import Project="..\..\common\vsprops\CodeGen_Debug.props" />
|
|
||||||
<Import Project="..\..\common\vsprops\IncrementalLinking.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
|
||||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
|
||||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
|
||||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'" />
|
|
||||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'" />
|
|
||||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
|
||||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
|
||||||
<TargetName Condition="'$(Configuration)|$(Platform)'=='Devel|Win32'">$(ProjectName)-dev</TargetName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<AdditionalIncludeDirectories>$(ProjectDir)soundtouch;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="3dnow_win.cpp" />
|
<ClCompile Include="source\SoundStretch\WavFile.cpp" />
|
||||||
<ClCompile Include="AAFilter.cpp" />
|
<ClCompile Include="source\SoundTouch\AAFilter.cpp" />
|
||||||
<ClCompile Include="cpu_detect_x86_win.cpp" />
|
<ClCompile Include="source\SoundTouch\BPMDetect.cpp" />
|
||||||
<ClCompile Include="FIFOSampleBuffer.cpp" />
|
<ClCompile Include="source\SoundTouch\cpu_detect_x86.cpp" />
|
||||||
<ClCompile Include="FIRFilter.cpp" />
|
<ClCompile Include="source\SoundTouch\FIFOSampleBuffer.cpp" />
|
||||||
<ClCompile Include="mmx_optimized.cpp" />
|
<ClCompile Include="source\SoundTouch\FIRFilter.cpp" />
|
||||||
<ClCompile Include="RateTransposer.cpp" />
|
<ClCompile Include="source\SoundTouch\InterpolateCubic.cpp" />
|
||||||
<ClCompile Include="SoundTouch.cpp" />
|
<ClCompile Include="source\SoundTouch\InterpolateLinear.cpp" />
|
||||||
<ClCompile Include="sse_optimized.cpp" />
|
<ClCompile Include="source\SoundTouch\InterpolateShannon.cpp" />
|
||||||
<ClCompile Include="TDStretch.cpp" />
|
<ClCompile Include="source\SoundTouch\mmx_optimized.cpp" />
|
||||||
<ClCompile Include="WavFile.cpp" />
|
<ClCompile Include="source\SoundTouch\PeakFinder.cpp" />
|
||||||
|
<ClCompile Include="source\SoundTouch\RateTransposer.cpp" />
|
||||||
|
<ClCompile Include="source\SoundTouch\SoundTouch.cpp" />
|
||||||
|
<ClCompile Include="source\SoundTouch\sse_optimized.cpp" />
|
||||||
|
<ClCompile Include="source\SoundTouch\TDStretch.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="AAFilter.h" />
|
<ClInclude Include="soundtouch\BPMDetect.h" />
|
||||||
<ClInclude Include="BPMDetect.h" />
|
<ClInclude Include="soundtouch\FIFOSampleBuffer.h" />
|
||||||
<ClInclude Include="cpu_detect.h" />
|
<ClInclude Include="soundtouch\FIFOSamplePipe.h" />
|
||||||
<ClInclude Include="FIFOSampleBuffer.h" />
|
<ClInclude Include="soundtouch\SoundTouch.h" />
|
||||||
<ClInclude Include="FIFOSamplePipe.h" />
|
<ClInclude Include="soundtouch\STTypes.h" />
|
||||||
<ClInclude Include="FIRFilter.h" />
|
<ClInclude Include="source\SoundStretch\WavFile.h" />
|
||||||
<ClInclude Include="RateTransposer.h" />
|
<ClInclude Include="source\SoundTouch\AAFilter.h" />
|
||||||
<ClInclude Include="SoundTouch.h" />
|
<ClInclude Include="source\SoundTouch\cpu_detect.h" />
|
||||||
<ClInclude Include="STTypes.h" />
|
<ClInclude Include="source\SoundTouch\FIRFilter.h" />
|
||||||
<ClInclude Include="TDStretch.h" />
|
<ClInclude Include="source\SoundTouch\InterpolateCubic.h" />
|
||||||
<ClInclude Include="WavFile.h" />
|
<ClInclude Include="source\SoundTouch\InterpolateLinear.h" />
|
||||||
|
<ClInclude Include="source\SoundTouch\InterpolateShannon.h" />
|
||||||
|
<ClInclude Include="source\SoundTouch\PeakFinder.h" />
|
||||||
|
<ClInclude Include="source\SoundTouch\RateTransposer.h" />
|
||||||
|
<ClInclude Include="source\SoundTouch\TDStretch.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
</Project>
|
|
@ -11,72 +11,96 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="3dnow_win.cpp">
|
<ClCompile Include="source\SoundTouch\AAFilter.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="AAFilter.cpp">
|
<ClCompile Include="source\SoundTouch\BPMDetect.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="cpu_detect_x86_win.cpp">
|
<ClCompile Include="source\SoundTouch\cpu_detect_x86.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="FIFOSampleBuffer.cpp">
|
<ClCompile Include="source\SoundTouch\FIFOSampleBuffer.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="FIRFilter.cpp">
|
<ClCompile Include="source\SoundTouch\FIRFilter.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="mmx_optimized.cpp">
|
<ClCompile Include="source\SoundTouch\InterpolateCubic.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="RateTransposer.cpp">
|
<ClCompile Include="source\SoundTouch\InterpolateLinear.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="SoundTouch.cpp">
|
<ClCompile Include="source\SoundTouch\InterpolateShannon.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="sse_optimized.cpp">
|
<ClCompile Include="source\SoundTouch\mmx_optimized.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TDStretch.cpp">
|
<ClCompile Include="source\SoundTouch\PeakFinder.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="WavFile.cpp">
|
<ClCompile Include="source\SoundTouch\RateTransposer.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="source\SoundTouch\SoundTouch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="source\SoundTouch\sse_optimized.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="source\SoundTouch\TDStretch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="source\SoundStretch\WavFile.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="AAFilter.h">
|
<ClInclude Include="soundtouch\BPMDetect.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="BPMDetect.h">
|
<ClInclude Include="soundtouch\FIFOSampleBuffer.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="cpu_detect.h">
|
<ClInclude Include="soundtouch\FIFOSamplePipe.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="FIFOSampleBuffer.h">
|
<ClInclude Include="soundtouch\SoundTouch.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="FIFOSamplePipe.h">
|
<ClInclude Include="soundtouch\STTypes.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="FIRFilter.h">
|
<ClInclude Include="source\SoundTouch\AAFilter.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="RateTransposer.h">
|
<ClInclude Include="source\SoundTouch\cpu_detect.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="SoundTouch.h">
|
<ClInclude Include="source\SoundTouch\FIRFilter.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="STTypes.h">
|
<ClInclude Include="source\SoundTouch\InterpolateCubic.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TDStretch.h">
|
<ClInclude Include="source\SoundTouch\InterpolateLinear.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="WavFile.h">
|
<ClInclude Include="source\SoundTouch\InterpolateShannon.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="source\SoundTouch\PeakFinder.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="source\SoundTouch\RateTransposer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="source\SoundTouch\TDStretch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="source\SoundStretch\WavFile.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -1,745 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///
|
|
||||||
/// Classes for easy reading & writing of WAV sound files.
|
|
||||||
///
|
|
||||||
/// For big-endian CPU, define _BIG_ENDIAN_ during compile-time to correctly
|
|
||||||
/// parse the WAV files with such processors.
|
|
||||||
///
|
|
||||||
/// Admittingly, more complete WAV reader routines may exist in public domain,
|
|
||||||
/// but the reason for 'yet another' one is that those generic WAV reader
|
|
||||||
/// libraries are exhaustingly large and cumbersome! Wanted to have something
|
|
||||||
/// simpler here, i.e. something that's not already larger than rest of the
|
|
||||||
/// SoundTouch/SoundStretch program...
|
|
||||||
///
|
|
||||||
/// Author : Copyright (c) Olli Parviainen
|
|
||||||
/// Author e-mail : oparviai 'at' iki.fi
|
|
||||||
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
|
|
||||||
// File revision : $Revision: 4 $
|
|
||||||
//
|
|
||||||
// $Id: WavFile.cpp 63 2009-02-21 16:00:14Z oparviai $
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// License :
|
|
||||||
//
|
|
||||||
// SoundTouch audio processing library
|
|
||||||
// Copyright (c) Olli Parviainen
|
|
||||||
//
|
|
||||||
// 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 (at your option) 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
#include <cstring>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include "WavFile.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
static const char riffStr[] = "RIFF";
|
|
||||||
static const char waveStr[] = "WAVE";
|
|
||||||
static const char fmtStr[] = "fmt ";
|
|
||||||
static const char dataStr[] = "data";
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Helper functions for swapping byte order to correctly read/write WAV files
|
|
||||||
// with big-endian CPU's: Define compile-time definition _BIG_ENDIAN_ to
|
|
||||||
// turn-on the conversion if it appears necessary.
|
|
||||||
//
|
|
||||||
// For example, Intel x86 is little-endian and doesn't require conversion,
|
|
||||||
// while PowerPC of Mac's and many other RISC cpu's are big-endian.
|
|
||||||
|
|
||||||
#ifdef BYTE_ORDER
|
|
||||||
// In gcc compiler detect the byte order automatically
|
|
||||||
#if BYTE_ORDER == BIG_ENDIAN
|
|
||||||
// big-endian platform.
|
|
||||||
#define _BIG_ENDIAN_
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _BIG_ENDIAN_
|
|
||||||
// big-endian CPU, swap bytes in 16 & 32 bit words
|
|
||||||
|
|
||||||
// helper-function to swap byte-order of 32bit integer
|
|
||||||
static inline void _swap32(unsigned int &dwData)
|
|
||||||
{
|
|
||||||
dwData = ((dwData >> 24) & 0x000000FF) |
|
|
||||||
((dwData >> 8) & 0x0000FF00) |
|
|
||||||
((dwData << 8) & 0x00FF0000) |
|
|
||||||
((dwData << 24) & 0xFF000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper-function to swap byte-order of 16bit integer
|
|
||||||
static inline void _swap16(unsigned short &wData)
|
|
||||||
{
|
|
||||||
wData = ((wData >> 8) & 0x00FF) |
|
|
||||||
((wData << 8) & 0xFF00);
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper-function to swap byte-order of buffer of 16bit integers
|
|
||||||
static inline void _swap16Buffer(unsigned short *pData, unsigned int dwNumWords)
|
|
||||||
{
|
|
||||||
unsigned long i;
|
|
||||||
|
|
||||||
for (i = 0; i < dwNumWords; i ++)
|
|
||||||
{
|
|
||||||
_swap16(pData[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // BIG_ENDIAN
|
|
||||||
// little-endian CPU, WAV file is ok as such
|
|
||||||
|
|
||||||
// dummy helper-function
|
|
||||||
static inline void _swap32(unsigned int &dwData)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
// dummy helper-function
|
|
||||||
static inline void _swap16(unsigned short &wData)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
// dummy helper-function
|
|
||||||
static inline void _swap16Buffer(unsigned short *pData, unsigned int dwNumBytes)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // BIG_ENDIAN
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Class WavInFile
|
|
||||||
//
|
|
||||||
|
|
||||||
WavInFile::WavInFile(const char *fileName)
|
|
||||||
{
|
|
||||||
// Try to open the file for reading
|
|
||||||
fptr = fopen(fileName, "rb");
|
|
||||||
if (fptr == NULL)
|
|
||||||
{
|
|
||||||
// didn't succeed
|
|
||||||
string msg = "Error : Unable to open file \"";
|
|
||||||
msg += fileName;
|
|
||||||
msg += "\" for reading.";
|
|
||||||
throw runtime_error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WavInFile::WavInFile(FILE *file)
|
|
||||||
{
|
|
||||||
// Try to open the file for reading
|
|
||||||
fptr = file;
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
// didn't succeed
|
|
||||||
string msg = "Error : Unable to access input stream for reading";
|
|
||||||
throw runtime_error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Init the WAV file stream
|
|
||||||
void WavInFile::init()
|
|
||||||
{
|
|
||||||
int hdrsOk;
|
|
||||||
|
|
||||||
// assume file stream is already open
|
|
||||||
assert(fptr);
|
|
||||||
|
|
||||||
// Read the file headers
|
|
||||||
hdrsOk = readWavHeaders();
|
|
||||||
if (hdrsOk != 0)
|
|
||||||
{
|
|
||||||
// Something didn't match in the wav file headers
|
|
||||||
string msg = "Input file is corrupt or not a WAV file";
|
|
||||||
throw runtime_error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (header.format.fixed != 1)
|
|
||||||
{
|
|
||||||
string msg = "Input file uses unsupported encoding.";
|
|
||||||
throw runtime_error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
dataRead = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WavInFile::~WavInFile()
|
|
||||||
{
|
|
||||||
if (fptr) fclose(fptr);
|
|
||||||
fptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavInFile::rewind()
|
|
||||||
{
|
|
||||||
int hdrsOk;
|
|
||||||
|
|
||||||
fseek(fptr, 0, SEEK_SET);
|
|
||||||
hdrsOk = readWavHeaders();
|
|
||||||
assert(hdrsOk == 0);
|
|
||||||
dataRead = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::checkCharTags() const
|
|
||||||
{
|
|
||||||
// header.format.fmt should equal to 'fmt '
|
|
||||||
if (memcmp(fmtStr, header.format.fmt, 4) != 0) return -1;
|
|
||||||
// header.data.data_field should equal to 'data'
|
|
||||||
if (memcmp(dataStr, header.data.data_field, 4) != 0) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::read(char *buffer, int maxElems)
|
|
||||||
{
|
|
||||||
int numBytes;
|
|
||||||
uint afterDataRead;
|
|
||||||
|
|
||||||
// ensure it's 8 bit format
|
|
||||||
if (header.format.bits_per_sample != 8)
|
|
||||||
{
|
|
||||||
throw runtime_error("Error: WavInFile::read(char*, int) works only with 8bit samples.");
|
|
||||||
}
|
|
||||||
assert(sizeof(char) == 1);
|
|
||||||
|
|
||||||
numBytes = maxElems;
|
|
||||||
afterDataRead = dataRead + numBytes;
|
|
||||||
if (afterDataRead > header.data.data_len)
|
|
||||||
{
|
|
||||||
// Don't read more samples than are marked available in header
|
|
||||||
numBytes = (int)header.data.data_len - (int)dataRead;
|
|
||||||
assert(numBytes >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(buffer);
|
|
||||||
numBytes = fread(buffer, 1, numBytes, fptr);
|
|
||||||
dataRead += numBytes;
|
|
||||||
|
|
||||||
return numBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::read(short *buffer, int maxElems)
|
|
||||||
{
|
|
||||||
unsigned int afterDataRead;
|
|
||||||
int numBytes;
|
|
||||||
int numElems;
|
|
||||||
|
|
||||||
assert(buffer);
|
|
||||||
if (header.format.bits_per_sample == 8)
|
|
||||||
{
|
|
||||||
// 8 bit format
|
|
||||||
char *temp = new char[maxElems];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
numElems = read(temp, maxElems);
|
|
||||||
// convert from 8 to 16 bit
|
|
||||||
for (i = 0; i < numElems; i ++)
|
|
||||||
{
|
|
||||||
buffer[i] = temp[i] << 8;
|
|
||||||
}
|
|
||||||
delete[] temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 16 bit format
|
|
||||||
assert(header.format.bits_per_sample == 16);
|
|
||||||
assert(sizeof(short) == 2);
|
|
||||||
|
|
||||||
numBytes = maxElems * 2;
|
|
||||||
afterDataRead = dataRead + numBytes;
|
|
||||||
if (afterDataRead > header.data.data_len)
|
|
||||||
{
|
|
||||||
// Don't read more samples than are marked available in header
|
|
||||||
numBytes = (int)header.data.data_len - (int)dataRead;
|
|
||||||
assert(numBytes >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
numBytes = fread(buffer, 1, numBytes, fptr);
|
|
||||||
dataRead += numBytes;
|
|
||||||
numElems = numBytes / 2;
|
|
||||||
|
|
||||||
// 16bit samples, swap byte order if necessary
|
|
||||||
_swap16Buffer((unsigned short *)buffer, numElems);
|
|
||||||
}
|
|
||||||
|
|
||||||
return numElems;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::read(float *buffer, int maxElems)
|
|
||||||
{
|
|
||||||
short *temp = new short[maxElems];
|
|
||||||
int num;
|
|
||||||
int i;
|
|
||||||
double fscale;
|
|
||||||
|
|
||||||
num = read(temp, maxElems);
|
|
||||||
|
|
||||||
fscale = 1.0 / 32768.0;
|
|
||||||
// convert to floats, scale to range [-1..+1[
|
|
||||||
for (i = 0; i < num; i ++)
|
|
||||||
{
|
|
||||||
buffer[i] = (float)(fscale * (double)temp[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] temp;
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::eof() const
|
|
||||||
{
|
|
||||||
// return true if all data has been read or file eof has reached
|
|
||||||
return (dataRead == header.data.data_len || feof(fptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// test if character code is between a white space ' ' and little 'z'
|
|
||||||
static int isAlpha(char c)
|
|
||||||
{
|
|
||||||
return (c >= ' ' && c <= 'z') ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// test if all characters are between a white space ' ' and little 'z'
|
|
||||||
static int isAlphaStr(const char *str)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
|
|
||||||
c = str[0];
|
|
||||||
while (c)
|
|
||||||
{
|
|
||||||
if (isAlpha(c) == 0) return 0;
|
|
||||||
str ++;
|
|
||||||
c = str[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::readRIFFBlock()
|
|
||||||
{
|
|
||||||
if (fread(&(header.riff), sizeof(WavRiff), 1, fptr) != 1) return -1;
|
|
||||||
|
|
||||||
// swap 32bit data byte order if necessary
|
|
||||||
_swap32((unsigned int &)header.riff.package_len);
|
|
||||||
|
|
||||||
// header.riff.riff_char should equal to 'RIFF');
|
|
||||||
if (memcmp(riffStr, header.riff.riff_char, 4) != 0) return -1;
|
|
||||||
// header.riff.wave should equal to 'WAVE'
|
|
||||||
if (memcmp(waveStr, header.riff.wave, 4) != 0) return -1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::readHeaderBlock()
|
|
||||||
{
|
|
||||||
char label[5];
|
|
||||||
string sLabel;
|
|
||||||
|
|
||||||
// lead label string
|
|
||||||
if (fread(label, 1, 4, fptr) !=4) return -1;
|
|
||||||
label[4] = 0;
|
|
||||||
|
|
||||||
if (isAlphaStr(label) == 0) return -1; // not a valid label
|
|
||||||
|
|
||||||
// Decode blocks according to their label
|
|
||||||
if (strcmp(label, fmtStr) == 0)
|
|
||||||
{
|
|
||||||
int nLen, nDump;
|
|
||||||
|
|
||||||
// 'fmt ' block
|
|
||||||
memcpy(header.format.fmt, fmtStr, 4);
|
|
||||||
|
|
||||||
// read length of the format field
|
|
||||||
if (fread(&nLen, sizeof(int), 1, fptr) != 1) return -1;
|
|
||||||
// swap byte order if necessary
|
|
||||||
_swap32((unsigned int &)nLen); // int format_len;
|
|
||||||
header.format.format_len = nLen;
|
|
||||||
|
|
||||||
// calculate how much length differs from expected
|
|
||||||
nDump = nLen - ((int)sizeof(header.format) - 8);
|
|
||||||
|
|
||||||
// if format_len is larger than expected, read only as much data as we've space for
|
|
||||||
if (nDump > 0)
|
|
||||||
{
|
|
||||||
nLen = sizeof(header.format) - 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read data
|
|
||||||
if (fread(&(header.format.fixed), nLen, 1, fptr) != 1) return -1;
|
|
||||||
|
|
||||||
// swap byte order if necessary
|
|
||||||
_swap16((unsigned short &)header.format.fixed); // short int fixed;
|
|
||||||
_swap16((unsigned short &)header.format.channel_number); // short int channel_number;
|
|
||||||
_swap32((unsigned int &)header.format.sample_rate); // int sample_rate;
|
|
||||||
_swap32((unsigned int &)header.format.byte_rate); // int byte_rate;
|
|
||||||
_swap16((unsigned short &)header.format.byte_per_sample); // short int byte_per_sample;
|
|
||||||
_swap16((unsigned short &)header.format.bits_per_sample); // short int bits_per_sample;
|
|
||||||
|
|
||||||
// if format_len is larger than expected, skip the extra data
|
|
||||||
if (nDump > 0)
|
|
||||||
{
|
|
||||||
fseek(fptr, nDump, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (strcmp(label, dataStr) == 0)
|
|
||||||
{
|
|
||||||
// 'data' block
|
|
||||||
memcpy(header.data.data_field, dataStr, 4);
|
|
||||||
if (fread(&(header.data.data_len), sizeof(uint), 1, fptr) != 1) return -1;
|
|
||||||
|
|
||||||
// swap byte order if necessary
|
|
||||||
_swap32((unsigned int &)header.data.data_len);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint len, i;
|
|
||||||
uint temp;
|
|
||||||
// unknown block
|
|
||||||
|
|
||||||
// read length
|
|
||||||
if (fread(&len, sizeof(len), 1, fptr) != 1) return -1;
|
|
||||||
// scan through the block
|
|
||||||
for (i = 0; i < len; i ++)
|
|
||||||
{
|
|
||||||
if (fread(&temp, 1, 1, fptr) != 1) return -1;
|
|
||||||
if (feof(fptr)) return -1; // unexpected eof
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int WavInFile::readWavHeaders()
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
memset(&header, 0, sizeof(header));
|
|
||||||
|
|
||||||
res = readRIFFBlock();
|
|
||||||
if (res) return 1;
|
|
||||||
// read header blocks until data block is found
|
|
||||||
do
|
|
||||||
{
|
|
||||||
// read header blocks
|
|
||||||
res = readHeaderBlock();
|
|
||||||
if (res < 0) return 1; // error in file structure
|
|
||||||
} while (res == 0);
|
|
||||||
// check that all required tags are legal
|
|
||||||
return checkCharTags();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getNumChannels() const
|
|
||||||
{
|
|
||||||
return header.format.channel_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getNumBits() const
|
|
||||||
{
|
|
||||||
return header.format.bits_per_sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getBytesPerSample() const
|
|
||||||
{
|
|
||||||
return getNumChannels() * getNumBits() / 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getSampleRate() const
|
|
||||||
{
|
|
||||||
return header.format.sample_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getDataSizeInBytes() const
|
|
||||||
{
|
|
||||||
return header.data.data_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getNumSamples() const
|
|
||||||
{
|
|
||||||
if (header.format.byte_per_sample == 0) return 0;
|
|
||||||
return header.data.data_len / (unsigned short)header.format.byte_per_sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint WavInFile::getLengthMS() const
|
|
||||||
{
|
|
||||||
uint numSamples;
|
|
||||||
uint sampleRate;
|
|
||||||
|
|
||||||
numSamples = getNumSamples();
|
|
||||||
sampleRate = getSampleRate();
|
|
||||||
|
|
||||||
assert(numSamples < UINT_MAX / 1000);
|
|
||||||
return (1000 * numSamples / sampleRate);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Class WavOutFile
|
|
||||||
//
|
|
||||||
|
|
||||||
WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int channels)
|
|
||||||
{
|
|
||||||
bytesWritten = 0;
|
|
||||||
fptr = fopen(fileName, "wb");
|
|
||||||
if (fptr == NULL)
|
|
||||||
{
|
|
||||||
string msg = "Error : Unable to open file \"";
|
|
||||||
msg += fileName;
|
|
||||||
msg += "\" for writing.";
|
|
||||||
//pmsg = msg.c_str;
|
|
||||||
throw runtime_error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
fillInHeader(sampleRate, bits, channels);
|
|
||||||
writeHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WavOutFile::WavOutFile(FILE *file, int sampleRate, int bits, int channels)
|
|
||||||
{
|
|
||||||
bytesWritten = 0;
|
|
||||||
fptr = file;
|
|
||||||
if (fptr == NULL)
|
|
||||||
{
|
|
||||||
string msg = "Error : Unable to access output file stream.";
|
|
||||||
throw runtime_error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
fillInHeader(sampleRate, bits, channels);
|
|
||||||
writeHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WavOutFile::~WavOutFile()
|
|
||||||
{
|
|
||||||
finishHeader();
|
|
||||||
if (fptr) fclose(fptr);
|
|
||||||
fptr = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
|
|
||||||
{
|
|
||||||
// fill in the 'riff' part..
|
|
||||||
|
|
||||||
// copy string 'RIFF' to riff_char
|
|
||||||
memcpy(&(header.riff.riff_char), riffStr, 4);
|
|
||||||
// package_len unknown so far
|
|
||||||
header.riff.package_len = 0;
|
|
||||||
// copy string 'WAVE' to wave
|
|
||||||
memcpy(&(header.riff.wave), waveStr, 4);
|
|
||||||
|
|
||||||
|
|
||||||
// fill in the 'format' part..
|
|
||||||
|
|
||||||
// copy string 'fmt ' to fmt
|
|
||||||
memcpy(&(header.format.fmt), fmtStr, 4);
|
|
||||||
|
|
||||||
header.format.format_len = 0x10;
|
|
||||||
header.format.fixed = 1;
|
|
||||||
header.format.channel_number = (short)channels;
|
|
||||||
header.format.sample_rate = (int)sampleRate;
|
|
||||||
header.format.bits_per_sample = (short)bits;
|
|
||||||
header.format.byte_per_sample = (short)(bits * channels / 8);
|
|
||||||
header.format.byte_rate = header.format.byte_per_sample * (int)sampleRate;
|
|
||||||
header.format.sample_rate = (int)sampleRate;
|
|
||||||
|
|
||||||
// fill in the 'data' part..
|
|
||||||
|
|
||||||
// copy string 'data' to data_field
|
|
||||||
memcpy(&(header.data.data_field), dataStr, 4);
|
|
||||||
// data_len unknown so far
|
|
||||||
header.data.data_len = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::finishHeader()
|
|
||||||
{
|
|
||||||
// supplement the file length into the header structure
|
|
||||||
header.riff.package_len = bytesWritten + 36;
|
|
||||||
header.data.data_len = bytesWritten;
|
|
||||||
|
|
||||||
writeHeader();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::writeHeader()
|
|
||||||
{
|
|
||||||
WavHeader hdrTemp;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
// swap byte order if necessary
|
|
||||||
hdrTemp = header;
|
|
||||||
_swap32((unsigned int &)hdrTemp.riff.package_len);
|
|
||||||
_swap32((unsigned int &)hdrTemp.format.format_len);
|
|
||||||
_swap16((unsigned short &)hdrTemp.format.fixed);
|
|
||||||
_swap16((unsigned short &)hdrTemp.format.channel_number);
|
|
||||||
_swap32((unsigned int &)hdrTemp.format.sample_rate);
|
|
||||||
_swap32((unsigned int &)hdrTemp.format.byte_rate);
|
|
||||||
_swap16((unsigned short &)hdrTemp.format.byte_per_sample);
|
|
||||||
_swap16((unsigned short &)hdrTemp.format.bits_per_sample);
|
|
||||||
_swap32((unsigned int &)hdrTemp.data.data_len);
|
|
||||||
|
|
||||||
// write the supplemented header in the beginning of the file
|
|
||||||
fseek(fptr, 0, SEEK_SET);
|
|
||||||
res = fwrite(&hdrTemp, sizeof(hdrTemp), 1, fptr);
|
|
||||||
if (res != 1)
|
|
||||||
{
|
|
||||||
throw runtime_error("Error while writing to a wav file.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// jump back to the end of the file
|
|
||||||
fseek(fptr, 0, SEEK_END);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::write(const char *buffer, int numElems)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if (header.format.bits_per_sample != 8)
|
|
||||||
{
|
|
||||||
throw runtime_error("Error: WavOutFile::write(const char*, int) accepts only 8bit samples.");
|
|
||||||
}
|
|
||||||
assert(sizeof(char) == 1);
|
|
||||||
|
|
||||||
res = fwrite(buffer, 1, numElems, fptr);
|
|
||||||
if (res != numElems)
|
|
||||||
{
|
|
||||||
throw runtime_error("Error while writing to a wav file.");
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesWritten += numElems;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::write(const short *buffer, int numElems)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
// 16 bit samples
|
|
||||||
if (numElems < 1) return; // nothing to do
|
|
||||||
|
|
||||||
if (header.format.bits_per_sample == 8)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *temp = new char[numElems];
|
|
||||||
// convert from 16bit format to 8bit format
|
|
||||||
for (i = 0; i < numElems; i ++)
|
|
||||||
{
|
|
||||||
temp[i] = buffer[i] >> 8;
|
|
||||||
}
|
|
||||||
// write in 8bit format
|
|
||||||
write(temp, numElems);
|
|
||||||
delete[] temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 16bit format
|
|
||||||
unsigned short *pTemp = new unsigned short[numElems];
|
|
||||||
|
|
||||||
assert(header.format.bits_per_sample == 16);
|
|
||||||
|
|
||||||
// allocate temp buffer to swap byte order if necessary
|
|
||||||
memcpy(pTemp, buffer, numElems * 2);
|
|
||||||
_swap16Buffer(pTemp, numElems);
|
|
||||||
|
|
||||||
res = fwrite(pTemp, 2, numElems, fptr);
|
|
||||||
|
|
||||||
delete[] pTemp;
|
|
||||||
|
|
||||||
if (res != numElems)
|
|
||||||
{
|
|
||||||
throw runtime_error("Error while writing to a wav file.");
|
|
||||||
}
|
|
||||||
bytesWritten += 2 * numElems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WavOutFile::write(const float *buffer, int numElems)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
short *temp = new short[numElems];
|
|
||||||
int iTemp;
|
|
||||||
|
|
||||||
// convert to 16 bit integer
|
|
||||||
for (i = 0; i < numElems; i ++)
|
|
||||||
{
|
|
||||||
// convert to integer
|
|
||||||
iTemp = (int)(32768.0f * buffer[i]);
|
|
||||||
|
|
||||||
// saturate
|
|
||||||
if (iTemp < -32768) iTemp = -32768;
|
|
||||||
if (iTemp > 32767) iTemp = 32767;
|
|
||||||
temp[i] = (short)iTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
write(temp, numElems);
|
|
||||||
|
|
||||||
delete[] temp;
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
curdir=`pwd`
|
|
||||||
|
|
||||||
echo -----------------
|
|
||||||
echo Building SoundTouch
|
|
||||||
echo -----------------
|
|
||||||
|
|
||||||
if [ $# -gt 0 ] && [ $1 = "all" ]
|
|
||||||
then
|
|
||||||
|
|
||||||
aclocal
|
|
||||||
automake -a
|
|
||||||
autoconf
|
|
||||||
./configure
|
|
||||||
make clean
|
|
||||||
make install
|
|
||||||
|
|
||||||
else
|
|
||||||
make $@
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#cp libZeroSPU2*.so* ${PCSX2PLUGINS}
|
|
|
@ -1,37 +0,0 @@
|
||||||
# -*- Autoconf -*-
|
|
||||||
# Process this file with autoconf to produce a configure script.
|
|
||||||
|
|
||||||
#AC_PREREQ([2.63])
|
|
||||||
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
|
|
||||||
AM_INIT_AUTOMAKE
|
|
||||||
AC_CONFIG_SRCDIR([BPMDetect.h])
|
|
||||||
|
|
||||||
# Checks for programs.
|
|
||||||
AC_PROG_CXX
|
|
||||||
AC_PROG_CC
|
|
||||||
AC_PROG_RANLIB
|
|
||||||
|
|
||||||
CFLAGS=
|
|
||||||
CPPFLAGS=
|
|
||||||
CXXFLAGS=
|
|
||||||
CCASFLAGS=
|
|
||||||
|
|
||||||
CFLAGS+=" -m32 "
|
|
||||||
CPPFLAGS+=" -m32 "
|
|
||||||
CXXFLAGS+=" -m32 "
|
|
||||||
CCASFLAGS+=" -m32 "
|
|
||||||
|
|
||||||
# Checks for header files.
|
|
||||||
AC_CHECK_HEADERS([limits.h memory.h stdlib.h string.h])
|
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
|
||||||
AC_C_INLINE
|
|
||||||
AC_C_RESTRICT
|
|
||||||
AC_TYPE_SIZE_T
|
|
||||||
AC_HEADER_STDBOOL
|
|
||||||
|
|
||||||
# Checks for library functions.
|
|
||||||
AC_CHECK_FUNCS([memmove memset])
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
|
||||||
AC_OUTPUT
|
|
|
@ -1,134 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///
|
|
||||||
/// Generic version of the x86 CPU extension detection routine.
|
|
||||||
///
|
|
||||||
/// This file is for GNU & other non-Windows compilers, see 'cpu_detect_x86_win.cpp'
|
|
||||||
/// for the Microsoft compiler version.
|
|
||||||
///
|
|
||||||
/// Author : Copyright (c) Olli Parviainen
|
|
||||||
/// Author e-mail : oparviai 'at' iki.fi
|
|
||||||
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Last changed : $Date: 2011-09-02 15:56:11 -0300 (sex, 02 set 2011) $
|
|
||||||
// File revision : $Revision: 4 $
|
|
||||||
//
|
|
||||||
// $Id: cpu_detect_x86_gcc.cpp 131 2011-09-02 18:56:11Z oparviai $
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// License :
|
|
||||||
//
|
|
||||||
// SoundTouch audio processing library
|
|
||||||
// Copyright (c) Olli Parviainen
|
|
||||||
//
|
|
||||||
// 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 (at your option) 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "cpu_detect.h"
|
|
||||||
#include "STTypes.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// processor instructions extension detection routines
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Flag variable indicating whick ISA extensions are disabled (for debugging)
|
|
||||||
static uint _dwDisabledISA = 0x00; // 0xffffffff; //<- use this to disable all extensions
|
|
||||||
|
|
||||||
// Disables given set of instruction extensions. See SUPPORT_... defines.
|
|
||||||
void disableExtensions(uint dwDisableMask)
|
|
||||||
{
|
|
||||||
_dwDisabledISA = dwDisableMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Checks which instruction set extensions are supported by the CPU.
|
|
||||||
uint detectCPUextensions(void)
|
|
||||||
{
|
|
||||||
#if (!(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS) || !(__GNUC__))
|
|
||||||
|
|
||||||
return 0; // always disable extensions on non-x86 platforms.
|
|
||||||
|
|
||||||
#else
|
|
||||||
uint res = 0;
|
|
||||||
|
|
||||||
if (_dwDisabledISA == 0xffffffff) return 0;
|
|
||||||
|
|
||||||
asm volatile(
|
|
||||||
#ifndef __x86_64__
|
|
||||||
// Check if 'cpuid' instructions is available by toggling eflags bit 21.
|
|
||||||
// Skip this for x86-64 as they always have cpuid while stack manipulation
|
|
||||||
// differs from 16/32bit ISA.
|
|
||||||
"\n\txor %%esi, %%esi" // clear %%esi = result register
|
|
||||||
|
|
||||||
"\n\tpushf" // save eflags to stack
|
|
||||||
"\n\tmovl (%%esp), %%eax" // load eax from stack (with eflags)
|
|
||||||
"\n\tmovl %%eax, %%ecx" // save the original eflags values to ecx
|
|
||||||
"\n\txor $0x00200000, %%eax" // toggle bit 21
|
|
||||||
"\n\tmovl %%eax, (%%esp)" // store toggled eflags to stack
|
|
||||||
"\n\tpopf" // load eflags from stack
|
|
||||||
"\n\tpushf" // save updated eflags to stack
|
|
||||||
"\n\tmovl (%%esp), %%eax" // load eax from stack
|
|
||||||
"\n\tpopf" // pop stack to restore esp
|
|
||||||
"\n\txor %%edx, %%edx" // clear edx for defaulting no mmx
|
|
||||||
"\n\tcmp %%ecx, %%eax" // compare to original eflags values
|
|
||||||
"\n\tjz end" // jumps to 'end' if cpuid not present
|
|
||||||
#endif // __x86_64__
|
|
||||||
|
|
||||||
// cpuid instruction available, test for presence of mmx instructions
|
|
||||||
|
|
||||||
"\n\tmovl $1, %%eax"
|
|
||||||
"\n\tcpuid"
|
|
||||||
"\n\ttest $0x00800000, %%edx"
|
|
||||||
"\n\tjz end" // branch if MMX not available
|
|
||||||
|
|
||||||
"\n\tor $0x01, %%esi" // otherwise add MMX support bit
|
|
||||||
|
|
||||||
"\n\ttest $0x02000000, %%edx"
|
|
||||||
"\n\tjz test3DNow" // branch if SSE not available
|
|
||||||
|
|
||||||
"\n\tor $0x08, %%esi" // otherwise add SSE support bit
|
|
||||||
|
|
||||||
"\n\ttest3DNow:"
|
|
||||||
// test for precense of AMD extensions
|
|
||||||
"\n\tmov $0x80000000, %%eax"
|
|
||||||
"\n\tcpuid"
|
|
||||||
"\n\tcmp $0x80000000, %%eax"
|
|
||||||
"\n\tjbe end" // branch if no AMD extensions detected
|
|
||||||
|
|
||||||
// test for precense of 3DNow! extension
|
|
||||||
"\n\tmov $0x80000001, %%eax"
|
|
||||||
"\n\tcpuid"
|
|
||||||
"\n\ttest $0x80000000, %%edx"
|
|
||||||
"\n\tjz end" // branch if 3DNow! not detected
|
|
||||||
|
|
||||||
"\n\tor $0x02, %%esi" // otherwise add 3DNow support bit
|
|
||||||
|
|
||||||
"\n\tend:"
|
|
||||||
|
|
||||||
"\n\tmov %%esi, %0"
|
|
||||||
|
|
||||||
: "=r" (res)
|
|
||||||
: /* no inputs */
|
|
||||||
: "%edx", "%eax", "%ecx", "%esi" );
|
|
||||||
|
|
||||||
return res & ~_dwDisabledISA;
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -1,137 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///
|
|
||||||
/// Win32 version of the x86 CPU detect routine.
|
|
||||||
///
|
|
||||||
/// This file is to be compiled in Windows platform with Microsoft Visual C++
|
|
||||||
/// Compiler. Please see 'cpu_detect_x86_gcc.cpp' for the gcc compiler version
|
|
||||||
/// for all GNU platforms.
|
|
||||||
///
|
|
||||||
/// Author : Copyright (c) Olli Parviainen
|
|
||||||
/// Author e-mail : oparviai 'at' iki.fi
|
|
||||||
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Last changed : $Date: 2011-07-17 07:58:40 -0300 (dom, 17 jul 2011) $
|
|
||||||
// File revision : $Revision: 4 $
|
|
||||||
//
|
|
||||||
// $Id: cpu_detect_x86_win.cpp 127 2011-07-17 10:58:40Z oparviai $
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// License :
|
|
||||||
//
|
|
||||||
// SoundTouch audio processing library
|
|
||||||
// Copyright (c) Olli Parviainen
|
|
||||||
//
|
|
||||||
// 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 (at your option) 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
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "cpu_detect.h"
|
|
||||||
|
|
||||||
#include "STTypes.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// processor instructions extension detection routines
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Flag variable indicating whick ISA extensions are disabled (for debugging)
|
|
||||||
static uint _dwDisabledISA = 0x00; // 0xffffffff; //<- use this to disable all extensions
|
|
||||||
|
|
||||||
|
|
||||||
// Disables given set of instruction extensions. See SUPPORT_... defines.
|
|
||||||
void disableExtensions(uint dwDisableMask)
|
|
||||||
{
|
|
||||||
_dwDisabledISA = dwDisableMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Checks which instruction set extensions are supported by the CPU.
|
|
||||||
uint detectCPUextensions(void)
|
|
||||||
{
|
|
||||||
uint res = 0;
|
|
||||||
|
|
||||||
if (_dwDisabledISA == 0xffffffff) return 0;
|
|
||||||
|
|
||||||
#ifndef _M_X64
|
|
||||||
// 32bit compilation, detect CPU capabilities with inline assembler.
|
|
||||||
__asm
|
|
||||||
{
|
|
||||||
; check if 'cpuid' instructions is available by toggling eflags bit 21
|
|
||||||
;
|
|
||||||
xor esi, esi ; clear esi = result register
|
|
||||||
|
|
||||||
pushfd ; save eflags to stack
|
|
||||||
mov eax,dword ptr [esp] ; load eax from stack (with eflags)
|
|
||||||
mov ecx, eax ; save the original eflags values to ecx
|
|
||||||
xor eax, 0x00200000 ; toggle bit 21
|
|
||||||
mov dword ptr [esp],eax ; store toggled eflags to stack
|
|
||||||
popfd ; load eflags from stack
|
|
||||||
|
|
||||||
pushfd ; save updated eflags to stack
|
|
||||||
mov eax,dword ptr [esp] ; load eax from stack
|
|
||||||
popfd ; pop stack to restore stack pointer
|
|
||||||
|
|
||||||
xor edx, edx ; clear edx for defaulting no mmx
|
|
||||||
cmp eax, ecx ; compare to original eflags values
|
|
||||||
jz end ; jumps to 'end' if cpuid not present
|
|
||||||
|
|
||||||
; cpuid instruction available, test for presence of mmx instructions
|
|
||||||
mov eax, 1
|
|
||||||
cpuid
|
|
||||||
test edx, 0x00800000
|
|
||||||
jz end ; branch if MMX not available
|
|
||||||
|
|
||||||
or esi, SUPPORT_MMX ; otherwise add MMX support bit
|
|
||||||
|
|
||||||
test edx, 0x02000000
|
|
||||||
jz test3DNow ; branch if SSE not available
|
|
||||||
|
|
||||||
or esi, SUPPORT_SSE ; otherwise add SSE support bit
|
|
||||||
|
|
||||||
test3DNow:
|
|
||||||
; test for precense of AMD extensions
|
|
||||||
mov eax, 0x80000000
|
|
||||||
cpuid
|
|
||||||
cmp eax, 0x80000000
|
|
||||||
jbe end ; branch if no AMD extensions detected
|
|
||||||
|
|
||||||
; test for precense of 3DNow! extension
|
|
||||||
mov eax, 0x80000001
|
|
||||||
cpuid
|
|
||||||
test edx, 0x80000000
|
|
||||||
jz end ; branch if 3DNow! not detected
|
|
||||||
|
|
||||||
or esi, SUPPORT_3DNOW ; otherwise add 3DNow support bit
|
|
||||||
|
|
||||||
end:
|
|
||||||
|
|
||||||
mov res, esi
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Visual C++ 64bit compilation doesn't support inline assembler. However,
|
|
||||||
// all x64 compatible CPUs support MMX & SSE extensions.
|
|
||||||
res = SUPPORT_MMX | SUPPORT_SSE | SUPPORT_SSE2;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return res & ~_dwDisabledISA;
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
/usr/share/automake-1.10/depcomp
|
|
|
@ -1 +0,0 @@
|
||||||
/usr/share/automake-1.10/install-sh
|
|
|
@ -1 +0,0 @@
|
||||||
/usr/share/automake-1.10/missing
|
|
|
@ -26,7 +26,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-08-30 16:53:44 -0300 (qui, 30 ago 2012) $
|
// Last changed : $Date: 2012-08-30 19:53:44 +0000 (Thu, 30 Aug 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: BPMDetect.h 150 2012-08-30 19:53:44Z oparviai $
|
// $Id: BPMDetect.h 150 2012-08-30 19:53:44Z oparviai $
|
|
@ -15,10 +15,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-06-13 16:29:53 -0300 (qua, 13 jun 2012) $
|
// Last changed : $Date: 2014-01-05 21:40:22 +0000 (Sun, 05 Jan 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIFOSampleBuffer.h 143 2012-06-13 19:29:53Z oparviai $
|
// $Id: FIFOSampleBuffer.h 177 2014-01-05 21:40:22Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -162,6 +162,12 @@ public:
|
||||||
/// Sets number of channels, 1 = mono, 2 = stereo.
|
/// Sets number of channels, 1 = mono, 2 = stereo.
|
||||||
void setChannels(int numChannels);
|
void setChannels(int numChannels);
|
||||||
|
|
||||||
|
/// Get number of channels
|
||||||
|
int getChannels()
|
||||||
|
{
|
||||||
|
return channels;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns nonzero if there aren't any samples available for outputting.
|
/// Returns nonzero if there aren't any samples available for outputting.
|
||||||
virtual int isEmpty() const;
|
virtual int isEmpty() const;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-06-13 16:29:53 -0300 (qua, 13 jun 2012) $
|
// Last changed : $Date: 2012-06-13 19:29:53 +0000 (Wed, 13 Jun 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIFOSamplePipe.h 143 2012-06-13 19:29:53Z oparviai $
|
// $Id: FIFOSamplePipe.h 143 2012-06-13 19:29:53Z oparviai $
|
|
@ -8,10 +8,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-12-28 12:53:56 -0200 (sex, 28 dez 2012) $
|
// Last changed : $Date: 2015-05-18 15:25:07 +0000 (Mon, 18 May 2015) $
|
||||||
// File revision : $Revision: 3 $
|
// File revision : $Revision: 3 $
|
||||||
//
|
//
|
||||||
// $Id: STTypes.h 162 2012-12-28 14:53:56Z oparviai $
|
// $Id: STTypes.h 215 2015-05-18 15:25:07Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -60,16 +60,6 @@ typedef unsigned long ulong;
|
||||||
#include "soundtouch_config.h"
|
#include "soundtouch_config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WINDEF_
|
|
||||||
// if these aren't defined already by Windows headers, define now
|
|
||||||
|
|
||||||
typedef int BOOL;
|
|
||||||
|
|
||||||
#define FALSE 0
|
|
||||||
#define TRUE 1
|
|
||||||
|
|
||||||
#endif // _WINDEF_
|
|
||||||
|
|
||||||
|
|
||||||
namespace soundtouch
|
namespace soundtouch
|
||||||
{
|
{
|
||||||
|
@ -78,7 +68,14 @@ namespace soundtouch
|
||||||
//#undef SOUNDTOUCH_INTEGER_SAMPLES
|
//#undef SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
//#undef SOUNDTOUCH_FLOAT_SAMPLES
|
//#undef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
|
|
||||||
#if (defined(__SOFTFP__))
|
/// If following flag is defined, always uses multichannel processing
|
||||||
|
/// routines also for mono and stero sound. This is for routine testing
|
||||||
|
/// purposes; output should be same with either routines, yet disabling
|
||||||
|
/// the dedicated mono/stereo processing routines will result in slower
|
||||||
|
/// runtime performance so recommendation is to keep this off.
|
||||||
|
// #define USE_MULTICH_ALWAYS
|
||||||
|
|
||||||
|
#if (defined(__SOFTFP__) && defined(ANDROID))
|
||||||
// For Android compilation: Force use of Integer samples in case that
|
// For Android compilation: Force use of Integer samples in case that
|
||||||
// compilation uses soft-floating point emulation - soft-fp is way too slow
|
// compilation uses soft-floating point emulation - soft-fp is way too slow
|
||||||
#undef SOUNDTOUCH_FLOAT_SAMPLES
|
#undef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
|
@ -175,6 +172,7 @@ namespace soundtouch
|
||||||
#else
|
#else
|
||||||
// use c++ standard exceptions
|
// use c++ standard exceptions
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
#define ST_THROW_RT_ERROR(x) {throw std::runtime_error(x);}
|
#define ST_THROW_RT_ERROR(x) {throw std::runtime_error(x);}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-12-28 17:32:59 -0200 (sex, 28 dez 2012) $
|
// Last changed : $Date: 2015-05-18 15:28:41 +0000 (Mon, 18 May 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: SoundTouch.h 163 2012-12-28 19:32:59Z oparviai $
|
// $Id: SoundTouch.h 216 2015-05-18 15:28:41Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -79,10 +79,10 @@ namespace soundtouch
|
||||||
{
|
{
|
||||||
|
|
||||||
/// Soundtouch library version string
|
/// Soundtouch library version string
|
||||||
#define SOUNDTOUCH_VERSION "1.7.1"
|
#define SOUNDTOUCH_VERSION "1.9.0"
|
||||||
|
|
||||||
/// SoundTouch library version id
|
/// SoundTouch library version id
|
||||||
#define SOUNDTOUCH_VERSION_ID (10701)
|
#define SOUNDTOUCH_VERSION_ID (10900)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
|
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
|
||||||
|
@ -160,7 +160,7 @@ private:
|
||||||
float virtualPitch;
|
float virtualPitch;
|
||||||
|
|
||||||
/// Flag: Has sample rate been set?
|
/// Flag: Has sample rate been set?
|
||||||
BOOL bSrateSet;
|
bool bSrateSet;
|
||||||
|
|
||||||
/// Calculates effective rate & tempo valuescfrom 'virtualRate', 'virtualTempo' and
|
/// Calculates effective rate & tempo valuescfrom 'virtualRate', 'virtualTempo' and
|
||||||
/// 'virtualPitch' parameters.
|
/// 'virtualPitch' parameters.
|
||||||
|
@ -247,8 +247,8 @@ public:
|
||||||
/// Changes a setting controlling the processing system behaviour. See the
|
/// Changes a setting controlling the processing system behaviour. See the
|
||||||
/// 'SETTING_...' defines for available setting ID's.
|
/// 'SETTING_...' defines for available setting ID's.
|
||||||
///
|
///
|
||||||
/// \return 'TRUE' if the setting was succesfully changed
|
/// \return 'true' if the setting was succesfully changed
|
||||||
BOOL setSetting(int settingId, ///< Setting ID number. see SETTING_... defines.
|
bool setSetting(int settingId, ///< Setting ID number. see SETTING_... defines.
|
||||||
int value ///< New setting value.
|
int value ///< New setting value.
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
#ifndef SOUNDTOUCH_CONFIG_H_INCLUDED
|
|
||||||
#define SOUNDTOUCH_CONFIG_H_INCLUDED
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // SOUNDTOUCH_CONFIG_H_INCLUDED
|
|
|
@ -0,0 +1,997 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Classes for easy reading & writing of WAV sound files.
|
||||||
|
///
|
||||||
|
/// For big-endian CPU, define _BIG_ENDIAN_ during compile-time to correctly
|
||||||
|
/// parse the WAV files with such processors.
|
||||||
|
///
|
||||||
|
/// Admittingly, more complete WAV reader routines may exist in public domain,
|
||||||
|
/// but the reason for 'yet another' one is that those generic WAV reader
|
||||||
|
/// libraries are exhaustingly large and cumbersome! Wanted to have something
|
||||||
|
/// simpler here, i.e. something that's not already larger than rest of the
|
||||||
|
/// SoundTouch/SoundStretch program...
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Last changed : $Date: 2014-10-05 16:20:24 +0000 (Sun, 05 Oct 2014) $
|
||||||
|
// File revision : $Revision: 4 $
|
||||||
|
//
|
||||||
|
// $Id: WavFile.cpp 200 2014-10-05 16:20:24Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <cstring>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include "WavFile.h"
|
||||||
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static const char riffStr[] = "RIFF";
|
||||||
|
static const char waveStr[] = "WAVE";
|
||||||
|
static const char fmtStr[] = "fmt ";
|
||||||
|
static const char factStr[] = "fact";
|
||||||
|
static const char dataStr[] = "data";
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Helper functions for swapping byte order to correctly read/write WAV files
|
||||||
|
// with big-endian CPU's: Define compile-time definition _BIG_ENDIAN_ to
|
||||||
|
// turn-on the conversion if it appears necessary.
|
||||||
|
//
|
||||||
|
// For example, Intel x86 is little-endian and doesn't require conversion,
|
||||||
|
// while PowerPC of Mac's and many other RISC cpu's are big-endian.
|
||||||
|
|
||||||
|
#ifdef BYTE_ORDER
|
||||||
|
// In gcc compiler detect the byte order automatically
|
||||||
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
// big-endian platform.
|
||||||
|
#define _BIG_ENDIAN_
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _BIG_ENDIAN_
|
||||||
|
// big-endian CPU, swap bytes in 16 & 32 bit words
|
||||||
|
|
||||||
|
// helper-function to swap byte-order of 32bit integer
|
||||||
|
static inline int _swap32(int &dwData)
|
||||||
|
{
|
||||||
|
dwData = ((dwData >> 24) & 0x000000FF) |
|
||||||
|
((dwData >> 8) & 0x0000FF00) |
|
||||||
|
((dwData << 8) & 0x00FF0000) |
|
||||||
|
((dwData << 24) & 0xFF000000);
|
||||||
|
return dwData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper-function to swap byte-order of 16bit integer
|
||||||
|
static inline short _swap16(short &wData)
|
||||||
|
{
|
||||||
|
wData = ((wData >> 8) & 0x00FF) |
|
||||||
|
((wData << 8) & 0xFF00);
|
||||||
|
return wData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper-function to swap byte-order of buffer of 16bit integers
|
||||||
|
static inline void _swap16Buffer(short *pData, int numWords)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < numWords; i ++)
|
||||||
|
{
|
||||||
|
pData[i] = _swap16(pData[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // BIG_ENDIAN
|
||||||
|
// little-endian CPU, WAV file is ok as such
|
||||||
|
|
||||||
|
// dummy helper-function
|
||||||
|
static inline int _swap32(int &dwData)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
return dwData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dummy helper-function
|
||||||
|
static inline short _swap16(short &wData)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
return wData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dummy helper-function
|
||||||
|
static inline void _swap16Buffer(short *pData, int numBytes)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BIG_ENDIAN
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Class WavFileBase
|
||||||
|
//
|
||||||
|
|
||||||
|
WavFileBase::WavFileBase()
|
||||||
|
{
|
||||||
|
convBuff = NULL;
|
||||||
|
convBuffSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WavFileBase::~WavFileBase()
|
||||||
|
{
|
||||||
|
delete[] convBuff;
|
||||||
|
convBuffSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Get pointer to conversion buffer of at min. given size
|
||||||
|
void *WavFileBase::getConvBuffer(int sizeBytes)
|
||||||
|
{
|
||||||
|
if (convBuffSize < sizeBytes)
|
||||||
|
{
|
||||||
|
delete[] convBuff;
|
||||||
|
|
||||||
|
convBuffSize = (sizeBytes + 15) & -8; // round up to following 8-byte bounday
|
||||||
|
convBuff = new char[convBuffSize];
|
||||||
|
}
|
||||||
|
return convBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Class WavInFile
|
||||||
|
//
|
||||||
|
|
||||||
|
WavInFile::WavInFile(const char *fileName)
|
||||||
|
{
|
||||||
|
// Try to open the file for reading
|
||||||
|
fptr = fopen(fileName, "rb");
|
||||||
|
if (fptr == NULL)
|
||||||
|
{
|
||||||
|
// didn't succeed
|
||||||
|
string msg = "Error : Unable to open file \"";
|
||||||
|
msg += fileName;
|
||||||
|
msg += "\" for reading.";
|
||||||
|
ST_THROW_RT_ERROR(msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WavInFile::WavInFile(FILE *file)
|
||||||
|
{
|
||||||
|
// Try to open the file for reading
|
||||||
|
fptr = file;
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
// didn't succeed
|
||||||
|
string msg = "Error : Unable to access input stream for reading";
|
||||||
|
ST_THROW_RT_ERROR(msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Init the WAV file stream
|
||||||
|
void WavInFile::init()
|
||||||
|
{
|
||||||
|
int hdrsOk;
|
||||||
|
|
||||||
|
// assume file stream is already open
|
||||||
|
assert(fptr);
|
||||||
|
|
||||||
|
// Read the file headers
|
||||||
|
hdrsOk = readWavHeaders();
|
||||||
|
if (hdrsOk != 0)
|
||||||
|
{
|
||||||
|
// Something didn't match in the wav file headers
|
||||||
|
string msg = "Input file is corrupt or not a WAV file";
|
||||||
|
ST_THROW_RT_ERROR(msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore 'fixed' field value as 32bit signed linear data can have other value than 1.
|
||||||
|
if (header.format.fixed != 1)
|
||||||
|
{
|
||||||
|
string msg = "Input file uses unsupported encoding.";
|
||||||
|
ST_THROW_RT_ERROR(msg.c_str());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
dataRead = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WavInFile::~WavInFile()
|
||||||
|
{
|
||||||
|
if (fptr) fclose(fptr);
|
||||||
|
fptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WavInFile::rewind()
|
||||||
|
{
|
||||||
|
int hdrsOk;
|
||||||
|
|
||||||
|
fseek(fptr, 0, SEEK_SET);
|
||||||
|
hdrsOk = readWavHeaders();
|
||||||
|
assert(hdrsOk == 0);
|
||||||
|
dataRead = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::checkCharTags() const
|
||||||
|
{
|
||||||
|
// header.format.fmt should equal to 'fmt '
|
||||||
|
if (memcmp(fmtStr, header.format.fmt, 4) != 0) return -1;
|
||||||
|
// header.data.data_field should equal to 'data'
|
||||||
|
if (memcmp(dataStr, header.data.data_field, 4) != 0) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::read(unsigned char *buffer, int maxElems)
|
||||||
|
{
|
||||||
|
int numBytes;
|
||||||
|
uint afterDataRead;
|
||||||
|
|
||||||
|
// ensure it's 8 bit format
|
||||||
|
if (header.format.bits_per_sample != 8)
|
||||||
|
{
|
||||||
|
ST_THROW_RT_ERROR("Error: WavInFile::read(char*, int) works only with 8bit samples.");
|
||||||
|
}
|
||||||
|
assert(sizeof(char) == 1);
|
||||||
|
|
||||||
|
numBytes = maxElems;
|
||||||
|
afterDataRead = dataRead + numBytes;
|
||||||
|
if (afterDataRead > header.data.data_len)
|
||||||
|
{
|
||||||
|
// Don't read more samples than are marked available in header
|
||||||
|
numBytes = (int)header.data.data_len - (int)dataRead;
|
||||||
|
assert(numBytes >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(buffer);
|
||||||
|
numBytes = (int)fread(buffer, 1, numBytes, fptr);
|
||||||
|
dataRead += numBytes;
|
||||||
|
|
||||||
|
return numBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::read(short *buffer, int maxElems)
|
||||||
|
{
|
||||||
|
unsigned int afterDataRead;
|
||||||
|
int numBytes;
|
||||||
|
int numElems;
|
||||||
|
|
||||||
|
assert(buffer);
|
||||||
|
switch (header.format.bits_per_sample)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
// 8 bit format
|
||||||
|
unsigned char *temp = (unsigned char*)getConvBuffer(maxElems);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
numElems = read(temp, maxElems);
|
||||||
|
// convert from 8 to 16 bit
|
||||||
|
for (i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
buffer[i] = (short)(((short)temp[i] - 128) * 256);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
{
|
||||||
|
// 16 bit format
|
||||||
|
|
||||||
|
assert(sizeof(short) == 2);
|
||||||
|
|
||||||
|
numBytes = maxElems * 2;
|
||||||
|
afterDataRead = dataRead + numBytes;
|
||||||
|
if (afterDataRead > header.data.data_len)
|
||||||
|
{
|
||||||
|
// Don't read more samples than are marked available in header
|
||||||
|
numBytes = (int)header.data.data_len - (int)dataRead;
|
||||||
|
assert(numBytes >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
numBytes = (int)fread(buffer, 1, numBytes, fptr);
|
||||||
|
dataRead += numBytes;
|
||||||
|
numElems = numBytes / 2;
|
||||||
|
|
||||||
|
// 16bit samples, swap byte order if necessary
|
||||||
|
_swap16Buffer((short *)buffer, numElems);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
stringstream ss;
|
||||||
|
ss << "\nOnly 8/16 bit sample WAV files supported in integer compilation. Can't open WAV file with ";
|
||||||
|
ss << (int)header.format.bits_per_sample;
|
||||||
|
ss << " bit sample format. ";
|
||||||
|
ST_THROW_RT_ERROR(ss.str().c_str());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return numElems;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Read data in float format. Notice that when reading in float format
|
||||||
|
/// 8/16/24/32 bit sample formats are supported
|
||||||
|
int WavInFile::read(float *buffer, int maxElems)
|
||||||
|
{
|
||||||
|
unsigned int afterDataRead;
|
||||||
|
int numBytes;
|
||||||
|
int numElems;
|
||||||
|
int bytesPerSample;
|
||||||
|
|
||||||
|
assert(buffer);
|
||||||
|
|
||||||
|
bytesPerSample = header.format.bits_per_sample / 8;
|
||||||
|
if ((bytesPerSample < 1) || (bytesPerSample > 4))
|
||||||
|
{
|
||||||
|
stringstream ss;
|
||||||
|
ss << "\nOnly 8/16/24/32 bit sample WAV files supported. Can't open WAV file with ";
|
||||||
|
ss << (int)header.format.bits_per_sample;
|
||||||
|
ss << " bit sample format. ";
|
||||||
|
ST_THROW_RT_ERROR(ss.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
numBytes = maxElems * bytesPerSample;
|
||||||
|
afterDataRead = dataRead + numBytes;
|
||||||
|
if (afterDataRead > header.data.data_len)
|
||||||
|
{
|
||||||
|
// Don't read more samples than are marked available in header
|
||||||
|
numBytes = (int)header.data.data_len - (int)dataRead;
|
||||||
|
assert(numBytes >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// read raw data into temporary buffer
|
||||||
|
char *temp = (char*)getConvBuffer(numBytes);
|
||||||
|
numBytes = (int)fread(temp, 1, numBytes, fptr);
|
||||||
|
dataRead += numBytes;
|
||||||
|
|
||||||
|
numElems = numBytes / bytesPerSample;
|
||||||
|
|
||||||
|
// swap byte ordert & convert to float, depending on sample format
|
||||||
|
switch (bytesPerSample)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
unsigned char *temp2 = (unsigned char*)temp;
|
||||||
|
double conv = 1.0 / 128.0;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
buffer[i] = (float)(temp2[i] * conv - 1.0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
short *temp2 = (short*)temp;
|
||||||
|
double conv = 1.0 / 32768.0;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
short value = temp2[i];
|
||||||
|
buffer[i] = (float)(_swap16(value) * conv);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
char *temp2 = (char *)temp;
|
||||||
|
double conv = 1.0 / 8388608.0;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
int value = *((int*)temp2);
|
||||||
|
value = _swap32(value) & 0x00ffffff; // take 24 bits
|
||||||
|
value |= (value & 0x00800000) ? 0xff000000 : 0; // extend minus sign bits
|
||||||
|
buffer[i] = (float)(value * conv);
|
||||||
|
temp2 += 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
int *temp2 = (int *)temp;
|
||||||
|
double conv = 1.0 / 2147483648.0;
|
||||||
|
assert(sizeof(int) == 4);
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
int value = temp2[i];
|
||||||
|
buffer[i] = (float)(_swap32(value) * conv);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return numElems;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::eof() const
|
||||||
|
{
|
||||||
|
// return true if all data has been read or file eof has reached
|
||||||
|
return (dataRead == header.data.data_len || feof(fptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// test if character code is between a white space ' ' and little 'z'
|
||||||
|
static int isAlpha(char c)
|
||||||
|
{
|
||||||
|
return (c >= ' ' && c <= 'z') ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// test if all characters are between a white space ' ' and little 'z'
|
||||||
|
static int isAlphaStr(const char *str)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
|
||||||
|
c = str[0];
|
||||||
|
while (c)
|
||||||
|
{
|
||||||
|
if (isAlpha(c) == 0) return 0;
|
||||||
|
str ++;
|
||||||
|
c = str[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::readRIFFBlock()
|
||||||
|
{
|
||||||
|
if (fread(&(header.riff), sizeof(WavRiff), 1, fptr) != 1) return -1;
|
||||||
|
|
||||||
|
// swap 32bit data byte order if necessary
|
||||||
|
_swap32((int &)header.riff.package_len);
|
||||||
|
|
||||||
|
// header.riff.riff_char should equal to 'RIFF');
|
||||||
|
if (memcmp(riffStr, header.riff.riff_char, 4) != 0) return -1;
|
||||||
|
// header.riff.wave should equal to 'WAVE'
|
||||||
|
if (memcmp(waveStr, header.riff.wave, 4) != 0) return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::readHeaderBlock()
|
||||||
|
{
|
||||||
|
char label[5];
|
||||||
|
string sLabel;
|
||||||
|
|
||||||
|
// lead label string
|
||||||
|
if (fread(label, 1, 4, fptr) !=4) return -1;
|
||||||
|
label[4] = 0;
|
||||||
|
|
||||||
|
if (isAlphaStr(label) == 0) return -1; // not a valid label
|
||||||
|
|
||||||
|
// Decode blocks according to their label
|
||||||
|
if (strcmp(label, fmtStr) == 0)
|
||||||
|
{
|
||||||
|
int nLen, nDump;
|
||||||
|
|
||||||
|
// 'fmt ' block
|
||||||
|
memcpy(header.format.fmt, fmtStr, 4);
|
||||||
|
|
||||||
|
// read length of the format field
|
||||||
|
if (fread(&nLen, sizeof(int), 1, fptr) != 1) return -1;
|
||||||
|
// swap byte order if necessary
|
||||||
|
_swap32(nLen); // int format_len;
|
||||||
|
header.format.format_len = nLen;
|
||||||
|
|
||||||
|
// calculate how much length differs from expected
|
||||||
|
nDump = nLen - ((int)sizeof(header.format) - 8);
|
||||||
|
|
||||||
|
// if format_len is larger than expected, read only as much data as we've space for
|
||||||
|
if (nDump > 0)
|
||||||
|
{
|
||||||
|
nLen = sizeof(header.format) - 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// read data
|
||||||
|
if (fread(&(header.format.fixed), nLen, 1, fptr) != 1) return -1;
|
||||||
|
|
||||||
|
// swap byte order if necessary
|
||||||
|
_swap16(header.format.fixed); // short int fixed;
|
||||||
|
_swap16(header.format.channel_number); // short int channel_number;
|
||||||
|
_swap32((int &)header.format.sample_rate); // int sample_rate;
|
||||||
|
_swap32((int &)header.format.byte_rate); // int byte_rate;
|
||||||
|
_swap16(header.format.byte_per_sample); // short int byte_per_sample;
|
||||||
|
_swap16(header.format.bits_per_sample); // short int bits_per_sample;
|
||||||
|
|
||||||
|
// if format_len is larger than expected, skip the extra data
|
||||||
|
if (nDump > 0)
|
||||||
|
{
|
||||||
|
fseek(fptr, nDump, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(label, factStr) == 0)
|
||||||
|
{
|
||||||
|
int nLen, nDump;
|
||||||
|
|
||||||
|
// 'fact' block
|
||||||
|
memcpy(header.fact.fact_field, factStr, 4);
|
||||||
|
|
||||||
|
// read length of the fact field
|
||||||
|
if (fread(&nLen, sizeof(int), 1, fptr) != 1) return -1;
|
||||||
|
// swap byte order if necessary
|
||||||
|
_swap32(nLen); // int fact_len;
|
||||||
|
header.fact.fact_len = nLen;
|
||||||
|
|
||||||
|
// calculate how much length differs from expected
|
||||||
|
nDump = nLen - ((int)sizeof(header.fact) - 8);
|
||||||
|
|
||||||
|
// if format_len is larger than expected, read only as much data as we've space for
|
||||||
|
if (nDump > 0)
|
||||||
|
{
|
||||||
|
nLen = sizeof(header.fact) - 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// read data
|
||||||
|
if (fread(&(header.fact.fact_sample_len), nLen, 1, fptr) != 1) return -1;
|
||||||
|
|
||||||
|
// swap byte order if necessary
|
||||||
|
_swap32((int &)header.fact.fact_sample_len); // int sample_length;
|
||||||
|
|
||||||
|
// if fact_len is larger than expected, skip the extra data
|
||||||
|
if (nDump > 0)
|
||||||
|
{
|
||||||
|
fseek(fptr, nDump, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (strcmp(label, dataStr) == 0)
|
||||||
|
{
|
||||||
|
// 'data' block
|
||||||
|
memcpy(header.data.data_field, dataStr, 4);
|
||||||
|
if (fread(&(header.data.data_len), sizeof(uint), 1, fptr) != 1) return -1;
|
||||||
|
|
||||||
|
// swap byte order if necessary
|
||||||
|
_swap32((int &)header.data.data_len);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint len, i;
|
||||||
|
uint temp;
|
||||||
|
// unknown block
|
||||||
|
|
||||||
|
// read length
|
||||||
|
if (fread(&len, sizeof(len), 1, fptr) != 1) return -1;
|
||||||
|
// scan through the block
|
||||||
|
for (i = 0; i < len; i ++)
|
||||||
|
{
|
||||||
|
if (fread(&temp, 1, 1, fptr) != 1) return -1;
|
||||||
|
if (feof(fptr)) return -1; // unexpected eof
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WavInFile::readWavHeaders()
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
memset(&header, 0, sizeof(header));
|
||||||
|
|
||||||
|
res = readRIFFBlock();
|
||||||
|
if (res) return 1;
|
||||||
|
// read header blocks until data block is found
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// read header blocks
|
||||||
|
res = readHeaderBlock();
|
||||||
|
if (res < 0) return 1; // error in file structure
|
||||||
|
} while (res == 0);
|
||||||
|
// check that all required tags are legal
|
||||||
|
return checkCharTags();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getNumChannels() const
|
||||||
|
{
|
||||||
|
return header.format.channel_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getNumBits() const
|
||||||
|
{
|
||||||
|
return header.format.bits_per_sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getBytesPerSample() const
|
||||||
|
{
|
||||||
|
return getNumChannels() * getNumBits() / 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getSampleRate() const
|
||||||
|
{
|
||||||
|
return header.format.sample_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getDataSizeInBytes() const
|
||||||
|
{
|
||||||
|
return header.data.data_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getNumSamples() const
|
||||||
|
{
|
||||||
|
if (header.format.byte_per_sample == 0) return 0;
|
||||||
|
if (header.format.fixed > 1) return header.fact.fact_sample_len;
|
||||||
|
return header.data.data_len / (unsigned short)header.format.byte_per_sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint WavInFile::getLengthMS() const
|
||||||
|
{
|
||||||
|
double numSamples;
|
||||||
|
double sampleRate;
|
||||||
|
|
||||||
|
numSamples = (double)getNumSamples();
|
||||||
|
sampleRate = (double)getSampleRate();
|
||||||
|
|
||||||
|
return (uint)(1000.0 * numSamples / sampleRate + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Returns how many milliseconds of audio have so far been read from the file
|
||||||
|
uint WavInFile::getElapsedMS() const
|
||||||
|
{
|
||||||
|
return (uint)(1000.0 * (double)dataRead / (double)header.format.byte_rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Class WavOutFile
|
||||||
|
//
|
||||||
|
|
||||||
|
WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int channels)
|
||||||
|
{
|
||||||
|
bytesWritten = 0;
|
||||||
|
fptr = fopen(fileName, "wb");
|
||||||
|
if (fptr == NULL)
|
||||||
|
{
|
||||||
|
string msg = "Error : Unable to open file \"";
|
||||||
|
msg += fileName;
|
||||||
|
msg += "\" for writing.";
|
||||||
|
//pmsg = msg.c_str;
|
||||||
|
ST_THROW_RT_ERROR(msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
fillInHeader(sampleRate, bits, channels);
|
||||||
|
writeHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WavOutFile::WavOutFile(FILE *file, int sampleRate, int bits, int channels)
|
||||||
|
{
|
||||||
|
bytesWritten = 0;
|
||||||
|
fptr = file;
|
||||||
|
if (fptr == NULL)
|
||||||
|
{
|
||||||
|
string msg = "Error : Unable to access output file stream.";
|
||||||
|
ST_THROW_RT_ERROR(msg.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
fillInHeader(sampleRate, bits, channels);
|
||||||
|
writeHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
WavOutFile::~WavOutFile()
|
||||||
|
{
|
||||||
|
finishHeader();
|
||||||
|
if (fptr) fclose(fptr);
|
||||||
|
fptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WavOutFile::fillInHeader(uint sampleRate, uint bits, uint channels)
|
||||||
|
{
|
||||||
|
// fill in the 'riff' part..
|
||||||
|
|
||||||
|
// copy string 'RIFF' to riff_char
|
||||||
|
memcpy(&(header.riff.riff_char), riffStr, 4);
|
||||||
|
// package_len unknown so far
|
||||||
|
header.riff.package_len = 0;
|
||||||
|
// copy string 'WAVE' to wave
|
||||||
|
memcpy(&(header.riff.wave), waveStr, 4);
|
||||||
|
|
||||||
|
// fill in the 'format' part..
|
||||||
|
|
||||||
|
// copy string 'fmt ' to fmt
|
||||||
|
memcpy(&(header.format.fmt), fmtStr, 4);
|
||||||
|
|
||||||
|
header.format.format_len = 0x10;
|
||||||
|
header.format.fixed = 1;
|
||||||
|
header.format.channel_number = (short)channels;
|
||||||
|
header.format.sample_rate = (int)sampleRate;
|
||||||
|
header.format.bits_per_sample = (short)bits;
|
||||||
|
header.format.byte_per_sample = (short)(bits * channels / 8);
|
||||||
|
header.format.byte_rate = header.format.byte_per_sample * (int)sampleRate;
|
||||||
|
header.format.sample_rate = (int)sampleRate;
|
||||||
|
|
||||||
|
// fill in the 'fact' part...
|
||||||
|
memcpy(&(header.fact.fact_field), factStr, 4);
|
||||||
|
header.fact.fact_len = 4;
|
||||||
|
header.fact.fact_sample_len = 0;
|
||||||
|
|
||||||
|
// fill in the 'data' part..
|
||||||
|
|
||||||
|
// copy string 'data' to data_field
|
||||||
|
memcpy(&(header.data.data_field), dataStr, 4);
|
||||||
|
// data_len unknown so far
|
||||||
|
header.data.data_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WavOutFile::finishHeader()
|
||||||
|
{
|
||||||
|
// supplement the file length into the header structure
|
||||||
|
header.riff.package_len = bytesWritten + sizeof(WavHeader) - sizeof(WavRiff) + 4;
|
||||||
|
header.data.data_len = bytesWritten;
|
||||||
|
header.fact.fact_sample_len = bytesWritten / header.format.byte_per_sample;
|
||||||
|
|
||||||
|
writeHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WavOutFile::writeHeader()
|
||||||
|
{
|
||||||
|
WavHeader hdrTemp;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
// swap byte order if necessary
|
||||||
|
hdrTemp = header;
|
||||||
|
_swap32((int &)hdrTemp.riff.package_len);
|
||||||
|
_swap32((int &)hdrTemp.format.format_len);
|
||||||
|
_swap16((short &)hdrTemp.format.fixed);
|
||||||
|
_swap16((short &)hdrTemp.format.channel_number);
|
||||||
|
_swap32((int &)hdrTemp.format.sample_rate);
|
||||||
|
_swap32((int &)hdrTemp.format.byte_rate);
|
||||||
|
_swap16((short &)hdrTemp.format.byte_per_sample);
|
||||||
|
_swap16((short &)hdrTemp.format.bits_per_sample);
|
||||||
|
_swap32((int &)hdrTemp.data.data_len);
|
||||||
|
_swap32((int &)hdrTemp.fact.fact_len);
|
||||||
|
_swap32((int &)hdrTemp.fact.fact_sample_len);
|
||||||
|
|
||||||
|
// write the supplemented header in the beginning of the file
|
||||||
|
fseek(fptr, 0, SEEK_SET);
|
||||||
|
res = (int)fwrite(&hdrTemp, sizeof(hdrTemp), 1, fptr);
|
||||||
|
if (res != 1)
|
||||||
|
{
|
||||||
|
ST_THROW_RT_ERROR("Error while writing to a wav file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// jump back to the end of the file
|
||||||
|
fseek(fptr, 0, SEEK_END);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WavOutFile::write(const unsigned char *buffer, int numElems)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (header.format.bits_per_sample != 8)
|
||||||
|
{
|
||||||
|
ST_THROW_RT_ERROR("Error: WavOutFile::write(const char*, int) accepts only 8bit samples.");
|
||||||
|
}
|
||||||
|
assert(sizeof(char) == 1);
|
||||||
|
|
||||||
|
res = (int)fwrite(buffer, 1, numElems, fptr);
|
||||||
|
if (res != numElems)
|
||||||
|
{
|
||||||
|
ST_THROW_RT_ERROR("Error while writing to a wav file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesWritten += numElems;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WavOutFile::write(const short *buffer, int numElems)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
// 16 bit samples
|
||||||
|
if (numElems < 1) return; // nothing to do
|
||||||
|
|
||||||
|
switch (header.format.bits_per_sample)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
unsigned char *temp = (unsigned char *)getConvBuffer(numElems);
|
||||||
|
// convert from 16bit format to 8bit format
|
||||||
|
for (i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
temp[i] = (unsigned char)(buffer[i] / 256 + 128);
|
||||||
|
}
|
||||||
|
// write in 8bit format
|
||||||
|
write(temp, numElems);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
{
|
||||||
|
// 16bit format
|
||||||
|
|
||||||
|
// use temp buffer to swap byte order if necessary
|
||||||
|
short *pTemp = (short *)getConvBuffer(numElems * sizeof(short));
|
||||||
|
memcpy(pTemp, buffer, numElems * 2);
|
||||||
|
_swap16Buffer(pTemp, numElems);
|
||||||
|
|
||||||
|
res = (int)fwrite(pTemp, 2, numElems, fptr);
|
||||||
|
|
||||||
|
if (res != numElems)
|
||||||
|
{
|
||||||
|
ST_THROW_RT_ERROR("Error while writing to a wav file.");
|
||||||
|
}
|
||||||
|
bytesWritten += 2 * numElems;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
stringstream ss;
|
||||||
|
ss << "\nOnly 8/16 bit sample WAV files supported in integer compilation. Can't open WAV file with ";
|
||||||
|
ss << (int)header.format.bits_per_sample;
|
||||||
|
ss << " bit sample format. ";
|
||||||
|
ST_THROW_RT_ERROR(ss.str().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Convert from float to integer and saturate
|
||||||
|
inline int saturate(float fvalue, float minval, float maxval)
|
||||||
|
{
|
||||||
|
if (fvalue > maxval)
|
||||||
|
{
|
||||||
|
fvalue = maxval;
|
||||||
|
}
|
||||||
|
else if (fvalue < minval)
|
||||||
|
{
|
||||||
|
fvalue = minval;
|
||||||
|
}
|
||||||
|
return (int)fvalue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WavOutFile::write(const float *buffer, int numElems)
|
||||||
|
{
|
||||||
|
int numBytes;
|
||||||
|
int bytesPerSample;
|
||||||
|
|
||||||
|
if (numElems == 0) return;
|
||||||
|
|
||||||
|
bytesPerSample = header.format.bits_per_sample / 8;
|
||||||
|
numBytes = numElems * bytesPerSample;
|
||||||
|
short *temp = (short*)getConvBuffer(numBytes);
|
||||||
|
|
||||||
|
switch (bytesPerSample)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
unsigned char *temp2 = (unsigned char *)temp;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
temp2[i] = (unsigned char)saturate(buffer[i] * 128.0f + 128.0f, 0.0f, 255.0f);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
short *temp2 = (short *)temp;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
short value = (short)saturate(buffer[i] * 32768.0f, -32768.0f, 32767.0f);
|
||||||
|
temp2[i] = _swap16(value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
char *temp2 = (char *)temp;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
int value = saturate(buffer[i] * 8388608.0f, -8388608.0f, 8388607.0f);
|
||||||
|
*((int*)temp2) = _swap32(value);
|
||||||
|
temp2 += 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
int *temp2 = (int *)temp;
|
||||||
|
for (int i = 0; i < numElems; i ++)
|
||||||
|
{
|
||||||
|
int value = saturate(buffer[i] * 2147483648.0f, -2147483648.0f, 2147483647.0f);
|
||||||
|
temp2[i] = _swap32(value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
int res = (int)fwrite(temp, 1, numBytes, fptr);
|
||||||
|
|
||||||
|
if (res != numBytes)
|
||||||
|
{
|
||||||
|
ST_THROW_RT_ERROR("Error while writing to a wav file.");
|
||||||
|
}
|
||||||
|
bytesWritten += numBytes;
|
||||||
|
}
|
|
@ -16,10 +16,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
|
// Last changed : $Date: 2014-10-05 16:20:24 +0000 (Sun, 05 Oct 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: WavFile.h 63 2009-02-21 16:00:14Z oparviai $
|
// $Id: WavFile.h 200 2014-10-05 16:20:24Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -75,6 +75,14 @@ typedef struct
|
||||||
short bits_per_sample;
|
short bits_per_sample;
|
||||||
} WavFormat;
|
} WavFormat;
|
||||||
|
|
||||||
|
/// WAV audio file 'fact' section header
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char fact_field[4];
|
||||||
|
int fact_len;
|
||||||
|
uint fact_sample_len;
|
||||||
|
} WavFact;
|
||||||
|
|
||||||
/// WAV audio file 'data' section header
|
/// WAV audio file 'data' section header
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -88,19 +96,40 @@ typedef struct
|
||||||
{
|
{
|
||||||
WavRiff riff;
|
WavRiff riff;
|
||||||
WavFormat format;
|
WavFormat format;
|
||||||
|
WavFact fact;
|
||||||
WavData data;
|
WavData data;
|
||||||
} WavHeader;
|
} WavHeader;
|
||||||
|
|
||||||
|
|
||||||
|
/// Base class for processing WAV audio files.
|
||||||
|
class WavFileBase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/// Conversion working buffer;
|
||||||
|
char *convBuff;
|
||||||
|
int convBuffSize;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WavFileBase();
|
||||||
|
virtual ~WavFileBase();
|
||||||
|
|
||||||
|
/// Get pointer to conversion buffer of at min. given size
|
||||||
|
void *getConvBuffer(int sizeByte);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Class for reading WAV audio files.
|
/// Class for reading WAV audio files.
|
||||||
class WavInFile
|
class WavInFile : protected WavFileBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/// File pointer.
|
/// File pointer.
|
||||||
FILE *fptr;
|
FILE *fptr;
|
||||||
|
|
||||||
|
/// Position within the audio stream
|
||||||
|
long position;
|
||||||
|
|
||||||
/// Counter of how many bytes of sample data have been read from the file.
|
/// Counter of how many bytes of sample data have been read from the file.
|
||||||
uint dataRead;
|
long dataRead;
|
||||||
|
|
||||||
/// WAV header information
|
/// WAV header information
|
||||||
WavHeader header;
|
WavHeader header;
|
||||||
|
@ -158,12 +187,17 @@ public:
|
||||||
/// Get the audio file length in milliseconds
|
/// Get the audio file length in milliseconds
|
||||||
uint getLengthMS() const;
|
uint getLengthMS() const;
|
||||||
|
|
||||||
|
/// Returns how many milliseconds of audio have so far been read from the file
|
||||||
|
///
|
||||||
|
/// \return elapsed duration in milliseconds
|
||||||
|
uint getElapsedMS() const;
|
||||||
|
|
||||||
/// Reads audio samples from the WAV file. This routine works only for 8 bit samples.
|
/// Reads audio samples from the WAV file. This routine works only for 8 bit samples.
|
||||||
/// Reads given number of elements from the file or if end-of-file reached, as many
|
/// Reads given number of elements from the file or if end-of-file reached, as many
|
||||||
/// elements as are left in the file.
|
/// elements as are left in the file.
|
||||||
///
|
///
|
||||||
/// \return Number of 8-bit integers read from the file.
|
/// \return Number of 8-bit integers read from the file.
|
||||||
int read(char *buffer, int maxElems);
|
int read(unsigned char *buffer, int maxElems);
|
||||||
|
|
||||||
/// Reads audio samples from the WAV file to 16 bit integer format. Reads given number
|
/// Reads audio samples from the WAV file to 16 bit integer format. Reads given number
|
||||||
/// of elements from the file or if end-of-file reached, as many elements as are
|
/// of elements from the file or if end-of-file reached, as many elements as are
|
||||||
|
@ -177,6 +211,7 @@ public:
|
||||||
/// Reads audio samples from the WAV file to floating point format, converting
|
/// Reads audio samples from the WAV file to floating point format, converting
|
||||||
/// sample values to range [-1,1[. Reads given number of elements from the file
|
/// sample values to range [-1,1[. Reads given number of elements from the file
|
||||||
/// or if end-of-file reached, as many elements as are left in the file.
|
/// or if end-of-file reached, as many elements as are left in the file.
|
||||||
|
/// Notice that reading in float format supports 8/16/24/32bit sample formats.
|
||||||
///
|
///
|
||||||
/// \return Number of elements read from the file.
|
/// \return Number of elements read from the file.
|
||||||
int read(float *buffer, ///< Pointer to buffer where to read data.
|
int read(float *buffer, ///< Pointer to buffer where to read data.
|
||||||
|
@ -192,7 +227,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/// Class for writing WAV audio files.
|
/// Class for writing WAV audio files.
|
||||||
class WavOutFile
|
class WavOutFile : protected WavFileBase
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/// Pointer to the WAV file
|
/// Pointer to the WAV file
|
||||||
|
@ -230,7 +265,7 @@ public:
|
||||||
|
|
||||||
/// Write data to WAV file. This function works only with 8bit samples.
|
/// Write data to WAV file. This function works only with 8bit samples.
|
||||||
/// Throws a 'runtime_error' exception if writing to file fails.
|
/// Throws a 'runtime_error' exception if writing to file fails.
|
||||||
void write(const char *buffer, ///< Pointer to sample data buffer.
|
void write(const unsigned char *buffer, ///< Pointer to sample data buffer.
|
||||||
int numElems ///< How many array items are to be written to file.
|
int numElems ///< How many array items are to be written to file.
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2009-01-11 09:34:24 -0200 (dom, 11 jan 2009) $
|
// Last changed : $Date: 2014-01-05 21:40:22 +0000 (Sun, 05 Jan 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: AAFilter.cpp 45 2009-01-11 11:34:24Z oparviai $
|
// $Id: AAFilter.cpp 177 2014-01-05 21:40:22Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -52,6 +52,30 @@ using namespace soundtouch;
|
||||||
#define PI 3.141592655357989
|
#define PI 3.141592655357989
|
||||||
#define TWOPI (2 * PI)
|
#define TWOPI (2 * PI)
|
||||||
|
|
||||||
|
// define this to save AA filter coefficients to a file
|
||||||
|
// #define _DEBUG_SAVE_AAFILTER_COEFFICIENTS 1
|
||||||
|
|
||||||
|
#ifdef _DEBUG_SAVE_AAFILTER_COEFFICIENTS
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static void _DEBUG_SAVE_AAFIR_COEFFS(SAMPLETYPE *coeffs, int len)
|
||||||
|
{
|
||||||
|
FILE *fptr = fopen("aa_filter_coeffs.txt", "wt");
|
||||||
|
if (fptr == NULL) return;
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i ++)
|
||||||
|
{
|
||||||
|
double temp = coeffs[i];
|
||||||
|
fprintf(fptr, "%lf\n", temp);
|
||||||
|
}
|
||||||
|
fclose(fptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define _DEBUG_SAVE_AAFIR_COEFFS(x, y)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
* Implementation of the class 'AAFilter'
|
* Implementation of the class 'AAFilter'
|
||||||
|
@ -99,7 +123,7 @@ void AAFilter::calculateCoeffs()
|
||||||
{
|
{
|
||||||
uint i;
|
uint i;
|
||||||
double cntTemp, temp, tempCoeff,h, w;
|
double cntTemp, temp, tempCoeff,h, w;
|
||||||
double fc2, wc;
|
double wc;
|
||||||
double scaleCoeff, sum;
|
double scaleCoeff, sum;
|
||||||
double *work;
|
double *work;
|
||||||
SAMPLETYPE *coeffs;
|
SAMPLETYPE *coeffs;
|
||||||
|
@ -112,8 +136,7 @@ void AAFilter::calculateCoeffs()
|
||||||
work = new double[length];
|
work = new double[length];
|
||||||
coeffs = new SAMPLETYPE[length];
|
coeffs = new SAMPLETYPE[length];
|
||||||
|
|
||||||
fc2 = 2.0 * cutoffFreq;
|
wc = 2.0 * PI * cutoffFreq;
|
||||||
wc = PI * fc2;
|
|
||||||
tempCoeff = TWOPI / (double)length;
|
tempCoeff = TWOPI / (double)length;
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
|
@ -124,7 +147,7 @@ void AAFilter::calculateCoeffs()
|
||||||
temp = cntTemp * wc;
|
temp = cntTemp * wc;
|
||||||
if (temp != 0)
|
if (temp != 0)
|
||||||
{
|
{
|
||||||
h = fc2 * sin(temp) / temp; // sinc function
|
h = sin(temp) / temp; // sinc function
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -153,17 +176,21 @@ void AAFilter::calculateCoeffs()
|
||||||
|
|
||||||
for (i = 0; i < length; i ++)
|
for (i = 0; i < length; i ++)
|
||||||
{
|
{
|
||||||
// scale & round to nearest integer
|
|
||||||
temp = work[i] * scaleCoeff;
|
temp = work[i] * scaleCoeff;
|
||||||
|
//#if SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
// scale & round to nearest integer
|
||||||
temp += (temp >= 0) ? 0.5 : -0.5;
|
temp += (temp >= 0) ? 0.5 : -0.5;
|
||||||
// ensure no overfloods
|
// ensure no overfloods
|
||||||
assert(temp >= -32768 && temp <= 32767);
|
assert(temp >= -32768 && temp <= 32767);
|
||||||
|
//#endif
|
||||||
coeffs[i] = (SAMPLETYPE)temp;
|
coeffs[i] = (SAMPLETYPE)temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set coefficients. Use divide factor 14 => divide result by 2^14 = 16384
|
// Set coefficients. Use divide factor 14 => divide result by 2^14 = 16384
|
||||||
pFIR->setCoefficients(coeffs, length, 14);
|
pFIR->setCoefficients(coeffs, length, 14);
|
||||||
|
|
||||||
|
_DEBUG_SAVE_AAFIR_COEFFS(coeffs, length);
|
||||||
|
|
||||||
delete[] work;
|
delete[] work;
|
||||||
delete[] coeffs;
|
delete[] coeffs;
|
||||||
}
|
}
|
||||||
|
@ -178,6 +205,31 @@ uint AAFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Applies the filter to the given src & dest pipes, so that processed amount of
|
||||||
|
/// samples get removed from src, and produced amount added to dest
|
||||||
|
/// Note : The amount of outputted samples is by value of 'filter length'
|
||||||
|
/// smaller than the amount of input samples.
|
||||||
|
uint AAFilter::evaluate(FIFOSampleBuffer &dest, FIFOSampleBuffer &src) const
|
||||||
|
{
|
||||||
|
SAMPLETYPE *pdest;
|
||||||
|
const SAMPLETYPE *psrc;
|
||||||
|
uint numSrcSamples;
|
||||||
|
uint result;
|
||||||
|
int numChannels = src.getChannels();
|
||||||
|
|
||||||
|
assert(numChannels == dest.getChannels());
|
||||||
|
|
||||||
|
numSrcSamples = src.numSamples();
|
||||||
|
psrc = src.ptrBegin();
|
||||||
|
pdest = dest.ptrEnd(numSrcSamples);
|
||||||
|
result = pFIR->evaluate(pdest, psrc, numSrcSamples, numChannels);
|
||||||
|
src.receiveSamples(result);
|
||||||
|
dest.putSamples(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint AAFilter::getLength() const
|
uint AAFilter::getLength() const
|
||||||
{
|
{
|
||||||
return pFIR->getLength();
|
return pFIR->getLength();
|
|
@ -13,10 +13,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2008-02-10 14:26:55 -0200 (dom, 10 fev 2008) $
|
// Last changed : $Date: 2014-01-07 19:41:23 +0000 (Tue, 07 Jan 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: AAFilter.h 11 2008-02-10 16:26:55Z oparviai $
|
// $Id: AAFilter.h 187 2014-01-07 19:41:23Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -45,6 +45,7 @@
|
||||||
#define AAFilter_H
|
#define AAFilter_H
|
||||||
|
|
||||||
#include "STTypes.h"
|
#include "STTypes.h"
|
||||||
|
#include "FIFOSampleBuffer.h"
|
||||||
|
|
||||||
namespace soundtouch
|
namespace soundtouch
|
||||||
{
|
{
|
||||||
|
@ -84,6 +85,14 @@ public:
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples,
|
uint numSamples,
|
||||||
uint numChannels) const;
|
uint numChannels) const;
|
||||||
|
|
||||||
|
/// Applies the filter to the given src & dest pipes, so that processed amount of
|
||||||
|
/// samples get removed from src, and produced amount added to dest
|
||||||
|
/// Note : The amount of outputted samples is by value of 'filter length'
|
||||||
|
/// smaller than the amount of input samples.
|
||||||
|
uint evaluate(FIFOSampleBuffer &dest,
|
||||||
|
FIFOSampleBuffer &src) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,10 +26,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-08-30 16:45:25 -0300 (qui, 30 ago 2012) $
|
// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: BPMDetect.cpp 149 2012-08-30 19:45:25Z oparviai $
|
// $Id: BPMDetect.cpp 202 2015-02-21 21:24:29Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -226,6 +226,7 @@ void BPMDetect::updateXCorr(int process_samples)
|
||||||
assert(buffer->numSamples() >= (uint)(process_samples + windowLen));
|
assert(buffer->numSamples() >= (uint)(process_samples + windowLen));
|
||||||
|
|
||||||
pBuffer = buffer->ptrBegin();
|
pBuffer = buffer->ptrBegin();
|
||||||
|
#pragma omp parallel for
|
||||||
for (offs = windowStart; offs < windowLen; offs ++)
|
for (offs = windowStart; offs < windowLen; offs ++)
|
||||||
{
|
{
|
||||||
LONG_SAMPLETYPE sum;
|
LONG_SAMPLETYPE sum;
|
|
@ -15,7 +15,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 16:53:01 -0200 (qui, 08 nov 2012) $
|
// Last changed : $Date: 2012-11-08 18:53:01 +0000 (Thu, 08 Nov 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIFOSampleBuffer.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: FIFOSampleBuffer.cpp 160 2012-11-08 18:53:01Z oparviai $
|
|
@ -11,10 +11,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-09-02 15:56:11 -0300 (sex, 02 set 2011) $
|
// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIRFilter.cpp 131 2011-09-02 18:56:11Z oparviai $
|
// $Id: FIRFilter.cpp 202 2015-02-21 21:24:29Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -72,8 +72,7 @@ FIRFilter::~FIRFilter()
|
||||||
// Usual C-version of the filter routine for stereo sound
|
// Usual C-version of the filter routine for stereo sound
|
||||||
uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
||||||
{
|
{
|
||||||
uint i, j, end;
|
int j, end;
|
||||||
LONG_SAMPLETYPE suml, sumr;
|
|
||||||
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
// when using floating point samples, use a scaler instead of a divider
|
// when using floating point samples, use a scaler instead of a divider
|
||||||
// because division is much slower operation than multiplying.
|
// because division is much slower operation than multiplying.
|
||||||
|
@ -87,9 +86,12 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
|
||||||
|
|
||||||
end = 2 * (numSamples - length);
|
end = 2 * (numSamples - length);
|
||||||
|
|
||||||
|
#pragma omp parallel for
|
||||||
for (j = 0; j < end; j += 2)
|
for (j = 0; j < end; j += 2)
|
||||||
{
|
{
|
||||||
const SAMPLETYPE *ptr;
|
const SAMPLETYPE *ptr;
|
||||||
|
LONG_SAMPLETYPE suml, sumr;
|
||||||
|
uint i;
|
||||||
|
|
||||||
suml = sumr = 0;
|
suml = sumr = 0;
|
||||||
ptr = src + j;
|
ptr = src + j;
|
||||||
|
@ -130,28 +132,31 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
|
||||||
// Usual C-version of the filter routine for mono sound
|
// Usual C-version of the filter routine for mono sound
|
||||||
uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
|
||||||
{
|
{
|
||||||
uint i, j, end;
|
int j, end;
|
||||||
LONG_SAMPLETYPE sum;
|
|
||||||
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
// when using floating point samples, use a scaler instead of a divider
|
// when using floating point samples, use a scaler instead of a divider
|
||||||
// because division is much slower operation than multiplying.
|
// because division is much slower operation than multiplying.
|
||||||
double dScaler = 1.0 / (double)resultDivider;
|
double dScaler = 1.0 / (double)resultDivider;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
assert(length != 0);
|
assert(length != 0);
|
||||||
|
|
||||||
end = numSamples - length;
|
end = numSamples - length;
|
||||||
|
#pragma omp parallel for
|
||||||
for (j = 0; j < end; j ++)
|
for (j = 0; j < end; j ++)
|
||||||
{
|
{
|
||||||
|
const SAMPLETYPE *pSrc = src + j;
|
||||||
|
LONG_SAMPLETYPE sum;
|
||||||
|
uint i;
|
||||||
|
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (i = 0; i < length; i += 4)
|
for (i = 0; i < length; i += 4)
|
||||||
{
|
{
|
||||||
// loop is unrolled by factor of 4 here for efficiency
|
// loop is unrolled by factor of 4 here for efficiency
|
||||||
sum += src[i + 0] * filterCoeffs[i + 0] +
|
sum += pSrc[i + 0] * filterCoeffs[i + 0] +
|
||||||
src[i + 1] * filterCoeffs[i + 1] +
|
pSrc[i + 1] * filterCoeffs[i + 1] +
|
||||||
src[i + 2] * filterCoeffs[i + 2] +
|
pSrc[i + 2] * filterCoeffs[i + 2] +
|
||||||
src[i + 3] * filterCoeffs[i + 3];
|
pSrc[i + 3] * filterCoeffs[i + 3];
|
||||||
}
|
}
|
||||||
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
|
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
sum >>= resultDivFactor;
|
sum >>= resultDivFactor;
|
||||||
|
@ -161,12 +166,67 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
|
||||||
sum *= dScaler;
|
sum *= dScaler;
|
||||||
#endif // SOUNDTOUCH_INTEGER_SAMPLES
|
#endif // SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
dest[j] = (SAMPLETYPE)sum;
|
dest[j] = (SAMPLETYPE)sum;
|
||||||
src ++;
|
|
||||||
}
|
}
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels)
|
||||||
|
{
|
||||||
|
int j, end;
|
||||||
|
|
||||||
|
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
|
// when using floating point samples, use a scaler instead of a divider
|
||||||
|
// because division is much slower operation than multiplying.
|
||||||
|
double dScaler = 1.0 / (double)resultDivider;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
assert(length != 0);
|
||||||
|
assert(src != NULL);
|
||||||
|
assert(dest != NULL);
|
||||||
|
assert(filterCoeffs != NULL);
|
||||||
|
assert(numChannels < 16);
|
||||||
|
|
||||||
|
end = numChannels * (numSamples - length);
|
||||||
|
|
||||||
|
#pragma omp parallel for
|
||||||
|
for (j = 0; j < end; j += numChannels)
|
||||||
|
{
|
||||||
|
const SAMPLETYPE *ptr;
|
||||||
|
LONG_SAMPLETYPE sums[16];
|
||||||
|
uint c, i;
|
||||||
|
|
||||||
|
for (c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
sums[c] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = src + j;
|
||||||
|
|
||||||
|
for (i = 0; i < length; i ++)
|
||||||
|
{
|
||||||
|
SAMPLETYPE coef=filterCoeffs[i];
|
||||||
|
for (c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
sums[c] += ptr[0] * coef;
|
||||||
|
ptr ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
sums[c] >>= resultDivFactor;
|
||||||
|
#else
|
||||||
|
sums[c] *= dScaler;
|
||||||
|
#endif // SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
dest[j+c] = (SAMPLETYPE)sums[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return numSamples - length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set filter coeffiecients and length.
|
// Set filter coeffiecients and length.
|
||||||
//
|
//
|
||||||
// Throws an exception if filter length isn't divisible by 8
|
// Throws an exception if filter length isn't divisible by 8
|
||||||
|
@ -199,18 +259,27 @@ uint FIRFilter::getLength() const
|
||||||
//
|
//
|
||||||
// Note : The amount of outputted samples is by value of 'filter_length'
|
// Note : The amount of outputted samples is by value of 'filter_length'
|
||||||
// smaller than the amount of input samples.
|
// smaller than the amount of input samples.
|
||||||
uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
|
uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels)
|
||||||
{
|
{
|
||||||
assert(numChannels == 1 || numChannels == 2);
|
|
||||||
|
|
||||||
assert(length > 0);
|
assert(length > 0);
|
||||||
assert(lengthDiv8 * 8 == length);
|
assert(lengthDiv8 * 8 == length);
|
||||||
|
|
||||||
if (numSamples < length) return 0;
|
if (numSamples < length) return 0;
|
||||||
if (numChannels == 2)
|
|
||||||
|
#ifndef USE_MULTICH_ALWAYS
|
||||||
|
if (numChannels == 1)
|
||||||
|
{
|
||||||
|
return evaluateFilterMono(dest, src, numSamples);
|
||||||
|
}
|
||||||
|
else if (numChannels == 2)
|
||||||
{
|
{
|
||||||
return evaluateFilterStereo(dest, src, numSamples);
|
return evaluateFilterStereo(dest, src, numSamples);
|
||||||
} else {
|
}
|
||||||
return evaluateFilterMono(dest, src, numSamples);
|
else
|
||||||
|
#endif // USE_MULTICH_ALWAYS
|
||||||
|
{
|
||||||
|
assert(numChannels > 0);
|
||||||
|
return evaluateFilterMulti(dest, src, numSamples, numChannels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-02-13 17:13:57 -0200 (dom, 13 fev 2011) $
|
// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIRFilter.h 104 2011-02-13 19:13:57Z oparviai $
|
// $Id: FIRFilter.h 202 2015-02-21 21:24:29Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -71,6 +71,7 @@ protected:
|
||||||
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
|
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples) const;
|
uint numSamples) const;
|
||||||
|
virtual uint evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FIRFilter();
|
FIRFilter();
|
||||||
|
@ -90,7 +91,7 @@ public:
|
||||||
uint evaluate(SAMPLETYPE *dest,
|
uint evaluate(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples,
|
uint numSamples,
|
||||||
uint numChannels) const;
|
uint numChannels);
|
||||||
|
|
||||||
uint getLength() const;
|
uint getLength() const;
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Cubic interpolation routine.
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// $Id: InterpolateCubic.cpp 179 2014-01-06 18:41:42Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "InterpolateCubic.h"
|
||||||
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
using namespace soundtouch;
|
||||||
|
|
||||||
|
// cubic interpolation coefficients
|
||||||
|
static const float _coeffs[]=
|
||||||
|
{ -0.5f, 1.0f, -0.5f, 0.0f,
|
||||||
|
1.5f, -2.5f, 0.0f, 1.0f,
|
||||||
|
-1.5f, 2.0f, 0.5f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.0f, 0.0f};
|
||||||
|
|
||||||
|
|
||||||
|
InterpolateCubic::InterpolateCubic()
|
||||||
|
{
|
||||||
|
fract = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InterpolateCubic::resetRegisters()
|
||||||
|
{
|
||||||
|
fract = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Transpose mono audio. Returns number of produced output samples, and
|
||||||
|
/// updates "srcSamples" to amount of consumed source samples
|
||||||
|
int InterpolateCubic::transposeMono(SAMPLETYPE *pdest,
|
||||||
|
const SAMPLETYPE *psrc,
|
||||||
|
int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 4;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
float out;
|
||||||
|
const float x3 = 1.0f;
|
||||||
|
const float x2 = (float)fract; // x
|
||||||
|
const float x1 = x2*x2; // x^2
|
||||||
|
const float x0 = x1*x2; // x^3
|
||||||
|
float y0, y1, y2, y3;
|
||||||
|
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
y0 = _coeffs[0] * x0 + _coeffs[1] * x1 + _coeffs[2] * x2 + _coeffs[3] * x3;
|
||||||
|
y1 = _coeffs[4] * x0 + _coeffs[5] * x1 + _coeffs[6] * x2 + _coeffs[7] * x3;
|
||||||
|
y2 = _coeffs[8] * x0 + _coeffs[9] * x1 + _coeffs[10] * x2 + _coeffs[11] * x3;
|
||||||
|
y3 = _coeffs[12] * x0 + _coeffs[13] * x1 + _coeffs[14] * x2 + _coeffs[15] * x3;
|
||||||
|
|
||||||
|
out = y0 * psrc[0] + y1 * psrc[1] + y2 * psrc[2] + y3 * psrc[3];
|
||||||
|
|
||||||
|
pdest[i] = (SAMPLETYPE)out;
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
psrc += whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Transpose stereo audio. Returns number of produced output samples, and
|
||||||
|
/// updates "srcSamples" to amount of consumed source samples
|
||||||
|
int InterpolateCubic::transposeStereo(SAMPLETYPE *pdest,
|
||||||
|
const SAMPLETYPE *psrc,
|
||||||
|
int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 4;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
const float x3 = 1.0f;
|
||||||
|
const float x2 = (float)fract; // x
|
||||||
|
const float x1 = x2*x2; // x^2
|
||||||
|
const float x0 = x1*x2; // x^3
|
||||||
|
float y0, y1, y2, y3;
|
||||||
|
float out0, out1;
|
||||||
|
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
y0 = _coeffs[0] * x0 + _coeffs[1] * x1 + _coeffs[2] * x2 + _coeffs[3] * x3;
|
||||||
|
y1 = _coeffs[4] * x0 + _coeffs[5] * x1 + _coeffs[6] * x2 + _coeffs[7] * x3;
|
||||||
|
y2 = _coeffs[8] * x0 + _coeffs[9] * x1 + _coeffs[10] * x2 + _coeffs[11] * x3;
|
||||||
|
y3 = _coeffs[12] * x0 + _coeffs[13] * x1 + _coeffs[14] * x2 + _coeffs[15] * x3;
|
||||||
|
|
||||||
|
out0 = y0 * psrc[0] + y1 * psrc[2] + y2 * psrc[4] + y3 * psrc[6];
|
||||||
|
out1 = y0 * psrc[1] + y1 * psrc[3] + y2 * psrc[5] + y3 * psrc[7];
|
||||||
|
|
||||||
|
pdest[2*i] = (SAMPLETYPE)out0;
|
||||||
|
pdest[2*i+1] = (SAMPLETYPE)out1;
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
psrc += 2*whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Transpose multi-channel audio. Returns number of produced output samples, and
|
||||||
|
/// updates "srcSamples" to amount of consumed source samples
|
||||||
|
int InterpolateCubic::transposeMulti(SAMPLETYPE *pdest,
|
||||||
|
const SAMPLETYPE *psrc,
|
||||||
|
int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 4;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
const float x3 = 1.0f;
|
||||||
|
const float x2 = (float)fract; // x
|
||||||
|
const float x1 = x2*x2; // x^2
|
||||||
|
const float x0 = x1*x2; // x^3
|
||||||
|
float y0, y1, y2, y3;
|
||||||
|
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
y0 = _coeffs[0] * x0 + _coeffs[1] * x1 + _coeffs[2] * x2 + _coeffs[3] * x3;
|
||||||
|
y1 = _coeffs[4] * x0 + _coeffs[5] * x1 + _coeffs[6] * x2 + _coeffs[7] * x3;
|
||||||
|
y2 = _coeffs[8] * x0 + _coeffs[9] * x1 + _coeffs[10] * x2 + _coeffs[11] * x3;
|
||||||
|
y3 = _coeffs[12] * x0 + _coeffs[13] * x1 + _coeffs[14] * x2 + _coeffs[15] * x3;
|
||||||
|
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
float out;
|
||||||
|
out = y0 * psrc[c] + y1 * psrc[c + numChannels] + y2 * psrc[c + 2 * numChannels] + y3 * psrc[c + 3 * numChannels];
|
||||||
|
pdest[0] = (SAMPLETYPE)out;
|
||||||
|
pdest ++;
|
||||||
|
}
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
psrc += numChannels*whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Cubic interpolation routine.
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// $Id: InterpolateCubic.h 179 2014-01-06 18:41:42Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _InterpolateCubic_H_
|
||||||
|
#define _InterpolateCubic_H_
|
||||||
|
|
||||||
|
#include "RateTransposer.h"
|
||||||
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
namespace soundtouch
|
||||||
|
{
|
||||||
|
|
||||||
|
class InterpolateCubic : public TransposerBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
virtual void resetRegisters();
|
||||||
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
virtual int transposeMulti(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
|
||||||
|
float fract;
|
||||||
|
|
||||||
|
public:
|
||||||
|
InterpolateCubic();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,299 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Linear interpolation algorithm.
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// $Id: InterpolateLinear.cpp 180 2014-01-06 19:16:02Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "InterpolateLinear.h"
|
||||||
|
|
||||||
|
using namespace soundtouch;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// InterpolateLinearInteger - integer arithmetic implementation
|
||||||
|
//
|
||||||
|
|
||||||
|
/// fixed-point interpolation routine precision
|
||||||
|
#define SCALE 65536
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
InterpolateLinearInteger::InterpolateLinearInteger() : TransposerBase()
|
||||||
|
{
|
||||||
|
// Notice: use local function calling syntax for sake of clarity,
|
||||||
|
// to indicate the fact that C++ constructor can't call virtual functions.
|
||||||
|
resetRegisters();
|
||||||
|
setRate(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InterpolateLinearInteger::resetRegisters()
|
||||||
|
{
|
||||||
|
iFract = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
|
// 'Mono' version of the routine. Returns the number of samples returned in
|
||||||
|
// the "dest" buffer
|
||||||
|
int InterpolateLinearInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
LONG_SAMPLETYPE temp;
|
||||||
|
|
||||||
|
assert(iFract < SCALE);
|
||||||
|
|
||||||
|
temp = (SCALE - iFract) * src[0] + iFract * src[1];
|
||||||
|
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
i++;
|
||||||
|
|
||||||
|
iFract += iRate;
|
||||||
|
|
||||||
|
int iWhole = iFract / SCALE;
|
||||||
|
iFract -= iWhole * SCALE;
|
||||||
|
srcCount += iWhole;
|
||||||
|
src += iWhole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
|
// 'Stereo' version of the routine. Returns the number of samples returned in
|
||||||
|
// the "dest" buffer
|
||||||
|
int InterpolateLinearInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
LONG_SAMPLETYPE temp0;
|
||||||
|
LONG_SAMPLETYPE temp1;
|
||||||
|
|
||||||
|
assert(iFract < SCALE);
|
||||||
|
|
||||||
|
temp0 = (SCALE - iFract) * src[0] + iFract * src[2];
|
||||||
|
temp1 = (SCALE - iFract) * src[1] + iFract * src[3];
|
||||||
|
dest[0] = (SAMPLETYPE)(temp0 / SCALE);
|
||||||
|
dest[1] = (SAMPLETYPE)(temp1 / SCALE);
|
||||||
|
dest += 2;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
iFract += iRate;
|
||||||
|
|
||||||
|
int iWhole = iFract / SCALE;
|
||||||
|
iFract -= iWhole * SCALE;
|
||||||
|
srcCount += iWhole;
|
||||||
|
src += 2*iWhole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InterpolateLinearInteger::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
LONG_SAMPLETYPE temp, vol1;
|
||||||
|
|
||||||
|
assert(iFract < SCALE);
|
||||||
|
vol1 = (SCALE - iFract);
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
temp = vol1 * src[c] + iFract * src[c + numChannels];
|
||||||
|
dest[0] = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
dest ++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
|
||||||
|
iFract += iRate;
|
||||||
|
|
||||||
|
int iWhole = iFract / SCALE;
|
||||||
|
iFract -= iWhole * SCALE;
|
||||||
|
srcCount += iWhole;
|
||||||
|
src += iWhole * numChannels;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
||||||
|
// iRate, larger faster iRates.
|
||||||
|
void InterpolateLinearInteger::setRate(float newRate)
|
||||||
|
{
|
||||||
|
iRate = (int)(newRate * SCALE + 0.5f);
|
||||||
|
TransposerBase::setRate(newRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// InterpolateLinearFloat - floating point arithmetic implementation
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
InterpolateLinearFloat::InterpolateLinearFloat() : TransposerBase()
|
||||||
|
{
|
||||||
|
// Notice: use local function calling syntax for sake of clarity,
|
||||||
|
// to indicate the fact that C++ constructor can't call virtual functions.
|
||||||
|
resetRegisters();
|
||||||
|
setRate(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InterpolateLinearFloat::resetRegisters()
|
||||||
|
{
|
||||||
|
fract = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
|
// 'Mono' version of the routine. Returns the number of samples returned in
|
||||||
|
// the "dest" buffer
|
||||||
|
int InterpolateLinearFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
double out;
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
out = (1.0 - fract) * src[0] + fract * src[1];
|
||||||
|
dest[i] = (SAMPLETYPE)out;
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
src += whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
|
// 'Mono' version of the routine. Returns the number of samples returned in
|
||||||
|
// the "dest" buffer
|
||||||
|
int InterpolateLinearFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
double out0, out1;
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
out0 = (1.0 - fract) * src[0] + fract * src[2];
|
||||||
|
out1 = (1.0 - fract) * src[1] + fract * src[3];
|
||||||
|
dest[2*i] = (SAMPLETYPE)out0;
|
||||||
|
dest[2*i+1] = (SAMPLETYPE)out1;
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
src += 2*whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InterpolateLinearFloat::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
float temp, vol1;
|
||||||
|
|
||||||
|
vol1 = (1.0f- fract);
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
temp = vol1 * src[c] + fract * src[c + numChannels];
|
||||||
|
*dest = (SAMPLETYPE)temp;
|
||||||
|
dest ++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
|
||||||
|
fract += rate;
|
||||||
|
|
||||||
|
int iWhole = (int)fract;
|
||||||
|
fract -= iWhole;
|
||||||
|
srcCount += iWhole;
|
||||||
|
src += iWhole * numChannels;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Linear interpolation routine.
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// $Id: InterpolateLinear.h 179 2014-01-06 18:41:42Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _InterpolateLinear_H_
|
||||||
|
#define _InterpolateLinear_H_
|
||||||
|
|
||||||
|
#include "RateTransposer.h"
|
||||||
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
namespace soundtouch
|
||||||
|
{
|
||||||
|
|
||||||
|
/// Linear transposer class that uses integer arithmetics
|
||||||
|
class InterpolateLinearInteger : public TransposerBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
int iFract;
|
||||||
|
int iRate;
|
||||||
|
|
||||||
|
virtual void resetRegisters();
|
||||||
|
|
||||||
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples);
|
||||||
|
public:
|
||||||
|
InterpolateLinearInteger();
|
||||||
|
|
||||||
|
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
|
||||||
|
/// rate, larger faster rates.
|
||||||
|
virtual void setRate(float newRate);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// Linear transposer class that uses floating point arithmetics
|
||||||
|
class InterpolateLinearFloat : public TransposerBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
float fract;
|
||||||
|
|
||||||
|
virtual void resetRegisters();
|
||||||
|
|
||||||
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples);
|
||||||
|
|
||||||
|
public:
|
||||||
|
InterpolateLinearFloat();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,185 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Sample interpolation routine using 8-tap band-limited Shannon interpolation
|
||||||
|
/// with kaiser window.
|
||||||
|
///
|
||||||
|
/// Notice. This algorithm is remarkably much heavier than linear or cubic
|
||||||
|
/// interpolation, and not remarkably better than cubic algorithm. Thus mostly
|
||||||
|
/// for experimental purposes
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// $Id: InterpolateShannon.cpp 195 2014-04-06 15:57:21Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include "InterpolateShannon.h"
|
||||||
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
using namespace soundtouch;
|
||||||
|
|
||||||
|
|
||||||
|
/// Kaiser window with beta = 2.0
|
||||||
|
/// Values scaled down by 5% to avoid overflows
|
||||||
|
static const double _kaiser8[8] =
|
||||||
|
{
|
||||||
|
0.41778693317814,
|
||||||
|
0.64888025049173,
|
||||||
|
0.83508562409944,
|
||||||
|
0.93887857733412,
|
||||||
|
0.93887857733412,
|
||||||
|
0.83508562409944,
|
||||||
|
0.64888025049173,
|
||||||
|
0.41778693317814
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
InterpolateShannon::InterpolateShannon()
|
||||||
|
{
|
||||||
|
fract = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InterpolateShannon::resetRegisters()
|
||||||
|
{
|
||||||
|
fract = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define PI 3.1415926536
|
||||||
|
#define sinc(x) (sin(PI * (x)) / (PI * (x)))
|
||||||
|
|
||||||
|
/// Transpose mono audio. Returns number of produced output samples, and
|
||||||
|
/// updates "srcSamples" to amount of consumed source samples
|
||||||
|
int InterpolateShannon::transposeMono(SAMPLETYPE *pdest,
|
||||||
|
const SAMPLETYPE *psrc,
|
||||||
|
int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 8;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
double out;
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
out = psrc[0] * sinc(-3.0 - fract) * _kaiser8[0];
|
||||||
|
out += psrc[1] * sinc(-2.0 - fract) * _kaiser8[1];
|
||||||
|
out += psrc[2] * sinc(-1.0 - fract) * _kaiser8[2];
|
||||||
|
if (fract < 1e-6)
|
||||||
|
{
|
||||||
|
out += psrc[3] * _kaiser8[3]; // sinc(0) = 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out += psrc[3] * sinc(- fract) * _kaiser8[3];
|
||||||
|
}
|
||||||
|
out += psrc[4] * sinc( 1.0 - fract) * _kaiser8[4];
|
||||||
|
out += psrc[5] * sinc( 2.0 - fract) * _kaiser8[5];
|
||||||
|
out += psrc[6] * sinc( 3.0 - fract) * _kaiser8[6];
|
||||||
|
out += psrc[7] * sinc( 4.0 - fract) * _kaiser8[7];
|
||||||
|
|
||||||
|
pdest[i] = (SAMPLETYPE)out;
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
psrc += whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Transpose stereo audio. Returns number of produced output samples, and
|
||||||
|
/// updates "srcSamples" to amount of consumed source samples
|
||||||
|
int InterpolateShannon::transposeStereo(SAMPLETYPE *pdest,
|
||||||
|
const SAMPLETYPE *psrc,
|
||||||
|
int &srcSamples)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int srcSampleEnd = srcSamples - 8;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
double out0, out1, w;
|
||||||
|
assert(fract < 1.0);
|
||||||
|
|
||||||
|
w = sinc(-3.0 - fract) * _kaiser8[0];
|
||||||
|
out0 = psrc[0] * w; out1 = psrc[1] * w;
|
||||||
|
w = sinc(-2.0 - fract) * _kaiser8[1];
|
||||||
|
out0 += psrc[2] * w; out1 += psrc[3] * w;
|
||||||
|
w = sinc(-1.0 - fract) * _kaiser8[2];
|
||||||
|
out0 += psrc[4] * w; out1 += psrc[5] * w;
|
||||||
|
w = _kaiser8[3] * ((fract < 1e-5) ? 1.0 : sinc(- fract)); // sinc(0) = 1
|
||||||
|
out0 += psrc[6] * w; out1 += psrc[7] * w;
|
||||||
|
w = sinc( 1.0 - fract) * _kaiser8[4];
|
||||||
|
out0 += psrc[8] * w; out1 += psrc[9] * w;
|
||||||
|
w = sinc( 2.0 - fract) * _kaiser8[5];
|
||||||
|
out0 += psrc[10] * w; out1 += psrc[11] * w;
|
||||||
|
w = sinc( 3.0 - fract) * _kaiser8[6];
|
||||||
|
out0 += psrc[12] * w; out1 += psrc[13] * w;
|
||||||
|
w = sinc( 4.0 - fract) * _kaiser8[7];
|
||||||
|
out0 += psrc[14] * w; out1 += psrc[15] * w;
|
||||||
|
|
||||||
|
pdest[2*i] = (SAMPLETYPE)out0;
|
||||||
|
pdest[2*i+1] = (SAMPLETYPE)out1;
|
||||||
|
i ++;
|
||||||
|
|
||||||
|
// update position fraction
|
||||||
|
fract += rate;
|
||||||
|
// update whole positions
|
||||||
|
int whole = (int)fract;
|
||||||
|
fract -= whole;
|
||||||
|
psrc += 2*whole;
|
||||||
|
srcCount += whole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Transpose stereo audio. Returns number of produced output samples, and
|
||||||
|
/// updates "srcSamples" to amount of consumed source samples
|
||||||
|
int InterpolateShannon::transposeMulti(SAMPLETYPE *pdest,
|
||||||
|
const SAMPLETYPE *psrc,
|
||||||
|
int &srcSamples)
|
||||||
|
{
|
||||||
|
// not implemented
|
||||||
|
assert(false);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Sample interpolation routine using 8-tap band-limited Shannon interpolation
|
||||||
|
/// with kaiser window.
|
||||||
|
///
|
||||||
|
/// Notice. This algorithm is remarkably much heavier than linear or cubic
|
||||||
|
/// interpolation, and not remarkably better than cubic algorithm. Thus mostly
|
||||||
|
/// for experimental purposes
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// $Id: InterpolateShannon.h 179 2014-01-06 18:41:42Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _InterpolateShannon_H_
|
||||||
|
#define _InterpolateShannon_H_
|
||||||
|
|
||||||
|
#include "RateTransposer.h"
|
||||||
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
namespace soundtouch
|
||||||
|
{
|
||||||
|
|
||||||
|
class InterpolateShannon : public TransposerBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void resetRegisters();
|
||||||
|
int transposeMono(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
int transposeStereo(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
int transposeMulti(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples);
|
||||||
|
|
||||||
|
float fract;
|
||||||
|
|
||||||
|
public:
|
||||||
|
InterpolateShannon();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -11,10 +11,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-12-28 17:52:47 -0200 (sex, 28 dez 2012) $
|
// Last changed : $Date: 2015-05-18 15:22:02 +0000 (Mon, 18 May 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: PeakFinder.cpp 164 2012-12-28 19:52:47Z oparviai $
|
// $Id: PeakFinder.cpp 213 2015-05-18 15:22:02Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -192,11 +192,21 @@ double PeakFinder::getPeakCenter(const float *data, int peakpos) const
|
||||||
gp1 = findGround(data, peakpos, -1);
|
gp1 = findGround(data, peakpos, -1);
|
||||||
gp2 = findGround(data, peakpos, 1);
|
gp2 = findGround(data, peakpos, 1);
|
||||||
|
|
||||||
groundLevel = 0.5f * (data[gp1] + data[gp2]);
|
|
||||||
peakLevel = data[peakpos];
|
peakLevel = data[peakpos];
|
||||||
|
|
||||||
|
if (gp1 == gp2)
|
||||||
|
{
|
||||||
|
// avoid rounding errors when all are equal
|
||||||
|
assert(gp1 == peakpos);
|
||||||
|
cutLevel = groundLevel = peakLevel;
|
||||||
|
} else {
|
||||||
|
// get average of the ground levels
|
||||||
|
groundLevel = 0.5f * (data[gp1] + data[gp2]);
|
||||||
|
|
||||||
// calculate 70%-level of the peak
|
// calculate 70%-level of the peak
|
||||||
cutLevel = 0.70f * peakLevel + 0.30f * groundLevel;
|
cutLevel = 0.70f * peakLevel + 0.30f * groundLevel;
|
||||||
|
}
|
||||||
|
|
||||||
// find mid-level crossings
|
// find mid-level crossings
|
||||||
crosspos1 = findCrossingLevel(data, cutLevel, peakpos, -1);
|
crosspos1 = findCrossingLevel(data, cutLevel, peakpos, -1);
|
||||||
crosspos2 = findCrossingLevel(data, cutLevel, peakpos, 1);
|
crosspos2 = findCrossingLevel(data, cutLevel, peakpos, 1);
|
|
@ -9,7 +9,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-12-30 18:33:46 -0200 (sex, 30 dez 2011) $
|
// Last changed : $Date: 2011-12-30 20:33:46 +0000 (Fri, 30 Dec 2011) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: PeakFinder.h 132 2011-12-30 20:33:46Z oparviai $
|
// $Id: PeakFinder.h 132 2011-12-30 20:33:46Z oparviai $
|
|
@ -0,0 +1,302 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///
|
||||||
|
/// Sample rate transposer. Changes sample rate by using linear interpolation
|
||||||
|
/// together with anti-alias filtering (first order interpolation with anti-
|
||||||
|
/// alias filtering should be quite adequate for this application)
|
||||||
|
///
|
||||||
|
/// Author : Copyright (c) Olli Parviainen
|
||||||
|
/// Author e-mail : oparviai 'at' iki.fi
|
||||||
|
/// SoundTouch WWW: http://www.surina.net/soundtouch
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $
|
||||||
|
// File revision : $Revision: 4 $
|
||||||
|
//
|
||||||
|
// $Id: RateTransposer.cpp 195 2014-04-06 15:57:21Z oparviai $
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// License :
|
||||||
|
//
|
||||||
|
// SoundTouch audio processing library
|
||||||
|
// Copyright (c) Olli Parviainen
|
||||||
|
//
|
||||||
|
// 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 (at your option) 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
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "RateTransposer.h"
|
||||||
|
#include "InterpolateLinear.h"
|
||||||
|
#include "InterpolateCubic.h"
|
||||||
|
#include "InterpolateShannon.h"
|
||||||
|
#include "AAFilter.h"
|
||||||
|
|
||||||
|
using namespace soundtouch;
|
||||||
|
|
||||||
|
// Define default interpolation algorithm here
|
||||||
|
TransposerBase::ALGORITHM TransposerBase::algorithm = TransposerBase::CUBIC;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
RateTransposer::RateTransposer() : FIFOProcessor(&outputBuffer)
|
||||||
|
{
|
||||||
|
bUseAAFilter = true;
|
||||||
|
|
||||||
|
// Instantiates the anti-alias filter
|
||||||
|
pAAFilter = new AAFilter(64);
|
||||||
|
pTransposer = TransposerBase::newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
RateTransposer::~RateTransposer()
|
||||||
|
{
|
||||||
|
delete pAAFilter;
|
||||||
|
delete pTransposer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
|
||||||
|
void RateTransposer::enableAAFilter(bool newMode)
|
||||||
|
{
|
||||||
|
bUseAAFilter = newMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Returns nonzero if anti-alias filter is enabled.
|
||||||
|
bool RateTransposer::isAAFilterEnabled() const
|
||||||
|
{
|
||||||
|
return bUseAAFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AAFilter *RateTransposer::getAAFilter()
|
||||||
|
{
|
||||||
|
return pAAFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
||||||
|
// iRate, larger faster iRates.
|
||||||
|
void RateTransposer::setRate(float newRate)
|
||||||
|
{
|
||||||
|
double fCutoff;
|
||||||
|
|
||||||
|
pTransposer->setRate(newRate);
|
||||||
|
|
||||||
|
// design a new anti-alias filter
|
||||||
|
if (newRate > 1.0f)
|
||||||
|
{
|
||||||
|
fCutoff = 0.5f / newRate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fCutoff = 0.5f * newRate;
|
||||||
|
}
|
||||||
|
pAAFilter->setCutoffFreq(fCutoff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Adds 'nSamples' pcs of samples from the 'samples' memory position into
|
||||||
|
// the input of the object.
|
||||||
|
void RateTransposer::putSamples(const SAMPLETYPE *samples, uint nSamples)
|
||||||
|
{
|
||||||
|
processSamples(samples, nSamples);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transposes sample rate by applying anti-alias filter to prevent folding.
|
||||||
|
// Returns amount of samples returned in the "dest" buffer.
|
||||||
|
// The maximum amount of samples that can be returned at a time is set by
|
||||||
|
// the 'set_returnBuffer_size' function.
|
||||||
|
void RateTransposer::processSamples(const SAMPLETYPE *src, uint nSamples)
|
||||||
|
{
|
||||||
|
uint count;
|
||||||
|
|
||||||
|
if (nSamples == 0) return;
|
||||||
|
|
||||||
|
// Store samples to input buffer
|
||||||
|
inputBuffer.putSamples(src, nSamples);
|
||||||
|
|
||||||
|
// If anti-alias filter is turned off, simply transpose without applying
|
||||||
|
// the filter
|
||||||
|
if (bUseAAFilter == false)
|
||||||
|
{
|
||||||
|
count = pTransposer->transpose(outputBuffer, inputBuffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pAAFilter);
|
||||||
|
|
||||||
|
// Transpose with anti-alias filter
|
||||||
|
if (pTransposer->rate < 1.0f)
|
||||||
|
{
|
||||||
|
// If the parameter 'Rate' value is smaller than 1, first transpose
|
||||||
|
// the samples and then apply the anti-alias filter to remove aliasing.
|
||||||
|
|
||||||
|
// Transpose the samples, store the result to end of "midBuffer"
|
||||||
|
pTransposer->transpose(midBuffer, inputBuffer);
|
||||||
|
|
||||||
|
// Apply the anti-alias filter for transposed samples in midBuffer
|
||||||
|
pAAFilter->evaluate(outputBuffer, midBuffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the parameter 'Rate' value is larger than 1, first apply the
|
||||||
|
// anti-alias filter to remove high frequencies (prevent them from folding
|
||||||
|
// over the lover frequencies), then transpose.
|
||||||
|
|
||||||
|
// Apply the anti-alias filter for samples in inputBuffer
|
||||||
|
pAAFilter->evaluate(midBuffer, inputBuffer);
|
||||||
|
|
||||||
|
// Transpose the AA-filtered samples in "midBuffer"
|
||||||
|
pTransposer->transpose(outputBuffer, midBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Sets the number of channels, 1 = mono, 2 = stereo
|
||||||
|
void RateTransposer::setChannels(int nChannels)
|
||||||
|
{
|
||||||
|
assert(nChannels > 0);
|
||||||
|
|
||||||
|
if (pTransposer->numChannels == nChannels) return;
|
||||||
|
pTransposer->setChannels(nChannels);
|
||||||
|
|
||||||
|
inputBuffer.setChannels(nChannels);
|
||||||
|
midBuffer.setChannels(nChannels);
|
||||||
|
outputBuffer.setChannels(nChannels);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Clears all the samples in the object
|
||||||
|
void RateTransposer::clear()
|
||||||
|
{
|
||||||
|
outputBuffer.clear();
|
||||||
|
midBuffer.clear();
|
||||||
|
inputBuffer.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Returns nonzero if there aren't any samples available for outputting.
|
||||||
|
int RateTransposer::isEmpty() const
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
res = FIFOProcessor::isEmpty();
|
||||||
|
if (res == 0) return 0;
|
||||||
|
return inputBuffer.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TransposerBase - Base class for interpolation
|
||||||
|
//
|
||||||
|
|
||||||
|
// static function to set interpolation algorithm
|
||||||
|
void TransposerBase::setAlgorithm(TransposerBase::ALGORITHM a)
|
||||||
|
{
|
||||||
|
TransposerBase::algorithm = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
|
// Returns the number of samples returned in the "dest" buffer
|
||||||
|
int TransposerBase::transpose(FIFOSampleBuffer &dest, FIFOSampleBuffer &src)
|
||||||
|
{
|
||||||
|
int numSrcSamples = src.numSamples();
|
||||||
|
int sizeDemand = (int)((float)numSrcSamples / rate) + 8;
|
||||||
|
int numOutput;
|
||||||
|
SAMPLETYPE *psrc = src.ptrBegin();
|
||||||
|
SAMPLETYPE *pdest = dest.ptrEnd(sizeDemand);
|
||||||
|
|
||||||
|
#ifndef USE_MULTICH_ALWAYS
|
||||||
|
if (numChannels == 1)
|
||||||
|
{
|
||||||
|
numOutput = transposeMono(pdest, psrc, numSrcSamples);
|
||||||
|
}
|
||||||
|
else if (numChannels == 2)
|
||||||
|
{
|
||||||
|
numOutput = transposeStereo(pdest, psrc, numSrcSamples);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // USE_MULTICH_ALWAYS
|
||||||
|
{
|
||||||
|
assert(numChannels > 0);
|
||||||
|
numOutput = transposeMulti(pdest, psrc, numSrcSamples);
|
||||||
|
}
|
||||||
|
dest.putSamples(numOutput);
|
||||||
|
src.receiveSamples(numSrcSamples);
|
||||||
|
return numOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TransposerBase::TransposerBase()
|
||||||
|
{
|
||||||
|
numChannels = 0;
|
||||||
|
rate = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TransposerBase::~TransposerBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TransposerBase::setChannels(int channels)
|
||||||
|
{
|
||||||
|
numChannels = channels;
|
||||||
|
resetRegisters();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TransposerBase::setRate(float newRate)
|
||||||
|
{
|
||||||
|
rate = newRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// static factory function
|
||||||
|
TransposerBase *TransposerBase::newInstance()
|
||||||
|
{
|
||||||
|
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
// Notice: For integer arithmetics support only linear algorithm (due to simplest calculus)
|
||||||
|
return ::new InterpolateLinearInteger;
|
||||||
|
#else
|
||||||
|
switch (algorithm)
|
||||||
|
{
|
||||||
|
case LINEAR:
|
||||||
|
return new InterpolateLinearFloat;
|
||||||
|
|
||||||
|
case CUBIC:
|
||||||
|
return new InterpolateCubic;
|
||||||
|
|
||||||
|
case SHANNON:
|
||||||
|
return new InterpolateShannon;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -14,10 +14,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2009-02-21 13:00:14 -0300 (sáb, 21 fev 2009) $
|
// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: RateTransposer.h 63 2009-02-21 16:00:14Z oparviai $
|
// $Id: RateTransposer.h 195 2014-04-06 15:57:21Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -55,50 +55,71 @@
|
||||||
namespace soundtouch
|
namespace soundtouch
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// Abstract base class for transposer implementations (linear, advanced vs integer, float etc)
|
||||||
|
class TransposerBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum ALGORITHM {
|
||||||
|
LINEAR = 0,
|
||||||
|
CUBIC,
|
||||||
|
SHANNON
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void resetRegisters() = 0;
|
||||||
|
|
||||||
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples) = 0;
|
||||||
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples) = 0;
|
||||||
|
virtual int transposeMulti(SAMPLETYPE *dest,
|
||||||
|
const SAMPLETYPE *src,
|
||||||
|
int &srcSamples) = 0;
|
||||||
|
|
||||||
|
static ALGORITHM algorithm;
|
||||||
|
|
||||||
|
public:
|
||||||
|
float rate;
|
||||||
|
int numChannels;
|
||||||
|
|
||||||
|
TransposerBase();
|
||||||
|
virtual ~TransposerBase();
|
||||||
|
|
||||||
|
virtual int transpose(FIFOSampleBuffer &dest, FIFOSampleBuffer &src);
|
||||||
|
virtual void setRate(float newRate);
|
||||||
|
virtual void setChannels(int channels);
|
||||||
|
|
||||||
|
// static factory function
|
||||||
|
static TransposerBase *newInstance();
|
||||||
|
|
||||||
|
// static function to set interpolation algorithm
|
||||||
|
static void setAlgorithm(ALGORITHM a);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// A common linear samplerate transposer class.
|
/// A common linear samplerate transposer class.
|
||||||
///
|
///
|
||||||
/// Note: Use function "RateTransposer::newInstance()" to create a new class
|
|
||||||
/// instance instead of the "new" operator; that function automatically
|
|
||||||
/// chooses a correct implementation depending on if integer or floating
|
|
||||||
/// arithmetics are to be used.
|
|
||||||
class RateTransposer : public FIFOProcessor
|
class RateTransposer : public FIFOProcessor
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/// Anti-alias filter object
|
/// Anti-alias filter object
|
||||||
AAFilter *pAAFilter;
|
AAFilter *pAAFilter;
|
||||||
|
TransposerBase *pTransposer;
|
||||||
float fRate;
|
|
||||||
|
|
||||||
int numChannels;
|
|
||||||
|
|
||||||
/// Buffer for collecting samples to feed the anti-alias filter between
|
/// Buffer for collecting samples to feed the anti-alias filter between
|
||||||
/// two batches
|
/// two batches
|
||||||
FIFOSampleBuffer storeBuffer;
|
FIFOSampleBuffer inputBuffer;
|
||||||
|
|
||||||
/// Buffer for keeping samples between transposing & anti-alias filter
|
/// Buffer for keeping samples between transposing & anti-alias filter
|
||||||
FIFOSampleBuffer tempBuffer;
|
FIFOSampleBuffer midBuffer;
|
||||||
|
|
||||||
/// Output sample buffer
|
/// Output sample buffer
|
||||||
FIFOSampleBuffer outputBuffer;
|
FIFOSampleBuffer outputBuffer;
|
||||||
|
|
||||||
BOOL bUseAAFilter;
|
bool bUseAAFilter;
|
||||||
|
|
||||||
virtual void resetRegisters() = 0;
|
|
||||||
|
|
||||||
virtual uint transposeStereo(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples) = 0;
|
|
||||||
virtual uint transposeMono(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples) = 0;
|
|
||||||
inline uint transpose(SAMPLETYPE *dest,
|
|
||||||
const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
|
|
||||||
void downsample(const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
void upsample(const SAMPLETYPE *src,
|
|
||||||
uint numSamples);
|
|
||||||
|
|
||||||
/// Transposes sample rate by applying anti-alias filter to prevent folding.
|
/// Transposes sample rate by applying anti-alias filter to prevent folding.
|
||||||
/// Returns amount of samples returned in the "dest" buffer.
|
/// Returns amount of samples returned in the "dest" buffer.
|
||||||
|
@ -107,34 +128,33 @@ protected:
|
||||||
void processSamples(const SAMPLETYPE *src,
|
void processSamples(const SAMPLETYPE *src,
|
||||||
uint numSamples);
|
uint numSamples);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RateTransposer();
|
RateTransposer();
|
||||||
virtual ~RateTransposer();
|
virtual ~RateTransposer();
|
||||||
|
|
||||||
/// Operator 'new' is overloaded so that it automatically creates a suitable instance
|
/// Operator 'new' is overloaded so that it automatically creates a suitable instance
|
||||||
/// depending on if we're to use integer or floating point arithmetics.
|
/// depending on if we're to use integer or floating point arithmetics.
|
||||||
static void *operator new(size_t s);
|
// static void *operator new(size_t s);
|
||||||
|
|
||||||
/// Use this function instead of "new" operator to create a new instance of this class.
|
/// Use this function instead of "new" operator to create a new instance of this class.
|
||||||
/// This function automatically chooses a correct implementation, depending on if
|
/// This function automatically chooses a correct implementation, depending on if
|
||||||
/// integer ot floating point arithmetics are to be used.
|
/// integer ot floating point arithmetics are to be used.
|
||||||
static RateTransposer *newInstance();
|
// static RateTransposer *newInstance();
|
||||||
|
|
||||||
/// Returns the output buffer object
|
/// Returns the output buffer object
|
||||||
FIFOSamplePipe *getOutput() { return &outputBuffer; };
|
FIFOSamplePipe *getOutput() { return &outputBuffer; };
|
||||||
|
|
||||||
/// Returns the store buffer object
|
/// Returns the store buffer object
|
||||||
FIFOSamplePipe *getStore() { return &storeBuffer; };
|
// FIFOSamplePipe *getStore() { return &storeBuffer; };
|
||||||
|
|
||||||
/// Return anti-alias filter object
|
/// Return anti-alias filter object
|
||||||
AAFilter *getAAFilter();
|
AAFilter *getAAFilter();
|
||||||
|
|
||||||
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
|
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
|
||||||
void enableAAFilter(BOOL newMode);
|
void enableAAFilter(bool newMode);
|
||||||
|
|
||||||
/// Returns nonzero if anti-alias filter is enabled.
|
/// Returns nonzero if anti-alias filter is enabled.
|
||||||
BOOL isAAFilterEnabled() const;
|
bool isAAFilterEnabled() const;
|
||||||
|
|
||||||
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
|
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
|
||||||
/// rate, larger faster rates.
|
/// rate, larger faster rates.
|
|
@ -41,10 +41,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-06-13 16:29:53 -0300 (qua, 13 jun 2012) $
|
// Last changed : $Date: 2014-10-08 15:26:57 +0000 (Wed, 08 Oct 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: SoundTouch.cpp 143 2012-06-13 19:29:53Z oparviai $
|
// $Id: SoundTouch.cpp 201 2014-10-08 15:26:57Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -97,7 +97,7 @@ SoundTouch::SoundTouch()
|
||||||
{
|
{
|
||||||
// Initialize rate transposer and tempo changer instances
|
// Initialize rate transposer and tempo changer instances
|
||||||
|
|
||||||
pRateTransposer = RateTransposer::newInstance();
|
pRateTransposer = new RateTransposer();
|
||||||
pTDStretch = TDStretch::newInstance();
|
pTDStretch = TDStretch::newInstance();
|
||||||
|
|
||||||
setOutPipe(pTDStretch);
|
setOutPipe(pTDStretch);
|
||||||
|
@ -111,7 +111,7 @@ SoundTouch::SoundTouch()
|
||||||
calcEffectiveRateAndTempo();
|
calcEffectiveRateAndTempo();
|
||||||
|
|
||||||
channels = 0;
|
channels = 0;
|
||||||
bSrateSet = FALSE;
|
bSrateSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,10 +143,11 @@ uint SoundTouch::getVersionId()
|
||||||
// Sets the number of channels, 1 = mono, 2 = stereo
|
// Sets the number of channels, 1 = mono, 2 = stereo
|
||||||
void SoundTouch::setChannels(uint numChannels)
|
void SoundTouch::setChannels(uint numChannels)
|
||||||
{
|
{
|
||||||
if (numChannels != 1 && numChannels != 2)
|
/*if (numChannels != 1 && numChannels != 2)
|
||||||
{
|
{
|
||||||
ST_THROW_RT_ERROR("Illegal number of channels");
|
//ST_THROW_RT_ERROR("Illegal number of channels");
|
||||||
}
|
return;
|
||||||
|
}*/
|
||||||
channels = numChannels;
|
channels = numChannels;
|
||||||
pRateTransposer->setChannels((int)numChannels);
|
pRateTransposer->setChannels((int)numChannels);
|
||||||
pTDStretch->setChannels((int)numChannels);
|
pTDStretch->setChannels((int)numChannels);
|
||||||
|
@ -254,7 +255,7 @@ void SoundTouch::calcEffectiveRateAndTempo()
|
||||||
tempoOut = pTDStretch->getOutput();
|
tempoOut = pTDStretch->getOutput();
|
||||||
tempoOut->moveSamples(*output);
|
tempoOut->moveSamples(*output);
|
||||||
// move samples in pitch transposer's store buffer to tempo changer's input
|
// move samples in pitch transposer's store buffer to tempo changer's input
|
||||||
pTDStretch->moveSamples(*pRateTransposer->getStore());
|
// deprecated : pTDStretch->moveSamples(*pRateTransposer->getStore());
|
||||||
|
|
||||||
output = pTDStretch;
|
output = pTDStretch;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +283,7 @@ void SoundTouch::calcEffectiveRateAndTempo()
|
||||||
// Sets sample rate.
|
// Sets sample rate.
|
||||||
void SoundTouch::setSampleRate(uint srate)
|
void SoundTouch::setSampleRate(uint srate)
|
||||||
{
|
{
|
||||||
bSrateSet = TRUE;
|
bSrateSet = true;
|
||||||
// set sample rate, leave other tempo changer parameters as they are.
|
// set sample rate, leave other tempo changer parameters as they are.
|
||||||
pTDStretch->setParameters((int)srate);
|
pTDStretch->setParameters((int)srate);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +293,7 @@ void SoundTouch::setSampleRate(uint srate)
|
||||||
// the input of the object.
|
// the input of the object.
|
||||||
void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
|
void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
|
||||||
{
|
{
|
||||||
if (bSrateSet == FALSE)
|
if (bSrateSet == false)
|
||||||
{
|
{
|
||||||
ST_THROW_RT_ERROR("SoundTouch : Sample rate not defined");
|
ST_THROW_RT_ERROR("SoundTouch : Sample rate not defined");
|
||||||
}
|
}
|
||||||
|
@ -347,7 +348,7 @@ void SoundTouch::flush()
|
||||||
int i;
|
int i;
|
||||||
int nUnprocessed;
|
int nUnprocessed;
|
||||||
int nOut;
|
int nOut;
|
||||||
SAMPLETYPE buff[64*2]; // note: allocate 2*64 to cater 64 sample frames of stereo sound
|
SAMPLETYPE *buff = new SAMPLETYPE[64 * channels];
|
||||||
|
|
||||||
// check how many samples still await processing, and scale
|
// check how many samples still await processing, and scale
|
||||||
// that by tempo & rate to get expected output sample count
|
// that by tempo & rate to get expected output sample count
|
||||||
|
@ -377,6 +378,8 @@ void SoundTouch::flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] buff;
|
||||||
|
|
||||||
// Clear working buffers
|
// Clear working buffers
|
||||||
pRateTransposer->clear();
|
pRateTransposer->clear();
|
||||||
pTDStretch->clearInput();
|
pTDStretch->clearInput();
|
||||||
|
@ -387,7 +390,7 @@ void SoundTouch::flush()
|
||||||
|
|
||||||
// Changes a setting controlling the processing system behaviour. See the
|
// Changes a setting controlling the processing system behaviour. See the
|
||||||
// 'SETTING_...' defines for available setting ID's.
|
// 'SETTING_...' defines for available setting ID's.
|
||||||
BOOL SoundTouch::setSetting(int settingId, int value)
|
bool SoundTouch::setSetting(int settingId, int value)
|
||||||
{
|
{
|
||||||
int sampleRate, sequenceMs, seekWindowMs, overlapMs;
|
int sampleRate, sequenceMs, seekWindowMs, overlapMs;
|
||||||
|
|
||||||
|
@ -398,36 +401,36 @@ BOOL SoundTouch::setSetting(int settingId, int value)
|
||||||
{
|
{
|
||||||
case SETTING_USE_AA_FILTER :
|
case SETTING_USE_AA_FILTER :
|
||||||
// enables / disabless anti-alias filter
|
// enables / disabless anti-alias filter
|
||||||
pRateTransposer->enableAAFilter((value != 0) ? TRUE : FALSE);
|
pRateTransposer->enableAAFilter((value != 0) ? true : false);
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
case SETTING_AA_FILTER_LENGTH :
|
case SETTING_AA_FILTER_LENGTH :
|
||||||
// sets anti-alias filter length
|
// sets anti-alias filter length
|
||||||
pRateTransposer->getAAFilter()->setLength(value);
|
pRateTransposer->getAAFilter()->setLength(value);
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
case SETTING_USE_QUICKSEEK :
|
case SETTING_USE_QUICKSEEK :
|
||||||
// enables / disables tempo routine quick seeking algorithm
|
// enables / disables tempo routine quick seeking algorithm
|
||||||
pTDStretch->enableQuickSeek((value != 0) ? TRUE : FALSE);
|
pTDStretch->enableQuickSeek((value != 0) ? true : false);
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
case SETTING_SEQUENCE_MS:
|
case SETTING_SEQUENCE_MS:
|
||||||
// change time-stretch sequence duration parameter
|
// change time-stretch sequence duration parameter
|
||||||
pTDStretch->setParameters(sampleRate, value, seekWindowMs, overlapMs);
|
pTDStretch->setParameters(sampleRate, value, seekWindowMs, overlapMs);
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
case SETTING_SEEKWINDOW_MS:
|
case SETTING_SEEKWINDOW_MS:
|
||||||
// change time-stretch seek window length parameter
|
// change time-stretch seek window length parameter
|
||||||
pTDStretch->setParameters(sampleRate, sequenceMs, value, overlapMs);
|
pTDStretch->setParameters(sampleRate, sequenceMs, value, overlapMs);
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
case SETTING_OVERLAP_MS:
|
case SETTING_OVERLAP_MS:
|
||||||
// change time-stretch overlap length parameter
|
// change time-stretch overlap length parameter
|
||||||
pTDStretch->setParameters(sampleRate, sequenceMs, seekWindowMs, value);
|
pTDStretch->setParameters(sampleRate, sequenceMs, seekWindowMs, value);
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 16:53:01 -0200 (qui, 08 nov 2012) $
|
// Last changed : $Date: 2015-02-22 15:07:12 +0000 (Sun, 22 Feb 2015) $
|
||||||
// File revision : $Revision: 1.12 $
|
// File revision : $Revision: 1.12 $
|
||||||
//
|
//
|
||||||
// $Id: TDStretch.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: TDStretch.cpp 205 2015-02-22 15:07:12Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -51,8 +51,6 @@
|
||||||
#include "cpu_detect.h"
|
#include "cpu_detect.h"
|
||||||
#include "TDStretch.h"
|
#include "TDStretch.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace soundtouch;
|
using namespace soundtouch;
|
||||||
|
|
||||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||||
|
@ -86,15 +84,15 @@ static const short _scanOffsets[5][24]={
|
||||||
|
|
||||||
TDStretch::TDStretch() : FIFOProcessor(&outputBuffer)
|
TDStretch::TDStretch() : FIFOProcessor(&outputBuffer)
|
||||||
{
|
{
|
||||||
bQuickSeek = FALSE;
|
bQuickSeek = false;
|
||||||
channels = 2;
|
channels = 2;
|
||||||
|
|
||||||
pMidBuffer = NULL;
|
pMidBuffer = NULL;
|
||||||
pMidBufferUnaligned = NULL;
|
pMidBufferUnaligned = NULL;
|
||||||
overlapLength = 0;
|
overlapLength = 0;
|
||||||
|
|
||||||
bAutoSeqSetting = TRUE;
|
bAutoSeqSetting = true;
|
||||||
bAutoSeekSetting = TRUE;
|
bAutoSeekSetting = true;
|
||||||
|
|
||||||
// outDebt = 0;
|
// outDebt = 0;
|
||||||
skipFract = 0;
|
skipFract = 0;
|
||||||
|
@ -134,23 +132,23 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
|
||||||
if (aSequenceMS > 0)
|
if (aSequenceMS > 0)
|
||||||
{
|
{
|
||||||
this->sequenceMs = aSequenceMS;
|
this->sequenceMs = aSequenceMS;
|
||||||
bAutoSeqSetting = FALSE;
|
bAutoSeqSetting = false;
|
||||||
}
|
}
|
||||||
else if (aSequenceMS == 0)
|
else if (aSequenceMS == 0)
|
||||||
{
|
{
|
||||||
// if zero, use automatic setting
|
// if zero, use automatic setting
|
||||||
bAutoSeqSetting = TRUE;
|
bAutoSeqSetting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aSeekWindowMS > 0)
|
if (aSeekWindowMS > 0)
|
||||||
{
|
{
|
||||||
this->seekWindowMs = aSeekWindowMS;
|
this->seekWindowMs = aSeekWindowMS;
|
||||||
bAutoSeekSetting = FALSE;
|
bAutoSeekSetting = false;
|
||||||
}
|
}
|
||||||
else if (aSeekWindowMS == 0)
|
else if (aSeekWindowMS == 0)
|
||||||
{
|
{
|
||||||
// if zero, use automatic setting
|
// if zero, use automatic setting
|
||||||
bAutoSeekSetting = TRUE;
|
bAutoSeekSetting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
calcSeqParameters();
|
calcSeqParameters();
|
||||||
|
@ -159,7 +157,6 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
|
||||||
|
|
||||||
// set tempo to recalculate 'sampleReq'
|
// set tempo to recalculate 'sampleReq'
|
||||||
setTempo(tempo);
|
setTempo(tempo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +209,7 @@ void TDStretch::overlapMono(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput) const
|
||||||
|
|
||||||
void TDStretch::clearMidBuffer()
|
void TDStretch::clearMidBuffer()
|
||||||
{
|
{
|
||||||
memset(pMidBuffer, 0, 2 * sizeof(SAMPLETYPE) * overlapLength);
|
memset(pMidBuffer, 0, channels * sizeof(SAMPLETYPE) * overlapLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,14 +231,14 @@ void TDStretch::clear()
|
||||||
|
|
||||||
// Enables/disables the quick position seeking algorithm. Zero to disable, nonzero
|
// Enables/disables the quick position seeking algorithm. Zero to disable, nonzero
|
||||||
// to enable
|
// to enable
|
||||||
void TDStretch::enableQuickSeek(BOOL enable)
|
void TDStretch::enableQuickSeek(bool enable)
|
||||||
{
|
{
|
||||||
bQuickSeek = enable;
|
bQuickSeek = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns nonzero if the quick seeking algorithm is enabled.
|
// Returns nonzero if the quick seeking algorithm is enabled.
|
||||||
BOOL TDStretch::isQuickSeekEnabled() const
|
bool TDStretch::isQuickSeekEnabled() const
|
||||||
{
|
{
|
||||||
return bQuickSeek;
|
return bQuickSeek;
|
||||||
}
|
}
|
||||||
|
@ -265,13 +262,22 @@ int TDStretch::seekBestOverlapPosition(const SAMPLETYPE *refPos)
|
||||||
// of 'ovlPos'.
|
// of 'ovlPos'.
|
||||||
inline void TDStretch::overlap(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput, uint ovlPos) const
|
inline void TDStretch::overlap(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput, uint ovlPos) const
|
||||||
{
|
{
|
||||||
if (channels == 2)
|
#ifndef USE_MULTICH_ALWAYS
|
||||||
|
if (channels == 1)
|
||||||
|
{
|
||||||
|
// mono sound.
|
||||||
|
overlapMono(pOutput, pInput + ovlPos);
|
||||||
|
}
|
||||||
|
else if (channels == 2)
|
||||||
{
|
{
|
||||||
// stereo sound
|
// stereo sound
|
||||||
overlapStereo(pOutput, pInput + 2 * ovlPos);
|
overlapStereo(pOutput, pInput + 2 * ovlPos);
|
||||||
} else {
|
}
|
||||||
// mono sound.
|
else
|
||||||
overlapMono(pOutput, pInput + ovlPos);
|
#endif // USE_MULTICH_ALWAYS
|
||||||
|
{
|
||||||
|
assert(channels > 0);
|
||||||
|
overlapMulti(pOutput, pInput + channels * ovlPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,30 +292,50 @@ inline void TDStretch::overlap(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput, ui
|
||||||
int TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos)
|
int TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos)
|
||||||
{
|
{
|
||||||
int bestOffs;
|
int bestOffs;
|
||||||
double bestCorr, corr;
|
double bestCorr;
|
||||||
int i;
|
int i;
|
||||||
|
double norm;
|
||||||
|
|
||||||
bestCorr = FLT_MIN;
|
bestCorr = FLT_MIN;
|
||||||
bestOffs = 0;
|
bestOffs = 0;
|
||||||
|
|
||||||
// Scans for the best correlation value by testing each possible position
|
// Scans for the best correlation value by testing each possible position
|
||||||
// over the permitted range.
|
// over the permitted range.
|
||||||
for (i = 0; i < seekLength; i ++)
|
bestCorr = calcCrossCorr(refPos, pMidBuffer, norm);
|
||||||
|
|
||||||
|
#pragma omp parallel for
|
||||||
|
for (i = 1; i < seekLength; i ++)
|
||||||
{
|
{
|
||||||
// Calculates correlation value for the mixing position corresponding
|
double corr;
|
||||||
// to 'i'
|
// Calculates correlation value for the mixing position corresponding to 'i'
|
||||||
corr = calcCrossCorr(refPos + channels * i, pMidBuffer);
|
#ifdef _OPENMP
|
||||||
|
// in parallel OpenMP mode, can't use norm accumulator version as parallel executor won't
|
||||||
|
// iterate the loop in sequential order
|
||||||
|
corr = calcCrossCorr(refPos + channels * i, pMidBuffer, norm);
|
||||||
|
#else
|
||||||
|
// In non-parallel version call "calcCrossCorrAccumulate" that is otherwise same
|
||||||
|
// as "calcCrossCorr", but saves time by reusing & updating previously stored
|
||||||
|
// "norm" value
|
||||||
|
corr = calcCrossCorrAccumulate(refPos + channels * i, pMidBuffer, norm);
|
||||||
|
#endif
|
||||||
// heuristic rule to slightly favour values close to mid of the range
|
// heuristic rule to slightly favour values close to mid of the range
|
||||||
double tmp = (double)(2 * i - seekLength) / (double)seekLength;
|
double tmp = (double)(2 * i - seekLength) / (double)seekLength;
|
||||||
corr = ((corr + 0.1) * (1.0 - 0.25 * tmp * tmp));
|
corr = ((corr + 0.1) * (1.0 - 0.25 * tmp * tmp));
|
||||||
|
|
||||||
// Checks for the highest correlation value
|
// Checks for the highest correlation value
|
||||||
if (corr > bestCorr)
|
if (corr > bestCorr)
|
||||||
|
{
|
||||||
|
// For optimal performance, enter critical section only in case that best value found.
|
||||||
|
// in such case repeat 'if' condition as it's possible that parallel execution may have
|
||||||
|
// updated the bestCorr value in the mean time
|
||||||
|
#pragma omp critical
|
||||||
|
if (corr > bestCorr)
|
||||||
{
|
{
|
||||||
bestCorr = corr;
|
bestCorr = corr;
|
||||||
bestOffs = i;
|
bestOffs = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// clear cross correlation routine state if necessary (is so e.g. in MMX routines).
|
// clear cross correlation routine state if necessary (is so e.g. in MMX routines).
|
||||||
clearCrossCorrState();
|
clearCrossCorrState();
|
||||||
|
|
||||||
|
@ -346,12 +372,13 @@ int TDStretch::seekBestOverlapPositionQuick(const SAMPLETYPE *refPos)
|
||||||
j = 0;
|
j = 0;
|
||||||
while (_scanOffsets[scanCount][j])
|
while (_scanOffsets[scanCount][j])
|
||||||
{
|
{
|
||||||
|
double norm;
|
||||||
tempOffset = corrOffset + _scanOffsets[scanCount][j];
|
tempOffset = corrOffset + _scanOffsets[scanCount][j];
|
||||||
if (tempOffset >= seekLength) break;
|
if (tempOffset >= seekLength) break;
|
||||||
|
|
||||||
// Calculates correlation value for the mixing position corresponding
|
// Calculates correlation value for the mixing position corresponding
|
||||||
// to 'tempOffset'
|
// to 'tempOffset'
|
||||||
corr = (double)calcCrossCorr(refPos + channels * tempOffset, pMidBuffer);
|
corr = (double)calcCrossCorr(refPos + channels * tempOffset, pMidBuffer, norm);
|
||||||
// heuristic rule to slightly favour values close to mid of the range
|
// heuristic rule to slightly favour values close to mid of the range
|
||||||
double tmp = (double)(2 * tempOffset - seekLength) / seekLength;
|
double tmp = (double)(2 * tempOffset - seekLength) / seekLength;
|
||||||
corr = ((corr + 0.1) * (1.0 - 0.25 * tmp * tmp));
|
corr = ((corr + 0.1) * (1.0 - 0.25 * tmp * tmp));
|
||||||
|
@ -458,11 +485,15 @@ void TDStretch::setChannels(int numChannels)
|
||||||
{
|
{
|
||||||
assert(numChannels > 0);
|
assert(numChannels > 0);
|
||||||
if (channels == numChannels) return;
|
if (channels == numChannels) return;
|
||||||
assert(numChannels == 1 || numChannels == 2);
|
// assert(numChannels == 1 || numChannels == 2);
|
||||||
|
|
||||||
channels = numChannels;
|
channels = numChannels;
|
||||||
inputBuffer.setChannels(channels);
|
inputBuffer.setChannels(channels);
|
||||||
outputBuffer.setChannels(channels);
|
outputBuffer.setChannels(channels);
|
||||||
|
|
||||||
|
// re-init overlap/buffer
|
||||||
|
overlapLength=0;
|
||||||
|
setParameters(sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -498,7 +529,6 @@ void TDStretch::processNominalTempo()
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// Processes as many processing frames of the samples 'inputBuffer', store
|
// Processes as many processing frames of the samples 'inputBuffer', store
|
||||||
// the result into 'outputBuffer'
|
// the result into 'outputBuffer'
|
||||||
|
@ -588,7 +618,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength)
|
||||||
{
|
{
|
||||||
delete[] pMidBufferUnaligned;
|
delete[] pMidBufferUnaligned;
|
||||||
|
|
||||||
pMidBufferUnaligned = new SAMPLETYPE[overlapLength * 2 + 16 / sizeof(SAMPLETYPE)];
|
pMidBufferUnaligned = new SAMPLETYPE[overlapLength * channels + 16 / sizeof(SAMPLETYPE)];
|
||||||
// ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency
|
// ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency
|
||||||
pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);
|
pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);
|
||||||
|
|
||||||
|
@ -666,6 +696,27 @@ void TDStretch::overlapStereo(short *poutput, const short *input) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Overlaps samples in 'midBuffer' with the samples in 'input'. The 'Multi'
|
||||||
|
// version of the routine.
|
||||||
|
void TDStretch::overlapMulti(SAMPLETYPE *poutput, const SAMPLETYPE *input) const
|
||||||
|
{
|
||||||
|
SAMPLETYPE m1=(SAMPLETYPE)0;
|
||||||
|
SAMPLETYPE m2;
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
for (m2 = (SAMPLETYPE)overlapLength; m2; m2 --)
|
||||||
|
{
|
||||||
|
for (int c = 0; c < channels; c ++)
|
||||||
|
{
|
||||||
|
poutput[i] = (input[i] * m1 + pMidBuffer[i] * m2) / overlapLength;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
m1++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Calculates the x having the closest 2^x value for the given value
|
// Calculates the x having the closest 2^x value for the given value
|
||||||
static int _getClosest2Power(double value)
|
static int _getClosest2Power(double value)
|
||||||
{
|
{
|
||||||
|
@ -699,32 +750,72 @@ void TDStretch::calculateOverlapLength(int aoverlapMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double TDStretch::calcCrossCorr(const short *mixingPos, const short *compare) const
|
double TDStretch::calcCrossCorr(const short *mixingPos, const short *compare, double &norm) const
|
||||||
{
|
{
|
||||||
long corr;
|
long corr;
|
||||||
long norm;
|
long lnorm;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
corr = norm = 0;
|
corr = lnorm = 0;
|
||||||
// Same routine for stereo and mono. For stereo, unroll loop for better
|
// Same routine for stereo and mono. For stereo, unroll loop for better
|
||||||
// efficiency and gives slightly better resolution against rounding.
|
// efficiency and gives slightly better resolution against rounding.
|
||||||
// For mono it same routine, just unrolls loop by factor of 4
|
// For mono it same routine, just unrolls loop by factor of 4
|
||||||
for (i = 0; i < channels * overlapLength; i += 4)
|
for (i = 0; i < channels * overlapLength; i += 4)
|
||||||
{
|
{
|
||||||
corr += (mixingPos[i] * compare[i] +
|
corr += (mixingPos[i] * compare[i] +
|
||||||
mixingPos[i + 1] * compare[i + 1] +
|
mixingPos[i + 1] * compare[i + 1]) >> overlapDividerBits; // notice: do intermediate division here to avoid integer overflow
|
||||||
mixingPos[i + 2] * compare[i + 2] +
|
corr += (mixingPos[i + 2] * compare[i + 2] +
|
||||||
mixingPos[i + 3] * compare[i + 3]) >> overlapDividerBits;
|
mixingPos[i + 3] * compare[i + 3]) >> overlapDividerBits;
|
||||||
norm += (mixingPos[i] * mixingPos[i] +
|
lnorm += (mixingPos[i] * mixingPos[i] +
|
||||||
mixingPos[i + 1] * mixingPos[i + 1] +
|
mixingPos[i + 1] * mixingPos[i + 1]) >> overlapDividerBits; // notice: do intermediate division here to avoid integer overflow
|
||||||
mixingPos[i + 2] * mixingPos[i + 2] +
|
lnorm += (mixingPos[i + 2] * mixingPos[i + 2] +
|
||||||
mixingPos[i + 3] * mixingPos[i + 3]) >> overlapDividerBits;
|
mixingPos[i + 3] * mixingPos[i + 3]) >> overlapDividerBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize result by dividing by sqrt(norm) - this step is easiest
|
// Normalize result by dividing by sqrt(norm) - this step is easiest
|
||||||
// done using floating point operation
|
// done using floating point operation
|
||||||
if (norm == 0) norm = 1; // to avoid div by zero
|
norm = (double)lnorm;
|
||||||
return (double)corr / sqrt((double)norm);
|
return (double)corr / sqrt((norm < 1e-9) ? 1.0 : norm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Update cross-correlation by accumulating "norm" coefficient by previously calculated value
|
||||||
|
double TDStretch::calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm) const
|
||||||
|
{
|
||||||
|
long corr;
|
||||||
|
long lnorm;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// cancel first normalizer tap from previous round
|
||||||
|
lnorm = 0;
|
||||||
|
for (i = 1; i <= channels; i ++)
|
||||||
|
{
|
||||||
|
lnorm -= (mixingPos[-i] * mixingPos[-i]) >> overlapDividerBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
corr = 0;
|
||||||
|
// Same routine for stereo and mono. For stereo, unroll loop for better
|
||||||
|
// efficiency and gives slightly better resolution against rounding.
|
||||||
|
// For mono it same routine, just unrolls loop by factor of 4
|
||||||
|
for (i = 0; i < channels * overlapLength; i += 4)
|
||||||
|
{
|
||||||
|
corr += (mixingPos[i] * compare[i] +
|
||||||
|
mixingPos[i + 1] * compare[i + 1]) >> overlapDividerBits; // notice: do intermediate division here to avoid integer overflow
|
||||||
|
corr += (mixingPos[i + 2] * compare[i + 2] +
|
||||||
|
mixingPos[i + 3] * compare[i + 3]) >> overlapDividerBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update normalizer with last samples of this round
|
||||||
|
for (int j = 0; j < channels; j ++)
|
||||||
|
{
|
||||||
|
i --;
|
||||||
|
lnorm += (mixingPos[i] * mixingPos[i]) >> overlapDividerBits;
|
||||||
|
}
|
||||||
|
norm += (double)lnorm;
|
||||||
|
|
||||||
|
// Normalize result by dividing by sqrt(norm) - this step is easiest
|
||||||
|
// done using floating point operation
|
||||||
|
return (double)corr / sqrt((norm < 1e-9) ? 1.0 : norm);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SOUNDTOUCH_INTEGER_SAMPLES
|
#endif // SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
@ -760,6 +851,34 @@ void TDStretch::overlapStereo(float *pOutput, const float *pInput) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Overlaps samples in 'midBuffer' with the samples in 'input'.
|
||||||
|
void TDStretch::overlapMulti(float *pOutput, const float *pInput) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
float fScale;
|
||||||
|
float f1;
|
||||||
|
float f2;
|
||||||
|
|
||||||
|
fScale = 1.0f / (float)overlapLength;
|
||||||
|
|
||||||
|
f1 = 0;
|
||||||
|
f2 = 1.0f;
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
for (int i2 = 0; i2 < overlapLength; i2 ++)
|
||||||
|
{
|
||||||
|
// note: Could optimize this slightly by taking into account that always channels > 2
|
||||||
|
for (int c = 0; c < channels; c ++)
|
||||||
|
{
|
||||||
|
pOutput[i] = pInput[i] * f1 + pMidBuffer[i] * f2;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
f1 += fScale;
|
||||||
|
f2 -= fScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Calculates overlapInMsec period length in samples.
|
/// Calculates overlapInMsec period length in samples.
|
||||||
void TDStretch::calculateOverlapLength(int overlapInMsec)
|
void TDStretch::calculateOverlapLength(int overlapInMsec)
|
||||||
{
|
{
|
||||||
|
@ -776,7 +895,8 @@ void TDStretch::calculateOverlapLength(int overlapInMsec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double TDStretch::calcCrossCorr(const float *mixingPos, const float *compare) const
|
/// Calculate cross-correlation
|
||||||
|
double TDStretch::calcCrossCorr(const float *mixingPos, const float *compare, double &anorm) const
|
||||||
{
|
{
|
||||||
double corr;
|
double corr;
|
||||||
double norm;
|
double norm;
|
||||||
|
@ -801,8 +921,44 @@ double TDStretch::calcCrossCorr(const float *mixingPos, const float *compare) co
|
||||||
mixingPos[i + 3] * mixingPos[i + 3];
|
mixingPos[i + 3] * mixingPos[i + 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (norm < 1e-9) norm = 1.0; // to avoid div by zero
|
anorm = norm;
|
||||||
return corr / sqrt(norm);
|
return corr / sqrt((norm < 1e-9 ? 1.0 : norm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Update cross-correlation by accumulating "norm" coefficient by previously calculated value
|
||||||
|
double TDStretch::calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm) const
|
||||||
|
{
|
||||||
|
double corr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
corr = 0;
|
||||||
|
|
||||||
|
// cancel first normalizer tap from previous round
|
||||||
|
for (i = 1; i <= channels; i ++)
|
||||||
|
{
|
||||||
|
norm -= mixingPos[-i] * mixingPos[-i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same routine for stereo and mono. For Stereo, unroll by factor of 2.
|
||||||
|
// For mono it's same routine yet unrollsd by factor of 4.
|
||||||
|
for (i = 0; i < channels * overlapLength; i += 4)
|
||||||
|
{
|
||||||
|
corr += mixingPos[i] * compare[i] +
|
||||||
|
mixingPos[i + 1] * compare[i + 1] +
|
||||||
|
mixingPos[i + 2] * compare[i + 2] +
|
||||||
|
mixingPos[i + 3] * compare[i + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
// update normalizer with last samples of this round
|
||||||
|
for (int j = 0; j < channels; j ++)
|
||||||
|
{
|
||||||
|
i --;
|
||||||
|
norm += mixingPos[i] * mixingPos[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return corr / sqrt((norm < 1e-9 ? 1.0 : norm));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // SOUNDTOUCH_FLOAT_SAMPLES
|
#endif // SOUNDTOUCH_FLOAT_SAMPLES
|
|
@ -13,10 +13,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-04-01 16:49:30 -0300 (dom, 01 abr 2012) $
|
// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: TDStretch.h 137 2012-04-01 19:49:30Z oparviai $
|
// $Id: TDStretch.h 195 2014-04-06 15:57:21Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -125,21 +125,22 @@ protected:
|
||||||
float skipFract;
|
float skipFract;
|
||||||
FIFOSampleBuffer outputBuffer;
|
FIFOSampleBuffer outputBuffer;
|
||||||
FIFOSampleBuffer inputBuffer;
|
FIFOSampleBuffer inputBuffer;
|
||||||
BOOL bQuickSeek;
|
bool bQuickSeek;
|
||||||
|
|
||||||
int sampleRate;
|
int sampleRate;
|
||||||
int sequenceMs;
|
int sequenceMs;
|
||||||
int seekWindowMs;
|
int seekWindowMs;
|
||||||
int overlapMs;
|
int overlapMs;
|
||||||
BOOL bAutoSeqSetting;
|
bool bAutoSeqSetting;
|
||||||
BOOL bAutoSeekSetting;
|
bool bAutoSeekSetting;
|
||||||
|
|
||||||
void acceptNewOverlapLength(int newOverlapLength);
|
void acceptNewOverlapLength(int newOverlapLength);
|
||||||
|
|
||||||
virtual void clearCrossCorrState();
|
virtual void clearCrossCorrState();
|
||||||
void calculateOverlapLength(int overlapMs);
|
void calculateOverlapLength(int overlapMs);
|
||||||
|
|
||||||
virtual double calcCrossCorr(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare) const;
|
virtual double calcCrossCorr(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm) const;
|
||||||
|
virtual double calcCrossCorrAccumulate(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm) const;
|
||||||
|
|
||||||
virtual int seekBestOverlapPositionFull(const SAMPLETYPE *refPos);
|
virtual int seekBestOverlapPositionFull(const SAMPLETYPE *refPos);
|
||||||
virtual int seekBestOverlapPositionQuick(const SAMPLETYPE *refPos);
|
virtual int seekBestOverlapPositionQuick(const SAMPLETYPE *refPos);
|
||||||
|
@ -147,6 +148,7 @@ protected:
|
||||||
|
|
||||||
virtual void overlapStereo(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
virtual void overlapStereo(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
||||||
virtual void overlapMono(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
virtual void overlapMono(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
||||||
|
virtual void overlapMulti(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
||||||
|
|
||||||
void clearMidBuffer();
|
void clearMidBuffer();
|
||||||
void overlap(SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const;
|
void overlap(SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const;
|
||||||
|
@ -193,10 +195,10 @@ public:
|
||||||
|
|
||||||
/// Enables/disables the quick position seeking algorithm. Zero to disable,
|
/// Enables/disables the quick position seeking algorithm. Zero to disable,
|
||||||
/// nonzero to enable
|
/// nonzero to enable
|
||||||
void enableQuickSeek(BOOL enable);
|
void enableQuickSeek(bool enable);
|
||||||
|
|
||||||
/// Returns nonzero if the quick seeking algorithm is enabled.
|
/// Returns nonzero if the quick seeking algorithm is enabled.
|
||||||
BOOL isQuickSeekEnabled() const;
|
bool isQuickSeekEnabled() const;
|
||||||
|
|
||||||
/// Sets routine control parameters. These control are certain time constants
|
/// Sets routine control parameters. These control are certain time constants
|
||||||
/// defining how the sound is stretched to the desired duration.
|
/// defining how the sound is stretched to the desired duration.
|
||||||
|
@ -247,7 +249,8 @@ public:
|
||||||
class TDStretchMMX : public TDStretch
|
class TDStretchMMX : public TDStretch
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
double calcCrossCorr(const short *mixingPos, const short *compare) const;
|
double calcCrossCorr(const short *mixingPos, const short *compare, double &norm) const;
|
||||||
|
double calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm) const;
|
||||||
virtual void overlapStereo(short *output, const short *input) const;
|
virtual void overlapStereo(short *output, const short *input) const;
|
||||||
virtual void clearCrossCorrState();
|
virtual void clearCrossCorrState();
|
||||||
};
|
};
|
||||||
|
@ -259,7 +262,8 @@ public:
|
||||||
class TDStretchSSE : public TDStretch
|
class TDStretchSSE : public TDStretch
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
double calcCrossCorr(const float *mixingPos, const float *compare) const;
|
double calcCrossCorr(const float *mixingPos, const float *compare, double &norm) const;
|
||||||
|
double calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /// SOUNDTOUCH_ALLOW_SSE
|
#endif /// SOUNDTOUCH_ALLOW_SSE
|
|
@ -12,7 +12,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2008-02-10 14:26:55 -0200 (dom, 10 fev 2008) $
|
// Last changed : $Date: 2008-02-10 16:26:55 +0000 (Sun, 10 Feb 2008) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: cpu_detect.h 11 2008-02-10 16:26:55Z oparviai $
|
// $Id: cpu_detect.h 11 2008-02-10 16:26:55Z oparviai $
|
|
@ -11,10 +11,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 16:44:37 -0200 (qui, 08 nov 2012) $
|
// Last changed : $Date: 2014-01-07 18:24:28 +0000 (Tue, 07 Jan 2014) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: cpu_detect_x86.cpp 159 2012-11-08 18:44:37Z oparviai $
|
// $Id: cpu_detect_x86.cpp 183 2014-01-07 18:24:28Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
#include "cpu_detect.h"
|
#include "cpu_detect.h"
|
||||||
#include "STTypes.h"
|
#include "STTypes.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
|
#if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
|
||||||
|
|
||||||
#if defined(__GNUC__) && defined(__i386__)
|
#if defined(__GNUC__) && defined(__i386__)
|
||||||
|
@ -50,11 +51,11 @@
|
||||||
#elif defined(_M_IX86)
|
#elif defined(_M_IX86)
|
||||||
// windows non-gcc
|
// windows non-gcc
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define bit_MMX (1 << 23)
|
#define bit_MMX (1 << 23)
|
||||||
#define bit_SSE (1 << 25)
|
#define bit_SSE (1 << 25)
|
||||||
#define bit_SSE2 (1 << 26)
|
#define bit_SSE2 (1 << 26)
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 16:53:01 -0200 (qui, 08 nov 2012) $
|
// Last changed : $Date: 2015-02-22 15:10:38 +0000 (Sun, 22 Feb 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: mmx_optimized.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: mmx_optimized.cpp 206 2015-02-22 15:10:38Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -68,7 +68,7 @@ using namespace soundtouch;
|
||||||
|
|
||||||
|
|
||||||
// Calculates cross correlation of two buffers
|
// Calculates cross correlation of two buffers
|
||||||
double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2) const
|
double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &dnorm) const
|
||||||
{
|
{
|
||||||
const __m64 *pVec1, *pVec2;
|
const __m64 *pVec1, *pVec2;
|
||||||
__m64 shifter;
|
__m64 shifter;
|
||||||
|
@ -93,19 +93,19 @@ double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2) const
|
||||||
// _mm_add_pi32 : 2*32bit add
|
// _mm_add_pi32 : 2*32bit add
|
||||||
// _m_psrad : 32bit right-shift
|
// _m_psrad : 32bit right-shift
|
||||||
|
|
||||||
temp = _mm_add_pi32(_mm_madd_pi16(pVec1[0], pVec2[0]),
|
temp = _mm_add_pi32(_mm_sra_pi32(_mm_madd_pi16(pVec1[0], pVec2[0]), shifter),
|
||||||
_mm_madd_pi16(pVec1[1], pVec2[1]));
|
_mm_sra_pi32(_mm_madd_pi16(pVec1[1], pVec2[1]), shifter));
|
||||||
temp2 = _mm_add_pi32(_mm_madd_pi16(pVec1[0], pVec1[0]),
|
temp2 = _mm_add_pi32(_mm_sra_pi32(_mm_madd_pi16(pVec1[0], pVec1[0]), shifter),
|
||||||
_mm_madd_pi16(pVec1[1], pVec1[1]));
|
_mm_sra_pi32(_mm_madd_pi16(pVec1[1], pVec1[1]), shifter));
|
||||||
accu = _mm_add_pi32(accu, _mm_sra_pi32(temp, shifter));
|
accu = _mm_add_pi32(accu, temp);
|
||||||
normaccu = _mm_add_pi32(normaccu, _mm_sra_pi32(temp2, shifter));
|
normaccu = _mm_add_pi32(normaccu, temp2);
|
||||||
|
|
||||||
temp = _mm_add_pi32(_mm_madd_pi16(pVec1[2], pVec2[2]),
|
temp = _mm_add_pi32(_mm_sra_pi32(_mm_madd_pi16(pVec1[2], pVec2[2]), shifter),
|
||||||
_mm_madd_pi16(pVec1[3], pVec2[3]));
|
_mm_sra_pi32(_mm_madd_pi16(pVec1[3], pVec2[3]), shifter));
|
||||||
temp2 = _mm_add_pi32(_mm_madd_pi16(pVec1[2], pVec1[2]),
|
temp2 = _mm_add_pi32(_mm_sra_pi32(_mm_madd_pi16(pVec1[2], pVec1[2]), shifter),
|
||||||
_mm_madd_pi16(pVec1[3], pVec1[3]));
|
_mm_sra_pi32(_mm_madd_pi16(pVec1[3], pVec1[3]), shifter));
|
||||||
accu = _mm_add_pi32(accu, _mm_sra_pi32(temp, shifter));
|
accu = _mm_add_pi32(accu, temp);
|
||||||
normaccu = _mm_add_pi32(normaccu, _mm_sra_pi32(temp2, shifter));
|
normaccu = _mm_add_pi32(normaccu, temp2);
|
||||||
|
|
||||||
pVec1 += 4;
|
pVec1 += 4;
|
||||||
pVec2 += 4;
|
pVec2 += 4;
|
||||||
|
@ -125,14 +125,81 @@ double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2) const
|
||||||
|
|
||||||
// Normalize result by dividing by sqrt(norm) - this step is easiest
|
// Normalize result by dividing by sqrt(norm) - this step is easiest
|
||||||
// done using floating point operation
|
// done using floating point operation
|
||||||
if (norm == 0) norm = 1; // to avoid div by zero
|
dnorm = (double)norm;
|
||||||
|
|
||||||
return (double)corr / sqrt((double)norm);
|
return (double)corr / sqrt(dnorm < 1e-9 ? 1.0 : dnorm);
|
||||||
// Note: Warning about the missing EMMS instruction is harmless
|
// Note: Warning about the missing EMMS instruction is harmless
|
||||||
// as it'll be called elsewhere.
|
// as it'll be called elsewhere.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Update cross-correlation by accumulating "norm" coefficient by previously calculated value
|
||||||
|
double TDStretchMMX::calcCrossCorrAccumulate(const short *pV1, const short *pV2, double &dnorm) const
|
||||||
|
{
|
||||||
|
const __m64 *pVec1, *pVec2;
|
||||||
|
__m64 shifter;
|
||||||
|
__m64 accu;
|
||||||
|
long corr, lnorm;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// cancel first normalizer tap from previous round
|
||||||
|
lnorm = 0;
|
||||||
|
for (i = 1; i <= channels; i ++)
|
||||||
|
{
|
||||||
|
lnorm -= (pV1[-i] * pV1[-i]) >> overlapDividerBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
pVec1 = (__m64*)pV1;
|
||||||
|
pVec2 = (__m64*)pV2;
|
||||||
|
|
||||||
|
shifter = _m_from_int(overlapDividerBits);
|
||||||
|
accu = _mm_setzero_si64();
|
||||||
|
|
||||||
|
// Process 4 parallel sets of 2 * stereo samples or 4 * mono samples
|
||||||
|
// during each round for improved CPU-level parallellization.
|
||||||
|
for (i = 0; i < channels * overlapLength / 16; i ++)
|
||||||
|
{
|
||||||
|
__m64 temp;
|
||||||
|
|
||||||
|
// dictionary of instructions:
|
||||||
|
// _m_pmaddwd : 4*16bit multiply-add, resulting two 32bits = [a0*b0+a1*b1 ; a2*b2+a3*b3]
|
||||||
|
// _mm_add_pi32 : 2*32bit add
|
||||||
|
// _m_psrad : 32bit right-shift
|
||||||
|
|
||||||
|
temp = _mm_add_pi32(_mm_sra_pi32(_mm_madd_pi16(pVec1[0], pVec2[0]), shifter),
|
||||||
|
_mm_sra_pi32(_mm_madd_pi16(pVec1[1], pVec2[1]), shifter));
|
||||||
|
accu = _mm_add_pi32(accu, temp);
|
||||||
|
|
||||||
|
temp = _mm_add_pi32(_mm_sra_pi32(_mm_madd_pi16(pVec1[2], pVec2[2]), shifter),
|
||||||
|
_mm_sra_pi32(_mm_madd_pi16(pVec1[3], pVec2[3]), shifter));
|
||||||
|
accu = _mm_add_pi32(accu, temp);
|
||||||
|
|
||||||
|
pVec1 += 4;
|
||||||
|
pVec2 += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy hi-dword of mm0 to lo-dword of mm1, then sum mmo+mm1
|
||||||
|
// and finally store the result into the variable "corr"
|
||||||
|
|
||||||
|
accu = _mm_add_pi32(accu, _mm_srli_si64(accu, 32));
|
||||||
|
corr = _m_to_int(accu);
|
||||||
|
|
||||||
|
// Clear MMS state
|
||||||
|
_m_empty();
|
||||||
|
|
||||||
|
// update normalizer with last samples of this round
|
||||||
|
pV1 = (short *)pVec1;
|
||||||
|
for (int j = 1; j <= channels; j ++)
|
||||||
|
{
|
||||||
|
lnorm += (pV1[-j] * pV1[-j]) >> overlapDividerBits;
|
||||||
|
}
|
||||||
|
dnorm += (double)lnorm;
|
||||||
|
|
||||||
|
// Normalize result by dividing by sqrt(norm) - this step is easiest
|
||||||
|
// done using floating point operation
|
||||||
|
return (double)corr / sqrt((dnorm < 1e-9) ? 1.0 : dnorm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TDStretchMMX::clearCrossCorrState()
|
void TDStretchMMX::clearCrossCorrState()
|
||||||
{
|
{
|
||||||
|
@ -220,6 +287,7 @@ void TDStretchMMX::overlapStereo(short *output, const short *input) const
|
||||||
|
|
||||||
FIRFilterMMX::FIRFilterMMX() : FIRFilter()
|
FIRFilterMMX::FIRFilterMMX() : FIRFilter()
|
||||||
{
|
{
|
||||||
|
filterCoeffsAlign = NULL;
|
||||||
filterCoeffsUnalign = NULL;
|
filterCoeffsUnalign = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 16:53:01 -0200 (qui, 08 nov 2012) $
|
// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: sse_optimized.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: sse_optimized.cpp 202 2015-02-21 21:24:29Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -71,7 +71,7 @@ using namespace soundtouch;
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
// Calculates cross correlation of two buffers
|
// Calculates cross correlation of two buffers
|
||||||
double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2) const
|
double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2, double &anorm) const
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const float *pVec1;
|
const float *pVec1;
|
||||||
|
@ -141,11 +141,11 @@ double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2) const
|
||||||
|
|
||||||
// return value = vSum[0] + vSum[1] + vSum[2] + vSum[3]
|
// return value = vSum[0] + vSum[1] + vSum[2] + vSum[3]
|
||||||
float *pvNorm = (float*)&vNorm;
|
float *pvNorm = (float*)&vNorm;
|
||||||
double norm = sqrt(pvNorm[0] + pvNorm[1] + pvNorm[2] + pvNorm[3]);
|
float norm = (pvNorm[0] + pvNorm[1] + pvNorm[2] + pvNorm[3]);
|
||||||
if (norm < 1e-9) norm = 1.0; // to avoid div by zero
|
anorm = norm;
|
||||||
|
|
||||||
float *pvSum = (float*)&vSum;
|
float *pvSum = (float*)&vSum;
|
||||||
return (double)(pvSum[0] + pvSum[1] + pvSum[2] + pvSum[3]) / norm;
|
return (double)(pvSum[0] + pvSum[1] + pvSum[2] + pvSum[3]) / sqrt(norm < 1e-9 ? 1.0 : norm);
|
||||||
|
|
||||||
/* This is approximately corresponding routine in C-language yet without normalization:
|
/* This is approximately corresponding routine in C-language yet without normalization:
|
||||||
double corr, norm;
|
double corr, norm;
|
||||||
|
@ -182,6 +182,16 @@ double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double TDStretchSSE::calcCrossCorrAccumulate(const float *pV1, const float *pV2, double &norm) const
|
||||||
|
{
|
||||||
|
// call usual calcCrossCorr function because SSE does not show big benefit of
|
||||||
|
// accumulating "norm" value, and also the "norm" rolling algorithm would get
|
||||||
|
// complicated due to SSE-specific alignment-vs-nonexact correlation rules.
|
||||||
|
return calcCrossCorr(pV1, pV2, norm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// implementation of SSE optimized functions of class 'FIRFilter'
|
// implementation of SSE optimized functions of class 'FIRFilter'
|
||||||
|
@ -249,14 +259,17 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
|
||||||
assert(((ulongptr)filterCoeffsAlign) % 16 == 0);
|
assert(((ulongptr)filterCoeffsAlign) % 16 == 0);
|
||||||
|
|
||||||
// filter is evaluated for two stereo samples with each iteration, thus use of 'j += 2'
|
// filter is evaluated for two stereo samples with each iteration, thus use of 'j += 2'
|
||||||
|
#pragma omp parallel for
|
||||||
for (j = 0; j < count; j += 2)
|
for (j = 0; j < count; j += 2)
|
||||||
{
|
{
|
||||||
const float *pSrc;
|
const float *pSrc;
|
||||||
|
float *pDest;
|
||||||
const __m128 *pFil;
|
const __m128 *pFil;
|
||||||
__m128 sum1, sum2;
|
__m128 sum1, sum2;
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
pSrc = (const float*)source; // source audio data
|
pSrc = (const float*)source + j * 2; // source audio data
|
||||||
|
pDest = dest + j * 2; // destination audio data
|
||||||
pFil = (const __m128*)filterCoeffsAlign; // filter coefficients. NOTE: Assumes coefficients
|
pFil = (const __m128*)filterCoeffsAlign; // filter coefficients. NOTE: Assumes coefficients
|
||||||
// are aligned to 16-byte boundary
|
// are aligned to 16-byte boundary
|
||||||
sum1 = sum2 = _mm_setzero_ps();
|
sum1 = sum2 = _mm_setzero_ps();
|
||||||
|
@ -289,12 +302,10 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
|
||||||
// to sum the two hi- and lo-floats of these registers together.
|
// to sum the two hi- and lo-floats of these registers together.
|
||||||
|
|
||||||
// post-shuffle & add the filtered values and store to dest.
|
// post-shuffle & add the filtered values and store to dest.
|
||||||
_mm_storeu_ps(dest, _mm_add_ps(
|
_mm_storeu_ps(pDest, _mm_add_ps(
|
||||||
_mm_shuffle_ps(sum1, sum2, _MM_SHUFFLE(1,0,3,2)), // s2_1 s2_0 s1_3 s1_2
|
_mm_shuffle_ps(sum1, sum2, _MM_SHUFFLE(1,0,3,2)), // s2_1 s2_0 s1_3 s1_2
|
||||||
_mm_shuffle_ps(sum1, sum2, _MM_SHUFFLE(3,2,1,0)) // s2_3 s2_2 s1_1 s1_0
|
_mm_shuffle_ps(sum1, sum2, _MM_SHUFFLE(3,2,1,0)) // s2_3 s2_2 s1_1 s1_0
|
||||||
));
|
));
|
||||||
source += 4;
|
|
||||||
dest += 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ideas for further improvement:
|
// Ideas for further improvement:
|
|
@ -63,6 +63,8 @@
|
||||||
#define wxCOMPILER_PREFIX vc110
|
#define wxCOMPILER_PREFIX vc110
|
||||||
#elif _MSC_VER == 1800
|
#elif _MSC_VER == 1800
|
||||||
#define wxCOMPILER_PREFIX vc120
|
#define wxCOMPILER_PREFIX vc120
|
||||||
|
#elif _MSC_VER == 1900
|
||||||
|
#define wxCOMPILER_PREFIX vc140
|
||||||
#else
|
#else
|
||||||
#error "Unknown MSVC compiler version, please report to wx-dev."
|
#error "Unknown MSVC compiler version, please report to wx-dev."
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,7 +53,14 @@
|
||||||
# define __VISUALC11__
|
# define __VISUALC11__
|
||||||
#elif __VISUALC__ < 1900
|
#elif __VISUALC__ < 1900
|
||||||
# define __VISUALC12__
|
# define __VISUALC12__
|
||||||
|
#elif __VISUALC__ < 2000
|
||||||
|
/* There is no __VISUALC13__! */
|
||||||
|
# define __VISUALC14__
|
||||||
#else
|
#else
|
||||||
|
/*
|
||||||
|
Don't forget to update include/msvc/wx/setup.h as well when adding
|
||||||
|
support for a newer MSVC version here.
|
||||||
|
*/
|
||||||
# pragma message("Please update wx/compiler.h to recognize this VC++ version")
|
# pragma message("Please update wx/compiler.h to recognize this VC++ version")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -102,7 +109,13 @@
|
||||||
# define wxVISUALC_VERSION(major) 0
|
# define wxVISUALC_VERSION(major) 0
|
||||||
# define wxCHECK_VISUALC_VERSION(major) 0
|
# define wxCHECK_VISUALC_VERSION(major) 0
|
||||||
#else
|
#else
|
||||||
# define wxVISUALC_VERSION(major) ( (6 + major) * 100 )
|
/*
|
||||||
|
Things used to be simple with the _MSC_VER value and the version number
|
||||||
|
increasing in lock step, but _MSC_VER value of 1900 is VC14 and not the
|
||||||
|
non existing (presumably for the superstitious reasons) VC13, so we now
|
||||||
|
need to account for this with an extra offset.
|
||||||
|
*/
|
||||||
|
# define wxVISUALC_VERSION(major) ( (6 + (major >= 14 ? 1 : 0) + major) * 100 )
|
||||||
# define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) )
|
# define wxCHECK_VISUALC_VERSION(major) ( __VISUALC__ >= wxVISUALC_VERSION(major) )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,69 @@
|
||||||
|
|
||||||
ChangeLog file for zlib
|
ChangeLog file for zlib
|
||||||
|
|
||||||
|
Changes in 1.2.8 (28 Apr 2013)
|
||||||
|
- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
|
||||||
|
- Do not force Z_CONST for C++
|
||||||
|
- Clean up contrib/vstudio [Ro§]
|
||||||
|
- Correct spelling error in zlib.h
|
||||||
|
- Fix mixed line endings in contrib/vstudio
|
||||||
|
|
||||||
|
Changes in 1.2.7.3 (13 Apr 2013)
|
||||||
|
- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc
|
||||||
|
|
||||||
|
Changes in 1.2.7.2 (13 Apr 2013)
|
||||||
|
- Change check for a four-byte type back to hexadecimal
|
||||||
|
- Fix typo in win32/Makefile.msc
|
||||||
|
- Add casts in gzwrite.c for pointer differences
|
||||||
|
|
||||||
|
Changes in 1.2.7.1 (24 Mar 2013)
|
||||||
|
- Replace use of unsafe string functions with snprintf if available
|
||||||
|
- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink]
|
||||||
|
- Fix gzgetc undefine when Z_PREFIX set [Turk]
|
||||||
|
- Eliminate use of mktemp in Makefile (not always available)
|
||||||
|
- Fix bug in 'F' mode for gzopen()
|
||||||
|
- Add inflateGetDictionary() function
|
||||||
|
- Correct comment in deflate.h
|
||||||
|
- Use _snprintf for snprintf in Microsoft C
|
||||||
|
- On Darwin, only use /usr/bin/libtool if libtool is not Apple
|
||||||
|
- Delete "--version" file if created by "ar --version" [Richard G.]
|
||||||
|
- Fix configure check for veracity of compiler error return codes
|
||||||
|
- Fix CMake compilation of static lib for MSVC2010 x64
|
||||||
|
- Remove unused variable in infback9.c
|
||||||
|
- Fix argument checks in gzlog_compress() and gzlog_write()
|
||||||
|
- Clean up the usage of z_const and respect const usage within zlib
|
||||||
|
- Clean up examples/gzlog.[ch] comparisons of different types
|
||||||
|
- Avoid shift equal to bits in type (caused endless loop)
|
||||||
|
- Fix unintialized value bug in gzputc() introduced by const patches
|
||||||
|
- Fix memory allocation error in examples/zran.c [Nor]
|
||||||
|
- Fix bug where gzopen(), gzclose() would write an empty file
|
||||||
|
- Fix bug in gzclose() when gzwrite() runs out of memory
|
||||||
|
- Check for input buffer malloc failure in examples/gzappend.c
|
||||||
|
- Add note to contrib/blast to use binary mode in stdio
|
||||||
|
- Fix comparisons of differently signed integers in contrib/blast
|
||||||
|
- Check for invalid code length codes in contrib/puff
|
||||||
|
- Fix serious but very rare decompression bug in inftrees.c
|
||||||
|
- Update inflateBack() comments, since inflate() can be faster
|
||||||
|
- Use underscored I/O function names for WINAPI_FAMILY
|
||||||
|
- Add _tr_flush_bits to the external symbols prefixed by --zprefix
|
||||||
|
- Add contrib/vstudio/vc10 pre-build step for static only
|
||||||
|
- Quote --version-script argument in CMakeLists.txt
|
||||||
|
- Don't specify --version-script on Apple platforms in CMakeLists.txt
|
||||||
|
- Fix casting error in contrib/testzlib/testzlib.c
|
||||||
|
- Fix types in contrib/minizip to match result of get_crc_table()
|
||||||
|
- Simplify contrib/vstudio/vc10 with 'd' suffix
|
||||||
|
- Add TOP support to win32/Makefile.msc
|
||||||
|
- Suport i686 and amd64 assembler builds in CMakeLists.txt
|
||||||
|
- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h
|
||||||
|
- Add vc11 and vc12 build files to contrib/vstudio
|
||||||
|
- Add gzvprintf() as an undocumented function in zlib
|
||||||
|
- Fix configure for Sun shell
|
||||||
|
- Remove runtime check in configure for four-byte integer type
|
||||||
|
- Add casts and consts to ease user conversion to C++
|
||||||
|
- Add man pages for minizip and miniunzip
|
||||||
|
- In Makefile uninstall, don't rm if preceding cd fails
|
||||||
|
- Do not return Z_BUF_ERROR if deflateParam() has nothing to write
|
||||||
|
|
||||||
Changes in 1.2.7 (2 May 2012)
|
Changes in 1.2.7 (2 May 2012)
|
||||||
- Replace use of memmove() with a simple copy for portability
|
- Replace use of memmove() with a simple copy for portability
|
||||||
- Test for existence of strerror
|
- Test for existence of strerror
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
noinst_LIBRARIES = libpcsx2zlib.a
|
|
||||||
|
|
||||||
libpcsx2zlib_a_SOURCES = \
|
|
||||||
adler32.c crc32.c deflate.h inffast.c inflate.c inftrees.h trees.h zlib.h \
|
|
||||||
crc32.h gzio.c inffast.h inflate.h uncompr.c zutil.c \
|
|
||||||
compress.c deflate.c infback.c inffixed.h inftrees.c trees.c zconf.h zutil.h
|
|
|
@ -1,6 +1,6 @@
|
||||||
ZLIB DATA COMPRESSION LIBRARY
|
ZLIB DATA COMPRESSION LIBRARY
|
||||||
|
|
||||||
zlib 1.2.7 is a general purpose data compression library. All the code is
|
zlib 1.2.8 is a general purpose data compression library. All the code is
|
||||||
thread safe. The data format used by the zlib library is described by RFCs
|
thread safe. The data format used by the zlib library is described by RFCs
|
||||||
(Request for Comments) 1950 to 1952 in the files
|
(Request for Comments) 1950 to 1952 in the files
|
||||||
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
|
||||||
|
@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||||
issue of Dr. Dobb's Journal; a copy of the article is available at
|
issue of Dr. Dobb's Journal; a copy of the article is available at
|
||||||
http://marknelson.us/1997/01/01/zlib-engine/ .
|
http://marknelson.us/1997/01/01/zlib-engine/ .
|
||||||
|
|
||||||
The changes made in version 1.2.7 are documented in the file ChangeLog.
|
The changes made in version 1.2.8 are documented in the file ChangeLog.
|
||||||
|
|
||||||
Unsupported third party contributions are provided in directory contrib/ .
|
Unsupported third party contributions are provided in directory contrib/ .
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ Acknowledgments:
|
||||||
|
|
||||||
Copyright notice:
|
Copyright notice:
|
||||||
|
|
||||||
(C) 1995-2012 Jean-loup Gailly and Mark Adler
|
(C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
|
|
@ -29,7 +29,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
stream.next_in = (Bytef*)source;
|
stream.next_in = (z_const Bytef *)source;
|
||||||
stream.avail_in = (uInt)sourceLen;
|
stream.avail_in = (uInt)sourceLen;
|
||||||
#ifdef MAXSEG_64K
|
#ifdef MAXSEG_64K
|
||||||
/* Check for source > 64K on 16-bit machine: */
|
/* Check for source > 64K on 16-bit machine: */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.c -- compress data using the deflation algorithm
|
/* deflate.c -- compress data using the deflation algorithm
|
||||||
* Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
|
* Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler ";
|
" deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -305,7 +305,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
||||||
s->pending_buf == Z_NULL) {
|
s->pending_buf == Z_NULL) {
|
||||||
s->status = FINISH_STATE;
|
s->status = FINISH_STATE;
|
||||||
strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
|
strm->msg = ERR_MSG(Z_MEM_ERROR);
|
||||||
deflateEnd (strm);
|
deflateEnd (strm);
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
||||||
uInt str, n;
|
uInt str, n;
|
||||||
int wrap;
|
int wrap;
|
||||||
unsigned avail;
|
unsigned avail;
|
||||||
unsigned char *next;
|
z_const unsigned char *next;
|
||||||
|
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
|
if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
|
@ -359,7 +359,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
||||||
avail = strm->avail_in;
|
avail = strm->avail_in;
|
||||||
next = strm->next_in;
|
next = strm->next_in;
|
||||||
strm->avail_in = dictLength;
|
strm->avail_in = dictLength;
|
||||||
strm->next_in = (Bytef *)dictionary;
|
strm->next_in = (z_const Bytef *)dictionary;
|
||||||
fill_window(s);
|
fill_window(s);
|
||||||
while (s->lookahead >= MIN_MATCH) {
|
while (s->lookahead >= MIN_MATCH) {
|
||||||
str = s->strstart;
|
str = s->strstart;
|
||||||
|
@ -513,6 +513,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
||||||
strm->total_in != 0) {
|
strm->total_in != 0) {
|
||||||
/* Flush the last buffer: */
|
/* Flush the last buffer: */
|
||||||
err = deflate(strm, Z_BLOCK);
|
err = deflate(strm, Z_BLOCK);
|
||||||
|
if (err == Z_BUF_ERROR && s->pending == 0)
|
||||||
|
err = Z_OK;
|
||||||
}
|
}
|
||||||
if (s->level != level) {
|
if (s->level != level) {
|
||||||
s->level = level;
|
s->level = level;
|
||||||
|
|
|
@ -104,7 +104,7 @@ typedef struct internal_state {
|
||||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||||
gz_headerp gzhead; /* gzip header information to write */
|
gz_headerp gzhead; /* gzip header information to write */
|
||||||
uInt gzindex; /* where in extra, name, or comment */
|
uInt gzindex; /* where in extra, name, or comment */
|
||||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
Byte method; /* can only be DEFLATED */
|
||||||
int last_flush; /* value of flush param for previous deflate call */
|
int last_flush; /* value of flush param for previous deflate call */
|
||||||
|
|
||||||
/* used by deflate.c: */
|
/* used by deflate.c: */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
|
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -35,6 +35,13 @@
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WINAPI_FAMILY
|
||||||
|
# define open _open
|
||||||
|
# define read _read
|
||||||
|
# define write _write
|
||||||
|
# define close _close
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||||
# define NO_GZCOMPRESS
|
# define NO_GZCOMPRESS
|
||||||
#endif
|
#endif
|
||||||
|
@ -88,6 +95,14 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* unlike snprintf (which is required in C99, yet still not supported by
|
||||||
|
Microsoft more than a decade later!), _snprintf does not guarantee null
|
||||||
|
termination of the result -- however this is only used in gzlib.c where
|
||||||
|
the result is assured to fit in the space provided */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
#endif
|
#endif
|
||||||
|
@ -127,7 +142,8 @@
|
||||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* default i/o buffer size -- double this for output when reading */
|
/* default i/o buffer size -- double this for output when reading (this and
|
||||||
|
twice this must be able to fit in an unsigned type) */
|
||||||
#define GZBUFSIZE 8192
|
#define GZBUFSIZE 8192
|
||||||
|
|
||||||
/* gzip modes, also provide a little integrity check on the passed structure */
|
/* gzip modes, also provide a little integrity check on the passed structure */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
/* gzlib.c -- zlib functions common to reading and writing gzip files
|
||||||
* Copyright (C) 2004, 2010, 2011, 2012 Mark Adler
|
* Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ local gzFile gz_open(path, fd, mode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* allocate gzFile structure to return */
|
/* allocate gzFile structure to return */
|
||||||
state = malloc(sizeof(gz_state));
|
state = (gz_statep)malloc(sizeof(gz_state));
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
state->size = 0; /* no buffers allocated yet */
|
state->size = 0; /* no buffers allocated yet */
|
||||||
|
@ -162,8 +162,10 @@ local gzFile gz_open(path, fd, mode)
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
state->strategy = Z_FIXED;
|
state->strategy = Z_FIXED;
|
||||||
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
state->direct = 1;
|
state->direct = 1;
|
||||||
|
break;
|
||||||
default: /* could consider as an error, but just ignore */
|
default: /* could consider as an error, but just ignore */
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -194,8 +196,8 @@ local gzFile gz_open(path, fd, mode)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
len = strlen(path);
|
len = strlen((const char *)path);
|
||||||
state->path = malloc(len + 1);
|
state->path = (char *)malloc(len + 1);
|
||||||
if (state->path == NULL) {
|
if (state->path == NULL) {
|
||||||
free(state);
|
free(state);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -208,7 +210,11 @@ local gzFile gz_open(path, fd, mode)
|
||||||
*(state->path) = 0;
|
*(state->path) = 0;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||||
|
snprintf(state->path, len + 1, "%s", (const char *)path);
|
||||||
|
#else
|
||||||
strcpy(state->path, path);
|
strcpy(state->path, path);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* compute the flags for open() */
|
/* compute the flags for open() */
|
||||||
oflag =
|
oflag =
|
||||||
|
@ -236,7 +242,7 @@ local gzFile gz_open(path, fd, mode)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fd == -2 ? _wopen(path, oflag, 0666) :
|
fd == -2 ? _wopen(path, oflag, 0666) :
|
||||||
#endif
|
#endif
|
||||||
open(path, oflag, 0666));
|
open((const char *)path, oflag, 0666));
|
||||||
if (state->fd == -1) {
|
if (state->fd == -1) {
|
||||||
free(state->path);
|
free(state->path);
|
||||||
free(state);
|
free(state);
|
||||||
|
@ -282,9 +288,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
|
||||||
char *path; /* identifier for error messages */
|
char *path; /* identifier for error messages */
|
||||||
gzFile gz;
|
gzFile gz;
|
||||||
|
|
||||||
if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
|
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||||
|
snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
|
||||||
|
#else
|
||||||
sprintf(path, "<fd:%d>", fd); /* for debugging */
|
sprintf(path, "<fd:%d>", fd); /* for debugging */
|
||||||
|
#endif
|
||||||
gz = gz_open(path, fd, mode);
|
gz = gz_open(path, fd, mode);
|
||||||
free(path);
|
free(path);
|
||||||
return gz;
|
return gz;
|
||||||
|
@ -531,7 +541,8 @@ const char * ZEXPORT gzerror(file, errnum)
|
||||||
/* return error information */
|
/* return error information */
|
||||||
if (errnum != NULL)
|
if (errnum != NULL)
|
||||||
*errnum = state->err;
|
*errnum = state->err;
|
||||||
return state->msg == NULL ? "" : state->msg;
|
return state->err == Z_MEM_ERROR ? "out of memory" :
|
||||||
|
(state->msg == NULL ? "" : state->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
|
@ -582,21 +593,24 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
|
||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* for an out of memory error, save as static string */
|
/* for an out of memory error, return literal string when requested */
|
||||||
if (err == Z_MEM_ERROR) {
|
if (err == Z_MEM_ERROR)
|
||||||
state->msg = (char *)msg;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* construct error message with path */
|
/* construct error message with path */
|
||||||
if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
|
if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
|
||||||
|
NULL) {
|
||||||
state->err = Z_MEM_ERROR;
|
state->err = Z_MEM_ERROR;
|
||||||
state->msg = (char *)"out of memory";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||||
|
snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
|
||||||
|
"%s%s%s", state->path, ": ", msg);
|
||||||
|
#else
|
||||||
strcpy(state->msg, state->path);
|
strcpy(state->msg, state->path);
|
||||||
strcat(state->msg, ": ");
|
strcat(state->msg, ": ");
|
||||||
strcat(state->msg, msg);
|
strcat(state->msg, msg);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzread.c -- zlib functions for reading gzip files
|
/* gzread.c -- zlib functions for reading gzip files
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
|
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ local int gz_avail(state)
|
||||||
return -1;
|
return -1;
|
||||||
if (state->eof == 0) {
|
if (state->eof == 0) {
|
||||||
if (strm->avail_in) { /* copy what's there to the start */
|
if (strm->avail_in) { /* copy what's there to the start */
|
||||||
unsigned char *p = state->in, *q = strm->next_in;
|
unsigned char *p = state->in;
|
||||||
|
unsigned const char *q = strm->next_in;
|
||||||
unsigned n = strm->avail_in;
|
unsigned n = strm->avail_in;
|
||||||
do {
|
do {
|
||||||
*p++ = *q++;
|
*p++ = *q++;
|
||||||
|
@ -90,8 +91,8 @@ local int gz_look(state)
|
||||||
/* allocate read buffers and inflate memory */
|
/* allocate read buffers and inflate memory */
|
||||||
if (state->size == 0) {
|
if (state->size == 0) {
|
||||||
/* allocate buffers */
|
/* allocate buffers */
|
||||||
state->in = malloc(state->want);
|
state->in = (unsigned char *)malloc(state->want);
|
||||||
state->out = malloc(state->want << 1);
|
state->out = (unsigned char *)malloc(state->want << 1);
|
||||||
if (state->in == NULL || state->out == NULL) {
|
if (state->in == NULL || state->out == NULL) {
|
||||||
if (state->out != NULL)
|
if (state->out != NULL)
|
||||||
free(state->out);
|
free(state->out);
|
||||||
|
@ -352,14 +353,14 @@ int ZEXPORT gzread(file, buf, len)
|
||||||
|
|
||||||
/* large len -- read directly into user buffer */
|
/* large len -- read directly into user buffer */
|
||||||
else if (state->how == COPY) { /* read directly */
|
else if (state->how == COPY) { /* read directly */
|
||||||
if (gz_load(state, buf, len, &n) == -1)
|
if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* large len -- decompress directly into user buffer */
|
/* large len -- decompress directly into user buffer */
|
||||||
else { /* state->how == GZIP */
|
else { /* state->how == GZIP */
|
||||||
strm->avail_out = len;
|
strm->avail_out = len;
|
||||||
strm->next_out = buf;
|
strm->next_out = (unsigned char *)buf;
|
||||||
if (gz_decomp(state) == -1)
|
if (gz_decomp(state) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
n = state->x.have;
|
n = state->x.have;
|
||||||
|
@ -378,7 +379,11 @@ int ZEXPORT gzread(file, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
#undef gzgetc
|
#ifdef Z_PREFIX_SET
|
||||||
|
# undef z_gzgetc
|
||||||
|
#else
|
||||||
|
# undef gzgetc
|
||||||
|
#endif
|
||||||
int ZEXPORT gzgetc(file)
|
int ZEXPORT gzgetc(file)
|
||||||
gzFile file;
|
gzFile file;
|
||||||
{
|
{
|
||||||
|
@ -518,7 +523,7 @@ char * ZEXPORT gzgets(file, buf, len)
|
||||||
|
|
||||||
/* look for end-of-line in current output buffer */
|
/* look for end-of-line in current output buffer */
|
||||||
n = state->x.have > left ? left : state->x.have;
|
n = state->x.have > left ? left : state->x.have;
|
||||||
eol = memchr(state->x.next, '\n', n);
|
eol = (unsigned char *)memchr(state->x.next, '\n', n);
|
||||||
if (eol != NULL)
|
if (eol != NULL)
|
||||||
n = (unsigned)(eol - state->x.next) + 1;
|
n = (unsigned)(eol - state->x.next) + 1;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* gzwrite.c -- zlib functions for writing gzip files
|
/* gzwrite.c -- zlib functions for writing gzip files
|
||||||
* Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler
|
* Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ local int gz_init(state)
|
||||||
z_streamp strm = &(state->strm);
|
z_streamp strm = &(state->strm);
|
||||||
|
|
||||||
/* allocate input buffer */
|
/* allocate input buffer */
|
||||||
state->in = malloc(state->want);
|
state->in = (unsigned char *)malloc(state->want);
|
||||||
if (state->in == NULL) {
|
if (state->in == NULL) {
|
||||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -28,7 +28,7 @@ local int gz_init(state)
|
||||||
/* only need output buffer and deflate state if compressing */
|
/* only need output buffer and deflate state if compressing */
|
||||||
if (!state->direct) {
|
if (!state->direct) {
|
||||||
/* allocate output buffer */
|
/* allocate output buffer */
|
||||||
state->out = malloc(state->want);
|
state->out = (unsigned char *)malloc(state->want);
|
||||||
if (state->out == NULL) {
|
if (state->out == NULL) {
|
||||||
free(state->in);
|
free(state->in);
|
||||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||||
|
@ -168,7 +168,6 @@ int ZEXPORT gzwrite(file, buf, len)
|
||||||
unsigned len;
|
unsigned len;
|
||||||
{
|
{
|
||||||
unsigned put = len;
|
unsigned put = len;
|
||||||
unsigned n;
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
|
|
||||||
|
@ -208,16 +207,19 @@ int ZEXPORT gzwrite(file, buf, len)
|
||||||
if (len < state->size) {
|
if (len < state->size) {
|
||||||
/* copy to input buffer, compress when full */
|
/* copy to input buffer, compress when full */
|
||||||
do {
|
do {
|
||||||
|
unsigned have, copy;
|
||||||
|
|
||||||
if (strm->avail_in == 0)
|
if (strm->avail_in == 0)
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
n = state->size - strm->avail_in;
|
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
|
||||||
if (n > len)
|
copy = state->size - have;
|
||||||
n = len;
|
if (copy > len)
|
||||||
memcpy(strm->next_in + strm->avail_in, buf, n);
|
copy = len;
|
||||||
strm->avail_in += n;
|
memcpy(state->in + have, buf, copy);
|
||||||
state->x.pos += n;
|
strm->avail_in += copy;
|
||||||
buf = (char *)buf + n;
|
state->x.pos += copy;
|
||||||
len -= n;
|
buf = (const char *)buf + copy;
|
||||||
|
len -= copy;
|
||||||
if (len && gz_comp(state, Z_NO_FLUSH) == -1)
|
if (len && gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
} while (len);
|
} while (len);
|
||||||
|
@ -229,7 +231,7 @@ int ZEXPORT gzwrite(file, buf, len)
|
||||||
|
|
||||||
/* directly compress user buffer to file */
|
/* directly compress user buffer to file */
|
||||||
strm->avail_in = len;
|
strm->avail_in = len;
|
||||||
strm->next_in = (voidp)buf;
|
strm->next_in = (z_const Bytef *)buf;
|
||||||
state->x.pos += len;
|
state->x.pos += len;
|
||||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -244,6 +246,7 @@ int ZEXPORT gzputc(file, c)
|
||||||
gzFile file;
|
gzFile file;
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
|
unsigned have;
|
||||||
unsigned char buf[1];
|
unsigned char buf[1];
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
|
@ -267,13 +270,17 @@ int ZEXPORT gzputc(file, c)
|
||||||
|
|
||||||
/* try writing to input buffer for speed (state->size == 0 if buffer not
|
/* try writing to input buffer for speed (state->size == 0 if buffer not
|
||||||
initialized) */
|
initialized) */
|
||||||
if (strm->avail_in < state->size) {
|
if (state->size) {
|
||||||
if (strm->avail_in == 0)
|
if (strm->avail_in == 0)
|
||||||
strm->next_in = state->in;
|
strm->next_in = state->in;
|
||||||
strm->next_in[strm->avail_in++] = c;
|
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
|
||||||
|
if (have < state->size) {
|
||||||
|
state->in[have] = c;
|
||||||
|
strm->avail_in++;
|
||||||
state->x.pos++;
|
state->x.pos++;
|
||||||
return c & 0xff;
|
return c & 0xff;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* no room in buffer or not initialized, use gz_write() */
|
/* no room in buffer or not initialized, use gz_write() */
|
||||||
buf[0] = c;
|
buf[0] = c;
|
||||||
|
@ -300,12 +307,11 @@ int ZEXPORT gzputs(file, str)
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
|
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
|
||||||
{
|
{
|
||||||
int size, len;
|
int size, len;
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
va_list va;
|
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
|
@ -335,25 +341,20 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
|
||||||
/* do the printf() into the input buffer, put length in len */
|
/* do the printf() into the input buffer, put length in len */
|
||||||
size = (int)(state->size);
|
size = (int)(state->size);
|
||||||
state->in[size - 1] = 0;
|
state->in[size - 1] = 0;
|
||||||
va_start(va, format);
|
|
||||||
#ifdef NO_vsnprintf
|
#ifdef NO_vsnprintf
|
||||||
# ifdef HAS_vsprintf_void
|
# ifdef HAS_vsprintf_void
|
||||||
(void)vsprintf((char *)(state->in), format, va);
|
(void)vsprintf((char *)(state->in), format, va);
|
||||||
va_end(va);
|
|
||||||
for (len = 0; len < size; len++)
|
for (len = 0; len < size; len++)
|
||||||
if (state->in[len] == 0) break;
|
if (state->in[len] == 0) break;
|
||||||
# else
|
# else
|
||||||
len = vsprintf((char *)(state->in), format, va);
|
len = vsprintf((char *)(state->in), format, va);
|
||||||
va_end(va);
|
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# ifdef HAS_vsnprintf_void
|
# ifdef HAS_vsnprintf_void
|
||||||
(void)vsnprintf((char *)(state->in), size, format, va);
|
(void)vsnprintf((char *)(state->in), size, format, va);
|
||||||
va_end(va);
|
|
||||||
len = strlen((char *)(state->in));
|
len = strlen((char *)(state->in));
|
||||||
# else
|
# else
|
||||||
len = vsnprintf((char *)(state->in), size, format, va);
|
len = vsnprintf((char *)(state->in), size, format, va);
|
||||||
va_end(va);
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -368,6 +369,17 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
va_start(va, format);
|
||||||
|
ret = gzvprintf(file, format, va);
|
||||||
|
va_end(va);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#else /* !STDC && !Z_HAVE_STDARG_H */
|
#else /* !STDC && !Z_HAVE_STDARG_H */
|
||||||
|
|
||||||
/* -- see zlib.h -- */
|
/* -- see zlib.h -- */
|
||||||
|
@ -547,9 +559,9 @@ int ZEXPORT gzclose_w(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush, free memory, and close file */
|
/* flush, free memory, and close file */
|
||||||
if (state->size) {
|
|
||||||
if (gz_comp(state, Z_FINISH) == -1)
|
if (gz_comp(state, Z_FINISH) == -1)
|
||||||
ret = state->err;
|
ret = state->err;
|
||||||
|
if (state->size) {
|
||||||
if (!state->direct) {
|
if (!state->direct) {
|
||||||
(void)deflateEnd(&(state->strm));
|
(void)deflateEnd(&(state->strm));
|
||||||
free(state->out);
|
free(state->out);
|
||||||
|
|
|
@ -255,7 +255,7 @@ out_func out;
|
||||||
void FAR *out_desc;
|
void FAR *out_desc;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
unsigned have, left; /* available input and output */
|
unsigned have, left; /* available input and output */
|
||||||
unsigned long hold; /* bit buffer */
|
unsigned long hold; /* bit buffer */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inffast.c -- fast decoding
|
/* inffast.c -- fast decoding
|
||||||
* Copyright (C) 1995-2008, 2010 Mark Adler
|
* Copyright (C) 1995-2008, 2010, 2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ z_streamp strm;
|
||||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *in; /* local strm->next_in */
|
z_const unsigned char FAR *in; /* local strm->next_in */
|
||||||
unsigned char FAR *last; /* while in < last, enough input available */
|
z_const unsigned char FAR *last; /* have enough input while in < last */
|
||||||
unsigned char FAR *out; /* local strm->next_out */
|
unsigned char FAR *out; /* local strm->next_out */
|
||||||
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
||||||
unsigned char FAR *end; /* while out < end, enough space available */
|
unsigned char FAR *end; /* while out < end, enough space available */
|
||||||
|
|
|
@ -93,11 +93,12 @@
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
local void fixedtables OF((struct inflate_state FAR *state));
|
local void fixedtables OF((struct inflate_state FAR *state));
|
||||||
local int updatewindow OF((z_streamp strm, unsigned out));
|
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
||||||
|
unsigned copy));
|
||||||
#ifdef BUILDFIXED
|
#ifdef BUILDFIXED
|
||||||
void makefixed OF((void));
|
void makefixed OF((void));
|
||||||
#endif
|
#endif
|
||||||
local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
|
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
||||||
unsigned len));
|
unsigned len));
|
||||||
|
|
||||||
int ZEXPORT inflateResetKeep(strm)
|
int ZEXPORT inflateResetKeep(strm)
|
||||||
|
@ -375,12 +376,13 @@ void makefixed()
|
||||||
output will fall in the output data, making match copies simpler and faster.
|
output will fall in the output data, making match copies simpler and faster.
|
||||||
The advantage may be dependent on the size of the processor's data caches.
|
The advantage may be dependent on the size of the processor's data caches.
|
||||||
*/
|
*/
|
||||||
local int updatewindow(strm, out)
|
local int updatewindow(strm, end, copy)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
unsigned out;
|
const Bytef *end;
|
||||||
|
unsigned copy;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned copy, dist;
|
unsigned dist;
|
||||||
|
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
|
||||||
|
@ -400,19 +402,18 @@ unsigned out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy state->wsize or less output bytes into the circular window */
|
/* copy state->wsize or less output bytes into the circular window */
|
||||||
copy = out - strm->avail_out;
|
|
||||||
if (copy >= state->wsize) {
|
if (copy >= state->wsize) {
|
||||||
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
|
zmemcpy(state->window, end - state->wsize, state->wsize);
|
||||||
state->wnext = 0;
|
state->wnext = 0;
|
||||||
state->whave = state->wsize;
|
state->whave = state->wsize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dist = state->wsize - state->wnext;
|
dist = state->wsize - state->wnext;
|
||||||
if (dist > copy) dist = copy;
|
if (dist > copy) dist = copy;
|
||||||
zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
|
zmemcpy(state->window + state->wnext, end - copy, dist);
|
||||||
copy -= dist;
|
copy -= dist;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
zmemcpy(state->window, strm->next_out - copy, copy);
|
zmemcpy(state->window, end - copy, copy);
|
||||||
state->wnext = copy;
|
state->wnext = copy;
|
||||||
state->whave = state->wsize;
|
state->whave = state->wsize;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +607,7 @@ z_streamp strm;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned char FAR *next; /* next input */
|
z_const unsigned char FAR *next; /* next input */
|
||||||
unsigned char FAR *put; /* next output */
|
unsigned char FAR *put; /* next output */
|
||||||
unsigned have, left; /* available input and output */
|
unsigned have, left; /* available input and output */
|
||||||
unsigned long hold; /* bit buffer */
|
unsigned long hold; /* bit buffer */
|
||||||
|
@ -920,7 +921,7 @@ int flush;
|
||||||
while (state->have < 19)
|
while (state->have < 19)
|
||||||
state->lens[order[state->have++]] = 0;
|
state->lens[order[state->have++]] = 0;
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (const code FAR *)(state->next);
|
||||||
state->lenbits = 7;
|
state->lenbits = 7;
|
||||||
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
||||||
&(state->lenbits), state->work);
|
&(state->lenbits), state->work);
|
||||||
|
@ -994,7 +995,7 @@ int flush;
|
||||||
values here (9 and 6) without reading the comments in inftrees.h
|
values here (9 and 6) without reading the comments in inftrees.h
|
||||||
concerning the ENOUGH constants, which depend on those values */
|
concerning the ENOUGH constants, which depend on those values */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (const code FAR *)(state->next);
|
||||||
state->lenbits = 9;
|
state->lenbits = 9;
|
||||||
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
||||||
&(state->lenbits), state->work);
|
&(state->lenbits), state->work);
|
||||||
|
@ -1003,7 +1004,7 @@ int flush;
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->distcode = (code const FAR *)(state->next);
|
state->distcode = (const code FAR *)(state->next);
|
||||||
state->distbits = 6;
|
state->distbits = 6;
|
||||||
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
||||||
&(state->next), &(state->distbits), state->work);
|
&(state->next), &(state->distbits), state->work);
|
||||||
|
@ -1230,7 +1231,7 @@ int flush;
|
||||||
RESTORE();
|
RESTORE();
|
||||||
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
||||||
(state->mode < CHECK || flush != Z_FINISH)))
|
(state->mode < CHECK || flush != Z_FINISH)))
|
||||||
if (updatewindow(strm, out)) {
|
if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
|
||||||
state->mode = MEM;
|
state->mode = MEM;
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1264,6 +1265,29 @@ z_streamp strm;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
|
||||||
|
z_streamp strm;
|
||||||
|
Bytef *dictionary;
|
||||||
|
uInt *dictLength;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
/* check state */
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
|
||||||
|
/* copy dictionary */
|
||||||
|
if (state->whave && dictionary != Z_NULL) {
|
||||||
|
zmemcpy(dictionary, state->window + state->wnext,
|
||||||
|
state->whave - state->wnext);
|
||||||
|
zmemcpy(dictionary + state->whave - state->wnext,
|
||||||
|
state->window, state->wnext);
|
||||||
|
}
|
||||||
|
if (dictLength != Z_NULL)
|
||||||
|
*dictLength = state->whave;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
const Bytef *dictionary;
|
const Bytef *dictionary;
|
||||||
|
@ -1271,8 +1295,6 @@ uInt dictLength;
|
||||||
{
|
{
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
unsigned long dictid;
|
unsigned long dictid;
|
||||||
unsigned char *next;
|
|
||||||
unsigned avail;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* check state */
|
/* check state */
|
||||||
|
@ -1291,13 +1313,7 @@ uInt dictLength;
|
||||||
|
|
||||||
/* copy dictionary to window using updatewindow(), which will amend the
|
/* copy dictionary to window using updatewindow(), which will amend the
|
||||||
existing dictionary if appropriate */
|
existing dictionary if appropriate */
|
||||||
next = strm->next_out;
|
ret = updatewindow(strm, dictionary + dictLength, dictLength);
|
||||||
avail = strm->avail_out;
|
|
||||||
strm->next_out = (Bytef *)dictionary + dictLength;
|
|
||||||
strm->avail_out = 0;
|
|
||||||
ret = updatewindow(strm, dictLength);
|
|
||||||
strm->avail_out = avail;
|
|
||||||
strm->next_out = next;
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
state->mode = MEM;
|
state->mode = MEM;
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
|
@ -1337,7 +1353,7 @@ gz_headerp head;
|
||||||
*/
|
*/
|
||||||
local unsigned syncsearch(have, buf, len)
|
local unsigned syncsearch(have, buf, len)
|
||||||
unsigned FAR *have;
|
unsigned FAR *have;
|
||||||
unsigned char FAR *buf;
|
const unsigned char FAR *buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
{
|
{
|
||||||
unsigned got;
|
unsigned got;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2012 Mark Adler
|
* Copyright (C) 1995-2013 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.7 Copyright 1995-2012 Mark Adler ";
|
" inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -62,7 +62,7 @@ unsigned short FAR *work;
|
||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
|
@ -208,8 +208,8 @@ unsigned short FAR *work;
|
||||||
mask = used - 1; /* mask for comparing low */
|
mask = used - 1; /* mask for comparing low */
|
||||||
|
|
||||||
/* check available table space */
|
/* check available table space */
|
||||||
if ((type == LENS && used >= ENOUGH_LENS) ||
|
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||||
(type == DISTS && used >= ENOUGH_DISTS))
|
(type == DISTS && used > ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* process all codes and make table entries */
|
/* process all codes and make table entries */
|
||||||
|
@ -277,8 +277,8 @@ unsigned short FAR *work;
|
||||||
|
|
||||||
/* check for enough space */
|
/* check for enough space */
|
||||||
used += 1U << curr;
|
used += 1U << curr;
|
||||||
if ((type == LENS && used >= ENOUGH_LENS) ||
|
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||||
(type == DISTS && used >= ENOUGH_DISTS))
|
(type == DISTS && used > ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* point entry in root table to sub-table */
|
/* point entry in root table to sub-table */
|
||||||
|
|
|
@ -146,8 +146,8 @@ local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||||
local int build_bl_tree OF((deflate_state *s));
|
local int build_bl_tree OF((deflate_state *s));
|
||||||
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||||
int blcodes));
|
int blcodes));
|
||||||
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
||||||
ct_data *dtree));
|
const ct_data *dtree));
|
||||||
local int detect_data_type OF((deflate_state *s));
|
local int detect_data_type OF((deflate_state *s));
|
||||||
local unsigned bi_reverse OF((unsigned value, int length));
|
local unsigned bi_reverse OF((unsigned value, int length));
|
||||||
local void bi_windup OF((deflate_state *s));
|
local void bi_windup OF((deflate_state *s));
|
||||||
|
@ -972,7 +972,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
||||||
#endif
|
#endif
|
||||||
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
||||||
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
|
compress_block(s, (const ct_data *)static_ltree,
|
||||||
|
(const ct_data *)static_dtree);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len += 3 + s->static_len;
|
s->compressed_len += 3 + s->static_len;
|
||||||
#endif
|
#endif
|
||||||
|
@ -980,7 +981,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
send_bits(s, (DYN_TREES<<1)+last, 3);
|
send_bits(s, (DYN_TREES<<1)+last, 3);
|
||||||
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
||||||
max_blindex+1);
|
max_blindex+1);
|
||||||
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
|
compress_block(s, (const ct_data *)s->dyn_ltree,
|
||||||
|
(const ct_data *)s->dyn_dtree);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len += 3 + s->opt_len;
|
s->compressed_len += 3 + s->opt_len;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1057,8 +1059,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||||
*/
|
*/
|
||||||
local void compress_block(s, ltree, dtree)
|
local void compress_block(s, ltree, dtree)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
ct_data *ltree; /* literal tree */
|
const ct_data *ltree; /* literal tree */
|
||||||
ct_data *dtree; /* distance tree */
|
const ct_data *dtree; /* distance tree */
|
||||||
{
|
{
|
||||||
unsigned dist; /* distance of matched string */
|
unsigned dist; /* distance of matched string */
|
||||||
int lc; /* match length or unmatched char (if dist == 0) */
|
int lc; /* match length or unmatched char (if dist == 0) */
|
||||||
|
|
|
@ -30,7 +30,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
||||||
z_stream stream;
|
z_stream stream;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
stream.next_in = (Bytef*)source;
|
stream.next_in = (z_const Bytef *)source;
|
||||||
stream.avail_in = (uInt)sourceLen;
|
stream.avail_in = (uInt)sourceLen;
|
||||||
/* Check for source > 64K on 16-bit machine: */
|
/* Check for source > 64K on 16-bit machine: */
|
||||||
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* zconf.h -- configuration of the zlib compression library
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
* Copyright (C) 1995-2012 Jean-loup Gailly.
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
# define _dist_code z__dist_code
|
# define _dist_code z__dist_code
|
||||||
# define _length_code z__length_code
|
# define _length_code z__length_code
|
||||||
# define _tr_align z__tr_align
|
# define _tr_align z__tr_align
|
||||||
|
# define _tr_flush_bits z__tr_flush_bits
|
||||||
# define _tr_flush_block z__tr_flush_block
|
# define _tr_flush_block z__tr_flush_block
|
||||||
# define _tr_init z__tr_init
|
# define _tr_init z__tr_init
|
||||||
# define _tr_stored_block z__tr_stored_block
|
# define _tr_stored_block z__tr_stored_block
|
||||||
|
@ -77,6 +78,7 @@
|
||||||
# define gzopen_w z_gzopen_w
|
# define gzopen_w z_gzopen_w
|
||||||
# endif
|
# endif
|
||||||
# define gzprintf z_gzprintf
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzvprintf z_gzvprintf
|
||||||
# define gzputc z_gzputc
|
# define gzputc z_gzputc
|
||||||
# define gzputs z_gzputs
|
# define gzputs z_gzputs
|
||||||
# define gzread z_gzread
|
# define gzread z_gzread
|
||||||
|
@ -103,6 +105,7 @@
|
||||||
# define inflateReset z_inflateReset
|
# define inflateReset z_inflateReset
|
||||||
# define inflateReset2 z_inflateReset2
|
# define inflateReset2 z_inflateReset2
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateGetDictionary z_inflateGetDictionary
|
||||||
# define inflateSync z_inflateSync
|
# define inflateSync z_inflateSync
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
# define inflateUndermine z_inflateUndermine
|
# define inflateUndermine z_inflateUndermine
|
||||||
|
@ -388,21 +391,15 @@ typedef uLong FAR uLongf;
|
||||||
typedef Byte *voidp;
|
typedef Byte *voidp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ./configure may #define Z_U4 here */
|
|
||||||
|
|
||||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
# if (UINT_MAX == 0xffffffffUL)
|
# if (UINT_MAX == 0xffffffffUL)
|
||||||
# define Z_U4 unsigned
|
# define Z_U4 unsigned
|
||||||
# else
|
# elif (ULONG_MAX == 0xffffffffUL)
|
||||||
# if (ULONG_MAX == 0xffffffffUL)
|
|
||||||
# define Z_U4 unsigned long
|
# define Z_U4 unsigned long
|
||||||
# else
|
# elif (USHRT_MAX == 0xffffffffUL)
|
||||||
# if (USHRT_MAX == 0xffffffffUL)
|
|
||||||
# define Z_U4 unsigned short
|
# define Z_U4 unsigned short
|
||||||
# endif
|
# endif
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_U4
|
#ifdef Z_U4
|
||||||
|
@ -425,8 +422,16 @@ typedef uLong FAR uLongf;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
# include <stdarg.h> /* for va_list */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
# ifndef Z_SOLO
|
||||||
# include <stddef.h> /* for wchar_t */
|
# include <stddef.h> /* for wchar_t */
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||||
|
@ -435,7 +440,7 @@ typedef uLong FAR uLongf;
|
||||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||||
* equivalently requesting no 64-bit operations
|
* equivalently requesting no 64-bit operations
|
||||||
*/
|
*/
|
||||||
#if defined(LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||||
# undef _LARGEFILE64_SOURCE
|
# undef _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -443,7 +448,7 @@ typedef uLong FAR uLongf;
|
||||||
# define Z_HAVE_UNISTD_H
|
# define Z_HAVE_UNISTD_H
|
||||||
#endif
|
#endif
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
# if defined(Z_HAVE_UNISTD_H) || defined(LARGEFILE64_SOURCE)
|
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
# ifdef VMS
|
# ifdef VMS
|
||||||
# include <unixio.h> /* for off_t */
|
# include <unixio.h> /* for off_t */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
version 1.2.7, May 2nd, 2012
|
version 1.2.8, April 28th, 2013
|
||||||
|
|
||||||
Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@ -37,11 +37,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.2.7"
|
#define ZLIB_VERSION "1.2.8"
|
||||||
#define ZLIB_VERNUM 0x1270
|
#define ZLIB_VERNUM 0x1280
|
||||||
#define ZLIB_VER_MAJOR 1
|
#define ZLIB_VER_MAJOR 1
|
||||||
#define ZLIB_VER_MINOR 2
|
#define ZLIB_VER_MINOR 2
|
||||||
#define ZLIB_VER_REVISION 7
|
#define ZLIB_VER_REVISION 8
|
||||||
#define ZLIB_VER_SUBREVISION 0
|
#define ZLIB_VER_SUBREVISION 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -839,6 +839,21 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||||
inflate().
|
inflate().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
|
||||||
|
Bytef *dictionary,
|
||||||
|
uInt *dictLength));
|
||||||
|
/*
|
||||||
|
Returns the sliding dictionary being maintained by inflate. dictLength is
|
||||||
|
set to the number of bytes in the dictionary, and that many bytes are copied
|
||||||
|
to dictionary. dictionary must have enough space, where 32768 bytes is
|
||||||
|
always enough. If inflateGetDictionary() is called with dictionary equal to
|
||||||
|
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
||||||
|
Similary, if dictLength is Z_NULL, then it is not set.
|
||||||
|
|
||||||
|
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
|
||||||
|
stream state is inconsistent.
|
||||||
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||||
/*
|
/*
|
||||||
Skips invalid compressed data until a possible full flush point (see above
|
Skips invalid compressed data until a possible full flush point (see above
|
||||||
|
@ -846,7 +861,7 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||||
available input is skipped. No output is provided.
|
available input is skipped. No output is provided.
|
||||||
|
|
||||||
inflateSync searches for a 00 00 FF FF pattern in the compressed data.
|
inflateSync searches for a 00 00 FF FF pattern in the compressed data.
|
||||||
All full flush points have this pattern, but not all occurences of this
|
All full flush points have this pattern, but not all occurrences of this
|
||||||
pattern are full flush points.
|
pattern are full flush points.
|
||||||
|
|
||||||
inflateSync returns Z_OK if a possible full flush point has been found,
|
inflateSync returns Z_OK if a possible full flush point has been found,
|
||||||
|
@ -1007,7 +1022,8 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
|
||||||
the version of the header file.
|
the version of the header file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
|
typedef unsigned (*in_func) OF((void FAR *,
|
||||||
|
z_const unsigned char FAR * FAR *));
|
||||||
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
|
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
||||||
|
@ -1015,11 +1031,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
|
||||||
out_func out, void FAR *out_desc));
|
out_func out, void FAR *out_desc));
|
||||||
/*
|
/*
|
||||||
inflateBack() does a raw inflate with a single call using a call-back
|
inflateBack() does a raw inflate with a single call using a call-back
|
||||||
interface for input and output. This is more efficient than inflate() for
|
interface for input and output. This is potentially more efficient than
|
||||||
file i/o applications in that it avoids copying between the output and the
|
inflate() for file i/o applications, in that it avoids copying between the
|
||||||
sliding window by simply making the window itself the output buffer. This
|
output and the sliding window by simply making the window itself the output
|
||||||
function trusts the application to not change the output buffer passed by
|
buffer. inflate() can be faster on modern CPUs when used with large
|
||||||
the output function, at least until inflateBack() returns.
|
buffers. inflateBack() trusts the application to not change the output
|
||||||
|
buffer passed by the output function, at least until inflateBack() returns.
|
||||||
|
|
||||||
inflateBackInit() must be called first to allocate the internal state
|
inflateBackInit() must be called first to allocate the internal state
|
||||||
and to initialize the state with the user-provided window buffer.
|
and to initialize the state with the user-provided window buffer.
|
||||||
|
@ -1736,6 +1753,13 @@ ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
||||||
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
|
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
|
||||||
const char *mode));
|
const char *mode));
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
# ifndef Z_SOLO
|
||||||
|
ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
|
||||||
|
const char *format,
|
||||||
|
va_list va));
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
struct internal_state {int dummy;}; /* for buggy compilers */
|
struct internal_state {int dummy;}; /* for buggy compilers */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * const z_errmsg[10] = {
|
z_const char * const z_errmsg[10] = {
|
||||||
"need dictionary", /* Z_NEED_DICT 2 */
|
"need dictionary", /* Z_NEED_DICT 2 */
|
||||||
"stream end", /* Z_STREAM_END 1 */
|
"stream end", /* Z_STREAM_END 1 */
|
||||||
"", /* Z_OK 0 */
|
"", /* Z_OK 0 */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2012 Jean-loup Gailly.
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -44,13 +44,13 @@ typedef unsigned short ush;
|
||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
/* (size given to avoid silly warnings with Visual C++) */
|
/* (size given to avoid silly warnings with Visual C++) */
|
||||||
|
|
||||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||||
|
|
||||||
#define ERR_RETURN(strm,err) \
|
#define ERR_RETURN(strm,err) \
|
||||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
return (strm->msg = ERR_MSG(err), (err))
|
||||||
/* To be used only when the state is known to be valid */
|
/* To be used only when the state is known to be valid */
|
||||||
|
|
||||||
/* common constants */
|
/* common constants */
|
||||||
|
@ -168,7 +168,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* provide prototypes for these when building zlib without LFS */
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
#if !defined(_WIN32) && \
|
||||||
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -185,25 +185,32 @@ Global
|
||||||
{18E42F6F-3A62-41EE-B42F-79366C4F1E95}.Release|x64.Build.0 = Release SSE2|x64
|
{18E42F6F-3A62-41EE-B42F-79366C4F1E95}.Release|x64.Build.0 = Release SSE2|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.ActiveCfg = Debug|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.Build.0 = Debug|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|x64.ActiveCfg = Debug|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|x64.Build.0 = Debug|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.ActiveCfg = Devel|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.ActiveCfg = Devel|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.Build.0 = Devel|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.Build.0 = Devel|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|x64.ActiveCfg = Devel|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|x64.ActiveCfg = Devel|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|x64.Build.0 = Devel|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|Win32.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|Win32.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|Win32.Build.0 = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|Win32.Build.0 = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|x64.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|x64.ActiveCfg = Release|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX|x64.Build.0 = Release|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|Win32.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|Win32.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|Win32.Build.0 = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|Win32.Build.0 = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|x64.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|x64.ActiveCfg = Release|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release AVX2|x64.Build.0 = Release|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|Win32.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|Win32.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|Win32.Build.0 = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|Win32.Build.0 = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|x64.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|x64.ActiveCfg = Release|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSE4|x64.Build.0 = Release|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|Win32.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|Win32.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|Win32.Build.0 = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|Win32.Build.0 = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|x64.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|x64.ActiveCfg = Release|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release SSSE3|x64.Build.0 = Release|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.Build.0 = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.Build.0 = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|x64.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|x64.Build.0 = Release|x64
|
||||||
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.ActiveCfg = Debug|Win32
|
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.Build.0 = Debug|Win32
|
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|x64.ActiveCfg = Debug|Win32
|
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|x64.ActiveCfg = Debug|Win32
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(SvnRootDir)\3rdparty\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SvnRootDir)\3rdparty\;$(SvnRootDir)\3rdparty\soundtouch\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalLibraryDirectories>$(SvnRootDir)\deps\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SvnRootDir)\deps\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
|
|
@ -97,13 +97,16 @@ Global
|
||||||
{5F78E90B-BD22-47B1-9CA5-7A80F4DF5EF3}.Release|x64.ActiveCfg = Release|Win32
|
{5F78E90B-BD22-47B1-9CA5-7A80F4DF5EF3}.Release|x64.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.ActiveCfg = Debug|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.Build.0 = Debug|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|x64.ActiveCfg = Debug|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Debug|x64.Build.0 = Debug|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.ActiveCfg = Devel|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.ActiveCfg = Devel|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.Build.0 = Devel|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|Win32.Build.0 = Devel|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|x64.ActiveCfg = Devel|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|x64.ActiveCfg = Devel|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Devel|x64.Build.0 = Devel|x64
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.Build.0 = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|Win32.Build.0 = Release|Win32
|
||||||
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|x64.ActiveCfg = Release|Win32
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{E9B51944-7E6D-4BCD-83F2-7BBD5A46182D}.Release|x64.Build.0 = Release|x64
|
||||||
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.ActiveCfg = Debug|Win32
|
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.Build.0 = Debug|Win32
|
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|x64.ActiveCfg = Debug|Win32
|
{2F6C0388-20CB-4242-9F6C-A6EBB6A83F47}.Debug|x64.ActiveCfg = Debug|Win32
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "WavFile.h"
|
#include "WavFile.h"
|
||||||
#else
|
#else
|
||||||
#include "soundtouch/WavFile.h"
|
#include "soundtouch/source/SoundStretch/WavFile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static WavOutFile* _new_WavOutFile( const char* destfile )
|
static WavOutFile* _new_WavOutFile( const char* destfile )
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "WavFile.h"
|
#include "WavFile.h"
|
||||||
#else
|
#else
|
||||||
#include "soundtouch/WavFile.h"
|
#include "soundtouch/source/SoundStretch/WavFile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char libraryName[256];
|
char libraryName[256];
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "WavFile.h"
|
#include "WavFile.h"
|
||||||
#else
|
#else
|
||||||
#include "soundtouch/WavFile.h"
|
#include "soundtouch/source/SoundStretch/WavFile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s32 g_logsound = 0;
|
s32 g_logsound = 0;
|
||||||
|
|
Loading…
Reference in New Issue