mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 05:01:41 +00:00
VERY IMPORTANT NOTE FOR ANYBODY BUILDING FROM THE TRUNK: This commit adds support
for FMOD Ex while at the same time removing support for FMOD 3. Be sure to update your SDKs. GCC users, be sure to do a "make cleandep && make clean" before building, or you will likely get inexplicable errors. - Fixed: If you wanted to make cleandep with MinGW, you had to specifically specify Makefile.mingw as the makefile to use. - Added a normalizer to the OPL synth. It helped bring up the volume a little, but not nearly as much as I would have liked. - Removed MIDI Mapper references. It doesn't work with the stream API, and it doesn't really exist on NT kernels, either. - Reworked music volume: Except for MIDI, all music volume is controlled through GSnd and not at the individual song level. - Removed the mididevice global variable. - Removed snd_midivolume. Now that all music uses a linear volume scale, there's no need for two separate music volume controls. - Increased snd_samplerate default up to 48000. - Added snd_format, defaulting to "PCM-16". - Added snd_speakermode, defaulting to "Auto". - Replaced snd_fpu with snd_resampler, defaulting to "Linear". - Bumped the snd_channels default up from a pitiful 12 to 32. - Changed snd_3d default to true. The new cvar snd_hw3d determines if hardware 3D support is used and default to false. - Removed the libFLAC source, since FMOD Ex has native FLAC support. - Removed the altsound code, since it was terribly gimped in comparison to the FMOD code. It's original purpose was to have been as a springboard for writing a non-FMOD sound system for Unix-y systems, but that never happened. - Finished preliminary FMOD Ex support. SVN r789 (trunk)
This commit is contained in:
parent
a5004f8827
commit
2b721975dd
74 changed files with 1673 additions and 20154 deletions
|
@ -1,245 +0,0 @@
|
|||
/* libFLAC++ - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLACPP__DECODER_H
|
||||
#define FLACPP__DECODER_H
|
||||
|
||||
#include "export.h"
|
||||
|
||||
// [RH] ZDoom doesn't need these
|
||||
//#include "FLAC/file_decoder.h"
|
||||
//#include "FLAC/seekable_stream_decoder.h"
|
||||
#include "FLAC/stream_decoder.h"
|
||||
|
||||
|
||||
/** \file include/FLAC++/decoder.h
|
||||
*
|
||||
* \brief
|
||||
* This module contains the classes which implement the various
|
||||
* decoders.
|
||||
*
|
||||
* See the detailed documentation in the
|
||||
* \link flacpp_decoder decoder \endlink module.
|
||||
*/
|
||||
|
||||
/** \defgroup flacpp_decoder FLAC++/decoder.h: decoder classes
|
||||
* \ingroup flacpp
|
||||
*
|
||||
* \brief
|
||||
* This module describes the decoder layers provided by libFLAC++.
|
||||
*
|
||||
* The libFLAC++ decoder classes are object wrappers around their
|
||||
* counterparts in libFLAC. All decoding layers available in
|
||||
* libFLAC are also provided here. The interface is very similar;
|
||||
* make sure to read the \link flac_decoder libFLAC decoder module \endlink.
|
||||
*
|
||||
* There are only two significant differences here. First, instead of
|
||||
* passing in C function pointers for callbacks, you inherit from the
|
||||
* decoder class and provide implementations for the callbacks in your
|
||||
* derived class; because of this there is no need for a 'client_data'
|
||||
* property.
|
||||
*
|
||||
* Second, there are two stream decoder classes. FLAC::Decoder::Stream
|
||||
* is used for the same cases that FLAC__stream_decoder_init_stream() /
|
||||
* FLAC__stream_decoder_init_ogg_stream() are used, and FLAC::Decoder::File
|
||||
* is used for the same cases that
|
||||
* FLAC__stream_decoder_init_FILE() and FLAC__stream_decoder_init_file() /
|
||||
* FLAC__stream_decoder_init_ogg_FILE() and FLAC__stream_decoder_init_ogg_file()
|
||||
* are used.
|
||||
*/
|
||||
|
||||
namespace FLAC {
|
||||
namespace Decoder {
|
||||
|
||||
/** \ingroup flacpp_decoder
|
||||
* \brief
|
||||
* This class wraps the ::FLAC__StreamDecoder. If you are
|
||||
* decoding from a file, FLAC::Decoder::File may be more
|
||||
* convenient.
|
||||
*
|
||||
* The usage of this class is similar to FLAC__StreamDecoder,
|
||||
* except instead of providing callbacks to
|
||||
* FLAC__stream_decoder_init*_stream(), you will inherit from this
|
||||
* class and override the virtual callback functions with your
|
||||
* own implementations, then call init() or init_ogg(). The rest
|
||||
* of the calls work the same as in the C layer.
|
||||
*
|
||||
* Only the read, write, and error callbacks are mandatory. The
|
||||
* others are optional; this class provides default
|
||||
* implementations that do nothing. In order for seeking to work
|
||||
* you must overide seek_callback(), tell_callback(),
|
||||
* length_callback(), and eof_callback().
|
||||
*/
|
||||
class FLACPP_API Stream {
|
||||
public:
|
||||
/** This class is a wrapper around FLAC__StreamDecoderState.
|
||||
*/
|
||||
class FLACPP_API State {
|
||||
public:
|
||||
inline State(::FLAC__StreamDecoderState state): state_(state) { }
|
||||
inline operator ::FLAC__StreamDecoderState() const { return state_; }
|
||||
inline const char *as_cstring() const { return ::FLAC__StreamDecoderStateString[state_]; }
|
||||
inline const char *resolved_as_cstring(const Stream &decoder) const { return ::FLAC__stream_decoder_get_resolved_state_string(decoder.decoder_); }
|
||||
protected:
|
||||
::FLAC__StreamDecoderState state_;
|
||||
};
|
||||
|
||||
Stream();
|
||||
virtual ~Stream();
|
||||
|
||||
//@{
|
||||
/** Call after construction to check the that the object was created
|
||||
* successfully. If not, use get_state() to find out why not.
|
||||
*/
|
||||
virtual bool is_valid() const;
|
||||
inline operator bool() const { return is_valid(); } ///< See is_valid()
|
||||
//@}
|
||||
|
||||
virtual bool set_ogg_serial_number(long value); ///< See FLAC__stream_decoder_set_ogg_serial_number()
|
||||
virtual bool set_md5_checking(bool value); ///< See FLAC__stream_decoder_set_md5_checking()
|
||||
virtual bool set_metadata_respond(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_respond()
|
||||
virtual bool set_metadata_respond_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_respond_application()
|
||||
virtual bool set_metadata_respond_all(); ///< See FLAC__stream_decoder_set_metadata_respond_all()
|
||||
virtual bool set_metadata_ignore(::FLAC__MetadataType type); ///< See FLAC__stream_decoder_set_metadata_ignore()
|
||||
virtual bool set_metadata_ignore_application(const FLAC__byte id[4]); ///< See FLAC__stream_decoder_set_metadata_ignore_application()
|
||||
virtual bool set_metadata_ignore_all(); ///< See FLAC__stream_decoder_set_metadata_ignore_all()
|
||||
|
||||
/* get_state() is not virtual since we want subclasses to be able to return their own state */
|
||||
State get_state() const; ///< See FLAC__stream_decoder_get_state()
|
||||
virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
|
||||
virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
|
||||
virtual unsigned get_channels() const; ///< See FLAC__stream_decoder_get_channels()
|
||||
virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
|
||||
virtual unsigned get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
|
||||
virtual unsigned get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
|
||||
virtual unsigned get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
|
||||
virtual bool get_decode_position(FLAC__uint64 *position) const; ///< See FLAC__stream_decoder_get_decode_position()
|
||||
|
||||
virtual ::FLAC__StreamDecoderInitStatus init(); ///< Seek FLAC__stream_decoder_init_stream()
|
||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(); ///< Seek FLAC__stream_decoder_init_ogg_stream()
|
||||
|
||||
virtual bool finish(); ///< See FLAC__stream_decoder_finish()
|
||||
|
||||
virtual bool flush(); ///< See FLAC__stream_decoder_flush()
|
||||
virtual bool reset(); ///< See FLAC__stream_decoder_reset()
|
||||
|
||||
virtual bool process_single(); ///< See FLAC__stream_decoder_process_single()
|
||||
virtual bool process_until_end_of_metadata(); ///< See FLAC__stream_decoder_process_until_end_of_metadata()
|
||||
virtual bool process_until_end_of_stream(); ///< See FLAC__stream_decoder_process_until_end_of_stream()
|
||||
virtual bool skip_single_frame(); ///< See FLAC__stream_decoder_skip_single_frame()
|
||||
|
||||
virtual bool seek_absolute(FLAC__uint64 sample); ///< See FLAC__stream_decoder_seek_absolute()
|
||||
protected:
|
||||
/// see FLAC__StreamDecoderReadCallback
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes) = 0;
|
||||
|
||||
/// see FLAC__StreamDecoderSeekCallback
|
||||
virtual ::FLAC__StreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
|
||||
|
||||
/// see FLAC__StreamDecoderTellCallback
|
||||
virtual ::FLAC__StreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
|
||||
|
||||
/// see FLAC__StreamDecoderLengthCallback
|
||||
virtual ::FLAC__StreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
|
||||
|
||||
/// see FLAC__StreamDecoderEofCallback
|
||||
virtual bool eof_callback();
|
||||
|
||||
/// see FLAC__StreamDecoderWriteCallback
|
||||
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]) = 0;
|
||||
|
||||
/// see FLAC__StreamDecoderMetadataCallback
|
||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
||||
|
||||
/// see FLAC__StreamDecoderErrorCallback
|
||||
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status) = 0;
|
||||
|
||||
#if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
|
||||
// lame hack: some MSVC/GCC versions can't see a protected decoder_ from nested State::resolved_as_cstring()
|
||||
friend State;
|
||||
#endif
|
||||
::FLAC__StreamDecoder *decoder_;
|
||||
|
||||
static ::FLAC__StreamDecoderReadStatus read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
static ::FLAC__StreamDecoderSeekStatus seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
|
||||
static ::FLAC__StreamDecoderTellStatus tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
|
||||
static ::FLAC__StreamDecoderLengthStatus length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
|
||||
static FLAC__bool eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data);
|
||||
static ::FLAC__StreamDecoderWriteStatus write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
|
||||
static void metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
|
||||
static void error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||
private:
|
||||
// Private and undefined so you can't use them:
|
||||
Stream(const Stream &);
|
||||
void operator=(const Stream &);
|
||||
};
|
||||
|
||||
/** \ingroup flacpp_decoder
|
||||
* \brief
|
||||
* This class wraps the ::FLAC__StreamDecoder. If you are
|
||||
* not decoding from a file, you may need to use
|
||||
* FLAC::Decoder::Stream.
|
||||
*
|
||||
* The usage of this class is similar to FLAC__StreamDecoder,
|
||||
* except instead of providing callbacks to
|
||||
* FLAC__stream_decoder_init*_FILE() or
|
||||
* FLAC__stream_decoder_init*_file(), you will inherit from this
|
||||
* class and override the virtual callback functions with your
|
||||
* own implementations, then call init() or init_off(). The rest
|
||||
* of the calls work the same as in the C layer.
|
||||
*
|
||||
* Only the write, and error callbacks from FLAC::Decoder::Stream
|
||||
* are mandatory. The others are optional; this class provides
|
||||
* full working implementations for all other callbacks and
|
||||
* supports seeking.
|
||||
*/
|
||||
class FLACPP_API File: public Stream {
|
||||
public:
|
||||
File();
|
||||
virtual ~File();
|
||||
|
||||
virtual ::FLAC__StreamDecoderInitStatus init(FILE *file); ///< See FLAC__stream_decoder_init_FILE()
|
||||
virtual ::FLAC__StreamDecoderInitStatus init(const char *filename); ///< See FLAC__stream_decoder_init_file()
|
||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(FILE *file); ///< See FLAC__stream_decoder_init_ogg_FILE()
|
||||
virtual ::FLAC__StreamDecoderInitStatus init_ogg(const char *filename); ///< See FLAC__stream_decoder_init_ogg_file()
|
||||
protected:
|
||||
// this is a dummy implementation to satisfy the pure virtual in Stream that is actually supplied internally by the C layer
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
|
||||
private:
|
||||
// Private and undefined so you can't use them:
|
||||
File(const File &);
|
||||
void operator=(const File &);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,80 +0,0 @@
|
|||
/* libFLAC++ - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLACPP__EXPORT_H
|
||||
#define FLACPP__EXPORT_H
|
||||
|
||||
/** \file include/FLAC++/export.h
|
||||
*
|
||||
* \brief
|
||||
* This module contains #defines and symbols for exporting function
|
||||
* calls, and providing version information and compiled-in features.
|
||||
*
|
||||
* See the \link flacpp_export export \endlink module.
|
||||
*/
|
||||
|
||||
/** \defgroup flacpp_export FLAC++/export.h: export symbols
|
||||
* \ingroup flacpp
|
||||
*
|
||||
* \brief
|
||||
* This module contains #defines and symbols for exporting function
|
||||
* calls, and providing version information and compiled-in features.
|
||||
*
|
||||
* If you are compiling with MSVC and will link to the static library
|
||||
* (libFLAC++.lib) you should define FLAC__NO_DLL in your project to
|
||||
* make sure the symbols are exported properly.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
|
||||
#if defined(FLAC__NO_DLL) || !defined(_MSC_VER)
|
||||
#define FLACPP_API
|
||||
|
||||
#else
|
||||
|
||||
#ifdef FLACPP_API_EXPORTS
|
||||
#define FLACPP_API _declspec(dllexport)
|
||||
#else
|
||||
#define FLACPP_API _declspec(dllimport)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* These #defines will mirror the libtool-based library version number, see
|
||||
* http://www.gnu.org/software/libtool/manual.html#Libtool-versioning
|
||||
*/
|
||||
#define FLACPP_API_VERSION_CURRENT 8
|
||||
#define FLACPP_API_VERSION_REVISION 0
|
||||
#define FLACPP_API_VERSION_AGE 2
|
||||
|
||||
/* \} */
|
||||
|
||||
#endif
|
690
FLAC/FLAC.vcproj
690
FLAC/FLAC.vcproj
|
@ -1,690 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="FLAC"
|
||||
ProjectGUID="{873F2EEA-24DF-454C-B245-CB9738BA993E}"
|
||||
RootNamespace="FLAC"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLAC__CPU_IA32;FLAC__HAS_NASM;FLAC__SSE_OS;FLAC__USE_3DNOW;FLAC__NO_DLL"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableFunctionLevelLinking="true"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/FLAC.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLAC__NO_DLL"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/FLAC.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;FLAC__CPU_IA32;FLAC__HAS_NASM;FLAC__SSE_OS;FLAC__USE_3DNOW;FLAC__NO_DLL"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/FLAC.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;FLAC__NO_DLL"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/FLAC.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
|
||||
>
|
||||
<File
|
||||
RelativePath="bitmath.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\bitreader.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="cpu.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="crc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="fixed.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="format.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="lpc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\md5.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\memory.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="stream_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="stream_decoder_pp.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc"
|
||||
>
|
||||
<Filter
|
||||
Name="Protected"
|
||||
>
|
||||
<File
|
||||
RelativePath="protected\stream_decoder.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Private"
|
||||
>
|
||||
<File
|
||||
RelativePath="private\bitmath.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\private\bitreader.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="private\cpu.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="private\crc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="private\fixed.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\private\float.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="private\format.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="private\lpc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\private\md5.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\private\memory.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="FLAC"
|
||||
>
|
||||
<File
|
||||
RelativePath="FLAC\assert.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FLAC\export.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FLAC\format.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FLAC\ordinals.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FLAC\stream_decoder.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="FLAC++"
|
||||
>
|
||||
<File
|
||||
RelativePath="FLAC++\decoder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="FLAC++\export.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Share"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\share\alloc.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="IA32 Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\ia32\bitreader_asm.nasm"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ia32\cpu_asm.nasm"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ia32\fixed_asm.nasm"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ia32\lpc_asm.nasm"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ia32\nasm.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ia32\stream_encoder_asm.nasm"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o "$(IntDir)\$(InputName).obj" -d OBJ_FORMAT_win32 -f win32 "$(InputPath)"
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Assembling $(InputPath)..."
|
||||
CommandLine="nasm -o $(IntDir)\$(InputName).obj -d OBJ_FORMAT_win32 -f win32 $(InputPath)
"
|
||||
Outputs="$(IntDir)\$(InputName).obj"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Makefile.mgw"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ReadMe.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,45 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__ASSERT_H
|
||||
#define FLAC__ASSERT_H
|
||||
|
||||
/* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#define FLAC__ASSERT(x) assert(x)
|
||||
#define FLAC__ASSERT_DECLARATION(x) x
|
||||
#else
|
||||
#define FLAC__ASSERT(x)
|
||||
#define FLAC__ASSERT_DECLARATION(x)
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,91 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__EXPORT_H
|
||||
#define FLAC__EXPORT_H
|
||||
|
||||
/** \file include/FLAC/export.h
|
||||
*
|
||||
* \brief
|
||||
* This module contains #defines and symbols for exporting function
|
||||
* calls, and providing version information and compiled-in features.
|
||||
*
|
||||
* See the \link flac_export export \endlink module.
|
||||
*/
|
||||
|
||||
/** \defgroup flac_export FLAC/export.h: export symbols
|
||||
* \ingroup flac
|
||||
*
|
||||
* \brief
|
||||
* This module contains #defines and symbols for exporting function
|
||||
* calls, and providing version information and compiled-in features.
|
||||
*
|
||||
* If you are compiling with MSVC and will link to the static library
|
||||
* (libFLAC.lib) you should define FLAC__NO_DLL in your project to
|
||||
* make sure the symbols are exported properly.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
|
||||
#if defined(FLAC__NO_DLL) || !defined(_MSC_VER)
|
||||
#define FLAC_API
|
||||
|
||||
#else
|
||||
|
||||
#ifdef FLAC_API_EXPORTS
|
||||
#define FLAC_API _declspec(dllexport)
|
||||
#else
|
||||
#define FLAC_API _declspec(dllimport)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** These #defines will mirror the libtool-based library version number, see
|
||||
* http://www.gnu.org/software/libtool/manual.html#Libtool-versioning
|
||||
*/
|
||||
#define FLAC_API_VERSION_CURRENT 10
|
||||
#define FLAC_API_VERSION_REVISION 0 /**< see above */
|
||||
#define FLAC_API_VERSION_AGE 2 /**< see above */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */
|
||||
extern FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* \} */
|
||||
|
||||
#endif
|
1010
FLAC/FLAC/format.h
1010
FLAC/FLAC/format.h
File diff suppressed because it is too large
Load diff
|
@ -1,80 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__ORDINALS_H
|
||||
#define FLAC__ORDINALS_H
|
||||
|
||||
#if !(defined(_MSC_VER) || defined(__BORLANDC__) || defined(__EMX__))
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
typedef signed char FLAC__int8;
|
||||
typedef unsigned char FLAC__uint8;
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef __int16 FLAC__int16;
|
||||
typedef __int32 FLAC__int32;
|
||||
typedef __int64 FLAC__int64;
|
||||
typedef unsigned __int16 FLAC__uint16;
|
||||
typedef unsigned __int32 FLAC__uint32;
|
||||
typedef unsigned __int64 FLAC__uint64;
|
||||
#elif defined(__EMX__)
|
||||
typedef short FLAC__int16;
|
||||
typedef long FLAC__int32;
|
||||
typedef long long FLAC__int64;
|
||||
typedef unsigned short FLAC__uint16;
|
||||
typedef unsigned long FLAC__uint32;
|
||||
typedef unsigned long long FLAC__uint64;
|
||||
#else
|
||||
typedef int16_t FLAC__int16;
|
||||
typedef int32_t FLAC__int32;
|
||||
typedef int64_t FLAC__int64;
|
||||
typedef uint16_t FLAC__uint16;
|
||||
typedef uint32_t FLAC__uint32;
|
||||
typedef uint64_t FLAC__uint64;
|
||||
#endif
|
||||
|
||||
typedef int FLAC__bool;
|
||||
|
||||
typedef FLAC__uint8 FLAC__byte;
|
||||
|
||||
#ifdef true
|
||||
#undef true
|
||||
#endif
|
||||
#ifdef false
|
||||
#undef false
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,79 +0,0 @@
|
|||
# Makefile for combined FLAC, FLAC++, derived from zlib's Makefile.mgw,
|
||||
# which was itself derived from zlib's Makefile.dj2.
|
||||
# Modified for mingw32 by C. Spieler, 6/16/98.
|
||||
# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003.
|
||||
# Last updated: 1-Aug-2003.
|
||||
|
||||
# Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
ifeq (Windows_NT,$(OS))
|
||||
WIN=1
|
||||
WINCMD=1
|
||||
endif
|
||||
ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
|
||||
WIN=1
|
||||
WINCMD=0
|
||||
endif
|
||||
|
||||
STATICLIB = libflac.a
|
||||
|
||||
#LOC = -DASMV
|
||||
#LOC = -DDEBUG -g
|
||||
|
||||
DEFINES = -D__MINW32__ -DWIN32 -DNDEBUG -D_LIB -DFLAC__CPU_IA32 -DFLAC_HAS_NASM -DFLAC__SSE_OS -DFLAC__USE_3DNOW -DFLAC__NO_DLL -I.
|
||||
|
||||
CCDV = @../ccdv
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
CFLAGS = $(LOC) $(DEFINES) -O2 -Wall -Wno-unused-function -fomit-frame-pointer
|
||||
CXXFLAGS = $(LOC) $(DEFINES) -O2 -Wall
|
||||
|
||||
NASM = nasm
|
||||
NASMFLAGS = -d OBJ_FORMAT_win32 -f win32
|
||||
|
||||
AR = ar
|
||||
ARFLAGS = rcs
|
||||
|
||||
OBJS = cpu_asm.o fixed_asm.o lpc_asm.o \
|
||||
bitmath.o bitreader.o cpu.o crc.o fixed.o format.o lpc.o md5.o memory.o stream_decoder.o stream_decoder_pp.o
|
||||
|
||||
all: $(STATICLIB)
|
||||
|
||||
.c.o:
|
||||
$(CCDV) $(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
.cpp.o:
|
||||
$(CCDV) $(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
$(STATICLIB): $(OBJS)
|
||||
$(CCDV) $(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
ifeq (1,$(WINCMD))
|
||||
-del /q /f $(STATICLIB) 2>nul
|
||||
-del /q /f *.o 2>nul
|
||||
else
|
||||
rm -f $(STATICLIB)
|
||||
rm -f *.o
|
||||
endif
|
||||
|
||||
cpu_asm.o: ia32/cpu_asm.nasm
|
||||
$(CCDV) $(NASM) -o $@ $(NASMFLAGS) $<
|
||||
fixed_asm.o: ia32/fixed_asm.nasm
|
||||
$(CCDV) $(NASM) -o $@ $(NASMFLAGS) $<
|
||||
lpc_asm.o: ia32/lpc_asm.nasm
|
||||
$(CCDV) $(NASM) -o $@ $(NASMFLAGS) $<
|
||||
bitbuffer.o: bitbuffer.c
|
||||
bitmath.o: bitmath.c
|
||||
cpu.o: cpu.c
|
||||
crc.o: crc.c
|
||||
fixed.o: fixed.c
|
||||
format.o: format.c
|
||||
lpc.o: lpc.c
|
||||
memory.o: memory.c
|
||||
stream_decoder.o: stream_decoder.c
|
||||
stream_decoder_pp.o: stream_decoder_pp.cpp
|
|
@ -1,7 +0,0 @@
|
|||
This is not the complete FLAC distribution. It contains only what
|
||||
ZDoom needs to decode compressed FLAC streams. For the complete
|
||||
distribution, please visit <http://flac.sourceforge.net/>. The
|
||||
version here is currently version 1.2.1.
|
||||
|
||||
Of course, under Linux, you are encouraged to ignore this source
|
||||
here and dynamically link to the full libraries.
|
149
FLAC/bitmath.c
149
FLAC/bitmath.c
|
@ -1,149 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "private/bitmath.h"
|
||||
#include "FLAC/assert.h"
|
||||
|
||||
/* An example of what FLAC__bitmath_ilog2() computes:
|
||||
*
|
||||
* ilog2( 0) = assertion failure
|
||||
* ilog2( 1) = 0
|
||||
* ilog2( 2) = 1
|
||||
* ilog2( 3) = 1
|
||||
* ilog2( 4) = 2
|
||||
* ilog2( 5) = 2
|
||||
* ilog2( 6) = 2
|
||||
* ilog2( 7) = 2
|
||||
* ilog2( 8) = 3
|
||||
* ilog2( 9) = 3
|
||||
* ilog2(10) = 3
|
||||
* ilog2(11) = 3
|
||||
* ilog2(12) = 3
|
||||
* ilog2(13) = 3
|
||||
* ilog2(14) = 3
|
||||
* ilog2(15) = 3
|
||||
* ilog2(16) = 4
|
||||
* ilog2(17) = 4
|
||||
* ilog2(18) = 4
|
||||
*/
|
||||
unsigned FLAC__bitmath_ilog2(FLAC__uint32 v)
|
||||
{
|
||||
unsigned l = 0;
|
||||
FLAC__ASSERT(v > 0);
|
||||
while(v >>= 1)
|
||||
l++;
|
||||
return l;
|
||||
}
|
||||
|
||||
unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
|
||||
{
|
||||
unsigned l = 0;
|
||||
FLAC__ASSERT(v > 0);
|
||||
while(v >>= 1)
|
||||
l++;
|
||||
return l;
|
||||
}
|
||||
|
||||
/* An example of what FLAC__bitmath_silog2() computes:
|
||||
*
|
||||
* silog2(-10) = 5
|
||||
* silog2(- 9) = 5
|
||||
* silog2(- 8) = 4
|
||||
* silog2(- 7) = 4
|
||||
* silog2(- 6) = 4
|
||||
* silog2(- 5) = 4
|
||||
* silog2(- 4) = 3
|
||||
* silog2(- 3) = 3
|
||||
* silog2(- 2) = 2
|
||||
* silog2(- 1) = 2
|
||||
* silog2( 0) = 0
|
||||
* silog2( 1) = 2
|
||||
* silog2( 2) = 3
|
||||
* silog2( 3) = 3
|
||||
* silog2( 4) = 4
|
||||
* silog2( 5) = 4
|
||||
* silog2( 6) = 4
|
||||
* silog2( 7) = 4
|
||||
* silog2( 8) = 5
|
||||
* silog2( 9) = 5
|
||||
* silog2( 10) = 5
|
||||
*/
|
||||
unsigned FLAC__bitmath_silog2(int v)
|
||||
{
|
||||
while(1) {
|
||||
if(v == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if(v > 0) {
|
||||
unsigned l = 0;
|
||||
while(v) {
|
||||
l++;
|
||||
v >>= 1;
|
||||
}
|
||||
return l+1;
|
||||
}
|
||||
else if(v == -1) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
v++;
|
||||
v = -v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v)
|
||||
{
|
||||
while(1) {
|
||||
if(v == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if(v > 0) {
|
||||
unsigned l = 0;
|
||||
while(v) {
|
||||
l++;
|
||||
v >>= 1;
|
||||
}
|
||||
return l+1;
|
||||
}
|
||||
else if(v == -1) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
v++;
|
||||
v = -v;
|
||||
}
|
||||
}
|
||||
}
|
1376
FLAC/bitreader.c
1376
FLAC/bitreader.c
File diff suppressed because it is too large
Load diff
418
FLAC/cpu.c
418
FLAC/cpu.c
|
@ -1,418 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "private/cpu.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined FLAC__CPU_IA32
|
||||
# include <signal.h>
|
||||
#elif defined FLAC__CPU_PPC
|
||||
# if !defined FLAC__NO_ASM
|
||||
# if defined FLAC__SYS_DARWIN
|
||||
# include <sys/sysctl.h>
|
||||
# include <mach/mach.h>
|
||||
# include <mach/mach_host.h>
|
||||
# include <mach/host_info.h>
|
||||
# include <mach/machine.h>
|
||||
# ifndef CPU_SUBTYPE_POWERPC_970
|
||||
# define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
|
||||
# endif
|
||||
# else /* FLAC__SYS_DARWIN */
|
||||
|
||||
# include <signal.h>
|
||||
# include <setjmp.h>
|
||||
|
||||
static sigjmp_buf jmpbuf;
|
||||
static volatile sig_atomic_t canjump = 0;
|
||||
|
||||
static void sigill_handler (int sig)
|
||||
{
|
||||
if (!canjump) {
|
||||
signal (sig, SIG_DFL);
|
||||
raise (sig);
|
||||
}
|
||||
canjump = 0;
|
||||
siglongjmp (jmpbuf, 1);
|
||||
}
|
||||
# endif /* FLAC__SYS_DARWIN */
|
||||
# endif /* FLAC__NO_ASM */
|
||||
#endif /* FLAC__CPU_PPC */
|
||||
|
||||
#if defined (__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/cpu.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* how to get sysctlbyname()? */
|
||||
#endif
|
||||
|
||||
/* these are flags in EDX of CPUID AX=00000001 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_FXSR = 0x01000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000;
|
||||
/* these are flags in ECX of CPUID AX=00000001 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200;
|
||||
/* these are flags in EDX of CPUID AX=80000001 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW = 0x80000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW = 0x40000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX = 0x00400000;
|
||||
|
||||
|
||||
/*
|
||||
* Extra stuff needed for detection of OS support for SSE on IA-32
|
||||
*/
|
||||
#if defined(FLAC__CPU_IA32) && !defined FLAC__NO_ASM && defined FLAC__HAS_NASM && !defined FLAC__NO_SSE_OS && !defined FLAC__SSE_OS
|
||||
# if defined(__linux__)
|
||||
/*
|
||||
* If the OS doesn't support SSE, we will get here with a SIGILL. We
|
||||
* modify the return address to jump over the offending SSE instruction
|
||||
* and also the operation following it that indicates the instruction
|
||||
* executed successfully. In this way we use no global variables and
|
||||
* stay thread-safe.
|
||||
*
|
||||
* 3 + 3 + 6:
|
||||
* 3 bytes for "xorps xmm0,xmm0"
|
||||
* 3 bytes for estimate of how long the follwing "inc var" instruction is
|
||||
* 6 bytes extra in case our estimate is wrong
|
||||
* 12 bytes puts us in the NOP "landing zone"
|
||||
*/
|
||||
# undef USE_OBSOLETE_SIGCONTEXT_FLAVOR /* #define this to use the older signal handler method */
|
||||
# ifdef USE_OBSOLETE_SIGCONTEXT_FLAVOR
|
||||
static void sigill_handler_sse_os(int signal, struct sigcontext sc)
|
||||
{
|
||||
(void)signal;
|
||||
sc.eip += 3 + 3 + 6;
|
||||
}
|
||||
# else
|
||||
# include <sys/ucontext.h>
|
||||
static void sigill_handler_sse_os(int signal, siginfo_t *si, void *uc)
|
||||
{
|
||||
(void)signal, (void)si;
|
||||
((ucontext_t*)uc)->uc_mcontext.gregs[14/*REG_EIP*/] += 3 + 3 + 6;
|
||||
}
|
||||
# endif
|
||||
# elif defined(_MSC_VER)
|
||||
# include <windows.h>
|
||||
# undef USE_TRY_CATCH_FLAVOR /* #define this to use the try/catch method for catching illegal opcode exception */
|
||||
# ifdef USE_TRY_CATCH_FLAVOR
|
||||
# else
|
||||
LONG CALLBACK sigill_handler_sse_os(EXCEPTION_POINTERS *ep)
|
||||
{
|
||||
if(ep->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) {
|
||||
ep->ContextRecord->Eip += 3 + 3 + 6;
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
void FLAC__cpu_info(FLAC__CPUInfo *info)
|
||||
{
|
||||
/*
|
||||
* IA32-specific
|
||||
*/
|
||||
#ifdef FLAC__CPU_IA32
|
||||
info->type = FLAC__CPUINFO_TYPE_IA32;
|
||||
#if !defined FLAC__NO_ASM && defined FLAC__HAS_NASM
|
||||
info->use_asm = true; /* we assume a minimum of 80386 with FLAC__CPU_IA32 */
|
||||
info->data.ia32.cpuid = FLAC__cpu_have_cpuid_asm_ia32()? true : false;
|
||||
info->data.ia32.bswap = info->data.ia32.cpuid; /* CPUID => BSWAP since it came after */
|
||||
info->data.ia32.cmov = false;
|
||||
info->data.ia32.mmx = false;
|
||||
info->data.ia32.fxsr = false;
|
||||
info->data.ia32.sse = false;
|
||||
info->data.ia32.sse2 = false;
|
||||
info->data.ia32.sse3 = false;
|
||||
info->data.ia32.ssse3 = false;
|
||||
info->data.ia32._3dnow = false;
|
||||
info->data.ia32.ext3dnow = false;
|
||||
info->data.ia32.extmmx = false;
|
||||
if(info->data.ia32.cpuid) {
|
||||
/* http://www.sandpile.org/ia32/cpuid.htm */
|
||||
FLAC__uint32 flags_edx, flags_ecx;
|
||||
FLAC__cpu_info_asm_ia32(&flags_edx, &flags_ecx);
|
||||
info->data.ia32.cmov = (flags_edx & FLAC__CPUINFO_IA32_CPUID_CMOV )? true : false;
|
||||
info->data.ia32.mmx = (flags_edx & FLAC__CPUINFO_IA32_CPUID_MMX )? true : false;
|
||||
info->data.ia32.fxsr = (flags_edx & FLAC__CPUINFO_IA32_CPUID_FXSR )? true : false;
|
||||
info->data.ia32.sse = (flags_edx & FLAC__CPUINFO_IA32_CPUID_SSE )? true : false;
|
||||
info->data.ia32.sse2 = (flags_edx & FLAC__CPUINFO_IA32_CPUID_SSE2 )? true : false;
|
||||
info->data.ia32.sse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE3 )? true : false;
|
||||
info->data.ia32.ssse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSSE3)? true : false;
|
||||
|
||||
#ifdef FLAC__USE_3DNOW
|
||||
flags_edx = FLAC__cpu_info_extended_amd_asm_ia32();
|
||||
info->data.ia32._3dnow = (flags_edx & FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW )? true : false;
|
||||
info->data.ia32.ext3dnow = (flags_edx & FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW)? true : false;
|
||||
info->data.ia32.extmmx = (flags_edx & FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX )? true : false;
|
||||
#else
|
||||
info->data.ia32._3dnow = info->data.ia32.ext3dnow = info->data.ia32.extmmx = false;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "CPU info (IA-32):\n");
|
||||
fprintf(stderr, " CPUID ...... %c\n", info->data.ia32.cpuid ? 'Y' : 'n');
|
||||
fprintf(stderr, " BSWAP ...... %c\n", info->data.ia32.bswap ? 'Y' : 'n');
|
||||
fprintf(stderr, " CMOV ....... %c\n", info->data.ia32.cmov ? 'Y' : 'n');
|
||||
fprintf(stderr, " MMX ........ %c\n", info->data.ia32.mmx ? 'Y' : 'n');
|
||||
fprintf(stderr, " FXSR ....... %c\n", info->data.ia32.fxsr ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE ........ %c\n", info->data.ia32.sse ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE2 ....... %c\n", info->data.ia32.sse2 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE3 ....... %c\n", info->data.ia32.sse3 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSSE3 ...... %c\n", info->data.ia32.ssse3 ? 'Y' : 'n');
|
||||
fprintf(stderr, " 3DNow! ..... %c\n", info->data.ia32._3dnow ? 'Y' : 'n');
|
||||
fprintf(stderr, " 3DNow!-ext . %c\n", info->data.ia32.ext3dnow? 'Y' : 'n');
|
||||
fprintf(stderr, " 3DNow!-MMX . %c\n", info->data.ia32.extmmx ? 'Y' : 'n');
|
||||
#endif
|
||||
|
||||
/*
|
||||
* now have to check for OS support of SSE/SSE2
|
||||
*/
|
||||
if(info->data.ia32.fxsr || info->data.ia32.sse || info->data.ia32.sse2) {
|
||||
#if defined FLAC__NO_SSE_OS
|
||||
/* assume user knows better than us; turn it off */
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
#elif defined FLAC__SSE_OS
|
||||
/* assume user knows better than us; leave as detected above */
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
int sse = 0;
|
||||
size_t len;
|
||||
/* at least one of these must work: */
|
||||
len = sizeof(sse); sse = sse || (sysctlbyname("hw.instruction_sse", &sse, &len, NULL, 0) == 0 && sse);
|
||||
len = sizeof(sse); sse = sse || (sysctlbyname("hw.optional.sse" , &sse, &len, NULL, 0) == 0 && sse); /* __APPLE__ ? */
|
||||
if(!sse)
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
#elif defined(__NetBSD__) || defined (__OpenBSD__)
|
||||
# if __NetBSD_Version__ >= 105250000 || (defined __OpenBSD__)
|
||||
int val = 0, mib[2] = { CTL_MACHDEP, CPU_SSE };
|
||||
size_t len = sizeof(val);
|
||||
if(sysctl(mib, 2, &val, &len, NULL, 0) < 0 || !val)
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
else { /* double-check SSE2 */
|
||||
mib[1] = CPU_SSE2;
|
||||
len = sizeof(val);
|
||||
if(sysctl(mib, 2, &val, &len, NULL, 0) < 0 || !val)
|
||||
info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
}
|
||||
# else
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
# endif
|
||||
#elif defined(__linux__)
|
||||
int sse = 0;
|
||||
struct sigaction sigill_save;
|
||||
#ifdef USE_OBSOLETE_SIGCONTEXT_FLAVOR
|
||||
if(0 == sigaction(SIGILL, NULL, &sigill_save) && signal(SIGILL, (void (*)(int))sigill_handler_sse_os) != SIG_ERR)
|
||||
#else
|
||||
struct sigaction sigill_sse;
|
||||
sigill_sse.sa_sigaction = sigill_handler_sse_os;
|
||||
__sigemptyset(&sigill_sse.sa_mask);
|
||||
sigill_sse.sa_flags = SA_SIGINFO | SA_RESETHAND; /* SA_RESETHAND just in case our SIGILL return jump breaks, so we don't get stuck in a loop */
|
||||
if(0 == sigaction(SIGILL, &sigill_sse, &sigill_save))
|
||||
#endif
|
||||
{
|
||||
/* http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html */
|
||||
/* see sigill_handler_sse_os() for an explanation of the following: */
|
||||
asm volatile (
|
||||
"xorl %0,%0\n\t" /* for some reason, still need to do this to clear 'sse' var */
|
||||
"xorps %%xmm0,%%xmm0\n\t" /* will cause SIGILL if unsupported by OS */
|
||||
"incl %0\n\t" /* SIGILL handler will jump over this */
|
||||
/* landing zone */
|
||||
"nop\n\t" /* SIGILL jump lands here if "inc" is 9 bytes */
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t" /* SIGILL jump lands here if "inc" is 3 bytes (expected) */
|
||||
"nop\n\t"
|
||||
"nop" /* SIGILL jump lands here if "inc" is 1 byte */
|
||||
: "=r"(sse)
|
||||
: "r"(sse)
|
||||
);
|
||||
|
||||
sigaction(SIGILL, &sigill_save, NULL);
|
||||
}
|
||||
|
||||
if(!sse)
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
#elif defined(_MSC_VER)
|
||||
# ifdef USE_TRY_CATCH_FLAVOR
|
||||
_try {
|
||||
__asm {
|
||||
# if _MSC_VER <= 1200
|
||||
/* VC6 assembler doesn't know SSE, have to emit bytecode instead */
|
||||
_emit 0x0F
|
||||
_emit 0x57
|
||||
_emit 0xC0
|
||||
# else
|
||||
xorps xmm0,xmm0
|
||||
# endif
|
||||
}
|
||||
}
|
||||
_except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
}
|
||||
# else
|
||||
int sse = 0;
|
||||
LPTOP_LEVEL_EXCEPTION_FILTER save = SetUnhandledExceptionFilter(sigill_handler_sse_os);
|
||||
/* see GCC version above for explanation */
|
||||
/* http://msdn2.microsoft.com/en-us/library/4ks26t93.aspx */
|
||||
/* http://www.codeproject.com/cpp/gccasm.asp */
|
||||
/* http://www.hick.org/~mmiller/msvc_inline_asm.html */
|
||||
__asm {
|
||||
# if _MSC_VER <= 1200
|
||||
/* VC6 assembler doesn't know SSE, have to emit bytecode instead */
|
||||
_emit 0x0F
|
||||
_emit 0x57
|
||||
_emit 0xC0
|
||||
# else
|
||||
xorps xmm0,xmm0
|
||||
# endif
|
||||
inc sse
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
}
|
||||
SetUnhandledExceptionFilter(save);
|
||||
if(!sse)
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
# endif
|
||||
#else
|
||||
/* no way to test, disable to be safe */
|
||||
info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " SSE OS sup . %c\n", info->data.ia32.sse ? 'Y' : 'n');
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
info->use_asm = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PPC-specific
|
||||
*/
|
||||
#elif defined FLAC__CPU_PPC
|
||||
info->type = FLAC__CPUINFO_TYPE_PPC;
|
||||
# if !defined FLAC__NO_ASM
|
||||
info->use_asm = true;
|
||||
# ifdef FLAC__USE_ALTIVEC
|
||||
# if defined FLAC__SYS_DARWIN
|
||||
{
|
||||
int val = 0, mib[2] = { CTL_HW, HW_VECTORUNIT };
|
||||
size_t len = sizeof(val);
|
||||
info->data.ppc.altivec = !(sysctl(mib, 2, &val, &len, NULL, 0) || !val);
|
||||
}
|
||||
{
|
||||
host_basic_info_data_t hostInfo;
|
||||
mach_msg_type_number_t infoCount;
|
||||
|
||||
infoCount = HOST_BASIC_INFO_COUNT;
|
||||
host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, &infoCount);
|
||||
|
||||
info->data.ppc.ppc64 = (hostInfo.cpu_type == CPU_TYPE_POWERPC) && (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970);
|
||||
}
|
||||
# else /* FLAC__USE_ALTIVEC && !FLAC__SYS_DARWIN */
|
||||
{
|
||||
/* no Darwin, do it the brute-force way */
|
||||
/* @@@@@@ this is not thread-safe; replace with SSE OS method above or remove */
|
||||
info->data.ppc.altivec = 0;
|
||||
info->data.ppc.ppc64 = 0;
|
||||
|
||||
signal (SIGILL, sigill_handler);
|
||||
canjump = 0;
|
||||
if (!sigsetjmp (jmpbuf, 1)) {
|
||||
canjump = 1;
|
||||
|
||||
asm volatile (
|
||||
"mtspr 256, %0\n\t"
|
||||
"vand %%v0, %%v0, %%v0"
|
||||
:
|
||||
: "r" (-1)
|
||||
);
|
||||
|
||||
info->data.ppc.altivec = 1;
|
||||
}
|
||||
canjump = 0;
|
||||
if (!sigsetjmp (jmpbuf, 1)) {
|
||||
int x = 0;
|
||||
canjump = 1;
|
||||
|
||||
/* PPC64 hardware implements the cntlzd instruction */
|
||||
asm volatile ("cntlzd %0, %1" : "=r" (x) : "r" (x) );
|
||||
|
||||
info->data.ppc.ppc64 = 1;
|
||||
}
|
||||
signal (SIGILL, SIG_DFL); /*@@@@@@ should save and restore old signal */
|
||||
}
|
||||
# endif
|
||||
# else /* !FLAC__USE_ALTIVEC */
|
||||
info->data.ppc.altivec = 0;
|
||||
info->data.ppc.ppc64 = 0;
|
||||
# endif
|
||||
# else
|
||||
info->use_asm = false;
|
||||
# endif
|
||||
|
||||
/*
|
||||
* unknown CPI
|
||||
*/
|
||||
#else
|
||||
info->type = FLAC__CPUINFO_TYPE_UNKNOWN;
|
||||
info->use_asm = false;
|
||||
#endif
|
||||
}
|
142
FLAC/crc.c
142
FLAC/crc.c
|
@ -1,142 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "private/crc.h"
|
||||
|
||||
/* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */
|
||||
|
||||
FLAC__byte const FLAC__crc8_table[256] = {
|
||||
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15,
|
||||
0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
|
||||
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
|
||||
0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
|
||||
0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5,
|
||||
0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
|
||||
0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85,
|
||||
0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
|
||||
0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2,
|
||||
0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
|
||||
0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2,
|
||||
0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
|
||||
0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32,
|
||||
0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
|
||||
0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42,
|
||||
0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
|
||||
0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C,
|
||||
0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
|
||||
0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC,
|
||||
0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
|
||||
0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C,
|
||||
0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
|
||||
0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C,
|
||||
0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
|
||||
0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B,
|
||||
0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
|
||||
0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B,
|
||||
0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
|
||||
0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB,
|
||||
0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
|
||||
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB,
|
||||
0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
|
||||
};
|
||||
|
||||
/* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */
|
||||
|
||||
unsigned FLAC__crc16_table[256] = {
|
||||
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
|
||||
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
|
||||
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
|
||||
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
|
||||
0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
|
||||
0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
|
||||
0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
|
||||
0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
|
||||
0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
|
||||
0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
|
||||
0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
|
||||
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
|
||||
0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
|
||||
0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
|
||||
0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
|
||||
0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
|
||||
0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
|
||||
0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
|
||||
0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
|
||||
0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
|
||||
0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
|
||||
0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
|
||||
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
|
||||
0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
|
||||
0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
|
||||
0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
|
||||
0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
|
||||
0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
|
||||
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
|
||||
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
|
||||
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
|
||||
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
|
||||
};
|
||||
|
||||
|
||||
void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc)
|
||||
{
|
||||
*crc = FLAC__crc8_table[*crc ^ data];
|
||||
}
|
||||
|
||||
void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc)
|
||||
{
|
||||
while(len--)
|
||||
*crc = FLAC__crc8_table[*crc ^ *data++];
|
||||
}
|
||||
|
||||
FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len)
|
||||
{
|
||||
FLAC__uint8 crc = 0;
|
||||
|
||||
while(len--)
|
||||
crc = FLAC__crc8_table[crc ^ *data++];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
unsigned FLAC__crc16(const FLAC__byte *data, unsigned len)
|
||||
{
|
||||
unsigned crc = 0;
|
||||
|
||||
while(len--)
|
||||
crc = ((crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]) & 0xffff;
|
||||
|
||||
return crc;
|
||||
}
|
435
FLAC/fixed.c
435
FLAC/fixed.c
|
@ -1,435 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "private/bitmath.h"
|
||||
#include "private/fixed.h"
|
||||
#include "FLAC/assert.h"
|
||||
|
||||
#ifndef M_LN2
|
||||
/* math.h in VC++ doesn't seem to have this (how Microsoft is that?) */
|
||||
#define M_LN2 0.69314718055994530942
|
||||
#endif
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#define min(x,y) ((x) < (y)? (x) : (y))
|
||||
|
||||
#ifdef local_abs
|
||||
#undef local_abs
|
||||
#endif
|
||||
#define local_abs(x) ((unsigned)((x)<0? -(x) : (x)))
|
||||
|
||||
#ifdef FLAC__INTEGER_ONLY_LIBRARY
|
||||
/* rbps stands for residual bits per sample
|
||||
*
|
||||
* (ln(2) * err)
|
||||
* rbps = log (-----------)
|
||||
* 2 ( n )
|
||||
*/
|
||||
static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n)
|
||||
{
|
||||
FLAC__uint32 rbps;
|
||||
unsigned bits; /* the number of bits required to represent a number */
|
||||
int fracbits; /* the number of bits of rbps that comprise the fractional part */
|
||||
|
||||
FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint));
|
||||
FLAC__ASSERT(err > 0);
|
||||
FLAC__ASSERT(n > 0);
|
||||
|
||||
FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE);
|
||||
if(err <= n)
|
||||
return 0;
|
||||
/*
|
||||
* The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
|
||||
* These allow us later to know we won't lose too much precision in the
|
||||
* fixed-point division (err<<fracbits)/n.
|
||||
*/
|
||||
|
||||
fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2(err)+1);
|
||||
|
||||
err <<= fracbits;
|
||||
err /= n;
|
||||
/* err now holds err/n with fracbits fractional bits */
|
||||
|
||||
/*
|
||||
* Whittle err down to 16 bits max. 16 significant bits is enough for
|
||||
* our purposes.
|
||||
*/
|
||||
FLAC__ASSERT(err > 0);
|
||||
bits = FLAC__bitmath_ilog2(err)+1;
|
||||
if(bits > 16) {
|
||||
err >>= (bits-16);
|
||||
fracbits -= (bits-16);
|
||||
}
|
||||
rbps = (FLAC__uint32)err;
|
||||
|
||||
/* Multiply by fixed-point version of ln(2), with 16 fractional bits */
|
||||
rbps *= FLAC__FP_LN2;
|
||||
fracbits += 16;
|
||||
FLAC__ASSERT(fracbits >= 0);
|
||||
|
||||
/* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */
|
||||
{
|
||||
const int f = fracbits & 3;
|
||||
if(f) {
|
||||
rbps >>= f;
|
||||
fracbits -= f;
|
||||
}
|
||||
}
|
||||
|
||||
rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1));
|
||||
|
||||
if(rbps == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The return value must have 16 fractional bits. Since the whole part
|
||||
* of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
|
||||
* must be >= -3, these assertion allows us to be able to shift rbps
|
||||
* left if necessary to get 16 fracbits without losing any bits of the
|
||||
* whole part of rbps.
|
||||
*
|
||||
* There is a slight chance due to accumulated error that the whole part
|
||||
* will require 6 bits, so we use 6 in the assertion. Really though as
|
||||
* long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
|
||||
*/
|
||||
FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6);
|
||||
FLAC__ASSERT(fracbits >= -3);
|
||||
|
||||
/* now shift the decimal point into place */
|
||||
if(fracbits < 16)
|
||||
return rbps << (16-fracbits);
|
||||
else if(fracbits > 16)
|
||||
return rbps >> (fracbits-16);
|
||||
else
|
||||
return rbps;
|
||||
}
|
||||
|
||||
static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n)
|
||||
{
|
||||
FLAC__uint32 rbps;
|
||||
unsigned bits; /* the number of bits required to represent a number */
|
||||
int fracbits; /* the number of bits of rbps that comprise the fractional part */
|
||||
|
||||
FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint));
|
||||
FLAC__ASSERT(err > 0);
|
||||
FLAC__ASSERT(n > 0);
|
||||
|
||||
FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE);
|
||||
if(err <= n)
|
||||
return 0;
|
||||
/*
|
||||
* The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
|
||||
* These allow us later to know we won't lose too much precision in the
|
||||
* fixed-point division (err<<fracbits)/n.
|
||||
*/
|
||||
|
||||
fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2_wide(err)+1);
|
||||
|
||||
err <<= fracbits;
|
||||
err /= n;
|
||||
/* err now holds err/n with fracbits fractional bits */
|
||||
|
||||
/*
|
||||
* Whittle err down to 16 bits max. 16 significant bits is enough for
|
||||
* our purposes.
|
||||
*/
|
||||
FLAC__ASSERT(err > 0);
|
||||
bits = FLAC__bitmath_ilog2_wide(err)+1;
|
||||
if(bits > 16) {
|
||||
err >>= (bits-16);
|
||||
fracbits -= (bits-16);
|
||||
}
|
||||
rbps = (FLAC__uint32)err;
|
||||
|
||||
/* Multiply by fixed-point version of ln(2), with 16 fractional bits */
|
||||
rbps *= FLAC__FP_LN2;
|
||||
fracbits += 16;
|
||||
FLAC__ASSERT(fracbits >= 0);
|
||||
|
||||
/* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */
|
||||
{
|
||||
const int f = fracbits & 3;
|
||||
if(f) {
|
||||
rbps >>= f;
|
||||
fracbits -= f;
|
||||
}
|
||||
}
|
||||
|
||||
rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1));
|
||||
|
||||
if(rbps == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The return value must have 16 fractional bits. Since the whole part
|
||||
* of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
|
||||
* must be >= -3, these assertion allows us to be able to shift rbps
|
||||
* left if necessary to get 16 fracbits without losing any bits of the
|
||||
* whole part of rbps.
|
||||
*
|
||||
* There is a slight chance due to accumulated error that the whole part
|
||||
* will require 6 bits, so we use 6 in the assertion. Really though as
|
||||
* long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
|
||||
*/
|
||||
FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6);
|
||||
FLAC__ASSERT(fracbits >= -3);
|
||||
|
||||
/* now shift the decimal point into place */
|
||||
if(fracbits < 16)
|
||||
return rbps << (16-fracbits);
|
||||
else if(fracbits > 16)
|
||||
return rbps >> (fracbits-16);
|
||||
else
|
||||
return rbps;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#else
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#endif
|
||||
{
|
||||
FLAC__int32 last_error_0 = data[-1];
|
||||
FLAC__int32 last_error_1 = data[-1] - data[-2];
|
||||
FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
|
||||
FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
|
||||
FLAC__int32 error, save;
|
||||
FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
|
||||
unsigned i, order;
|
||||
|
||||
for(i = 0; i < data_len; i++) {
|
||||
error = data[i] ; total_error_0 += local_abs(error); save = error;
|
||||
error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
|
||||
error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
|
||||
error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error;
|
||||
error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
|
||||
}
|
||||
|
||||
if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
|
||||
order = 0;
|
||||
else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
|
||||
order = 1;
|
||||
else if(total_error_2 < min(total_error_3, total_error_4))
|
||||
order = 2;
|
||||
else if(total_error_3 < total_error_4)
|
||||
order = 3;
|
||||
else
|
||||
order = 4;
|
||||
|
||||
/* Estimate the expected number of bits per residual signal sample. */
|
||||
/* 'total_error*' is linearly related to the variance of the residual */
|
||||
/* signal, so we use it directly to compute E(|x|) */
|
||||
FLAC__ASSERT(data_len > 0 || total_error_0 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_1 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_2 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
#else
|
||||
residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_integerized(total_error_0, data_len) : 0;
|
||||
residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_integerized(total_error_1, data_len) : 0;
|
||||
residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_integerized(total_error_2, data_len) : 0;
|
||||
residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_integerized(total_error_3, data_len) : 0;
|
||||
residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_integerized(total_error_4, data_len) : 0;
|
||||
#endif
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#else
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#endif
|
||||
{
|
||||
FLAC__int32 last_error_0 = data[-1];
|
||||
FLAC__int32 last_error_1 = data[-1] - data[-2];
|
||||
FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
|
||||
FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
|
||||
FLAC__int32 error, save;
|
||||
/* total_error_* are 64-bits to avoid overflow when encoding
|
||||
* erratic signals when the bits-per-sample and blocksize are
|
||||
* large.
|
||||
*/
|
||||
FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
|
||||
unsigned i, order;
|
||||
|
||||
for(i = 0; i < data_len; i++) {
|
||||
error = data[i] ; total_error_0 += local_abs(error); save = error;
|
||||
error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
|
||||
error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
|
||||
error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error;
|
||||
error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
|
||||
}
|
||||
|
||||
if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
|
||||
order = 0;
|
||||
else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
|
||||
order = 1;
|
||||
else if(total_error_2 < min(total_error_3, total_error_4))
|
||||
order = 2;
|
||||
else if(total_error_3 < total_error_4)
|
||||
order = 3;
|
||||
else
|
||||
order = 4;
|
||||
|
||||
/* Estimate the expected number of bits per residual signal sample. */
|
||||
/* 'total_error*' is linearly related to the variance of the residual */
|
||||
/* signal, so we use it directly to compute E(|x|) */
|
||||
FLAC__ASSERT(data_len > 0 || total_error_0 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_1 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_2 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
/* with MSVC you have to spoon feed it the casting */
|
||||
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
#else
|
||||
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
#endif
|
||||
#else
|
||||
residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_wide_integerized(total_error_0, data_len) : 0;
|
||||
residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_wide_integerized(total_error_1, data_len) : 0;
|
||||
residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_wide_integerized(total_error_2, data_len) : 0;
|
||||
residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_wide_integerized(total_error_3, data_len) : 0;
|
||||
residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_wide_integerized(total_error_4, data_len) : 0;
|
||||
#endif
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[])
|
||||
{
|
||||
const int idata_len = (int)data_len;
|
||||
int i;
|
||||
|
||||
switch(order) {
|
||||
case 0:
|
||||
FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
|
||||
memcpy(residual, data, sizeof(residual[0])*data_len);
|
||||
break;
|
||||
case 1:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
residual[i] = data[i] - data[i-1];
|
||||
break;
|
||||
case 2:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
residual[i] = data[i] - (data[i-1] << 1) + data[i-2];
|
||||
#else
|
||||
residual[i] = data[i] - 2*data[i-1] + data[i-2];
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3];
|
||||
#else
|
||||
residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3];
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4];
|
||||
#else
|
||||
residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4];
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[])
|
||||
{
|
||||
int i, idata_len = (int)data_len;
|
||||
|
||||
switch(order) {
|
||||
case 0:
|
||||
FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
|
||||
memcpy(data, residual, sizeof(residual[0])*data_len);
|
||||
break;
|
||||
case 1:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
data[i] = residual[i] + data[i-1];
|
||||
break;
|
||||
case 2:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
data[i] = residual[i] + (data[i-1]<<1) - data[i-2];
|
||||
#else
|
||||
data[i] = residual[i] + 2*data[i-1] - data[i-2];
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
data[i] = residual[i] + (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) + data[i-3];
|
||||
#else
|
||||
data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3];
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
data[i] = residual[i] + ((data[i-1]+data[i-3])<<2) - ((data[i-2]<<2) + (data[i-2]<<1)) - data[i-4];
|
||||
#else
|
||||
data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4];
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
}
|
||||
}
|
593
FLAC/format.c
593
FLAC/format.c
|
@ -1,593 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* for qsort() */
|
||||
#include <string.h> /* for memset() */
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/format.h"
|
||||
#include "private/format.h"
|
||||
|
||||
#ifndef FLaC__INLINE
|
||||
#define FLaC__INLINE
|
||||
#endif
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
|
||||
#ifdef _MSC_VER
|
||||
#define FLAC__U64L(x) x
|
||||
#else
|
||||
#define FLAC__U64L(x) x##LLU
|
||||
#endif
|
||||
|
||||
/* VERSION should come from configure */
|
||||
FLAC_API const char *FLAC__VERSION_STRING = "1.2.1";
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINW32__
|
||||
/* yet one more hack because of MSVC6: */
|
||||
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.1.2 20070917";
|
||||
#else
|
||||
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20070917";
|
||||
#endif
|
||||
|
||||
FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
|
||||
FLAC_API const unsigned FLAC__STREAM_SYNC = 0x664C6143;
|
||||
FLAC_API const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */
|
||||
|
||||
FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff);
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC = 0x3ffe;
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
|
||||
|
||||
FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[] = {
|
||||
"PARTITIONED_RICE",
|
||||
"PARTITIONED_RICE2"
|
||||
};
|
||||
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00;
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02;
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10;
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40;
|
||||
|
||||
FLAC_API const char * const FLAC__SubframeTypeString[] = {
|
||||
"CONSTANT",
|
||||
"VERBATIM",
|
||||
"FIXED",
|
||||
"LPC"
|
||||
};
|
||||
|
||||
FLAC_API const char * const FLAC__ChannelAssignmentString[] = {
|
||||
"INDEPENDENT",
|
||||
"LEFT_SIDE",
|
||||
"RIGHT_SIDE",
|
||||
"MID_SIDE"
|
||||
};
|
||||
|
||||
FLAC_API const char * const FLAC__FrameNumberTypeString[] = {
|
||||
"FRAME_NUMBER_TYPE_FRAME_NUMBER",
|
||||
"FRAME_NUMBER_TYPE_SAMPLE_NUMBER"
|
||||
};
|
||||
|
||||
FLAC_API const char * const FLAC__MetadataTypeString[] = {
|
||||
"STREAMINFO",
|
||||
"PADDING",
|
||||
"APPLICATION",
|
||||
"SEEKTABLE",
|
||||
"VORBIS_COMMENT",
|
||||
"CUESHEET",
|
||||
"PICTURE"
|
||||
};
|
||||
|
||||
FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = {
|
||||
"Other",
|
||||
"32x32 pixels 'file icon' (PNG only)",
|
||||
"Other file icon",
|
||||
"Cover (front)",
|
||||
"Cover (back)",
|
||||
"Leaflet page",
|
||||
"Media (e.g. label side of CD)",
|
||||
"Lead artist/lead performer/soloist",
|
||||
"Artist/performer",
|
||||
"Conductor",
|
||||
"Band/Orchestra",
|
||||
"Composer",
|
||||
"Lyricist/text writer",
|
||||
"Recording Location",
|
||||
"During recording",
|
||||
"During performance",
|
||||
"Movie/video screen capture",
|
||||
"A bright coloured fish",
|
||||
"Illustration",
|
||||
"Band/artist logotype",
|
||||
"Publisher/Studio logotype"
|
||||
};
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
|
||||
{
|
||||
if(sample_rate == 0 || sample_rate > FLAC__MAX_SAMPLE_RATE) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate)
|
||||
{
|
||||
if(
|
||||
!FLAC__format_sample_rate_is_valid(sample_rate) ||
|
||||
(
|
||||
sample_rate >= (1u << 16) &&
|
||||
!(sample_rate % 1000 == 0 || sample_rate % 10 == 0)
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table)
|
||||
{
|
||||
unsigned i;
|
||||
FLAC__uint64 prev_sample_number = 0;
|
||||
FLAC__bool got_prev = false;
|
||||
|
||||
FLAC__ASSERT(0 != seek_table);
|
||||
|
||||
for(i = 0; i < seek_table->num_points; i++) {
|
||||
if(got_prev) {
|
||||
if(
|
||||
seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER &&
|
||||
seek_table->points[i].sample_number <= prev_sample_number
|
||||
)
|
||||
return false;
|
||||
}
|
||||
prev_sample_number = seek_table->points[i].sample_number;
|
||||
got_prev = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* used as the sort predicate for qsort() */
|
||||
static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLAC__StreamMetadata_SeekPoint *r)
|
||||
{
|
||||
/* we don't just 'return l->sample_number - r->sample_number' since the result (FLAC__int64) might overflow an 'int' */
|
||||
if(l->sample_number == r->sample_number)
|
||||
return 0;
|
||||
else if(l->sample_number < r->sample_number)
|
||||
return -1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table)
|
||||
{
|
||||
unsigned i, j;
|
||||
FLAC__bool first;
|
||||
|
||||
FLAC__ASSERT(0 != seek_table);
|
||||
|
||||
/* sort the seekpoints */
|
||||
qsort(seek_table->points, seek_table->num_points, sizeof(FLAC__StreamMetadata_SeekPoint), (int (*)(const void *, const void *))seekpoint_compare_);
|
||||
|
||||
/* uniquify the seekpoints */
|
||||
first = true;
|
||||
for(i = j = 0; i < seek_table->num_points; i++) {
|
||||
if(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
|
||||
if(!first) {
|
||||
if(seek_table->points[i].sample_number == seek_table->points[j-1].sample_number)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
seek_table->points[j++] = seek_table->points[i];
|
||||
}
|
||||
|
||||
for(i = j; i < seek_table->num_points; i++) {
|
||||
seek_table->points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
|
||||
seek_table->points[i].stream_offset = 0;
|
||||
seek_table->points[i].frame_samples = 0;
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
/*
|
||||
* also disallows non-shortest-form encodings, c.f.
|
||||
* http://www.unicode.org/versions/corrigendum1.html
|
||||
* and a more clear explanation at the end of this section:
|
||||
* http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
*/
|
||||
static FLaC__INLINE unsigned utf8len_(const FLAC__byte *utf8)
|
||||
{
|
||||
FLAC__ASSERT(0 != utf8);
|
||||
if ((utf8[0] & 0x80) == 0) {
|
||||
return 1;
|
||||
}
|
||||
else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80) {
|
||||
if ((utf8[0] & 0xFE) == 0xC0) /* overlong sequence check */
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80) {
|
||||
if (utf8[0] == 0xE0 && (utf8[1] & 0xE0) == 0x80) /* overlong sequence check */
|
||||
return 0;
|
||||
/* illegal surrogates check (U+D800...U+DFFF and U+FFFE...U+FFFF) */
|
||||
if (utf8[0] == 0xED && (utf8[1] & 0xE0) == 0xA0) /* D800-DFFF */
|
||||
return 0;
|
||||
if (utf8[0] == 0xEF && utf8[1] == 0xBF && (utf8[2] & 0xFE) == 0xBE) /* FFFE-FFFF */
|
||||
return 0;
|
||||
return 3;
|
||||
}
|
||||
else if ((utf8[0] & 0xF8) == 0xF0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80) {
|
||||
if (utf8[0] == 0xF0 && (utf8[1] & 0xF0) == 0x80) /* overlong sequence check */
|
||||
return 0;
|
||||
return 4;
|
||||
}
|
||||
else if ((utf8[0] & 0xFC) == 0xF8 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80) {
|
||||
if (utf8[0] == 0xF8 && (utf8[1] & 0xF8) == 0x80) /* overlong sequence check */
|
||||
return 0;
|
||||
return 5;
|
||||
}
|
||||
else if ((utf8[0] & 0xFE) == 0xFC && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80 && (utf8[5] & 0xC0) == 0x80) {
|
||||
if (utf8[0] == 0xFC && (utf8[1] & 0xFC) == 0x80) /* overlong sequence check */
|
||||
return 0;
|
||||
return 6;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name)
|
||||
{
|
||||
char c;
|
||||
for(c = *name; c; c = *(++name))
|
||||
if(c < 0x20 || c == 0x3d || c > 0x7d)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length)
|
||||
{
|
||||
if(length == (unsigned)(-1)) {
|
||||
while(*value) {
|
||||
unsigned n = utf8len_(value);
|
||||
if(n == 0)
|
||||
return false;
|
||||
value += n;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const FLAC__byte *end = value + length;
|
||||
while(value < end) {
|
||||
unsigned n = utf8len_(value);
|
||||
if(n == 0)
|
||||
return false;
|
||||
value += n;
|
||||
}
|
||||
if(value != end)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length)
|
||||
{
|
||||
const FLAC__byte *s, *end;
|
||||
|
||||
for(s = entry, end = s + length; s < end && *s != '='; s++) {
|
||||
if(*s < 0x20 || *s > 0x7D)
|
||||
return false;
|
||||
}
|
||||
if(s == end)
|
||||
return false;
|
||||
|
||||
s++; /* skip '=' */
|
||||
|
||||
while(s < end) {
|
||||
unsigned n = utf8len_(s);
|
||||
if(n == 0)
|
||||
return false;
|
||||
s += n;
|
||||
}
|
||||
if(s != end)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
if(check_cd_da_subset) {
|
||||
if(cue_sheet->lead_in < 2 * 44100) {
|
||||
if(violation) *violation = "CD-DA cue sheet must have a lead-in length of at least 2 seconds";
|
||||
return false;
|
||||
}
|
||||
if(cue_sheet->lead_in % 588 != 0) {
|
||||
if(violation) *violation = "CD-DA cue sheet lead-in length must be evenly divisible by 588 samples";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(cue_sheet->num_tracks == 0) {
|
||||
if(violation) *violation = "cue sheet must have at least one track (the lead-out)";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(check_cd_da_subset && cue_sheet->tracks[cue_sheet->num_tracks-1].number != 170) {
|
||||
if(violation) *violation = "CD-DA cue sheet must have a lead-out track number 170 (0xAA)";
|
||||
return false;
|
||||
}
|
||||
|
||||
for(i = 0; i < cue_sheet->num_tracks; i++) {
|
||||
if(cue_sheet->tracks[i].number == 0) {
|
||||
if(violation) *violation = "cue sheet may not have a track number 0";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(check_cd_da_subset) {
|
||||
if(!((cue_sheet->tracks[i].number >= 1 && cue_sheet->tracks[i].number <= 99) || cue_sheet->tracks[i].number == 170)) {
|
||||
if(violation) *violation = "CD-DA cue sheet track number must be 1-99 or 170";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(check_cd_da_subset && cue_sheet->tracks[i].offset % 588 != 0) {
|
||||
if(violation) {
|
||||
if(i == cue_sheet->num_tracks-1) /* the lead-out track... */
|
||||
*violation = "CD-DA cue sheet lead-out offset must be evenly divisible by 588 samples";
|
||||
else
|
||||
*violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(i < cue_sheet->num_tracks - 1) {
|
||||
if(cue_sheet->tracks[i].num_indices == 0) {
|
||||
if(violation) *violation = "cue sheet track must have at least one index point";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(cue_sheet->tracks[i].indices[0].number > 1) {
|
||||
if(violation) *violation = "cue sheet track's first index number must be 0 or 1";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(j = 0; j < cue_sheet->tracks[i].num_indices; j++) {
|
||||
if(check_cd_da_subset && cue_sheet->tracks[i].indices[j].offset % 588 != 0) {
|
||||
if(violation) *violation = "CD-DA cue sheet track index offset must be evenly divisible by 588 samples";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(j > 0) {
|
||||
if(cue_sheet->tracks[i].indices[j].number != cue_sheet->tracks[i].indices[j-1].number + 1) {
|
||||
if(violation) *violation = "cue sheet track index numbers must increase by 1";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation)
|
||||
{
|
||||
char *p;
|
||||
FLAC__byte *b;
|
||||
|
||||
for(p = picture->mime_type; *p; p++) {
|
||||
if(*p < 0x20 || *p > 0x7e) {
|
||||
if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(b = picture->description; *b; ) {
|
||||
unsigned n = utf8len_(b);
|
||||
if(n == 0) {
|
||||
if(violation) *violation = "description string must be valid UTF-8";
|
||||
return false;
|
||||
}
|
||||
b += n;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* These routines are private to libFLAC
|
||||
*/
|
||||
unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order)
|
||||
{
|
||||
return
|
||||
FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(
|
||||
FLAC__format_get_max_rice_partition_order_from_blocksize(blocksize),
|
||||
blocksize,
|
||||
predictor_order
|
||||
);
|
||||
}
|
||||
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize)
|
||||
{
|
||||
unsigned max_rice_partition_order = 0;
|
||||
while(!(blocksize & 1)) {
|
||||
max_rice_partition_order++;
|
||||
blocksize >>= 1;
|
||||
}
|
||||
return min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order);
|
||||
}
|
||||
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order)
|
||||
{
|
||||
unsigned max_rice_partition_order = limit;
|
||||
|
||||
while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order)
|
||||
max_rice_partition_order--;
|
||||
|
||||
FLAC__ASSERT(
|
||||
(max_rice_partition_order == 0 && blocksize >= predictor_order) ||
|
||||
(max_rice_partition_order > 0 && blocksize >> max_rice_partition_order > predictor_order)
|
||||
);
|
||||
|
||||
return max_rice_partition_order;
|
||||
}
|
||||
|
||||
void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
|
||||
{
|
||||
FLAC__ASSERT(0 != object);
|
||||
|
||||
object->parameters = 0;
|
||||
object->raw_bits = 0;
|
||||
object->capacity_by_order = 0;
|
||||
}
|
||||
|
||||
void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
|
||||
{
|
||||
FLAC__ASSERT(0 != object);
|
||||
|
||||
if(0 != object->parameters)
|
||||
free(object->parameters);
|
||||
if(0 != object->raw_bits)
|
||||
free(object->raw_bits);
|
||||
FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order)
|
||||
{
|
||||
FLAC__ASSERT(0 != object);
|
||||
|
||||
FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits));
|
||||
|
||||
if(object->capacity_by_order < max_partition_order) {
|
||||
if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned) << max_partition_order)))
|
||||
return false;
|
||||
if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned) << max_partition_order)))
|
||||
return false;
|
||||
memset(object->raw_bits, 0, sizeof(unsigned)*(1 << max_partition_order));
|
||||
object->capacity_by_order = max_partition_order;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,568 +0,0 @@
|
|||
; vim:filetype=nasm ts=8
|
||||
|
||||
; libFLAC - Free Lossless Audio Codec library
|
||||
; Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions
|
||||
; are met:
|
||||
;
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
;
|
||||
; - Redistributions in binary form must reproduce the above copyright
|
||||
; notice, this list of conditions and the following disclaimer in the
|
||||
; documentation and/or other materials provided with the distribution.
|
||||
;
|
||||
; - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
; contributors may be used to endorse or promote products derived from
|
||||
; this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
%include "ia32/nasm.h"
|
||||
|
||||
data_section
|
||||
|
||||
cextern FLAC__crc16_table ; unsigned FLAC__crc16_table[256];
|
||||
cextern bitreader_read_from_client_ ; FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br);
|
||||
|
||||
cglobal FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap
|
||||
|
||||
code_section
|
||||
|
||||
|
||||
; **********************************************************************
|
||||
;
|
||||
; void FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter)
|
||||
;
|
||||
; Some details like assertions and other checking is performed by the caller.
|
||||
ALIGN 16
|
||||
cident FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap
|
||||
|
||||
;ASSERT(0 != br);
|
||||
;ASSERT(0 != br->buffer);
|
||||
; WATCHOUT: code only works if sizeof(brword)==32; we can make things much faster with this assertion
|
||||
;ASSERT(FLAC__BITS_PER_WORD == 32);
|
||||
;ASSERT(parameter < 32);
|
||||
; the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it
|
||||
|
||||
;; peppered throughout the code at major checkpoints are keys like this as to where things are at that point in time
|
||||
;; [esp + 16] unsigned parameter
|
||||
;; [esp + 12] unsigned nvals
|
||||
;; [esp + 8] int vals[]
|
||||
;; [esp + 4] FLAC__BitReader *br
|
||||
mov eax, [esp + 12] ; if(nvals == 0)
|
||||
test eax, eax
|
||||
ja .nvals_gt_0
|
||||
mov eax, 1 ; return true;
|
||||
ret
|
||||
|
||||
.nvals_gt_0:
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
sub esp, 4
|
||||
;; [esp + 36] unsigned parameter
|
||||
;; [esp + 32] unsigned nvals
|
||||
;; [esp + 28] int vals[]
|
||||
;; [esp + 24] FLAC__BitReader *br
|
||||
;; [esp] ucbits
|
||||
mov ebp, [esp + 24] ; ebp <- br == br->buffer
|
||||
mov esi, [ebp + 16] ; esi <- br->consumed_words (aka 'cwords' in the C version)
|
||||
mov ecx, [ebp + 20] ; ecx <- br->consumed_bits (aka 'cbits' in the C version)
|
||||
xor edi, edi ; edi <- 0 'uval'
|
||||
;; ecx cbits
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
;; [ebp] br->buffer
|
||||
;; [ebp + 8] br->words
|
||||
;; [ebp + 12] br->bytes
|
||||
;; [ebp + 16] br->consumed_words
|
||||
;; [ebp + 20] br->consumed_bits
|
||||
;; [ebp + 24] br->read_crc
|
||||
;; [ebp + 28] br->crc16_align
|
||||
|
||||
; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
|
||||
mov eax, [ebp + 8] ; eax <- br->words
|
||||
sub eax, esi ; eax <- br->words-cwords
|
||||
shl eax, 2 ; eax <- (br->words-cwords)*FLAC__BYTES_PER_WORD
|
||||
add eax, [ebp + 12] ; eax <- (br->words-cwords)*FLAC__BYTES_PER_WORD + br->bytes
|
||||
shl eax, 3 ; eax <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8
|
||||
sub eax, ecx ; eax <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits
|
||||
mov [esp], eax ; ucbits <- eax
|
||||
|
||||
ALIGN 16
|
||||
.val_loop: ; while(1) {
|
||||
|
||||
;
|
||||
; read unary part
|
||||
;
|
||||
.unary_loop: ; while(1) {
|
||||
;; ecx cbits
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
cmp esi, [ebp + 8] ; while(cwords < br->words) /* if we've not consumed up to a partial tail word... */
|
||||
jae near .c1_next1
|
||||
.c1_loop: ; {
|
||||
mov ebx, [ebp]
|
||||
mov eax, [ebx + 4*esi] ; b = br->buffer[cwords]
|
||||
mov edx, eax ; edx = br->buffer[cwords] (saved for later use)
|
||||
shl eax, cl ; b = br->buffer[cwords] << cbits
|
||||
test eax, eax ; (still have to test since cbits may be 0, thus ZF not updated for shl eax,0)
|
||||
jz near .c1_next2 ; if(b) {
|
||||
bsr ebx, eax
|
||||
not ebx
|
||||
and ebx, 31 ; ebx = 'i' = # of leading 0 bits in 'b' (eax)
|
||||
add ecx, ebx ; cbits += i;
|
||||
add edi, ebx ; uval += i;
|
||||
add ecx, byte 1 ; cbits++; /* skip over stop bit */
|
||||
test ecx, ~31
|
||||
jz near .break1 ; if(cbits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(cbits == FLAC__BITS_PER_WORD) */
|
||||
; crc16_update_word_(br, br->buffer[cwords]);
|
||||
push edi ; [need more registers]
|
||||
bswap edx ; edx = br->buffer[cwords] swapped; now we can CRC the bytes from LSByte to MSByte which makes things much easier
|
||||
mov ecx, [ebp + 28] ; ecx <- br->crc16_align
|
||||
mov eax, [ebp + 24] ; ax <- br->read_crc (a.k.a. crc)
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
mov edi, _FLAC__crc16_table
|
||||
%else
|
||||
mov edi, FLAC__crc16_table
|
||||
%endif
|
||||
;; eax (ax) crc a.k.a. br->read_crc
|
||||
;; ebx (bl) intermediate result index into FLAC__crc16_table[]
|
||||
;; ecx br->crc16_align
|
||||
;; edx byteswapped brword to CRC
|
||||
;; esi cwords
|
||||
;; edi unsigned FLAC__crc16_table[]
|
||||
;; ebp br
|
||||
test ecx, ecx ; switch(br->crc16_align) ...
|
||||
jnz .c0b4 ; [br->crc16_align is 0 the vast majority of the time so we optimize the common case]
|
||||
.c0b0: xor dl, ah ; dl <- (crc>>8)^(word>>24)
|
||||
movzx ebx, dl
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word>>24)]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word>>24)]
|
||||
.c0b1: xor dh, ah ; dh <- (crc>>8)^((word>>16)&0xff))
|
||||
movzx ebx, dh
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
|
||||
shr edx, 16
|
||||
.c0b2: xor dl, ah ; dl <- (crc>>8)^((word>>8)&0xff))
|
||||
movzx ebx, dl
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
|
||||
.c0b3: xor dh, ah ; dh <- (crc>>8)^(word&0xff)
|
||||
movzx ebx, dh
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word&0xff)]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word&0xff)]
|
||||
movzx eax, ax
|
||||
mov [ebp + 24], eax ; br->read_crc <- crc
|
||||
pop edi
|
||||
|
||||
add esi, byte 1 ; cwords++;
|
||||
xor ecx, ecx ; cbits = 0;
|
||||
; }
|
||||
jmp near .break1 ; goto break1;
|
||||
;; this section relocated out of the way for performance
|
||||
.c0b4:
|
||||
mov [ebp + 28], dword 0 ; br->crc16_align <- 0
|
||||
cmp ecx, 8
|
||||
je .c0b1
|
||||
shr edx, 16
|
||||
cmp ecx, 16
|
||||
je .c0b2
|
||||
jmp .c0b3
|
||||
|
||||
;; this section relocated out of the way for performance
|
||||
.c1b4:
|
||||
mov [ebp + 28], dword 0 ; br->crc16_align <- 0
|
||||
cmp ecx, 8
|
||||
je .c1b1
|
||||
shr edx, 16
|
||||
cmp ecx, 16
|
||||
je .c1b2
|
||||
jmp .c1b3
|
||||
|
||||
.c1_next2: ; } else {
|
||||
;; ecx cbits
|
||||
;; edx current brword 'b'
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
add edi, 32
|
||||
sub edi, ecx ; uval += FLAC__BITS_PER_WORD - cbits;
|
||||
; crc16_update_word_(br, br->buffer[cwords]);
|
||||
push edi ; [need more registers]
|
||||
bswap edx ; edx = br->buffer[cwords] swapped; now we can CRC the bytes from LSByte to MSByte which makes things much easier
|
||||
mov ecx, [ebp + 28] ; ecx <- br->crc16_align
|
||||
mov eax, [ebp + 24] ; ax <- br->read_crc (a.k.a. crc)
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
mov edi, _FLAC__crc16_table
|
||||
%else
|
||||
mov edi, FLAC__crc16_table
|
||||
%endif
|
||||
;; eax (ax) crc a.k.a. br->read_crc
|
||||
;; ebx (bl) intermediate result index into FLAC__crc16_table[]
|
||||
;; ecx br->crc16_align
|
||||
;; edx byteswapped brword to CRC
|
||||
;; esi cwords
|
||||
;; edi unsigned FLAC__crc16_table[]
|
||||
;; ebp br
|
||||
test ecx, ecx ; switch(br->crc16_align) ...
|
||||
jnz .c1b4 ; [br->crc16_align is 0 the vast majority of the time so we optimize the common case]
|
||||
.c1b0: xor dl, ah ; dl <- (crc>>8)^(word>>24)
|
||||
movzx ebx, dl
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word>>24)]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word>>24)]
|
||||
.c1b1: xor dh, ah ; dh <- (crc>>8)^((word>>16)&0xff))
|
||||
movzx ebx, dh
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
|
||||
shr edx, 16
|
||||
.c1b2: xor dl, ah ; dl <- (crc>>8)^((word>>8)&0xff))
|
||||
movzx ebx, dl
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
|
||||
.c1b3: xor dh, ah ; dh <- (crc>>8)^(word&0xff)
|
||||
movzx ebx, dh
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word&0xff)]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word&0xff)]
|
||||
movzx eax, ax
|
||||
mov [ebp + 24], eax ; br->read_crc <- crc
|
||||
pop edi
|
||||
|
||||
add esi, byte 1 ; cwords++;
|
||||
xor ecx, ecx ; cbits = 0;
|
||||
; /* didn't find stop bit yet, have to keep going... */
|
||||
; }
|
||||
|
||||
cmp esi, [ebp + 8] ; } while(cwords < br->words) /* if we've not consumed up to a partial tail word... */
|
||||
jb near .c1_loop
|
||||
|
||||
.c1_next1:
|
||||
; at this point we've eaten up all the whole words; have to try
|
||||
; reading through any tail bytes before calling the read callback.
|
||||
; this is a repeat of the above logic adjusted for the fact we
|
||||
; don't have a whole word. note though if the client is feeding
|
||||
; us data a byte at a time (unlikely), br->consumed_bits may not
|
||||
; be zero.
|
||||
;; ecx cbits
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
mov edx, [ebp + 12] ; edx <- br->bytes
|
||||
test edx, edx
|
||||
jz .read1 ; if(br->bytes) { [NOTE: this case is rare so it doesn't have to be all that fast ]
|
||||
mov ebx, [ebp]
|
||||
shl edx, 3 ; edx <- const unsigned end = br->bytes * 8;
|
||||
mov eax, [ebx + 4*esi] ; b = br->buffer[cwords]
|
||||
xchg edx, ecx ; [edx <- cbits , ecx <- end]
|
||||
mov ebx, 0xffffffff ; ebx <- FLAC__WORD_ALL_ONES
|
||||
shr ebx, cl ; ebx <- FLAC__WORD_ALL_ONES >> end
|
||||
not ebx ; ebx <- ~(FLAC__WORD_ALL_ONES >> end)
|
||||
xchg edx, ecx ; [edx <- end , ecx <- cbits]
|
||||
and eax, ebx ; b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end));
|
||||
shl eax, cl ; b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end)) << cbits;
|
||||
test eax, eax ; (still have to test since cbits may be 0, thus ZF not updated for shl eax,0)
|
||||
jz .c1_next3 ; if(b) {
|
||||
bsr ebx, eax
|
||||
not ebx
|
||||
and ebx, 31 ; ebx = 'i' = # of leading 0 bits in 'b' (eax)
|
||||
add ecx, ebx ; cbits += i;
|
||||
add edi, ebx ; uval += i;
|
||||
add ecx, byte 1 ; cbits++; /* skip over stop bit */
|
||||
jmp short .break1 ; goto break1;
|
||||
.c1_next3: ; } else {
|
||||
sub edi, ecx
|
||||
add edi, edx ; uval += end - cbits;
|
||||
add ecx, edx ; cbits += end
|
||||
; /* didn't find stop bit yet, have to keep going... */
|
||||
; }
|
||||
; }
|
||||
.read1:
|
||||
; flush registers and read; bitreader_read_from_client_() does
|
||||
; not touch br->consumed_bits at all but we still need to set
|
||||
; it in case it fails and we have to return false.
|
||||
;; ecx cbits
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
mov [ebp + 16], esi ; br->consumed_words = cwords;
|
||||
mov [ebp + 20], ecx ; br->consumed_bits = cbits;
|
||||
push ecx ; /* save */
|
||||
push ebp ; /* push br argument */
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
call _bitreader_read_from_client_
|
||||
%else
|
||||
call bitreader_read_from_client_
|
||||
%endif
|
||||
pop edx ; /* discard, unused */
|
||||
pop ecx ; /* restore */
|
||||
mov esi, [ebp + 16] ; cwords = br->consumed_words;
|
||||
; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
|
||||
mov ebx, [ebp + 8] ; ebx <- br->words
|
||||
sub ebx, esi ; ebx <- br->words-cwords
|
||||
shl ebx, 2 ; ebx <- (br->words-cwords)*FLAC__BYTES_PER_WORD
|
||||
add ebx, [ebp + 12] ; ebx <- (br->words-cwords)*FLAC__BYTES_PER_WORD + br->bytes
|
||||
shl ebx, 3 ; ebx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8
|
||||
sub ebx, ecx ; ebx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits
|
||||
add ebx, edi ; ebx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits + uval
|
||||
; + uval to offset our count by the # of unary bits already
|
||||
; consumed before the read, because we will add these back
|
||||
; in all at once at break1
|
||||
mov [esp], ebx ; ucbits <- ebx
|
||||
test eax, eax ; if(!bitreader_read_from_client_(br))
|
||||
jnz near .unary_loop
|
||||
jmp .end ; return false; /* eax (the return value) is already 0 */
|
||||
; } /* end while(1) unary part */
|
||||
|
||||
ALIGN 16
|
||||
.break1:
|
||||
;; ecx cbits
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
;; [esp] ucbits
|
||||
sub [esp], edi ; ucbits -= uval;
|
||||
sub dword [esp], byte 1 ; ucbits--; /* account for stop bit */
|
||||
|
||||
;
|
||||
; read binary part
|
||||
;
|
||||
mov ebx, [esp + 36] ; ebx <- parameter
|
||||
test ebx, ebx ; if(parameter) {
|
||||
jz near .break2
|
||||
.read2:
|
||||
cmp [esp], ebx ; while(ucbits < parameter) {
|
||||
jae .c2_next1
|
||||
; flush registers and read; bitreader_read_from_client_() does
|
||||
; not touch br->consumed_bits at all but we still need to set
|
||||
; it in case it fails and we have to return false.
|
||||
mov [ebp + 16], esi ; br->consumed_words = cwords;
|
||||
mov [ebp + 20], ecx ; br->consumed_bits = cbits;
|
||||
push ecx ; /* save */
|
||||
push ebp ; /* push br argument */
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
call _bitreader_read_from_client_
|
||||
%else
|
||||
call bitreader_read_from_client_
|
||||
%endif
|
||||
pop edx ; /* discard, unused */
|
||||
pop ecx ; /* restore */
|
||||
mov esi, [ebp + 16] ; cwords = br->consumed_words;
|
||||
; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
|
||||
mov edx, [ebp + 8] ; edx <- br->words
|
||||
sub edx, esi ; edx <- br->words-cwords
|
||||
shl edx, 2 ; edx <- (br->words-cwords)*FLAC__BYTES_PER_WORD
|
||||
add edx, [ebp + 12] ; edx <- (br->words-cwords)*FLAC__BYTES_PER_WORD + br->bytes
|
||||
shl edx, 3 ; edx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8
|
||||
sub edx, ecx ; edx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits
|
||||
mov [esp], edx ; ucbits <- edx
|
||||
test eax, eax ; if(!bitreader_read_from_client_(br))
|
||||
jnz .read2
|
||||
jmp .end ; return false; /* eax (the return value) is already 0 */
|
||||
; }
|
||||
.c2_next1:
|
||||
;; ebx parameter
|
||||
;; ecx cbits
|
||||
;; esi cwords
|
||||
;; edi uval
|
||||
;; ebp br
|
||||
;; [esp] ucbits
|
||||
cmp esi, [ebp + 8] ; if(cwords < br->words) { /* if we've not consumed up to a partial tail word... */
|
||||
jae near .c2_next2
|
||||
test ecx, ecx ; if(cbits) {
|
||||
jz near .c2_next3 ; /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
|
||||
mov eax, 32
|
||||
mov edx, [ebp]
|
||||
sub eax, ecx ; const unsigned n = FLAC__BITS_PER_WORD - cbits;
|
||||
mov edx, [edx + 4*esi] ; const brword word = br->buffer[cwords];
|
||||
cmp ebx, eax ; if(parameter < n) {
|
||||
jae .c2_next4
|
||||
; uval <<= parameter;
|
||||
; uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-parameter);
|
||||
shl edx, cl
|
||||
xchg ebx, ecx
|
||||
shld edi, edx, cl
|
||||
add ebx, ecx ; cbits += parameter;
|
||||
xchg ebx, ecx ; ebx <- parameter, ecx <- cbits
|
||||
jmp .break2 ; goto break2;
|
||||
; }
|
||||
.c2_next4:
|
||||
; uval <<= n;
|
||||
; uval |= word & (FLAC__WORD_ALL_ONES >> cbits);
|
||||
%if 1
|
||||
rol edx, cl ; @@@@@@OPT: may be faster to use rol to save edx so we can restore it for CRC'ing
|
||||
; @@@@@@OPT: or put parameter in ch instead and free up ebx completely again
|
||||
%else
|
||||
shl edx, cl
|
||||
%endif
|
||||
xchg eax, ecx
|
||||
shld edi, edx, cl
|
||||
xchg eax, ecx
|
||||
%if 1
|
||||
ror edx, cl ; restored.
|
||||
%else
|
||||
mov edx, [ebp]
|
||||
mov edx, [edx + 4*esi]
|
||||
%endif
|
||||
; crc16_update_word_(br, br->buffer[cwords]);
|
||||
push edi ; [need more registers]
|
||||
push ebx ; [need more registers]
|
||||
push eax ; [need more registers]
|
||||
bswap edx ; edx = br->buffer[cwords] swapped; now we can CRC the bytes from LSByte to MSByte which makes things much easier
|
||||
mov ecx, [ebp + 28] ; ecx <- br->crc16_align
|
||||
mov eax, [ebp + 24] ; ax <- br->read_crc (a.k.a. crc)
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
mov edi, _FLAC__crc16_table
|
||||
%else
|
||||
mov edi, FLAC__crc16_table
|
||||
%endif
|
||||
;; eax (ax) crc a.k.a. br->read_crc
|
||||
;; ebx (bl) intermediate result index into FLAC__crc16_table[]
|
||||
;; ecx br->crc16_align
|
||||
;; edx byteswapped brword to CRC
|
||||
;; esi cwords
|
||||
;; edi unsigned FLAC__crc16_table[]
|
||||
;; ebp br
|
||||
test ecx, ecx ; switch(br->crc16_align) ...
|
||||
jnz .c2b4 ; [br->crc16_align is 0 the vast majority of the time so we optimize the common case]
|
||||
.c2b0: xor dl, ah ; dl <- (crc>>8)^(word>>24)
|
||||
movzx ebx, dl
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word>>24)]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word>>24)]
|
||||
.c2b1: xor dh, ah ; dh <- (crc>>8)^((word>>16)&0xff))
|
||||
movzx ebx, dh
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
|
||||
shr edx, 16
|
||||
.c2b2: xor dl, ah ; dl <- (crc>>8)^((word>>8)&0xff))
|
||||
movzx ebx, dl
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
|
||||
.c2b3: xor dh, ah ; dh <- (crc>>8)^(word&0xff)
|
||||
movzx ebx, dh
|
||||
mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word&0xff)]
|
||||
shl eax, 8 ; ax <- (crc<<8)
|
||||
xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word&0xff)]
|
||||
movzx eax, ax
|
||||
mov [ebp + 24], eax ; br->read_crc <- crc
|
||||
pop eax
|
||||
pop ebx
|
||||
pop edi
|
||||
add esi, byte 1 ; cwords++;
|
||||
mov ecx, ebx
|
||||
sub ecx, eax ; cbits = parameter - n;
|
||||
jz .break2 ; if(cbits) { /* parameter > n, i.e. if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
|
||||
; uval <<= cbits;
|
||||
; uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits));
|
||||
mov eax, [ebp]
|
||||
mov eax, [eax + 4*esi]
|
||||
shld edi, eax, cl
|
||||
; }
|
||||
jmp .break2 ; goto break2;
|
||||
|
||||
;; this section relocated out of the way for performance
|
||||
.c2b4:
|
||||
mov [ebp + 28], dword 0 ; br->crc16_align <- 0
|
||||
cmp ecx, 8
|
||||
je .c2b1
|
||||
shr edx, 16
|
||||
cmp ecx, 16
|
||||
je .c2b2
|
||||
jmp .c2b3
|
||||
|
||||
.c2_next3: ; } else {
|
||||
mov ecx, ebx ; cbits = parameter;
|
||||
; uval <<= cbits;
|
||||
; uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits));
|
||||
mov eax, [ebp]
|
||||
mov eax, [eax + 4*esi]
|
||||
shld edi, eax, cl
|
||||
jmp .break2 ; goto break2;
|
||||
; }
|
||||
.c2_next2: ; } else {
|
||||
; in this case we're starting our read at a partial tail word;
|
||||
; the reader has guaranteed that we have at least 'parameter'
|
||||
; bits available to read, which makes this case simpler.
|
||||
; uval <<= parameter;
|
||||
; if(cbits) {
|
||||
; /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
|
||||
; uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-parameter);
|
||||
; cbits += parameter;
|
||||
; goto break2;
|
||||
; } else {
|
||||
; cbits = parameter;
|
||||
; uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits);
|
||||
; goto break2;
|
||||
; }
|
||||
; the above is much shorter in assembly:
|
||||
mov eax, [ebp]
|
||||
mov eax, [eax + 4*esi] ; eax <- br->buffer[cwords]
|
||||
shl eax, cl ; eax <- br->buffer[cwords] << cbits
|
||||
add ecx, ebx ; cbits += parameter
|
||||
xchg ebx, ecx ; ebx <- cbits, ecx <- parameter
|
||||
shld edi, eax, cl ; uval <<= parameter <<< 'parameter' bits of tail word
|
||||
xchg ebx, ecx ; ebx <- parameter, ecx <- cbits
|
||||
; }
|
||||
; }
|
||||
.break2:
|
||||
sub [esp], ebx ; ucbits -= parameter;
|
||||
|
||||
;
|
||||
; compose the value
|
||||
;
|
||||
mov ebx, [esp + 28] ; ebx <- vals
|
||||
mov edx, edi ; edx <- uval
|
||||
and edi, 1 ; edi <- uval & 1
|
||||
shr edx, 1 ; edx <- uval >> 1
|
||||
neg edi ; edi <- -(int)(uval & 1)
|
||||
xor edx, edi ; edx <- (uval >> 1 ^ -(int)(uval & 1))
|
||||
mov [ebx], edx ; *vals <- edx
|
||||
sub dword [esp + 32], byte 1 ; --nvals;
|
||||
jz .finished ; if(nvals == 0) /* jump to finish */
|
||||
xor edi, edi ; uval = 0;
|
||||
add dword [esp + 28], 4 ; ++vals
|
||||
jmp .val_loop ; }
|
||||
|
||||
.finished:
|
||||
mov [ebp + 16], esi ; br->consumed_words = cwords;
|
||||
mov [ebp + 20], ecx ; br->consumed_bits = cbits;
|
||||
mov eax, 1
|
||||
.end:
|
||||
add esp, 4
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
end:
|
||||
|
||||
%ifdef OBJ_FORMAT_elf
|
||||
section .note.GNU-stack noalloc
|
||||
%endif
|
|
@ -1,121 +0,0 @@
|
|||
; vim:filetype=nasm ts=8
|
||||
|
||||
; libFLAC - Free Lossless Audio Codec library
|
||||
; Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions
|
||||
; are met:
|
||||
;
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
;
|
||||
; - Redistributions in binary form must reproduce the above copyright
|
||||
; notice, this list of conditions and the following disclaimer in the
|
||||
; documentation and/or other materials provided with the distribution.
|
||||
;
|
||||
; - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
; contributors may be used to endorse or promote products derived from
|
||||
; this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
%include "ia32/nasm.h"
|
||||
|
||||
data_section
|
||||
|
||||
cglobal FLAC__cpu_have_cpuid_asm_ia32
|
||||
cglobal FLAC__cpu_info_asm_ia32
|
||||
cglobal FLAC__cpu_info_extended_amd_asm_ia32
|
||||
|
||||
code_section
|
||||
|
||||
; **********************************************************************
|
||||
;
|
||||
; FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32()
|
||||
;
|
||||
|
||||
cident FLAC__cpu_have_cpuid_asm_ia32
|
||||
push ebx
|
||||
pushfd
|
||||
pop eax
|
||||
mov edx, eax
|
||||
xor eax, 0x00200000
|
||||
push eax
|
||||
popfd
|
||||
pushfd
|
||||
pop eax
|
||||
cmp eax, edx
|
||||
jz .no_cpuid
|
||||
mov eax, 1
|
||||
jmp .end
|
||||
.no_cpuid:
|
||||
xor eax, eax
|
||||
.end:
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
; **********************************************************************
|
||||
;
|
||||
; void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx)
|
||||
;
|
||||
|
||||
cident FLAC__cpu_info_asm_ia32
|
||||
;[esp + 8] == flags_edx
|
||||
;[esp + 12] == flags_ecx
|
||||
|
||||
push ebx
|
||||
call FLAC__cpu_have_cpuid_asm_ia32
|
||||
test eax, eax
|
||||
jz .no_cpuid
|
||||
mov eax, 1
|
||||
cpuid
|
||||
mov ebx, [esp + 8]
|
||||
mov [ebx], edx
|
||||
mov ebx, [esp + 12]
|
||||
mov [ebx], ecx
|
||||
jmp .end
|
||||
.no_cpuid:
|
||||
xor eax, eax
|
||||
mov ebx, [esp + 8]
|
||||
mov [ebx], eax
|
||||
mov ebx, [esp + 12]
|
||||
mov [ebx], eax
|
||||
.end:
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
cident FLAC__cpu_info_extended_amd_asm_ia32
|
||||
push ebx
|
||||
call FLAC__cpu_have_cpuid_asm_ia32
|
||||
test eax, eax
|
||||
jz .no_cpuid
|
||||
mov eax, 0x80000000
|
||||
cpuid
|
||||
cmp eax, 0x80000001
|
||||
jb .no_cpuid
|
||||
mov eax, 0x80000001
|
||||
cpuid
|
||||
mov eax, edx
|
||||
jmp .end
|
||||
.no_cpuid:
|
||||
xor eax, eax
|
||||
.end:
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
end:
|
||||
|
||||
%ifdef OBJ_FORMAT_elf
|
||||
section .note.GNU-stack noalloc
|
||||
%endif
|
|
@ -1,312 +0,0 @@
|
|||
; vim:filetype=nasm ts=8
|
||||
|
||||
; libFLAC - Free Lossless Audio Codec library
|
||||
; Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions
|
||||
; are met:
|
||||
;
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
;
|
||||
; - Redistributions in binary form must reproduce the above copyright
|
||||
; notice, this list of conditions and the following disclaimer in the
|
||||
; documentation and/or other materials provided with the distribution.
|
||||
;
|
||||
; - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
; contributors may be used to endorse or promote products derived from
|
||||
; this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
%include "ia32/nasm.h"
|
||||
|
||||
data_section
|
||||
|
||||
cglobal FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
|
||||
|
||||
code_section
|
||||
|
||||
; **********************************************************************
|
||||
;
|
||||
; unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 *data, unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
; {
|
||||
; FLAC__int32 last_error_0 = data[-1];
|
||||
; FLAC__int32 last_error_1 = data[-1] - data[-2];
|
||||
; FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
|
||||
; FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
|
||||
; FLAC__int32 error, save;
|
||||
; FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
|
||||
; unsigned i, order;
|
||||
;
|
||||
; for(i = 0; i < data_len; i++) {
|
||||
; error = data[i] ; total_error_0 += local_abs(error); save = error;
|
||||
; error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
|
||||
; error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
|
||||
; error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error;
|
||||
; error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
|
||||
; }
|
||||
;
|
||||
; if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
|
||||
; order = 0;
|
||||
; else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
|
||||
; order = 1;
|
||||
; else if(total_error_2 < min(total_error_3, total_error_4))
|
||||
; order = 2;
|
||||
; else if(total_error_3 < total_error_4)
|
||||
; order = 3;
|
||||
; else
|
||||
; order = 4;
|
||||
;
|
||||
; residual_bits_per_sample[0] = (FLAC__float)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[1] = (FLAC__float)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[2] = (FLAC__float)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[3] = (FLAC__float)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[4] = (FLAC__float)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
;
|
||||
; return order;
|
||||
; }
|
||||
ALIGN 16
|
||||
cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
|
||||
|
||||
; esp + 36 == data[]
|
||||
; esp + 40 == data_len
|
||||
; esp + 44 == residual_bits_per_sample[]
|
||||
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
sub esp, byte 16
|
||||
; qword [esp] == temp space for loading FLAC__uint64s to FPU regs
|
||||
|
||||
; ebx == &data[i]
|
||||
; ecx == loop counter (i)
|
||||
; ebp == order
|
||||
; mm0 == total_error_1:total_error_0
|
||||
; mm1 == total_error_2:total_error_3
|
||||
; mm2 == :total_error_4
|
||||
; mm3 == last_error_1:last_error_0
|
||||
; mm4 == last_error_2:last_error_3
|
||||
|
||||
mov ecx, [esp + 40] ; ecx = data_len
|
||||
test ecx, ecx
|
||||
jz near .data_len_is_0
|
||||
|
||||
mov ebx, [esp + 36] ; ebx = data[]
|
||||
movd mm3, [ebx - 4] ; mm3 = 0:last_error_0
|
||||
movd mm2, [ebx - 8] ; mm2 = 0:data[-2]
|
||||
movd mm1, [ebx - 12] ; mm1 = 0:data[-3]
|
||||
movd mm0, [ebx - 16] ; mm0 = 0:data[-4]
|
||||
movq mm5, mm3 ; mm5 = 0:last_error_0
|
||||
psubd mm5, mm2 ; mm5 = 0:last_error_1
|
||||
punpckldq mm3, mm5 ; mm3 = last_error_1:last_error_0
|
||||
psubd mm2, mm1 ; mm2 = 0:data[-2] - data[-3]
|
||||
psubd mm5, mm2 ; mm5 = 0:last_error_2
|
||||
movq mm4, mm5 ; mm4 = 0:last_error_2
|
||||
psubd mm4, mm2 ; mm4 = 0:last_error_2 - (data[-2] - data[-3])
|
||||
paddd mm4, mm1 ; mm4 = 0:last_error_2 - (data[-2] - 2 * data[-3])
|
||||
psubd mm4, mm0 ; mm4 = 0:last_error_3
|
||||
punpckldq mm4, mm5 ; mm4 = last_error_2:last_error_3
|
||||
pxor mm0, mm0 ; mm0 = total_error_1:total_error_0
|
||||
pxor mm1, mm1 ; mm1 = total_error_2:total_error_3
|
||||
pxor mm2, mm2 ; mm2 = 0:total_error_4
|
||||
|
||||
ALIGN 16
|
||||
.loop:
|
||||
movd mm7, [ebx] ; mm7 = 0:error_0
|
||||
add ebx, byte 4
|
||||
movq mm6, mm7 ; mm6 = 0:error_0
|
||||
psubd mm7, mm3 ; mm7 = :error_1
|
||||
punpckldq mm6, mm7 ; mm6 = error_1:error_0
|
||||
movq mm5, mm6 ; mm5 = error_1:error_0
|
||||
movq mm7, mm6 ; mm7 = error_1:error_0
|
||||
psubd mm5, mm3 ; mm5 = error_2:
|
||||
movq mm3, mm6 ; mm3 = error_1:error_0
|
||||
psrad mm6, 31
|
||||
pxor mm7, mm6
|
||||
psubd mm7, mm6 ; mm7 = abs(error_1):abs(error_0)
|
||||
paddd mm0, mm7 ; mm0 = total_error_1:total_error_0
|
||||
movq mm6, mm5 ; mm6 = error_2:
|
||||
psubd mm5, mm4 ; mm5 = error_3:
|
||||
punpckhdq mm5, mm6 ; mm5 = error_2:error_3
|
||||
movq mm7, mm5 ; mm7 = error_2:error_3
|
||||
movq mm6, mm5 ; mm6 = error_2:error_3
|
||||
psubd mm5, mm4 ; mm5 = :error_4
|
||||
movq mm4, mm6 ; mm4 = error_2:error_3
|
||||
psrad mm6, 31
|
||||
pxor mm7, mm6
|
||||
psubd mm7, mm6 ; mm7 = abs(error_2):abs(error_3)
|
||||
paddd mm1, mm7 ; mm1 = total_error_2:total_error_3
|
||||
movq mm6, mm5 ; mm6 = :error_4
|
||||
psrad mm5, 31
|
||||
pxor mm6, mm5
|
||||
psubd mm6, mm5 ; mm6 = :abs(error_4)
|
||||
paddd mm2, mm6 ; mm2 = :total_error_4
|
||||
|
||||
dec ecx
|
||||
jnz short .loop
|
||||
|
||||
; if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
|
||||
; order = 0;
|
||||
; else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
|
||||
; order = 1;
|
||||
; else if(total_error_2 < min(total_error_3, total_error_4))
|
||||
; order = 2;
|
||||
; else if(total_error_3 < total_error_4)
|
||||
; order = 3;
|
||||
; else
|
||||
; order = 4;
|
||||
movq mm3, mm0 ; mm3 = total_error_1:total_error_0
|
||||
movd edi, mm2 ; edi = total_error_4
|
||||
movd esi, mm1 ; esi = total_error_3
|
||||
movd eax, mm0 ; eax = total_error_0
|
||||
punpckhdq mm1, mm1 ; mm1 = total_error_2:total_error_2
|
||||
punpckhdq mm3, mm3 ; mm3 = total_error_1:total_error_1
|
||||
movd edx, mm1 ; edx = total_error_2
|
||||
movd ecx, mm3 ; ecx = total_error_1
|
||||
|
||||
xor ebx, ebx
|
||||
xor ebp, ebp
|
||||
inc ebx
|
||||
cmp ecx, eax
|
||||
cmovb eax, ecx ; eax = min(total_error_0, total_error_1)
|
||||
cmovbe ebp, ebx
|
||||
inc ebx
|
||||
cmp edx, eax
|
||||
cmovb eax, edx ; eax = min(total_error_0, total_error_1, total_error_2)
|
||||
cmovbe ebp, ebx
|
||||
inc ebx
|
||||
cmp esi, eax
|
||||
cmovb eax, esi ; eax = min(total_error_0, total_error_1, total_error_2, total_error_3)
|
||||
cmovbe ebp, ebx
|
||||
inc ebx
|
||||
cmp edi, eax
|
||||
cmovb eax, edi ; eax = min(total_error_0, total_error_1, total_error_2, total_error_3, total_error_4)
|
||||
cmovbe ebp, ebx
|
||||
movd ebx, mm0 ; ebx = total_error_0
|
||||
emms
|
||||
|
||||
; residual_bits_per_sample[0] = (FLAC__float)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[1] = (FLAC__float)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[2] = (FLAC__float)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[3] = (FLAC__float)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
; residual_bits_per_sample[4] = (FLAC__float)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
xor eax, eax
|
||||
fild dword [esp + 40] ; ST = data_len (NOTE: assumes data_len is <2gigs)
|
||||
.rbps_0:
|
||||
test ebx, ebx
|
||||
jz .total_error_0_is_0
|
||||
fld1 ; ST = 1.0 data_len
|
||||
mov [esp], ebx
|
||||
mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_0
|
||||
mov ebx, [esp + 44]
|
||||
fild qword [esp] ; ST = total_error_0 1.0 data_len
|
||||
fdiv st2 ; ST = total_error_0/data_len 1.0 data_len
|
||||
fldln2 ; ST = ln2 total_error_0/data_len 1.0 data_len
|
||||
fmulp st1 ; ST = ln2*total_error_0/data_len 1.0 data_len
|
||||
fyl2x ; ST = log2(ln2*total_error_0/data_len) data_len
|
||||
fstp dword [ebx] ; residual_bits_per_sample[0] = log2(ln2*total_error_0/data_len) ST = data_len
|
||||
jmp short .rbps_1
|
||||
.total_error_0_is_0:
|
||||
mov ebx, [esp + 44]
|
||||
mov [ebx], eax ; residual_bits_per_sample[0] = 0.0
|
||||
.rbps_1:
|
||||
test ecx, ecx
|
||||
jz .total_error_1_is_0
|
||||
fld1 ; ST = 1.0 data_len
|
||||
mov [esp], ecx
|
||||
mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_1
|
||||
fild qword [esp] ; ST = total_error_1 1.0 data_len
|
||||
fdiv st2 ; ST = total_error_1/data_len 1.0 data_len
|
||||
fldln2 ; ST = ln2 total_error_1/data_len 1.0 data_len
|
||||
fmulp st1 ; ST = ln2*total_error_1/data_len 1.0 data_len
|
||||
fyl2x ; ST = log2(ln2*total_error_1/data_len) data_len
|
||||
fstp dword [ebx + 4] ; residual_bits_per_sample[1] = log2(ln2*total_error_1/data_len) ST = data_len
|
||||
jmp short .rbps_2
|
||||
.total_error_1_is_0:
|
||||
mov [ebx + 4], eax ; residual_bits_per_sample[1] = 0.0
|
||||
.rbps_2:
|
||||
test edx, edx
|
||||
jz .total_error_2_is_0
|
||||
fld1 ; ST = 1.0 data_len
|
||||
mov [esp], edx
|
||||
mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_2
|
||||
fild qword [esp] ; ST = total_error_2 1.0 data_len
|
||||
fdiv st2 ; ST = total_error_2/data_len 1.0 data_len
|
||||
fldln2 ; ST = ln2 total_error_2/data_len 1.0 data_len
|
||||
fmulp st1 ; ST = ln2*total_error_2/data_len 1.0 data_len
|
||||
fyl2x ; ST = log2(ln2*total_error_2/data_len) data_len
|
||||
fstp dword [ebx + 8] ; residual_bits_per_sample[2] = log2(ln2*total_error_2/data_len) ST = data_len
|
||||
jmp short .rbps_3
|
||||
.total_error_2_is_0:
|
||||
mov [ebx + 8], eax ; residual_bits_per_sample[2] = 0.0
|
||||
.rbps_3:
|
||||
test esi, esi
|
||||
jz .total_error_3_is_0
|
||||
fld1 ; ST = 1.0 data_len
|
||||
mov [esp], esi
|
||||
mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_3
|
||||
fild qword [esp] ; ST = total_error_3 1.0 data_len
|
||||
fdiv st2 ; ST = total_error_3/data_len 1.0 data_len
|
||||
fldln2 ; ST = ln2 total_error_3/data_len 1.0 data_len
|
||||
fmulp st1 ; ST = ln2*total_error_3/data_len 1.0 data_len
|
||||
fyl2x ; ST = log2(ln2*total_error_3/data_len) data_len
|
||||
fstp dword [ebx + 12] ; residual_bits_per_sample[3] = log2(ln2*total_error_3/data_len) ST = data_len
|
||||
jmp short .rbps_4
|
||||
.total_error_3_is_0:
|
||||
mov [ebx + 12], eax ; residual_bits_per_sample[3] = 0.0
|
||||
.rbps_4:
|
||||
test edi, edi
|
||||
jz .total_error_4_is_0
|
||||
fld1 ; ST = 1.0 data_len
|
||||
mov [esp], edi
|
||||
mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_4
|
||||
fild qword [esp] ; ST = total_error_4 1.0 data_len
|
||||
fdiv st2 ; ST = total_error_4/data_len 1.0 data_len
|
||||
fldln2 ; ST = ln2 total_error_4/data_len 1.0 data_len
|
||||
fmulp st1 ; ST = ln2*total_error_4/data_len 1.0 data_len
|
||||
fyl2x ; ST = log2(ln2*total_error_4/data_len) data_len
|
||||
fstp dword [ebx + 16] ; residual_bits_per_sample[4] = log2(ln2*total_error_4/data_len) ST = data_len
|
||||
jmp short .rbps_end
|
||||
.total_error_4_is_0:
|
||||
mov [ebx + 16], eax ; residual_bits_per_sample[4] = 0.0
|
||||
.rbps_end:
|
||||
fstp st0 ; ST = [empty]
|
||||
jmp short .end
|
||||
.data_len_is_0:
|
||||
; data_len == 0, so residual_bits_per_sample[*] = 0.0
|
||||
xor ebp, ebp
|
||||
mov edi, [esp + 44]
|
||||
mov [edi], ebp
|
||||
mov [edi + 4], ebp
|
||||
mov [edi + 8], ebp
|
||||
mov [edi + 12], ebp
|
||||
mov [edi + 16], ebp
|
||||
add ebp, byte 4 ; order = 4
|
||||
|
||||
.end:
|
||||
mov eax, ebp ; return order
|
||||
add esp, byte 16
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
end:
|
||||
|
||||
%ifdef OBJ_FORMAT_elf
|
||||
section .note.GNU-stack noalloc
|
||||
%endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,75 +0,0 @@
|
|||
; libFLAC - Free Lossless Audio Codec library
|
||||
; Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions
|
||||
; are met:
|
||||
;
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
;
|
||||
; - Redistributions in binary form must reproduce the above copyright
|
||||
; notice, this list of conditions and the following disclaimer in the
|
||||
; documentation and/or other materials provided with the distribution.
|
||||
;
|
||||
; - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
; contributors may be used to endorse or promote products derived from
|
||||
; this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
bits 32
|
||||
|
||||
%ifdef OBJ_FORMAT_win32
|
||||
%define FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
%idefine code_section section .text align=16 class=CODE use32
|
||||
%idefine data_section section .data align=32 class=DATA use32
|
||||
%idefine bss_section section .bss align=32 class=DATA use32
|
||||
%elifdef OBJ_FORMAT_aout
|
||||
%define FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
%idefine code_section section .text
|
||||
%idefine data_section section .data
|
||||
%idefine bss_section section .bss
|
||||
%elifdef OBJ_FORMAT_aoutb
|
||||
%define FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
%idefine code_section section .text
|
||||
%idefine data_section section .data
|
||||
%idefine bss_section section .bss
|
||||
%elifdef OBJ_FORMAT_elf
|
||||
%idefine code_section section .text align=16
|
||||
%idefine data_section section .data align=32
|
||||
%idefine bss_section section .bss align=32
|
||||
%else
|
||||
%error unsupported object format!
|
||||
%endif
|
||||
|
||||
%imacro cglobal 1
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
global _%1
|
||||
%else
|
||||
global %1
|
||||
%endif
|
||||
%endmacro
|
||||
|
||||
%imacro cextern 1
|
||||
%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
|
||||
extern _%1
|
||||
%else
|
||||
extern %1
|
||||
%endif
|
||||
%endmacro
|
||||
|
||||
%imacro cident 1
|
||||
_%1:
|
||||
%1:
|
||||
%endmacro
|
|
@ -1,159 +0,0 @@
|
|||
; vim:filetype=nasm ts=8
|
||||
|
||||
; libFLAC - Free Lossless Audio Codec library
|
||||
; Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions
|
||||
; are met:
|
||||
;
|
||||
; - Redistributions of source code must retain the above copyright
|
||||
; notice, this list of conditions and the following disclaimer.
|
||||
;
|
||||
; - Redistributions in binary form must reproduce the above copyright
|
||||
; notice, this list of conditions and the following disclaimer in the
|
||||
; documentation and/or other materials provided with the distribution.
|
||||
;
|
||||
; - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
; contributors may be used to endorse or promote products derived from
|
||||
; this software without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
%include "ia32/nasm.h"
|
||||
|
||||
data_section
|
||||
|
||||
cglobal precompute_partition_info_sums_32bit_asm_ia32_
|
||||
|
||||
code_section
|
||||
|
||||
|
||||
; **********************************************************************
|
||||
;
|
||||
; void FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter)
|
||||
; void precompute_partition_info_sums_32bit_(
|
||||
; const FLAC__int32 residual[],
|
||||
; FLAC__uint64 abs_residual_partition_sums[],
|
||||
; unsigned blocksize,
|
||||
; unsigned predictor_order,
|
||||
; unsigned min_partition_order,
|
||||
; unsigned max_partition_order
|
||||
; )
|
||||
;
|
||||
ALIGN 16
|
||||
cident precompute_partition_info_sums_32bit_asm_ia32_
|
||||
|
||||
;; peppered throughout the code at major checkpoints are keys like this as to where things are at that point in time
|
||||
;; [esp + 4] const FLAC__int32 residual[]
|
||||
;; [esp + 8] FLAC__uint64 abs_residual_partition_sums[]
|
||||
;; [esp + 12] unsigned blocksize
|
||||
;; [esp + 16] unsigned predictor_order
|
||||
;; [esp + 20] unsigned min_partition_order
|
||||
;; [esp + 24] unsigned max_partition_order
|
||||
push ebp
|
||||
push ebx
|
||||
push esi
|
||||
push edi
|
||||
sub esp, 8
|
||||
;; [esp + 28] const FLAC__int32 residual[]
|
||||
;; [esp + 32] FLAC__uint64 abs_residual_partition_sums[]
|
||||
;; [esp + 36] unsigned blocksize
|
||||
;; [esp + 40] unsigned predictor_order
|
||||
;; [esp + 44] unsigned min_partition_order
|
||||
;; [esp + 48] unsigned max_partition_order
|
||||
;; [esp] partitions
|
||||
;; [esp + 4] default_partition_samples
|
||||
|
||||
mov ecx, [esp + 48]
|
||||
mov eax, 1
|
||||
shl eax, cl
|
||||
mov [esp], eax ; [esp] <- partitions = 1u << max_partition_order;
|
||||
mov eax, [esp + 36]
|
||||
shr eax, cl
|
||||
mov [esp + 4], eax ; [esp + 4] <- default_partition_samples = blocksize >> max_partition_order;
|
||||
|
||||
;
|
||||
; first do max_partition_order
|
||||
;
|
||||
mov edi, [esp + 4]
|
||||
sub edi, [esp + 40] ; edi <- end = (unsigned)(-(int)predictor_order) + default_partition_samples
|
||||
xor esi, esi ; esi <- residual_sample = 0
|
||||
xor ecx, ecx ; ecx <- partition = 0
|
||||
mov ebp, [esp + 28] ; ebp <- residual[]
|
||||
xor ebx, ebx ; ebx <- abs_residual_partition_sum = 0;
|
||||
; note we put the updates to 'end' and 'abs_residual_partition_sum' at the end of loop0 and in the initialization above so we could align loop0 and loop1
|
||||
ALIGN 16
|
||||
.loop0: ; for(partition = residual_sample = 0; partition < partitions; partition++) {
|
||||
.loop1: ; for( ; residual_sample < end; residual_sample++)
|
||||
mov eax, [ebp + esi * 4]
|
||||
cdq
|
||||
xor eax, edx
|
||||
sub eax, edx
|
||||
add ebx, eax ; abs_residual_partition_sum += abs(residual[residual_sample]);
|
||||
;@@@@@@ check overflow flag and abort here?
|
||||
add esi, byte 1
|
||||
cmp esi, edi ; /* since the loop will always run at least once, we can put the loop check down here */
|
||||
jb .loop1
|
||||
.next1:
|
||||
add edi, [esp + 4] ; end += default_partition_samples;
|
||||
mov eax, [esp + 32]
|
||||
mov [eax + ecx * 8], ebx ; abs_residual_partition_sums[partition] = abs_residual_partition_sum;
|
||||
mov [eax + ecx * 8 + 4], dword 0
|
||||
xor ebx, ebx ; abs_residual_partition_sum = 0;
|
||||
add ecx, byte 1
|
||||
cmp ecx, [esp] ; /* since the loop will always run at least once, we can put the loop check down here */
|
||||
jb .loop0
|
||||
.next0: ; }
|
||||
;
|
||||
; now merge partitions for lower orders
|
||||
;
|
||||
mov esi, [esp + 32] ; esi <- abs_residual_partition_sums[from_partition==0];
|
||||
mov eax, [esp]
|
||||
lea edi, [esi + eax * 8] ; edi <- abs_residual_partition_sums[to_partition==partitions];
|
||||
mov ecx, [esp + 48]
|
||||
sub ecx, byte 1 ; ecx <- partition_order = (int)max_partition_order - 1;
|
||||
ALIGN 16
|
||||
.loop2: ; for(; partition_order >= (int)min_partition_order; partition_order--) {
|
||||
cmp ecx, [esp + 44]
|
||||
jl .next2
|
||||
mov edx, 1
|
||||
shl edx, cl ; const unsigned partitions = 1u << partition_order;
|
||||
ALIGN 16
|
||||
.loop3: ; for(i = 0; i < partitions; i++) {
|
||||
mov eax, [esi]
|
||||
mov ebx, [esi + 4]
|
||||
add eax, [esi + 8]
|
||||
adc ebx, [esi + 12]
|
||||
mov [edi], eax
|
||||
mov [edi + 4], ebx ; a_r_p_s[to_partition] = a_r_p_s[from_partition] + a_r_p_s[from_partition+1];
|
||||
add esi, byte 16
|
||||
add edi, byte 8
|
||||
sub edx, byte 1
|
||||
jnz .loop3 ; }
|
||||
sub ecx, byte 1
|
||||
jmp .loop2 ; }
|
||||
.next2:
|
||||
|
||||
add esp, 8
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
end:
|
||||
|
||||
%ifdef OBJ_FORMAT_elf
|
||||
section .note.GNU-stack noalloc
|
||||
%endif
|
1377
FLAC/lpc.c
1377
FLAC/lpc.c
File diff suppressed because it is too large
Load diff
426
FLAC/md5.c
426
FLAC/md5.c
|
@ -1,426 +0,0 @@
|
|||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* for malloc() */
|
||||
#include <string.h> /* for memcpy() */
|
||||
|
||||
#include "private/md5.h"
|
||||
#include "share/alloc.h"
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#ifndef FLaC__INLINE
|
||||
#define FLaC__INLINE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*
|
||||
* Changed so as no longer to depend on Colin Plumb's `usual.h' header
|
||||
* definitions; now uses stuff from dpkg's config.h.
|
||||
* - Ian Jackson <ijackson@nyx.cs.du.edu>.
|
||||
* Still in the public domain.
|
||||
*
|
||||
* Josh Coalson: made some changes to integrate with libFLAC.
|
||||
* Still in the public domain.
|
||||
*/
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f,w,x,y,z,in,s) \
|
||||
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
|
||||
{
|
||||
register FLAC__uint32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
//@@@@@@ OPT: use bswap/intrinsics
|
||||
static void byteSwap(FLAC__uint32 *buf, unsigned words)
|
||||
{
|
||||
register FLAC__uint32 x;
|
||||
do {
|
||||
x = *buf;
|
||||
x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff);
|
||||
*buf++ = (x >> 16) | (x << 16);
|
||||
} while (--words);
|
||||
}
|
||||
static void byteSwapX16(FLAC__uint32 *buf)
|
||||
{
|
||||
register FLAC__uint32 x;
|
||||
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
|
||||
x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf = (x >> 16) | (x << 16);
|
||||
}
|
||||
#else
|
||||
#define byteSwap(buf, words)
|
||||
#define byteSwapX16(buf)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, unsigned len)
|
||||
{
|
||||
FLAC__uint32 t;
|
||||
|
||||
/* Update byte count */
|
||||
|
||||
t = ctx->bytes[0];
|
||||
if ((ctx->bytes[0] = t + len) < t)
|
||||
ctx->bytes[1]++; /* Carry from low to high */
|
||||
|
||||
t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
|
||||
if (t > len) {
|
||||
memcpy((FLAC__byte *)ctx->in + 64 - t, buf, len);
|
||||
return;
|
||||
}
|
||||
/* First chunk is an odd size */
|
||||
memcpy((FLAC__byte *)ctx->in + 64 - t, buf, t);
|
||||
byteSwapX16(ctx->in);
|
||||
FLAC__MD5Transform(ctx->buf, ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
|
||||
/* Process data in 64-byte chunks */
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteSwapX16(ctx->in);
|
||||
FLAC__MD5Transform(ctx->buf, ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
void FLAC__MD5Init(FLAC__MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bytes[0] = 0;
|
||||
ctx->bytes[1] = 0;
|
||||
|
||||
ctx->internal_buf = 0;
|
||||
ctx->capacity = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
|
||||
{
|
||||
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
|
||||
FLAC__byte *p = (FLAC__byte *)ctx->in + count;
|
||||
|
||||
/* Set the first char of padding to 0x80. There is always room. */
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 56 bytes (-8..55) */
|
||||
count = 56 - 1 - count;
|
||||
|
||||
if (count < 0) { /* Padding forces an extra block */
|
||||
memset(p, 0, count + 8);
|
||||
byteSwapX16(ctx->in);
|
||||
FLAC__MD5Transform(ctx->buf, ctx->in);
|
||||
p = (FLAC__byte *)ctx->in;
|
||||
count = 56;
|
||||
}
|
||||
memset(p, 0, count);
|
||||
byteSwap(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
ctx->in[14] = ctx->bytes[0] << 3;
|
||||
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
|
||||
FLAC__MD5Transform(ctx->buf, ctx->in);
|
||||
|
||||
byteSwap(ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
if(0 != ctx->internal_buf) {
|
||||
free(ctx->internal_buf);
|
||||
ctx->internal_buf = 0;
|
||||
ctx->capacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the incoming audio signal to a byte stream
|
||||
*/
|
||||
static void format_input_(FLAC__byte *buf, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
|
||||
{
|
||||
unsigned channel, sample;
|
||||
register FLAC__int32 a_word;
|
||||
register FLAC__byte *buf_ = buf;
|
||||
|
||||
#if WORDS_BIGENDIAN
|
||||
#else
|
||||
if(channels == 2 && bytes_per_sample == 2) {
|
||||
FLAC__int16 *buf1_ = ((FLAC__int16*)buf_) + 1;
|
||||
memcpy(buf_, signal[0], sizeof(FLAC__int32) * samples);
|
||||
for(sample = 0; sample < samples; sample++, buf1_+=2)
|
||||
*buf1_ = (FLAC__int16)signal[1][sample];
|
||||
}
|
||||
else if(channels == 1 && bytes_per_sample == 2) {
|
||||
FLAC__int16 *buf1_ = (FLAC__int16*)buf_;
|
||||
for(sample = 0; sample < samples; sample++)
|
||||
*buf1_++ = (FLAC__int16)signal[0][sample];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if(bytes_per_sample == 2) {
|
||||
if(channels == 2) {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
a_word = signal[0][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
a_word = signal[1][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
else if(channels == 1) {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
a_word = signal[0][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
for(channel = 0; channel < channels; channel++) {
|
||||
a_word = signal[channel][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(bytes_per_sample == 3) {
|
||||
if(channels == 2) {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
a_word = signal[0][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
a_word = signal[1][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
else if(channels == 1) {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
a_word = signal[0][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
for(channel = 0; channel < channels; channel++) {
|
||||
a_word = signal[channel][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(bytes_per_sample == 1) {
|
||||
if(channels == 2) {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
a_word = signal[0][sample];
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
a_word = signal[1][sample];
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
else if(channels == 1) {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
a_word = signal[0][sample];
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
for(channel = 0; channel < channels; channel++) {
|
||||
a_word = signal[channel][sample];
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* bytes_per_sample == 4, maybe optimize more later */
|
||||
for(sample = 0; sample < samples; sample++) {
|
||||
for(channel = 0; channel < channels; channel++) {
|
||||
a_word = signal[channel][sample];
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word; a_word >>= 8;
|
||||
*buf_++ = (FLAC__byte)a_word;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the incoming audio signal to a byte stream and FLAC__MD5Update it.
|
||||
*/
|
||||
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
|
||||
{
|
||||
const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample;
|
||||
|
||||
/* overflow check */
|
||||
if((size_t)channels > SIZE_MAX / (size_t)bytes_per_sample)
|
||||
return false;
|
||||
if((size_t)channels * (size_t)bytes_per_sample > SIZE_MAX / (size_t)samples)
|
||||
return false;
|
||||
|
||||
if(ctx->capacity < bytes_needed) {
|
||||
FLAC__byte *tmp = (FLAC__byte*)realloc(ctx->internal_buf, bytes_needed);
|
||||
if(0 == tmp) {
|
||||
free(ctx->internal_buf);
|
||||
if(0 == (ctx->internal_buf = (FLAC__byte*)safe_malloc_(bytes_needed)))
|
||||
return false;
|
||||
}
|
||||
ctx->internal_buf = tmp;
|
||||
ctx->capacity = bytes_needed;
|
||||
}
|
||||
|
||||
format_input_(ctx->internal_buf, signal, channels, samples, bytes_per_sample);
|
||||
|
||||
FLAC__MD5Update(ctx, ctx->internal_buf, (unsigned int)bytes_needed);
|
||||
|
||||
return true;
|
||||
}
|
221
FLAC/memory.c
221
FLAC/memory.c
|
@ -1,221 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "private/memory.h"
|
||||
#include "FLAC/assert.h"
|
||||
#include "share/alloc.h"
|
||||
|
||||
void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
|
||||
{
|
||||
void *x;
|
||||
|
||||
FLAC__ASSERT(0 != aligned_address);
|
||||
|
||||
#ifdef FLAC__ALIGN_MALLOC_DATA
|
||||
/* align on 32-byte (256-bit) boundary */
|
||||
x = safe_malloc_add_2op_(bytes, /*+*/31);
|
||||
#ifdef SIZEOF_VOIDP
|
||||
#if SIZEOF_VOIDP == 4
|
||||
/* could do *aligned_address = x + ((unsigned) (32 - (((unsigned)x) & 31))) & 31; */
|
||||
*aligned_address = (void*)(((unsigned)x + 31) & -32);
|
||||
#elif SIZEOF_VOIDP == 8
|
||||
*aligned_address = (void*)(((FLAC__uint64)x + 31) & (FLAC__uint64)(-((FLAC__int64)32)));
|
||||
#else
|
||||
# error Unsupported sizeof(void*)
|
||||
#endif
|
||||
#else
|
||||
/* there's got to be a better way to do this right for all archs */
|
||||
if(sizeof(void*) == sizeof(unsigned))
|
||||
*aligned_address = (void*)(((unsigned)x + 31) & -32);
|
||||
else if(sizeof(void*) == sizeof(FLAC__uint64))
|
||||
*aligned_address = (void*)(((FLAC__uint64)x + 31) & (FLAC__uint64)(-((FLAC__int64)32)));
|
||||
else
|
||||
return 0;
|
||||
#endif
|
||||
#else
|
||||
x = safe_malloc_(bytes);
|
||||
*aligned_address = x;
|
||||
#endif
|
||||
return x;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer)
|
||||
{
|
||||
FLAC__int32 *pu; /* unaligned pointer */
|
||||
union { /* union needed to comply with C99 pointer aliasing rules */
|
||||
FLAC__int32 *pa; /* aligned pointer */
|
||||
void *pv; /* aligned pointer alias */
|
||||
} u;
|
||||
|
||||
FLAC__ASSERT(elements > 0);
|
||||
FLAC__ASSERT(0 != unaligned_pointer);
|
||||
FLAC__ASSERT(0 != aligned_pointer);
|
||||
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
|
||||
|
||||
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * (size_t)elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(*unaligned_pointer != 0)
|
||||
free(*unaligned_pointer);
|
||||
*unaligned_pointer = pu;
|
||||
*aligned_pointer = u.pa;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer)
|
||||
{
|
||||
FLAC__uint32 *pu; /* unaligned pointer */
|
||||
union { /* union needed to comply with C99 pointer aliasing rules */
|
||||
FLAC__uint32 *pa; /* aligned pointer */
|
||||
void *pv; /* aligned pointer alias */
|
||||
} u;
|
||||
|
||||
FLAC__ASSERT(elements > 0);
|
||||
FLAC__ASSERT(0 != unaligned_pointer);
|
||||
FLAC__ASSERT(0 != aligned_pointer);
|
||||
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
|
||||
|
||||
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(*unaligned_pointer != 0)
|
||||
free(*unaligned_pointer);
|
||||
*unaligned_pointer = pu;
|
||||
*aligned_pointer = u.pa;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer)
|
||||
{
|
||||
FLAC__uint64 *pu; /* unaligned pointer */
|
||||
union { /* union needed to comply with C99 pointer aliasing rules */
|
||||
FLAC__uint64 *pa; /* aligned pointer */
|
||||
void *pv; /* aligned pointer alias */
|
||||
} u;
|
||||
|
||||
FLAC__ASSERT(elements > 0);
|
||||
FLAC__ASSERT(0 != unaligned_pointer);
|
||||
FLAC__ASSERT(0 != aligned_pointer);
|
||||
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
|
||||
|
||||
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(*unaligned_pointer != 0)
|
||||
free(*unaligned_pointer);
|
||||
*unaligned_pointer = pu;
|
||||
*aligned_pointer = u.pa;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer)
|
||||
{
|
||||
unsigned *pu; /* unaligned pointer */
|
||||
union { /* union needed to comply with C99 pointer aliasing rules */
|
||||
unsigned *pa; /* aligned pointer */
|
||||
void *pv; /* aligned pointer alias */
|
||||
} u;
|
||||
|
||||
FLAC__ASSERT(elements > 0);
|
||||
FLAC__ASSERT(0 != unaligned_pointer);
|
||||
FLAC__ASSERT(0 != aligned_pointer);
|
||||
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
|
||||
|
||||
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(*unaligned_pointer != 0)
|
||||
free(*unaligned_pointer);
|
||||
*unaligned_pointer = pu;
|
||||
*aligned_pointer = u.pa;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
|
||||
FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer)
|
||||
{
|
||||
FLAC__real *pu; /* unaligned pointer */
|
||||
union { /* union needed to comply with C99 pointer aliasing rules */
|
||||
FLAC__real *pa; /* aligned pointer */
|
||||
void *pv; /* aligned pointer alias */
|
||||
} u;
|
||||
|
||||
FLAC__ASSERT(elements > 0);
|
||||
FLAC__ASSERT(0 != unaligned_pointer);
|
||||
FLAC__ASSERT(0 != aligned_pointer);
|
||||
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
|
||||
|
||||
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
|
||||
return false;
|
||||
|
||||
pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
|
||||
if(0 == pu) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if(*unaligned_pointer != 0)
|
||||
free(*unaligned_pointer);
|
||||
*unaligned_pointer = pu;
|
||||
*aligned_pointer = u.pa;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,42 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__BITMATH_H
|
||||
#define FLAC__PRIVATE__BITMATH_H
|
||||
|
||||
#include "FLAC/ordinals.h"
|
||||
|
||||
unsigned FLAC__bitmath_ilog2(FLAC__uint32 v);
|
||||
unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v);
|
||||
unsigned FLAC__bitmath_silog2(int v);
|
||||
unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v);
|
||||
|
||||
#endif
|
|
@ -1,99 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__BITREADER_H
|
||||
#define FLAC__PRIVATE__BITREADER_H
|
||||
|
||||
#include <stdio.h> /* for FILE */
|
||||
#include "FLAC/ordinals.h"
|
||||
#include "cpu.h"
|
||||
|
||||
/*
|
||||
* opaque structure definition
|
||||
*/
|
||||
struct FLAC__BitReader;
|
||||
typedef struct FLAC__BitReader FLAC__BitReader;
|
||||
|
||||
typedef FLAC__bool (*FLAC__BitReaderReadCallback)(FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
|
||||
/*
|
||||
* construction, deletion, initialization, etc functions
|
||||
*/
|
||||
FLAC__BitReader *FLAC__bitreader_new(void);
|
||||
void FLAC__bitreader_delete(FLAC__BitReader *br);
|
||||
FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__CPUInfo cpu, FLAC__BitReaderReadCallback rcb, void *cd);
|
||||
void FLAC__bitreader_free(FLAC__BitReader *br); /* does not 'free(br)' */
|
||||
FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br);
|
||||
void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out);
|
||||
|
||||
/*
|
||||
* CRC functions
|
||||
*/
|
||||
void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed);
|
||||
FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br);
|
||||
|
||||
/*
|
||||
* info functions
|
||||
*/
|
||||
FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br);
|
||||
unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
|
||||
unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
|
||||
|
||||
/*
|
||||
* read functions
|
||||
*/
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits);
|
||||
FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/
|
||||
FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */
|
||||
FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
|
||||
FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
|
||||
FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val);
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if 0 /* UNUSED */
|
||||
FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter);
|
||||
#endif
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen);
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen);
|
||||
|
||||
FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br);
|
||||
#endif
|
|
@ -1,88 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__CPU_H
|
||||
#define FLAC__PRIVATE__CPU_H
|
||||
|
||||
#include "FLAC/ordinals.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
FLAC__CPUINFO_TYPE_IA32,
|
||||
FLAC__CPUINFO_TYPE_PPC,
|
||||
FLAC__CPUINFO_TYPE_UNKNOWN
|
||||
} FLAC__CPUInfo_Type;
|
||||
|
||||
typedef struct {
|
||||
FLAC__bool cpuid;
|
||||
FLAC__bool bswap;
|
||||
FLAC__bool cmov;
|
||||
FLAC__bool mmx;
|
||||
FLAC__bool fxsr;
|
||||
FLAC__bool sse;
|
||||
FLAC__bool sse2;
|
||||
FLAC__bool sse3;
|
||||
FLAC__bool ssse3;
|
||||
FLAC__bool _3dnow;
|
||||
FLAC__bool ext3dnow;
|
||||
FLAC__bool extmmx;
|
||||
} FLAC__CPUInfo_IA32;
|
||||
|
||||
typedef struct {
|
||||
FLAC__bool altivec;
|
||||
FLAC__bool ppc64;
|
||||
} FLAC__CPUInfo_PPC;
|
||||
|
||||
typedef struct {
|
||||
FLAC__bool use_asm;
|
||||
FLAC__CPUInfo_Type type;
|
||||
union {
|
||||
FLAC__CPUInfo_IA32 ia32;
|
||||
FLAC__CPUInfo_PPC ppc;
|
||||
} data;
|
||||
} FLAC__CPUInfo;
|
||||
|
||||
void FLAC__cpu_info(FLAC__CPUInfo *info);
|
||||
|
||||
#ifndef FLAC__NO_ASM
|
||||
#ifdef FLAC__CPU_IA32
|
||||
#ifdef FLAC__HAS_NASM
|
||||
FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void);
|
||||
void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx);
|
||||
FLAC__uint32 FLAC__cpu_info_extended_amd_asm_ia32(void);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,61 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__CRC_H
|
||||
#define FLAC__PRIVATE__CRC_H
|
||||
|
||||
#include "FLAC/ordinals.h"
|
||||
|
||||
/* 8 bit CRC generator, MSB shifted first
|
||||
** polynomial = x^8 + x^2 + x^1 + x^0
|
||||
** init = 0
|
||||
*/
|
||||
extern FLAC__byte const FLAC__crc8_table[256];
|
||||
#define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)];
|
||||
void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc);
|
||||
void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc);
|
||||
FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len);
|
||||
|
||||
/* 16 bit CRC generator, MSB shifted first
|
||||
** polynomial = x^16 + x^15 + x^2 + x^0
|
||||
** init = 0
|
||||
*/
|
||||
extern unsigned FLAC__crc16_table[256];
|
||||
|
||||
#define FLAC__CRC16_UPDATE(data, crc) (((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]))
|
||||
/* this alternate may be faster on some systems/compilers */
|
||||
#if 0
|
||||
#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff)
|
||||
#endif
|
||||
|
||||
unsigned FLAC__crc16(const FLAC__byte *data, unsigned len);
|
||||
|
||||
#endif
|
|
@ -1,97 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__FIXED_H
|
||||
#define FLAC__PRIVATE__FIXED_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "private/float.h"
|
||||
#include "FLAC/format.h"
|
||||
|
||||
/*
|
||||
* FLAC__fixed_compute_best_predictor()
|
||||
* --------------------------------------------------------------------
|
||||
* Compute the best fixed predictor and the expected bits-per-sample
|
||||
* of the residual signal for each order. The _wide() version uses
|
||||
* 64-bit integers which is statistically necessary when bits-per-
|
||||
* sample + log2(blocksize) > 30
|
||||
*
|
||||
* IN data[0,data_len-1]
|
||||
* IN data_len
|
||||
* OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
|
||||
*/
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
# ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
#else
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FLAC__fixed_compute_residual()
|
||||
* --------------------------------------------------------------------
|
||||
* Compute the residual signal obtained from sutracting the predicted
|
||||
* signal from the original.
|
||||
*
|
||||
* IN data[-order,data_len-1] original signal (NOTE THE INDICES!)
|
||||
* IN data_len length of original signal
|
||||
* IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
|
||||
* OUT residual[0,data_len-1] residual signal
|
||||
*/
|
||||
void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]);
|
||||
|
||||
/*
|
||||
* FLAC__fixed_restore_signal()
|
||||
* --------------------------------------------------------------------
|
||||
* Restore the original signal by summing the residual and the
|
||||
* predictor.
|
||||
*
|
||||
* IN residual[0,data_len-1] residual signal
|
||||
* IN data_len length of original signal
|
||||
* IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
|
||||
* *** IMPORTANT: the caller must pass in the historical samples:
|
||||
* IN data[-order,-1] previously-reconstructed historical samples
|
||||
* OUT data[0,data_len-1] original signal
|
||||
*/
|
||||
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]);
|
||||
|
||||
#endif
|
|
@ -1,97 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__FLOAT_H
|
||||
#define FLAC__PRIVATE__FLOAT_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "FLAC/ordinals.h"
|
||||
|
||||
/*
|
||||
* These typedefs make it easier to ensure that integer versions of
|
||||
* the library really only contain integer operations. All the code
|
||||
* in libFLAC should use FLAC__float and FLAC__double in place of
|
||||
* float and double, and be protected by checks of the macro
|
||||
* FLAC__INTEGER_ONLY_LIBRARY.
|
||||
*
|
||||
* FLAC__real is the basic floating point type used in LPC analysis.
|
||||
*/
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
typedef double FLAC__double;
|
||||
typedef float FLAC__float;
|
||||
/*
|
||||
* WATCHOUT: changing FLAC__real will change the signatures of many
|
||||
* functions that have assembly language equivalents and break them.
|
||||
*/
|
||||
typedef float FLAC__real;
|
||||
#else
|
||||
/*
|
||||
* The convention for FLAC__fixedpoint is to use the upper 16 bits
|
||||
* for the integer part and lower 16 bits for the fractional part.
|
||||
*/
|
||||
typedef FLAC__int32 FLAC__fixedpoint;
|
||||
extern const FLAC__fixedpoint FLAC__FP_ZERO;
|
||||
extern const FLAC__fixedpoint FLAC__FP_ONE_HALF;
|
||||
extern const FLAC__fixedpoint FLAC__FP_ONE;
|
||||
extern const FLAC__fixedpoint FLAC__FP_LN2;
|
||||
extern const FLAC__fixedpoint FLAC__FP_E;
|
||||
|
||||
#define FLAC__fixedpoint_trunc(x) ((x)>>16)
|
||||
|
||||
#define FLAC__fixedpoint_mul(x, y) ( (FLAC__fixedpoint) ( ((FLAC__int64)(x)*(FLAC__int64)(y)) >> 16 ) )
|
||||
|
||||
#define FLAC__fixedpoint_div(x, y) ( (FLAC__fixedpoint) ( ( ((FLAC__int64)(x)<<32) / (FLAC__int64)(y) ) >> 16 ) )
|
||||
|
||||
/*
|
||||
* FLAC__fixedpoint_log2()
|
||||
* --------------------------------------------------------------------
|
||||
* Returns the base-2 logarithm of the fixed-point number 'x' using an
|
||||
* algorithm by Knuth for x >= 1.0
|
||||
*
|
||||
* 'fracbits' is the number of fractional bits of 'x'. 'fracbits' must
|
||||
* be < 32 and evenly divisible by 4 (0 is OK but not very precise).
|
||||
*
|
||||
* 'precision' roughly limits the number of iterations that are done;
|
||||
* use (unsigned)(-1) for maximum precision.
|
||||
*
|
||||
* If 'x' is less than one -- that is, x < (1<<fracbits) -- then this
|
||||
* function will punt and return 0.
|
||||
*
|
||||
* The return value will also have 'fracbits' fractional bits.
|
||||
*/
|
||||
FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,44 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__FORMAT_H
|
||||
#define FLAC__PRIVATE__FORMAT_H
|
||||
|
||||
#include "FLAC/format.h"
|
||||
|
||||
unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order);
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize);
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order);
|
||||
void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object);
|
||||
void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object);
|
||||
FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order);
|
||||
|
||||
#endif
|
|
@ -1,214 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__LPC_H
|
||||
#define FLAC__PRIVATE__LPC_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "private/float.h"
|
||||
#include "FLAC/format.h"
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
|
||||
/*
|
||||
* FLAC__lpc_window_data()
|
||||
* --------------------------------------------------------------------
|
||||
* Applies the given window to the data.
|
||||
* OPT: asm implementation
|
||||
*
|
||||
* IN in[0,data_len-1]
|
||||
* IN window[0,data_len-1]
|
||||
* OUT out[0,lag-1]
|
||||
* IN data_len
|
||||
*/
|
||||
void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_autocorrelation()
|
||||
* --------------------------------------------------------------------
|
||||
* Compute the autocorrelation for lags between 0 and lag-1.
|
||||
* Assumes data[] outside of [0,data_len-1] == 0.
|
||||
* Asserts that lag > 0.
|
||||
*
|
||||
* IN data[0,data_len-1]
|
||||
* IN data_len
|
||||
* IN 0 < lag <= data_len
|
||||
* OUT autoc[0,lag-1]
|
||||
*/
|
||||
void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_lp_coefficients()
|
||||
* --------------------------------------------------------------------
|
||||
* Computes LP coefficients for orders 1..max_order.
|
||||
* Do not call if autoc[0] == 0.0. This means the signal is zero
|
||||
* and there is no point in calculating a predictor.
|
||||
*
|
||||
* IN autoc[0,max_order] autocorrelation values
|
||||
* IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute
|
||||
* OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order
|
||||
* *** IMPORTANT:
|
||||
* *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched
|
||||
* OUT error[0,max_order-1] error for each order (more
|
||||
* specifically, the variance of
|
||||
* the error signal times # of
|
||||
* samples in the signal)
|
||||
*
|
||||
* Example: if max_order is 9, the LP coefficients for order 9 will be
|
||||
* in lp_coeff[8][0,8], the LP coefficients for order 8 will be
|
||||
* in lp_coeff[7][0,7], etc.
|
||||
*/
|
||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_quantize_coefficients()
|
||||
* --------------------------------------------------------------------
|
||||
* Quantizes the LP coefficients. NOTE: precision + bits_per_sample
|
||||
* must be less than 32 (sizeof(FLAC__int32)*8).
|
||||
*
|
||||
* IN lp_coeff[0,order-1] LP coefficients
|
||||
* IN order LP order
|
||||
* IN FLAC__MIN_QLP_COEFF_PRECISION < precision
|
||||
* desired precision (in bits, including sign
|
||||
* bit) of largest coefficient
|
||||
* OUT qlp_coeff[0,order-1] quantized coefficients
|
||||
* OUT shift # of bits to shift right to get approximated
|
||||
* LP coefficients. NOTE: could be negative.
|
||||
* RETURN 0 => quantization OK
|
||||
* 1 => coefficients require too much shifting for *shift to
|
||||
* fit in the LPC subframe header. 'shift' is unset.
|
||||
* 2 => coefficients are all zero, which is bad. 'shift' is
|
||||
* unset.
|
||||
*/
|
||||
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_residual_from_qlp_coefficients()
|
||||
* --------------------------------------------------------------------
|
||||
* Compute the residual signal obtained from sutracting the predicted
|
||||
* signal from the original.
|
||||
*
|
||||
* IN data[-order,data_len-1] original signal (NOTE THE INDICES!)
|
||||
* IN data_len length of original signal
|
||||
* IN qlp_coeff[0,order-1] quantized LP coefficients
|
||||
* IN order > 0 LP order
|
||||
* IN lp_quantization quantization of LP coefficients in bits
|
||||
* OUT residual[0,data_len-1] residual signal
|
||||
*/
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
|
||||
|
||||
/*
|
||||
* FLAC__lpc_restore_signal()
|
||||
* --------------------------------------------------------------------
|
||||
* Restore the original signal by summing the residual and the
|
||||
* predictor.
|
||||
*
|
||||
* IN residual[0,data_len-1] residual signal
|
||||
* IN data_len length of original signal
|
||||
* IN qlp_coeff[0,order-1] quantized LP coefficients
|
||||
* IN order > 0 LP order
|
||||
* IN lp_quantization quantization of LP coefficients in bits
|
||||
* *** IMPORTANT: the caller must pass in the historical samples:
|
||||
* IN data[-order,-1] previously-reconstructed historical samples
|
||||
* OUT data[0,data_len-1] original signal
|
||||
*/
|
||||
void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
# endif /* FLAC__HAS_NASM */
|
||||
# elif defined FLAC__CPU_PPC
|
||||
void FLAC__lpc_restore_signal_asm_ppc_altivec_16(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
# endif/* FLAC__CPU_IA32 || FLAC__CPU_PPC */
|
||||
#endif /* FLAC__NO_ASM */
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_expected_bits_per_residual_sample()
|
||||
* --------------------------------------------------------------------
|
||||
* Compute the expected number of bits per residual signal sample
|
||||
* based on the LP error (which is related to the residual variance).
|
||||
*
|
||||
* IN lpc_error >= 0.0 error returned from calculating LP coefficients
|
||||
* IN total_samples > 0 # of samples in residual signal
|
||||
* RETURN expected bits per sample
|
||||
*/
|
||||
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples);
|
||||
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_best_order()
|
||||
* --------------------------------------------------------------------
|
||||
* Compute the best order from the array of signal errors returned
|
||||
* during coefficient computation.
|
||||
*
|
||||
* IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients
|
||||
* IN max_order > 0 max LP order
|
||||
* IN total_samples > 0 # of samples in residual signal
|
||||
* IN overhead_bits_per_order # of bits overhead for each increased LP order
|
||||
* (includes warmup sample size and quantized LP coefficient)
|
||||
* RETURN [1,max_order] best order
|
||||
*/
|
||||
unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order);
|
||||
|
||||
#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
|
||||
|
||||
#endif
|
|
@ -1,44 +0,0 @@
|
|||
#ifndef FLAC__PRIVATE__MD5_H
|
||||
#define FLAC__PRIVATE__MD5_H
|
||||
|
||||
/*
|
||||
* This is the header file for the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*
|
||||
* Changed so as no longer to depend on Colin Plumb's `usual.h'
|
||||
* header definitions; now uses stuff from dpkg's config.h
|
||||
* - Ian Jackson <ijackson@nyx.cs.du.edu>.
|
||||
* Still in the public domain.
|
||||
*
|
||||
* Josh Coalson: made some changes to integrate with libFLAC.
|
||||
* Still in the public domain, with no warranty.
|
||||
*/
|
||||
|
||||
#include "FLAC/ordinals.h"
|
||||
|
||||
typedef struct {
|
||||
FLAC__uint32 in[16];
|
||||
FLAC__uint32 buf[4];
|
||||
FLAC__uint32 bytes[2];
|
||||
FLAC__byte *internal_buf;
|
||||
size_t capacity;
|
||||
} FLAC__MD5Context;
|
||||
|
||||
void FLAC__MD5Init(FLAC__MD5Context *context);
|
||||
void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context);
|
||||
|
||||
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample);
|
||||
|
||||
#endif
|
|
@ -1,56 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PRIVATE__MEMORY_H
|
||||
#define FLAC__PRIVATE__MEMORY_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /* for size_t */
|
||||
|
||||
#include "private/float.h"
|
||||
#include "FLAC/ordinals.h" /* for FLAC__bool */
|
||||
|
||||
/* Returns the unaligned address returned by malloc.
|
||||
* Use free() on this address to deallocate.
|
||||
*/
|
||||
void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer);
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer);
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,58 +0,0 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef FLAC__PROTECTED__STREAM_DECODER_H
|
||||
#define FLAC__PROTECTED__STREAM_DECODER_H
|
||||
|
||||
#include "FLAC/stream_decoder.h"
|
||||
#if FLAC__HAS_OGG
|
||||
#include "private/ogg_decoder_aspect.h"
|
||||
#endif
|
||||
|
||||
typedef struct FLAC__StreamDecoderProtected {
|
||||
FLAC__StreamDecoderState state;
|
||||
unsigned channels;
|
||||
FLAC__ChannelAssignment channel_assignment;
|
||||
unsigned bits_per_sample;
|
||||
unsigned sample_rate; /* in Hz */
|
||||
unsigned blocksize; /* in samples (per channel) */
|
||||
FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */
|
||||
#if FLAC__HAS_OGG
|
||||
FLAC__OggDecoderAspect ogg_decoder_aspect;
|
||||
#endif
|
||||
} FLAC__StreamDecoderProtected;
|
||||
|
||||
/*
|
||||
* return the number of input bytes consumed
|
||||
*/
|
||||
unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder);
|
||||
|
||||
#endif
|
|
@ -1,214 +0,0 @@
|
|||
/* alloc - Convenience routines for safely allocating memory
|
||||
* Copyright (C) 2007 Josh Coalson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef FLAC__SHARE__ALLOC_H
|
||||
#define FLAC__SHARE__ALLOC_H
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early
|
||||
* before #including this file, otherwise SIZE_MAX might not be defined
|
||||
*/
|
||||
|
||||
#include <limits.h> /* for SIZE_MAX */
|
||||
#if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__
|
||||
#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
|
||||
#endif
|
||||
#include <stdlib.h> /* for size_t, malloc(), etc */
|
||||
|
||||
#ifndef SIZE_T_MAX
|
||||
# ifdef _WIN64
|
||||
# define SIZE_T_MAX ULLONG_MAX
|
||||
# elif defined(_WIN32)
|
||||
# define SIZE_T_MAX UINT_MAX /* Why doesn't the standard MinGW distribution define this? */
|
||||
# else
|
||||
# error
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX SIZE_T_MAX
|
||||
#endif
|
||||
|
||||
#ifndef FLaC__INLINE
|
||||
#define FLaC__INLINE
|
||||
#endif
|
||||
|
||||
/* avoid malloc()ing 0 bytes, see:
|
||||
* https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003
|
||||
*/
|
||||
static FLaC__INLINE void *safe_malloc_(size_t size)
|
||||
{
|
||||
/* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
if(!size)
|
||||
size++;
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_calloc_(size_t nmemb, size_t size)
|
||||
{
|
||||
if(!nmemb || !size)
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
|
||||
/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */
|
||||
|
||||
static FLaC__INLINE void *safe_malloc_add_2op_(size_t size1, size_t size2)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
return safe_malloc_(size2);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
return safe_malloc_(size3);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
size4 += size3;
|
||||
if(size4 < size3)
|
||||
return 0;
|
||||
return safe_malloc_(size4);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_malloc_mul_2op_(size_t size1, size_t size2)
|
||||
#if 0
|
||||
needs support for cases where sizeof(size_t) != 4
|
||||
{
|
||||
/* could be faster #ifdef'ing off SIZEOF_SIZE_T */
|
||||
if(sizeof(size_t) == 4) {
|
||||
if ((double)size1 * (double)size2 < 4294967296.0)
|
||||
return malloc(size1*size2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
/* better? */
|
||||
{
|
||||
if(!size1 || !size2)
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return malloc(size1*size2);
|
||||
}
|
||||
#endif
|
||||
|
||||
static FLaC__INLINE void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || !size2 || !size3)
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
size1 *= size2;
|
||||
if(size1 > SIZE_MAX / size3)
|
||||
return 0;
|
||||
return malloc(size1*size3);
|
||||
}
|
||||
|
||||
/* size1*size2 + size3 */
|
||||
static FLaC__INLINE void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || !size2)
|
||||
return safe_malloc_(size3);
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return safe_malloc_add_2op_(size1*size2, size3);
|
||||
}
|
||||
|
||||
/* size1 * (size2 + size3) */
|
||||
static FLaC__INLINE void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || (!size2 && !size3))
|
||||
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
|
||||
size2 += size3;
|
||||
if(size2 < size3)
|
||||
return 0;
|
||||
return safe_malloc_mul_2op_(size1, size2);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_realloc_add_2op_(void *ptr, size_t size1, size_t size2)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
return realloc(ptr, size2);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
return realloc(ptr, size3);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_realloc_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
return 0;
|
||||
size3 += size2;
|
||||
if(size3 < size2)
|
||||
return 0;
|
||||
size4 += size3;
|
||||
if(size4 < size3)
|
||||
return 0;
|
||||
return realloc(ptr, size4);
|
||||
}
|
||||
|
||||
static FLaC__INLINE void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
|
||||
{
|
||||
if(!size1 || !size2)
|
||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return realloc(ptr, size1*size2);
|
||||
}
|
||||
|
||||
/* size1 * (size2 + size3) */
|
||||
static FLaC__INLINE void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
|
||||
{
|
||||
if(!size1 || (!size2 && !size3))
|
||||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
||||
size2 += size3;
|
||||
if(size2 < size3)
|
||||
return 0;
|
||||
return safe_realloc_mul_2op_(ptr, size1, size2);
|
||||
}
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,379 +0,0 @@
|
|||
/* libFLAC++ - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "FLAC++/decoder.h"
|
||||
#include "FLAC/assert.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
|
||||
#pragma warning ( disable : 4800 )
|
||||
#endif
|
||||
|
||||
namespace FLAC {
|
||||
namespace Decoder {
|
||||
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// Stream
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
|
||||
Stream::Stream():
|
||||
decoder_(::FLAC__stream_decoder_new())
|
||||
{ }
|
||||
|
||||
Stream::~Stream()
|
||||
{
|
||||
if(0 != decoder_) {
|
||||
(void)::FLAC__stream_decoder_finish(decoder_);
|
||||
::FLAC__stream_decoder_delete(decoder_);
|
||||
}
|
||||
}
|
||||
|
||||
bool Stream::is_valid() const
|
||||
{
|
||||
return 0 != decoder_;
|
||||
}
|
||||
|
||||
bool Stream::set_ogg_serial_number(long value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_ogg_serial_number(decoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_md5_checking(bool value)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_md5_checking(decoder_, value);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_respond(::FLAC__MetadataType type)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_metadata_respond(decoder_, type);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_respond_application(const FLAC__byte id[4])
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_metadata_respond_application(decoder_, id);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_respond_all()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_metadata_respond_all(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_ignore(::FLAC__MetadataType type)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_metadata_ignore(decoder_, type);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_ignore_application(const FLAC__byte id[4])
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_metadata_ignore_application(decoder_, id);
|
||||
}
|
||||
|
||||
bool Stream::set_metadata_ignore_all()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_set_metadata_ignore_all(decoder_);
|
||||
}
|
||||
|
||||
Stream::State Stream::get_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return State(::FLAC__stream_decoder_get_state(decoder_));
|
||||
}
|
||||
|
||||
bool Stream::get_md5_checking() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_get_md5_checking(decoder_);
|
||||
}
|
||||
|
||||
FLAC__uint64 Stream::get_total_samples() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_total_samples(decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_channels() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_channels(decoder_);
|
||||
}
|
||||
|
||||
::FLAC__ChannelAssignment Stream::get_channel_assignment() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_channel_assignment(decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_bits_per_sample() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_bits_per_sample(decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_sample_rate() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_sample_rate(decoder_);
|
||||
}
|
||||
|
||||
unsigned Stream::get_blocksize() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_blocksize(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::get_decode_position(FLAC__uint64 *position) const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_get_decode_position(decoder_, position);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus Stream::init()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_init_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus Stream::init_ogg()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return ::FLAC__stream_decoder_init_ogg_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
bool Stream::finish()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_finish(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::flush()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_flush(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::reset()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_reset(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_single()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_single(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_until_end_of_metadata()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_until_end_of_metadata(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_until_end_of_stream()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_until_end_of_stream(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::skip_single_frame()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_skip_single_frame(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::seek_absolute(FLAC__uint64 sample)
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_seek_absolute(decoder_, sample);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderSeekStatus Stream::seek_callback(FLAC__uint64 absolute_byte_offset)
|
||||
{
|
||||
(void)absolute_byte_offset;
|
||||
return ::FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderTellStatus Stream::tell_callback(FLAC__uint64 *absolute_byte_offset)
|
||||
{
|
||||
(void)absolute_byte_offset;
|
||||
return ::FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderLengthStatus Stream::length_callback(FLAC__uint64 *stream_length)
|
||||
{
|
||||
(void)stream_length;
|
||||
return ::FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
bool Stream::eof_callback()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Stream::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
||||
{
|
||||
(void)metadata;
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderReadStatus Stream::read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->read_callback(buffer, bytes);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderSeekStatus Stream::seek_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->seek_callback(absolute_byte_offset);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderTellStatus Stream::tell_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->tell_callback(absolute_byte_offset);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderLengthStatus Stream::length_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->length_callback(stream_length);
|
||||
}
|
||||
|
||||
FLAC__bool Stream::eof_callback_(const ::FLAC__StreamDecoder *decoder, void *client_data)
|
||||
{
|
||||
(void) decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->eof_callback();
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderWriteStatus Stream::write_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
return instance->write_callback(frame, buffer);
|
||||
}
|
||||
|
||||
void Stream::metadata_callback_(const ::FLAC__StreamDecoder *decoder, const ::FLAC__StreamMetadata *metadata, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
instance->metadata_callback(metadata);
|
||||
}
|
||||
|
||||
void Stream::error_callback_(const ::FLAC__StreamDecoder *decoder, ::FLAC__StreamDecoderErrorStatus status, void *client_data)
|
||||
{
|
||||
(void)decoder;
|
||||
FLAC__ASSERT(0 != client_data);
|
||||
Stream *instance = reinterpret_cast<Stream *>(client_data);
|
||||
FLAC__ASSERT(0 != instance);
|
||||
instance->error_callback(status);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// File
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
|
||||
File::File():
|
||||
Stream()
|
||||
{ }
|
||||
|
||||
File::~File()
|
||||
{
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus File::init(FILE *file)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return ::FLAC__stream_decoder_init_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus File::init(const char *filename)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return ::FLAC__stream_decoder_init_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus File::init_ogg(FILE *file)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return ::FLAC__stream_decoder_init_ogg_FILE(decoder_, file, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderInitStatus File::init_ogg(const char *filename)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return ::FLAC__stream_decoder_init_ogg_file(decoder_, filename, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
|
||||
}
|
||||
|
||||
// This is a dummy to satisfy the pure virtual from Stream; the
|
||||
// read callback will never be called since we are initializing
|
||||
// with FLAC__stream_decoder_init_FILE() or
|
||||
// FLAC__stream_decoder_init_file() and those supply the read
|
||||
// callback internally.
|
||||
::FLAC__StreamDecoderReadStatus File::read_callback(FLAC__byte buffer[], size_t *bytes)
|
||||
{
|
||||
(void)buffer, (void)bytes;
|
||||
FLAC__ASSERT(false);
|
||||
return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; // double protection
|
||||
}
|
||||
|
||||
}
|
||||
}
|
22
Makefile
22
Makefile
|
@ -1,12 +1,12 @@
|
|||
ifeq (Windows_NT,$(OS))
|
||||
WIN=1
|
||||
endif
|
||||
ifeq (Windows_NT,$(OS))
|
||||
WIN=1
|
||||
endif
|
||||
ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
|
||||
WIN=1
|
||||
endif
|
||||
|
||||
ifeq (1,$(WIN))
|
||||
include Makefile.mgw
|
||||
else
|
||||
include Makefile.linux
|
||||
endif
|
||||
WIN=1
|
||||
endif
|
||||
|
||||
ifeq (1,$(WIN))
|
||||
include Makefile.mgw
|
||||
else
|
||||
include Makefile.linux
|
||||
endif
|
||||
|
|
|
@ -16,7 +16,7 @@ ifdef GC
|
|||
endif
|
||||
CFLAGS += -MMD -DHAVE_FILELENGTH -D__forceinline=inline `sdl-config --cflags` `pkg-config gtk+-2.0 --cflags`
|
||||
CFLAGS += -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR
|
||||
LDFLAGS += -lFLAC++ -lFLAC -lz -ljpeg -lfmod `sdl-config --libs` `pkg-config gtk+-2.0 --libs`
|
||||
LDFLAGS += -lz -ljpeg -lfmodex `sdl-config --libs` `pkg-config gtk+-2.0 --libs`
|
||||
NASMFLAGS += -f elf -DM_TARGET_LINUX
|
||||
|
||||
SRCDIRS = src/ $(addprefix src/,g_doom/ g_heretic/ g_hexen/ g_raven/ g_shared/ g_strife/ oplsynth/ sound/ sdl/ textures/ thingdef/)
|
||||
|
|
109
Makefile.mgw
109
Makefile.mgw
|
@ -1,55 +1,56 @@
|
|||
RELEASETARGET = zdoomgcc.exe
|
||||
DEBUGTARGET = zdoomgccd.exe
|
||||
|
||||
all: basetools game
|
||||
debug: basetools debuggame
|
||||
release: basetools game
|
||||
|
||||
ifndef CONFIG
|
||||
CONFIG=Release
|
||||
endif
|
||||
|
||||
game: basetools ccdv.exe
|
||||
@$(MAKE) -f Makefile.mingw
|
||||
|
||||
debuggame: basetools ccdv.exe
|
||||
@$(MAKE) CONFIG=Debug -f Makefile.mingw
|
||||
|
||||
$(RELEASETARGET): game
|
||||
$(DEBUGTARGET): debuggame
|
||||
|
||||
basetools: ccdv.exe
|
||||
$(MAKE) -C tools/lemon
|
||||
$(MAKE) -C tools/re2c
|
||||
$(MAKE) -C zlib -f Makefile.mgw
|
||||
$(MAKE) -C tools/makewad
|
||||
$(MAKE) -C tools/dehsupp
|
||||
$(MAKE) -C tools/xlatcc
|
||||
$(MAKE) -C tools/fixrtext
|
||||
$(MAKE) -C wadsrc -f Makefile.mgw
|
||||
$(MAKE) -C flac -f Makefile.mgw
|
||||
$(MAKE) -C jpeg-6b -f Makefile.mgw
|
||||
|
||||
cleanexe:
|
||||
@$(MAKE) -C . -f Makefile.mingw clean
|
||||
|
||||
clean:
|
||||
@$(MAKE) -C tools/lemon clean
|
||||
@$(MAKE) -C tools/re2c clean
|
||||
@$(MAKE) -C tools/dehsupp clean
|
||||
@$(MAKE) -C tools/makewad clean
|
||||
@$(MAKE) -C tools/xlatcc clean
|
||||
@$(MAKE) -C tools/fixrtext clean
|
||||
@$(MAKE) -C wadsrc -f Makefile.mgw clean
|
||||
@$(MAKE) -C . -f Makefile.mingw clean
|
||||
@$(MAKE) -C zlib -f Makefile.mgw clean
|
||||
@$(MAKE) -C flac -f Makefile.mgw clean
|
||||
@$(MAKE) -C jpeg-6b -f Makefile.mgw clean
|
||||
RELEASETARGET = zdoomgcc.exe
|
||||
DEBUGTARGET = zdoomgccd.exe
|
||||
|
||||
all: basetools game
|
||||
debug: basetools debuggame
|
||||
release: basetools game
|
||||
|
||||
ifndef CONFIG
|
||||
CONFIG=Release
|
||||
endif
|
||||
|
||||
game: basetools ccdv.exe
|
||||
@$(MAKE) -f Makefile.mingw
|
||||
|
||||
debuggame: basetools ccdv.exe
|
||||
@$(MAKE) CONFIG=Debug -f Makefile.mingw
|
||||
|
||||
$(RELEASETARGET): game
|
||||
$(DEBUGTARGET): debuggame
|
||||
|
||||
basetools: ccdv.exe
|
||||
$(MAKE) -C tools/lemon
|
||||
$(MAKE) -C tools/re2c
|
||||
$(MAKE) -C zlib -f Makefile.mgw
|
||||
$(MAKE) -C tools/makewad
|
||||
$(MAKE) -C tools/dehsupp
|
||||
$(MAKE) -C tools/xlatcc
|
||||
$(MAKE) -C tools/fixrtext
|
||||
$(MAKE) -C wadsrc -f Makefile.mgw
|
||||
$(MAKE) -C jpeg-6b -f Makefile.mgw
|
||||
|
||||
cleanexe:
|
||||
@$(MAKE) -C . -f Makefile.mingw clean
|
||||
|
||||
clean:
|
||||
@$(MAKE) -C tools/lemon clean
|
||||
@$(MAKE) -C tools/re2c clean
|
||||
@$(MAKE) -C tools/dehsupp clean
|
||||
@$(MAKE) -C tools/makewad clean
|
||||
@$(MAKE) -C tools/xlatcc clean
|
||||
@$(MAKE) -C tools/fixrtext clean
|
||||
@$(MAKE) -C wadsrc -f Makefile.mgw clean
|
||||
@$(MAKE) -C . -f Makefile.mingw clean
|
||||
@$(MAKE) -C zlib -f Makefile.mgw clean
|
||||
@$(MAKE) -C jpeg-6b -f Makefile.mgw clean
|
||||
ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
|
||||
rm -f ccdv.exe
|
||||
else
|
||||
del /q /f ccdv.exe 2>nul
|
||||
endif
|
||||
|
||||
ccdv.exe: ccdv-win32.c
|
||||
@gcc -Os -s -nostdlib -fomit-frame-pointer -o ccdv.exe ccdv-win32.c -lkernel32 -luser32
|
||||
rm -f ccdv.exe
|
||||
else
|
||||
del /q /f ccdv.exe 2>nul
|
||||
endif
|
||||
|
||||
cleandep:
|
||||
@$(MAKE) -C . -f Makefile.mingw cleandep
|
||||
|
||||
ccdv.exe: ccdv-win32.c
|
||||
@gcc -Os -s -nostdlib -fomit-frame-pointer -o ccdv.exe ccdv-win32.c -lkernel32 -luser32
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# And then tweaked by hand
|
||||
|
||||
# Where did you install the FMOD API to? Change this line so that the build process can find it.
|
||||
FMODDIR = "c:/program files/fmodapi375win"
|
||||
FMODDIR = "e:/program files (x86)/FMOD SoundSystem/FMOD Programmers API Win32"
|
||||
|
||||
ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
|
||||
WINCMD=0
|
||||
|
@ -29,7 +29,7 @@ CCDV ?= @ccdv
|
|||
RE2C = tools/re2c/re2c
|
||||
|
||||
CPPFLAGS = -DWIN32 -D_WIN32 -D_WINDOWS -DHAVE_STRUPR -DHAVE_FILELENGTH -DI_DO_NOT_LIKE_BIG_DOWNLOADS -D__forceinline=inline -MMD -Izlib -IFLAC -Ijpeg-6b -Isrc -Isrc/win32 -Isrc/g_doom -Isrc/g_heretic -Isrc/g_hexen -Isrc/g_raven -Isrc/g_strife -Isrc/g_shared -Isrc/oplsynth -Isrc/sound -Isrc/textures -Isrc/thingdef
|
||||
LDFLAGS += flac/libflac.a zlib/libz.a jpeg-6b/libjpeg.a -lfmod -lwsock32 -lwinmm -lddraw -ldsound -ldxguid -ldinput8 -lole32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lsetupapi -lws2_32 -Wl,--subsystem,windows
|
||||
LDFLAGS += zlib/libz.a jpeg-6b/libjpeg.a -lfmodex -lwsock32 -lwinmm -lddraw -ldsound -ldxguid -ldinput8 -lole32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lsetupapi -lws2_32 -Wl,--subsystem,windows
|
||||
|
||||
ifdef FMODDIR
|
||||
CPPFLAGS += -I$(FMODDIR)/api/inc
|
||||
|
@ -125,8 +125,8 @@ clean:
|
|||
rm -fr $(RELEASEOBJDIR)
|
||||
|
||||
cleandep:
|
||||
rm -f $(DEBUGOBJDIR)\*.d
|
||||
rm -f $(RELEASEOBJDIR)\*.d
|
||||
rm -f $(DEBUGOBJDIR)/*.d
|
||||
rm -f $(RELEASEOBJDIR)/*.d
|
||||
endif
|
||||
|
||||
testobjdir:
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
March 8, 2008
|
||||
- Fixed: If you wanted to make cleandep with MinGW, you had to specifically
|
||||
specify Makefile.mingw as the makefile to use.
|
||||
- Added a normalizer to the OPL synth. It helped bring up the volume a little,
|
||||
but not nearly as much as I would have liked.
|
||||
- Removed MIDI Mapper references. It doesn't work with the stream API, and
|
||||
it doesn't really exist on NT kernels, either.
|
||||
- Reworked music volume: Except for MIDI, all music volume is controlled
|
||||
through GSnd and not at the individual song level.
|
||||
- Removed the mididevice global variable.
|
||||
- Added back support for custom streams.
|
||||
|
||||
March 7, 2008
|
||||
- I think the new FMOD Ex code should support everything the old FMOD 3 code
|
||||
did, sans custom streaming sounds.
|
||||
- Removed snd_midivolume. Now that all music uses a linear volume scale,
|
||||
there's no need for two separate music volume controls.
|
||||
- Increased snd_samplerate default up to 48000.
|
||||
- Added snd_format, defaulting to "PCM-16".
|
||||
- Added snd_speakermode, defaulting to "Auto".
|
||||
- Replaced snd_fpu with snd_resampler, defaulting to "Linear".
|
||||
- Bumped the snd_channels default up from a pitiful 12 to 32.
|
||||
- Changed snd_3d default to true. The new cvar snd_hw3d determines if
|
||||
hardware 3D support is used and default to false.
|
||||
- Removed the libFLAC source, since FMOD Ex has native FLAC support.
|
||||
- Removed the altsound code, since it was terribly gimped in comparison to
|
||||
the FMOD code. It's original purpose was to have been as a springboard for
|
||||
writing a non-FMOD sound system for Unix-y systems, but that never
|
||||
happened.
|
||||
- Finished preliminary FMOD Ex support.
|
||||
|
||||
March 6, 2008
|
||||
- Fixed: If P_BounceWall() can't find a wall when it does its trace, but it
|
||||
was entered because a line blocked the projectile, then it should still use
|
||||
|
|
|
@ -1115,7 +1115,6 @@ static menu_t CompatibilityMenu =
|
|||
*=======================================*/
|
||||
|
||||
#ifdef _WIN32
|
||||
EXTERN_CVAR (Float, snd_midivolume)
|
||||
EXTERN_CVAR (Float, snd_movievolume)
|
||||
#endif
|
||||
EXTERN_CVAR (Bool, snd_flipstereo)
|
||||
|
@ -1156,14 +1155,13 @@ static menuitem_t SoundItems[] =
|
|||
{
|
||||
{ slider, "Sound effects volume", {&snd_sfxvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
|
||||
#ifdef _WIN32
|
||||
{ slider, "MIDI music volume", {&snd_midivolume}, {0.0}, {1.0}, {0.05}, {NULL} },
|
||||
{ slider, "Other music volume", {&snd_musicvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
|
||||
{ slider, "Music volume", {&snd_musicvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
|
||||
{ slider, "Movie volume", {&snd_movievolume}, {0.0}, {1.0}, {0.05}, {NULL} },
|
||||
#else
|
||||
{ slider, "Music volume", {&snd_musicvolume}, {0.0}, {1.0}, {0.05}, {NULL} },
|
||||
#endif
|
||||
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
|
||||
{ discrete, "Underwater EAX Reverb",{&snd_waterreverb}, {2.0}, {0.0}, {0.0}, {OnOff} },
|
||||
{ discrete, "Underwater Reverb", {&snd_waterreverb}, {2.0}, {0.0}, {0.0}, {OnOff} },
|
||||
{ discrete, "Flip Stereo Channels", {&snd_flipstereo}, {2.0}, {0.0}, {0.0}, {OnOff} },
|
||||
{ discrete, "Random Pitch Variations", {&snd_pitched}, {2.0}, {0.0}, {0.0}, {OnOff} },
|
||||
{ redtext, " ", {NULL}, {0.0}, {0.0}, {0.0}, {NULL} },
|
||||
|
|
|
@ -26,6 +26,7 @@ OPLmusicBlock::OPLmusicBlock (FILE *file, char * musiccache, int len, int rate,
|
|||
{
|
||||
scoredata = NULL;
|
||||
SampleBuff = NULL;
|
||||
SampleBuffSize = 0;
|
||||
TwoChips = !opl_onechip;
|
||||
io = new OPLio;
|
||||
|
||||
|
@ -116,7 +117,6 @@ OPLmusicBlock::OPLmusicBlock (FILE *file, char * musiccache, int len, int rate,
|
|||
}
|
||||
}
|
||||
|
||||
SampleBuff = new int[maxSamples];
|
||||
Restart ();
|
||||
}
|
||||
|
||||
|
@ -209,12 +209,22 @@ void OPLmusicBlock::Restart ()
|
|||
bool OPLmusicBlock::ServiceStream (void *buff, int numbytes)
|
||||
{
|
||||
short *samples = (short *)buff;
|
||||
int *samples1 = SampleBuff;
|
||||
int *samples1;
|
||||
int numsamples = numbytes / 2;
|
||||
bool prevEnded = false;
|
||||
bool res = true;
|
||||
|
||||
memset (SampleBuff, 0, numsamples * 4);
|
||||
// SampleBuff is allocated here, since FMOD might not give us exactly
|
||||
// the buffer size we requested. (Actually, it's giving us twice what
|
||||
// was asked for. Am I doing something wrong?)
|
||||
numbytes = numsamples * sizeof(int);
|
||||
if (SampleBuff == NULL || numbytes > SampleBuffSize)
|
||||
{
|
||||
SampleBuff = (int *)M_Realloc(SampleBuff, numbytes);
|
||||
SampleBuffSize = numbytes;
|
||||
}
|
||||
memset(SampleBuff, 0, numbytes);
|
||||
samples1 = SampleBuff;
|
||||
|
||||
#ifdef _WIN32
|
||||
EnterCriticalSection (&ChipAccess);
|
||||
|
@ -278,7 +288,7 @@ bool OPLmusicBlock::ServiceStream (void *buff, int numbytes)
|
|||
#else
|
||||
SDL_mutexV (ChipAccess);
|
||||
#endif
|
||||
numsamples = numbytes / 2;
|
||||
numsamples = numbytes / sizeof(int);
|
||||
samples1 = SampleBuff;
|
||||
|
||||
#if defined(_MSC_VER) && defined(USEASM)
|
||||
|
|
|
@ -32,6 +32,7 @@ protected:
|
|||
int ScoreLen;
|
||||
|
||||
int *SampleBuff;
|
||||
int SampleBuffSize;
|
||||
|
||||
#ifdef _WIN32
|
||||
CRITICAL_SECTION ChipAccess;
|
||||
|
|
|
@ -110,7 +110,7 @@ static ReverbContainer Psychotic =
|
|||
0x1900,
|
||||
true,
|
||||
false,
|
||||
{25, 1.0f, 0.50f, -1000, -151, 0, 7.56f, 0.91f, 1.0f, -626, 0.020f, 0.0f,0.0f,0.0f, 774, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 4.00f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
{0,25, 1.0f, 0.50f, -1000, -151, 0, 7.56f, 0.91f, 1.0f, -626, 0.020f, 0.0f,0.0f,0.0f, 774, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 4.00f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
};
|
||||
|
||||
static ReverbContainer Dizzy =
|
||||
|
@ -120,7 +120,7 @@ static ReverbContainer Dizzy =
|
|||
0x1800,
|
||||
true,
|
||||
false,
|
||||
{24, 1.8f, 0.60f, -1000, -400, 0, 17.23f, 0.56f, 1.0f, -1713, 0.020f, 0.0f,0.0f,0.0f, -613, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.81f, 0.310f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
{0,24, 1.8f, 0.60f, -1000, -400, 0, 17.23f, 0.56f, 1.0f, -1713, 0.020f, 0.0f,0.0f,0.0f, -613, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.81f, 0.310f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
};
|
||||
|
||||
static ReverbContainer Drugged =
|
||||
|
@ -130,7 +130,7 @@ static ReverbContainer Drugged =
|
|||
0x1700,
|
||||
true,
|
||||
false,
|
||||
{23, 1.9f, 0.50f, -1000, 0, 0, 8.39f, 1.39f, 1.0f, -115, 0.002f, 0.0f,0.0f,0.0f, 985, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
{0,23, 1.9f, 0.50f, -1000, 0, 0, 8.39f, 1.39f, 1.0f, -115, 0.002f, 0.0f,0.0f,0.0f, 985, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 1.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
};
|
||||
|
||||
static ReverbContainer Underwater =
|
||||
|
@ -140,7 +140,7 @@ static ReverbContainer Underwater =
|
|||
0x1600,
|
||||
true,
|
||||
false,
|
||||
{22, 1.8f, 1.00f, -1000, -4000, 0, 1.49f, 0.10f, 1.0f, -449, 0.007f, 0.0f,0.0f,0.0f, 1700, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 1.18f, 0.348f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,22, 1.8f, 1.00f, -1000, -4000, 0, 1.49f, 0.10f, 1.0f, -449, 0.007f, 0.0f,0.0f,0.0f, 1700, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 1.18f, 0.348f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer SewerPipe =
|
||||
|
@ -150,7 +150,7 @@ static ReverbContainer SewerPipe =
|
|||
0x1500,
|
||||
true,
|
||||
false,
|
||||
{21, 1.7f, 0.80f, -1000, -1000, 0, 2.81f, 0.14f, 1.0f, 429, 0.014f, 0.0f,0.0f,0.0f, 1023, 0.021f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 80.0f, 60.0f, 0x3f }
|
||||
{0,21, 1.7f, 0.80f, -1000, -1000, 0, 2.81f, 0.14f, 1.0f, 429, 0.014f, 0.0f,0.0f,0.0f, 1023, 0.021f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 80.0f, 60.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer ParkingLot =
|
||||
|
@ -160,7 +160,7 @@ static ReverbContainer ParkingLot =
|
|||
0x1400,
|
||||
true,
|
||||
false,
|
||||
{20, 8.3f, 1.00f, -1000, 0, 0, 1.65f, 1.50f, 1.0f, -1363, 0.008f, 0.0f,0.0f,0.0f, -1153, 0.012f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
{0,20, 8.3f, 1.00f, -1000, 0, 0, 1.65f, 1.50f, 1.0f, -1363, 0.008f, 0.0f,0.0f,0.0f, -1153, 0.012f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
};
|
||||
|
||||
static ReverbContainer Plain =
|
||||
|
@ -170,7 +170,7 @@ static ReverbContainer Plain =
|
|||
0x1300,
|
||||
true,
|
||||
false,
|
||||
{19, 42.5f, 0.21f, -1000, -2000, 0, 1.49f, 0.50f, 1.0f, -2466, 0.179f, 0.0f,0.0f,0.0f, -1926, 0.100f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 21.0f, 100.0f, 0x3f }
|
||||
{0,19, 42.5f, 0.21f, -1000, -2000, 0, 1.49f, 0.50f, 1.0f, -2466, 0.179f, 0.0f,0.0f,0.0f, -1926, 0.100f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 21.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Quarry =
|
||||
|
@ -180,7 +180,7 @@ static ReverbContainer Quarry =
|
|||
0x1200,
|
||||
true,
|
||||
false,
|
||||
{18, 17.5f, 1.00f, -1000, -1000, 0, 1.49f, 0.83f, 1.0f, -10000, 0.061f, 0.0f,0.0f,0.0f, 500, 0.025f, 0.0f,0.0f,0.0f, 0.125f, 0.70f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,18, 17.5f, 1.00f, -1000, -1000, 0, 1.49f, 0.83f, 1.0f, -10000, 0.061f, 0.0f,0.0f,0.0f, 500, 0.025f, 0.0f,0.0f,0.0f, 0.125f, 0.70f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Mountains =
|
||||
|
@ -190,7 +190,7 @@ static ReverbContainer Mountains =
|
|||
0x1100,
|
||||
true,
|
||||
false,
|
||||
{17, 100.0f, 0.27f, -1000, -2500, 0, 1.49f, 0.21f, 1.0f, -2780, 0.300f, 0.0f,0.0f,0.0f, -1434, 0.100f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 27.0f, 100.0f, 0x1f }
|
||||
{0,17, 100.0f, 0.27f, -1000, -2500, 0, 1.49f, 0.21f, 1.0f, -2780, 0.300f, 0.0f,0.0f,0.0f, -1434, 0.100f, 0.0f,0.0f,0.0f, 0.250f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 27.0f, 100.0f, 0x1f }
|
||||
};
|
||||
|
||||
static ReverbContainer City =
|
||||
|
@ -200,7 +200,7 @@ static ReverbContainer City =
|
|||
0x1000,
|
||||
true,
|
||||
false,
|
||||
{16, 7.5f, 0.50f, -1000, -800, 0, 1.49f, 0.67f, 1.0f, -2273, 0.007f, 0.0f,0.0f,0.0f, -1691, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 50.0f, 100.0f, 0x3f }
|
||||
{0,16, 7.5f, 0.50f, -1000, -800, 0, 1.49f, 0.67f, 1.0f, -2273, 0.007f, 0.0f,0.0f,0.0f, -1691, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 50.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Forest =
|
||||
|
@ -210,7 +210,7 @@ static ReverbContainer Forest =
|
|||
0x0F00,
|
||||
true,
|
||||
false,
|
||||
{15, 38.0f, 0.30f, -1000, -3300, 0, 1.49f, 0.54f, 1.0f, -2560, 0.162f, 0.0f,0.0f,0.0f, -229, 0.088f, 0.0f,0.0f,0.0f, 0.125f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 79.0f, 100.0f, 0x3f }
|
||||
{0,15, 38.0f, 0.30f, -1000, -3300, 0, 1.49f, 0.54f, 1.0f, -2560, 0.162f, 0.0f,0.0f,0.0f, -229, 0.088f, 0.0f,0.0f,0.0f, 0.125f, 1.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 79.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Alley =
|
||||
|
@ -220,7 +220,7 @@ static ReverbContainer Alley =
|
|||
0x0E00,
|
||||
true,
|
||||
false,
|
||||
{14, 7.5f, 0.30f, -1000, -270, 0, 1.49f, 0.86f, 1.0f, -1204, 0.007f, 0.0f,0.0f,0.0f, -4, 0.011f, 0.0f,0.0f,0.0f, 0.125f, 0.95f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,14, 7.5f, 0.30f, -1000, -270, 0, 1.49f, 0.86f, 1.0f, -1204, 0.007f, 0.0f,0.0f,0.0f, -4, 0.011f, 0.0f,0.0f,0.0f, 0.125f, 0.95f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer StoneCorridor =
|
||||
|
@ -230,7 +230,7 @@ static ReverbContainer StoneCorridor =
|
|||
0x0D00,
|
||||
true,
|
||||
false,
|
||||
{13, 13.5f, 1.00f, -1000, -237, 0, 2.70f, 0.79f, 1.0f, -1214, 0.013f, 0.0f,0.0f,0.0f, 395, 0.020f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,13, 13.5f, 1.00f, -1000, -237, 0, 2.70f, 0.79f, 1.0f, -1214, 0.013f, 0.0f,0.0f,0.0f, 395, 0.020f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Hallway =
|
||||
|
@ -240,7 +240,7 @@ static ReverbContainer Hallway =
|
|||
0x0C00,
|
||||
true,
|
||||
false,
|
||||
{12, 1.8f, 1.00f, -1000, -300, 0, 1.49f, 0.59f, 1.0f, -1219, 0.007f, 0.0f,0.0f,0.0f, 441, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,12, 1.8f, 1.00f, -1000, -300, 0, 1.49f, 0.59f, 1.0f, -1219, 0.007f, 0.0f,0.0f,0.0f, 441, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer CarpettedHallway =
|
||||
|
@ -250,7 +250,7 @@ static ReverbContainer CarpettedHallway =
|
|||
0x0B00,
|
||||
true,
|
||||
false,
|
||||
{11, 1.9f, 1.00f, -1000, -4000, 0, 0.30f, 0.10f, 1.0f, -1831, 0.002f, 0.0f,0.0f,0.0f, -1630, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,11, 1.9f, 1.00f, -1000, -4000, 0, 0.30f, 0.10f, 1.0f, -1831, 0.002f, 0.0f,0.0f,0.0f, -1630, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Hangar =
|
||||
|
@ -260,7 +260,7 @@ static ReverbContainer Hangar =
|
|||
0x0A00,
|
||||
true,
|
||||
false,
|
||||
{10, 50.3f, 1.00f, -1000, -1000, 0, 10.05f, 0.23f, 1.0f, -602, 0.020f, 0.0f,0.0f,0.0f, 198, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0,10, 50.3f, 1.00f, -1000, -1000, 0, 10.05f, 0.23f, 1.0f, -602, 0.020f, 0.0f,0.0f,0.0f, 198, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Arena =
|
||||
|
@ -270,7 +270,7 @@ static ReverbContainer Arena =
|
|||
0x0900,
|
||||
true,
|
||||
false,
|
||||
{9, 36.2f, 1.00f, -1000, -698, 0, 7.24f, 0.33f, 1.0f, -1166, 0.020f, 0.0f,0.0f,0.0f, 16, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 9, 36.2f, 1.00f, -1000, -698, 0, 7.24f, 0.33f, 1.0f, -1166, 0.020f, 0.0f,0.0f,0.0f, 16, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Cave =
|
||||
|
@ -280,7 +280,7 @@ static ReverbContainer Cave =
|
|||
0x0800,
|
||||
true,
|
||||
false,
|
||||
{8, 14.6f, 1.00f, -1000, 0, 0, 2.91f, 1.30f, 1.0f, -602, 0.015f, 0.0f,0.0f,0.0f, -302, 0.022f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
{0, 8, 14.6f, 1.00f, -1000, 0, 0, 2.91f, 1.30f, 1.0f, -602, 0.015f, 0.0f,0.0f,0.0f, -302, 0.022f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x1f }
|
||||
};
|
||||
|
||||
static ReverbContainer ConcertHall =
|
||||
|
@ -290,7 +290,7 @@ static ReverbContainer ConcertHall =
|
|||
0x0700,
|
||||
true,
|
||||
false,
|
||||
{7, 19.6f, 1.00f, -1000, -500, 0, 3.92f, 0.70f, 1.0f, -1230, 0.020f, 0.0f,0.0f,0.0f, -2, 0.029f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 7, 19.6f, 1.00f, -1000, -500, 0, 3.92f, 0.70f, 1.0f, -1230, 0.020f, 0.0f,0.0f,0.0f, -2, 0.029f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Auditorium =
|
||||
|
@ -300,7 +300,7 @@ static ReverbContainer Auditorium =
|
|||
0x0600,
|
||||
true,
|
||||
false,
|
||||
{6, 21.6f, 1.00f, -1000, -476, 0, 4.32f, 0.59f, 1.0f, -789, 0.020f, 0.0f,0.0f,0.0f, -289, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 6, 21.6f, 1.00f, -1000, -476, 0, 4.32f, 0.59f, 1.0f, -789, 0.020f, 0.0f,0.0f,0.0f, -289, 0.030f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer StoneRoom =
|
||||
|
@ -310,7 +310,7 @@ static ReverbContainer StoneRoom =
|
|||
0x0500,
|
||||
true,
|
||||
false,
|
||||
{5, 11.6f, 1.00f, -1000, -300, 0, 2.31f, 0.64f, 1.0f, -711, 0.012f, 0.0f,0.0f,0.0f, 83, 0.017f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 5, 11.6f, 1.00f, -1000, -300, 0, 2.31f, 0.64f, 1.0f, -711, 0.012f, 0.0f,0.0f,0.0f, 83, 0.017f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer LivingRoom =
|
||||
|
@ -320,7 +320,7 @@ static ReverbContainer LivingRoom =
|
|||
0x0400,
|
||||
true,
|
||||
false,
|
||||
{4, 2.5f, 1.00f, -1000, -6000, 0, 0.50f, 0.10f, 1.0f, -1376, 0.003f, 0.0f,0.0f,0.0f, -1104, 0.004f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 4, 2.5f, 1.00f, -1000, -6000, 0, 0.50f, 0.10f, 1.0f, -1376, 0.003f, 0.0f,0.0f,0.0f, -1104, 0.004f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Bathroom =
|
||||
|
@ -330,7 +330,7 @@ static ReverbContainer Bathroom =
|
|||
0x0300,
|
||||
true,
|
||||
false,
|
||||
{3, 1.4f, 1.00f, -1000, -1200, 0, 1.49f, 0.54f, 1.0f, -370, 0.007f, 0.0f,0.0f,0.0f, 1030, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 60.0f, 0x3f }
|
||||
{0, 3, 1.4f, 1.00f, -1000, -1200, 0, 1.49f, 0.54f, 1.0f, -370, 0.007f, 0.0f,0.0f,0.0f, 1030, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 60.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Room =
|
||||
|
@ -340,7 +340,7 @@ static ReverbContainer Room =
|
|||
0x0200,
|
||||
true,
|
||||
false,
|
||||
{2, 1.9f, 1.00f, -1000, -454, 0, 0.40f, 0.83f, 1.0f, -1646, 0.002f, 0.0f,0.0f,0.0f, 53, 0.003f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 2, 1.9f, 1.00f, -1000, -454, 0, 0.40f, 0.83f, 1.0f, -1646, 0.002f, 0.0f,0.0f,0.0f, 53, 0.003f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer PaddedCell =
|
||||
|
@ -350,7 +350,7 @@ static ReverbContainer PaddedCell =
|
|||
0x0100,
|
||||
true,
|
||||
false,
|
||||
{1, 1.4f, 1.00f, -1000, -6000, 0, 0.17f, 0.10f, 1.0f, -1204, 0.001f, 0.0f,0.0f,0.0f, 207, 0.002f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 1, 1.4f, 1.00f, -1000, -6000, 0, 0.17f, 0.10f, 1.0f, -1204, 0.001f, 0.0f,0.0f,0.0f, 207, 0.002f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Generic =
|
||||
|
@ -360,7 +360,7 @@ static ReverbContainer Generic =
|
|||
0x0001,
|
||||
true,
|
||||
false,
|
||||
{0, 7.5f, 1.00f, -1000, -100, 0, 1.49f, 0.83f, 1.0f, -2602, 0.007f, 0.0f,0.0f,0.0f, 200, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
{0, 0, 7.5f, 1.00f, -1000, -100, 0, 1.49f, 0.83f, 1.0f, -2602, 0.007f, 0.0f,0.0f,0.0f, 200, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 100.0f, 100.0f, 0x3f }
|
||||
};
|
||||
|
||||
static ReverbContainer Off =
|
||||
|
@ -370,7 +370,7 @@ static ReverbContainer Off =
|
|||
0x0000,
|
||||
true,
|
||||
false,
|
||||
{0, 7.5f, 1.00f, -10000, -10000, 0, 1.00f, 1.00f, 1.0f, -2602, 0.007f, 0.0f,0.0f,0.0f, 200, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 0.0f, 0.0f, 0x33f }
|
||||
{0, 0, 7.5f, 1.00f, -10000, -10000, 0, 1.00f, 1.00f, 1.0f, -2602, 0.007f, 0.0f,0.0f,0.0f, 200, 0.011f, 0.0f,0.0f,0.0f, 0.250f, 0.00f, 0.25f, 0.000f, -5.0f, 5000.0f, 250.0f, 0.0f, 0.0f, 0.0f, 0x33f }
|
||||
};
|
||||
|
||||
ReverbContainer *DefaultEnvironments[26] =
|
||||
|
@ -486,6 +486,7 @@ static void ReadEAX (int lump, const char *lumpname)
|
|||
id2 = sc.Number;
|
||||
sc.MustGetStringName ("{");
|
||||
memset (inited, 0, sizeof(inited));
|
||||
props.Instance = 0;
|
||||
props.Flags = 0;
|
||||
while (sc.MustGetString (), NUM_EAX_FIELDS > (i = sc.MustMatchString (EAXFieldNames)))
|
||||
{
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
//
|
||||
//
|
||||
// DESCRIPTION: none
|
||||
// Dolby Pro Logic code by Gavino.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -74,11 +73,11 @@
|
|||
|
||||
#define NORM_PITCH 128
|
||||
#define NORM_PRIORITY 64
|
||||
#define NORM_SEP 128
|
||||
#define NORM_SEP 0
|
||||
#define NONE_SEP -2
|
||||
|
||||
#define S_PITCH_PERTURB 1
|
||||
#define S_STEREO_SWING (96<<FRACBITS)
|
||||
#define S_STEREO_SWING 0.25f
|
||||
|
||||
/* Sound curve parameters for Doom */
|
||||
|
||||
|
@ -89,7 +88,7 @@ const int S_CLIPPING_DIST = 1200;
|
|||
// Originally: 200.
|
||||
const int S_CLOSE_DIST = 160;
|
||||
|
||||
const int S_ATTENUATOR = S_CLIPPING_DIST - S_CLOSE_DIST;
|
||||
const float S_ATTENUATOR = S_CLIPPING_DIST - S_CLOSE_DIST;
|
||||
|
||||
// TYPES -------------------------------------------------------------------
|
||||
|
||||
|
@ -146,7 +145,7 @@ static bool SoundPaused; // whether sound effects are paused
|
|||
static bool MusicPaused; // whether music is paused
|
||||
static MusPlayingInfo mus_playing; // music currently being played
|
||||
static FString LastSong; // last music that was played
|
||||
static BYTE *SoundCurve;
|
||||
static float *SoundCurve;
|
||||
static int nextcleanup;
|
||||
static FPlayList *PlayList;
|
||||
|
||||
|
@ -158,8 +157,7 @@ int numChannels;
|
|||
|
||||
CVAR (Bool, snd_surround, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // [RH] Use surround sounds?
|
||||
FBoolCVar noisedebug ("noise", false, 0); // [RH] Print sound debugging info?
|
||||
CVAR (Int, snd_channels, 12, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // number of channels available
|
||||
CVAR (Bool, snd_matrix, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Int, snd_channels, 32, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // number of channels available
|
||||
CVAR (Bool, snd_flipstereo, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
@ -282,35 +280,41 @@ void S_Init ()
|
|||
atterm (S_Shutdown);
|
||||
|
||||
// remove old data (S_Init can be called multiple times!)
|
||||
if (SoundCurve) delete [] SoundCurve;
|
||||
if (SoundCurve)
|
||||
{
|
||||
delete[] SoundCurve;
|
||||
}
|
||||
|
||||
// Heretic and Hexen have sound curve lookup tables. Doom does not.
|
||||
curvelump = Wads.CheckNumForName ("SNDCURVE");
|
||||
if (curvelump >= 0)
|
||||
{
|
||||
MAX_SND_DIST = Wads.LumpLength (curvelump);
|
||||
SoundCurve = new BYTE[MAX_SND_DIST];
|
||||
Wads.ReadLump (curvelump, SoundCurve);
|
||||
SoundCurve = new float[MAX_SND_DIST];
|
||||
FMemLump lump = Wads.ReadLump(curvelump);
|
||||
BYTE *lumpmem = (BYTE *)lump.GetMem();
|
||||
|
||||
// The maximum value in a SNDCURVE lump is 127, so scale it to
|
||||
// fit our sound system's volume levels.
|
||||
// fit our sound system's volume levels. Also, FMOD's volumes
|
||||
// are linear, whereas we want the "dumb" logarithmic volumes
|
||||
// for our "2D" sounds.
|
||||
for (i = 0; i < S_CLIPPING_DIST; ++i)
|
||||
{
|
||||
SoundCurve[i] = SoundCurve[i] * 255 / 127;
|
||||
SoundCurve[i] = (powf(10.f, (lumpmem[i] / 127.f)) - 1.f) / 9.f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MAX_SND_DIST = S_CLIPPING_DIST;
|
||||
SoundCurve = new BYTE[S_CLIPPING_DIST];
|
||||
SoundCurve = new float[S_CLIPPING_DIST];
|
||||
for (i = 0; i < S_CLIPPING_DIST; ++i)
|
||||
{
|
||||
SoundCurve[i] = MIN (255, (S_CLIPPING_DIST - i) * 255 / S_ATTENUATOR);
|
||||
SoundCurve[i] = (powf(10.f, MIN(1.f, (S_CLIPPING_DIST - i) / S_ATTENUATOR)) - 1.f) / 9.f;
|
||||
}
|
||||
}
|
||||
|
||||
// Allocating the virtual channels
|
||||
numChannels = GSnd ? GSnd->SetChannels (snd_channels) : 0;
|
||||
numChannels = GSnd ? GSnd->GetNumChannels() : 0;
|
||||
if (Channel != NULL)
|
||||
{
|
||||
delete[] Channel;
|
||||
|
@ -594,11 +598,12 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
|
|||
int sound_id, float volume, float attenuation, bool looping)
|
||||
{
|
||||
sfxinfo_t *sfx;
|
||||
int dist, vol;
|
||||
int dist;
|
||||
float vol;
|
||||
int i;
|
||||
int chanflags;
|
||||
int basepriority, priority;
|
||||
int sep;
|
||||
float sep;
|
||||
int org_id;
|
||||
fixed_t x, y, z;
|
||||
angle_t angle;
|
||||
|
@ -655,7 +660,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
|
|||
}
|
||||
else if (attenuation < 0)
|
||||
{
|
||||
sep = snd_surround ? -1 : NONE_SEP;
|
||||
sep = NONE_SEP;
|
||||
dist = 0;
|
||||
}
|
||||
else
|
||||
|
@ -827,7 +832,7 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
|
|||
}
|
||||
}
|
||||
|
||||
vol = (int)(SoundCurve[dist]*volume);
|
||||
vol = SoundCurve[dist] * volume;
|
||||
if (sep == -3)
|
||||
{
|
||||
AActor *listener = players[consoleplayer].camera;
|
||||
|
@ -846,21 +851,10 @@ static void S_StartSound (fixed_t *pt, AActor *mover, int channel,
|
|||
angle = angle - listener->angle;
|
||||
else
|
||||
angle = angle + (ANGLE_MAX - listener->angle);
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
sep = NORM_SEP - (FixedMul (S_STEREO_SWING, finesine[angle])>>FRACBITS);
|
||||
sep = NORM_SEP - S_STEREO_SWING * sin((angle >> 1) * M_PI / 2147483648.0);
|
||||
if (snd_flipstereo)
|
||||
{
|
||||
sep = 255-sep;
|
||||
}
|
||||
if (snd_matrix)
|
||||
{
|
||||
int rearsep = NORM_SEP -
|
||||
(FixedMul (S_STEREO_SWING, finecosine[angle])>>FRACBITS);
|
||||
if (rearsep > 128)
|
||||
{
|
||||
sep = -1;
|
||||
attenuation = -1;
|
||||
}
|
||||
sep = -sep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1308,9 +1302,9 @@ void S_UpdateSounds (void *listener_p)
|
|||
{
|
||||
fixed_t *listener;
|
||||
fixed_t x, y;
|
||||
int i, dist, vol;
|
||||
int i, dist;
|
||||
angle_t angle;
|
||||
int sep;
|
||||
float vol, sep;
|
||||
|
||||
I_UpdateMusic();
|
||||
|
||||
|
@ -1366,7 +1360,7 @@ void S_UpdateSounds (void *listener_p)
|
|||
{
|
||||
dist = 0;
|
||||
}
|
||||
vol = (int)(SoundCurve[dist]*Channel[i].volume);
|
||||
vol = SoundCurve[dist] * Channel[i].volume;
|
||||
if (dist > 0)
|
||||
{
|
||||
angle = R_PointToAngle2(listener[0], listener[1], x, y);
|
||||
|
@ -1374,20 +1368,10 @@ void S_UpdateSounds (void *listener_p)
|
|||
angle = angle - players[consoleplayer].camera->angle;
|
||||
else
|
||||
angle = angle + (ANGLE_MAX - players[consoleplayer].camera->angle);
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
sep = NORM_SEP - (FixedMul (S_STEREO_SWING, finesine[angle])>>FRACBITS);
|
||||
sep = NORM_SEP - S_STEREO_SWING * sin((angle >> 1) * M_PI / 2147483648.0);
|
||||
if (snd_flipstereo)
|
||||
{
|
||||
sep = 255-sep;
|
||||
}
|
||||
if (snd_matrix)
|
||||
{
|
||||
int rearsep = NORM_SEP -
|
||||
(FixedMul (S_STEREO_SWING, finecosine[angle])>>FRACBITS);
|
||||
if (rearsep > 128)
|
||||
{
|
||||
sep = -1;
|
||||
}
|
||||
sep = -sep;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -208,12 +208,13 @@ void S_ShrinkPlayerSoundLists ();
|
|||
// Modelled after Hexen's noise cheat.
|
||||
void S_NoiseDebug ();
|
||||
|
||||
// For convenience, this structure matches FSOUND_REVERB_PROPERTIES.
|
||||
// For convenience, this structure matches FMOD_REVERB_PROPERTIES.
|
||||
// Since I can't very well #include system-specific stuff in the
|
||||
// main game files, I duplicate it here.
|
||||
struct REVERB_PROPERTIES
|
||||
{
|
||||
/*unsigned*/int Environment;
|
||||
{
|
||||
int Instance;
|
||||
int Environment;
|
||||
float EnvSize;
|
||||
float EnvDiffusion;
|
||||
int Room;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,106 +0,0 @@
|
|||
#ifndef ALTSOUND_H
|
||||
#define ALTSOUND_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
|
||||
#include "i_sound.h"
|
||||
|
||||
class AltSoundRenderer : public SoundRenderer
|
||||
{
|
||||
public:
|
||||
AltSoundRenderer ();
|
||||
~AltSoundRenderer ();
|
||||
bool IsValid ();
|
||||
|
||||
void SetSfxVolume (float volume);
|
||||
int SetChannels (int numchans);
|
||||
void LoadSound (sfxinfo_t *sfx);
|
||||
void UnloadSound (sfxinfo_t *sfx);
|
||||
|
||||
// Streaming sounds. PlayStream returns a channel handle that can be used with StopSound.
|
||||
SoundStream *CreateStream (SoundStreamCallback callback, int buffsamples, int flags, int samplerate, void *userdata);
|
||||
SoundStream *OpenStream (const char *filename, int flags, int offset, int length);
|
||||
|
||||
// Starts a sound in a particular sound channel.
|
||||
long StartSound (sfxinfo_t *sfx, int vol, int sep, int pitch, int channel, bool looping, bool pauseable);
|
||||
|
||||
// Stops a sound channel.
|
||||
void StopSound (long handle);
|
||||
|
||||
// Stops all sounds.
|
||||
void StopAllChannels ();
|
||||
|
||||
// Pauses or resumes all sound effect channels.
|
||||
void SetSfxPaused (bool paused);
|
||||
|
||||
// Returns true if the channel is still playing a sound.
|
||||
bool IsPlayingSound (long handle);
|
||||
|
||||
// Updates the volume, separation, and pitch of a sound channel.
|
||||
void UpdateSoundParams (long handle, int vol, int sep, int pitch);
|
||||
|
||||
// For use by I_PlayMovie
|
||||
void MovieDisableSound ();
|
||||
void MovieResumeSound ();
|
||||
|
||||
void UpdateSounds ();
|
||||
|
||||
void PrintStatus ();
|
||||
void PrintDriversList ();
|
||||
FString GatherStats ();
|
||||
|
||||
private:
|
||||
struct Channel;
|
||||
struct Stream;
|
||||
|
||||
LPDIRECTSOUND lpds;
|
||||
LPDIRECTSOUNDBUFFER lpdsb, lpdsbPrimary;
|
||||
|
||||
int Frequency;
|
||||
bool SimpleDown;
|
||||
int Amp;
|
||||
DWORD BufferSamples, BufferBytes;
|
||||
DWORD WritePos;
|
||||
DWORD BufferTime;
|
||||
DWORD MaxWaitTime;
|
||||
SDWORD *RenderBuffer;
|
||||
HANDLE MixerThread;
|
||||
HANDLE MixerEvent;
|
||||
bool MixerQuit;
|
||||
|
||||
enum { NUM_PERFMETERS = 32 };
|
||||
double PerfMeter[NUM_PERFMETERS];
|
||||
int CurPerfMeter;
|
||||
|
||||
Channel *Channels;
|
||||
int NumChannels;
|
||||
Stream *Streams;
|
||||
CRITICAL_SECTION StreamCriticalSection;
|
||||
|
||||
bool DidInit;
|
||||
|
||||
bool Init ();
|
||||
void Shutdown ();
|
||||
|
||||
void CopyAndClip (SWORD *buffer, DWORD count, DWORD start);
|
||||
void UpdateSound ();
|
||||
void AddChannel8 (Channel *chan, DWORD count);
|
||||
void AddChannel16 (Channel *chan, DWORD count);
|
||||
void AddStream8 (Stream *chan, DWORD count);
|
||||
void AddStream16 (Stream *chan, DWORD count);
|
||||
static DWORD WINAPI MixerThreadFunc (LPVOID param);
|
||||
|
||||
static SQWORD MixMono8 (SDWORD *dest, const SBYTE *src, DWORD count, SQWORD pos, SQWORD step, int leftvol, int rightvol);
|
||||
static SQWORD MixMono16 (SDWORD *dest, const SWORD *src, DWORD count, SQWORD pos, SQWORD step, int leftvol, int rightvol);
|
||||
static SQWORD MixStereo8 (SDWORD *dest, const SBYTE *src, DWORD count, SQWORD pos, SQWORD step, int vol);
|
||||
static SQWORD MixStereo16 (SDWORD *dest, const SWORD *src, DWORD count, SQWORD pos, SQWORD step, int vol);
|
||||
};
|
||||
|
||||
class AltSoundStream : public SoundStream
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,156 +0,0 @@
|
|||
#ifdef _WIN32
|
||||
|
||||
#define USE_WINDOWS_DWORD
|
||||
#include "altsound.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
EXTERN_CVAR (Int, snd_interpolate)
|
||||
|
||||
// These macros implement linear interpolation
|
||||
|
||||
__forceinline SDWORD lininterp (SDWORD sample1, SDWORD sample2, DWORD frac)
|
||||
{
|
||||
return sample1 + MulScale30 (frac >> 2, sample2 - sample1);
|
||||
}
|
||||
|
||||
#define INTERPOLATEL \
|
||||
SDWORD sample = lininterp ((SDWORD)src[pos.HighPart], (SDWORD)src[pos.HighPart+1], pos.LowPart);
|
||||
|
||||
#define INTERPOLATEL2 \
|
||||
SDWORD samplel = lininterp ((SDWORD)src[pos.HighPart*2+0], (SDWORD)src[pos.HighPart*2+2], pos.LowPart); \
|
||||
SDWORD sampler = lininterp ((SDWORD)src[pos.HighPart*2+1], (SDWORD)src[pos.HighPart*2+3], pos.LowPart);
|
||||
|
||||
// These macros implement quadratic interpolation
|
||||
|
||||
__forceinline SDWORD quadraticinterp (SDWORD sample1, SDWORD sample2, SDWORD sample3, DWORD frac)
|
||||
{
|
||||
|
||||
SDWORD a = sample1 - 2*sample2 + sample3;
|
||||
SDWORD b = -3*sample1 + 4*sample2 - sample3;
|
||||
frac >>= 17;
|
||||
return MulScale31 (a, frac*frac) + MulScale16 (b, frac) + sample1;
|
||||
}
|
||||
|
||||
#define INTERPOLATEQ \
|
||||
SDWORD sample = quadraticinterp ((SDWORD)src[pos.HighPart], \
|
||||
(SDWORD)src[pos.HighPart + 1], \
|
||||
(SDWORD)src[pos.HighPart + 2], \
|
||||
pos.LowPart);
|
||||
|
||||
#define INTERPOLATEQ2 \
|
||||
SDWORD samplel = quadraticinterp ((SDWORD)src[pos.HighPart*2], \
|
||||
(SDWORD)src[pos.HighPart*2 + 2], \
|
||||
(SDWORD)src[pos.HighPart*2 + 4], \
|
||||
pos.LowPart); \
|
||||
SDWORD sampler = quadraticinterp ((SDWORD)src[pos.HighPart*2 + 1], \
|
||||
(SDWORD)src[pos.HighPart*2 + 3], \
|
||||
(SDWORD)src[pos.HighPart*2 + 5], \
|
||||
pos.LowPart);
|
||||
|
||||
/* Possible snd_interpolate values:
|
||||
0: No interpolation
|
||||
1: Linear interpolation
|
||||
2: Quadratic interpolation
|
||||
*/
|
||||
#define MONO_MIXER \
|
||||
LARGE_INTEGER pos; \
|
||||
\
|
||||
switch (snd_interpolate) \
|
||||
{ \
|
||||
default: \
|
||||
for (pos.QuadPart = inpos; count; --count) \
|
||||
{ \
|
||||
SDWORD sample = (SDWORD)src[pos.HighPart]; \
|
||||
pos.QuadPart += step; \
|
||||
dest[0] += sample * leftvol; \
|
||||
dest[1] += sample * rightvol; \
|
||||
dest += 2; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 1: \
|
||||
for (pos.QuadPart = inpos; count; --count) \
|
||||
{ \
|
||||
INTERPOLATEL \
|
||||
pos.QuadPart += step; \
|
||||
dest[0] += sample * leftvol; \
|
||||
dest[1] += sample * rightvol; \
|
||||
dest += 2; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
for (pos.QuadPart = inpos; count; --count) \
|
||||
{ \
|
||||
INTERPOLATEQ \
|
||||
pos.QuadPart += step; \
|
||||
dest[0] += sample * leftvol; \
|
||||
dest[1] += sample * rightvol; \
|
||||
dest += 2; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
return pos.QuadPart;
|
||||
|
||||
#define STEREO_MIXER \
|
||||
LARGE_INTEGER pos; \
|
||||
\
|
||||
switch (snd_interpolate) \
|
||||
{ \
|
||||
default: \
|
||||
for (pos.QuadPart = inpos; count; --count) \
|
||||
{ \
|
||||
SDWORD samplel = (SDWORD)src[pos.HighPart*2]; \
|
||||
SDWORD sampler = (SDWORD)src[pos.HighPart*2+1]; \
|
||||
pos.QuadPart += step; \
|
||||
dest[0] += samplel * vol; \
|
||||
dest[1] += sampler * vol; \
|
||||
dest += 2; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 1: \
|
||||
for (pos.QuadPart = inpos; count; --count) \
|
||||
{ \
|
||||
INTERPOLATEL2 \
|
||||
pos.QuadPart += step; \
|
||||
dest[0] += samplel * vol; \
|
||||
dest[1] += sampler * vol; \
|
||||
dest += 2; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 2: \
|
||||
for (pos.QuadPart = inpos; count; --count) \
|
||||
{ \
|
||||
INTERPOLATEQ2 \
|
||||
pos.QuadPart += step; \
|
||||
dest[0] += samplel * vol; \
|
||||
dest[1] += sampler * vol; \
|
||||
dest += 2; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
return pos.QuadPart;
|
||||
|
||||
SQWORD AltSoundRenderer::MixMono8 (SDWORD *dest, const SBYTE *src, DWORD count, SQWORD inpos, SQWORD step, int leftvol, int rightvol)
|
||||
{
|
||||
MONO_MIXER
|
||||
}
|
||||
|
||||
SQWORD AltSoundRenderer::MixMono16 (SDWORD *dest, const SWORD *src, DWORD count, SQWORD inpos, SQWORD step, int leftvol, int rightvol)
|
||||
{
|
||||
MONO_MIXER
|
||||
}
|
||||
|
||||
SQWORD AltSoundRenderer::MixStereo8 (SDWORD *dest, const SBYTE *src, DWORD count, SQWORD inpos, SQWORD step, int vol)
|
||||
{
|
||||
STEREO_MIXER
|
||||
}
|
||||
|
||||
SQWORD AltSoundRenderer::MixStereo16 (SDWORD *dest, const SWORD *src, DWORD count, SQWORD inpos, SQWORD step, int vol)
|
||||
{
|
||||
STEREO_MIXER
|
||||
}
|
||||
|
||||
#endif
|
568
src/sound/fmod_wrap.h
Normal file
568
src/sound/fmod_wrap.h
Normal file
|
@ -0,0 +1,568 @@
|
|||
|
||||
#ifndef FMOD_WRAP_H
|
||||
#define FMOD_WRAP_H
|
||||
|
||||
#if !defined(_WIN32) || defined(_MSC_VER)
|
||||
// Use the real C++ interface if it's supported on this platform.
|
||||
#include "fmod.hpp"
|
||||
#else
|
||||
// Use a wrapper C++ interface for non-Microsoft compilers on Windows.
|
||||
|
||||
#include "fmod.h"
|
||||
|
||||
// Create fake definitions for these structs so they can be subclassed.
|
||||
struct FMOD_SYSTEM {};
|
||||
struct FMOD_SOUND {};
|
||||
struct FMOD_CHANNEL {};
|
||||
struct FMOD_CHANNELGROUP {};
|
||||
struct FMOD_SOUNDGROUP {};
|
||||
struct FMOD_REVERB {};
|
||||
struct FMOD_DSP {};
|
||||
struct FMOD_POLYGON {};
|
||||
struct FMOD_GEOMETRY {};
|
||||
struct FMOD_SYNCPOINT {};
|
||||
/*
|
||||
Constant and defines
|
||||
*/
|
||||
|
||||
/*
|
||||
FMOD Namespace
|
||||
*/
|
||||
|
||||
namespace FMOD
|
||||
{
|
||||
|
||||
class System;
|
||||
class Sound;
|
||||
class Channel;
|
||||
class ChannelGroup;
|
||||
class SoundGroup;
|
||||
class Reverb;
|
||||
class DSP;
|
||||
class Geometry;
|
||||
|
||||
/*
|
||||
FMOD global system functions (optional).
|
||||
*/
|
||||
inline FMOD_RESULT Memory_Initialize(void *poolmem, int poollen, FMOD_MEMORY_ALLOCCALLBACK useralloc, FMOD_MEMORY_REALLOCCALLBACK userrealloc, FMOD_MEMORY_FREECALLBACK userfree) { return FMOD_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree); }
|
||||
inline FMOD_RESULT Memory_GetStats (int *currentalloced, int *maxalloced) { return FMOD_Memory_GetStats(currentalloced, maxalloced); }
|
||||
inline FMOD_RESULT Debug_SetLevel(FMOD_DEBUGLEVEL level) { return FMOD_Debug_SetLevel(level); }
|
||||
inline FMOD_RESULT Debug_GetLevel(FMOD_DEBUGLEVEL *level) { return FMOD_Debug_GetLevel(level); }
|
||||
inline FMOD_RESULT File_SetDiskBusy(int busy) { return FMOD_File_SetDiskBusy(busy); }
|
||||
inline FMOD_RESULT File_GetDiskBusy(int *busy) { return FMOD_File_GetDiskBusy(busy); }
|
||||
|
||||
/*
|
||||
FMOD System factory functions.
|
||||
*/
|
||||
inline FMOD_RESULT System_Create(System **system) { return FMOD_System_Create((FMOD_SYSTEM **)system); }
|
||||
|
||||
/*
|
||||
'System' API
|
||||
*/
|
||||
|
||||
class System : FMOD_SYSTEM
|
||||
{
|
||||
private:
|
||||
|
||||
System(); /* Constructor made private so user cannot statically instance a System class.
|
||||
System_Create must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_System_Release(this); }
|
||||
|
||||
// Pre-init functions.
|
||||
FMOD_RESULT setOutput (FMOD_OUTPUTTYPE output) { return FMOD_System_SetOutput(this, output); }
|
||||
FMOD_RESULT getOutput (FMOD_OUTPUTTYPE *output) { return FMOD_System_GetOutput(this, output); }
|
||||
FMOD_RESULT getNumDrivers (int *numdrivers) { return FMOD_System_GetNumDrivers(this, numdrivers); }
|
||||
FMOD_RESULT getDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid) { return FMOD_System_GetDriverInfo(this, id, name, namelen, guid); }
|
||||
FMOD_RESULT getDriverCaps (int id, FMOD_CAPS *caps, int *minfrequency, int *maxfrequency, FMOD_SPEAKERMODE *controlpanelspeakermode) { return FMOD_System_GetDriverCaps(this, id, caps, minfrequency, maxfrequency, controlpanelspeakermode); }
|
||||
FMOD_RESULT setDriver (int driver) { return FMOD_System_SetDriver(this, driver); }
|
||||
FMOD_RESULT getDriver (int *driver) { return FMOD_System_GetDriver(this, driver); }
|
||||
FMOD_RESULT setHardwareChannels (int min2d, int max2d, int min3d, int max3d) { return FMOD_System_SetHardwareChannels(this, min2d, max2d, min3d, max3d); }
|
||||
FMOD_RESULT setSoftwareChannels (int numsoftwarechannels) { return FMOD_System_SetSoftwareChannels(this, numsoftwarechannels); }
|
||||
FMOD_RESULT getSoftwareChannels (int *numsoftwarechannels) { return FMOD_System_GetSoftwareChannels(this, numsoftwarechannels); }
|
||||
FMOD_RESULT setSoftwareFormat (int samplerate, FMOD_SOUND_FORMAT format, int numoutputchannels, int maxinputchannels, FMOD_DSP_RESAMPLER resamplemethod) { return FMOD_System_SetSoftwareFormat(this, samplerate, format, numoutputchannels, maxinputchannels, resamplemethod); }
|
||||
FMOD_RESULT getSoftwareFormat (int *samplerate, FMOD_SOUND_FORMAT *format, int *numoutputchannels, int *maxinputchannels, FMOD_DSP_RESAMPLER *resamplemethod, int *bits) { return FMOD_System_GetSoftwareFormat(this, samplerate, format, numoutputchannels, maxinputchannels, resamplemethod, bits); }
|
||||
FMOD_RESULT setDSPBufferSize (unsigned int bufferlength, int numbuffers) { return FMOD_System_SetDSPBufferSize(this, bufferlength, numbuffers); }
|
||||
FMOD_RESULT getDSPBufferSize (unsigned int *bufferlength, int *numbuffers) { return FMOD_System_GetDSPBufferSize(this, bufferlength, numbuffers); }
|
||||
FMOD_RESULT setFileSystem (FMOD_FILE_OPENCALLBACK useropen, FMOD_FILE_CLOSECALLBACK userclose, FMOD_FILE_READCALLBACK userread, FMOD_FILE_SEEKCALLBACK userseek, int blockalign) { return FMOD_System_SetFileSystem(this, useropen, userclose, userread, userseek, blockalign); }
|
||||
FMOD_RESULT attachFileSystem (FMOD_FILE_OPENCALLBACK useropen, FMOD_FILE_CLOSECALLBACK userclose, FMOD_FILE_READCALLBACK userread, FMOD_FILE_SEEKCALLBACK userseek) { return FMOD_System_AttachFileSystem(this, useropen, userclose, userread, userseek); }
|
||||
FMOD_RESULT setAdvancedSettings (FMOD_ADVANCEDSETTINGS *settings) { return FMOD_System_SetAdvancedSettings(this, settings); }
|
||||
FMOD_RESULT getAdvancedSettings (FMOD_ADVANCEDSETTINGS *settings) { return FMOD_System_GetAdvancedSettings(this, settings); }
|
||||
FMOD_RESULT setSpeakerMode (FMOD_SPEAKERMODE speakermode) { return FMOD_System_SetSpeakerMode(this, speakermode); }
|
||||
FMOD_RESULT getSpeakerMode (FMOD_SPEAKERMODE *speakermode) { return FMOD_System_GetSpeakerMode(this, speakermode); }
|
||||
FMOD_RESULT setCallback (FMOD_SYSTEM_CALLBACKTYPE type, FMOD_SYSTEM_CALLBACK callback) { return FMOD_System_SetCallback(this, type, callback); }
|
||||
|
||||
// Plug-in support
|
||||
FMOD_RESULT setPluginPath (const char *path) { return FMOD_System_SetPluginPath(this, path); }
|
||||
FMOD_RESULT loadPlugin (const char *filename, FMOD_PLUGINTYPE *plugintype, int *index) { return FMOD_System_LoadPlugin(this, filename, plugintype, index); }
|
||||
FMOD_RESULT getNumPlugins (FMOD_PLUGINTYPE plugintype, int *numplugins) { return FMOD_System_GetNumPlugins(this, plugintype, numplugins); }
|
||||
FMOD_RESULT getPluginInfo (FMOD_PLUGINTYPE plugintype, int index, char *name, int namelen, unsigned int *version) { return FMOD_System_GetPluginInfo(this, plugintype, index, name, namelen, version); }
|
||||
FMOD_RESULT unloadPlugin (FMOD_PLUGINTYPE plugintype, int index) { return FMOD_System_UnloadPlugin(this, plugintype, index); }
|
||||
FMOD_RESULT setOutputByPlugin (int index) { return FMOD_System_SetOutputByPlugin(this, index); }
|
||||
FMOD_RESULT getOutputByPlugin (int *index) { return FMOD_System_GetOutputByPlugin(this, index); }
|
||||
FMOD_RESULT createCodec (FMOD_CODEC_DESCRIPTION *description) { return FMOD_System_CreateCodec(this, description); }
|
||||
|
||||
// Init/Close
|
||||
FMOD_RESULT init (int maxchannels, FMOD_INITFLAGS flags, void *extradriverdata) { return FMOD_System_Init(this, maxchannels, flags, extradriverdata); }
|
||||
FMOD_RESULT close () { return FMOD_System_Close(this); }
|
||||
|
||||
// General post-init system functions
|
||||
FMOD_RESULT update () /* IMPORTANT! CALL THIS ONCE PER FRAME! */ { return FMOD_System_Update(this); }
|
||||
|
||||
FMOD_RESULT set3DSettings (float dopplerscale, float distancefactor, float rolloffscale) { return FMOD_System_Set3DSettings(this, dopplerscale, distancefactor, rolloffscale); }
|
||||
FMOD_RESULT get3DSettings (float *dopplerscale, float *distancefactor, float *rolloffscale) { return FMOD_System_Get3DSettings(this, dopplerscale, distancefactor, rolloffscale); }
|
||||
FMOD_RESULT set3DNumListeners (int numlisteners) { return FMOD_System_Set3DNumListeners(this, numlisteners); }
|
||||
FMOD_RESULT get3DNumListeners (int *numlisteners) { return FMOD_System_Get3DNumListeners(this, numlisteners); }
|
||||
FMOD_RESULT set3DListenerAttributes(int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up) { return FMOD_System_Set3DListenerAttributes(this, listener, pos, vel, forward, up); }
|
||||
FMOD_RESULT get3DListenerAttributes(int listener, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *forward, FMOD_VECTOR *up) { return FMOD_System_Get3DListenerAttributes(this, listener, pos, vel, forward, up); }
|
||||
FMOD_RESULT set3DRolloffCallback (FMOD_3D_ROLLOFFCALLBACK callback) { return FMOD_System_Set3DRolloffCallback(this, callback); }
|
||||
FMOD_RESULT set3DSpeakerPosition (FMOD_SPEAKER speaker, float x, float y, bool active) { return FMOD_System_Set3DSpeakerPosition(this, speaker, x, y, active); }
|
||||
FMOD_RESULT get3DSpeakerPosition (FMOD_SPEAKER speaker, float *x, float *y, bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_System_Get3DSpeakerPosition(this, speaker, x, y, &b); *active = b; return res; }
|
||||
|
||||
FMOD_RESULT setStreamBufferSize (unsigned int filebuffersize, FMOD_TIMEUNIT filebuffersizetype) { return FMOD_System_SetStreamBufferSize(this, filebuffersize, filebuffersizetype); }
|
||||
FMOD_RESULT getStreamBufferSize (unsigned int *filebuffersize, FMOD_TIMEUNIT *filebuffersizetype) { return FMOD_System_GetStreamBufferSize(this, filebuffersize, filebuffersizetype); }
|
||||
|
||||
// System information functions.
|
||||
FMOD_RESULT getVersion (unsigned int *version) { return FMOD_System_GetVersion(this, version); }
|
||||
FMOD_RESULT getOutputHandle (void **handle) { return FMOD_System_GetOutputHandle(this, handle); }
|
||||
FMOD_RESULT getChannelsPlaying (int *channels) { return FMOD_System_GetChannelsPlaying(this, channels); }
|
||||
FMOD_RESULT getHardwareChannels (int *num2d, int *num3d, int *total) { return FMOD_System_GetHardwareChannels(this, num2d, num3d, total); }
|
||||
FMOD_RESULT getCPUUsage (float *dsp, float *stream, float *update, float *total) { return FMOD_System_GetCPUUsage(this, dsp, stream, update, total); }
|
||||
FMOD_RESULT getSoundRAM (int *currentalloced, int *maxalloced, int *total) { return FMOD_System_GetSoundRAM(this, currentalloced, maxalloced, total); }
|
||||
FMOD_RESULT getNumCDROMDrives (int *numdrives) { return FMOD_System_GetNumCDROMDrives(this, numdrives); }
|
||||
FMOD_RESULT getCDROMDriveName (int drive, char *drivename, int drivenamelen, char *scsiname, int scsinamelen, char *devicename, int devicenamelen) { return FMOD_System_GetCDROMDriveName(this, drive, drivename, drivenamelen, scsiname, scsinamelen, devicename, devicenamelen); }
|
||||
FMOD_RESULT getSpectrum (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype) { return FMOD_System_GetSpectrum(this, spectrumarray, numvalues, channeloffset, windowtype); }
|
||||
FMOD_RESULT getWaveData (float *wavearray, int numvalues, int channeloffset) { return FMOD_System_GetWaveData(this, wavearray, numvalues, channeloffset); }
|
||||
|
||||
// Sound/DSP/Channel/FX creation and retrieval.
|
||||
FMOD_RESULT createSound (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound) { return FMOD_System_CreateSound(this, name_or_data, mode, exinfo, (FMOD_SOUND **)sound); }
|
||||
FMOD_RESULT createStream (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound) { return FMOD_System_CreateStream(this, name_or_data, mode, exinfo, (FMOD_SOUND **)sound); }
|
||||
FMOD_RESULT createDSP (FMOD_DSP_DESCRIPTION *description, DSP **dsp) { return FMOD_System_CreateDSP(this, description, (FMOD_DSP **)dsp); }
|
||||
FMOD_RESULT createDSPByType (FMOD_DSP_TYPE type, DSP **dsp) { return FMOD_System_CreateDSPByType(this, type, (FMOD_DSP **)dsp); }
|
||||
FMOD_RESULT createDSPByIndex (int index, DSP **dsp) { return FMOD_System_CreateDSPByIndex(this, index, (FMOD_DSP **)dsp); }
|
||||
FMOD_RESULT createChannelGroup (const char *name, ChannelGroup **channelgroup) { return FMOD_System_CreateChannelGroup(this, name, (FMOD_CHANNELGROUP **)channelgroup); }
|
||||
FMOD_RESULT createSoundGroup (const char *name, SoundGroup **soundgroup) { return FMOD_System_CreateSoundGroup(this, name, (FMOD_SOUNDGROUP **)soundgroup); }
|
||||
FMOD_RESULT createReverb (Reverb **reverb) { return FMOD_System_CreateReverb(this, (FMOD_REVERB **)reverb); }
|
||||
|
||||
FMOD_RESULT playSound (FMOD_CHANNELINDEX channelid, Sound *sound, bool paused, Channel **channel) { return FMOD_System_PlaySound(this, channelid, (FMOD_SOUND *)sound, paused, (FMOD_CHANNEL **)channel); }
|
||||
FMOD_RESULT playDSP (FMOD_CHANNELINDEX channelid, DSP *dsp, bool paused, Channel **channel) { return FMOD_System_PlayDSP(this, channelid, (FMOD_DSP *)dsp, paused, (FMOD_CHANNEL **)channel); }
|
||||
FMOD_RESULT getChannel (int channelid, Channel **channel) { return FMOD_System_GetChannel(this, channelid, (FMOD_CHANNEL **)channel); }
|
||||
FMOD_RESULT getMasterChannelGroup (ChannelGroup **channelgroup) { return FMOD_System_GetMasterChannelGroup(this, (FMOD_CHANNELGROUP **)channelgroup); }
|
||||
FMOD_RESULT getMasterSoundGroup (SoundGroup **soundgroup) { return FMOD_System_GetMasterSoundGroup(this, (FMOD_SOUNDGROUP **)soundgroup); }
|
||||
|
||||
// Reverb API
|
||||
FMOD_RESULT setReverbProperties (const FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_SetReverbProperties(this, prop); }
|
||||
FMOD_RESULT getReverbProperties (FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_GetReverbProperties(this, prop); }
|
||||
FMOD_RESULT setReverbAmbientProperties(FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_SetReverbAmbientProperties(this, prop); }
|
||||
FMOD_RESULT getReverbAmbientProperties(FMOD_REVERB_PROPERTIES *prop) { return FMOD_System_GetReverbAmbientProperties(this, prop); }
|
||||
|
||||
// System level DSP access.
|
||||
FMOD_RESULT getDSPHead (DSP **dsp) { return FMOD_System_GetDSPHead(this, (FMOD_DSP **)dsp); }
|
||||
FMOD_RESULT addDSP (DSP *dsp) { return FMOD_System_AddDSP(this, (FMOD_DSP *)dsp); }
|
||||
FMOD_RESULT lockDSP () { return FMOD_System_LockDSP(this); }
|
||||
FMOD_RESULT unlockDSP () { return FMOD_System_UnlockDSP(this); }
|
||||
|
||||
// Recording API.
|
||||
FMOD_RESULT setRecordDriver (int driver) { return FMOD_System_SetRecordDriver(this, driver); }
|
||||
FMOD_RESULT getRecordDriver (int *driver) { return FMOD_System_GetRecordDriver(this, driver); }
|
||||
FMOD_RESULT getRecordNumDrivers (int *numdrivers) { return FMOD_System_GetRecordNumDrivers(this, numdrivers); }
|
||||
FMOD_RESULT getRecordDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid) { return FMOD_System_GetRecordDriverInfo(this, id, name, namelen, guid); }
|
||||
FMOD_RESULT getRecordDriverCaps (int id, FMOD_CAPS *caps, int *minfrequency, int *maxfrequency) { return FMOD_System_GetRecordDriverCaps(this, id, caps, minfrequency, maxfrequency); }
|
||||
FMOD_RESULT getRecordPosition (unsigned int *position) { return FMOD_System_GetRecordPosition(this, position); }
|
||||
|
||||
FMOD_RESULT recordStart (Sound *sound, bool loop) { return FMOD_System_RecordStart(this, (FMOD_SOUND *)sound, loop); }
|
||||
FMOD_RESULT recordStop () { return FMOD_System_RecordStop(this); }
|
||||
FMOD_RESULT isRecording (bool *recording) { FMOD_BOOL b; FMOD_RESULT res = FMOD_System_IsRecording(this, &b); *recording = b; return res; }
|
||||
|
||||
// Geometry API.
|
||||
FMOD_RESULT createGeometry (int maxpolygons, int maxvertices, Geometry **geometry) { return FMOD_System_CreateGeometry(this, maxpolygons, maxvertices, (FMOD_GEOMETRY **)geometry); }
|
||||
FMOD_RESULT setGeometrySettings (float maxworldsize) { return FMOD_System_SetGeometrySettings(this, maxworldsize); }
|
||||
FMOD_RESULT getGeometrySettings (float *maxworldsize) { return FMOD_System_GetGeometrySettings(this, maxworldsize); }
|
||||
FMOD_RESULT loadGeometry (const void *data, int datasize, Geometry **geometry) { return FMOD_System_LoadGeometry(this, data, datasize, (FMOD_GEOMETRY **)geometry); }
|
||||
|
||||
// Network functions.
|
||||
FMOD_RESULT setNetworkProxy (const char *proxy) { return FMOD_System_SetNetworkProxy(this, proxy); }
|
||||
FMOD_RESULT getNetworkProxy (char *proxy, int proxylen) { return FMOD_System_GetNetworkProxy(this, proxy, proxylen); }
|
||||
FMOD_RESULT setNetworkTimeout (int timeout) { return FMOD_System_SetNetworkTimeout(this, timeout); }
|
||||
FMOD_RESULT getNetworkTimeout (int *timeout) { return FMOD_System_GetNetworkTimeout(this, timeout); }
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_System_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_System_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
/*
|
||||
'Sound' API
|
||||
*/
|
||||
class Sound : FMOD_SOUND
|
||||
{
|
||||
private:
|
||||
|
||||
Sound(); /* Constructor made private so user cannot statically instance a Sound class.
|
||||
Appropriate Sound creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_Sound_Release(this); }
|
||||
FMOD_RESULT getSystemObject (System **system) { return FMOD_Sound_GetSystemObject(this, (FMOD_SYSTEM **)system); }
|
||||
|
||||
// Standard sound manipulation functions.
|
||||
FMOD_RESULT lock (unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2) { return FMOD_Sound_Lock(this, offset, length, ptr1, ptr2, len1, len2); }
|
||||
FMOD_RESULT unlock (void *ptr1, void *ptr2, unsigned int len1, unsigned int len2) { return FMOD_Sound_Unlock(this, ptr1, ptr2, len1, len2); }
|
||||
FMOD_RESULT setDefaults (float frequency, float volume, float pan, int priority) { return FMOD_Sound_SetDefaults(this, frequency, volume, pan, priority); }
|
||||
FMOD_RESULT getDefaults (float *frequency, float *volume, float *pan, int *priority) { return FMOD_Sound_GetDefaults(this, frequency, volume, pan, priority); }
|
||||
FMOD_RESULT setVariations (float frequencyvar, float volumevar, float panvar) { return FMOD_Sound_SetVariations(this, frequencyvar, volumevar, panvar); }
|
||||
FMOD_RESULT getVariations (float *frequencyvar, float *volumevar, float *panvar) { return FMOD_Sound_GetVariations(this, frequencyvar, volumevar, panvar); }
|
||||
FMOD_RESULT set3DMinMaxDistance (float min, float max) { return FMOD_Sound_Set3DMinMaxDistance(this, min, max); }
|
||||
FMOD_RESULT get3DMinMaxDistance (float *min, float *max) { return FMOD_Sound_Get3DMinMaxDistance(this, min, max); }
|
||||
FMOD_RESULT set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume) { return FMOD_Sound_Set3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
|
||||
FMOD_RESULT get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume) { return FMOD_Sound_Get3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
|
||||
FMOD_RESULT set3DCustomRolloff (FMOD_VECTOR *points, int numpoints) { return FMOD_Sound_Set3DCustomRolloff(this, points, numpoints); }
|
||||
FMOD_RESULT get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints) { return FMOD_Sound_Get3DCustomRolloff(this, points, numpoints); }
|
||||
FMOD_RESULT setSubSound (int index, Sound *subsound) { return FMOD_Sound_SetSubSound(this, index, subsound); }
|
||||
FMOD_RESULT getSubSound (int index, Sound **subsound) { return FMOD_Sound_GetSubSound(this, index, (FMOD_SOUND **)subsound); }
|
||||
FMOD_RESULT setSubSoundSentence (int *subsoundlist, int numsubsounds) { return FMOD_Sound_SetSubSoundSentence(this, subsoundlist, numsubsounds); }
|
||||
FMOD_RESULT getName (char *name, int namelen) { return FMOD_Sound_GetName(this, name, namelen); }
|
||||
FMOD_RESULT getLength (unsigned int *length, FMOD_TIMEUNIT lengthtype) { return FMOD_Sound_GetLength(this, length, lengthtype); }
|
||||
FMOD_RESULT getFormat (FMOD_SOUND_TYPE *type, FMOD_SOUND_FORMAT *format, int *channels, int *bits) { return FMOD_Sound_GetFormat(this, type, format, channels, bits); }
|
||||
FMOD_RESULT getNumSubSounds (int *numsubsounds) { return FMOD_Sound_GetNumSubSounds(this, numsubsounds); }
|
||||
FMOD_RESULT getNumTags (int *numtags, int *numtagsupdated) { return FMOD_Sound_GetNumTags(this, numtags, numtagsupdated); }
|
||||
FMOD_RESULT getTag (const char *name, int index, FMOD_TAG *tag) { return FMOD_Sound_GetTag(this, name, index, tag); }
|
||||
FMOD_RESULT getOpenState (FMOD_OPENSTATE *openstate, unsigned int *percentbuffered, bool *starving) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Sound_GetOpenState(this, openstate, percentbuffered, &b); *starving = b; return res; }
|
||||
FMOD_RESULT readData (void *buffer, unsigned int lenbytes, unsigned int *read) { return FMOD_Sound_ReadData(this, buffer, lenbytes, read); }
|
||||
FMOD_RESULT seekData (unsigned int pcm) { return FMOD_Sound_SeekData(this, pcm); }
|
||||
|
||||
FMOD_RESULT setSoundGroup (SoundGroup *soundgroup) { return FMOD_Sound_SetSoundGroup(this, (FMOD_SOUNDGROUP *)soundgroup); }
|
||||
FMOD_RESULT getSoundGroup (SoundGroup **soundgroup) { return FMOD_Sound_GetSoundGroup(this, (FMOD_SOUNDGROUP **)soundgroup); }
|
||||
|
||||
// Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.
|
||||
FMOD_RESULT getNumSyncPoints (int *numsyncpoints) { return FMOD_Sound_GetNumSyncPoints(this, numsyncpoints); }
|
||||
FMOD_RESULT getSyncPoint (int index, FMOD_SYNCPOINT **point) { return FMOD_Sound_GetSyncPoint(this, index, point); }
|
||||
FMOD_RESULT getSyncPointInfo (FMOD_SYNCPOINT *point, char *name, int namelen, unsigned int *offset, FMOD_TIMEUNIT offsettype) { return FMOD_Sound_GetSyncPointInfo(this, point, name, namelen, offset, offsettype); }
|
||||
FMOD_RESULT addSyncPoint (unsigned int offset, FMOD_TIMEUNIT offsettype, const char *name, FMOD_SYNCPOINT **point) { return FMOD_Sound_AddSyncPoint(this, offset, offsettype, name, point); }
|
||||
FMOD_RESULT deleteSyncPoint (FMOD_SYNCPOINT *point) { return FMOD_Sound_DeleteSyncPoint(this, point); }
|
||||
|
||||
// Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
|
||||
FMOD_RESULT setMode (FMOD_MODE mode) { return FMOD_Sound_SetMode(this, mode); }
|
||||
FMOD_RESULT getMode (FMOD_MODE *mode) { return FMOD_Sound_GetMode(this, mode); }
|
||||
FMOD_RESULT setLoopCount (int loopcount) { return FMOD_Sound_SetLoopCount(this, loopcount); }
|
||||
FMOD_RESULT getLoopCount (int *loopcount) { return FMOD_Sound_GetLoopCount(this, loopcount); }
|
||||
FMOD_RESULT setLoopPoints (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Sound_SetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
|
||||
FMOD_RESULT getLoopPoints (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Sound_GetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_Sound_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_Sound_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
/*
|
||||
'Channel' API.
|
||||
*/
|
||||
class Channel : FMOD_CHANNEL
|
||||
{
|
||||
private:
|
||||
|
||||
Channel(); /* Constructor made private so user cannot statically instance a Channel class.
|
||||
Appropriate Channel creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT getSystemObject (System **system) { return FMOD_Channel_GetSystemObject(this, (FMOD_SYSTEM **)system); }
|
||||
|
||||
FMOD_RESULT stop () { return FMOD_Channel_Stop(this); }
|
||||
FMOD_RESULT setPaused (bool paused) { return FMOD_Channel_SetPaused(this, paused); }
|
||||
FMOD_RESULT getPaused (bool *paused) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_GetPaused(this, &b); *paused = b; return res; }
|
||||
FMOD_RESULT setVolume (float volume) { return FMOD_Channel_SetVolume(this, volume); }
|
||||
FMOD_RESULT getVolume (float *volume) { return FMOD_Channel_GetVolume(this, volume); }
|
||||
FMOD_RESULT setFrequency (float frequency) { return FMOD_Channel_SetFrequency(this, frequency); }
|
||||
FMOD_RESULT getFrequency (float *frequency) { return FMOD_Channel_GetFrequency(this, frequency); }
|
||||
FMOD_RESULT setPan (float pan) { return FMOD_Channel_SetPan(this, pan); }
|
||||
FMOD_RESULT getPan (float *pan) { return FMOD_Channel_GetPan(this, pan); }
|
||||
FMOD_RESULT setDelay (unsigned int startdelay, unsigned int enddelay) { return FMOD_Channel_SetDelay(this, startdelay, enddelay); }
|
||||
FMOD_RESULT getDelay (unsigned int *startdelay, unsigned int *enddelay) { return FMOD_Channel_GetDelay(this, startdelay, enddelay); }
|
||||
FMOD_RESULT setSpeakerMix (float frontleft, float frontright, float center, float lfe, float backleft, float backright, float sideleft, float sideright) { return FMOD_Channel_SetSpeakerMix(this, frontleft, frontright, center, lfe, backleft, backright, sideleft, sideright); }
|
||||
FMOD_RESULT getSpeakerMix (float *frontleft, float *frontright, float *center, float *lfe, float *backleft, float *backright, float *sideleft, float *sideright) { return FMOD_Channel_GetSpeakerMix(this, frontleft, frontright, center, lfe, backleft, backright, sideleft, sideright); }
|
||||
FMOD_RESULT setSpeakerLevels (FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_Channel_SetSpeakerLevels(this, speaker, levels, numlevels); }
|
||||
FMOD_RESULT getSpeakerLevels (FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_Channel_GetSpeakerLevels(this, speaker, levels, numlevels); }
|
||||
FMOD_RESULT setInputChannelMix (float *levels, int numlevels) { return FMOD_Channel_SetInputChannelMix(this, levels, numlevels); }
|
||||
FMOD_RESULT getInputChannelMix (float *levels, int numlevels) { return FMOD_Channel_GetInputChannelMix(this, levels, numlevels); }
|
||||
FMOD_RESULT setMute (bool mute) { return FMOD_Channel_SetMute(this, mute); }
|
||||
FMOD_RESULT getMute (bool *mute) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_GetMute(this, &b); *mute = b; return res; }
|
||||
FMOD_RESULT setPriority (int priority) { return FMOD_Channel_SetPriority(this, priority); }
|
||||
FMOD_RESULT getPriority (int *priority) { return FMOD_Channel_GetPriority(this, priority); }
|
||||
FMOD_RESULT setPosition (unsigned int position, FMOD_TIMEUNIT postype) { return FMOD_Channel_SetPosition(this, position, postype); }
|
||||
FMOD_RESULT getPosition (unsigned int *position, FMOD_TIMEUNIT postype) { return FMOD_Channel_GetPosition(this, position, postype); }
|
||||
FMOD_RESULT setReverbProperties (const FMOD_REVERB_CHANNELPROPERTIES *prop) { return FMOD_Channel_SetReverbProperties(this, prop); }
|
||||
FMOD_RESULT getReverbProperties (FMOD_REVERB_CHANNELPROPERTIES *prop) { return FMOD_Channel_GetReverbProperties(this, prop); }
|
||||
|
||||
FMOD_RESULT setChannelGroup (ChannelGroup *channelgroup) { return FMOD_Channel_SetChannelGroup(this, (FMOD_CHANNELGROUP *)channelgroup); }
|
||||
FMOD_RESULT getChannelGroup (ChannelGroup **channelgroup) { return FMOD_Channel_GetChannelGroup(this, (FMOD_CHANNELGROUP **)channelgroup); }
|
||||
FMOD_RESULT setCallback (FMOD_CHANNEL_CALLBACKTYPE type, FMOD_CHANNEL_CALLBACK callback, int command) { return FMOD_Channel_SetCallback(this, type, callback, command); }
|
||||
|
||||
// 3D functionality.
|
||||
FMOD_RESULT set3DAttributes (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel) { return FMOD_Channel_Set3DAttributes(this, pos, vel); }
|
||||
FMOD_RESULT get3DAttributes (FMOD_VECTOR *pos, FMOD_VECTOR *vel) { return FMOD_Channel_Get3DAttributes(this, pos, vel); }
|
||||
FMOD_RESULT set3DMinMaxDistance (float mindistance, float maxdistance) { return FMOD_Channel_Set3DMinMaxDistance(this, mindistance, maxdistance); }
|
||||
FMOD_RESULT get3DMinMaxDistance (float *mindistance, float *maxdistance) { return FMOD_Channel_Get3DMinMaxDistance(this, mindistance, maxdistance); }
|
||||
FMOD_RESULT set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume) { return FMOD_Channel_Set3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
|
||||
FMOD_RESULT get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume) { return FMOD_Channel_Get3DConeSettings(this, insideconeangle, outsideconeangle, outsidevolume); }
|
||||
FMOD_RESULT set3DConeOrientation (FMOD_VECTOR *orientation) { return FMOD_Channel_Set3DConeOrientation(this, orientation); }
|
||||
FMOD_RESULT get3DConeOrientation (FMOD_VECTOR *orientation) { return FMOD_Channel_Get3DConeOrientation(this, orientation); }
|
||||
FMOD_RESULT set3DCustomRolloff (FMOD_VECTOR *points, int numpoints) { return FMOD_Channel_Set3DCustomRolloff(this, points, numpoints); }
|
||||
FMOD_RESULT get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints) { return FMOD_Channel_Get3DCustomRolloff(this, points, numpoints); }
|
||||
FMOD_RESULT set3DOcclusion (float directocclusion, float reverbocclusion) { return FMOD_Channel_Set3DOcclusion(this, directocclusion, reverbocclusion); }
|
||||
FMOD_RESULT get3DOcclusion (float *directocclusion, float *reverbocclusion) { return FMOD_Channel_Get3DOcclusion(this, directocclusion, reverbocclusion); }
|
||||
FMOD_RESULT set3DSpread (float angle) { return FMOD_Channel_Set3DSpread(this, angle); }
|
||||
FMOD_RESULT get3DSpread (float *angle) { return FMOD_Channel_Get3DSpread(this, angle); }
|
||||
FMOD_RESULT set3DPanLevel (float level) { return FMOD_Channel_Set3DPanLevel(this, level); }
|
||||
FMOD_RESULT get3DPanLevel (float *level) { return FMOD_Channel_Get3DPanLevel(this, level); }
|
||||
FMOD_RESULT set3DDopplerLevel (float level) { return FMOD_Channel_Set3DDopplerLevel(this, level); }
|
||||
FMOD_RESULT get3DDopplerLevel (float *level) { return FMOD_Channel_Get3DDopplerLevel(this, level); }
|
||||
|
||||
// DSP functionality only for channels playing sounds created with FMOD_SOFTWARE.
|
||||
FMOD_RESULT getDSPHead (DSP **dsp) { return FMOD_Channel_GetDSPHead(this, (FMOD_DSP **)dsp); }
|
||||
FMOD_RESULT addDSP (DSP *dsp) { return FMOD_Channel_AddDSP(this, (FMOD_DSP *)dsp); }
|
||||
|
||||
// Information only functions.
|
||||
FMOD_RESULT isPlaying (bool *isplaying) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_IsPlaying(this, &b); *isplaying = b; return res; }
|
||||
FMOD_RESULT isVirtual (bool *isvirtual) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Channel_IsVirtual(this, &b); *isvirtual = b; return res; }
|
||||
FMOD_RESULT getAudibility (float *audibility) { return FMOD_Channel_GetAudibility(this, audibility); }
|
||||
FMOD_RESULT getCurrentSound (Sound **sound) { return FMOD_Channel_GetCurrentSound(this, (FMOD_SOUND **)sound); }
|
||||
FMOD_RESULT getSpectrum (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype) { return FMOD_Channel_GetSpectrum(this, spectrumarray, numvalues, channeloffset, windowtype); }
|
||||
FMOD_RESULT getWaveData (float *wavearray, int numvalues, int channeloffset) { return FMOD_Channel_GetWaveData(this, wavearray, numvalues, channeloffset); }
|
||||
FMOD_RESULT getIndex (int *index) { return FMOD_Channel_GetIndex(this, index); }
|
||||
|
||||
// Functions also found in Sound class but here they can be set per channel.
|
||||
FMOD_RESULT setMode (FMOD_MODE mode) { return FMOD_Channel_SetMode(this, mode); }
|
||||
FMOD_RESULT getMode (FMOD_MODE *mode) { return FMOD_Channel_GetMode(this, mode); }
|
||||
FMOD_RESULT setLoopCount (int loopcount) { return FMOD_Channel_SetLoopCount(this, loopcount); }
|
||||
FMOD_RESULT getLoopCount (int *loopcount) { return FMOD_Channel_GetLoopCount(this, loopcount); }
|
||||
FMOD_RESULT setLoopPoints (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Channel_SetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
|
||||
FMOD_RESULT getLoopPoints (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype) { return FMOD_Channel_GetLoopPoints(this, loopstart, loopstarttype, loopend, loopendtype); }
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_Channel_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_Channel_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
/*
|
||||
'ChannelGroup' API
|
||||
*/
|
||||
class ChannelGroup : FMOD_CHANNELGROUP
|
||||
{
|
||||
private:
|
||||
|
||||
ChannelGroup(); /* Constructor made private so user cannot statically instance a ChannelGroup class.
|
||||
Appropriate ChannelGroup creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_ChannelGroup_Release(this); }
|
||||
FMOD_RESULT getSystemObject (System **system) { return FMOD_ChannelGroup_GetSystemObject(this, (FMOD_SYSTEM **)system); }
|
||||
|
||||
// Channelgroup scale values. (changes attributes relative to the channels, doesn't overwrite them)
|
||||
FMOD_RESULT setVolume (float volume) { return FMOD_ChannelGroup_SetVolume(this, volume); }
|
||||
FMOD_RESULT getVolume (float *volume) { return FMOD_ChannelGroup_GetVolume(this, volume); }
|
||||
FMOD_RESULT setPitch (float pitch) { return FMOD_ChannelGroup_SetPitch(this, pitch); }
|
||||
FMOD_RESULT getPitch (float *pitch) { return FMOD_ChannelGroup_GetPitch(this, pitch); }
|
||||
FMOD_RESULT set3DOcclusion (float directocclusion, float reverbocclusion) { return FMOD_ChannelGroup_Set3DOcclusion(this, directocclusion, reverbocclusion); }
|
||||
FMOD_RESULT get3DOcclusion (float *directocclusion, float *reverbocclusion) { return FMOD_ChannelGroup_Get3DOcclusion(this, directocclusion, reverbocclusion); }
|
||||
FMOD_RESULT setPaused (bool paused) { return FMOD_ChannelGroup_SetPaused(this, paused); }
|
||||
FMOD_RESULT getPaused (bool *paused) { FMOD_BOOL b; FMOD_RESULT res = FMOD_ChannelGroup_GetPaused(this, &b); *paused = b; return res; }
|
||||
FMOD_RESULT setMute (bool mute) { return FMOD_ChannelGroup_SetMute(this, mute); }
|
||||
FMOD_RESULT getMute (bool *mute) { FMOD_BOOL b; FMOD_RESULT res = FMOD_ChannelGroup_GetMute(this, &b); *mute = b; return res; }
|
||||
|
||||
// Channelgroup override values. (recursively overwrites whatever settings the channels had)
|
||||
FMOD_RESULT stop () { return FMOD_ChannelGroup_Stop(this); }
|
||||
FMOD_RESULT overrideVolume (float volume) { return FMOD_ChannelGroup_OverrideVolume(this, volume); }
|
||||
FMOD_RESULT overrideFrequency (float frequency) { return FMOD_ChannelGroup_OverrideFrequency(this, frequency); }
|
||||
FMOD_RESULT overridePan (float pan) { return FMOD_ChannelGroup_OverridePan(this, pan); }
|
||||
FMOD_RESULT overrideReverbProperties(const FMOD_REVERB_CHANNELPROPERTIES *prop) { return FMOD_ChannelGroup_OverrideReverbProperties(this, prop); }
|
||||
FMOD_RESULT override3DAttributes (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel) { return FMOD_ChannelGroup_Override3DAttributes(this, pos, vel); }
|
||||
FMOD_RESULT overrideSpeakerMix (float frontleft, float frontright, float center, float lfe, float backleft, float backright, float sideleft, float sideright) { return FMOD_ChannelGroup_OverrideSpeakerMix(this, frontleft, frontright, center, lfe, backleft, backright, sideleft, sideright); }
|
||||
|
||||
// Nested channel groups.
|
||||
FMOD_RESULT addGroup (ChannelGroup *group) { return FMOD_ChannelGroup_AddGroup(this, group); }
|
||||
FMOD_RESULT getNumGroups (int *numgroups) { return FMOD_ChannelGroup_GetNumGroups(this, numgroups); }
|
||||
FMOD_RESULT getGroup (int index, ChannelGroup **group) { return FMOD_ChannelGroup_GetGroup(this, index, (FMOD_CHANNELGROUP **)group); }
|
||||
FMOD_RESULT getParentGroup (ChannelGroup **group) { return FMOD_ChannelGroup_GetParentGroup(this, (FMOD_CHANNELGROUP **)group); }
|
||||
|
||||
// DSP functionality only for channel groups playing sounds created with FMOD_SOFTWARE.
|
||||
FMOD_RESULT getDSPHead (DSP **dsp) { return FMOD_ChannelGroup_GetDSPHead(this, (FMOD_DSP **)dsp); }
|
||||
FMOD_RESULT addDSP (DSP *dsp) { return FMOD_ChannelGroup_AddDSP(this, (FMOD_DSP *)dsp); }
|
||||
|
||||
// Information only functions.
|
||||
FMOD_RESULT getName (char *name, int namelen) { return FMOD_ChannelGroup_GetName(this, name, namelen); }
|
||||
FMOD_RESULT getNumChannels (int *numchannels) { return FMOD_ChannelGroup_GetNumChannels(this, numchannels); }
|
||||
FMOD_RESULT getChannel (int index, Channel **channel) { return FMOD_ChannelGroup_GetChannel(this, index, (FMOD_CHANNEL **)channel); }
|
||||
FMOD_RESULT getSpectrum (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype) { return FMOD_ChannelGroup_GetSpectrum(this, spectrumarray, numvalues, channeloffset, windowtype); }
|
||||
FMOD_RESULT getWaveData (float *wavearray, int numvalues, int channeloffset) { return FMOD_ChannelGroup_GetWaveData(this, wavearray, numvalues, channeloffset) ;}
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_ChannelGroup_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_ChannelGroup_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
/*
|
||||
'SoundGroup' API
|
||||
*/
|
||||
class SoundGroup : FMOD_SOUNDGROUP
|
||||
{
|
||||
private:
|
||||
|
||||
SoundGroup(); /* Constructor made private so user cannot statically instance a SoundGroup class.
|
||||
Appropriate SoundGroup creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_SoundGroup_Release(this); }
|
||||
FMOD_RESULT getSystemObject (System **system) { return FMOD_SoundGroup_GetSystemObject(this, (FMOD_SYSTEM **)system); }
|
||||
|
||||
// SoundGroup control functions.
|
||||
FMOD_RESULT setMaxAudible (int maxaudible) { return FMOD_SoundGroup_SetMaxAudible(this, maxaudible); }
|
||||
FMOD_RESULT getMaxAudible (int *maxaudible) { return FMOD_SoundGroup_GetMaxAudible(this, maxaudible); }
|
||||
FMOD_RESULT setMaxAudibleBehavior (FMOD_SOUNDGROUP_BEHAVIOR behavior) { return FMOD_SoundGroup_SetMaxAudibleBehavior(this, behavior); }
|
||||
FMOD_RESULT getMaxAudibleBehavior (FMOD_SOUNDGROUP_BEHAVIOR *behavior) { return FMOD_SoundGroup_GetMaxAudibleBehavior(this, behavior); }
|
||||
FMOD_RESULT setMuteFadeSpeed (float speed) { return FMOD_SoundGroup_SetMuteFadeSpeed(this, speed); }
|
||||
FMOD_RESULT getMuteFadeSpeed (float *speed) { return FMOD_SoundGroup_GetMuteFadeSpeed(this, speed); }
|
||||
FMOD_RESULT setVolume (float volume) { return FMOD_SoundGroup_SetVolume(this, volume); }
|
||||
FMOD_RESULT getVolume (float *volume) { return FMOD_SoundGroup_GetVolume(this, volume); }
|
||||
FMOD_RESULT stop () { return FMOD_SoundGroup_Stop(this); }
|
||||
|
||||
// Information only functions.
|
||||
FMOD_RESULT getName (char *name, int namelen) { return FMOD_SoundGroup_GetName(this, name, namelen); }
|
||||
FMOD_RESULT getNumSounds (int *numsounds) { return FMOD_SoundGroup_GetNumSounds(this, numsounds); }
|
||||
FMOD_RESULT getSound (int index, Sound **sound) { return FMOD_SoundGroup_GetSound(this, index, (FMOD_SOUND **)sound); }
|
||||
FMOD_RESULT getNumPlaying (int *numplaying) { return FMOD_SoundGroup_GetNumPlaying(this, numplaying); }
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_SoundGroup_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_SoundGroup_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
/*
|
||||
'DSP' API
|
||||
*/
|
||||
class DSP : FMOD_DSP
|
||||
{
|
||||
private:
|
||||
|
||||
DSP(); /* Constructor made private so user cannot statically instance a DSP class.
|
||||
Appropriate DSP creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_DSP_Release(this); }
|
||||
FMOD_RESULT getSystemObject (System **system) { return FMOD_DSP_GetSystemObject(this, (FMOD_SYSTEM **)system); }
|
||||
|
||||
// Connection / disconnection / input and output enumeration.
|
||||
FMOD_RESULT addInput (DSP *target) { return FMOD_DSP_AddInput(this, target); }
|
||||
FMOD_RESULT disconnectFrom (DSP *target) { return FMOD_DSP_DisconnectFrom(this, target); }
|
||||
FMOD_RESULT disconnectAll (bool inputs, bool outputs) { return FMOD_DSP_DisconnectAll(this, inputs, outputs); }
|
||||
FMOD_RESULT remove () { return FMOD_DSP_Remove(this); }
|
||||
FMOD_RESULT getNumInputs (int *numinputs) { return FMOD_DSP_GetNumInputs(this, numinputs); }
|
||||
FMOD_RESULT getNumOutputs (int *numoutputs) { return FMOD_DSP_GetNumOutputs(this, numoutputs); }
|
||||
FMOD_RESULT getInput (int index, DSP **input) { return FMOD_DSP_GetInput(this, index, (FMOD_DSP **)input); }
|
||||
FMOD_RESULT getOutput (int index, DSP **output) { return FMOD_DSP_GetOutput(this, index, (FMOD_DSP **)output); }
|
||||
FMOD_RESULT setInputMix (int index, float volume) { return FMOD_DSP_SetInputMix(this, index, volume); }
|
||||
FMOD_RESULT getInputMix (int index, float *volume) { return FMOD_DSP_GetInputMix(this, index, volume); }
|
||||
FMOD_RESULT setInputLevels (int index, FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_DSP_SetInputLevels(this, index, speaker, levels, numlevels); }
|
||||
FMOD_RESULT getInputLevels (int index, FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_DSP_GetInputLevels(this, index, speaker, levels, numlevels); }
|
||||
FMOD_RESULT setOutputMix (int index, float volume) { return FMOD_DSP_SetOutputMix(this, index, volume); }
|
||||
FMOD_RESULT getOutputMix (int index, float *volume) { return FMOD_DSP_GetOutputMix(this, index, volume); }
|
||||
FMOD_RESULT setOutputLevels (int index, FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_DSP_SetOutputLevels(this, index, speaker, levels, numlevels); }
|
||||
FMOD_RESULT getOutputLevels (int index, FMOD_SPEAKER speaker, float *levels, int numlevels) { return FMOD_DSP_GetOutputLevels(this, index, speaker, levels, numlevels); }
|
||||
|
||||
// DSP unit control.
|
||||
FMOD_RESULT setActive (bool active) { return FMOD_DSP_SetActive(this, active); }
|
||||
FMOD_RESULT getActive (bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_DSP_GetActive(this, &b); *active = b; return res; }
|
||||
FMOD_RESULT setBypass (bool bypass) { return FMOD_DSP_SetBypass(this, bypass); }
|
||||
FMOD_RESULT getBypass (bool *bypass) { FMOD_BOOL b; FMOD_RESULT res = FMOD_DSP_GetBypass(this, &b); *bypass = b; return res; }
|
||||
FMOD_RESULT reset () { return FMOD_DSP_Reset(this); }
|
||||
|
||||
// DSP parameter control.
|
||||
FMOD_RESULT setParameter (int index, float value) { return FMOD_DSP_SetParameter(this, index, value); }
|
||||
FMOD_RESULT getParameter (int index, float *value, char *valuestr, int valuestrlen) { return FMOD_DSP_GetParameter(this, index, value, valuestr, valuestrlen); }
|
||||
FMOD_RESULT getNumParameters (int *numparams) { return FMOD_DSP_GetNumParameters(this, numparams); }
|
||||
FMOD_RESULT getParameterInfo (int index, char *name, char *label, char *description, int descriptionlen, float *min, float *max) { return FMOD_DSP_GetParameterInfo(this, index, name, label, description, descriptionlen, min, max); }
|
||||
FMOD_RESULT showConfigDialog (void *hwnd, bool show) { return FMOD_DSP_ShowConfigDialog(this, hwnd, show); }
|
||||
|
||||
// DSP attributes.
|
||||
FMOD_RESULT getInfo (char *name, unsigned int *version, int *channels, int *configwidth, int *configheight) { return FMOD_DSP_GetInfo(this, name, version, channels, configwidth, configheight); }
|
||||
FMOD_RESULT getType (FMOD_DSP_TYPE *type) { return FMOD_DSP_GetType(this, type); }
|
||||
FMOD_RESULT setDefaults (float frequency, float volume, float pan, int priority) { return FMOD_DSP_SetDefaults(this, frequency, volume, pan, priority); }
|
||||
FMOD_RESULT getDefaults (float *frequency, float *volume, float *pan, int *priority) { return FMOD_DSP_GetDefaults(this, frequency, volume, pan, priority) ;}
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_DSP_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_DSP_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
'Geometry' API
|
||||
*/
|
||||
class Geometry : FMOD_GEOMETRY
|
||||
{
|
||||
private:
|
||||
|
||||
Geometry(); /* Constructor made private so user cannot statically instance a Geometry class.
|
||||
Appropriate Geometry creation or retrieval function must be used. */
|
||||
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_Geometry_Release(this); }
|
||||
|
||||
// Polygon manipulation.
|
||||
FMOD_RESULT addPolygon (float directocclusion, float reverbocclusion, bool doublesided, int numvertices, const FMOD_VECTOR *vertices, int *polygonindex) { return FMOD_Geometry_AddPolygon(this, directocclusion, reverbocclusion, doublesided, numvertices, vertices, polygonindex); }
|
||||
FMOD_RESULT getNumPolygons (int *numpolygons) { return FMOD_Geometry_GetNumPolygons(this, numpolygons); }
|
||||
FMOD_RESULT getMaxPolygons (int *maxpolygons, int *maxvertices) { return FMOD_Geometry_GetMaxPolygons(this, maxpolygons, maxvertices); }
|
||||
FMOD_RESULT getPolygonNumVertices (int index, int *numvertices) { return FMOD_Geometry_GetPolygonNumVertices(this, index, numvertices); }
|
||||
FMOD_RESULT setPolygonVertex (int index, int vertexindex, const FMOD_VECTOR *vertex) { return FMOD_Geometry_SetPolygonVertex(this, index, vertexindex, vertex); }
|
||||
FMOD_RESULT getPolygonVertex (int index, int vertexindex, FMOD_VECTOR *vertex) { return FMOD_Geometry_GetPolygonVertex(this, index, vertexindex, vertex); }
|
||||
FMOD_RESULT setPolygonAttributes (int index, float directocclusion, float reverbocclusion, bool doublesided) { return FMOD_Geometry_SetPolygonAttributes(this, index, directocclusion, reverbocclusion, doublesided); }
|
||||
FMOD_RESULT getPolygonAttributes (int index, float *directocclusion, float *reverbocclusion, bool *doublesided) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Geometry_GetPolygonAttributes(this, index, directocclusion, reverbocclusion, &b); *doublesided = b; return res; }
|
||||
|
||||
// Object manipulation.
|
||||
FMOD_RESULT setActive (bool active) { return FMOD_Geometry_SetActive(this, active); }
|
||||
FMOD_RESULT getActive (bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Geometry_GetActive(this, &b); *active = b; return res; }
|
||||
FMOD_RESULT setRotation (const FMOD_VECTOR *forward, const FMOD_VECTOR *up) { return FMOD_Geometry_SetRotation(this, forward, up); }
|
||||
FMOD_RESULT getRotation (FMOD_VECTOR *forward, FMOD_VECTOR *up) { return FMOD_Geometry_GetRotation(this, forward, up); }
|
||||
FMOD_RESULT setPosition (const FMOD_VECTOR *position) { return FMOD_Geometry_SetPosition(this, position); }
|
||||
FMOD_RESULT getPosition (FMOD_VECTOR *position) { return FMOD_Geometry_GetPosition(this, position); }
|
||||
FMOD_RESULT setScale (const FMOD_VECTOR *scale) { return FMOD_Geometry_SetScale(this, scale); }
|
||||
FMOD_RESULT getScale (FMOD_VECTOR *scale) { return FMOD_Geometry_GetScale(this, scale); }
|
||||
FMOD_RESULT save (void *data, int *datasize) { return FMOD_Geometry_Save(this, data, datasize); }
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_Geometry_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_Geometry_GetUserData(this, userdata); }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
'Reverb' API
|
||||
*/
|
||||
class Reverb : FMOD_REVERB
|
||||
{
|
||||
private:
|
||||
|
||||
Reverb(); /* Constructor made private so user cannot statically instance a Reverb class.
|
||||
Appropriate Reverb creation or retrieval function must be used. */
|
||||
|
||||
public:
|
||||
|
||||
FMOD_RESULT release () { return FMOD_Reverb_Release(this); }
|
||||
|
||||
// Reverb manipulation.
|
||||
FMOD_RESULT set3DAttributes (const FMOD_VECTOR *position, float mindistance, float maxdistance) { return FMOD_Reverb_Set3DAttributes(this, position, mindistance, maxdistance); }
|
||||
FMOD_RESULT get3DAttributes (FMOD_VECTOR *position, float *mindistance, float *maxdistance) { return FMOD_Reverb_Get3DAttributes(this, position, mindistance, maxdistance); }
|
||||
FMOD_RESULT setProperties (const FMOD_REVERB_PROPERTIES *properties) { return FMOD_Reverb_SetProperties(this, properties); }
|
||||
FMOD_RESULT getProperties (FMOD_REVERB_PROPERTIES *properties) { return FMOD_Reverb_GetProperties(this, properties); }
|
||||
FMOD_RESULT setActive (bool active) { return FMOD_Reverb_SetActive(this, active); }
|
||||
FMOD_RESULT getActive (bool *active) { FMOD_BOOL b; FMOD_RESULT res = FMOD_Reverb_GetActive(this, &b); *active = b; return res; }
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT setUserData (void *userdata) { return FMOD_Reverb_SetUserData(this, userdata); }
|
||||
FMOD_RESULT getUserData (void **userdata) { return FMOD_Reverb_GetUserData(this, userdata); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
#define FMODSOUND_H
|
||||
|
||||
#include "i_sound.h"
|
||||
#include <fmod.h>
|
||||
#include "fmod_wrap.h"
|
||||
|
||||
class FMODSoundRenderer : public SoundRenderer
|
||||
{
|
||||
|
@ -12,7 +12,8 @@ public:
|
|||
bool IsValid ();
|
||||
|
||||
void SetSfxVolume (float volume);
|
||||
int SetChannels (int numchans);
|
||||
void SetMusicVolume (float volume);
|
||||
int GetNumChannels ();
|
||||
void LoadSound (sfxinfo_t *sfx);
|
||||
void UnloadSound (sfxinfo_t *sfx);
|
||||
|
||||
|
@ -22,11 +23,8 @@ public:
|
|||
long PlayStream (SoundStream *stream, int volume);
|
||||
void StopStream (SoundStream *stream);
|
||||
|
||||
// Tracker modules.
|
||||
SoundTrackerModule *OpenModule (const char *file, int offset, int length);
|
||||
|
||||
// Starts a sound in a particular sound channel.
|
||||
long StartSound (sfxinfo_t *sfx, int vol, int sep, int pitch, int channel, bool looping, bool pauseable);
|
||||
long StartSound (sfxinfo_t *sfx, float vol, float sep, int pitch, int channel, bool looping, bool pauseable);
|
||||
long StartSound3D (sfxinfo_t *sfx, float vol, int pitch, int channel, bool looping, float pos[3], float vel[3], bool pauseable);
|
||||
|
||||
// Stops a sound channel.
|
||||
|
@ -42,7 +40,7 @@ public:
|
|||
bool IsPlayingSound (long handle);
|
||||
|
||||
// Updates the volume, separation, and pitch of a sound channel.
|
||||
void UpdateSoundParams (long handle, int vol, int sep, int pitch);
|
||||
void UpdateSoundParams (long handle, float vol, float sep, int pitch);
|
||||
void UpdateSoundParams3D (long handle, float pos[3], float vel[3]);
|
||||
|
||||
// For use by I_PlayMovie
|
||||
|
@ -61,26 +59,36 @@ private:
|
|||
struct ChanMap
|
||||
{
|
||||
int soundID; // sfx playing on this channel
|
||||
long channelID;
|
||||
FMOD::Channel *channelID;
|
||||
bool bIsLooping;
|
||||
bool bIs3D;
|
||||
bool bIsPauseable;
|
||||
unsigned int lastPos;
|
||||
} *ChannelMap;
|
||||
|
||||
int NumChannels;
|
||||
unsigned int DriverCaps;
|
||||
int OutputType;
|
||||
bool DidInit;
|
||||
bool Hardware3D;
|
||||
bool SFXPaused;
|
||||
|
||||
int PutSampleData (FSOUND_SAMPLE *sample, const BYTE *data, int len, unsigned int mode);
|
||||
// int PutSampleData (FSOUND_SAMPLE *sample, const BYTE *data, int len, unsigned int mode);
|
||||
void DoLoad (void **slot, sfxinfo_t *sfx);
|
||||
void getsfx (sfxinfo_t *sfx);
|
||||
FSOUND_SAMPLE *CheckLooping (sfxinfo_t *sfx, bool looped);
|
||||
FMOD::Sound *CheckLooping (sfxinfo_t *sfx, bool looped);
|
||||
void UncheckSound (sfxinfo_t *sfx, bool looped);
|
||||
|
||||
bool Init ();
|
||||
void Shutdown ();
|
||||
void DumpDriverCaps(FMOD_CAPS caps, int minfrequency, int maxfrequency);
|
||||
|
||||
FMOD::System *Sys;
|
||||
FMOD::ChannelGroup *SfxGroup, *PausableSfx;
|
||||
FMOD::ChannelGroup *MusicGroup;
|
||||
|
||||
// Just for snd_status display
|
||||
int Driver_MinFrequency;
|
||||
int Driver_MaxFrequency;
|
||||
FMOD_CAPS Driver_Caps;
|
||||
|
||||
friend class FMODStreamCapsule;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -72,13 +72,9 @@ extern void ChildSigHandler (int signum);
|
|||
|
||||
#include <fmod.h>
|
||||
|
||||
EXTERN_CVAR (Float, snd_midivolume)
|
||||
EXTERN_CVAR (Int, snd_samplerate)
|
||||
EXTERN_CVAR (Int, snd_mididevice)
|
||||
|
||||
void Enable_FSOUND_IO_Loader ();
|
||||
void Disable_FSOUND_IO_Loader ();
|
||||
|
||||
static bool MusicDown = true;
|
||||
|
||||
MusInfo *currSong;
|
||||
|
@ -99,8 +95,18 @@ CUSTOM_CVAR (Float, snd_musicvolume, 0.3f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
self = 0.f;
|
||||
else if (self > 1.f)
|
||||
self = 1.f;
|
||||
else if (currSong != NULL && !currSong->IsMIDI ())
|
||||
currSong->SetVolume (clamp<float> (self * relative_volume, 0.f, 1.f));
|
||||
else if (GSnd != NULL)
|
||||
{
|
||||
// Set general music volume.
|
||||
GSnd->SetMusicVolume(clamp<float>(self * relative_volume, 0, 1));
|
||||
|
||||
// For music not implemented through the digital sound system,
|
||||
// let them know about the changed.
|
||||
if (currSong != NULL)
|
||||
{
|
||||
currSong->MusicVolumeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MusInfo::~MusInfo ()
|
||||
|
@ -116,6 +122,14 @@ void MusInfo::Update ()
|
|||
{
|
||||
}
|
||||
|
||||
void MusInfo::MusicVolumeChanged()
|
||||
{
|
||||
}
|
||||
|
||||
void MusInfo::TimidityVolumeChanged()
|
||||
{
|
||||
}
|
||||
|
||||
void I_InitMusic (void)
|
||||
{
|
||||
static bool setatterm = false;
|
||||
|
@ -335,12 +349,6 @@ void *I_RegisterSong (const char *filename, char * musiccache, int offset, int l
|
|||
}
|
||||
}
|
||||
#endif
|
||||
// Check for FLAC format
|
||||
else if (id == MAKE_ID('f','L','a','C'))
|
||||
{
|
||||
info = new FLACSong (file, musiccache, len);
|
||||
file = NULL;
|
||||
}
|
||||
// Check for RDosPlay raw OPL format
|
||||
else if (id == MAKE_ID('R','A','W','A') && len >= 12)
|
||||
{
|
||||
|
@ -421,14 +429,12 @@ void *I_RegisterSong (const char *filename, char * musiccache, int offset, int l
|
|||
if (info == NULL && GSnd != NULL && len >= 1024)
|
||||
{
|
||||
// First try loading it as MOD, then as a stream
|
||||
if (file != NULL) fclose (file);
|
||||
file = NULL;
|
||||
info = new MODSong (offset>=0? filename : musiccache, offset, len);
|
||||
if (!info->IsValid ())
|
||||
if (file != NULL)
|
||||
{
|
||||
delete info;
|
||||
info = new StreamSong (offset>=0? filename : musiccache, offset, len);
|
||||
fclose (file);
|
||||
file = NULL;
|
||||
}
|
||||
info = new StreamSong (offset >=0 ? filename : musiccache, offset, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -487,9 +493,6 @@ void I_SetMusicVolume (float factor)
|
|||
{
|
||||
factor = clamp<float>(factor, 0, 2.0f);
|
||||
relative_volume = saved_relative_volume * factor;
|
||||
#ifdef _WIN32
|
||||
snd_midivolume.Callback();
|
||||
#endif
|
||||
snd_musicvolume.Callback();
|
||||
}
|
||||
|
||||
|
@ -498,9 +501,6 @@ CCMD(testmusicvol)
|
|||
if (argv.argc() > 1)
|
||||
{
|
||||
relative_volume = (float)strtod(argv[1], NULL);
|
||||
#ifdef _WIN32
|
||||
snd_midivolume.Callback();
|
||||
#endif
|
||||
snd_musicvolume.Callback();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ class MusInfo
|
|||
public:
|
||||
MusInfo () : m_Status(STATE_Stopped) {}
|
||||
virtual ~MusInfo ();
|
||||
virtual void SetVolume (float volume) = 0;
|
||||
virtual void MusicVolumeChanged(); // snd_musicvolume changed
|
||||
virtual void TimidityVolumeChanged(); // timidity_mastervolume changed
|
||||
virtual void Play (bool looping) = 0;
|
||||
virtual void Pause () = 0;
|
||||
virtual void Resume () = 0;
|
||||
|
@ -116,7 +117,7 @@ public:
|
|||
MIDIStreamer();
|
||||
~MIDIStreamer();
|
||||
|
||||
void SetVolume(float volume);
|
||||
void MusicVolumeChanged();
|
||||
void Play(bool looping);
|
||||
void Pause();
|
||||
void Resume();
|
||||
|
@ -171,6 +172,7 @@ protected:
|
|||
int Tempo;
|
||||
int InitialTempo;
|
||||
BYTE ChannelVolumes[16];
|
||||
DWORD Volume;
|
||||
};
|
||||
|
||||
// MUS file played with a MIDI stream ---------------------------------------
|
||||
|
@ -225,37 +227,13 @@ protected:
|
|||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
// MOD file played with FMOD ------------------------------------------------
|
||||
|
||||
class MODSong : public MusInfo
|
||||
{
|
||||
public:
|
||||
MODSong (const char *file, int offset, int length);
|
||||
~MODSong ();
|
||||
void SetVolume (float volume);
|
||||
void Play (bool looping);
|
||||
void Pause ();
|
||||
void Resume ();
|
||||
void Stop ();
|
||||
bool IsPlaying ();
|
||||
bool IsMIDI () const { return false; }
|
||||
bool IsValid () const { return m_Module != NULL; }
|
||||
bool SetPosition (int order);
|
||||
|
||||
protected:
|
||||
MODSong () {}
|
||||
|
||||
SoundTrackerModule *m_Module;
|
||||
};
|
||||
|
||||
// OGG/MP3/WAV/other format streamed through FMOD ---------------------------
|
||||
// Anything supported by FMOD out of the box --------------------------------
|
||||
|
||||
class StreamSong : public MusInfo
|
||||
{
|
||||
public:
|
||||
StreamSong (const char *file, int offset, int length);
|
||||
~StreamSong ();
|
||||
void SetVolume (float volume);
|
||||
void Play (bool looping);
|
||||
void Pause ();
|
||||
void Resume ();
|
||||
|
@ -263,6 +241,7 @@ public:
|
|||
bool IsPlaying ();
|
||||
bool IsMIDI () const { return false; }
|
||||
bool IsValid () const { return m_Stream != NULL; }
|
||||
bool SetPosition (int order);
|
||||
|
||||
protected:
|
||||
StreamSong () : m_Stream(NULL), m_LastPos(0) {}
|
||||
|
@ -328,7 +307,7 @@ public:
|
|||
void Stop ();
|
||||
bool IsPlaying ();
|
||||
bool IsValid () const { return CommandLine.Len() > 0; }
|
||||
void SetVolume (float volume);
|
||||
void TimidityVolumeChanged();
|
||||
|
||||
protected:
|
||||
void PrepTimidity ();
|
||||
|
@ -373,25 +352,6 @@ protected:
|
|||
OPLmusicBlock *Music;
|
||||
};
|
||||
|
||||
// FLAC file streamed through FMOD (You should probably use Vorbis instead) -
|
||||
|
||||
class FLACSong : public StreamSong
|
||||
{
|
||||
public:
|
||||
FLACSong (FILE *file, char * musiccache, int length);
|
||||
~FLACSong ();
|
||||
void Play (bool looping);
|
||||
bool IsPlaying ();
|
||||
bool IsValid () const;
|
||||
|
||||
protected:
|
||||
static bool FillStream (SoundStream *stream, void *buff, int len, void *userdata);
|
||||
|
||||
class FLACStreamer;
|
||||
|
||||
FLACStreamer *State;
|
||||
};
|
||||
|
||||
// CD track/disk played through the multimedia system -----------------------
|
||||
|
||||
class CDSong : public MusInfo
|
||||
|
@ -399,7 +359,6 @@ class CDSong : public MusInfo
|
|||
public:
|
||||
CDSong (int track, int id);
|
||||
~CDSong ();
|
||||
void SetVolume (float volume) {}
|
||||
void Play (bool looping);
|
||||
void Pause ();
|
||||
void Resume ();
|
||||
|
|
|
@ -54,9 +54,6 @@ extern HINSTANCE g_hInst;
|
|||
#include <math.h>
|
||||
|
||||
#include "fmodsound.h"
|
||||
#ifdef _WIN32
|
||||
#include "altsound.h"
|
||||
#endif
|
||||
|
||||
#include "m_swap.h"
|
||||
#include "stats.h"
|
||||
|
@ -76,7 +73,7 @@ extern HINSTANCE g_hInst;
|
|||
#include "doomdef.h"
|
||||
|
||||
EXTERN_CVAR (Float, snd_sfxvolume)
|
||||
CVAR (Int, snd_samplerate, 44100, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Int, snd_samplerate, 48000, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR (String, snd_output, "default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
|
@ -172,23 +169,7 @@ void I_InitSound ()
|
|||
snd_samplerate = 65535;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (stricmp (snd_output, "alternate") == 0)
|
||||
{
|
||||
GSnd = new AltSoundRenderer;
|
||||
}
|
||||
else
|
||||
{
|
||||
GSnd = new FMODSoundRenderer;
|
||||
if (!GSnd->IsValid ())
|
||||
{
|
||||
delete GSnd;
|
||||
GSnd = new AltSoundRenderer;
|
||||
}
|
||||
}
|
||||
#else
|
||||
GSnd = new FMODSoundRenderer;
|
||||
#endif
|
||||
|
||||
if (!GSnd->IsValid ())
|
||||
{
|
||||
|
@ -269,11 +250,6 @@ SoundRenderer::~SoundRenderer ()
|
|||
{
|
||||
}
|
||||
|
||||
SoundTrackerModule *SoundRenderer::OpenModule (const char *file, int offset, int length)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
long SoundRenderer::StartSound3D (sfxinfo_t *sfx, float vol, int pitch, int channel, bool looping, float pos[3], float vel[3], bool pauseable)
|
||||
{
|
||||
return 0;
|
||||
|
@ -304,7 +280,7 @@ SoundStream::~SoundStream ()
|
|||
{
|
||||
}
|
||||
|
||||
SoundTrackerModule::~SoundTrackerModule ()
|
||||
bool SoundStream::SetPosition(int pos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,25 +51,12 @@ public:
|
|||
Loop = 4
|
||||
};
|
||||
|
||||
virtual bool Play (bool looping, float volume) = 0;
|
||||
virtual bool Play (bool looping, float volume, bool normalize) = 0;
|
||||
virtual void Stop () = 0;
|
||||
virtual void SetVolume (float volume) = 0;
|
||||
virtual bool SetPaused (bool paused) = 0;
|
||||
virtual unsigned int GetPosition () = 0;
|
||||
};
|
||||
|
||||
class SoundTrackerModule
|
||||
{
|
||||
public:
|
||||
virtual ~SoundTrackerModule ();
|
||||
|
||||
virtual bool Play () = 0;
|
||||
virtual void Stop () = 0;
|
||||
virtual void SetVolume (float volume) = 0;
|
||||
virtual bool SetPaused (bool paused) = 0;
|
||||
virtual bool IsPlaying () = 0;
|
||||
virtual bool IsFinished () = 0;
|
||||
virtual bool SetOrder (int order) = 0;
|
||||
virtual bool SetPosition (int pos);
|
||||
};
|
||||
|
||||
typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata);
|
||||
|
@ -81,7 +68,8 @@ public:
|
|||
virtual ~SoundRenderer ();
|
||||
|
||||
virtual void SetSfxVolume (float volume) = 0;
|
||||
virtual int SetChannels (int numchans) = 0; // Initialize channels
|
||||
virtual void SetMusicVolume (float volume) = 0;
|
||||
virtual int GetNumChannels () = 0; // Initialize channels
|
||||
virtual void LoadSound (sfxinfo_t *sfx) = 0; // load a sound from disk
|
||||
virtual void UnloadSound (sfxinfo_t *sfx) = 0; // unloads a sound from memory
|
||||
|
||||
|
@ -89,11 +77,8 @@ public:
|
|||
virtual SoundStream *CreateStream (SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata) = 0;
|
||||
virtual SoundStream *OpenStream (const char *filename, int flags, int offset, int length) = 0;
|
||||
|
||||
// Tracker modules.
|
||||
virtual SoundTrackerModule *OpenModule (const char *file, int offset, int length);
|
||||
|
||||
// Starts a sound in a particular sound channel.
|
||||
virtual long StartSound (sfxinfo_t *sfx, int vol, int sep, int pitch, int channel, bool looping, bool pauseable) = 0;
|
||||
virtual long StartSound (sfxinfo_t *sfx, float vol, float sep, int pitch, int channel, bool looping, bool pauseable) = 0;
|
||||
virtual long StartSound3D (sfxinfo_t *sfx, float vol, int pitch, int channel, bool looping, float pos[3], float vel[3], bool pauseable);
|
||||
|
||||
// Stops a sound channel.
|
||||
|
@ -109,7 +94,7 @@ public:
|
|||
virtual bool IsPlayingSound (long handle) = 0;
|
||||
|
||||
// Updates the volume, separation, and pitch of a sound channel.
|
||||
virtual void UpdateSoundParams (long handle, int vol, int sep, int pitch) = 0;
|
||||
virtual void UpdateSoundParams (long handle, float vol, float sep, int pitch) = 0;
|
||||
virtual void UpdateSoundParams3D (long handle, float pos[3], float vel[3]);
|
||||
|
||||
// For use by I_PlayMovie
|
||||
|
|
|
@ -1,323 +0,0 @@
|
|||
#include "i_musicinterns.h"
|
||||
#include "templates.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define FLAC__NO_DLL
|
||||
#include <FLAC++/decoder.h>
|
||||
|
||||
class FLACSong::FLACStreamer : protected FLAC::Decoder::Stream
|
||||
{
|
||||
public:
|
||||
FLACStreamer (FILE *file, char * musiccache, int length);
|
||||
~FLACStreamer ();
|
||||
|
||||
bool ServiceStream (void *buff, int len, bool loop);
|
||||
|
||||
unsigned NumChannels, SampleBits, SampleRate;
|
||||
|
||||
protected:
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
|
||||
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
|
||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
||||
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status);
|
||||
|
||||
void CopyToStream (void *&sbuff, FLAC__int32 **buffer, size_t ofs, size_t samples);
|
||||
|
||||
FileReader *File;
|
||||
long StartPos, EndPos;
|
||||
|
||||
FLAC__int32 *SamplePool[2];
|
||||
size_t PoolSize;
|
||||
size_t PoolUsed;
|
||||
size_t PoolPos;
|
||||
|
||||
void *SBuff;
|
||||
size_t SLen;
|
||||
};
|
||||
|
||||
FLACSong::FLACSong (FILE *file, char * musiccache, int length)
|
||||
: State (NULL)
|
||||
{
|
||||
State = new FLACStreamer (file, musiccache, length);
|
||||
|
||||
if (State->NumChannels > 0 && State->SampleBits > 0 && State->SampleRate > 0)
|
||||
{
|
||||
int flags = 0;
|
||||
int buffsize = State->SampleRate / 5;
|
||||
|
||||
if (State->SampleBits <= 8)
|
||||
{
|
||||
flags |= SoundStream::Bits8;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffsize <<= 1;
|
||||
}
|
||||
if (State->NumChannels == 1)
|
||||
{
|
||||
flags |= SoundStream::Mono;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffsize <<= 1;
|
||||
}
|
||||
m_Stream = GSnd->CreateStream (FillStream, buffsize, flags, State->SampleRate, this);
|
||||
if (m_Stream == NULL)
|
||||
{
|
||||
Printf (PRINT_BOLD, "Could not create music stream.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLACSong::~FLACSong ()
|
||||
{
|
||||
Stop ();
|
||||
if (State != NULL)
|
||||
{
|
||||
delete State;
|
||||
}
|
||||
}
|
||||
|
||||
bool FLACSong::IsValid () const
|
||||
{
|
||||
return m_Stream != NULL;
|
||||
}
|
||||
|
||||
bool FLACSong::IsPlaying ()
|
||||
{
|
||||
return m_Status == STATE_Playing;
|
||||
}
|
||||
|
||||
void FLACSong::Play (bool looping)
|
||||
{
|
||||
m_Status = STATE_Stopped;
|
||||
m_Looping = looping;
|
||||
|
||||
if (m_Stream->Play (true, snd_musicvolume))
|
||||
{
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
}
|
||||
|
||||
bool FLACSong::FillStream (SoundStream *stream, void *buff, int len, void *userdata)
|
||||
{
|
||||
FLACSong *song = (FLACSong *)userdata;
|
||||
return song->State->ServiceStream (buff, len, song->m_Looping);
|
||||
}
|
||||
|
||||
FLACSong::FLACStreamer::FLACStreamer (FILE *iofile, char * musiccache, int length)
|
||||
: NumChannels (0),
|
||||
SampleBits (0),
|
||||
SampleRate (0),
|
||||
PoolSize (0),
|
||||
PoolUsed (0),
|
||||
PoolPos (0)
|
||||
{
|
||||
if (iofile != NULL)
|
||||
{
|
||||
File = new FileReader (iofile, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
File = new MemoryReader(musiccache, length);
|
||||
}
|
||||
|
||||
StartPos = File->Tell();
|
||||
EndPos = StartPos + File->GetLength();
|
||||
init ();
|
||||
process_until_end_of_metadata ();
|
||||
}
|
||||
|
||||
FLACSong::FLACStreamer::~FLACStreamer ()
|
||||
{
|
||||
if (PoolSize > 0 && SamplePool[0] != NULL)
|
||||
{
|
||||
delete[] SamplePool[0];
|
||||
SamplePool[0] = NULL;
|
||||
}
|
||||
if (File->GetFile()!=NULL) fclose (File->GetFile());
|
||||
delete File;
|
||||
}
|
||||
|
||||
bool FLACSong::FLACStreamer::ServiceStream (void *buff1, int len, bool loop)
|
||||
{
|
||||
void *buff = buff1;
|
||||
size_t samples = len;
|
||||
size_t poolAvail;
|
||||
size_t poolGrab;
|
||||
|
||||
if (NumChannels == 2)
|
||||
{
|
||||
samples >>= 1;
|
||||
}
|
||||
if (SampleBits > 8)
|
||||
{
|
||||
samples >>= 1;
|
||||
}
|
||||
|
||||
poolAvail = PoolUsed - PoolPos;
|
||||
if (poolAvail > 0)
|
||||
{
|
||||
poolGrab = MIN (samples, poolAvail);
|
||||
CopyToStream (buff, SamplePool, PoolPos, poolGrab);
|
||||
PoolPos += poolGrab;
|
||||
if (PoolPos == PoolUsed)
|
||||
{
|
||||
PoolPos = PoolUsed = 0;
|
||||
}
|
||||
samples -= poolGrab;
|
||||
}
|
||||
|
||||
SBuff = buff;
|
||||
SLen = samples;
|
||||
|
||||
while (SLen > 0)
|
||||
{
|
||||
if (get_state() == FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||
{
|
||||
if (!loop)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
File->Seek (StartPos, SEEK_SET);
|
||||
reset ();
|
||||
}
|
||||
|
||||
if (!process_single ())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void FLACSong::FLACStreamer::CopyToStream (void *&sbuff, FLAC__int32 **buffer, size_t ofs, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (SampleBits == 16)
|
||||
{
|
||||
SWORD *buff = (SWORD *)sbuff;
|
||||
if (NumChannels == 1)
|
||||
{
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = SWORD(buffer[0][i + ofs]);
|
||||
}
|
||||
sbuff = buff + i;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i*2] = SWORD(buffer[0][i + ofs]);
|
||||
buff[i*2+1] = SWORD(buffer[1][i + ofs]);
|
||||
}
|
||||
sbuff = buff + i*2;
|
||||
}
|
||||
}
|
||||
else if (SampleBits == 8)
|
||||
{
|
||||
SBYTE *buff = (SBYTE *)sbuff;
|
||||
if (NumChannels == 1)
|
||||
{
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = SBYTE(buffer[0][i + ofs]);
|
||||
}
|
||||
sbuff = buff + i;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i*2] = SBYTE(buffer[0][i + ofs]);
|
||||
buff[i*2+1] = SBYTE(buffer[1][i + ofs]);
|
||||
}
|
||||
sbuff = buff + i*2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderReadStatus FLACSong::FLACStreamer::read_callback(FLAC__byte buffer[], unsigned *bytes)
|
||||
{
|
||||
if (*bytes > 0)
|
||||
{
|
||||
long here = File->Tell();
|
||||
if (here == EndPos)
|
||||
{
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*bytes > (size_t)(EndPos - here))
|
||||
{
|
||||
*bytes = EndPos - here;
|
||||
}
|
||||
File->Read (buffer, *bytes);
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderWriteStatus FLACSong::FLACStreamer::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
|
||||
{
|
||||
size_t blockSize = frame->header.blocksize;
|
||||
size_t blockGrab = 0;
|
||||
size_t buffAvail;
|
||||
size_t blockOfs;
|
||||
|
||||
buffAvail = SLen;
|
||||
blockGrab = MIN (SLen, blockSize);
|
||||
CopyToStream (SBuff, (FLAC__int32 **)buffer, 0, blockGrab);
|
||||
blockSize -= blockGrab;
|
||||
SLen -= blockGrab;
|
||||
blockOfs = blockGrab;
|
||||
|
||||
if (blockSize > 0)
|
||||
{
|
||||
buffAvail = PoolSize - PoolUsed;
|
||||
blockGrab = MIN (buffAvail, blockSize);
|
||||
memcpy (SamplePool[0] + PoolUsed, buffer[0] + blockOfs, sizeof(buffer[0])*blockGrab);
|
||||
if (NumChannels > 1)
|
||||
{
|
||||
memcpy (SamplePool[1] + PoolUsed, buffer[1] + blockOfs, sizeof(buffer[1])*blockGrab);
|
||||
}
|
||||
PoolUsed += blockGrab;
|
||||
}
|
||||
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
void FLACSong::FLACStreamer::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
||||
{
|
||||
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO && PoolSize == 0)
|
||||
{
|
||||
switch (metadata->data.stream_info.bits_per_sample)
|
||||
{
|
||||
case 8: case 16: break;
|
||||
default:
|
||||
Printf ("Only FLACs with 8 or 16 bits per sample are supported\n");
|
||||
return;
|
||||
}
|
||||
SampleRate = metadata->data.stream_info.sample_rate;
|
||||
NumChannels = (unsigned int)MIN (2u, metadata->data.stream_info.channels);
|
||||
SampleBits = metadata->data.stream_info.bits_per_sample;
|
||||
PoolSize = metadata->data.stream_info.max_blocksize * 2;
|
||||
|
||||
SamplePool[0] = new FLAC__int32[PoolSize * NumChannels];
|
||||
SamplePool[1] = SamplePool[0] + PoolSize;
|
||||
}
|
||||
}
|
||||
|
||||
void FLACSong::FLACStreamer::error_callback(::FLAC__StreamDecoderErrorStatus status)
|
||||
{
|
||||
status = status;
|
||||
}
|
|
@ -9,34 +9,8 @@
|
|||
|
||||
static DWORD nummididevices;
|
||||
static bool nummididevicesset;
|
||||
DWORD midivolume;
|
||||
UINT mididevice;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CVAR snd_midivolume
|
||||
//
|
||||
// Maximum volume of MIDI/MUS music through the MM subsystem.
|
||||
//==========================================================================
|
||||
|
||||
CUSTOM_CVAR (Float, snd_midivolume, 0.5f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0.f)
|
||||
self = 0.f;
|
||||
else if (self > 1.f)
|
||||
self = 1.f;
|
||||
else
|
||||
{
|
||||
float realvolume = clamp<float>(self * relative_volume, 0.f, 1.f);
|
||||
DWORD onechanvol = clamp<DWORD>((DWORD)(realvolume * 65535.f), 0, 65535);
|
||||
midivolume = (onechanvol << 16) | onechanvol;
|
||||
if (currSong && currSong->IsMIDI ())
|
||||
{
|
||||
currSong->SetVolume (realvolume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVAR (Bool, snd_midiprecache, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
|
||||
CUSTOM_CVAR (Int, snd_mididevice, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
@ -48,13 +22,13 @@ CUSTOM_CVAR (Int, snd_mididevice, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
|
||||
if ((self >= (signed)nummididevices) || (self < -2))
|
||||
{
|
||||
Printf ("ID out of range. Using MIDI mapper.\n");
|
||||
self = -1;
|
||||
Printf ("ID out of range. Using default device.\n");
|
||||
self = 0;
|
||||
return;
|
||||
}
|
||||
else if (self < 0)
|
||||
{
|
||||
mididevice = MIDI_MAPPER;
|
||||
mididevice = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,7 +36,7 @@ CUSTOM_CVAR (Int, snd_mididevice, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
}
|
||||
|
||||
// If a song is playing, move it to the new device.
|
||||
if (oldmididev != mididevice && currSong)
|
||||
if (oldmididev != mididevice && currSong != NULL && currSong->IsMIDI())
|
||||
{
|
||||
MusInfo *song = currSong;
|
||||
if (song->m_Status == MusInfo::STATE_Playing)
|
||||
|
|
|
@ -87,9 +87,6 @@ struct MIDISong2::TrackInfo
|
|||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
EXTERN_CVAR (Float, snd_midivolume)
|
||||
|
||||
extern DWORD midivolume;
|
||||
extern UINT mididevice;
|
||||
|
||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||
|
|
|
@ -64,8 +64,8 @@ CUSTOM_CVAR (Float, timidity_mastervolume, 1.0f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
self = 0.f;
|
||||
else if (self > 4.f)
|
||||
self = 4.f;
|
||||
else if (currSong != NULL && !currSong->IsMIDI ())
|
||||
currSong->SetVolume (clamp<float> (snd_musicvolume, 0.f, 1.f));
|
||||
else if (currSong != NULL)
|
||||
currSong->TimidityVolumeChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ void TimiditySong::Play (bool looping)
|
|||
{
|
||||
if (m_Stream != NULL)
|
||||
{
|
||||
if (m_Stream->Play (true, timidity_mastervolume * snd_musicvolume))
|
||||
if (m_Stream->Play (true, timidity_mastervolume, false))
|
||||
{
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
|
@ -594,9 +594,12 @@ bool TimiditySong::FillStream (SoundStream *stream, void *buff, int len, void *u
|
|||
return true;
|
||||
}
|
||||
|
||||
void TimiditySong::SetVolume (float volume)
|
||||
void TimiditySong::TimidityVolumeChanged()
|
||||
{
|
||||
if (m_Stream!=NULL) m_Stream->SetVolume (volume*timidity_mastervolume);
|
||||
if (m_Stream != NULL)
|
||||
{
|
||||
m_Stream->SetVolume(timidity_mastervolume);
|
||||
}
|
||||
}
|
||||
|
||||
bool TimiditySong::IsPlaying ()
|
||||
|
|
|
@ -53,9 +53,8 @@
|
|||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
EXTERN_CVAR (Float, snd_midivolume)
|
||||
EXTERN_CVAR(Float, snd_musicvolume)
|
||||
|
||||
extern DWORD midivolume;
|
||||
extern UINT mididevice;
|
||||
|
||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||
|
@ -184,8 +183,7 @@ void MIDIStreamer::Play (bool looping)
|
|||
return;
|
||||
}
|
||||
|
||||
snd_midivolume.Callback(); // set volume to current music's properties
|
||||
OutputVolume (midivolume & 0xffff);
|
||||
MusicVolumeChanged(); // set volume to current music's properties
|
||||
|
||||
ResetEvent(ExitEvent);
|
||||
ResetEvent(BufferDoneEvent);
|
||||
|
@ -290,7 +288,7 @@ void MIDIStreamer::Resume ()
|
|||
{
|
||||
if (m_Status == STATE_Paused)
|
||||
{
|
||||
OutputVolume(midivolume & 0xffff);
|
||||
OutputVolume(Volume);
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
}
|
||||
|
@ -341,13 +339,22 @@ bool MIDIStreamer::IsPlaying ()
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// MIDIStreamer :: SetVolume
|
||||
// MIDIStreamer :: MusicVolumeChanged
|
||||
//
|
||||
// WinMM MIDI doesn't go through the sound system, so the normal volume
|
||||
// changing procedure doesn't work for it.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void MIDIStreamer::SetVolume (float volume)
|
||||
void MIDIStreamer::MusicVolumeChanged ()
|
||||
{
|
||||
OutputVolume(midivolume & 0xffff);
|
||||
float realvolume = clamp<float>(snd_musicvolume * relative_volume, 0.f, 1.f);
|
||||
DWORD onechanvol = clamp<DWORD>((DWORD)(realvolume * 65535.f), 0, 65535);
|
||||
Volume = onechanvol;
|
||||
if (m_Status == STATE_Playing)
|
||||
{
|
||||
OutputVolume(onechanvol);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -377,7 +384,7 @@ void MIDIStreamer::OutputVolume (DWORD volume)
|
|||
int MIDIStreamer::VolumeControllerChange(int channel, int volume)
|
||||
{
|
||||
ChannelVolumes[channel] = volume;
|
||||
return ((volume + 1) * (midivolume & 0xffff)) >> 16;
|
||||
return ((volume + 1) * Volume) >> 16;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
#include "i_musicinterns.h"
|
||||
|
||||
void MODSong::SetVolume (float volume)
|
||||
{
|
||||
if (m_Module)
|
||||
{
|
||||
m_Module->SetVolume (volume);
|
||||
}
|
||||
}
|
||||
|
||||
void MODSong::Play (bool looping)
|
||||
{
|
||||
m_Status = STATE_Stopped;
|
||||
m_Looping = looping;
|
||||
|
||||
if (m_Module->Play ())
|
||||
{
|
||||
m_Module->SetVolume (snd_musicvolume);
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
}
|
||||
|
||||
void MODSong::Pause ()
|
||||
{
|
||||
if (m_Status == STATE_Playing)
|
||||
{
|
||||
if (m_Module->SetPaused (true))
|
||||
m_Status = STATE_Paused;
|
||||
}
|
||||
}
|
||||
|
||||
void MODSong::Resume ()
|
||||
{
|
||||
if (m_Status == STATE_Paused)
|
||||
{
|
||||
if (m_Module->SetPaused (false))
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
}
|
||||
|
||||
void MODSong::Stop ()
|
||||
{
|
||||
if (m_Status != STATE_Stopped && m_Module)
|
||||
{
|
||||
m_Module->Stop ();
|
||||
}
|
||||
m_Status = STATE_Stopped;
|
||||
}
|
||||
|
||||
MODSong::~MODSong ()
|
||||
{
|
||||
Stop ();
|
||||
if (m_Module != NULL)
|
||||
{
|
||||
delete m_Module;
|
||||
m_Module = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
MODSong::MODSong (const char *file_or_data, int offset, int length)
|
||||
{
|
||||
m_Module = GSnd->OpenModule (file_or_data, offset, length);
|
||||
}
|
||||
|
||||
bool MODSong::IsPlaying ()
|
||||
{
|
||||
if (m_Status != STATE_Stopped)
|
||||
{
|
||||
if (m_Module->IsPlaying ())
|
||||
{
|
||||
if (!m_Looping && m_Module->IsFinished ())
|
||||
{
|
||||
Stop ();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (m_Looping)
|
||||
{
|
||||
Play (true);
|
||||
return m_Status != STATE_Stopped;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MODSong::SetPosition (int order)
|
||||
{
|
||||
return m_Module->SetOrder (order);
|
||||
}
|
||||
|
|
@ -54,11 +54,8 @@
|
|||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
extern DWORD midivolume;
|
||||
extern UINT mididevice;
|
||||
|
||||
EXTERN_CVAR (Float, snd_midivolume)
|
||||
|
||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||
|
||||
static const BYTE CtrlTranslate[15] =
|
||||
|
|
|
@ -72,7 +72,7 @@ void OPLMUSSong::Play (bool looping)
|
|||
Music->SetLooping (looping);
|
||||
Music->Restart ();
|
||||
|
||||
if (m_Stream->Play (true, snd_musicvolume))
|
||||
if (m_Stream->Play (true, snd_musicvolume, true))
|
||||
{
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ void SPCSong::Play (bool looping)
|
|||
m_Status = STATE_Stopped;
|
||||
m_Looping = true;
|
||||
|
||||
if (m_Stream->Play (true, snd_musicvolume))
|
||||
if (m_Stream->Play (true, snd_musicvolume, false))
|
||||
{
|
||||
m_Status = STATE_Playing;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
#include "i_musicinterns.h"
|
||||
|
||||
void StreamSong::SetVolume (float volume)
|
||||
{
|
||||
if (m_Stream!=NULL) m_Stream->SetVolume (volume);
|
||||
}
|
||||
|
||||
void StreamSong::Play (bool looping)
|
||||
{
|
||||
m_Status = STATE_Stopped;
|
||||
m_Looping = looping;
|
||||
|
||||
if (m_Stream->Play (m_Looping, snd_musicvolume))
|
||||
if (m_Stream->Play (m_Looping, 1, false))
|
||||
{
|
||||
m_Status = STATE_Playing;
|
||||
m_LastPos = 0;
|
||||
|
@ -80,3 +75,13 @@ bool StreamSong::IsPlaying ()
|
|||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// StreamSong :: SetPosition
|
||||
//
|
||||
// Sets the current order number for a MOD-type song, or the position in ms
|
||||
// for anything else.
|
||||
|
||||
bool StreamSong::SetPosition(int order)
|
||||
{
|
||||
return m_Stream->SetPosition(order);
|
||||
}
|
||||
|
|
|
@ -1,300 +0,0 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "sample_flac.h"
|
||||
#include "w_wad.h"
|
||||
#include "templates.h"
|
||||
|
||||
FLACSampleLoader::FLACSampleLoader (sfxinfo_t *sfx)
|
||||
: NumChannels (0),
|
||||
SampleBits (0),
|
||||
SampleRate (0),
|
||||
NumSamples (0),
|
||||
File (Wads.OpenLumpNum (sfx->lumpnum)),
|
||||
Sfx (sfx)
|
||||
{
|
||||
StartPos = File.Tell();
|
||||
EndPos = StartPos + File.GetLength();
|
||||
|
||||
init ();
|
||||
process_until_end_of_metadata ();
|
||||
}
|
||||
|
||||
FSOUND_SAMPLE *FLACSampleLoader::LoadSample (unsigned int samplemode)
|
||||
{
|
||||
if (NumSamples == 0)
|
||||
{
|
||||
DPrintf ("FLAC has unknown number of samples\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FSOUND_SAMPLE *sample;
|
||||
unsigned int mode;
|
||||
unsigned int bits;
|
||||
|
||||
Sfx->frequency = SampleRate;
|
||||
bits = (SampleBits <= 8) ? FSOUND_8BITS : FSOUND_16BITS;
|
||||
mode = FSOUND_SIGNED | FSOUND_MONO | FSOUND_LOOP_OFF;
|
||||
|
||||
sample = FSOUND_Sample_Alloc (FSOUND_FREE, NumSamples,
|
||||
samplemode | bits | mode, SampleRate, 255, FSOUND_STEREOPAN, 255);
|
||||
if (sample == NULL)
|
||||
{
|
||||
bits ^= FSOUND_8BITS | FSOUND_16BITS;
|
||||
sample = FSOUND_Sample_Alloc (FSOUND_FREE, NumSamples,
|
||||
samplemode | bits | mode, SampleRate, 255, FSOUND_STEREOPAN, 255);
|
||||
if (sample == NULL)
|
||||
{
|
||||
return sample;
|
||||
}
|
||||
}
|
||||
|
||||
void *ptr1, *ptr2;
|
||||
unsigned int len1, len2;
|
||||
|
||||
if (!FSOUND_Sample_Lock (sample, 0,
|
||||
bits & FSOUND_8BITS ? NumSamples : NumSamples * 2,
|
||||
&ptr1, &ptr2, &len1, &len2))
|
||||
{
|
||||
FSOUND_Sample_Free (sample);
|
||||
DPrintf ("Failed locking FLAC sample\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SBuff = ptr1;
|
||||
SBuff2 = ptr2;
|
||||
SLen = len1;
|
||||
SLen2 = len2;
|
||||
Dest8 = (bits & FSOUND_8BITS) ? true : false;
|
||||
|
||||
if (!process_until_end_of_stream ())
|
||||
{
|
||||
FSOUND_Sample_Unlock (sample, ptr1, ptr2, len1, len2);
|
||||
FSOUND_Sample_Free (sample);
|
||||
DPrintf ("Failed loading FLAC sample\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FSOUND_Sample_Unlock (sample, ptr1, ptr2, len1, len2);
|
||||
return sample;
|
||||
}
|
||||
|
||||
BYTE *FLACSampleLoader::ReadSample (SDWORD *numbytes)
|
||||
{
|
||||
if (NumSamples == 0)
|
||||
{
|
||||
DPrintf ("FLAC has unknown number of samples\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BYTE *sfxdata;
|
||||
|
||||
Sfx->frequency = SampleRate;
|
||||
Sfx->b16bit = (SampleBits > 8);
|
||||
|
||||
sfxdata = new BYTE[NumSamples << Sfx->b16bit];
|
||||
|
||||
SBuff = sfxdata;
|
||||
SBuff2 = NULL;
|
||||
SLen = NumSamples;
|
||||
SLen2 = 0;
|
||||
Dest8 = !Sfx->b16bit;
|
||||
*numbytes = NumSamples << Sfx->b16bit;
|
||||
|
||||
if (!process_until_end_of_stream ())
|
||||
{
|
||||
DPrintf ("Failed loading FLAC sample\n");
|
||||
delete[] sfxdata;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return sfxdata;
|
||||
}
|
||||
|
||||
FLACSampleLoader::~FLACSampleLoader ()
|
||||
{
|
||||
}
|
||||
|
||||
void FLACSampleLoader::CopyToSample (size_t ofs, FLAC__int32 **buffer, size_t ilen)
|
||||
{
|
||||
size_t i;
|
||||
size_t len = MIN<size_t> (ilen, SLen);
|
||||
FLAC__int32 *buffer0 = buffer[0] + ofs;
|
||||
|
||||
if (SampleBits == 16)
|
||||
{
|
||||
if (!Dest8)
|
||||
{
|
||||
SWORD *buff = (SWORD *)SBuff;
|
||||
|
||||
if (NumChannels == 1)
|
||||
{
|
||||
// Mono16 -> Mono16
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = SWORD(buffer0[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stereo16 -> Mono16
|
||||
FLAC__int32 *buffer1 = buffer[1] + ofs;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = (buffer0[i] + buffer1[i]) / 2;
|
||||
}
|
||||
}
|
||||
SBuff = buff + i;
|
||||
}
|
||||
else
|
||||
{
|
||||
SBYTE *buff = (SBYTE *)SBuff;
|
||||
|
||||
if (NumChannels == 1)
|
||||
{
|
||||
// Mono16 -> Mono8
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = buffer0[i] / 256;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stereo16 -> Mono8
|
||||
FLAC__int32 *buffer1 = buffer[1] + ofs;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = (buffer0[i] + buffer1[i]) / 512;
|
||||
}
|
||||
}
|
||||
SBuff = buff + i;
|
||||
}
|
||||
}
|
||||
else if (SampleBits == 8)
|
||||
{
|
||||
if (Dest8)
|
||||
{
|
||||
SBYTE *buff = (SBYTE *)SBuff;
|
||||
|
||||
if (NumChannels == 1)
|
||||
{
|
||||
// Mono8 -> Mono8
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = SBYTE(buffer0[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stereo8 -> Mono8
|
||||
FLAC__int32 *buffer1 = buffer[1] + ofs;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i*2] = SBYTE(buffer0[i]);
|
||||
buff[i*2+1] = SBYTE(buffer1[i]);
|
||||
}
|
||||
}
|
||||
SBuff = buff + i;
|
||||
}
|
||||
else
|
||||
{
|
||||
SWORD *buff = (SWORD *)SBuff;
|
||||
|
||||
if (NumChannels == 1)
|
||||
{
|
||||
// Mono8 -> Mono16
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i] = buffer0[i] * 257;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stereo8 -> Mono16
|
||||
FLAC__int32 *buffer1 = buffer[1] + ofs;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
buff[i*2] = ((buffer0[i] + buffer1[i]) / 2) * 257;
|
||||
}
|
||||
}
|
||||
SBuff = buff + i;
|
||||
}
|
||||
}
|
||||
|
||||
// If the lock was split into two buffers, do the other one next.
|
||||
// (Will this ever happen? Don't think so, but...)
|
||||
if (ilen > len)
|
||||
{
|
||||
SBuff = SBuff2;
|
||||
SLen = SLen2;
|
||||
SBuff2 = NULL;
|
||||
SLen2 = 0;
|
||||
if (SLen > 0)
|
||||
{
|
||||
CopyToSample (len, buffer, ilen - len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderReadStatus FLACSampleLoader::read_callback(FLAC__byte buffer[], unsigned *bytes)
|
||||
{
|
||||
if (*bytes > 0)
|
||||
{
|
||||
long here = File.Tell();
|
||||
|
||||
if (here == EndPos)
|
||||
{
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*bytes > (size_t)(EndPos - here))
|
||||
{
|
||||
*bytes = EndPos - here;
|
||||
}
|
||||
File.Read (buffer, *bytes);
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderWriteStatus FLACSampleLoader::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
|
||||
{
|
||||
CopyToSample (0, (FLAC__int32 **)buffer, frame->header.blocksize);
|
||||
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
void FLACSampleLoader::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
||||
{
|
||||
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
|
||||
{
|
||||
switch (metadata->data.stream_info.bits_per_sample)
|
||||
{
|
||||
case 8: case 16: break;
|
||||
default:
|
||||
DPrintf ("Only FLACs with 8 or 16 bits per sample are supported\n");
|
||||
return;
|
||||
}
|
||||
if (metadata->data.stream_info.total_samples > 0xFFFFFFFF)
|
||||
{
|
||||
DPrintf ("FLAC is too long\n");
|
||||
}
|
||||
SampleRate = metadata->data.stream_info.sample_rate;
|
||||
NumChannels = (unsigned int)MIN (2u, metadata->data.stream_info.channels);
|
||||
SampleBits = metadata->data.stream_info.bits_per_sample;
|
||||
NumSamples = (unsigned int)metadata->data.stream_info.total_samples;
|
||||
}
|
||||
}
|
||||
|
||||
void FLACSampleLoader::error_callback(::FLAC__StreamDecoderErrorStatus status)
|
||||
{
|
||||
status = status;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#define FLAC__NO_DLL
|
||||
#include <fmod.h>
|
||||
#include <FLAC++/decoder.h>
|
||||
#include "s_sound.h"
|
||||
#include "files.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
class FLACSampleLoader : protected FLAC::Decoder::Stream
|
||||
{
|
||||
public:
|
||||
FLACSampleLoader (sfxinfo_t *sfx);
|
||||
~FLACSampleLoader ();
|
||||
|
||||
FSOUND_SAMPLE *LoadSample (unsigned int samplemode);
|
||||
BYTE *ReadSample (SDWORD *numbytes);
|
||||
|
||||
unsigned NumChannels, SampleBits, SampleRate, NumSamples;
|
||||
|
||||
protected:
|
||||
virtual ::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
|
||||
virtual ::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
|
||||
virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
||||
virtual void error_callback(::FLAC__StreamDecoderErrorStatus status);
|
||||
|
||||
void CopyToSample (size_t ofs, FLAC__int32 **buffer, size_t samples);
|
||||
|
||||
FWadLump File;
|
||||
long StartPos, EndPos;
|
||||
|
||||
void *SBuff, *SBuff2;
|
||||
unsigned int SLen, SLen2;
|
||||
sfxinfo_t *Sfx;
|
||||
bool Dest8;
|
||||
};
|
11
zdoom.sln
11
zdoom.sln
|
@ -5,15 +5,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdoom", "zdoom.vcproj", "{8
|
|||
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}
|
||||
{6077B7D6-349F-4077-B552-3BC302EF5859} = {6077B7D6-349F-4077-B552-3BC302EF5859}
|
||||
{667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E} = {873F2EEA-24DF-454C-B245-CB9738BA993E}
|
||||
{DA47396F-60C1-4BDE-A977-7F7DE461CF77} = {DA47396F-60C1-4BDE-A977-7F7DE461CF77}
|
||||
{AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} = {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcproj", "{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLAC", "FLAC\FLAC.vcproj", "{873F2EEA-24DF-454C-B245-CB9738BA993E}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lemon", "tools\lemon\lemon.vcproj", "{0F80ACBF-460E-44F0-B28E-B3272D1774A7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "tools\re2c\re2c.vcproj", "{667D2EE7-C357-49E2-9BAB-0A4A45F0F76E}"
|
||||
|
@ -68,14 +65,6 @@ Global
|
|||
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|Win32.Build.0 = Release|Win32
|
||||
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|x64.ActiveCfg = Debug|x64
|
||||
{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}.Release|x64.Build.0 = Debug|x64
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Debug|x64.Build.0 = Debug|x64
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Release|Win32.Build.0 = Release|Win32
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Release|x64.ActiveCfg = Debug|x64
|
||||
{873F2EEA-24DF-454C-B245-CB9738BA993E}.Release|x64.Build.0 = Debug|x64
|
||||
{0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0F80ACBF-460E-44F0-B28E-B3272D1774A7}.Debug|x64.ActiveCfg = Release|Win32
|
||||
|
|
30
zdoom.vcproj
30
zdoom.vcproj
|
@ -317,7 +317,7 @@
|
|||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="gdi32.lib user32.lib comctl32.lib shell32.lib advapi32.lib comdlg32.lib ole32.lib dxguid.lib dsound.lib dinput8.lib strmiids.lib wsock32.lib winmm.lib fmodvc.lib setupapi.lib ws2_32.lib"
|
||||
AdditionalDependencies="gdi32.lib user32.lib comctl32.lib shell32.lib advapi32.lib comdlg32.lib ole32.lib dxguid.lib dsound.lib dinput8.lib strmiids.lib wsock32.lib winmm.lib fmodex_vc.lib setupapi.lib ws2_32.lib"
|
||||
OutputFile="../zdoomd.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
|
@ -9206,18 +9206,6 @@
|
|||
<Filter
|
||||
Name="Audio Files"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\sound\altsound.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\sound\altsound.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\sound\altsoundmixer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\sound\fmodsound.cpp"
|
||||
>
|
||||
|
@ -9250,10 +9238,6 @@
|
|||
RelativePath="src\sound\music_cd.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="src\sound\music_flac.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\sound\music_midi_base.cpp"
|
||||
>
|
||||
|
@ -9270,10 +9254,6 @@
|
|||
RelativePath=".\src\sound\music_midistream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="src\sound\music_mod.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="src\sound\music_mus_midiout.cpp"
|
||||
>
|
||||
|
@ -9294,14 +9274,6 @@
|
|||
RelativePath=".\src\sound\music_win_mididevice.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="src\sound\sample_flac.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="src\sound\sample_flac.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="OPL Synth"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue