Updated WavPack to version 4.60.1
parent
63b8f55dcf
commit
43704d16ce
|
@ -1,85 +1,103 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
This package contains all the source code required to build the WavPack
|
||||
command-line programs and the WavPack library and it has been tested on many
|
||||
platforms. For example code using the library you might want to check some
|
||||
of the plugin sources in the Windows source release.
|
||||
platforms.
|
||||
|
||||
To build everything, type:
|
||||
On Windows there are solution and project files for Visual Studio 2005 and
|
||||
additional sourcecode to build the CoolEdit/Audition plugin and the winamp
|
||||
plugin. The CoolEdit/Audition plugin provides a good example for using the
|
||||
library to both read and write WavPack files.
|
||||
|
||||
1. ./configure
|
||||
To build everything on Linux, type:
|
||||
|
||||
1. ./configure [--enable-mmx]
|
||||
2. make
|
||||
3. make install (optionally, to install into /usr/local/bin)
|
||||
|
||||
If you are using the code directly from SVN (rather than a distribution)
|
||||
then you will need to do a ./autogen.sh before the configure step. For
|
||||
processors that support MMX, use the --enable-mmx switch to utilize MMX
|
||||
intrinsics to speed up encoding of stereo 24-bit (and higher) audio.
|
||||
|
||||
Notes:
|
||||
|
||||
1. This code is designed to be much easier to port to other platforms than
|
||||
the previous version of WavPack. File I/O is done with streams and all file
|
||||
functions (except "fopen") are handled in a wrapper in the "utils.c"
|
||||
module. The code is even written to be endian-independent and a compile
|
||||
option is provided to eliminate the DOS-specific directory searches.
|
||||
1. There are two documentation files contained in the distribution:
|
||||
|
||||
doc/library_use.txt contains a detailed description of the API provided
|
||||
by WavPack library appropriate for read and writing
|
||||
WavPack files
|
||||
|
||||
doc/file_format.txt contains a description of the WavPack file format,
|
||||
including details needed for parsing WavPack blocks
|
||||
and interpreting the block header and flags
|
||||
|
||||
There is also a description of the WavPack algorithms in the forth edition
|
||||
of David Salomon's book "Data Compression: The Complete Reference". The
|
||||
section on WavPack can be found here:
|
||||
|
||||
www.wavpack.com/WavPack.pdf
|
||||
|
||||
2. This code is designed to be easy to port to other platforms. File I/O is
|
||||
done with streams and all file functions (except "fopen") are handled in
|
||||
a wrapper in the "utils.c" module. The code is endian-independent.
|
||||
|
||||
To maintain compatibility on various platforms, the following conventions
|
||||
are used:
|
||||
are used: A "short" must be 16-bits and an "int" must be 32-bits.
|
||||
The "long" type is not used. The "char" type must be 8-bits, signed or
|
||||
unsigned.
|
||||
|
||||
a "short" must be 16-bits
|
||||
an "int" must be at least 16-bits, but may be larger
|
||||
|
||||
For version 4.2 references to "long" variables were eliminated to allow
|
||||
compilation on 64-bit machines. For version 4.3 "char" types may default
|
||||
to signed or unsigned.
|
||||
|
||||
2. For WavPack file decoding, a library interface in "wputils.c" provides all
|
||||
3. For WavPack file decoding, a library interface in "wputils.c" provides all
|
||||
the functionality required for both the winamp plugin and the "wvunpack"
|
||||
command-line program (including the transparent decoding of "correction"
|
||||
files). There is also an alternate entry point that uses reader callbacks
|
||||
for all input, although in this case it is the caller's responsibility to
|
||||
to open the "correction" file. It is no longer necessary to manipulate the
|
||||
WavPack structures directly; everything is handled with function calls. In
|
||||
fact, a new header file called "wputils.h" can be used that hides all the
|
||||
WavPack internals from the application.
|
||||
to open the "correction" file. The header file "include/wavpack.h"
|
||||
includes everything needed while hiding all the WavPack internals from the
|
||||
application.
|
||||
|
||||
3. For WavPack file creation, the library interface in "wputils.c" provides
|
||||
4. For WavPack file creation, the library interface in "wputils.c" provides
|
||||
all the functionality for both the Audition filter and the "wavpack"
|
||||
command-line program. No file I/O is performed by the library when creating
|
||||
WavPack files. Instead, the user supplies a "write_block" function that
|
||||
accepts completed WavPack blocks. For version 4.2 limited functionality
|
||||
has been added to append APEv2 tags to WavPack files during creation.
|
||||
accepts completed WavPack blocks. It is also possible to append APEv2 tags
|
||||
to WavPack files during creation and edit APEv2 tags on existing files
|
||||
(although there is no support currently for "binary" fields in the tags).
|
||||
|
||||
4. The following #define's are used to control the optimum configuration of
|
||||
the library for the desired application and must be the same for the
|
||||
compilation of ALL files:
|
||||
5. The following #define's can be optionally used to eliminate some functionality
|
||||
to create smaller binaries. It is important that they must be specified
|
||||
the same for the compilation of ALL files:
|
||||
|
||||
UNPACK to unpack audio samples from WavPack files
|
||||
PACK to create WavPack files from raw audio data
|
||||
NO_UNPACK no unpacking of audio samples from WavPack files
|
||||
(also don't include unpack.c)
|
||||
NO_PACK no creating WavPack files from raw audio data
|
||||
(also don't include pack.c, extra1.c and extra2.c)
|
||||
INFO_ONLY to obtain information from WavPack files, but not audio
|
||||
SEEKING to allow seeking to a specific sample index (unpack only)
|
||||
USE_FSTREAMS to open WavPack files by name using fstreams (via fopen)
|
||||
TAGS to read specified fields from ID3v1 and APEv2 tags and
|
||||
(also don't include pack.c, extra1.c and extra2.c)
|
||||
NO_SEEKING to not allow seeking to a specific sample index (unpack only)
|
||||
NO_USE_FSTREAMS to not open WavPack files by name using fstreams
|
||||
NO_TAGS to not read specified fields from ID3v1 and APEv2 tags and
|
||||
create APEv2 tags
|
||||
VER3 to handle WavPack files from versions prior to 4.0
|
||||
VER4_ONLY to only handle WavPack files from versions 4.0 onward
|
||||
WIN32 required for Win32 platform
|
||||
|
||||
The following files are required for various configurations:
|
||||
6. There are alternate versions of this library available specifically designed
|
||||
for "resource limited" CPUs or hardware encoding and decoding. There is the
|
||||
"tiny decoder" library which works with less than 32k of code and less than
|
||||
4k of data and has assembly language optimizations for the ARM and Freescale
|
||||
ColdFire CPUs. The "tiny encoder" is also designed for embedded use and
|
||||
handles the pure lossless, lossy, and hybrid lossless modes. Neither of the
|
||||
"tiny" versions use any memory allocation functions nor do they require
|
||||
floating-point arithmetic support.
|
||||
|
||||
UNPACK or
|
||||
INFO_ONLY: wputils.c unpack.c words.c bits.c metadata.c float.c
|
||||
For applications requiring very low latency, there is a special version of
|
||||
the library that supports a variation on the regular WavPack block format
|
||||
to facilitate this.
|
||||
|
||||
PACK: wputils.c pack.c extra1.c extra2.c
|
||||
words.c bits.c metadata.c float.c
|
||||
|
||||
PACK and
|
||||
UNPACK: wputils.c unpack.c pack.c extra1.c extra2.c
|
||||
words.c bits.c metadata.c float.c
|
||||
|
||||
5. An alternate version of this library is available specifically designed
|
||||
for "resource limited" CPUs or hardware decoding. This "tiny" decoder
|
||||
library works with less than 32k of code and less than 4k of data.
|
||||
|
||||
6. Questions or comments should be directed to david@wavpack.com
|
||||
7. Questions or comments should be directed to david@wavpack.com
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -14,7 +14,7 @@
|
|||
// endian-ness, both for enhancing portability. Finally, a debug wrapper for
|
||||
// the malloc() system is provided.
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -24,18 +24,21 @@
|
|||
#if defined(WIN32)
|
||||
#include <io.h>
|
||||
#else
|
||||
#if defined(__OS2__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
////////////////////////// Bitstream functions ////////////////////////////////
|
||||
|
||||
#if defined(UNPACK) || defined(INFO_ONLY)
|
||||
#if !defined(NO_UNPACK) || defined(INFO_ONLY)
|
||||
|
||||
// Open the specified BitStream and associate with the specified buffer.
|
||||
|
||||
static void bs_read (Bitstream *bs);
|
||||
|
||||
void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end)
|
||||
void bs_open_read (Bitstream *bs, void *buffer_start, void *buffer_end)
|
||||
{
|
||||
bs->error = bs->sr = bs->bc = 0;
|
||||
bs->ptr = (bs->buf = buffer_start) - 1;
|
||||
|
@ -61,20 +64,21 @@ uint32_t bs_close_read (Bitstream *bs)
|
|||
{
|
||||
uint32_t bytes_read;
|
||||
|
||||
if (bs->bc < 8)
|
||||
if (bs->bc < sizeof (*(bs->ptr)) * 8)
|
||||
bs->ptr++;
|
||||
|
||||
if ((bs->buf - bs->ptr) & 1)
|
||||
bs->ptr++;
|
||||
bytes_read = (uint32_t)(bs->ptr - bs->buf) * sizeof (*(bs->ptr));
|
||||
|
||||
if (!(bytes_read & 1))
|
||||
++bytes_read;
|
||||
|
||||
bytes_read = bs->ptr - bs->buf;
|
||||
CLEAR (*bs);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PACK
|
||||
#ifndef NO_PACK
|
||||
|
||||
// Open the specified BitStream using the specified buffer pointers. It is
|
||||
// assumed that enough buffer space has been allocated for all data that will
|
||||
|
@ -82,7 +86,7 @@ uint32_t bs_close_read (Bitstream *bs)
|
|||
|
||||
static void bs_write (Bitstream *bs);
|
||||
|
||||
void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end)
|
||||
void bs_open_write (Bitstream *bs, void *buffer_start, void *buffer_end)
|
||||
{
|
||||
bs->error = bs->sr = bs->bc = 0;
|
||||
bs->ptr = bs->buf = buffer_start;
|
||||
|
@ -109,8 +113,19 @@ uint32_t bs_close_write (Bitstream *bs)
|
|||
if (bs->error)
|
||||
return (uint32_t) -1;
|
||||
|
||||
while (bs->bc || ((bs->ptr - bs->buf) & 1)) putbit_1 (bs);
|
||||
bytes_written = bs->ptr - bs->buf;
|
||||
while (1) {
|
||||
while (bs->bc)
|
||||
putbit_1 (bs);
|
||||
|
||||
bytes_written = (uint32_t)(bs->ptr - bs->buf) * sizeof (*(bs->ptr));
|
||||
|
||||
if (bytes_written & 1) {
|
||||
putbit_1 (bs);
|
||||
}
|
||||
else
|
||||
break;
|
||||
};
|
||||
|
||||
CLEAR (*bs);
|
||||
return bytes_written;
|
||||
}
|
||||
|
@ -121,7 +136,7 @@ uint32_t bs_close_write (Bitstream *bs)
|
|||
|
||||
void little_endian_to_native (void *data, char *format)
|
||||
{
|
||||
uchar *cp = (uchar *) data;
|
||||
unsigned char *cp = (unsigned char *) data;
|
||||
int32_t temp;
|
||||
|
||||
while (*format) {
|
||||
|
@ -151,23 +166,23 @@ void little_endian_to_native (void *data, char *format)
|
|||
|
||||
void native_to_little_endian (void *data, char *format)
|
||||
{
|
||||
uchar *cp = (uchar *) data;
|
||||
unsigned char *cp = (unsigned char *) data;
|
||||
int32_t temp;
|
||||
|
||||
while (*format) {
|
||||
switch (*format) {
|
||||
case 'L':
|
||||
temp = * (int32_t *) cp;
|
||||
*cp++ = (uchar) temp;
|
||||
*cp++ = (uchar) (temp >> 8);
|
||||
*cp++ = (uchar) (temp >> 16);
|
||||
*cp++ = (uchar) (temp >> 24);
|
||||
*cp++ = (unsigned char) temp;
|
||||
*cp++ = (unsigned char) (temp >> 8);
|
||||
*cp++ = (unsigned char) (temp >> 16);
|
||||
*cp++ = (unsigned char) (temp >> 24);
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
temp = * (short *) cp;
|
||||
*cp++ = (uchar) temp;
|
||||
*cp++ = (uchar) (temp >> 8);
|
||||
*cp++ = (unsigned char) temp;
|
||||
*cp++ = (unsigned char) (temp >> 8);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand `-c -o'.
|
||||
|
||||
scriptversion=2005-02-03.08
|
||||
scriptversion=2005-05-14.22
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
|
@ -18,7 +18,7 @@ scriptversion=2005-02-03.08
|
|||
#
|
||||
# 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.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
|
|
|
@ -1,8 +1,32 @@
|
|||
# wavpack 4.32 configure.ac
|
||||
# wavpack 4.60.1 configure.ac
|
||||
|
||||
AC_INIT(wavpack, 4.32, bryant@wavpack.com)
|
||||
AM_INIT_AUTOMAKE(wavpack, 4.32, bryant@wavpack.com)
|
||||
AC_CONFIG_SRCDIR([pack.c])
|
||||
AC_INIT(wavpack, 4.60.1, bryant@wavpack.com)
|
||||
AM_INIT_AUTOMAKE(wavpack, 4.60.1, bryant@wavpack.com)
|
||||
AC_CONFIG_SRCDIR([src/pack.c])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
LIBWAVPACK_MAJOR=4
|
||||
LIBWAVPACK_MINOR=60
|
||||
LIBWAVPACK_MICRO=1
|
||||
LIBWAVPACK_VERSION_STRING=$LIBWAVPACK_MAJOR.$LIBWAVPACK_MINOR.$LIBWAVPACK_MICRO
|
||||
|
||||
AC_DEFINE_UNQUOTED(LIBWAVPACK_MAJOR, $LIBWAVPACK_MAJOR, [libwavpack major version])
|
||||
AC_DEFINE_UNQUOTED(LIBWAVPACK_MINOR, $LIBWAVPACK_MINOR, [libwavpack minor version])
|
||||
AC_DEFINE_UNQUOTED(LIBWAVPACK_MICRO, $LIBWAVPACK_MICRO, [libwavpack micro version])
|
||||
AC_DEFINE_UNQUOTED(LIBWAVPACK_VERSION_STRING, "$LIBWAVPACK_VERSION_STRING", [libwavpack version string])
|
||||
|
||||
# set libtool versioning
|
||||
# +1 : 0 : +1 == new interface that does not break old one.
|
||||
# +1 : 0 : 0 == changed/removed an interface. Breaks old apps.
|
||||
# ? : +1 : ? == internal changes that doesn't break anything.
|
||||
# CURRENT : REVISION : AGE
|
||||
LT_CURRENT=2
|
||||
LT_REVISION=4
|
||||
LT_AGE=1
|
||||
|
||||
AC_SUBST(LT_CURRENT)
|
||||
AC_SUBST(LT_REVISION)
|
||||
AC_SUBST(LT_AGE)
|
||||
|
||||
# Check for os version
|
||||
VERSION_OS=$(uname -s)
|
||||
|
@ -13,18 +37,28 @@ AC_C_BIGENDIAN(AC_DEFINE([HIGHFIRST], [1], [big-endian machine]))
|
|||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_INSTALL
|
||||
AM_PROG_CC_C_O
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
# Checks for libraries.
|
||||
AC_CHECK_LIB(m, log10, [], AC_MSG_ERROR(math library not found))
|
||||
AC_CHECK_LIBM
|
||||
AC_SUBST(LIBM)
|
||||
|
||||
# Check if cross-compiling on mingw
|
||||
AC_MINGW32
|
||||
|
||||
if test "x$MINGW32" != "xyes" ; then
|
||||
# Check for iconv
|
||||
AC_ARG_WITH(iconv, [ --with-iconv[=DIR] Add ICONV support (on)])
|
||||
AC_ARG_WITH(iconv, [[ --with-iconv[=DIR] add ICONV support [yes]]])
|
||||
if test "$with_iconv" = "no" ; then
|
||||
AC_MSG_ERROR([[Sorry, you can't deactivate iconv.]])
|
||||
else
|
||||
if test "$with_iconv" != "yes" -a "$with_iconv" != "" ; then
|
||||
CPPFLAGS="${CPPFLAGS} -I$with_iconv/include"
|
||||
ICONV_CFLAGS="${CPPFLAGS} -I$with_iconv/include"
|
||||
ICONV_LIBS="-L$with_iconv/lib"
|
||||
fi
|
||||
|
||||
|
@ -35,13 +69,12 @@ else
|
|||
iconv_t cd = iconv_open ("","");
|
||||
iconv (cd, NULL, NULL, NULL, NULL);],[
|
||||
AC_MSG_RESULT(yes)
|
||||
WITH_ICONV=1
|
||||
ICONV=""],[
|
||||
WITH_ICONV=1],[
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_CHECKING(for iconv in -liconv)
|
||||
|
||||
_ldflags="${LDFLAGS}"
|
||||
_libs="${LIBS}"
|
||||
old_ldflags="${LDFLAGS}"
|
||||
old_libs="${LIBS}"
|
||||
LDFLAGS="${LDFLAGS} ${ICONV_LIBS}"
|
||||
LIBS="${LIBS} -liconv"
|
||||
|
||||
|
@ -52,11 +85,51 @@ iconv (cd, NULL, NULL, NULL, NULL);],[
|
|||
AC_MSG_RESULT(yes)
|
||||
WITH_ICONV=1
|
||||
ICONV_LIBS="${ICONV_LIBS} -liconv"
|
||||
ICONV="${ICONV_LIBS}"],[
|
||||
AC_MSG_ERROR([[Can't find iconv libraries.]])])]),
|
||||
ICONV="-liconv"],[
|
||||
AC_MSG_ERROR([[Can't find iconv libraries.]])])
|
||||
LDFLAGS=$old_ldflags
|
||||
LIBS=$old_libs
|
||||
]),
|
||||
AC_MSG_ERROR([[Can't find iconv headers.]]))
|
||||
fi
|
||||
AC_SUBST(ICONV)
|
||||
AC_SUBST(ICONV_LIBS)
|
||||
AC_SUBST(ICONV)
|
||||
fi
|
||||
|
||||
AC_OUTPUT(Makefile wavpack.pc)
|
||||
AC_ARG_ENABLE(mmx, [[ --enable-mmx enable MMX optimizations [default=no]]])
|
||||
if test "x$enable_mmx" = "xyes" ; then
|
||||
AC_DEFINE([OPT_MMX], 1, [MMX optimization])
|
||||
$CC $CFLAGS -mmmx -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && CFLAGS="-mmmx $CFLAGS"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(man,
|
||||
[AC_HELP_STRING([--enable-man],
|
||||
[regenerate man pages from Docbook [default=no]])],enable_man=yes,
|
||||
enable_man=no)
|
||||
|
||||
if test "${enable_man}" != no; then
|
||||
dnl
|
||||
dnl Check for xsltproc
|
||||
dnl
|
||||
AC_PATH_PROG([XSLTPROC], [xsltproc])
|
||||
if test -z "$XSLTPROC"; then
|
||||
enable_man=no
|
||||
fi
|
||||
|
||||
dnl check for DocBook DTD and stylesheets in the local catalog.
|
||||
JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.1.2//EN],
|
||||
[DocBook XML DTD V4.1.2],,enable_man=no)
|
||||
JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl],
|
||||
[DocBook XSL Stylesheets],,enable_man=no)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
|
||||
|
||||
AC_CONFIG_FILES(
|
||||
Makefile
|
||||
wavpack.pc
|
||||
src/Makefile
|
||||
include/Makefile
|
||||
cli/Makefile
|
||||
man/Makefile)
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2005-02-09.22
|
||||
scriptversion=2007-03-29.01
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,8 +18,8 @@ scriptversion=2005-02-09.22
|
|||
|
||||
# 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.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
|
@ -91,7 +92,20 @@ gcc3)
|
|||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
|
@ -201,34 +215,39 @@ aix)
|
|||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test -f "$tmpdepfile"; then :
|
||||
else
|
||||
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||
tmpdepfile="$stripped.u"
|
||||
fi
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
outname="$stripped.o"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
|
@ -276,6 +295,46 @@ icc)
|
|||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
|
@ -288,13 +347,13 @@ tru64)
|
|||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mecanism is used in libtool 1.4 series to
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in in $dir.libs/$base.o.d and
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
|
@ -467,7 +526,8 @@ cpp)
|
|||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -10,15 +10,16 @@
|
|||
|
||||
// This module handles the "extra" mode for mono files.
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
//#define USE_OVERHEAD
|
||||
#define LOG_LIMIT 6912
|
||||
// #define EXTRA_DUMP
|
||||
//#define EXTRA_DUMP
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
#define malloc malloc_db
|
||||
|
@ -39,8 +40,6 @@ typedef struct {
|
|||
uint32_t best_bits;
|
||||
} WavpackExtraInfo;
|
||||
|
||||
extern const signed char default_terms [], high_terms [], fast_terms [];
|
||||
|
||||
static void decorr_mono_pass (int32_t *in_samples, int32_t *out_samples, uint32_t num_samples, struct decorr_pass *dpp, int dir)
|
||||
{
|
||||
int m = 0, i;
|
||||
|
@ -186,6 +185,18 @@ static void decorr_mono_buffer (int32_t *samples, int32_t *outsamples, uint32_t
|
|||
decorr_mono_pass (samples, outsamples, num_samples, &dp, 1);
|
||||
}
|
||||
|
||||
static int log2overhead (int first_term, int num_terms)
|
||||
{
|
||||
#ifdef USE_OVERHEAD
|
||||
if (first_term > MAX_TERM)
|
||||
return (4 + num_terms * 2) << 11;
|
||||
else
|
||||
return (2 + num_terms * 2) << 11;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void recurse_mono (WavpackContext *wpc, WavpackExtraInfo *info, int depth, int delta, uint32_t input_bits)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
|
@ -204,11 +215,10 @@ static void recurse_mono (WavpackContext *wpc, WavpackExtraInfo *info, int depth
|
|||
if (term == 17 && branches == 1 && depth + 1 < info->nterms)
|
||||
continue;
|
||||
|
||||
if (term >= 9 && term <= 16)
|
||||
if (term > MAX_TERM || !(wpc->config.flags & CONFIG_HIGH_FLAG) || (wpc->config.extra_flags & EXTRA_SKIP_8TO16))
|
||||
if (term > 8 && term < 17)
|
||||
continue;
|
||||
|
||||
if ((wpc->config.flags & CONFIG_FAST_FLAG) && (term >= 5 && term <= 16))
|
||||
if ((wpc->config.flags & CONFIG_FAST_FLAG) && (term > 4 && term < 17))
|
||||
continue;
|
||||
|
||||
info->dps [depth].term = term;
|
||||
|
@ -216,6 +226,9 @@ static void recurse_mono (WavpackContext *wpc, WavpackExtraInfo *info, int depth
|
|||
decorr_mono_buffer (samples, outsamples, wps->wphdr.block_samples, info->dps, depth);
|
||||
bits = log2buffer (outsamples, wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (info->dps [0].term, depth + 1);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
info->best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
|
@ -233,13 +246,15 @@ static void recurse_mono (WavpackContext *wpc, WavpackExtraInfo *info, int depth
|
|||
for (i = 0; i < 22; ++i)
|
||||
if (term_bits [i] && term_bits [i] < local_best_bits) {
|
||||
local_best_bits = term_bits [i];
|
||||
term_bits [i] = 0;
|
||||
// term_bits [i] = 0;
|
||||
best_term = i - 3;
|
||||
}
|
||||
|
||||
if (!best_term)
|
||||
break;
|
||||
|
||||
term_bits [best_term + 3] = 0;
|
||||
|
||||
info->dps [depth].term = best_term;
|
||||
info->dps [depth].delta = delta;
|
||||
decorr_mono_buffer (samples, outsamples, wps->wphdr.block_samples, info->dps, depth);
|
||||
|
@ -276,6 +291,9 @@ static void delta_mono (WavpackContext *wpc, WavpackExtraInfo *info)
|
|||
|
||||
bits = log2buffer (info->sampleptrs [i], wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (wps->decorr_passes [0].term, i);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
lower = TRUE;
|
||||
info->best_bits = bits;
|
||||
|
@ -298,6 +316,9 @@ static void delta_mono (WavpackContext *wpc, WavpackExtraInfo *info)
|
|||
|
||||
bits = log2buffer (info->sampleptrs [i], wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (wps->decorr_passes [0].term, i);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
info->best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
|
@ -339,6 +360,9 @@ static void sort_mono (WavpackContext *wpc, WavpackExtraInfo *info)
|
|||
|
||||
bits = log2buffer (info->sampleptrs [i], wps->wphdr.block_samples, info->log_limit);
|
||||
|
||||
if (bits != (uint32_t) -1)
|
||||
bits += log2overhead (wps->decorr_passes [0].term, i);
|
||||
|
||||
if (bits < info->best_bits) {
|
||||
reversed = TRUE;
|
||||
info->best_bits = bits;
|
||||
|
@ -355,21 +379,12 @@ static void sort_mono (WavpackContext *wpc, WavpackExtraInfo *info)
|
|||
}
|
||||
}
|
||||
|
||||
#define EXTRA_ADVANCED (EXTRA_BRANCHES | EXTRA_SORT_FIRST | EXTRA_SORT_LAST | EXTRA_TRY_DELTAS)
|
||||
static const uint32_t xtable [] = { 91, 123, 187, 251 };
|
||||
|
||||
//extern uint32_t crc3;
|
||||
|
||||
void analyze_mono (WavpackContext *wpc, int32_t *samples)
|
||||
static void analyze_mono (WavpackContext *wpc, int32_t *samples, int do_samples)
|
||||
{
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
#ifdef EXTRA_DUMP
|
||||
uint32_t bits, default_bits, cnt;
|
||||
#else
|
||||
uint32_t bits, cnt;
|
||||
#endif
|
||||
const signed char *decorr_terms = default_terms, *tp;
|
||||
WavpackExtraInfo info;
|
||||
int32_t *lptr;
|
||||
int i;
|
||||
|
||||
#ifdef LOG_LIMIT
|
||||
|
@ -381,73 +396,74 @@ void analyze_mono (WavpackContext *wpc, int32_t *samples)
|
|||
info.log_limit = 0;
|
||||
#endif
|
||||
|
||||
CLEAR (wps->decorr_passes);
|
||||
cnt = wps->wphdr.block_samples;
|
||||
lptr = samples;
|
||||
if (wpc->config.flags & (CONFIG_HIGH_FLAG | CONFIG_VERY_HIGH_FLAG))
|
||||
wpc->config.extra_flags = xtable [wpc->config.xmode - 4];
|
||||
else
|
||||
wpc->config.extra_flags = xtable [wpc->config.xmode - 3];
|
||||
|
||||
while (cnt--)
|
||||
if (*lptr++)
|
||||
break;
|
||||
|
||||
if (cnt == (uint32_t) -1) {
|
||||
scan_word (wps, samples, wps->wphdr.block_samples, -1);
|
||||
wps->num_terms = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (wpc->config.flags & CONFIG_HIGH_FLAG)
|
||||
decorr_terms = high_terms;
|
||||
else if (wpc->config.flags & CONFIG_FAST_FLAG)
|
||||
decorr_terms = fast_terms;
|
||||
|
||||
for (info.nterms = 0, tp = decorr_terms; *tp; tp++)
|
||||
if (*tp > 0)
|
||||
++info.nterms;
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_TERMS)
|
||||
if ((info.nterms += (wpc->config.extra_flags & EXTRA_TERMS) >> 10) > MAX_NTERMS)
|
||||
info.nterms = MAX_NTERMS;
|
||||
info.nterms = wps->num_terms;
|
||||
|
||||
for (i = 0; i < info.nterms + 2; ++i)
|
||||
info.sampleptrs [i] = malloc (wps->wphdr.block_samples * 4);
|
||||
|
||||
memcpy (info.sampleptrs [info.nterms + 1], samples, wps->wphdr.block_samples * 4);
|
||||
info.best_bits = log2buffer (info.sampleptrs [info.nterms + 1], wps->wphdr.block_samples, 0);
|
||||
memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
|
||||
memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 4);
|
||||
CLEAR (info.dps);
|
||||
|
||||
for (tp = decorr_terms, i = 0; *tp; tp++)
|
||||
if (*tp > 0) {
|
||||
info.dps [i].term = *tp;
|
||||
info.dps [i].delta = 2;
|
||||
decorr_mono_buffer (info.sampleptrs [i], info.sampleptrs [i+1], wps->wphdr.block_samples, info.dps, i);
|
||||
++i;
|
||||
}
|
||||
for (i = 0; i < info.nterms && info.dps [i].term; ++i)
|
||||
decorr_mono_pass (info.sampleptrs [i], info.sampleptrs [i + 1], wps->wphdr.block_samples, info.dps + i, 1);
|
||||
|
||||
#ifdef EXTRA_DUMP
|
||||
default_bits = bits = log2buffer (info.sampleptrs [i], wps->wphdr.block_samples, 0);
|
||||
#else
|
||||
bits = log2buffer (info.sampleptrs [i], wps->wphdr.block_samples, 0);
|
||||
#endif
|
||||
|
||||
if (bits < info.best_bits) {
|
||||
info.best_bits = bits;
|
||||
CLEAR (wps->decorr_passes);
|
||||
memcpy (wps->decorr_passes, info.dps, sizeof (info.dps [0]) * i);
|
||||
info.best_bits = log2buffer (info.sampleptrs [info.nterms], wps->wphdr.block_samples, 0) * 1;
|
||||
info.best_bits += log2overhead (info.dps [0].term, i);
|
||||
memcpy (info.sampleptrs [info.nterms + 1], info.sampleptrs [i], wps->wphdr.block_samples * 4);
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_BRANCHES)
|
||||
recurse_mono (wpc, &info, 0, (int) floor (wps->delta_decay + 0.5),
|
||||
log2buffer (info.sampleptrs [0], wps->wphdr.block_samples, 0));
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_SORT_FIRST)
|
||||
sort_mono (wpc, &info);
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_TRY_DELTAS) {
|
||||
delta_mono (wpc, &info);
|
||||
|
||||
if ((wpc->config.extra_flags & EXTRA_ADJUST_DELTAS) && wps->decorr_passes [0].term)
|
||||
wps->delta_decay = (float)((wps->delta_decay * 2.0 + wps->decorr_passes [0].delta) / 3.0);
|
||||
else
|
||||
wps->delta_decay = 2.0;
|
||||
}
|
||||
|
||||
if ((wps->wphdr.flags & HYBRID_FLAG) && (wpc->config.extra_flags & EXTRA_ADVANCED)) {
|
||||
if (wpc->config.extra_flags & EXTRA_SORT_LAST)
|
||||
sort_mono (wpc, &info);
|
||||
|
||||
if (do_samples)
|
||||
memcpy (samples, info.sampleptrs [info.nterms + 1], wps->wphdr.block_samples * 4);
|
||||
|
||||
for (i = 0; i < info.nterms; ++i)
|
||||
if (!wps->decorr_passes [i].term)
|
||||
break;
|
||||
|
||||
wps->num_terms = i;
|
||||
|
||||
for (i = 0; i < info.nterms + 2; ++i)
|
||||
free (info.sampleptrs [i]);
|
||||
}
|
||||
|
||||
static void mono_add_noise (WavpackStream *wps, int32_t *lptr, int32_t *rptr)
|
||||
{
|
||||
int shaping_weight, new = wps->wphdr.flags & NEW_SHAPING;
|
||||
int32_t *rptr = info.sampleptrs [info.nterms + 1], error = 0, temp;
|
||||
short *shaping_array = wps->dc.shaping_array;
|
||||
int32_t error = 0, temp, cnt;
|
||||
|
||||
scan_word (wps, rptr, wps->wphdr.block_samples, -1);
|
||||
cnt = wps->wphdr.block_samples;
|
||||
lptr = info.sampleptrs [0];
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_SHAPE) {
|
||||
while (cnt--) {
|
||||
if (shaping_array)
|
||||
shaping_weight = *shaping_array++;
|
||||
else
|
||||
shaping_weight = (wps->dc.shaping_acc [0] += wps->dc.shaping_delta [0]) >> 16;
|
||||
|
||||
temp = -apply_weight (shaping_weight, error);
|
||||
|
||||
if (new && shaping_weight < 0 && temp) {
|
||||
|
@ -463,6 +479,7 @@ void analyze_mono (WavpackContext *wpc, int32_t *samples)
|
|||
rptr++;
|
||||
}
|
||||
|
||||
if (!shaping_array)
|
||||
wps->dc.shaping_acc [0] -= wps->dc.shaping_delta [0] * wps->wphdr.block_samples;
|
||||
}
|
||||
else
|
||||
|
@ -471,66 +488,169 @@ void analyze_mono (WavpackContext *wpc, int32_t *samples)
|
|||
lptr++;
|
||||
rptr++;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
|
||||
void execute_mono (WavpackContext *wpc, int32_t *samples, int no_history, int do_samples)
|
||||
{
|
||||
int32_t *temp_buffer [2], *best_buffer, *noisy_buffer = NULL;
|
||||
struct decorr_pass temp_decorr_pass, save_decorr_passes [MAX_NTERMS];
|
||||
WavpackStream *wps = wpc->streams [wpc->current_stream];
|
||||
int32_t num_samples = wps->wphdr.block_samples;
|
||||
int32_t buf_size = sizeof (int32_t) * num_samples;
|
||||
uint32_t best_size = (uint32_t) -1, size;
|
||||
int log_limit, pi, i;
|
||||
|
||||
for (i = 0; i < info.nterms && info.dps [i].term; ++i)
|
||||
decorr_mono_buffer (info.sampleptrs [i], info.sampleptrs [i + 1], wps->wphdr.block_samples, info.dps, i);
|
||||
|
||||
#ifdef EXTRA_DUMP
|
||||
info.best_bits = default_bits = log2buffer (info.sampleptrs [i], wps->wphdr.block_samples, 0);
|
||||
#else
|
||||
info.best_bits = log2buffer (info.sampleptrs [i], wps->wphdr.block_samples, 0);
|
||||
#endif
|
||||
for (i = 0; i < num_samples; ++i)
|
||||
if (samples [i])
|
||||
break;
|
||||
|
||||
if (i == num_samples) {
|
||||
CLEAR (wps->decorr_passes);
|
||||
memcpy (wps->decorr_passes, info.dps, sizeof (info.dps [0]) * i);
|
||||
memcpy (info.sampleptrs [info.nterms + 1], info.sampleptrs [i], wps->wphdr.block_samples * 4);
|
||||
wps->num_terms = 0;
|
||||
init_words (wps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_BRANCHES)
|
||||
recurse_mono (wpc, &info, 0, (int) floor (wps->delta_decay + 0.5),
|
||||
log2buffer (info.sampleptrs [0], wps->wphdr.block_samples, 0));
|
||||
#ifdef LOG_LIMIT
|
||||
log_limit = (((wps->wphdr.flags & MAG_MASK) >> MAG_LSB) + 4) * 256;
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_SORT_FIRST)
|
||||
sort_mono (wpc, &info);
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_TRY_DELTAS) {
|
||||
delta_mono (wpc, &info);
|
||||
|
||||
if ((wpc->config.extra_flags & EXTRA_ADJUST_DELTAS) && wps->decorr_passes [0].term)
|
||||
wps->delta_decay = (wps->delta_decay * 2.0 + wps->decorr_passes [0].delta) / 3.0;
|
||||
else
|
||||
wps->delta_decay = 2.0;
|
||||
}
|
||||
|
||||
if (wpc->config.extra_flags & EXTRA_SORT_LAST)
|
||||
sort_mono (wpc, &info);
|
||||
|
||||
#if 0
|
||||
memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
|
||||
|
||||
for (i = 0; i < info.nterms && info.dps [i].term; ++i)
|
||||
decorr_mono_pass (info.sampleptrs [i], info.sampleptrs [i + 1], wps->wphdr.block_samples, info.dps + i, 1);
|
||||
|
||||
if (log2buffer (info.sampleptrs [i], wps->wphdr.block_samples, 0) != info.best_bits)
|
||||
error_line ("(1) samples do not match!");
|
||||
|
||||
if (log2buffer (info.sampleptrs [info.nterms + 1], wps->wphdr.block_samples, 0) != info.best_bits)
|
||||
error_line ("(2) samples do not match!");
|
||||
if (log_limit > LOG_LIMIT)
|
||||
log_limit = LOG_LIMIT;
|
||||
#else
|
||||
log_limit = 0;
|
||||
#endif
|
||||
|
||||
scan_word (wps, info.sampleptrs [info.nterms + 1], wps->wphdr.block_samples, -1);
|
||||
CLEAR (save_decorr_passes);
|
||||
temp_buffer [0] = malloc (buf_size);
|
||||
temp_buffer [1] = malloc (buf_size);
|
||||
best_buffer = malloc (buf_size);
|
||||
|
||||
if (wps->num_passes > 1 && (wps->wphdr.flags & HYBRID_FLAG)) {
|
||||
CLEAR (temp_decorr_pass);
|
||||
temp_decorr_pass.delta = 2;
|
||||
temp_decorr_pass.term = 18;
|
||||
|
||||
decorr_mono_pass (samples, temp_buffer [0],
|
||||
num_samples > 2048 ? 2048 : num_samples, &temp_decorr_pass, -1);
|
||||
|
||||
reverse_mono_decorr (&temp_decorr_pass);
|
||||
decorr_mono_pass (samples, temp_buffer [0], num_samples, &temp_decorr_pass, 1);
|
||||
CLEAR (temp_decorr_pass);
|
||||
temp_decorr_pass.delta = 2;
|
||||
temp_decorr_pass.term = 17;
|
||||
|
||||
decorr_mono_pass (temp_buffer [0], temp_buffer [1],
|
||||
num_samples > 2048 ? 2048 : num_samples, &temp_decorr_pass, -1);
|
||||
|
||||
decorr_mono_pass (temp_buffer [0], temp_buffer [1], num_samples, &temp_decorr_pass, 1);
|
||||
noisy_buffer = malloc (buf_size);
|
||||
memcpy (noisy_buffer, samples, buf_size);
|
||||
mono_add_noise (wps, noisy_buffer, temp_buffer [1]);
|
||||
no_history = 1;
|
||||
}
|
||||
|
||||
if (no_history || wps->num_passes >= 7)
|
||||
wps->best_decorr = wps->mask_decorr = 0;
|
||||
|
||||
for (pi = 0; pi < wps->num_passes;) {
|
||||
const WavpackDecorrSpec *wpds;
|
||||
int nterms, c, j;
|
||||
|
||||
if (!pi)
|
||||
c = wps->best_decorr;
|
||||
else {
|
||||
if (wps->mask_decorr == 0)
|
||||
c = 0;
|
||||
else
|
||||
c = (wps->best_decorr & (wps->mask_decorr - 1)) | wps->mask_decorr;
|
||||
|
||||
if (c == wps->best_decorr) {
|
||||
wps->mask_decorr = wps->mask_decorr ? ((wps->mask_decorr << 1) & (wps->num_decorrs - 1)) : 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
wpds = &wps->decorr_specs [c];
|
||||
nterms = (int) strlen (wpds->terms);
|
||||
|
||||
while (1) {
|
||||
memcpy (temp_buffer [0], noisy_buffer ? noisy_buffer : samples, buf_size);
|
||||
CLEAR (save_decorr_passes);
|
||||
|
||||
for (j = 0; j < nterms; ++j) {
|
||||
CLEAR (temp_decorr_pass);
|
||||
temp_decorr_pass.delta = wpds->delta;
|
||||
temp_decorr_pass.term = wpds->terms [j];
|
||||
|
||||
if (temp_decorr_pass.term < 0)
|
||||
temp_decorr_pass.term = 1;
|
||||
|
||||
decorr_mono_pass (temp_buffer [j&1], temp_buffer [~j&1],
|
||||
num_samples > 2048 ? 2048 : num_samples, &temp_decorr_pass, -1);
|
||||
|
||||
if (j) {
|
||||
CLEAR (temp_decorr_pass.samples_A);
|
||||
}
|
||||
else
|
||||
reverse_mono_decorr (&temp_decorr_pass);
|
||||
|
||||
memcpy (save_decorr_passes + j, &temp_decorr_pass, sizeof (struct decorr_pass));
|
||||
decorr_mono_pass (temp_buffer [j&1], temp_buffer [~j&1], num_samples, &temp_decorr_pass, 1);
|
||||
}
|
||||
|
||||
size = log2buffer (temp_buffer [j&1], num_samples, log_limit);
|
||||
|
||||
if (size == (uint32_t) -1 && nterms)
|
||||
nterms >>= 1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
size += log2overhead (wpds->terms [0], nterms);
|
||||
|
||||
if (size < best_size) {
|
||||
memcpy (best_buffer, temp_buffer [j&1], buf_size);
|
||||
memcpy (wps->decorr_passes, save_decorr_passes, sizeof (struct decorr_pass) * MAX_NTERMS);
|
||||
wps->num_terms = nterms;
|
||||
wps->best_decorr = c;
|
||||
best_size = size;
|
||||
}
|
||||
|
||||
if (pi++)
|
||||
wps->mask_decorr = wps->mask_decorr ? ((wps->mask_decorr << 1) & (wps->num_decorrs - 1)) : 1;
|
||||
}
|
||||
|
||||
if (wpc->config.xmode > 3) {
|
||||
if (noisy_buffer) {
|
||||
analyze_mono (wpc, noisy_buffer, do_samples);
|
||||
|
||||
if (do_samples)
|
||||
memcpy (samples, noisy_buffer, buf_size);
|
||||
}
|
||||
else
|
||||
analyze_mono (wpc, samples, do_samples);
|
||||
}
|
||||
else if (do_samples)
|
||||
memcpy (samples, best_buffer, buf_size);
|
||||
|
||||
if (no_history || wpc->config.xmode > 3)
|
||||
scan_word (wps, best_buffer, num_samples, -1);
|
||||
|
||||
if (noisy_buffer)
|
||||
free (noisy_buffer);
|
||||
|
||||
free (temp_buffer [1]);
|
||||
free (temp_buffer [0]);
|
||||
free (best_buffer);
|
||||
|
||||
#ifdef EXTRA_DUMP
|
||||
if (1) {
|
||||
char string [256], substring [20];
|
||||
int i;
|
||||
|
||||
sprintf (string, "M: delta = %.4f%%, terms =",
|
||||
((double) info.best_bits - default_bits) / 256.0 / wps->wphdr.block_samples / 32.0 * 100.0);
|
||||
sprintf (string, "M: terms =");
|
||||
|
||||
for (i = 0; i < info.nterms; ++i) {
|
||||
for (i = 0; i < wps->num_terms; ++i) {
|
||||
if (wps->decorr_passes [i].term) {
|
||||
if (i && wps->decorr_passes [i-1].delta == wps->decorr_passes [i].delta)
|
||||
sprintf (substring, " %d", wps->decorr_passes [i].term);
|
||||
|
@ -547,13 +667,5 @@ void analyze_mono (WavpackContext *wpc, int32_t *samples)
|
|||
error_line (string);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < info.nterms; ++i)
|
||||
if (!wps->decorr_passes [i].term)
|
||||
break;
|
||||
|
||||
wps->num_terms = i;
|
||||
|
||||
for (i = 0; i < info.nterms + 2; ++i)
|
||||
free (info.sampleptrs [i]);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,242 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WavPack 4.0 File / Block Format
|
||||
-------------------------------
|
||||
|
||||
December 9, 2006
|
||||
David Bryant
|
||||
|
||||
updated: April 29, 2007
|
||||
updated: Sept 26, 2009
|
||||
|
||||
1.0 INTRODUCTION
|
||||
|
||||
A WavPack 4.0 file consists of a series of WavPack audio blocks. It may also
|
||||
contain tags and other information, but these must be outside the blocks
|
||||
(either before, in-between, or after) and are ignored for the purpose of
|
||||
unpacking audio data. The WavPack blocks are easy to identify by their unique
|
||||
header data, and by looking in the header it is very easy to determine the total
|
||||
size of the block (both in physical bytes and compressed samples) and the audio
|
||||
format stored. There are no specialized seek tables.
|
||||
|
||||
The blocks are completely independent in that they can be decoded to mono or
|
||||
stereo audio all by themselves. The blocks may contain any number of samples
|
||||
(well, up to 131072), either stereo or mono. Obviously, putting more samples
|
||||
in each block is more efficient because of reduced header overhead, but they are
|
||||
reasonably efficient down to even a thousand samples. I have set the max size to
|
||||
1 MB for the whole block, but this is arbitrary. The blocks may be lossless or
|
||||
lossy. Currently the hybrid/lossy modes are basically CBR, but I am planning a
|
||||
quality based VBR version also, and all the provisions exist for this in the
|
||||
format.
|
||||
|
||||
For multichannel audio, the data is divided into some number of stereo and mono
|
||||
streams and multiplexed into separate blocks which repeat in sequence. A flag
|
||||
in the header indicates whether the block is the first or the last in the
|
||||
sequence (for simple mono or stereo files both of these would always be set).
|
||||
The speaker assignments are in standard Microsoft order and the channel_mask is
|
||||
transmitted in a separate piece of metadata. Channels that naturally belong
|
||||
together (i.e. left and right pairs) are put into stereo blocks and other
|
||||
channels are put into mono block. So, for example, a standard 5.1 audio stream
|
||||
would have a channel_mask of 0x3F and be organized into 4 blocks in sequence:
|
||||
|
||||
1. stereo block (front left + front right) (INITIAL_BLOCK)
|
||||
2. mono block (front center)
|
||||
3. mono block (low frequency effects)
|
||||
4. stereo block (back left + back right) (FINAL_BLOCK)
|
||||
|
||||
Correction files (.wvc) have an identical structure to the main file (.wv) and
|
||||
there is a one-to-one correspondence between main file blocks that contain audio
|
||||
and their correction file match (blocks that do not contain audio do not exist
|
||||
in the correction file). The only difference in the headers of main blocks and
|
||||
correction blocks is the size and the CRC value, although it is easy (if a
|
||||
little ugly) to tell the blocks apart by looking at the metadata ids.
|
||||
|
||||
The format is designed with hardware decoding in mind, and so it is possible to
|
||||
decode regular stereo (or mono) WavPack files without buffering an entire block,
|
||||
which allows the memory requirements to be reduced to only a few kilobytes if
|
||||
desired. This is not true of multichannel files, and this also restricts
|
||||
playback of high-resolution files to 24 bits of precision (although neither of
|
||||
these would be associated with low-cost playback equipment).
|
||||
|
||||
2.0 BLOCK HEADER
|
||||
|
||||
Here is the 32-byte little-endian header at the front of every WavPack block:
|
||||
|
||||
typedef struct {
|
||||
char ckID [4]; // "wvpk"
|
||||
uint32_t ckSize; // size of entire block (minus 8, of course)
|
||||
uint16_t version; // 0x402 to 0x410 are currently valid for decode
|
||||
uchar track_no; // track number (0 if not used, like now)
|
||||
uchar index_no; // track sub-index (0 if not used, like now)
|
||||
uint32_t total_samples; // total samples for entire file, but this is
|
||||
// only valid if block_index == 0 and a value of
|
||||
// -1 indicates unknown length
|
||||
uint32_t block_index; // index of first sample in block relative to
|
||||
// beginning of file (normally this would start
|
||||
// at 0 for the first block)
|
||||
uint32_t block_samples; // number of samples in this block (0 = no audio)
|
||||
uint32_t flags; // various flags for id and decoding
|
||||
uint32_t crc; // crc for actual decoded data
|
||||
} WavpackHeader;
|
||||
|
||||
Note that in this context the meaning of "samples" refers to a complete
|
||||
sample for all channels (sometimes called a "frame"). Therefore, in a stereo
|
||||
or multichannel file the actual number of numeric samples is this value
|
||||
multiplied by the number of channels. This effectively limits the size of an
|
||||
on-disk WavPack file to (2^32)-2 samples, although this should not be a big
|
||||
restriction for most applications (that is over 24 hours at 44.1 kHz, no
|
||||
matter how many channels).
|
||||
|
||||
There is no limit to the size of the WavPack file itself, although the
|
||||
library currently cannot seek in WavPack files over 4 gig. Also, the .wav
|
||||
format itself has a 4 gig limit, so this limits the size of the source and
|
||||
destination files (although this is planned to be resolved with the W64
|
||||
and RIFF64 file formats).
|
||||
|
||||
Normally, the first block of a WavPack file that contains audio samples
|
||||
(blocks may contains only metadata) would have "block_index" == 0 and
|
||||
"total_samples" would be equal to the total number of samples in the
|
||||
file. However, there are some possible exceptions to this rule. For example,
|
||||
a file may be created such that its total length is unknown (i.e. with
|
||||
pipes) and in this case total_samples == -1. For these files, the WavPack
|
||||
decoder will attempt to seek to the end of the file to determine the actual
|
||||
length, and if this is impossible then the length is simply unknown.
|
||||
|
||||
Another case is where a WavPack file is created by cutting a portion out of a
|
||||
longer WavPack file (or from a WavPack stream). Since this file would start
|
||||
with a block that didn't have "block_index" == 0, the length would be unknown
|
||||
until a seek to end was performed. In fact, an on-disk file would still be
|
||||
perfectly playable and seekable as long as there were less than (2^32)-2 total
|
||||
samples (the "block_index" could even wrap).
|
||||
|
||||
It is also possible to have streamed WavPack data. In this case both the
|
||||
"block_index" and "total_samples" fields are ignored for every block and the
|
||||
decoder simply decodes every block encountered indefinitely.
|
||||
|
||||
The "flags" field contains information for decoding the block along with some
|
||||
general information including sample size and format, hybrid/lossless,
|
||||
mono/stereo and sampling rate (if one of 15 standard rates). Here are the
|
||||
(little-endian) bit assignments:
|
||||
|
||||
bits 1,0: // 00 = 1 byte / sample (1-8 bits / sample)
|
||||
// 01 = 2 bytes / sample (1-16 bits / sample)
|
||||
// 10 = 3 bytes / sample (1-24 bits / sample)
|
||||
// 11 = 4 bytes / sample (1-32 bits / sample)
|
||||
bit 2: // 0 = stereo output; 1 = mono output
|
||||
bit 3: // 0 = lossless mode; 1 = hybrid mode
|
||||
bit 4: // 0 = true stereo; 1 = joint stereo (mid/side)
|
||||
bit 5: // 0 = independent channels; 1 = cross-channel decorrelation
|
||||
bit 6: // 0 = flat noise spectrum in hybrid; 1 = hybrid noise shaping
|
||||
bit 7: // 0 = integer data; 1 = floating point data
|
||||
bit 8: // 1 = extended size integers (> 24-bit) or shifted integers
|
||||
bit 9: // 0 = hybrid mode parameters control noise level
|
||||
// 1 = hybrid mode parameters control bitrate
|
||||
bit 10: // 1 = hybrid noise balanced between channels
|
||||
bit 11: // 1 = initial block in sequence (for multichannel)
|
||||
bit 12: // 1 = final block in sequence (for multichannel)
|
||||
bits 17-13: // amount of data left-shift after decode (0-31 places)
|
||||
bits 22-18: // maximum magnitude of decoded data
|
||||
// (number of bits integers require minus 1)
|
||||
bits 26-23: // sampling rate (1111 = unknown/custom)
|
||||
bits 27-28: // reserved (but decoders should ignore if set)
|
||||
bit 29: // 1 = use IIR for negative hybrid noise shaping
|
||||
bit 30: // 1 = false stereo (data is mono but output is stereo)
|
||||
bit 31: // reserved (decoders should refuse to decode if set)
|
||||
|
||||
|
||||
3.0 METADATA SUB-BLOCKS
|
||||
|
||||
Following the 32-byte header to the end of the block are a series of "metadata"
|
||||
sub-blocks. These may from 2 bytes long to the size of the entire block and are
|
||||
extremely easy to parse (even without knowing what they mean). These mostly
|
||||
contain extra information needed to decode the audio, but may also contain user
|
||||
information that is not required for decoding and that could be used in the
|
||||
future without breaking existing decoders. The final sub-block is usually the
|
||||
compressed audio bitstream itself, although this is not a strict rule.
|
||||
|
||||
The format of the metadata is:
|
||||
|
||||
uchar id; // mask meaning
|
||||
// ---- -------
|
||||
// 0x1f metadata function
|
||||
// 0x20 decoder need not understand metadata
|
||||
// 0x40 actual data byte length is 1 less
|
||||
// 0x80 large block (> 255 words)
|
||||
|
||||
uchar word_size; // small block: data size in words (padded)
|
||||
or...
|
||||
uchar word_size [3]; // large block: data size in words (padded,
|
||||
little-endian)
|
||||
|
||||
uint16_t data [word_size]; // data, padded to an even # of bytes
|
||||
|
||||
The currently assigned metadata ids are:
|
||||
|
||||
ID_DUMMY 0x0 // could be used to pad WavPack blocks
|
||||
ID_DECORR_TERMS 0x2 // decorrelation terms & deltas (fixed)
|
||||
ID_DECORR_WEIGHTS 0x3 // initial decorrelation weights
|
||||
ID_DECORR_SAMPLES 0x4 // decorrelation sample history
|
||||
ID_ENTROPY_VARS 0x5 // initial entropy variables
|
||||
ID_HYBRID_PROFILE 0x6 // entropy variables specific to hybrid mode
|
||||
ID_SHAPING_WEIGHTS 0x7 // info needed for hybrid lossless (wvc) mode
|
||||
ID_FLOAT_INFO 0x8 // specific info for floating point decode
|
||||
ID_INT32_INFO 0x9 // specific info for decoding integers > 24
|
||||
// bits, or data requiring shift after decode
|
||||
ID_WV_BITSTREAM 0xa // normal compressed audio bitstream (wv file)
|
||||
ID_WVC_BITSTREAM 0xb // correction file bitstream (wvc file)
|
||||
ID_WVX_BITSTREAM 0xc // special extended bitstream for floating
|
||||
// point data or integers > 24 bit (can be
|
||||
// in either wv or wvc file, depending...)
|
||||
ID_CHANNEL_INFO 0xd // contains channel count and channel_mask
|
||||
|
||||
ID_RIFF_HEADER 0x21 // RIFF header for .wav files (before audio)
|
||||
ID_RIFF_TRAILER 0x22 // RIFF trailer for .wav files (after audio)
|
||||
ID_CONFIG_BLOCK 0x25 // some encoding details for info purposes
|
||||
ID_MD5_CHECKSUM 0x26 // 16-byte MD5 sum of raw audio data
|
||||
ID_SAMPLE_RATE 0x27 // non-standard sampling rate info
|
||||
|
||||
Note: unlisted ids are reserved.
|
||||
|
||||
The RIFF header and trailer are optional for most playback purposes, however
|
||||
older decoders (< 4.40) will not decode to .wav files unless at least the
|
||||
ID_RIFF_HEADER is present. In the future these could be used to encode other
|
||||
uncompressed audio formats (like AIFF).
|
||||
|
||||
4.0 METADATA TAGS
|
||||
|
||||
These tags are not to be confused with the metadata sub-blocks described above
|
||||
but are specialized tags for storing user data on many formats of audio files.
|
||||
The tags recommended for use with WavPack files (and the ones that the WavPack
|
||||
supplied plugins and programs will work with) are ID3v1 and APEv2. The ID3v1
|
||||
tags are somewhat primitive and limited, but are supported for legacy purposes.
|
||||
The more recommended tagging format is APEv2 because of its rich functionality
|
||||
and broad software support (it is also used on Monkey's Audio and Musepack
|
||||
files). Both the APEv2 tags and/or ID3v1 tags must come at the end of the
|
||||
WavPack file, with the ID3v1 coming last if both are present.
|
||||
|
||||
For the APEv2 tags, the following field names are officially supported and
|
||||
recommended by WavPack (although there are no restrictions on what field names
|
||||
may be used):
|
||||
|
||||
Artist
|
||||
Title
|
||||
Album
|
||||
Track
|
||||
Year
|
||||
Genre
|
||||
Comment
|
||||
Cuesheet (note: may include replay gain info as remarks)
|
||||
Replaygain_Track_Gain
|
||||
Replaygain_Track_Peak
|
||||
Replaygain_Album_Gain
|
||||
Replaygain_Album_Peak
|
||||
Cover Art (Front)
|
||||
Cover Art (Back)
|
||||
Log
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// float.c
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -22,7 +22,7 @@ void free_db (void *ptr);
|
|||
int32_t dump_alloc (void);
|
||||
#endif
|
||||
|
||||
#ifdef PACK
|
||||
#ifndef NO_PACK
|
||||
|
||||
void write_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ void write_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
*byteptr++ = wps->float_shift;
|
||||
*byteptr++ = wps->float_max_exp;
|
||||
*byteptr++ = wps->float_norm_exp;
|
||||
wpmd->byte_length = byteptr - (char *) wpmd->data;
|
||||
wpmd->byte_length = (int32_t)(byteptr - (char *) wpmd->data);
|
||||
}
|
||||
|
||||
int scan_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
||||
|
@ -42,36 +42,36 @@ int scan_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
|||
int32_t shifted_ones = 0, shifted_zeros = 0, shifted_both = 0;
|
||||
int32_t false_zeros = 0, neg_zeros = 0;
|
||||
uint32_t ordata = 0, crc = 0xffffffff;
|
||||
int max_exp = 0, shift_count;
|
||||
int32_t count, value;
|
||||
int32_t count, value, shift_count;
|
||||
int max_exp = 0;
|
||||
f32 *dp;
|
||||
|
||||
wps->float_shift = wps->float_flags = 0;
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++) {
|
||||
crc = crc * 27 + dp->mantissa * 9 + dp->exponent * 3 + dp->sign;
|
||||
crc = crc * 27 + get_mantissa (*dp) * 9 + get_exponent (*dp) * 3 + get_sign (*dp);
|
||||
|
||||
if (dp->exponent > max_exp && dp->exponent < 255)
|
||||
max_exp = dp->exponent;
|
||||
if (get_exponent (*dp) > max_exp && get_exponent (*dp) < 255)
|
||||
max_exp = get_exponent (*dp);
|
||||
}
|
||||
|
||||
wps->crc_x = crc;
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++) {
|
||||
if (dp->exponent == 255) {
|
||||
if (get_exponent (*dp) == 255) {
|
||||
wps->float_flags |= FLOAT_EXCEPTIONS;
|
||||
value = 0x1000000;
|
||||
shift_count = 0;
|
||||
}
|
||||
else if (dp->exponent) {
|
||||
shift_count = max_exp - dp->exponent;
|
||||
value = 0x800000 + dp->mantissa;
|
||||
else if (get_exponent (*dp)) {
|
||||
shift_count = max_exp - get_exponent (*dp);
|
||||
value = 0x800000 + get_mantissa (*dp);
|
||||
}
|
||||
else {
|
||||
shift_count = max_exp ? max_exp - 1 : 0;
|
||||
value = dp->mantissa;
|
||||
value = get_mantissa (*dp);
|
||||
|
||||
// if (dp->mantissa)
|
||||
// if (get_mantissa (*dp))
|
||||
// denormals++;
|
||||
}
|
||||
|
||||
|
@ -81,24 +81,24 @@ int scan_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
|||
value = 0;
|
||||
|
||||
if (!value) {
|
||||
if (dp->exponent || dp->mantissa)
|
||||
if (get_exponent (*dp) || get_mantissa (*dp))
|
||||
++false_zeros;
|
||||
else if (dp->sign)
|
||||
else if (get_sign (*dp))
|
||||
++neg_zeros;
|
||||
}
|
||||
else if (shift_count) {
|
||||
int32_t mask = (1 << shift_count) - 1;
|
||||
|
||||
if (!(dp->mantissa & mask))
|
||||
if (!(get_mantissa (*dp) & mask))
|
||||
shifted_zeros++;
|
||||
else if ((dp->mantissa & mask) == mask)
|
||||
else if ((get_mantissa (*dp) & mask) == mask)
|
||||
shifted_ones++;
|
||||
else
|
||||
shifted_both++;
|
||||
}
|
||||
|
||||
ordata |= value;
|
||||
* (int32_t *) dp = (dp->sign) ? -value : value;
|
||||
* (int32_t *) dp = (get_sign (*dp)) ? -value : value;
|
||||
}
|
||||
|
||||
wps->float_max_exp = max_exp;
|
||||
|
@ -149,10 +149,10 @@ void send_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
|||
f32 *dp;
|
||||
|
||||
for (dp = values, count = num_values; count--; dp++) {
|
||||
if (dp->exponent == 255) {
|
||||
if (dp->mantissa) {
|
||||
if (get_exponent (*dp) == 255) {
|
||||
if (get_mantissa (*dp)) {
|
||||
putbit_1 (&wps->wvxbits);
|
||||
putbits (dp->mantissa, 23, &wps->wvxbits);
|
||||
putbits (get_mantissa (*dp), 23, &wps->wvxbits);
|
||||
}
|
||||
else {
|
||||
putbit_0 (&wps->wvxbits);
|
||||
|
@ -161,13 +161,13 @@ void send_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
|||
value = 0x1000000;
|
||||
shift_count = 0;
|
||||
}
|
||||
else if (dp->exponent) {
|
||||
shift_count = max_exp - dp->exponent;
|
||||
value = 0x800000 + dp->mantissa;
|
||||
else if (get_exponent (*dp)) {
|
||||
shift_count = max_exp - get_exponent (*dp);
|
||||
value = 0x800000 + get_mantissa (*dp);
|
||||
}
|
||||
else {
|
||||
shift_count = max_exp ? max_exp - 1 : 0;
|
||||
value = dp->mantissa;
|
||||
value = get_mantissa (*dp);
|
||||
}
|
||||
|
||||
if (shift_count < 25)
|
||||
|
@ -177,31 +177,31 @@ void send_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
|||
|
||||
if (!value) {
|
||||
if (wps->float_flags & FLOAT_ZEROS_SENT) {
|
||||
if (dp->exponent || dp->mantissa) {
|
||||
if (get_exponent (*dp) || get_mantissa (*dp)) {
|
||||
putbit_1 (&wps->wvxbits);
|
||||
putbits (dp->mantissa, 23, &wps->wvxbits);
|
||||
putbits (get_mantissa (*dp), 23, &wps->wvxbits);
|
||||
|
||||
if (max_exp >= 25) {
|
||||
putbits (dp->exponent, 8, &wps->wvxbits);
|
||||
putbits (get_exponent (*dp), 8, &wps->wvxbits);
|
||||
}
|
||||
|
||||
putbit (dp->sign, &wps->wvxbits);
|
||||
putbit (get_sign (*dp), &wps->wvxbits);
|
||||
}
|
||||
else {
|
||||
putbit_0 (&wps->wvxbits);
|
||||
|
||||
if (wps->float_flags & FLOAT_NEG_ZEROS)
|
||||
putbit (dp->sign, &wps->wvxbits);
|
||||
putbit (get_sign (*dp), &wps->wvxbits);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (shift_count) {
|
||||
if (wps->float_flags & FLOAT_SHIFT_SENT) {
|
||||
int32_t data = dp->mantissa & ((1 << shift_count) - 1);
|
||||
int32_t data = get_mantissa (*dp) & ((1 << shift_count) - 1);
|
||||
putbits (data, shift_count, &wps->wvxbits);
|
||||
}
|
||||
else if (wps->float_flags & FLOAT_SHIFT_SAME) {
|
||||
putbit (dp->mantissa & 1, &wps->wvxbits);
|
||||
putbit (get_mantissa (*dp) & 1, &wps->wvxbits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ void send_float_data (WavpackStream *wps, f32 *values, int32_t num_values)
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(UNPACK) || defined(INFO_ONLY)
|
||||
#if !defined(NO_UNPACK) || defined(INFO_ONLY)
|
||||
|
||||
int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef UNPACK
|
||||
#ifndef NO_UNPACK
|
||||
|
||||
static void float_values_nowvx (WavpackStream *wps, int32_t *values, int32_t num_values);
|
||||
|
||||
|
@ -243,24 +243,24 @@ void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
|
|||
|
||||
while (num_values--) {
|
||||
int shift_count = 0, exp = wps->float_max_exp;
|
||||
f32 outval = { 0, 0, 0 };
|
||||
f32 outval = 0;
|
||||
uint32_t temp;
|
||||
|
||||
if (*values == 0) {
|
||||
if (wps->float_flags & FLOAT_ZEROS_SENT) {
|
||||
if (getbit (&wps->wvxbits)) {
|
||||
getbits (&temp, 23, &wps->wvxbits);
|
||||
outval.mantissa = temp;
|
||||
set_mantissa (outval, temp);
|
||||
|
||||
if (exp >= 25) {
|
||||
getbits (&temp, 8, &wps->wvxbits);
|
||||
outval.exponent = temp;
|
||||
set_exponent (outval, temp);
|
||||
}
|
||||
|
||||
outval.sign = getbit (&wps->wvxbits);
|
||||
set_sign (outval, getbit (&wps->wvxbits));
|
||||
}
|
||||
else if (wps->float_flags & FLOAT_NEG_ZEROS)
|
||||
outval.sign = getbit (&wps->wvxbits);
|
||||
set_sign (outval, getbit (&wps->wvxbits));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -268,16 +268,16 @@ void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
|
|||
|
||||
if (*values < 0) {
|
||||
*values = -*values;
|
||||
outval.sign = 1;
|
||||
set_sign (outval, 1);
|
||||
}
|
||||
|
||||
if (*values == 0x1000000) {
|
||||
if (getbit (&wps->wvxbits)) {
|
||||
getbits (&temp, 23, &wps->wvxbits);
|
||||
outval.mantissa = temp;
|
||||
set_mantissa (outval, temp);
|
||||
}
|
||||
|
||||
outval.exponent = 255;
|
||||
set_exponent (outval, 255);
|
||||
}
|
||||
else {
|
||||
if (exp)
|
||||
|
@ -296,12 +296,12 @@ void float_values (WavpackStream *wps, int32_t *values, int32_t num_values)
|
|||
}
|
||||
}
|
||||
|
||||
outval.mantissa = *values;
|
||||
outval.exponent = exp;
|
||||
set_mantissa (outval, *values);
|
||||
set_exponent (outval, exp);
|
||||
}
|
||||
}
|
||||
|
||||
crc = crc * 27 + outval.mantissa * 9 + outval.exponent * 3 + outval.sign;
|
||||
crc = crc * 27 + get_mantissa (outval) * 9 + get_exponent (outval) * 3 + get_sign (outval);
|
||||
* (f32 *) values++ = outval;
|
||||
}
|
||||
|
||||
|
@ -312,14 +312,14 @@ static void float_values_nowvx (WavpackStream *wps, int32_t *values, int32_t num
|
|||
{
|
||||
while (num_values--) {
|
||||
int shift_count = 0, exp = wps->float_max_exp;
|
||||
f32 outval = { 0, 0, 0 };
|
||||
f32 outval = 0;
|
||||
|
||||
if (*values) {
|
||||
*values <<= wps->float_shift;
|
||||
|
||||
if (*values < 0) {
|
||||
*values = -*values;
|
||||
outval.sign = 1;
|
||||
set_sign (outval, 1);
|
||||
}
|
||||
|
||||
if (*values >= 0x1000000) {
|
||||
|
@ -338,8 +338,8 @@ static void float_values_nowvx (WavpackStream *wps, int32_t *values, int32_t num
|
|||
*values |= ((1 << shift_count) - 1);
|
||||
}
|
||||
|
||||
outval.mantissa = *values;
|
||||
outval.exponent = exp;
|
||||
set_mantissa (outval, *values);
|
||||
set_exponent (outval, exp);
|
||||
}
|
||||
|
||||
* (f32 *) values++ = outval;
|
||||
|
@ -348,23 +348,23 @@ static void float_values_nowvx (WavpackStream *wps, int32_t *values, int32_t num
|
|||
|
||||
#endif
|
||||
|
||||
void float_normalize (int32_t *values, int32_t num_values, int delta_exp)
|
||||
void WavpackFloatNormalize (int32_t *values, int32_t num_values, int delta_exp)
|
||||
{
|
||||
f32 *fvalues = (f32 *) values, fzero = { 0, 0, 0 };
|
||||
f32 *fvalues = (f32 *) values;
|
||||
int exp;
|
||||
|
||||
if (!delta_exp)
|
||||
return;
|
||||
|
||||
while (num_values--) {
|
||||
if ((exp = fvalues->exponent) == 0 || exp + delta_exp <= 0)
|
||||
*fvalues = fzero;
|
||||
if ((exp = get_exponent (*fvalues)) == 0 || exp + delta_exp <= 0)
|
||||
*fvalues = 0;
|
||||
else if (exp == 255 || (exp += delta_exp) >= 255) {
|
||||
fvalues->exponent = 255;
|
||||
fvalues->mantissa = 0;
|
||||
set_exponent (*fvalues, 255);
|
||||
set_mantissa (*fvalues, 0);
|
||||
}
|
||||
else
|
||||
fvalues->exponent = exp;
|
||||
set_exponent (*fvalues, exp);
|
||||
|
||||
fvalues++;
|
||||
}
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WavPack 4.0 File / Block Format
|
||||
-------------------------------
|
||||
|
||||
A WavPack 4.0 file consists of a series of WavPack audio blocks. It may also
|
||||
contain tags and other information, but these must be outside the blocks
|
||||
(either before, in-between, or after) and are ignored for the purpose of
|
||||
unpacking audio data. The WavPack blocks are easy to identify by their
|
||||
unique header data, and by looking in the header it is very easy to
|
||||
determine the total size of the block, both in physical bytes and compressed
|
||||
samples. There are no seek tables.
|
||||
|
||||
The blocks (or frames, if you prefer) are completely independent in that they
|
||||
can be decoded to mono or stereo audio all by themselves. A single function
|
||||
is provided to convert a whole block into its corresponding audio data.
|
||||
Similarly, a function is provided to convert a block of audio samples into
|
||||
a finished WavPack block. These all work in memory; disk I/O is handled
|
||||
outside. It is also possible to decode or encode blocks in smaller increments
|
||||
if it is important to distribute CPU load more evenly over time. The blocks may
|
||||
also be decoded without reading the whole block into memory, although this
|
||||
would only be important for hardware decoding.
|
||||
|
||||
The blocks may contain any number of samples, either stereo or mono. Obviously,
|
||||
putting more samples in each block is more efficient, but they are reasonably
|
||||
efficient down to even a thousand samples. I have set the max size to 1 MB for
|
||||
the whole block, but this is arbitrary. The blocks may be lossless or lossy
|
||||
(currently the lossy modes are basically CBR, but I am planning a quality
|
||||
based VBR version also).
|
||||
|
||||
For multichannel audio, the data is divided into some number of stereo and mono
|
||||
streams and multiplexed into separate blocks. Because blocks are independent
|
||||
there can be a mix of sampling rates, but all the streams must be sliced at
|
||||
the same point in time which is a multiple of all the sampling rates. The
|
||||
metadata contains source information (like front, center, rear, etc.).
|
||||
|
||||
Correction files (.wvc) have an identical structure to the main file (.wv) and
|
||||
there is a one-to-one correspondence between main file blocks that contain
|
||||
audio and their correction file match (blocks that do not contain audio do
|
||||
not exist in the correction file). The only difference in the headers of
|
||||
main blocks and correction blocks is the CRC value, although it is easy to
|
||||
tell the blocks apart by looking at the metadata ids.
|
||||
|
||||
Here is the 32-byte header at the front of every block:
|
||||
|
||||
typedef struct {
|
||||
char ckID [4]; // "wvpk"
|
||||
long ckSize; // size of entire frame (minus 8, of course)
|
||||
short version; // 0x403 for now
|
||||
uchar track_no; // track number (0 if not used, like now)
|
||||
uchar index_no; // track sub-index (0 if not used, like now)
|
||||
ulong total_samples; // for entire file (-1 if unknown)
|
||||
ulong block_index; // index of first sample in block (to file begin)
|
||||
ulong block_samples; // # samples in this block
|
||||
ulong flags; // various flags for id and decoding
|
||||
ulong crc; // crc for actual decoded data
|
||||
} WavpackHeader;
|
||||
|
||||
The "flags" field contains information for decoding the block along with some
|
||||
general information including sample size and format, hybrid/lossless,
|
||||
mono/stereo and sampling rate. This structure is stored "little-endian".
|
||||
|
||||
Following the 32-byte header to the end of the block are a series of "metadata"
|
||||
sub-blocks. These may from 2 bytes long to the size of the entire block and are
|
||||
extremely easy to parse (even without knowing what they mean). Currently these
|
||||
mostly contain extra information needed to decode the audio, but may also
|
||||
contain user information. The only non-audio information I currently have
|
||||
implemented is a copy of the original wave RIFF header (or trailer if present),
|
||||
and the MD5 checksums, but there is plenty of flexibility here. For example,
|
||||
these metadata blocks could store cuesheets, artist/title information,
|
||||
replaygain values, even pictures or lyrics. The final metadata sub-blocks are
|
||||
the actual audio bitstreams, which have ids for standard audio (wvbits),
|
||||
correction data (wvcbits), and a special extension for large integer and
|
||||
floating-point data (wvxbits).
|
||||
|
||||
The format of the metadata is:
|
||||
|
||||
uchar id; // mask meaning
|
||||
// ---- -------
|
||||
// 0x1f metadata function
|
||||
// 0x20 decoder need not understand metadata
|
||||
// 0x40 actual data byte length is 1 less
|
||||
// 0x80 large block (> 255 words)
|
||||
|
||||
uchar word_size; // small block: data size in words (padded)
|
||||
or...
|
||||
uchar word_size [3]; // large block: data size in words (padded,
|
||||
little-endian)
|
||||
|
||||
ushort data [word_size]; // data, padded to an even # of bytes
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 1998 - 2005 Conifer Software
|
||||
Copyright (c) 1998 - 2009 Conifer Software
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -157,7 +157,7 @@ void MD5Final(digest, ctx)
|
|||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
byteReverse((unsigned char *) ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
// This module handles the metadata structure introduced in WavPack 4.0
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -25,12 +25,12 @@ void free_db (void *ptr);
|
|||
int32_t dump_alloc (void);
|
||||
#endif
|
||||
|
||||
#if defined(UNPACK) || defined(INFO_ONLY)
|
||||
#if !defined(NO_UNPACK) || defined(INFO_ONLY)
|
||||
|
||||
int read_metadata_buff (WavpackMetadata *wpmd, uchar *blockbuff, uchar **buffptr)
|
||||
int read_metadata_buff (WavpackMetadata *wpmd, unsigned char *blockbuff, unsigned char **buffptr)
|
||||
{
|
||||
WavpackHeader *wphdr = (WavpackHeader *) blockbuff;
|
||||
uchar *buffend = blockbuff + wphdr->ckSize + 8;
|
||||
unsigned char *buffend = blockbuff + wphdr->ckSize + 8;
|
||||
|
||||
if (buffend - *buffptr < 2)
|
||||
return FALSE;
|
||||
|
@ -137,9 +137,9 @@ int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef PACK
|
||||
#ifndef NO_PACK
|
||||
|
||||
int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end)
|
||||
int copy_metadata (WavpackMetadata *wpmd, unsigned char *buffer_start, unsigned char *buffer_end)
|
||||
{
|
||||
uint32_t mdsize = wpmd->byte_length + (wpmd->byte_length & 1);
|
||||
WavpackHeader *wphdr = (WavpackHeader *) buffer_start;
|
||||
|
@ -177,10 +177,10 @@ int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int add_to_metadata (WavpackContext *wpc, void *data, uint32_t bcount, uchar id)
|
||||
int add_to_metadata (WavpackContext *wpc, void *data, uint32_t bcount, unsigned char id)
|
||||
{
|
||||
WavpackMetadata *mdp;
|
||||
uchar *src = data;
|
||||
unsigned char *src = data;
|
||||
|
||||
while (bcount) {
|
||||
if (wpc->metacount) {
|
||||
|
@ -218,7 +218,7 @@ int add_to_metadata (WavpackContext *wpc, void *data, uint32_t bcount, uchar id)
|
|||
|
||||
static char *write_metadata (WavpackMetadata *wpmd, char *outdata)
|
||||
{
|
||||
uchar id = wpmd->id, wordlen [3];
|
||||
unsigned char id = wpmd->id, wordlen [3];
|
||||
|
||||
wordlen [0] = (wpmd->byte_length + 1) >> 1;
|
||||
wordlen [1] = (wpmd->byte_length + 1) >> 9;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2005-02-08.22
|
||||
scriptversion=2006-05-10.23
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
|
||||
# Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
|
@ -19,8 +19,8 @@ scriptversion=2005-02-08.22
|
|||
|
||||
# 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.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
|
@ -33,6 +33,8 @@ if test $# -eq 0; then
|
|||
fi
|
||||
|
||||
run=:
|
||||
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
|
@ -44,7 +46,7 @@ fi
|
|||
|
||||
msg="missing on your system"
|
||||
|
||||
case "$1" in
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
|
@ -77,6 +79,7 @@ Supported PROGRAM values:
|
|||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
autom4te touch the output file, or create a stub one
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
|
@ -106,7 +109,7 @@ esac
|
|||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program).
|
||||
case "$1" in
|
||||
case $1 in
|
||||
lex|yacc)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
@ -135,7 +138,7 @@ esac
|
|||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
case $1 in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
|
@ -164,7 +167,7 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
case $f in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
|
@ -192,8 +195,8 @@ WARNING: \`$1' is needed, but is $msg.
|
|||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
|
||||
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
|
@ -214,25 +217,25 @@ WARNING: \`$1' $msg. You should only need it if
|
|||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
@ -244,18 +247,18 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
@ -267,11 +270,9 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
|
||||
fi
|
||||
if [ -f "$file" ]; then
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
|
@ -289,14 +290,23 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
|
@ -314,13 +324,13 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case "$firstarg" in
|
||||
case $firstarg in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case "$firstarg" in
|
||||
case $firstarg in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -19,9 +19,11 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "wavpack_local.h"
|
||||
#include "unpack3.h"
|
||||
|
||||
#define ATTEMPT_ERROR_MUTING
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
#define malloc malloc_db
|
||||
#define realloc realloc_db
|
||||
|
@ -35,7 +37,7 @@ int32_t dump_alloc (void);
|
|||
static void unpack_init3 (WavpackStream3 *wps);
|
||||
static int bs_open_read3 (Bitstream3 *bs, WavpackStreamReader *reader, void *id);
|
||||
static void bs_close_read3 (Bitstream3 *bs);
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
static void bs_restore3 (Bitstream3 *bs);
|
||||
#endif
|
||||
|
||||
|
@ -53,6 +55,7 @@ WavpackContext *open_file3 (WavpackContext *wpc, char *error)
|
|||
WavpackStream3 *wps;
|
||||
WaveHeader3 wavhdr;
|
||||
|
||||
CLEAR (wavhdr);
|
||||
wpc->stream3 = wps = (WavpackStream3 *) malloc (sizeof (WavpackStream3));
|
||||
CLEAR (*wps);
|
||||
|
||||
|
@ -108,34 +111,40 @@ WavpackContext *open_file3 (WavpackContext *wpc, char *error)
|
|||
if (ChunkHeader.ckSize > sizeof (wavhdr)) {
|
||||
uint32_t bytes_to_skip = (ChunkHeader.ckSize + 1 - sizeof (wavhdr)) & ~1L;
|
||||
|
||||
if (bytes_to_skip > 1024 * 1024) {
|
||||
strcpy (error, "not a valid WavPack file!");
|
||||
return WavpackCloseFile (wpc);
|
||||
}
|
||||
|
||||
if (wpc->open_flags & OPEN_WRAPPER) {
|
||||
wpc->wrapper_data = realloc (wpc->wrapper_data, wpc->wrapper_bytes + bytes_to_skip);
|
||||
wpc->reader->read_bytes (wpc->wv_in, wpc->wrapper_data + wpc->wrapper_bytes, bytes_to_skip);
|
||||
wpc->wrapper_bytes += bytes_to_skip;
|
||||
}
|
||||
else {
|
||||
uchar *temp = malloc (bytes_to_skip);
|
||||
unsigned char *temp = malloc (bytes_to_skip);
|
||||
wpc->reader->read_bytes (wpc->wv_in, temp, bytes_to_skip);
|
||||
free (temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strncmp (ChunkHeader.ckID, "data", 4)) {
|
||||
wpc->total_samples = ChunkHeader.ckSize / wavhdr.NumChannels /
|
||||
((wavhdr.BitsPerSample > 16) ? 3 : 2);
|
||||
|
||||
else if (!strncmp (ChunkHeader.ckID, "data", 4))
|
||||
break;
|
||||
}
|
||||
else if ((ChunkHeader.ckSize + 1) & ~1L) {
|
||||
uint32_t bytes_to_skip = (ChunkHeader.ckSize + 1) & ~1L;
|
||||
|
||||
if (bytes_to_skip > 1024 * 1024) {
|
||||
strcpy (error, "not a valid WavPack file!");
|
||||
return WavpackCloseFile (wpc);
|
||||
}
|
||||
|
||||
if (wpc->open_flags & OPEN_WRAPPER) {
|
||||
wpc->wrapper_data = realloc (wpc->wrapper_data, wpc->wrapper_bytes + bytes_to_skip);
|
||||
wpc->reader->read_bytes (wpc->wv_in, wpc->wrapper_data + wpc->wrapper_bytes, bytes_to_skip);
|
||||
wpc->wrapper_bytes += bytes_to_skip;
|
||||
}
|
||||
else {
|
||||
uchar *temp = malloc (bytes_to_skip);
|
||||
unsigned char *temp = malloc (bytes_to_skip);
|
||||
wpc->reader->read_bytes (wpc->wv_in, temp, bytes_to_skip);
|
||||
free (temp);
|
||||
}
|
||||
|
@ -148,6 +157,17 @@ WavpackContext *open_file3 (WavpackContext *wpc, char *error)
|
|||
return WavpackCloseFile (wpc);
|
||||
}
|
||||
|
||||
if (wavhdr.FormatTag != 1 || !wavhdr.NumChannels || wavhdr.NumChannels > 2 ||
|
||||
!wavhdr.SampleRate || wavhdr.BitsPerSample < 16 || wavhdr.BitsPerSample > 24 ||
|
||||
wavhdr.BlockAlign / wavhdr.NumChannels > 3 || wavhdr.BlockAlign % wavhdr.NumChannels ||
|
||||
wavhdr.BlockAlign / wavhdr.NumChannels < (wavhdr.BitsPerSample + 7) / 8) {
|
||||
strcpy (error, "not a valid WavPack file!");
|
||||
return WavpackCloseFile (wpc);
|
||||
}
|
||||
|
||||
wpc->total_samples = ChunkHeader.ckSize / wavhdr.NumChannels /
|
||||
((wavhdr.BitsPerSample > 16) ? 3 : 2);
|
||||
|
||||
if (wpc->reader->read_bytes (wpc->wv_in, &wphdr, 10) != 10) {
|
||||
strcpy (error, "not a valid WavPack file!");
|
||||
return WavpackCloseFile (wpc);
|
||||
|
@ -221,6 +241,7 @@ WavpackContext *open_file3 (WavpackContext *wpc, char *error)
|
|||
|
||||
wpc->config.sample_rate = wavhdr.SampleRate;
|
||||
wpc->config.num_channels = wavhdr.NumChannels;
|
||||
wpc->config.channel_mask = 5 - wavhdr.NumChannels;
|
||||
|
||||
if (wphdr.flags & MONO_FLAG)
|
||||
wpc->config.flags |= CONFIG_MONO_FLAG;
|
||||
|
@ -266,7 +287,7 @@ void free_stream3 (WavpackContext *wpc)
|
|||
WavpackStream3 *wps = (WavpackStream3 *) wpc->stream3;
|
||||
|
||||
if (wps) {
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
if (wps->unpack_data)
|
||||
free (wps->unpack_data);
|
||||
#endif
|
||||
|
@ -306,7 +327,7 @@ static int bs_open_read3 (Bitstream3 *bs, WavpackStreamReader *reader, void *id)
|
|||
bs->fpos = (bs->reader = reader)->get_pos (bs->id = id);
|
||||
|
||||
if (!bs->buf)
|
||||
bs->buf = (uchar *) malloc (bs->bufsiz);
|
||||
bs->buf = (unsigned char *) malloc (bs->bufsiz);
|
||||
|
||||
bs->end = bs->buf + bs->bufsiz;
|
||||
bs->ptr = bs->end - 1;
|
||||
|
@ -316,16 +337,16 @@ static int bs_open_read3 (Bitstream3 *bs, WavpackStreamReader *reader, void *id)
|
|||
return bs->error;
|
||||
}
|
||||
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
|
||||
// This function is called after a call to unpack_restore() has restored
|
||||
// the BitStream structure to a previous state and causes any required data
|
||||
// to be read from the file. This function is NOT supported for overlapped
|
||||
// operation.
|
||||
|
||||
void bs_restore3 (Bitstream3 *bs)
|
||||
static void bs_restore3 (Bitstream3 *bs)
|
||||
{
|
||||
uint32_t bytes_to_read = bs->end - bs->ptr - 1, bytes_read;
|
||||
uint32_t bytes_to_read = (uint32_t)(bs->end - bs->ptr - 1), bytes_read;
|
||||
|
||||
bs->reader->set_pos_abs (bs->id, bs->fpos - bytes_to_read);
|
||||
|
||||
|
@ -358,10 +379,10 @@ static uint32_t bs_unused_bytes (Bitstream3 *bs)
|
|||
bs->ptr++;
|
||||
}
|
||||
|
||||
return bs->end - bs->ptr;
|
||||
return (uint32_t)(bs->end - bs->ptr);
|
||||
}
|
||||
|
||||
static uchar *bs_unused_data (Bitstream3 *bs)
|
||||
static unsigned char *bs_unused_data (Bitstream3 *bs)
|
||||
{
|
||||
if (bs->bc < 8) {
|
||||
bs->bc += 8;
|
||||
|
@ -371,7 +392,7 @@ static uchar *bs_unused_data (Bitstream3 *bs)
|
|||
return bs->ptr;
|
||||
}
|
||||
|
||||
#ifdef UNPACK
|
||||
#ifndef NO_UNPACK
|
||||
|
||||
//////////////////////////////// local macros /////////////////////////////////
|
||||
|
||||
|
@ -434,11 +455,11 @@ static void unpack_init3 (WavpackStream3 *wps)
|
|||
for (dpp = wps->decorr_passes, ti = 0; ti < sizeof (simple_terms); ti++)
|
||||
dpp++->term = simple_terms [sizeof (simple_terms) - ti - 1];
|
||||
|
||||
wps->num_terms = dpp - wps->decorr_passes;
|
||||
wps->num_terms = (int)(dpp - wps->decorr_passes);
|
||||
init_words3 (wps);
|
||||
}
|
||||
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
|
||||
#define SAVE(destin, item) { memcpy (destin, &item, sizeof (item)); destin = (char *) destin + sizeof (item); }
|
||||
#define RESTORE(item, source) { memcpy (&item, source, sizeof (item)); source = (char *) source + sizeof (item); }
|
||||
|
@ -482,8 +503,8 @@ static int unpack_size (WavpackStream3 *wps)
|
|||
byte_sum += sizeof (wps->dc.weight);
|
||||
}
|
||||
|
||||
if (flags & (HIGH_FLAG | NEW_HIGH_FLAG)) {
|
||||
for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) {
|
||||
if (flags & (HIGH_FLAG | NEW_HIGH_FLAG))
|
||||
for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++)
|
||||
if (dpp->term > 0) {
|
||||
byte_sum += sizeof (dpp->samples_A [0]) * dpp->term;
|
||||
byte_sum += sizeof (dpp->weight_A);
|
||||
|
@ -497,8 +518,6 @@ static int unpack_size (WavpackStream3 *wps)
|
|||
byte_sum += sizeof (dpp->samples_A [0]) + sizeof (dpp->samples_B [0]);
|
||||
byte_sum += sizeof (dpp->weight_A) + sizeof (dpp->weight_B);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return byte_sum;
|
||||
}
|
||||
|
@ -552,8 +571,8 @@ static void *unpack_save (WavpackStream3 *wps, void *destin)
|
|||
SAVE (destin, wps->dc.weight);
|
||||
}
|
||||
|
||||
if (flags & (HIGH_FLAG | NEW_HIGH_FLAG)) {
|
||||
for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) {
|
||||
if (flags & (HIGH_FLAG | NEW_HIGH_FLAG))
|
||||
for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++)
|
||||
if (dpp->term > 0) {
|
||||
int count = dpp->term;
|
||||
int index = wps->dc.m;
|
||||
|
@ -583,8 +602,6 @@ static void *unpack_save (WavpackStream3 *wps, void *destin)
|
|||
SAVE (destin, dpp->samples_A [0]);
|
||||
SAVE (destin, dpp->samples_B [0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return destin;
|
||||
}
|
||||
|
@ -601,7 +618,7 @@ static void *unpack_restore (WavpackStream3 *wps, void *source, int keep_resourc
|
|||
int flags = wps->wphdr.flags, tcount;
|
||||
struct decorr_pass *dpp;
|
||||
FILE *temp_file;
|
||||
uchar *temp_buf;
|
||||
unsigned char *temp_buf;
|
||||
|
||||
unpack_init3 (wps);
|
||||
temp_file = wps->wvbits.id;
|
||||
|
@ -666,8 +683,8 @@ static void *unpack_restore (WavpackStream3 *wps, void *source, int keep_resourc
|
|||
RESTORE (wps->dc.weight, source);
|
||||
}
|
||||
|
||||
if (flags & (HIGH_FLAG | NEW_HIGH_FLAG)) {
|
||||
for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++) {
|
||||
if (flags & (HIGH_FLAG | NEW_HIGH_FLAG))
|
||||
for (tcount = wps->num_terms, dpp = wps->decorr_passes; tcount--; dpp++)
|
||||
if (dpp->term > 0) {
|
||||
int count = dpp->term;
|
||||
int index = wps->dc.m;
|
||||
|
@ -697,8 +714,6 @@ static void *unpack_restore (WavpackStream3 *wps, void *source, int keep_resourc
|
|||
RESTORE (dpp->samples_A [0], source);
|
||||
RESTORE (dpp->samples_B [0], source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
@ -781,7 +796,7 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
{
|
||||
WavpackStream3 *wps = (WavpackStream3 *) wpc->stream3;
|
||||
int shift = wps->wphdr.shift, flags = wps->wphdr.flags, min_weight = 0, m = wps->dc.m, tcount;
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
int points_index = wps->sample_index / ((wpc->total_samples >> 8) + 1);
|
||||
#endif
|
||||
int32_t min_value, max_value, min_shifted, max_shifted;
|
||||
|
@ -790,7 +805,19 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
int32_t read_word, *bptr;
|
||||
int32_t sample [2] [2];
|
||||
int weight [2] [1];
|
||||
uint i;
|
||||
unsigned int i;
|
||||
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
int32_t mute_limit = (flags & BYTES_3) ? 8388608 : 32768;
|
||||
int mute_block = 0;
|
||||
|
||||
if (wps->wphdr.bits && !(flags & WVC_FLAG)) {
|
||||
if (wps->wphdr.version < 3)
|
||||
mute_limit *= 4;
|
||||
else
|
||||
mute_limit *= 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wps->sample_index + sample_count > wpc->total_samples)
|
||||
sample_count = wpc->total_samples - wps->sample_index;
|
||||
|
@ -807,11 +834,11 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
bs_open_read3 (&wps->wvcbits, wpc->reader, wpc->wvc_in);
|
||||
}
|
||||
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
if (!wps->index_points [points_index].saved) {
|
||||
|
||||
if (!wps->unpack_data)
|
||||
wps->unpack_data = (uchar *) malloc (256 * (wps->unpack_size = unpack_size (wps)));
|
||||
wps->unpack_data = (unsigned char *) malloc (256 * (wps->unpack_size = unpack_size (wps)));
|
||||
|
||||
wps->index_points [points_index].sample_index = wps->sample_index;
|
||||
unpack_save (wps, wps->unpack_data + points_index * wps->unpack_size);
|
||||
|
@ -1032,7 +1059,7 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
right = (sum - diff) >> 1;
|
||||
}
|
||||
else
|
||||
sum = left + (right = (left = next_word) - diff);
|
||||
sum = next_word + (right = (left = next_word) - diff);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1049,7 +1076,7 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
right = (sum - diff) >> 1;
|
||||
}
|
||||
else
|
||||
sum = (left = diff + (right = next_word)) + right;
|
||||
sum = (left = diff + (right = next_word)) + next_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1067,9 +1094,9 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
right = (sum - read_word) >> 1;
|
||||
}
|
||||
else if (left_level <= right_level)
|
||||
sum = left + (right = (left = next_word) - read_word);
|
||||
sum = next_word + (right = (left = next_word) - read_word);
|
||||
else
|
||||
sum = right + (left = read_word + (right = next_word));
|
||||
sum = next_word + (left = read_word + (right = next_word));
|
||||
|
||||
diff = left - right;
|
||||
}
|
||||
|
@ -1194,10 +1221,14 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
left = (sum + read_word) >> 1;
|
||||
right = (sum - read_word) >> 1;
|
||||
}
|
||||
else if (left_level <= right_level)
|
||||
sum = left + (right = (left = get_word3 (wps, 1)) - read_word);
|
||||
else
|
||||
sum = right + (left = read_word + (right = get_word3 (wps, 1)));
|
||||
else if (left_level <= right_level) {
|
||||
right = (left = get_word3 (wps, 1)) - read_word;
|
||||
sum = left + right;
|
||||
}
|
||||
else {
|
||||
left = read_word + (right = get_word3 (wps, 1));
|
||||
sum = right + left;
|
||||
}
|
||||
|
||||
sum_level = sum_level - (sum_level >> 8) + labs (sum >> 1);
|
||||
left_level = left_level - (left_level >> 8) + labs (left);
|
||||
|
@ -1262,10 +1293,20 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
|
||||
crc = crc * 3 + (sample [0] [0] += sample [0] [1] += read_word);
|
||||
|
||||
if (sample [0] [0] < min_value)
|
||||
if (sample [0] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (sample [0] [0] > max_value)
|
||||
}
|
||||
else if (sample [0] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = sample [0] [0] << shift;
|
||||
}
|
||||
|
@ -1302,10 +1343,20 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
else {
|
||||
crc = crc * 3 + read_word;
|
||||
|
||||
if (read_word < min_value)
|
||||
if (read_word < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (read_word < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (read_word > max_value)
|
||||
}
|
||||
else if (read_word > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (read_word > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = read_word << shift;
|
||||
}
|
||||
|
@ -1329,10 +1380,20 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
sample [0] [1] = new_sample - sample [0] [0];
|
||||
crc = crc * 3 + (sample [0] [0] = new_sample);
|
||||
|
||||
if (sample [0] [0] < min_value)
|
||||
if (sample [0] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (sample [0] [0] > max_value)
|
||||
}
|
||||
else if (sample [0] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = sample [0] [0] << shift;
|
||||
}
|
||||
|
@ -1349,19 +1410,39 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
|
||||
crc = crc * 3 + (sample [0] [0] += sample [0] [1] += read_word);
|
||||
|
||||
if (sample [0] [0] < min_value)
|
||||
if (sample [0] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (sample [0] [0] > max_value)
|
||||
}
|
||||
else if (sample [0] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = sample [0] [0] << shift;
|
||||
|
||||
crc = crc * 3 + (sample [1] [0] += sample [1] [1] += get_word3 (wps, 1));
|
||||
|
||||
if (sample [1] [0] < min_value)
|
||||
if (sample [1] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [1] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (sample [1] [0] > max_value)
|
||||
}
|
||||
else if (sample [1] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [1] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = sample [1] [0] << shift;
|
||||
}
|
||||
|
@ -1421,17 +1502,37 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
*bptr++ = right << shift;
|
||||
}
|
||||
else {
|
||||
if (left < min_value)
|
||||
if (left < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (left < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (left > max_value)
|
||||
}
|
||||
else if (left > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (left > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = left << shift;
|
||||
|
||||
if (right < min_value)
|
||||
if (right < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (right < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (right > max_value)
|
||||
}
|
||||
else if (right > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (right > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = right << shift;
|
||||
}
|
||||
|
@ -1468,17 +1569,37 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
sample [1] [1] = new_sample - sample [1] [0];
|
||||
crc = crc * 3 + (sample [1] [0] = new_sample);
|
||||
|
||||
if (sample [0] [0] < min_value)
|
||||
if (sample [0] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (sample [0] [0] > max_value)
|
||||
}
|
||||
else if (sample [0] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = sample [0] [0] << shift;
|
||||
|
||||
if (sample [1] [0] < min_value)
|
||||
if (sample [1] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [1] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = min_shifted;
|
||||
else if (sample [1] [0] > max_value)
|
||||
}
|
||||
else if (sample [1] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [1] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
*bptr++ = max_shifted;
|
||||
}
|
||||
else
|
||||
*bptr++ = sample [1] [0] << shift;
|
||||
}
|
||||
|
@ -1494,11 +1615,21 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
sample [0] [0] += sample [0] [1] += read_word;
|
||||
|
||||
if (wps->wphdr.bits) {
|
||||
if (sample [0] [0] < min_value)
|
||||
if (sample [0] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
sample [0] [0] = min_value;
|
||||
else if (sample [0] [0] > max_value)
|
||||
}
|
||||
else if (sample [0] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
sample [0] [0] = max_value;
|
||||
}
|
||||
}
|
||||
|
||||
*bptr++ = sample [0] [0] << shift;
|
||||
}
|
||||
|
@ -1516,20 +1647,57 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
sample [1] [0] += sample [1] [1] += ((sum - diff) >> 1);
|
||||
|
||||
if (wps->wphdr.bits) {
|
||||
if (sample [0] [0] < min_value)
|
||||
if (sample [0] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
sample [0] [0] = min_value;
|
||||
else if (sample [0] [0] > max_value)
|
||||
}
|
||||
else if (sample [0] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [0] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
sample [0] [0] = max_value;
|
||||
}
|
||||
|
||||
if (sample [1] [0] < min_value)
|
||||
if (sample [1] [0] < min_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [1] [0] < -mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
sample [1] [0] = min_value;
|
||||
else if (sample [1] [0] > max_value)
|
||||
}
|
||||
else if (sample [1] [0] > max_value) {
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (sample [1] [0] > mute_limit)
|
||||
mute_block = 1;
|
||||
#endif
|
||||
sample [1] [0] = max_value;
|
||||
}
|
||||
}
|
||||
|
||||
*bptr++ = sample [0] [0] << shift;
|
||||
*bptr++ = sample [1] [0] << shift;
|
||||
}
|
||||
else
|
||||
i = 0; /* can't get here, but suppresses warning */
|
||||
|
||||
#ifdef ATTEMPT_ERROR_MUTING
|
||||
if (!wps->wphdr.bits || (flags & WVC_FLAG)) {
|
||||
int32_t *eptr = buffer + sample_count * ((flags & MONO_FLAG) ? 1 : 2);
|
||||
|
||||
for (bptr = buffer; bptr < eptr; bptr += 3)
|
||||
if (*bptr > mute_limit || *bptr < -mute_limit) {
|
||||
mute_block = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mute_block)
|
||||
memset (buffer, 0, sizeof (*buffer) * sample_count * ((flags & MONO_FLAG) ? 1 : 2));
|
||||
#endif
|
||||
|
||||
if (i && (wps->sample_index += i) == wpc->total_samples) {
|
||||
|
||||
|
@ -1537,7 +1705,7 @@ int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_c
|
|||
wpc->crc_errors++;
|
||||
|
||||
if (wpc->open_flags & OPEN_WRAPPER) {
|
||||
uchar *temp = malloc (1024);
|
||||
unsigned char *temp = malloc (1024);
|
||||
uint32_t bcount;
|
||||
|
||||
if (bs_unused_bytes (&wps->wvbits)) {
|
||||
|
@ -1622,7 +1790,7 @@ static void init_words3 (WavpackStream3 *wps)
|
|||
static int32_t FASTCALL get_word1 (WavpackStream3 *wps, int chan)
|
||||
{
|
||||
uint32_t tmp1, tmp2, avalue;
|
||||
uint ones_count;
|
||||
unsigned int ones_count;
|
||||
int k;
|
||||
|
||||
if ((wps->wphdr.flags & EXTREME_DECORR) && !(wps->wphdr.flags & OVER_20)) {
|
||||
|
@ -1664,6 +1832,9 @@ static int32_t FASTCALL get_word1 (WavpackStream3 *wps, int chan)
|
|||
k = (wps->w1.ave_level [0] [chan] + (wps->w1.ave_level [0] [chan] >> 3) + 0x40) >> 7;
|
||||
k = count_bits (k);
|
||||
|
||||
if (k & ~31)
|
||||
return WORD_EOF;
|
||||
|
||||
if (ones_count == 0) {
|
||||
getbits (&avalue, k, &wps->wvbits);
|
||||
avalue &= bitmask [k];
|
||||
|
@ -1673,6 +1844,9 @@ static int32_t FASTCALL get_word1 (WavpackStream3 *wps, int chan)
|
|||
k = (wps->w1.ave_level [1] [chan] + (wps->w1.ave_level [1] [chan] >> 4) + 0x20) >> 6;
|
||||
k = count_bits (k);
|
||||
|
||||
if (k & ~31)
|
||||
return WORD_EOF;
|
||||
|
||||
if (ones_count == 1) {
|
||||
getbits (&avalue, k, &wps->wvbits);
|
||||
avalue &= bitmask [k];
|
||||
|
@ -1689,6 +1863,10 @@ static int32_t FASTCALL get_word1 (WavpackStream3 *wps, int chan)
|
|||
else {
|
||||
k = (wps->w1.ave_level [2] [chan] + 0x10) >> 5;
|
||||
k = count_bits (k);
|
||||
|
||||
if (k & ~31)
|
||||
return WORD_EOF;
|
||||
|
||||
getbits (&avalue, k, &wps->wvbits);
|
||||
avalue = (avalue & bitmask [k]) + (bitset [k] * (ones_count - 2));
|
||||
}
|
||||
|
@ -1714,7 +1892,7 @@ static int32_t FASTCALL get_word1 (WavpackStream3 *wps, int chan)
|
|||
static int32_t FASTCALL get_old_word1 (WavpackStream3 *wps, int chan)
|
||||
{
|
||||
uint32_t avalue;
|
||||
uint bc;
|
||||
unsigned int bc;
|
||||
int k;
|
||||
|
||||
if (!wps->w1.index [chan]) {
|
||||
|
@ -1743,7 +1921,7 @@ static int32_t FASTCALL get_old_word1 (WavpackStream3 *wps, int chan)
|
|||
|
||||
for (bc = 0; bc < 32 && getbit (&wps->wvbits); ++bc);
|
||||
|
||||
if (bc == 32)
|
||||
if (bc == 32 || (k & ~31))
|
||||
return WORD_EOF;
|
||||
|
||||
avalue = (avalue & bitmask [k]) + bitset [k] * bc;
|
||||
|
@ -2014,3 +2192,4 @@ static int FASTCALL _log2 (uint32_t avalue)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -12,9 +12,9 @@
|
|||
// decoding old (versions 1, 2 & 3) WavPack files.
|
||||
|
||||
typedef struct {
|
||||
ushort FormatTag, NumChannels;
|
||||
unsigned short FormatTag, NumChannels;
|
||||
uint32_t SampleRate, BytesPerSecond;
|
||||
ushort BlockAlign, BitsPerSample;
|
||||
unsigned short BlockAlign, BitsPerSample;
|
||||
} WaveHeader3;
|
||||
|
||||
#define WaveHeader3Format "SSLLSS"
|
||||
|
@ -61,7 +61,7 @@ typedef struct {
|
|||
|
||||
typedef struct bs3 {
|
||||
void (*wrap)(struct bs3 *bs);
|
||||
uchar *buf, *end, *ptr;
|
||||
unsigned char *buf, *end, *ptr;
|
||||
uint32_t bufsiz, fpos, sr;
|
||||
WavpackStreamReader *reader;
|
||||
int error, bc;
|
||||
|
@ -77,13 +77,13 @@ typedef struct {
|
|||
uint32_t sample_index;
|
||||
int num_terms;
|
||||
|
||||
#ifdef SEEKING
|
||||
#ifndef NO_SEEKING
|
||||
struct index_point {
|
||||
char saved;
|
||||
uint32_t sample_index;
|
||||
} index_points [256];
|
||||
|
||||
uchar *unpack_data;
|
||||
unsigned char *unpack_data;
|
||||
uint32_t unpack_size;
|
||||
#endif
|
||||
|
||||
|
@ -98,7 +98,7 @@ typedef struct {
|
|||
struct decorr_pass decorr_passes [MAX_NTERMS3];
|
||||
|
||||
struct {
|
||||
uint index [2], k_value [2], ave_k [2];
|
||||
unsigned int index [2], k_value [2], ave_k [2];
|
||||
uint32_t zeros_acc, ave_level [K_DEPTH] [2];
|
||||
} w1;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -16,17 +16,25 @@
|
|||
#include <io.h>
|
||||
#include <conio.h>
|
||||
#include <shlobj.h>
|
||||
#elif defined(__GNUC__)
|
||||
#elif defined(__GNUC__) || defined(__sun)
|
||||
#include <glob.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define fileno _fileno
|
||||
#define stat64 __stat64
|
||||
#define fstat64 _fstat64
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
@ -156,7 +164,7 @@ char *filespec_ext (char *filespec)
|
|||
// returned. //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__GNUC__) && !defined(WIN32)
|
||||
#if (defined(__GNUC__) || defined(__sun)) && !defined(WIN32)
|
||||
|
||||
char *filespec_path (char *filespec)
|
||||
{
|
||||
|
@ -196,7 +204,7 @@ char *filespec_path (char *filespec)
|
|||
char *cp = filespec + strlen (filespec);
|
||||
LANGID langid = GetSystemDefaultLangID ();
|
||||
struct _finddata_t finddata;
|
||||
int32_t file;
|
||||
intptr_t file;
|
||||
|
||||
if (cp == filespec || filespec_wild (filespec))
|
||||
return NULL;
|
||||
|
@ -212,7 +220,7 @@ char *filespec_path (char *filespec)
|
|||
if (*cp == '.' && cp == filespec)
|
||||
return strcat (filespec, "\\");
|
||||
|
||||
if ((file = _findfirst (filespec, &finddata)) != -1L &&
|
||||
if ((file = _findfirst (filespec, &finddata)) != (intptr_t) -1 &&
|
||||
(finddata.attrib & _A_SUBDIR)) {
|
||||
_findclose (file);
|
||||
return strcat (filespec, "\\");
|
||||
|
@ -289,13 +297,13 @@ char *filespec_name (char *filespec)
|
|||
|
||||
static int is_second_byte (char *filespec, char *pos)
|
||||
{
|
||||
uchar *cp = pos;
|
||||
unsigned char *cp = pos;
|
||||
|
||||
while (cp > filespec && ((cp [-1] >= 0x81 && cp [-1] <= 0x9f) ||
|
||||
(cp [-1] >= 0xe0 && cp [-1] <= 0xfc)))
|
||||
cp--;
|
||||
|
||||
return ((int) pos - (int) cp) & 1;
|
||||
return (int)((unsigned char *)pos - cp) & 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -317,7 +325,7 @@ char yna (void)
|
|||
|
||||
while (1) {
|
||||
#if defined(WIN32)
|
||||
key = getch ();
|
||||
key = _getch ();
|
||||
#else
|
||||
key = fgetc(stdin);
|
||||
#endif
|
||||
|
@ -334,15 +342,21 @@ char yna (void)
|
|||
fprintf (stderr, "%c", 7);
|
||||
}
|
||||
else if (key == 'Y' || key == 'y') {
|
||||
#ifdef WIN32
|
||||
fprintf (stderr, "%c\b", key);
|
||||
#endif
|
||||
choice = 'y';
|
||||
}
|
||||
else if (key == 'N' || key == 'n') {
|
||||
#ifdef WIN32
|
||||
fprintf (stderr, "%c\b", key);
|
||||
#endif
|
||||
choice = 'n';
|
||||
}
|
||||
else if (key == 'A' || key == 'a') {
|
||||
#ifdef WIN32
|
||||
fprintf (stderr, "%c\b", key);
|
||||
#endif
|
||||
choice = 'a';
|
||||
}
|
||||
else
|
||||
|
@ -361,7 +375,7 @@ char yna (void)
|
|||
// with printf strings and args. //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int debug_logging_mode = FALSE;
|
||||
extern int debug_logging_mode;
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
@ -610,7 +624,7 @@ int DoReadFile (FILE *hFile, void *lpBuffer, uint32_t nNumberOfBytesToRead, uint
|
|||
*lpNumberOfBytesRead = 0;
|
||||
|
||||
while (nNumberOfBytesToRead) {
|
||||
bcount = fread ((uchar *) lpBuffer + *lpNumberOfBytesRead, 1, nNumberOfBytesToRead, hFile);
|
||||
bcount = (uint32_t) fread ((unsigned char *) lpBuffer + *lpNumberOfBytesRead, 1, nNumberOfBytesToRead, hFile);
|
||||
|
||||
if (bcount) {
|
||||
*lpNumberOfBytesRead += bcount;
|
||||
|
@ -630,7 +644,7 @@ int DoWriteFile (FILE *hFile, void *lpBuffer, uint32_t nNumberOfBytesToWrite, ui
|
|||
*lpNumberOfBytesWritten = 0;
|
||||
|
||||
while (nNumberOfBytesToWrite) {
|
||||
bcount = fwrite ((uchar *) lpBuffer + *lpNumberOfBytesWritten, 1, nNumberOfBytesToWrite, hFile);
|
||||
bcount = (uint32_t) fwrite ((unsigned char *) lpBuffer + *lpNumberOfBytesWritten, 1, nNumberOfBytesToWrite, hFile);
|
||||
|
||||
if (bcount) {
|
||||
*lpNumberOfBytesWritten += bcount;
|
||||
|
@ -643,16 +657,32 @@ int DoWriteFile (FILE *hFile, void *lpBuffer, uint32_t nNumberOfBytesToWrite, ui
|
|||
return !ferror (hFile);
|
||||
}
|
||||
|
||||
uint32_t DoGetFileSize (FILE *hFile)
|
||||
#ifdef WIN32
|
||||
|
||||
int64_t DoGetFileSize (FILE *hFile)
|
||||
{
|
||||
struct stat64 statbuf;
|
||||
|
||||
if (!hFile || fstat64 (fileno (hFile), &statbuf) || !(statbuf.st_mode & S_IFREG))
|
||||
return 0;
|
||||
|
||||
return statbuf.st_size;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int64_t DoGetFileSize (FILE *hFile)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (!hFile || fstat (fileno (hFile), &statbuf) || !(statbuf.st_mode & S_IFREG))
|
||||
return 0;
|
||||
|
||||
return statbuf.st_size;
|
||||
return (int64_t) statbuf.st_size;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
uint32_t DoGetFilePosition (FILE *hFile)
|
||||
{
|
||||
return ftell (hFile);
|
||||
|
@ -686,7 +716,7 @@ int DoTruncateFile (FILE *hFile)
|
|||
if (hFile) {
|
||||
fflush (hFile);
|
||||
#if defined(WIN32)
|
||||
return !chsize (fileno (hFile), 0);
|
||||
return !_chsize (_fileno (hFile), 0);
|
||||
#else
|
||||
return !ftruncate(fileno (hFile), 0);
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -11,17 +11,11 @@
|
|||
#ifndef WAVPACK_H
|
||||
#define WAVPACK_H
|
||||
|
||||
#if defined(WIN32)
|
||||
#define FASTCALL __fastcall
|
||||
#else
|
||||
#define FASTCALL
|
||||
#define SetConsoleTitle(x)
|
||||
#endif
|
||||
// This header file contains all the definitions required to use the
|
||||
// functions in "wputils.c" to read and write WavPack files and streams.
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
// This header file contains all the definitions required by WavPack.
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#include <stdlib.h>
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
@ -37,70 +31,10 @@ typedef float float32_t;
|
|||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
#if !defined(__GNUC__) || defined(WIN32)
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#ifdef MAX_PATH
|
||||
#define PATH_MAX MAX_PATH
|
||||
#elif defined (MAXPATHLEN)
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#else
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// This structure is used to access the individual fields of 32-bit ieee
|
||||
// floating point numbers. This will not be compatible with compilers that
|
||||
// allocate bit fields from the most significant bits, although I'm not sure
|
||||
// how common that is.
|
||||
|
||||
typedef struct {
|
||||
unsigned mantissa : 23;
|
||||
unsigned exponent : 8;
|
||||
unsigned sign : 1;
|
||||
} f32;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#if defined(WIN32)
|
||||
#undef VERSION_OS
|
||||
#define VERSION_OS "Win32"
|
||||
#endif
|
||||
#define VERSION_STR "4.32"
|
||||
#define DATE_STR "2006-04-05"
|
||||
|
||||
// ID3v1 and APEv2 TAG formats (may occur at the end of WavPack files)
|
||||
|
||||
typedef struct {
|
||||
uchar tag_id [3], title [30], artist [30], album [30];
|
||||
uchar year [4], comment [30], genre;
|
||||
} ID3_Tag;
|
||||
|
||||
typedef struct {
|
||||
char ID [8];
|
||||
int32_t version, length, item_count, flags;
|
||||
char res [8];
|
||||
} APE_Tag_Hdr;
|
||||
|
||||
#define APE_Tag_Hdr_Format "8LLLL"
|
||||
|
||||
typedef struct {
|
||||
int32_t tag_file_pos;
|
||||
ID3_Tag id3_tag;
|
||||
APE_Tag_Hdr ape_tag_hdr;
|
||||
char *ape_tag_data;
|
||||
} M_Tag;
|
||||
|
||||
// RIFF / wav header formats (these occur at the beginning of both wav files
|
||||
// and pre-4.0 WavPack files that are not in the "raw" mode)
|
||||
// and pre-4.0 WavPack files that are not in the "raw" mode). Generally, an
|
||||
// application using the library to read or write WavPack files will not be
|
||||
// concerned with any of these.
|
||||
|
||||
typedef struct {
|
||||
char ckID [4];
|
||||
|
@ -116,35 +50,35 @@ typedef struct {
|
|||
#define ChunkHeaderFormat "4L"
|
||||
|
||||
typedef struct {
|
||||
ushort FormatTag, NumChannels;
|
||||
unsigned short FormatTag, NumChannels;
|
||||
uint32_t SampleRate, BytesPerSecond;
|
||||
ushort BlockAlign, BitsPerSample;
|
||||
ushort cbSize, ValidBitsPerSample;
|
||||
unsigned short BlockAlign, BitsPerSample;
|
||||
unsigned short cbSize, ValidBitsPerSample;
|
||||
int32_t ChannelMask;
|
||||
ushort SubFormat;
|
||||
unsigned short SubFormat;
|
||||
char GUID [14];
|
||||
} WaveHeader;
|
||||
|
||||
#define WaveHeaderFormat "SSLLSSSSLS"
|
||||
|
||||
////////////////////////////// WavPack Header /////////////////////////////////
|
||||
|
||||
// Note that this is the ONLY structure that is written to (or read from)
|
||||
// WavPack 4.0 files, and is the preamble to every block in both the .wv
|
||||
// and .wvc files.
|
||||
// This is the ONLY structure that occurs in WavPack files (as of version
|
||||
// 4.0), and is the preamble to every block in both the .wv and .wvc
|
||||
// files (in little-endian format). Normally, this structure has no use
|
||||
// to an application using the library to read or write WavPack files,
|
||||
// but if an application needs to manually parse WavPack files then this
|
||||
// would be used (with appropriate endian correction).
|
||||
|
||||
typedef struct {
|
||||
char ckID [4];
|
||||
uint32_t ckSize;
|
||||
short version;
|
||||
uchar track_no, index_no;
|
||||
unsigned char track_no, index_no;
|
||||
uint32_t total_samples, block_index, block_samples, flags, crc;
|
||||
} WavpackHeader;
|
||||
|
||||
#define WavpackHeaderFormat "4LS2LLLLL"
|
||||
|
||||
// or-values for "flags"
|
||||
|
||||
// or-values for WavpackHeader.flags
|
||||
#define BYTES_STORED 3 // 1-4 bytes/sample
|
||||
#define MONO_FLAG 4 // not stereo
|
||||
#define HYBRID_FLAG 8 // hybrid mode
|
||||
|
@ -179,19 +113,10 @@ typedef struct {
|
|||
#define MONO_DATA (MONO_FLAG | FALSE_STEREO)
|
||||
|
||||
#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode
|
||||
#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode
|
||||
#define CUR_STREAM_VERS 0x404 // stream version we are writing now
|
||||
#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode or encode
|
||||
#define CUR_STREAM_VERS 0x407 // stream version we are writing now
|
||||
|
||||
|
||||
//////////////////////////// WavPack Metadata /////////////////////////////////
|
||||
|
||||
// This is an internal representation of metadata.
|
||||
|
||||
typedef struct {
|
||||
int32_t byte_length;
|
||||
void *data;
|
||||
uchar id;
|
||||
} WavpackMetadata;
|
||||
// These are the mask bit definitions for the metadata chunk id byte (see format.txt)
|
||||
|
||||
#define ID_UNIQUE 0x3f
|
||||
#define ID_OPTIONAL_DATA 0x20
|
||||
|
@ -215,15 +140,15 @@ typedef struct {
|
|||
|
||||
#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1)
|
||||
#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2)
|
||||
#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3)
|
||||
#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4)
|
||||
#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3) // never used (APEv2)
|
||||
#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4) // never used (APEv2)
|
||||
#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
|
||||
#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
|
||||
#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
|
||||
|
||||
///////////////////////// WavPack Configuration ///////////////////////////////
|
||||
|
||||
// This internal structure is used during encode to provide configuration to
|
||||
// This external structure is used during encode to provide configuration to
|
||||
// the encoding engine and during decoding to provide fle information back to
|
||||
// the higher level functions. Not all fields are used in both modes.
|
||||
|
||||
|
@ -232,124 +157,33 @@ typedef struct {
|
|||
int bits_per_sample, bytes_per_sample;
|
||||
int qmode, flags, xmode, num_channels, float_norm_exp;
|
||||
int32_t block_samples, extra_flags, sample_rate, channel_mask;
|
||||
uchar md5_checksum [16], md5_read;
|
||||
unsigned char md5_checksum [16], md5_read;
|
||||
int num_tag_strings;
|
||||
char **tag_strings;
|
||||
} WavpackConfig;
|
||||
|
||||
#define CONFIG_BYTES_STORED 3 // 1-4 bytes/sample
|
||||
#define CONFIG_MONO_FLAG 4 // not stereo
|
||||
#define CONFIG_HYBRID_FLAG 8 // hybrid mode
|
||||
#define CONFIG_JOINT_STEREO 0x10 // joint stereo
|
||||
#define CONFIG_CROSS_DECORR 0x20 // no-delay cross decorrelation
|
||||
#define CONFIG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
|
||||
#define CONFIG_FLOAT_DATA 0x80 // ieee 32-bit floating point data
|
||||
|
||||
#define CONFIG_ADOBE_MODE 0x100 // "adobe" mode for 32-bit floats
|
||||
#define CONFIG_FAST_FLAG 0x200 // fast mode
|
||||
#define CONFIG_VERY_FAST_FLAG 0x400 // double fast
|
||||
#define CONFIG_HIGH_FLAG 0x800 // high quality mode
|
||||
#define CONFIG_VERY_HIGH_FLAG 0x1000 // double high (not used yet)
|
||||
#define CONFIG_VERY_HIGH_FLAG 0x1000 // very high
|
||||
#define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample
|
||||
#define CONFIG_AUTO_SHAPING 0x4000 // automatic noise shaping
|
||||
#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified
|
||||
#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified
|
||||
#define CONFIG_COPY_TIME 0x20000 // copy file-time from source
|
||||
#define CONFIG_DYNAMIC_SHAPING 0x20000 // dynamic noise shaping
|
||||
#define CONFIG_CREATE_EXE 0x40000 // create executable
|
||||
#define CONFIG_CREATE_WVC 0x80000 // create correction file
|
||||
#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression
|
||||
#define CONFIG_QUALITY_MODE 0x200000 // psychoacoustic quality mode
|
||||
#define CONFIG_RAW_FLAG 0x400000 // raw mode (not implemented yet)
|
||||
#define CONFIG_CALC_NOISE 0x800000 // calc noise in hybrid mode
|
||||
#define CONFIG_LOSSY_MODE 0x1000000 // obsolete (for information)
|
||||
#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode
|
||||
#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints
|
||||
#define CONFIG_MD5_CHECKSUM 0x8000000 // compute & store MD5 signature
|
||||
#define CONFIG_QUIET_MODE 0x10000000 // don't report progress %
|
||||
#define CONFIG_IGNORE_LENGTH 0x20000000 // ignore length in wav header
|
||||
#define CONFIG_NEW_RIFF_HEADER 0x40000000 // generate new RIFF wav header
|
||||
#define CONFIG_MD5_CHECKSUM 0x8000000 // store MD5 signature
|
||||
#define CONFIG_MERGE_BLOCKS 0x10000000 // merge blocks of equal redundancy (for lossyWAV)
|
||||
#define CONFIG_PAIR_UNDEF_CHANS 0x20000000 // encode undefined channels in stereo pairs
|
||||
#define CONFIG_OPTIMIZE_MONO 0x80000000 // optimize for mono streams posing as stereo
|
||||
|
||||
#define EXTRA_SCAN_ONLY 1
|
||||
#define EXTRA_STEREO_MODES 2
|
||||
#define EXTRA_TRY_DELTAS 8
|
||||
#define EXTRA_ADJUST_DELTAS 16
|
||||
#define EXTRA_SORT_FIRST 32
|
||||
#define EXTRA_BRANCHES 0x1c0
|
||||
#define EXTRA_SKIP_8TO16 512
|
||||
#define EXTRA_TERMS 0x3c00
|
||||
#define EXTRA_DUMP_TERMS 16384
|
||||
#define EXTRA_SORT_LAST 32768
|
||||
|
||||
//////////////////////////////// WavPack Stream ///////////////////////////////
|
||||
|
||||
// This internal structure contains everything required to handle a WavPack
|
||||
// "stream", which is defined as a stereo or mono stream of audio samples. For
|
||||
// multichannel audio several of these would be required. Each stream contains
|
||||
// pointers to hold a complete allocated block of WavPack data, although it's
|
||||
// possible to decode WavPack blocks without buffering an entire block.
|
||||
|
||||
typedef struct bs {
|
||||
uchar *buf, *end, *ptr;
|
||||
void (*wrap)(struct bs *bs);
|
||||
int error, bc;
|
||||
uint32_t sr;
|
||||
} Bitstream;
|
||||
|
||||
#define MAX_STREAMS 8
|
||||
#define MAX_NTERMS 16
|
||||
#define MAX_TERM 8
|
||||
|
||||
struct decorr_pass {
|
||||
int term, delta, weight_A, weight_B;
|
||||
int32_t samples_A [MAX_TERM], samples_B [MAX_TERM];
|
||||
int32_t aweight_A, aweight_B;
|
||||
int32_t sum_A, sum_B;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
WavpackHeader wphdr;
|
||||
|
||||
uchar *blockbuff, *blockend;
|
||||
uchar *block2buff, *block2end;
|
||||
int32_t *sample_buffer;
|
||||
|
||||
int bits, num_terms, mute_error, false_stereo, shift;
|
||||
uint32_t sample_index, crc, crc_x, crc_wvx;
|
||||
Bitstream wvbits, wvcbits, wvxbits;
|
||||
float delta_decay;
|
||||
|
||||
uchar int32_sent_bits, int32_zeros, int32_ones, int32_dups;
|
||||
uchar float_flags, float_shift, float_max_exp, float_norm_exp;
|
||||
|
||||
struct {
|
||||
int32_t shaping_acc [2], shaping_delta [2], error [2];
|
||||
double noise_sum, noise_ave, noise_max;
|
||||
} dc;
|
||||
|
||||
struct decorr_pass decorr_passes [MAX_NTERMS];
|
||||
|
||||
struct {
|
||||
uint32_t bitrate_delta [2], bitrate_acc [2];
|
||||
uint32_t median [3] [2], slow_level [2], error_limit [2];
|
||||
uint32_t pend_data, holding_one, zeros_acc;
|
||||
int holding_zero, pend_count;
|
||||
} w;
|
||||
} WavpackStream;
|
||||
|
||||
// flags for float_flags:
|
||||
|
||||
#define FLOAT_SHIFT_ONES 1 // bits left-shifted into float = '1'
|
||||
#define FLOAT_SHIFT_SAME 2 // bits left-shifted into float are the same
|
||||
#define FLOAT_SHIFT_SENT 4 // bits shifted into float are sent literally
|
||||
#define FLOAT_ZEROS_SENT 8 // "zeros" are not all real zeros
|
||||
#define FLOAT_NEG_ZEROS 0x10 // contains negative zeros
|
||||
#define FLOAT_EXCEPTIONS 0x20 // contains exceptions (inf, nan, etc.)
|
||||
|
||||
/////////////////////////////// WavPack Context ///////////////////////////////
|
||||
|
||||
// This internal structure holds everything required to encode or decode WavPack
|
||||
// files. It is recommended that direct access to this structure be minimized
|
||||
// and the provided utilities used instead.
|
||||
////////////// Callbacks used for reading & writing WavPack streams //////////
|
||||
|
||||
typedef struct {
|
||||
int32_t (*read_bytes)(void *id, void *data, int32_t bcount);
|
||||
|
@ -366,253 +200,16 @@ typedef struct {
|
|||
|
||||
typedef int (*WavpackBlockOutput)(void *id, void *data, int32_t bcount);
|
||||
|
||||
typedef struct {
|
||||
WavpackConfig config;
|
||||
//////////////////////////// function prototypes /////////////////////////////
|
||||
|
||||
WavpackMetadata *metadata;
|
||||
uint32_t metabytes;
|
||||
int metacount;
|
||||
// Note: See wputils.c sourcecode for descriptions for using these functions.
|
||||
|
||||
uchar *wrapper_data;
|
||||
uint32_t wrapper_bytes;
|
||||
typedef void WavpackContext;
|
||||
|
||||
WavpackBlockOutput blockout;
|
||||
void *wv_out, *wvc_out;
|
||||
|
||||
WavpackStreamReader *reader;
|
||||
void *wv_in, *wvc_in;
|
||||
|
||||
uint32_t filelen, file2len, filepos, file2pos, total_samples, crc_errors, first_flags;
|
||||
int wvc_flag, open_flags, norm_offset, reduced_channels, lossy_blocks, close_files;
|
||||
int block_samples, max_samples, acc_samples, riff_header_added, riff_header_created;
|
||||
M_Tag m_tag;
|
||||
|
||||
int current_stream, num_streams, stream_version;
|
||||
WavpackStream *streams [8];
|
||||
void *stream3;
|
||||
|
||||
char error_message [80];
|
||||
} WavpackContext;
|
||||
|
||||
//////////////////////// function prototypes and macros //////////////////////
|
||||
|
||||
#define CLEAR(destin) memset (&destin, 0, sizeof (destin));
|
||||
|
||||
// these macros implement the weight application and update operations
|
||||
// that are at the heart of the decorrelation loops
|
||||
|
||||
#define apply_weight_i(weight, sample) ((weight * sample + 512) >> 10)
|
||||
|
||||
#define apply_weight_f(weight, sample) (((((sample & 0xffff) * weight) >> 9) + \
|
||||
(((sample & ~0xffff) >> 9) * weight) + 1) >> 1)
|
||||
|
||||
#if 1 // PERFCOND
|
||||
#define apply_weight(weight, sample) (sample != (short) sample ? \
|
||||
apply_weight_f (weight, sample) : apply_weight_i (weight, sample))
|
||||
#else
|
||||
#define apply_weight(weight, sample) ((int32_t)((weight * (int64_t) sample + 512) >> 10))
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if 1 // PERFCOND
|
||||
#define update_weight(weight, delta, source, result) \
|
||||
if (source && result) weight -= ((((source ^ result) >> 30) & 2) - 1) * delta;
|
||||
#else
|
||||
#define update_weight(weight, delta, source, result) \
|
||||
if (source && result) (source ^ result) < 0 ? (weight -= delta) : (weight += delta);
|
||||
#endif
|
||||
|
||||
#define update_weight_d1(weight, delta, source, result) \
|
||||
if (source && result) weight -= (((source ^ result) >> 30) & 2) - 1;
|
||||
|
||||
#define update_weight_d2(weight, delta, source, result) \
|
||||
if (source && result) weight -= (((source ^ result) >> 29) & 4) - 2;
|
||||
|
||||
#define update_weight_clip(weight, delta, source, result) \
|
||||
if (source && result && ((source ^ result) < 0 ? (weight -= delta) < -1024 : (weight += delta) > 1024)) \
|
||||
weight = weight < 0 ? -1024 : 1024;
|
||||
|
||||
#define update_weight_clip_d1(weight, delta, source, result) \
|
||||
if (source && result && abs (weight -= (((source ^ result) >> 30) & 2) - 1) > 1024) \
|
||||
weight = weight < 0 ? -1024 : 1024;
|
||||
|
||||
#define update_weight_clip_d2(weight, delta, source, result) \
|
||||
if (source && result && abs (weight -= (((source ^ result) >> 29) & 4) - 2) > 1024) \
|
||||
weight = weight < 0 ? -1024 : 1024;
|
||||
|
||||
// bits.c
|
||||
|
||||
void bs_open_read (Bitstream *bs, uchar *buffer_start, uchar *buffer_end);
|
||||
void bs_open_write (Bitstream *bs, uchar *buffer_start, uchar *buffer_end);
|
||||
uint32_t bs_close_read (Bitstream *bs);
|
||||
uint32_t bs_close_write (Bitstream *bs);
|
||||
|
||||
int DoReadFile (FILE *hFile, void *lpBuffer, uint32_t nNumberOfBytesToRead, uint32_t *lpNumberOfBytesRead);
|
||||
int DoWriteFile (FILE *hFile, void *lpBuffer, uint32_t nNumberOfBytesToWrite, uint32_t *lpNumberOfBytesWritten);
|
||||
uint32_t DoGetFileSize (FILE *hFile), DoGetFilePosition (FILE *hFile);
|
||||
int DoSetFilePositionRelative (FILE *hFile, int32_t pos, int mode);
|
||||
int DoSetFilePositionAbsolute (FILE *hFile, uint32_t pos);
|
||||
int DoUngetc (int c, FILE *hFile), DoDeleteFile (char *filename);
|
||||
int DoCloseHandle (FILE *hFile), DoTruncateFile (FILE *hFile);
|
||||
|
||||
#define bs_is_open(bs) ((bs)->ptr != NULL)
|
||||
|
||||
#define getbit(bs) ( \
|
||||
(((bs)->bc) ? \
|
||||
((bs)->bc--, (bs)->sr & 1) : \
|
||||
(((++((bs)->ptr) != (bs)->end) ? (void) 0 : (bs)->wrap (bs)), (bs)->bc = 7, ((bs)->sr = *((bs)->ptr)) & 1) \
|
||||
) ? \
|
||||
((bs)->sr >>= 1, 1) : \
|
||||
((bs)->sr >>= 1, 0) \
|
||||
)
|
||||
|
||||
#define getbits(value, nbits, bs) { \
|
||||
while ((nbits) > (bs)->bc) { \
|
||||
if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \
|
||||
(bs)->sr |= (int32_t)*((bs)->ptr) << (bs)->bc; \
|
||||
(bs)->bc += 8; \
|
||||
} \
|
||||
*(value) = (bs)->sr; \
|
||||
if ((bs)->bc > 32) { \
|
||||
(bs)->bc -= (nbits); \
|
||||
(bs)->sr = *((bs)->ptr) >> (8 - (bs)->bc); \
|
||||
} \
|
||||
else { \
|
||||
(bs)->bc -= (nbits); \
|
||||
(bs)->sr >>= (nbits); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define putbit(bit, bs) { if (bit) (bs)->sr |= (1 << (bs)->bc); \
|
||||
if (++((bs)->bc) == 8) { \
|
||||
*((bs)->ptr) = (bs)->sr; \
|
||||
(bs)->sr = (bs)->bc = 0; \
|
||||
if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \
|
||||
}}
|
||||
|
||||
#define putbit_0(bs) { \
|
||||
if (++((bs)->bc) == 8) { \
|
||||
*((bs)->ptr) = (bs)->sr; \
|
||||
(bs)->sr = (bs)->bc = 0; \
|
||||
if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \
|
||||
}}
|
||||
|
||||
#define putbit_1(bs) { (bs)->sr |= (1 << (bs)->bc); \
|
||||
if (++((bs)->bc) == 8) { \
|
||||
*((bs)->ptr) = (bs)->sr; \
|
||||
(bs)->sr = (bs)->bc = 0; \
|
||||
if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \
|
||||
}}
|
||||
|
||||
#define putbits(value, nbits, bs) { \
|
||||
(bs)->sr |= (int32_t)(value) << (bs)->bc; \
|
||||
if (((bs)->bc += (nbits)) >= 8) \
|
||||
do { \
|
||||
*((bs)->ptr) = (bs)->sr; \
|
||||
(bs)->sr >>= 8; \
|
||||
if (((bs)->bc -= 8) > 24) (bs)->sr |= ((value) >> ((nbits) - (bs)->bc)); \
|
||||
if (++((bs)->ptr) == (bs)->end) (bs)->wrap (bs); \
|
||||
} while ((bs)->bc >= 8); \
|
||||
}
|
||||
|
||||
void little_endian_to_native (void *data, char *format);
|
||||
void native_to_little_endian (void *data, char *format);
|
||||
|
||||
// pack.c
|
||||
|
||||
void pack_init (WavpackContext *wpc);
|
||||
int pack_block (WavpackContext *wpc, int32_t *buffer);
|
||||
double pack_noise (WavpackContext *wpc, double *peak);
|
||||
|
||||
// unpack.c
|
||||
|
||||
int unpack_init (WavpackContext *wpc);
|
||||
int init_wv_bitstream (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int init_wvc_bitstream (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int init_wvx_bitstream (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_decorr_terms (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_shaping_info (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd);
|
||||
int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd);
|
||||
int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd);
|
||||
int read_wrapper_data (WavpackContext *wpc, WavpackMetadata *wpmd);
|
||||
int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count);
|
||||
int check_crc_error (WavpackContext *wpc);
|
||||
|
||||
// unpack3.c
|
||||
|
||||
WavpackContext *open_file3 (WavpackContext *wpc, char *error);
|
||||
int32_t unpack_samples3 (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count);
|
||||
int seek_sample3 (WavpackContext *wpc, uint32_t desired_index);
|
||||
uint32_t get_sample_index3 (WavpackContext *wpc);
|
||||
void free_stream3 (WavpackContext *wpc);
|
||||
int get_version3 (WavpackContext *wpc);
|
||||
|
||||
// utils.c
|
||||
|
||||
int copy_timestamp (const char *src_filename, const char *dst_filename);
|
||||
char *filespec_ext (char *filespec), *filespec_path (char *filespec);
|
||||
char *filespec_name (char *filespec), *filespec_wild (char *filespec);
|
||||
void error_line (char *error, ...);
|
||||
void setup_break (void), finish_line (void);
|
||||
int check_break (void);
|
||||
char yna (void);
|
||||
|
||||
#define FN_FIT(fn) ((strlen (fn) > 30) ? filespec_name (fn) : fn)
|
||||
|
||||
// metadata.c stuff
|
||||
|
||||
int read_metadata_buff (WavpackMetadata *wpmd, uchar *blockbuff, uchar **buffptr);
|
||||
int write_metadata_block (WavpackContext *wpc);
|
||||
int copy_metadata (WavpackMetadata *wpmd, uchar *buffer_start, uchar *buffer_end);
|
||||
int add_to_metadata (WavpackContext *wpc, void *data, uint32_t bcount, uchar id);
|
||||
int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd);
|
||||
void free_metadata (WavpackMetadata *wpmd);
|
||||
|
||||
// words.c stuff
|
||||
|
||||
void init_words (WavpackStream *wps);
|
||||
void word_set_bitrate (WavpackStream *wps);
|
||||
void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
void write_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan);
|
||||
void FASTCALL send_word_lossless (WavpackStream *wps, int32_t value, int chan);
|
||||
int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction);
|
||||
int32_t FASTCALL get_word_lossless (WavpackStream *wps, int chan);
|
||||
void flush_word (WavpackStream *wps);
|
||||
int32_t nosend_word (WavpackStream *wps, int32_t value, int chan);
|
||||
void scan_word (WavpackStream *wps, int32_t *samples, uint32_t num_samples, int dir);
|
||||
|
||||
int log2s (int32_t value);
|
||||
int32_t exp2s (int log);
|
||||
uint32_t log2buffer (int32_t *samples, uint32_t num_samples, int limit);
|
||||
|
||||
signed char store_weight (int weight);
|
||||
int restore_weight (signed char weight);
|
||||
|
||||
#define WORD_EOF (1L << 31)
|
||||
|
||||
// float.c
|
||||
|
||||
void write_float_info (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
int scan_float_data (WavpackStream *wps, f32 *values, int32_t num_values);
|
||||
void send_float_data (WavpackStream *wps, f32 *values, int32_t num_values);
|
||||
int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd);
|
||||
void float_values (WavpackStream *wps, int32_t *values, int32_t num_values);
|
||||
void float_normalize (int32_t *values, int32_t num_values, int delta_exp);
|
||||
|
||||
// analyze?.c
|
||||
|
||||
void analyze_stereo (WavpackContext *wpc, int32_t *samples);
|
||||
void analyze_mono (WavpackContext *wpc, int32_t *samples);
|
||||
|
||||
// wputils.c
|
||||
|
||||
WavpackContext *WavpackOpenFileInputEx (WavpackStreamReader *reader, void *wv_id, void *wvc_id, char *error, int flags, int norm_offset);
|
||||
WavpackContext *WavpackOpenFileInput (const char *infilename, char *error, int flags, int norm_offset);
|
||||
|
||||
|
@ -634,10 +231,15 @@ int WavpackGetMode (WavpackContext *wpc);
|
|||
#define MODE_VALID_TAG 0x10
|
||||
#define MODE_HIGH 0x20
|
||||
#define MODE_FAST 0x40
|
||||
#define MODE_EXTRA 0x80
|
||||
#define MODE_EXTRA 0x80 // extra mode used, see MODE_XMODE for possible level
|
||||
#define MODE_APETAG 0x100
|
||||
#define MODE_SFX 0x200
|
||||
#define MODE_VERY_HIGH 0x400
|
||||
#define MODE_MD5 0x800
|
||||
#define MODE_XMODE 0x7000 // mask for extra level (1-6, 0=unknown)
|
||||
#define MODE_DNS 0x8000
|
||||
|
||||
char *WavpackGetErrorMessage (WavpackContext *wpc);
|
||||
int WavpackGetVersion (WavpackContext *wpc);
|
||||
uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples);
|
||||
uint32_t WavpackGetNumSamples (WavpackContext *wpc);
|
||||
|
@ -650,11 +252,14 @@ uint32_t WavpackGetSampleRate (WavpackContext *wpc);
|
|||
int WavpackGetBitsPerSample (WavpackContext *wpc);
|
||||
int WavpackGetBytesPerSample (WavpackContext *wpc);
|
||||
int WavpackGetNumChannels (WavpackContext *wpc);
|
||||
int WavpackGetChannelMask (WavpackContext *wpc);
|
||||
int WavpackGetReducedChannels (WavpackContext *wpc);
|
||||
int WavpackGetMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
int WavpackGetFloatNormExp (WavpackContext *wpc);
|
||||
int WavpackGetMD5Sum (WavpackContext *wpc, unsigned char data [16]);
|
||||
uint32_t WavpackGetWrapperBytes (WavpackContext *wpc);
|
||||
uchar *WavpackGetWrapperData (WavpackContext *wpc);
|
||||
unsigned char *WavpackGetWrapperData (WavpackContext *wpc);
|
||||
void WavpackFreeWrapper (WavpackContext *wpc);
|
||||
void WavpackSeekTrailingWrapper (WavpackContext *wpc);
|
||||
double WavpackGetProgress (WavpackContext *wpc);
|
||||
uint32_t WavpackGetFileSize (WavpackContext *wpc);
|
||||
double WavpackGetRatio (WavpackContext *wpc);
|
||||
|
@ -663,18 +268,35 @@ double WavpackGetInstantBitrate (WavpackContext *wpc);
|
|||
int WavpackGetNumTagItems (WavpackContext *wpc);
|
||||
int WavpackGetTagItem (WavpackContext *wpc, const char *item, char *value, int size);
|
||||
int WavpackGetTagItemIndexed (WavpackContext *wpc, int index, char *item, int size);
|
||||
int WavpackGetNumBinaryTagItems (WavpackContext *wpc);
|
||||
int WavpackGetBinaryTagItem (WavpackContext *wpc, const char *item, char *value, int size);
|
||||
int WavpackGetBinaryTagItemIndexed (WavpackContext *wpc, int index, char *item, int size);
|
||||
int WavpackAppendTagItem (WavpackContext *wpc, const char *item, const char *value, int vsize);
|
||||
int WavpackAppendBinaryTagItem (WavpackContext *wpc, const char *item, const char *value, int vsize);
|
||||
int WavpackDeleteTagItem (WavpackContext *wpc, const char *item);
|
||||
int WavpackWriteTag (WavpackContext *wpc);
|
||||
|
||||
WavpackContext *WavpackOpenFileOutput (WavpackBlockOutput blockout, void *wv_id, void *wvc_id);
|
||||
int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples);
|
||||
int WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount);
|
||||
int WavpackStoreMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
int WavpackStoreMD5Sum (WavpackContext *wpc, unsigned char data [16]);
|
||||
int WavpackPackInit (WavpackContext *wpc);
|
||||
int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count);
|
||||
int WavpackFlushSamples (WavpackContext *wpc);
|
||||
void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block);
|
||||
void *WavpackGetWrapperLocation (void *first_block, uint32_t *size);
|
||||
double WavpackGetEncodedNoise (WavpackContext *wpc, double *peak);
|
||||
|
||||
void WavpackFloatNormalize (int32_t *values, int32_t num_values, int delta_exp);
|
||||
|
||||
void WavpackLittleEndianToNative (void *data, char *format);
|
||||
void WavpackNativeToLittleEndian (void *data, char *format);
|
||||
|
||||
uint32_t WavpackGetLibraryVersion (void);
|
||||
const char *WavpackGetLibraryVersionString (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// Copyright (c) 1998 - 2006 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
// very simple encoding that is over 99% efficient with this data and
|
||||
// results in about 1.22 bits per sample.
|
||||
|
||||
#include "wavpack.h"
|
||||
#include "wavpack_local.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -38,8 +38,6 @@ void free_db (void *ptr);
|
|||
int32_t dump_alloc (void);
|
||||
#endif
|
||||
|
||||
// #define DEBUG_WORDS // debug module by sending all 32 bits literally
|
||||
|
||||
//////////////////////////////// local macros /////////////////////////////////
|
||||
|
||||
#define LIMIT_ONES 16 // maximum consecutive 1s sent for "div" data
|
||||
|
@ -55,19 +53,19 @@ int32_t dump_alloc (void);
|
|||
#define DIV2 32 // 20/343 of samples
|
||||
|
||||
// this macro retrieves the specified median breakpoint (without frac; min = 1)
|
||||
#define GET_MED(med) (((wps->w.median [med] [chan]) >> 4) + 1)
|
||||
#define GET_MED(med) (((c->median [med]) >> 4) + 1)
|
||||
|
||||
// These macros update the specified median breakpoints. Note that the median
|
||||
// is incremented when the sample is higher than the median, else decremented.
|
||||
// They are designed so that the median will never drop below 1 and the value
|
||||
// is essentially stationary if there are 2 increments for every 5 decrements.
|
||||
|
||||
#define INC_MED0() (wps->w.median [0] [chan] += ((wps->w.median [0] [chan] + DIV0) / DIV0) * 5)
|
||||
#define DEC_MED0() (wps->w.median [0] [chan] -= ((wps->w.median [0] [chan] + (DIV0-2)) / DIV0) * 2)
|
||||
#define INC_MED1() (wps->w.median [1] [chan] += ((wps->w.median [1] [chan] + DIV1) / DIV1) * 5)
|
||||
#define DEC_MED1() (wps->w.median [1] [chan] -= ((wps->w.median [1] [chan] + (DIV1-2)) / DIV1) * 2)
|
||||
#define INC_MED2() (wps->w.median [2] [chan] += ((wps->w.median [2] [chan] + DIV2) / DIV2) * 5)
|
||||
#define DEC_MED2() (wps->w.median [2] [chan] -= ((wps->w.median [2] [chan] + (DIV2-2)) / DIV2) * 2)
|
||||
#define INC_MED0() (c->median [0] += ((c->median [0] + DIV0) / DIV0) * 5)
|
||||
#define DEC_MED0() (c->median [0] -= ((c->median [0] + (DIV0-2)) / DIV0) * 2)
|
||||
#define INC_MED1() (c->median [1] += ((c->median [1] + DIV1) / DIV1) * 5)
|
||||
#define DEC_MED1() (c->median [1] -= ((c->median [1] + (DIV1-2)) / DIV1) * 2)
|
||||
#define INC_MED2() (c->median [2] += ((c->median [2] + DIV2) / DIV2) * 5)
|
||||
#define DEC_MED2() (c->median [2] -= ((c->median [2] + (DIV2-2)) / DIV2) * 2)
|
||||
|
||||
#define count_bits(av) ( \
|
||||
(av) < (1 << 8) ? nbits_table [av] : \
|
||||
|
@ -120,7 +118,7 @@ const char nbits_table [] = {
|
|||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 // 240 - 255
|
||||
};
|
||||
|
||||
static const uchar log2_table [] = {
|
||||
static const unsigned char log2_table [] = {
|
||||
0x00, 0x01, 0x03, 0x04, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0d, 0x0e, 0x10, 0x11, 0x12, 0x14, 0x15,
|
||||
0x16, 0x18, 0x19, 0x1a, 0x1c, 0x1d, 0x1e, 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a,
|
||||
0x2c, 0x2d, 0x2e, 0x2f, 0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3b, 0x3c, 0x3d, 0x3e,
|
||||
|
@ -139,7 +137,7 @@ static const uchar log2_table [] = {
|
|||
0xf4, 0xf5, 0xf6, 0xf7, 0xf7, 0xf8, 0xf9, 0xf9, 0xfa, 0xfb, 0xfc, 0xfc, 0xfd, 0xfe, 0xff, 0xff
|
||||
};
|
||||
|
||||
static const uchar exp2_table [] = {
|
||||
static const unsigned char exp2_table [] = {
|
||||
0x00, 0x01, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b,
|
||||
0x0b, 0x0c, 0x0d, 0x0e, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x15, 0x16, 0x16,
|
||||
0x17, 0x18, 0x19, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1f, 0x20, 0x20, 0x21, 0x22, 0x23,
|
||||
|
@ -177,7 +175,7 @@ static int FASTCALL mylog2 (uint32_t avalue);
|
|||
// are no parameters to select; in hybrid mode the bitrate mode and value need
|
||||
// be initialized.
|
||||
|
||||
#ifdef PACK
|
||||
#ifndef NO_PACK
|
||||
|
||||
void init_words (WavpackStream *wps)
|
||||
{
|
||||
|
@ -198,6 +196,9 @@ void word_set_bitrate (WavpackStream *wps)
|
|||
int bitrate_0, bitrate_1;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
if (wps->wphdr.flags & FALSE_STEREO)
|
||||
bitrate_0 = (wps->bits * 2 - 512) < 568 ? 0 : (wps->bits * 2 - 512) - 568;
|
||||
else
|
||||
bitrate_0 = wps->bits < 568 ? 0 : wps->bits - 568;
|
||||
|
||||
if (!(wps->wphdr.flags & MONO_DATA)) {
|
||||
|
@ -219,6 +220,8 @@ void word_set_bitrate (WavpackStream *wps)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
bitrate_1 = 0;
|
||||
}
|
||||
else
|
||||
bitrate_0 = bitrate_1 = 0;
|
||||
|
@ -235,29 +238,29 @@ void word_set_bitrate (WavpackStream *wps)
|
|||
|
||||
void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
uchar *byteptr;
|
||||
unsigned char *byteptr;
|
||||
int temp;
|
||||
|
||||
byteptr = wpmd->data = malloc (12);
|
||||
wpmd->id = ID_ENTROPY_VARS;
|
||||
|
||||
*byteptr++ = temp = mylog2 (wps->w.median [0] [0]);
|
||||
*byteptr++ = temp = mylog2 (wps->w.c [0].median [0]);
|
||||
*byteptr++ = temp >> 8;
|
||||
*byteptr++ = temp = mylog2 (wps->w.median [1] [0]);
|
||||
*byteptr++ = temp = mylog2 (wps->w.c [0].median [1]);
|
||||
*byteptr++ = temp >> 8;
|
||||
*byteptr++ = temp = mylog2 (wps->w.median [2] [0]);
|
||||
*byteptr++ = temp = mylog2 (wps->w.c [0].median [2]);
|
||||
*byteptr++ = temp >> 8;
|
||||
|
||||
if (!(wps->wphdr.flags & MONO_DATA)) {
|
||||
*byteptr++ = temp = mylog2 (wps->w.median [0] [1]);
|
||||
*byteptr++ = temp = mylog2 (wps->w.c [1].median [0]);
|
||||
*byteptr++ = temp >> 8;
|
||||
*byteptr++ = temp = mylog2 (wps->w.median [1] [1]);
|
||||
*byteptr++ = temp = mylog2 (wps->w.c [1].median [1]);
|
||||
*byteptr++ = temp >> 8;
|
||||
*byteptr++ = temp = mylog2 (wps->w.median [2] [1]);
|
||||
*byteptr++ = temp = mylog2 (wps->w.c [1].median [2]);
|
||||
*byteptr++ = temp >> 8;
|
||||
}
|
||||
|
||||
wpmd->byte_length = byteptr - (uchar *) wpmd->data;
|
||||
wpmd->byte_length = (int32_t)(byteptr - (unsigned char *) wpmd->data);
|
||||
read_entropy_vars (wps, wpmd);
|
||||
}
|
||||
|
||||
|
@ -270,7 +273,7 @@ void write_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
|
||||
void write_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
uchar *byteptr;
|
||||
unsigned char *byteptr;
|
||||
int temp;
|
||||
|
||||
word_set_bitrate (wps);
|
||||
|
@ -278,11 +281,11 @@ void write_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
wpmd->id = ID_HYBRID_PROFILE;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
*byteptr++ = temp = log2s (wps->w.slow_level [0]);
|
||||
*byteptr++ = temp = log2s (wps->w.c [0].slow_level);
|
||||
*byteptr++ = temp >> 8;
|
||||
|
||||
if (!(wps->wphdr.flags & MONO_DATA)) {
|
||||
*byteptr++ = temp = log2s (wps->w.slow_level [1]);
|
||||
*byteptr++ = temp = log2s (wps->w.c [1].slow_level);
|
||||
*byteptr++ = temp >> 8;
|
||||
}
|
||||
}
|
||||
|
@ -305,7 +308,7 @@ void write_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
}
|
||||
}
|
||||
|
||||
wpmd->byte_length = byteptr - (uchar *) wpmd->data;
|
||||
wpmd->byte_length = (int32_t)(byteptr - (unsigned char *) wpmd->data);
|
||||
read_hybrid_profile (wps, wpmd);
|
||||
}
|
||||
|
||||
|
@ -317,19 +320,19 @@ void write_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
|
||||
int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
uchar *byteptr = wpmd->data;
|
||||
unsigned char *byteptr = wpmd->data;
|
||||
|
||||
if (wpmd->byte_length != ((wps->wphdr.flags & MONO_DATA) ? 6 : 12))
|
||||
return FALSE;
|
||||
|
||||
wps->w.median [0] [0] = exp2s (byteptr [0] + (byteptr [1] << 8));
|
||||
wps->w.median [1] [0] = exp2s (byteptr [2] + (byteptr [3] << 8));
|
||||
wps->w.median [2] [0] = exp2s (byteptr [4] + (byteptr [5] << 8));
|
||||
wps->w.c [0].median [0] = exp2s (byteptr [0] + (byteptr [1] << 8));
|
||||
wps->w.c [0].median [1] = exp2s (byteptr [2] + (byteptr [3] << 8));
|
||||
wps->w.c [0].median [2] = exp2s (byteptr [4] + (byteptr [5] << 8));
|
||||
|
||||
if (!(wps->wphdr.flags & MONO_DATA)) {
|
||||
wps->w.median [0] [1] = exp2s (byteptr [6] + (byteptr [7] << 8));
|
||||
wps->w.median [1] [1] = exp2s (byteptr [8] + (byteptr [9] << 8));
|
||||
wps->w.median [2] [1] = exp2s (byteptr [10] + (byteptr [11] << 8));
|
||||
wps->w.c [1].median [0] = exp2s (byteptr [6] + (byteptr [7] << 8));
|
||||
wps->w.c [1].median [1] = exp2s (byteptr [8] + (byteptr [9] << 8));
|
||||
wps->w.c [1].median [2] = exp2s (byteptr [10] + (byteptr [11] << 8));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -342,19 +345,25 @@ int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
|
||||
int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
|
||||
{
|
||||
uchar *byteptr = wpmd->data;
|
||||
uchar *endptr = byteptr + wpmd->byte_length;
|
||||
unsigned char *byteptr = wpmd->data;
|
||||
unsigned char *endptr = byteptr + wpmd->byte_length;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
wps->w.slow_level [0] = exp2s (byteptr [0] + (byteptr [1] << 8));
|
||||
if (byteptr + (wps->wphdr.flags & MONO_DATA ? 2 : 4) > endptr)
|
||||
return FALSE;
|
||||
|
||||
wps->w.c [0].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8));
|
||||
byteptr += 2;
|
||||
|
||||
if (!(wps->wphdr.flags & MONO_DATA)) {
|
||||
wps->w.slow_level [1] = exp2s (byteptr [0] + (byteptr [1] << 8));
|
||||
wps->w.c [1].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8));
|
||||
byteptr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (byteptr + (wps->wphdr.flags & MONO_DATA ? 2 : 4) > endptr)
|
||||
return FALSE;
|
||||
|
||||
wps->w.bitrate_acc [0] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16;
|
||||
byteptr += 2;
|
||||
|
||||
|
@ -364,6 +373,9 @@ int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
|
|||
}
|
||||
|
||||
if (byteptr < endptr) {
|
||||
if (byteptr + (wps->wphdr.flags & MONO_DATA ? 2 : 4) > endptr)
|
||||
return FALSE;
|
||||
|
||||
wps->w.bitrate_delta [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
|
||||
byteptr += 2;
|
||||
|
||||
|
@ -393,22 +405,22 @@ static void update_error_limit (WavpackStream *wps)
|
|||
|
||||
if (wps->wphdr.flags & MONO_DATA) {
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
int slow_log_0 = (wps->w.slow_level [0] + SLO) >> SLS;
|
||||
int slow_log_0 = (wps->w.c [0].slow_level + SLO) >> SLS;
|
||||
|
||||
if (slow_log_0 - bitrate_0 > -0x100)
|
||||
wps->w.error_limit [0] = exp2s (slow_log_0 - bitrate_0 + 0x100);
|
||||
wps->w.c [0].error_limit = exp2s (slow_log_0 - bitrate_0 + 0x100);
|
||||
else
|
||||
wps->w.error_limit [0] = 0;
|
||||
wps->w.c [0].error_limit = 0;
|
||||
}
|
||||
else
|
||||
wps->w.error_limit [0] = exp2s (bitrate_0);
|
||||
wps->w.c [0].error_limit = exp2s (bitrate_0);
|
||||
}
|
||||
else {
|
||||
int bitrate_1 = (wps->w.bitrate_acc [1] += wps->w.bitrate_delta [1]) >> 16;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
int slow_log_0 = (wps->w.slow_level [0] + SLO) >> SLS;
|
||||
int slow_log_1 = (wps->w.slow_level [1] + SLO) >> SLS;
|
||||
int slow_log_0 = (wps->w.c [0].slow_level + SLO) >> SLS;
|
||||
int slow_log_1 = (wps->w.c [1].slow_level + SLO) >> SLS;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BALANCE) {
|
||||
int balance = (slow_log_1 - slow_log_0 + bitrate_1 + 1) >> 1;
|
||||
|
@ -428,23 +440,23 @@ static void update_error_limit (WavpackStream *wps)
|
|||
}
|
||||
|
||||
if (slow_log_0 - bitrate_0 > -0x100)
|
||||
wps->w.error_limit [0] = exp2s (slow_log_0 - bitrate_0 + 0x100);
|
||||
wps->w.c [0].error_limit = exp2s (slow_log_0 - bitrate_0 + 0x100);
|
||||
else
|
||||
wps->w.error_limit [0] = 0;
|
||||
wps->w.c [0].error_limit = 0;
|
||||
|
||||
if (slow_log_1 - bitrate_1 > -0x100)
|
||||
wps->w.error_limit [1] = exp2s (slow_log_1 - bitrate_1 + 0x100);
|
||||
wps->w.c [1].error_limit = exp2s (slow_log_1 - bitrate_1 + 0x100);
|
||||
else
|
||||
wps->w.error_limit [1] = 0;
|
||||
wps->w.c [1].error_limit = 0;
|
||||
}
|
||||
else {
|
||||
wps->w.error_limit [0] = exp2s (bitrate_0);
|
||||
wps->w.error_limit [1] = exp2s (bitrate_1);
|
||||
wps->w.c [0].error_limit = exp2s (bitrate_0);
|
||||
wps->w.c [1].error_limit = exp2s (bitrate_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PACK
|
||||
#ifndef NO_PACK
|
||||
|
||||
// This function writes the specified word to the open bitstream "wvbits" and,
|
||||
// if the bitstream "wvcbits" is open, writes any correction data there. This
|
||||
|
@ -456,25 +468,16 @@ static void update_error_limit (WavpackStream *wps)
|
|||
|
||||
int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
||||
{
|
||||
struct entropy_data *c = wps->w.c + chan;
|
||||
uint32_t ones_count, low, mid, high;
|
||||
int sign = (value < 0) ? 1 : 0;
|
||||
|
||||
#ifdef DEBUG_WORDS
|
||||
mid = value;
|
||||
ones_count = 32;
|
||||
while (ones_count--) {
|
||||
putbit (value & 1, &wps->wvbits);
|
||||
value >>= 1;
|
||||
}
|
||||
return mid;
|
||||
#endif
|
||||
|
||||
if (!(wps->w.median [0] [0] & ~1) && !wps->w.holding_zero && !(wps->w.median [0] [1] & ~1)) {
|
||||
if (wps->w.c [0].median [0] < 2 && !wps->w.holding_zero && wps->w.c [1].median [0] < 2) {
|
||||
if (wps->w.zeros_acc) {
|
||||
if (value)
|
||||
flush_word (wps);
|
||||
else {
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
wps->w.zeros_acc++;
|
||||
return 0;
|
||||
}
|
||||
|
@ -483,8 +486,9 @@ int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
|||
putbit_0 (&wps->wvbits);
|
||||
}
|
||||
else {
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
CLEAR (wps->w.median);
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
CLEAR (wps->w.c [0].median);
|
||||
CLEAR (wps->w.c [1].median);
|
||||
wps->w.zeros_acc = 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -496,7 +500,7 @@ int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
|||
if ((wps->wphdr.flags & HYBRID_FLAG) && !chan)
|
||||
update_error_limit (wps);
|
||||
|
||||
if (value < GET_MED (0)) {
|
||||
if (value < (int32_t) GET_MED (0)) {
|
||||
ones_count = low = 0;
|
||||
high = GET_MED (0) - 1;
|
||||
DEC_MED0 ();
|
||||
|
@ -548,7 +552,7 @@ int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
|||
|
||||
wps->w.holding_one = ones_count * 2;
|
||||
|
||||
if (!wps->w.error_limit [chan]) {
|
||||
if (!c->error_limit) {
|
||||
if (high != low) {
|
||||
uint32_t maxcode = high - low, code = value - low;
|
||||
int bitcount = count_bits (maxcode);
|
||||
|
@ -568,8 +572,8 @@ int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
|||
mid = value;
|
||||
}
|
||||
else
|
||||
while (high - low > wps->w.error_limit [chan])
|
||||
if (value < mid) {
|
||||
while (high - low > c->error_limit)
|
||||
if (value < (int32_t) mid) {
|
||||
mid = ((high = mid - 1) + low + 1) >> 1;
|
||||
wps->w.pend_count++;
|
||||
}
|
||||
|
@ -583,7 +587,7 @@ int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
|||
if (!wps->w.holding_zero)
|
||||
flush_word (wps);
|
||||
|
||||
if (bs_is_open (&wps->wvcbits) && wps->w.error_limit [chan]) {
|
||||
if (bs_is_open (&wps->wvcbits) && c->error_limit) {
|
||||
uint32_t code = value - low, maxcode = high - low;
|
||||
int bitcount = count_bits (maxcode);
|
||||
uint32_t extras = bitset [bitcount] - maxcode - 1;
|
||||
|
@ -600,54 +604,58 @@ int32_t FASTCALL send_word (WavpackStream *wps, int32_t value, int chan)
|
|||
}
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
wps->w.slow_level [chan] += mylog2 (mid);
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
c->slow_level += mylog2 (mid);
|
||||
}
|
||||
|
||||
return sign ? ~mid : mid;
|
||||
}
|
||||
|
||||
// This function is an optimized version of send_word() that only handles
|
||||
// lossless (error_limit == 0). It does not return a value because it always
|
||||
// encodes the exact value passed.
|
||||
// lossless (error_limit == 0) and sends an entire buffer of either mono or
|
||||
// stereo data rather than a single sample. Unlike the generalized
|
||||
// send_word(), it does not return values because it always encodes
|
||||
// the exact value passed.
|
||||
|
||||
void FASTCALL send_word_lossless (WavpackStream *wps, int32_t value, int chan)
|
||||
void send_words_lossless (WavpackStream *wps, int32_t *buffer, int32_t nsamples)
|
||||
{
|
||||
int sign = (value < 0) ? 1 : 0;
|
||||
struct entropy_data *c = wps->w.c;
|
||||
int32_t value, csamples;
|
||||
|
||||
if (!(wps->wphdr.flags & MONO_DATA))
|
||||
nsamples *= 2;
|
||||
|
||||
for (csamples = 0; csamples < nsamples; ++csamples) {
|
||||
int sign = ((value = *buffer++) < 0) ? 1 : 0;
|
||||
uint32_t ones_count, low, high;
|
||||
|
||||
#ifdef DEBUG_WORDS
|
||||
ones_count = 32;
|
||||
while (ones_count--) {
|
||||
putbit (value & 1, &wps->wvbits);
|
||||
value >>= 1;
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
if (!(wps->wphdr.flags & MONO_DATA))
|
||||
c = wps->w.c + (csamples & 1);
|
||||
|
||||
if (!(wps->w.median [0] [0] & ~1) && !wps->w.holding_zero && !(wps->w.median [0] [1] & ~1)) {
|
||||
if (wps->w.c [0].median [0] < 2 && !wps->w.holding_zero && wps->w.c [1].median [0] < 2) {
|
||||
if (wps->w.zeros_acc) {
|
||||
if (value)
|
||||
flush_word (wps);
|
||||
else {
|
||||
wps->w.zeros_acc++;
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (value) {
|
||||
putbit_0 (&wps->wvbits);
|
||||
}
|
||||
else {
|
||||
CLEAR (wps->w.median);
|
||||
CLEAR (wps->w.c [0].median);
|
||||
CLEAR (wps->w.c [1].median);
|
||||
wps->w.zeros_acc = 1;
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (sign)
|
||||
value = ~value;
|
||||
|
||||
if (value < GET_MED (0)) {
|
||||
if (value < (int32_t) GET_MED (0)) {
|
||||
ones_count = low = 0;
|
||||
high = GET_MED (0) - 1;
|
||||
DEC_MED0 ();
|
||||
|
@ -717,6 +725,7 @@ void FASTCALL send_word_lossless (WavpackStream *wps, int32_t value, int chan)
|
|||
|
||||
if (!wps->w.holding_zero)
|
||||
flush_word (wps);
|
||||
}
|
||||
}
|
||||
|
||||
// Used by send_word() and send_word_lossless() to actually send most the
|
||||
|
@ -793,6 +802,7 @@ void flush_word (WavpackStream *wps)
|
|||
|
||||
int32_t nosend_word (WavpackStream *wps, int32_t value, int chan)
|
||||
{
|
||||
struct entropy_data *c = wps->w.c + chan;
|
||||
uint32_t ones_count, low, mid, high;
|
||||
int sign = (value < 0) ? 1 : 0;
|
||||
|
||||
|
@ -802,7 +812,7 @@ int32_t nosend_word (WavpackStream *wps, int32_t value, int chan)
|
|||
if ((wps->wphdr.flags & HYBRID_FLAG) && !chan)
|
||||
update_error_limit (wps);
|
||||
|
||||
if (value < GET_MED (0)) {
|
||||
if (value < (int32_t) GET_MED (0)) {
|
||||
low = 0;
|
||||
high = GET_MED (0) - 1;
|
||||
DEC_MED0 ();
|
||||
|
@ -834,17 +844,17 @@ int32_t nosend_word (WavpackStream *wps, int32_t value, int chan)
|
|||
|
||||
mid = (high + low + 1) >> 1;
|
||||
|
||||
if (!wps->w.error_limit [chan])
|
||||
if (!c->error_limit)
|
||||
mid = value;
|
||||
else
|
||||
while (high - low > wps->w.error_limit [chan])
|
||||
if (value < mid)
|
||||
while (high - low > c->error_limit)
|
||||
if (value < (int32_t) mid)
|
||||
mid = ((high = mid - 1) + low + 1) >> 1;
|
||||
else
|
||||
mid = (high + (low = mid) + 1) >> 1;
|
||||
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
wps->w.slow_level [chan] += mylog2 (mid);
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
c->slow_level += mylog2 (mid);
|
||||
|
||||
return sign ? ~mid : mid;
|
||||
}
|
||||
|
@ -860,10 +870,10 @@ int32_t nosend_word (WavpackStream *wps, int32_t value, int chan)
|
|||
void scan_word (WavpackStream *wps, int32_t *samples, uint32_t num_samples, int dir)
|
||||
{
|
||||
uint32_t flags = wps->wphdr.flags, value, low;
|
||||
struct entropy_data *c = wps->w.c;
|
||||
int chan;
|
||||
|
||||
CLEAR (wps->w.slow_level);
|
||||
CLEAR (wps->w.median);
|
||||
init_words (wps);
|
||||
|
||||
if (flags & MONO_DATA) {
|
||||
if (dir < 0) {
|
||||
|
@ -887,8 +897,8 @@ void scan_word (WavpackStream *wps, int32_t *samples, uint32_t num_samples, int
|
|||
value = labs (samples [chan = 0]);
|
||||
|
||||
if (flags & HYBRID_BITRATE) {
|
||||
wps->w.slow_level [0] -= (wps->w.slow_level [0] + SLO) >> SLS;
|
||||
wps->w.slow_level [0] += mylog2 (value);
|
||||
wps->w.c [0].slow_level -= (wps->w.c [0].slow_level + SLO) >> SLS;
|
||||
wps->w.c [0].slow_level += mylog2 (value);
|
||||
}
|
||||
|
||||
if (value < GET_MED (0)) {
|
||||
|
@ -916,10 +926,11 @@ void scan_word (WavpackStream *wps, int32_t *samples, uint32_t num_samples, int
|
|||
|
||||
if (!(flags & MONO_DATA)) {
|
||||
value = labs (samples [chan = 1]);
|
||||
c++;
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
wps->w.slow_level [1] -= (wps->w.slow_level [1] + SLO) >> SLS;
|
||||
wps->w.slow_level [1] += mylog2 (value);
|
||||
wps->w.c [1].slow_level -= (wps->w.c [1].slow_level + SLO) >> SLS;
|
||||
wps->w.c [1].slow_level += mylog2 (value);
|
||||
}
|
||||
|
||||
if (value < GET_MED (0)) {
|
||||
|
@ -944,6 +955,8 @@ void scan_word (WavpackStream *wps, int32_t *samples, uint32_t num_samples, int
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
c--;
|
||||
}
|
||||
|
||||
samples += dir;
|
||||
|
@ -952,7 +965,7 @@ void scan_word (WavpackStream *wps, int32_t *samples, uint32_t num_samples, int
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef UNPACK
|
||||
#ifndef NO_UNPACK
|
||||
|
||||
static uint32_t FASTCALL read_code (Bitstream *bs, uint32_t maxcode);
|
||||
|
||||
|
@ -966,6 +979,7 @@ static uint32_t FASTCALL read_code (Bitstream *bs, uint32_t maxcode);
|
|||
|
||||
int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
||||
{
|
||||
register struct entropy_data *c = wps->w.c + chan;
|
||||
uint32_t ones_count, low, mid, high;
|
||||
int next8, sign;
|
||||
int32_t value;
|
||||
|
@ -973,20 +987,13 @@ int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
|||
if (correction)
|
||||
*correction = 0;
|
||||
|
||||
#ifdef DEBUG_WORDS
|
||||
ones_count = 32;
|
||||
while (ones_count--)
|
||||
value = getbit (&wps->wvbits) ? (value >> 1) | 0x80000000 : (value >> 1) & 0x7fffffff;
|
||||
return value;
|
||||
#endif
|
||||
|
||||
if (!(wps->w.median [0] [0] & ~1) && !wps->w.holding_zero && !wps->w.holding_one && !(wps->w.median [0] [1] & ~1)) {
|
||||
if (!(wps->w.c [0].median [0] & ~1) && !wps->w.holding_zero && !wps->w.holding_one && !(wps->w.c [1].median [0] & ~1)) {
|
||||
uint32_t mask;
|
||||
int cbits;
|
||||
|
||||
if (wps->w.zeros_acc) {
|
||||
if (--wps->w.zeros_acc) {
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1007,8 +1014,9 @@ int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
|||
}
|
||||
|
||||
if (wps->w.zeros_acc) {
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
CLEAR (wps->w.median);
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
CLEAR (wps->w.c [0].median);
|
||||
CLEAR (wps->w.c [1].median);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1022,7 +1030,7 @@ int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
|||
wps->wvbits.wrap (&wps->wvbits);
|
||||
|
||||
next8 = (wps->wvbits.sr |= *(wps->wvbits.ptr) << wps->wvbits.bc) & 0xff;
|
||||
wps->wvbits.bc += 8;
|
||||
wps->wvbits.bc += sizeof (*(wps->wvbits.ptr)) * 8;
|
||||
}
|
||||
else
|
||||
next8 = wps->wvbits.sr & 0xff;
|
||||
|
@ -1107,11 +1115,13 @@ int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
|||
}
|
||||
}
|
||||
|
||||
low &= 0x7fffffff;
|
||||
high &= 0x7fffffff;
|
||||
mid = (high + low + 1) >> 1;
|
||||
|
||||
if (!wps->w.error_limit [chan])
|
||||
if (!c->error_limit)
|
||||
mid = read_code (&wps->wvbits, high - low) + low;
|
||||
else while (high - low > wps->w.error_limit [chan]) {
|
||||
else while (high - low > c->error_limit) {
|
||||
if (getbit (&wps->wvbits))
|
||||
mid = (high + (low = mid) + 1) >> 1;
|
||||
else
|
||||
|
@ -1120,7 +1130,7 @@ int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
|||
|
||||
sign = getbit (&wps->wvbits);
|
||||
|
||||
if (bs_is_open (&wps->wvcbits) && wps->w.error_limit [chan]) {
|
||||
if (bs_is_open (&wps->wvcbits) && c->error_limit) {
|
||||
value = read_code (&wps->wvcbits, high - low) + low;
|
||||
|
||||
if (correction)
|
||||
|
@ -1128,57 +1138,62 @@ int32_t FASTCALL get_word (WavpackStream *wps, int chan, int32_t *correction)
|
|||
}
|
||||
|
||||
if (wps->wphdr.flags & HYBRID_BITRATE) {
|
||||
wps->w.slow_level [chan] -= (wps->w.slow_level [chan] + SLO) >> SLS;
|
||||
wps->w.slow_level [chan] += mylog2 (mid);
|
||||
c->slow_level -= (c->slow_level + SLO) >> SLS;
|
||||
c->slow_level += mylog2 (mid);
|
||||
}
|
||||
|
||||
return sign ? ~mid : mid;
|
||||
}
|
||||
|
||||
// This is an optimized version of get_word() that is used for lossless only
|
||||
// (error_limit == 0). There are two versions of an internal section; they
|
||||
// are identical from a functional standpoint, but one may be faster than the
|
||||
// other under different compilers / processors.
|
||||
// (error_limit == 0). Also, rather than obtaining a single sample, it can be
|
||||
// used to obtain an entire buffer of either mono or stereo samples.
|
||||
|
||||
int32_t FASTCALL get_word_lossless (WavpackStream *wps, int chan)
|
||||
int32_t get_words_lossless (WavpackStream *wps, int32_t *buffer, int32_t nsamples)
|
||||
{
|
||||
struct entropy_data *c = wps->w.c;
|
||||
uint32_t ones_count, low, high;
|
||||
int next8;
|
||||
Bitstream *bs = &wps->wvbits;
|
||||
int32_t csamples;
|
||||
|
||||
#ifdef DEBUG_WORDS
|
||||
ones_count = 32;
|
||||
while (ones_count--)
|
||||
low = getbit (&wps->wvbits) ? (low >> 1) | 0x80000000 : (low >> 1) & 0x7fffffff;
|
||||
return low;
|
||||
#endif
|
||||
if (!(wps->wphdr.flags & MONO_DATA))
|
||||
nsamples *= 2;
|
||||
|
||||
if (!(wps->w.median [0] [0] & ~1) && !wps->w.holding_zero && !wps->w.holding_one && !(wps->w.median [0] [1] & ~1)) {
|
||||
for (csamples = 0; csamples < nsamples; ++csamples) {
|
||||
if (!(wps->wphdr.flags & MONO_DATA))
|
||||
c = wps->w.c + (csamples & 1);
|
||||
|
||||
if (wps->w.c [0].median [0] < 2 && !wps->w.holding_zero && !wps->w.holding_one && wps->w.c [1].median [0] < 2) {
|
||||
uint32_t mask;
|
||||
int cbits;
|
||||
|
||||
if (wps->w.zeros_acc) {
|
||||
if (--wps->w.zeros_acc)
|
||||
return 0;
|
||||
if (--wps->w.zeros_acc) {
|
||||
*buffer++ = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (cbits = 0; cbits < 33 && getbit (&wps->wvbits); ++cbits);
|
||||
for (cbits = 0; cbits < 33 && getbit (bs); ++cbits);
|
||||
|
||||
if (cbits == 33)
|
||||
return WORD_EOF;
|
||||
break;
|
||||
|
||||
if (cbits < 2)
|
||||
wps->w.zeros_acc = cbits;
|
||||
else {
|
||||
for (mask = 1, wps->w.zeros_acc = 0; --cbits; mask <<= 1)
|
||||
if (getbit (&wps->wvbits))
|
||||
if (getbit (bs))
|
||||
wps->w.zeros_acc |= mask;
|
||||
|
||||
wps->w.zeros_acc |= mask;
|
||||
}
|
||||
|
||||
if (wps->w.zeros_acc) {
|
||||
CLEAR (wps->w.median);
|
||||
return 0;
|
||||
CLEAR (wps->w.c [0].median);
|
||||
CLEAR (wps->w.c [1].median);
|
||||
*buffer++ = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1186,39 +1201,41 @@ int32_t FASTCALL get_word_lossless (WavpackStream *wps, int chan)
|
|||
if (wps->w.holding_zero)
|
||||
ones_count = wps->w.holding_zero = 0;
|
||||
else {
|
||||
if (wps->wvbits.bc < 8) {
|
||||
if (++(wps->wvbits.ptr) == wps->wvbits.end)
|
||||
wps->wvbits.wrap (&wps->wvbits);
|
||||
int next8;
|
||||
|
||||
next8 = (wps->wvbits.sr |= *(wps->wvbits.ptr) << wps->wvbits.bc) & 0xff;
|
||||
wps->wvbits.bc += 8;
|
||||
if (bs->bc < 8) {
|
||||
if (++(bs->ptr) == bs->end)
|
||||
bs->wrap (bs);
|
||||
|
||||
next8 = (bs->sr |= *(bs->ptr) << bs->bc) & 0xff;
|
||||
bs->bc += sizeof (*(bs->ptr)) * 8;
|
||||
}
|
||||
else
|
||||
next8 = wps->wvbits.sr & 0xff;
|
||||
next8 = bs->sr & 0xff;
|
||||
|
||||
if (next8 == 0xff) {
|
||||
wps->wvbits.bc -= 8;
|
||||
wps->wvbits.sr >>= 8;
|
||||
bs->bc -= 8;
|
||||
bs->sr >>= 8;
|
||||
|
||||
for (ones_count = 8; ones_count < (LIMIT_ONES + 1) && getbit (&wps->wvbits); ++ones_count);
|
||||
for (ones_count = 8; ones_count < (LIMIT_ONES + 1) && getbit (bs); ++ones_count);
|
||||
|
||||
if (ones_count == (LIMIT_ONES + 1))
|
||||
return WORD_EOF;
|
||||
break;
|
||||
|
||||
if (ones_count == LIMIT_ONES) {
|
||||
uint32_t mask;
|
||||
int cbits;
|
||||
|
||||
for (cbits = 0; cbits < 33 && getbit (&wps->wvbits); ++cbits);
|
||||
for (cbits = 0; cbits < 33 && getbit (bs); ++cbits);
|
||||
|
||||
if (cbits == 33)
|
||||
return WORD_EOF;
|
||||
break;
|
||||
|
||||
if (cbits < 2)
|
||||
ones_count = cbits;
|
||||
else {
|
||||
for (mask = 1, ones_count = 0; --cbits; mask <<= 1)
|
||||
if (getbit (&wps->wvbits))
|
||||
if (getbit (bs))
|
||||
ones_count |= mask;
|
||||
|
||||
ones_count |= mask;
|
||||
|
@ -1228,8 +1245,8 @@ int32_t FASTCALL get_word_lossless (WavpackStream *wps, int chan)
|
|||
}
|
||||
}
|
||||
else {
|
||||
wps->wvbits.bc -= (ones_count = ones_count_table [next8]) + 1;
|
||||
wps->wvbits.sr >>= ones_count + 1;
|
||||
bs->bc -= (ones_count = ones_count_table [next8]) + 1;
|
||||
bs->sr >>= ones_count + 1;
|
||||
}
|
||||
|
||||
if (wps->w.holding_one) {
|
||||
|
@ -1273,8 +1290,11 @@ int32_t FASTCALL get_word_lossless (WavpackStream *wps, int chan)
|
|||
}
|
||||
}
|
||||
|
||||
low += read_code (&wps->wvbits, high - low);
|
||||
return (getbit (&wps->wvbits)) ? ~low : low;
|
||||
low += read_code (bs, high - low);
|
||||
*buffer++ = (getbit (bs)) ? ~low : low;
|
||||
}
|
||||
|
||||
return (wps->wphdr.flags & MONO_DATA) ? csamples : (csamples / 2);
|
||||
}
|
||||
|
||||
// Read a single unsigned value from the specified bitstream with a value
|
||||
|
@ -1285,20 +1305,35 @@ int32_t FASTCALL get_word_lossless (WavpackStream *wps, int chan)
|
|||
|
||||
static uint32_t FASTCALL read_code (Bitstream *bs, uint32_t maxcode)
|
||||
{
|
||||
int bitcount = count_bits (maxcode);
|
||||
uint32_t extras = bitset [bitcount] - maxcode - 1, code;
|
||||
uint32_t extras, code;
|
||||
int bitcount;
|
||||
|
||||
if (!bitcount)
|
||||
return 0;
|
||||
if (maxcode < 2)
|
||||
return maxcode ? getbit (bs) : 0;
|
||||
|
||||
getbits (&code, bitcount - 1, bs);
|
||||
code &= bitmask [bitcount - 1];
|
||||
bitcount = count_bits (maxcode);
|
||||
extras = bitset [bitcount] - maxcode - 1;
|
||||
|
||||
if (code >= extras) {
|
||||
code = (code << 1) - extras;
|
||||
while (bs->bc < bitcount) {
|
||||
if (++(bs->ptr) == bs->end)
|
||||
bs->wrap (bs);
|
||||
|
||||
if (getbit (bs))
|
||||
++code;
|
||||
bs->sr |= *(bs->ptr) << bs->bc;
|
||||
bs->bc += sizeof (*(bs->ptr)) * 8;
|
||||
}
|
||||
|
||||
if ((code = bs->sr & bitmask [bitcount - 1]) >= extras)
|
||||
code = (code << 1) - extras + ((bs->sr >> (bitcount - 1)) & 1);
|
||||
else
|
||||
bitcount--;
|
||||
|
||||
if (bs->bc > 32) {
|
||||
bs->bc -= bitcount;
|
||||
bs->sr = *(bs->ptr) >> (sizeof (*(bs->ptr)) * 8 - bs->bc);
|
||||
}
|
||||
else {
|
||||
bs->sr >>= bitcount;
|
||||
bs->bc -= bitcount;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,172 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
// **** WAVPACK **** //
|
||||
// Hybrid Lossless Wavefile Compressor //
|
||||
// Copyright (c) 1998 - 2005 Conifer Software. //
|
||||
// All Rights Reserved. //
|
||||
// Distributed under the BSD Software License (see license.txt) //
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// wputils.h
|
||||
|
||||
#ifndef WPUTILS_H
|
||||
#define WPUTILS_H
|
||||
|
||||
// This header file contains all the definitions required to use the
|
||||
// functions in "wputils.c" to read and write WavPack files and streams.
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#include <stdlib.h>
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef float float32_t;
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
#if !defined(__GNUC__) || defined(WIN32)
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
#endif
|
||||
|
||||
///////////////////////// WavPack Configuration ///////////////////////////////
|
||||
|
||||
// This external structure is used during encode to provide configuration to
|
||||
// the encoding engine and during decoding to provide fle information back to
|
||||
// the higher level functions. Not all fields are used in both modes.
|
||||
|
||||
typedef struct {
|
||||
float bitrate, shaping_weight;
|
||||
int bits_per_sample, bytes_per_sample;
|
||||
int qmode, flags, xmode, num_channels, float_norm_exp;
|
||||
int32_t block_samples, extra_flags, sample_rate, channel_mask;
|
||||
uchar md5_checksum [16], md5_read;
|
||||
int num_tag_strings;
|
||||
char **tag_strings;
|
||||
} WavpackConfig;
|
||||
|
||||
#define CONFIG_HYBRID_FLAG 8 // hybrid mode
|
||||
#define CONFIG_JOINT_STEREO 0x10 // joint stereo
|
||||
#define CONFIG_HYBRID_SHAPE 0x40 // noise shape (hybrid mode only)
|
||||
#define CONFIG_FAST_FLAG 0x200 // fast mode
|
||||
#define CONFIG_HIGH_FLAG 0x800 // high quality mode
|
||||
#define CONFIG_BITRATE_KBPS 0x2000 // bitrate is kbps, not bits / sample
|
||||
#define CONFIG_SHAPE_OVERRIDE 0x8000 // shaping mode specified
|
||||
#define CONFIG_JOINT_OVERRIDE 0x10000 // joint-stereo mode specified
|
||||
#define CONFIG_CREATE_EXE 0x40000 // create executable
|
||||
#define CONFIG_CREATE_WVC 0x80000 // create correction file
|
||||
#define CONFIG_OPTIMIZE_WVC 0x100000 // maximize bybrid compression
|
||||
#define CONFIG_CALC_NOISE 0x800000 // calc noise in hybrid mode
|
||||
#define CONFIG_EXTRA_MODE 0x2000000 // extra processing mode
|
||||
#define CONFIG_SKIP_WVX 0x4000000 // no wvx stream w/ floats & big ints
|
||||
#define CONFIG_MD5_CHECKSUM 0x8000000 // store MD5 signature
|
||||
|
||||
////////////// Callbacks used for reading & writing WavPack streams //////////
|
||||
|
||||
typedef struct {
|
||||
int32_t (*read_bytes)(void *id, void *data, int32_t bcount);
|
||||
uint32_t (*get_pos)(void *id);
|
||||
int (*set_pos_abs)(void *id, uint32_t pos);
|
||||
int (*set_pos_rel)(void *id, int32_t delta, int mode);
|
||||
int (*push_back_byte)(void *id, int c);
|
||||
uint32_t (*get_length)(void *id);
|
||||
int (*can_seek)(void *id);
|
||||
|
||||
// this callback is for writing edited tags only
|
||||
int32_t (*write_bytes)(void *id, void *data, int32_t bcount);
|
||||
} WavpackStreamReader;
|
||||
|
||||
typedef int (*WavpackBlockOutput)(void *id, void *data, int32_t bcount);
|
||||
|
||||
//////////////////////// function prototypes and macros //////////////////////
|
||||
|
||||
typedef void WavpackContext;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WavpackContext *WavpackOpenFileInputEx (WavpackStreamReader *reader, void *wv_id, void *wvc_id, char *error, int flags, int norm_offset);
|
||||
WavpackContext *WavpackOpenFileInput (const char *infilename, char *error, int flags, int norm_offset);
|
||||
|
||||
#define OPEN_WVC 0x1 // open/read "correction" file
|
||||
#define OPEN_TAGS 0x2 // read ID3v1 / APEv2 tags (seekable file)
|
||||
#define OPEN_WRAPPER 0x4 // make audio wrapper available (i.e. RIFF)
|
||||
#define OPEN_2CH_MAX 0x8 // open multichannel as stereo (no downmix)
|
||||
#define OPEN_NORMALIZE 0x10 // normalize floating point data to +/- 1.0
|
||||
#define OPEN_STREAMING 0x20 // "streaming" mode blindly unpacks blocks
|
||||
// w/o regard to header file position info
|
||||
#define OPEN_EDIT_TAGS 0x40 // allow editing of tags
|
||||
|
||||
int WavpackGetMode (WavpackContext *wpc);
|
||||
|
||||
#define MODE_WVC 0x1
|
||||
#define MODE_LOSSLESS 0x2
|
||||
#define MODE_HYBRID 0x4
|
||||
#define MODE_FLOAT 0x8
|
||||
#define MODE_VALID_TAG 0x10
|
||||
#define MODE_HIGH 0x20
|
||||
#define MODE_FAST 0x40
|
||||
#define MODE_EXTRA 0x80
|
||||
#define MODE_APETAG 0x100
|
||||
#define MODE_SFX 0x200
|
||||
|
||||
int WavpackGetVersion (WavpackContext *wpc);
|
||||
uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t samples);
|
||||
uint32_t WavpackGetNumSamples (WavpackContext *wpc);
|
||||
uint32_t WavpackGetSampleIndex (WavpackContext *wpc);
|
||||
int WavpackGetNumErrors (WavpackContext *wpc);
|
||||
int WavpackLossyBlocks (WavpackContext *wpc);
|
||||
int WavpackSeekSample (WavpackContext *wpc, uint32_t sample);
|
||||
WavpackContext *WavpackCloseFile (WavpackContext *wpc);
|
||||
uint32_t WavpackGetSampleRate (WavpackContext *wpc);
|
||||
int WavpackGetBitsPerSample (WavpackContext *wpc);
|
||||
int WavpackGetBytesPerSample (WavpackContext *wpc);
|
||||
int WavpackGetNumChannels (WavpackContext *wpc);
|
||||
int WavpackGetReducedChannels (WavpackContext *wpc);
|
||||
int WavpackGetFloatNormExp (WavpackContext *wpc);
|
||||
int WavpackGetMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
uint32_t WavpackGetWrapperBytes (WavpackContext *wpc);
|
||||
uchar *WavpackGetWrapperData (WavpackContext *wpc);
|
||||
void WavpackFreeWrapper (WavpackContext *wpc);
|
||||
double WavpackGetProgress (WavpackContext *wpc);
|
||||
uint32_t WavpackGetFileSize (WavpackContext *wpc);
|
||||
double WavpackGetRatio (WavpackContext *wpc);
|
||||
double WavpackGetAverageBitrate (WavpackContext *wpc, int count_wvc);
|
||||
double WavpackGetInstantBitrate (WavpackContext *wpc);
|
||||
int WavpackGetNumTagItems (WavpackContext *wpc);
|
||||
int WavpackGetTagItem (WavpackContext *wpc, const char *item, char *value, int size);
|
||||
int WavpackGetTagItemIndexed (WavpackContext *wpc, int index, char *item, int size);
|
||||
int WavpackAppendTagItem (WavpackContext *wpc, const char *item, const char *value, int vsize);
|
||||
int WavpackDeleteTagItem (WavpackContext *wpc, const char *item);
|
||||
int WavpackWriteTag (WavpackContext *wpc);
|
||||
|
||||
|
||||
WavpackContext *WavpackOpenFileOutput (WavpackBlockOutput blockout, void *wv_id, void *wvc_id);
|
||||
int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples);
|
||||
int WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount);
|
||||
int WavpackStoreMD5Sum (WavpackContext *wpc, uchar data [16]);
|
||||
int WavpackPackInit (WavpackContext *wpc);
|
||||
int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count);
|
||||
int WavpackFlushSamples (WavpackContext *wpc);
|
||||
void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block);
|
||||
void *WavpackGetWrapperLocation (void *first_block, uint32_t *size);
|
||||
|
||||
// this function is not actually in wputils.c, but is generally useful
|
||||
|
||||
void float_normalize (int32_t *values, int32_t num_values, int delta_exp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -7,11 +7,15 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
83DD1DD017FA038A00249519 /* utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 83DD1DCD17FA038A00249519 /* utils.h */; };
|
||||
83DD1DD117FA038A00249519 /* wavpack_local.h in Headers */ = {isa = PBXBuildFile; fileRef = 83DD1DCE17FA038A00249519 /* wavpack_local.h */; };
|
||||
83DD1DD217FA038A00249519 /* wavpack_version.h in Headers */ = {isa = PBXBuildFile; fileRef = 83DD1DCF17FA038A00249519 /* wavpack_version.h */; };
|
||||
83DD1DD417FA03F900249519 /* tags.c in Sources */ = {isa = PBXBuildFile; fileRef = 83DD1DD317FA03F900249519 /* tags.c */; };
|
||||
83DD1DD517FA04E100249519 /* wavpack.c in Sources */ = {isa = PBXBuildFile; fileRef = 8E7574C109F31BD50080F1EE /* wavpack.c */; };
|
||||
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
|
||||
8E7574B309F31BB90080F1EE /* md5.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E7574AF09F31BB90080F1EE /* md5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
8E7574B409F31BB90080F1EE /* unpack3.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E7574B009F31BB90080F1EE /* unpack3.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
8E7574B509F31BB90080F1EE /* wavpack.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E7574B109F31BB90080F1EE /* wavpack.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
8E7574B609F31BB90080F1EE /* wputils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E7574B209F31BB90080F1EE /* wputils.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
8E7574C509F31BD50080F1EE /* bits.c in Sources */ = {isa = PBXBuildFile; fileRef = 8E7574B709F31BD50080F1EE /* bits.c */; };
|
||||
8E7574C609F31BD50080F1EE /* extra1.c in Sources */ = {isa = PBXBuildFile; fileRef = 8E7574B809F31BD50080F1EE /* extra1.c */; };
|
||||
8E7574C709F31BD50080F1EE /* extra2.c in Sources */ = {isa = PBXBuildFile; fileRef = 8E7574B909F31BD50080F1EE /* extra2.c */; };
|
||||
|
@ -29,12 +33,15 @@
|
|||
|
||||
/* Begin PBXFileReference section */
|
||||
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
83DD1DCD17FA038A00249519 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = utils.h; path = Files/utils.h; sourceTree = "<group>"; };
|
||||
83DD1DCE17FA038A00249519 /* wavpack_local.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wavpack_local.h; path = Files/wavpack_local.h; sourceTree = "<group>"; };
|
||||
83DD1DCF17FA038A00249519 /* wavpack_version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = wavpack_version.h; path = Files/wavpack_version.h; sourceTree = "<group>"; };
|
||||
83DD1DD317FA03F900249519 /* tags.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tags.c; path = Files/tags.c; sourceTree = "<group>"; };
|
||||
8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
8DC2EF5B0486A6940098B216 /* WavPack.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WavPack.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8E7574AF09F31BB90080F1EE /* md5.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = md5.h; path = Files/md5.h; sourceTree = "<group>"; };
|
||||
8E7574B009F31BB90080F1EE /* unpack3.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = unpack3.h; path = Files/unpack3.h; sourceTree = "<group>"; };
|
||||
8E7574B109F31BB90080F1EE /* wavpack.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = wavpack.h; path = Files/wavpack.h; sourceTree = "<group>"; };
|
||||
8E7574B209F31BB90080F1EE /* wputils.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = wputils.h; path = Files/wputils.h; sourceTree = "<group>"; };
|
||||
8E7574B709F31BD50080F1EE /* bits.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = bits.c; path = Files/bits.c; sourceTree = "<group>"; };
|
||||
8E7574B809F31BD50080F1EE /* extra1.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = extra1.c; path = Files/extra1.c; sourceTree = "<group>"; };
|
||||
8E7574B909F31BD50080F1EE /* extra2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = extra2.c; path = Files/extra2.c; sourceTree = "<group>"; };
|
||||
|
@ -120,6 +127,7 @@
|
|||
8E7574A809F31B940080F1EE /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83DD1DD317FA03F900249519 /* tags.c */,
|
||||
8E7574B709F31BD50080F1EE /* bits.c */,
|
||||
8E7574B809F31BD50080F1EE /* extra1.c */,
|
||||
8E7574B909F31BD50080F1EE /* extra2.c */,
|
||||
|
@ -141,10 +149,12 @@
|
|||
8E7574A909F31B9A0080F1EE /* Headers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83DD1DCD17FA038A00249519 /* utils.h */,
|
||||
83DD1DCE17FA038A00249519 /* wavpack_local.h */,
|
||||
83DD1DCF17FA038A00249519 /* wavpack_version.h */,
|
||||
8E7574AF09F31BB90080F1EE /* md5.h */,
|
||||
8E7574B009F31BB90080F1EE /* unpack3.h */,
|
||||
8E7574B109F31BB90080F1EE /* wavpack.h */,
|
||||
8E7574B209F31BB90080F1EE /* wputils.h */,
|
||||
);
|
||||
name = Headers;
|
||||
sourceTree = "<group>";
|
||||
|
@ -157,9 +167,11 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8E7574B309F31BB90080F1EE /* md5.h in Headers */,
|
||||
83DD1DD117FA038A00249519 /* wavpack_local.h in Headers */,
|
||||
8E7574B409F31BB90080F1EE /* unpack3.h in Headers */,
|
||||
83DD1DD217FA038A00249519 /* wavpack_version.h in Headers */,
|
||||
83DD1DD017FA038A00249519 /* utils.h in Headers */,
|
||||
8E7574B509F31BB90080F1EE /* wavpack.h in Headers */,
|
||||
8E7574B609F31BB90080F1EE /* wputils.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -225,6 +237,8 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
83DD1DD517FA04E100249519 /* wavpack.c in Sources */,
|
||||
83DD1DD417FA03F900249519 /* tags.c in Sources */,
|
||||
8E7574C509F31BD50080F1EE /* bits.c in Sources */,
|
||||
8E7574C609F31BD50080F1EE /* extra1.c in Sources */,
|
||||
8E7574C709F31BD50080F1EE /* extra2.c in Sources */,
|
||||
|
|
Loading…
Reference in New Issue