Updates livVorbis to v1.3.3

This commit is contained in:
thecelloman 2013-02-24 19:07:14 -05:00
parent 853b70255b
commit 44beb6210b
62 changed files with 32606 additions and 41208 deletions

View file

@ -1,3 +1,92 @@
libvorbis 1.3.3 (2012-02-03) -- "Xiph.Org libVorbis I 20120203 (Omnipresent)"
* vorbis: additional proofing against invalid/malicious
streams in decode (see SVN for details).
* vorbis: fix a memory leak in vorbis_commentheader_out().
* updates, corrections and clarifications in the Vorbis I specification
document
* win32: fixed project configuration which referenced two CRT versions
in output binaries.
* build warning fixes
libvorbis 1.3.2 (2010-11-01) -- "Xiph.Org libVorbis I 20101101 (Schaufenugget)"
* vorbis: additional proofing against invalid/malicious
streams in floor, residue, and bos/eos packet trimming
code (see SVN for details).
* vorbis: Added programming documentation tree for the
low-level calls
* vorbisfile: Correct handling of serial numbers array
element [0] on non-seekable streams
* vorbisenc: Back out an [old] AoTuV HF weighting that was
first enabled in 1.3.0; there are a few samples where I
really don't like the effect it causes.
* vorbis: return correct timestamp for granule positions
with high bit set.
* vorbisfile: the [undocumented] half-rate decode api made no
attempt to keep the pcm offset tracking consistent in seeks.
Fix and add a testing mode to seeking_example.c to torture
test seeking in halfrate mode. Also remove requirement that
halfrate mode only work with seekable files.
* vorbisfile: Fix a chaining bug in raw_seeks where seeking
out of the current link would fail due to not
reinitializing the decode machinery.
* vorbisfile: improve seeking strategy. Reduces the
necessary number of seek callbacks in an open or seek
operation by well over 2/3.
libvorbis 1.3.1 (2010-02-26) -- "Xiph.Org libVorbis I 20100325 (Everywhere)"
* tweak + minor arithmetic fix in floor1 fit
* revert noise norm to conservative 1.2.3 behavior pending
more listening testing
libvorbis 1.3.0 (2010-02-25) -- unreleased staging snapshot
* Optimized surround support for 5.1 encoding at 44.1/48kHz
* Added encoder control call to disable channel coupling
* Correct an overflow bug in very low-bitrate encoding on 32 bit
machines that caused inflated bitrates
* Numerous API hardening, leak and build fixes
* Correct bug in 22kHz compand setup that could cause a crash
* Correct bug in 16kHz codebooks that could cause unstable pure
tones at high bitrates
libvorbis 1.2.3 (2009-07-09) -- "Xiph.Org libVorbis I 20090709"
* correct a vorbisfile bug that prevented proper playback of
Vorbis files where all audio in a logical stream is in a
single page
* Additional decode setup hardening against malicious streams
* Add 'OV_EXCLUDE_STATIC_CALLBACKS' define for developers who
wish to avoid unused symbol warnings from the static callbacks
defined in vorbisfile.h
libvorbis 1.2.2 (2009-06-24) -- "Xiph.Org libVorbis I 20090624"
* define VENDOR and ENCODER strings
* seek correctly in files bigger than 2 GB (Windows)
* fix regression from CVE-2008-1420; 1.0b1 files work again
* mark all tables as constant to reduce memory occupation
* additional decoder hardening against malicious streams
* substantially reduce amount of seeking performed by Vorbisfile
* Multichannel decode bugfix
* build system updates
* minor specification clarifications/fixes
libvorbis 1.2.1 (unreleased) -- "Xiph.Org libVorbis I 20080501"
* Improved robustness with corrupt streams.
* New ov_read_filter() vorbisfile call allows filtering decoded
audio as floats before converting to integer samples.
* Fix an encoder bug with multichannel streams.
* Replaced RTP payload format draft with RFC 5215.
* Bare bones self test under 'make check'.
* Fix a problem encoding some streams between 14 and 28 kHz.
* Fix a numerical instability in the edge extrapolation filter.
* Build system improvements.
* Specification correction.
libvorbis 1.2.0 (2007-07-25) -- "Xiph.Org libVorbis I 20070622" libvorbis 1.2.0 (2007-07-25) -- "Xiph.Org libVorbis I 20070622"
* new ov_fopen() convenience call that avoids the common * new ov_fopen() convenience call that avoids the common

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: libvorbis codec headers function: libvorbis codec headers
last mod: $Id: codec.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $
********************************************************************/ ********************************************************************/
@ -121,7 +121,7 @@ typedef struct vorbis_block{
/* vorbis_block is a single block of data to be processed as part of /* vorbis_block is a single block of data to be processed as part of
the analysis/synthesis stream; it belongs to a specific logical the analysis/synthesis stream; it belongs to a specific logical
bitstream, but is independant from other vorbis_blocks belonging to bitstream, but is independent from other vorbis_blocks belonging to
that logical bitstream. *************************************************/ that logical bitstream. *************************************************/
struct alloc_chain{ struct alloc_chain{
@ -166,11 +166,11 @@ extern void vorbis_info_init(vorbis_info *vi);
extern void vorbis_info_clear(vorbis_info *vi); extern void vorbis_info_clear(vorbis_info *vi);
extern int vorbis_info_blocksize(vorbis_info *vi,int zo); extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
extern void vorbis_comment_init(vorbis_comment *vc); extern void vorbis_comment_init(vorbis_comment *vc);
extern void vorbis_comment_add(vorbis_comment *vc, char *comment); extern void vorbis_comment_add(vorbis_comment *vc, const char *comment);
extern void vorbis_comment_add_tag(vorbis_comment *vc, extern void vorbis_comment_add_tag(vorbis_comment *vc,
char *tag, char *contents); const char *tag, const char *contents);
extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count);
extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag);
extern void vorbis_comment_clear(vorbis_comment *vc); extern void vorbis_comment_clear(vorbis_comment *vc);
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
@ -179,6 +179,8 @@ extern void vorbis_dsp_clear(vorbis_dsp_state *v);
extern double vorbis_granule_time(vorbis_dsp_state *v, extern double vorbis_granule_time(vorbis_dsp_state *v,
ogg_int64_t granulepos); ogg_int64_t granulepos);
extern const char *vorbis_version_string(void);
/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);

View file

@ -11,10 +11,16 @@
******************************************************************** ********************************************************************
function: vorbis encode-engine setup function: vorbis encode-engine setup
last mod: $Id: vorbisenc.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: vorbisenc.h 17021 2010-03-24 09:29:41Z xiphmont $
********************************************************************/ ********************************************************************/
/** \file
* Libvorbisenc is a convenient API for setting up an encoding
* environment using libvorbis. Libvorbisenc encapsulates the
* actions needed to set up the encoder properly.
*/
#ifndef _OV_ENC_H_ #ifndef _OV_ENC_H_
#define _OV_ENC_H_ #define _OV_ENC_H_
@ -25,6 +31,32 @@ extern "C"
#include "codec.h" #include "codec.h"
/**
* This is the primary function within libvorbisenc for setting up managed
* bitrate modes.
*
* Before this function is called, the \ref vorbis_info
* struct should be initialized by using vorbis_info_init() from the libvorbis
* API. After encoding, vorbis_info_clear() should be called.
*
* The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set
* constraints for the encoded file. This function uses these settings to
* select the appropriate encoding mode and set it up.
*
* \param vi Pointer to an initialized \ref vorbis_info struct.
* \param channels The number of channels to be encoded.
* \param rate The sampling rate of the source audio.
* \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset.
* \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset.
* \param min_bitrate Desired minimum bitrate. -1 indicates unset.
*
* \return Zero for success, and negative values for failure.
*
* \retval 0 Success.
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
* \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request.
*/
extern int vorbis_encode_init(vorbis_info *vi, extern int vorbis_encode_init(vorbis_info *vi,
long channels, long channels,
long rate, long rate,
@ -33,6 +65,35 @@ extern int vorbis_encode_init(vorbis_info *vi,
long nominal_bitrate, long nominal_bitrate,
long min_bitrate); long min_bitrate);
/**
* This function performs step-one of a three-step bitrate-managed encode
* setup. It functions similarly to the one-step setup performed by \ref
* vorbis_encode_init but allows an application to make further encode setup
* tweaks using \ref vorbis_encode_ctl before finally calling \ref
* vorbis_encode_setup_init to complete the setup process.
*
* Before this function is called, the \ref vorbis_info struct should be
* initialized by using vorbis_info_init() from the libvorbis API. After
* encoding, vorbis_info_clear() should be called.
*
* The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set
* constraints for the encoded file. This function uses these settings to
* select the appropriate encoding mode and set it up.
*
* \param vi Pointer to an initialized vorbis_info struct.
* \param channels The number of channels to be encoded.
* \param rate The sampling rate of the source audio.
* \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset.
* \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset.
* \param min_bitrate Desired minimum bitrate. -1 indicates unset.
*
* \return Zero for success, and negative for failure.
*
* \retval 0 Success
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
* \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request.
*/
extern int vorbis_encode_setup_managed(vorbis_info *vi, extern int vorbis_encode_setup_managed(vorbis_info *vi,
long channels, long channels,
long rate, long rate,
@ -41,72 +102,335 @@ extern int vorbis_encode_setup_managed(vorbis_info *vi,
long nominal_bitrate, long nominal_bitrate,
long min_bitrate); long min_bitrate);
/**
* This function performs step-one of a three-step variable bitrate
* (quality-based) encode setup. It functions similarly to the one-step setup
* performed by \ref vorbis_encode_init_vbr() but allows an application to
* make further encode setup tweaks using \ref vorbis_encode_ctl() before
* finally calling \ref vorbis_encode_setup_init to complete the setup
* process.
*
* Before this function is called, the \ref vorbis_info struct should be
* initialized by using \ref vorbis_info_init() from the libvorbis API. After
* encoding, vorbis_info_clear() should be called.
*
* \param vi Pointer to an initialized vorbis_info struct.
* \param channels The number of channels to be encoded.
* \param rate The sampling rate of the source audio.
* \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi).
*
* \return Zero for success, and negative values for failure.
*
* \retval 0 Success
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
* \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request.
*/
extern int vorbis_encode_setup_vbr(vorbis_info *vi, extern int vorbis_encode_setup_vbr(vorbis_info *vi,
long channels, long channels,
long rate, long rate,
float quality /* quality level from 0. (lo) to 1. (hi) */ float quality
); );
/**
* This is the primary function within libvorbisenc for setting up variable
* bitrate ("quality" based) modes.
*
*
* Before this function is called, the vorbis_info struct should be
* initialized by using vorbis_info_init() from the libvorbis API. After
* encoding, vorbis_info_clear() should be called.
*
* \param vi Pointer to an initialized vorbis_info struct.
* \param channels The number of channels to be encoded.
* \param rate The sampling rate of the source audio.
* \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi).
*
*
* \return Zero for success, or a negative number for failure.
*
* \retval 0 Success
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
* \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request.
*/
extern int vorbis_encode_init_vbr(vorbis_info *vi, extern int vorbis_encode_init_vbr(vorbis_info *vi,
long channels, long channels,
long rate, long rate,
float base_quality /* quality level from 0. (lo) to 1. (hi) */ float base_quality
); );
/**
* This function performs the last stage of three-step encoding setup, as
* described in the API overview under managed bitrate modes.
*
* Before this function is called, the \ref vorbis_info struct should be
* initialized by using vorbis_info_init() from the libvorbis API, one of
* \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to
* initialize the high-level encoding setup, and \ref vorbis_encode_ctl()
* called if necessary to make encoding setup changes.
* vorbis_encode_setup_init() finalizes the highlevel encoding structure into
* a complete encoding setup after which the application may make no further
* setup changes.
*
* After encoding, vorbis_info_clear() should be called.
*
* \param vi Pointer to an initialized \ref vorbis_info struct.
*
* \return Zero for success, and negative values for failure.
*
* \retval 0 Success.
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
*
* \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first
* calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to
* initialize the high-level encoding setup
*
*/
extern int vorbis_encode_setup_init(vorbis_info *vi); extern int vorbis_encode_setup_init(vorbis_info *vi);
/**
* This function implements a generic interface to miscellaneous encoder
* settings similar to the classic UNIX 'ioctl()' system call. Applications
* may use vorbis_encode_ctl() to query or set bitrate management or quality
* mode details by using one of several \e request arguments detailed below.
* vorbis_encode_ctl() must be called after one of
* vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used
* to modify settings, \ref vorbis_encode_ctl() must be called before \ref
* vorbis_encode_setup_init().
*
* \param vi Pointer to an initialized vorbis_info struct.
*
* \param number Specifies the desired action; See \ref encctlcodes "the list
* of available requests".
*
* \param arg void * pointing to a data structure matching the request
* argument.
*
* \retval 0 Success. Any further return information (such as the result of a
* query) is placed into the storage pointed to by *arg.
*
* \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after
* calling vorbis_encode_setup_init().
*
* \retval OV_EIMPL Unimplemented or unknown request
*/
extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg);
/* deprecated rate management supported only for compatability */ /**
#define OV_ECTL_RATEMANAGE_GET 0x10 * \deprecated This is a deprecated interface. Please use vorbis_encode_ctl()
#define OV_ECTL_RATEMANAGE_SET 0x11 * with the \ref ovectl_ratemanage2_arg struct and \ref
#define OV_ECTL_RATEMANAGE_AVG 0x12 * OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code.
#define OV_ECTL_RATEMANAGE_HARD 0x13 *
* The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl()
* and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref
* OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to
* query and modify specifics of the encoder's bitrate management
* configuration.
*/
struct ovectl_ratemanage_arg { struct ovectl_ratemanage_arg {
int management_active; int management_active; /**< nonzero if bitrate management is active*/
/** hard lower limit (in kilobits per second) below which the stream bitrate
will never be allowed for any given bitrate_hard_window seconds of time.*/
long bitrate_hard_min; long bitrate_hard_min;
/** hard upper limit (in kilobits per second) above which the stream bitrate
will never be allowed for any given bitrate_hard_window seconds of time.*/
long bitrate_hard_max; long bitrate_hard_max;
/** the window period (in seconds) used to regulate the hard bitrate minimum
and maximum*/
double bitrate_hard_window; double bitrate_hard_window;
/** soft lower limit (in kilobits per second) below which the average bitrate
tracker will start nudging the bitrate higher.*/
long bitrate_av_lo; long bitrate_av_lo;
/** soft upper limit (in kilobits per second) above which the average bitrate
tracker will start nudging the bitrate lower.*/
long bitrate_av_hi; long bitrate_av_hi;
/** the window period (in seconds) used to regulate the average bitrate
minimum and maximum.*/
double bitrate_av_window; double bitrate_av_window;
/** Regulates the relative centering of the average and hard windows; in
libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but
followed the average window regulation. In libvorbis 1.1 a bit-reservoir
interface replaces the old windowing interface; the older windowing
interface is simulated and this field has no effect.*/
double bitrate_av_window_center; double bitrate_av_window_center;
}; };
/**
/* new rate setup */ * \name struct ovectl_ratemanage2_arg
#define OV_ECTL_RATEMANAGE2_GET 0x14 *
#define OV_ECTL_RATEMANAGE2_SET 0x15 * The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and
* the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to
* query and modify specifics of the encoder's bitrate management
* configuration.
*
*/
struct ovectl_ratemanage2_arg { struct ovectl_ratemanage2_arg {
int management_active; int management_active; /**< nonzero if bitrate management is active */
/** Lower allowed bitrate limit in kilobits per second */
long bitrate_limit_min_kbps; long bitrate_limit_min_kbps;
/** Upper allowed bitrate limit in kilobits per second */
long bitrate_limit_max_kbps; long bitrate_limit_max_kbps;
long bitrate_limit_reservoir_bits; long bitrate_limit_reservoir_bits; /**<Size of the bitrate reservoir in bits */
/** Regulates the bitrate reservoir's preferred fill level in a range from 0.0
* to 1.0; 0.0 tries to bank bits to buffer against future bitrate spikes, 1.0
* buffers against future sudden drops in instantaneous bitrate. Default is
* 0.1
*/
double bitrate_limit_reservoir_bias; double bitrate_limit_reservoir_bias;
/** Average bitrate setting in kilobits per second */
long bitrate_average_kbps; long bitrate_average_kbps;
/** Slew rate limit setting for average bitrate adjustment; sets the minimum
* time in seconds the bitrate tracker may swing from one extreme to the
* other when boosting or damping average bitrate.
*/
double bitrate_average_damping; double bitrate_average_damping;
}; };
/**
* \name vorbis_encode_ctl() codes
*
* \anchor encctlcodes
*
* These values are passed as the \c number parameter of vorbis_encode_ctl().
* The type of the referent of that function's \c arg pointer depends on these
* codes.
*/
/*@{*/
/**
* Query the current encoder bitrate management setting.
*
*Argument: <tt>struct ovectl_ratemanage2_arg *</tt>
*
* Used to query the current encoder bitrate management setting. Also used to
* initialize fields of an ovectl_ratemanage2_arg structure for use with
* \ref OV_ECTL_RATEMANAGE2_SET.
*/
#define OV_ECTL_RATEMANAGE2_GET 0x14
/**
* Set the current encoder bitrate management settings.
*
* Argument: <tt>struct ovectl_ratemanage2_arg *</tt>
*
* Used to set the current encoder bitrate management settings to the values
* listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable
* bitrate management.
*/
#define OV_ECTL_RATEMANAGE2_SET 0x15
/**
* Returns the current encoder hard-lowpass setting (kHz) in the double
* pointed to by arg.
*
* Argument: <tt>double *</tt>
*/
#define OV_ECTL_LOWPASS_GET 0x20 #define OV_ECTL_LOWPASS_GET 0x20
/**
* Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid
* lowpass settings range from 2 to 99.
*
* Argument: <tt>double *</tt>
*/
#define OV_ECTL_LOWPASS_SET 0x21 #define OV_ECTL_LOWPASS_SET 0x21
/**
* Returns the current encoder impulse block setting in the double pointed
* to by arg.
*
* Argument: <tt>double *</tt>
*/
#define OV_ECTL_IBLOCK_GET 0x30 #define OV_ECTL_IBLOCK_GET 0x30
/**
* Sets the impulse block bias to the the value pointed to by arg.
*
* Argument: <tt>double *</tt>
*
* Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will
* direct to encoder to use more bits when incoding short blocks that contain
* strong impulses, thus improving the accuracy of impulse encoding.
*/
#define OV_ECTL_IBLOCK_SET 0x31 #define OV_ECTL_IBLOCK_SET 0x31
/**
* Returns the current encoder coupling setting in the int pointed
* to by arg.
*
* Argument: <tt>int *</tt>
*/
#define OV_ECTL_COUPLING_GET 0x40
/**
* Enables/disables channel coupling in multichannel encoding according to arg.
*
* Argument: <tt>int *</tt>
*
* Zero disables channel coupling for multichannel inputs, nonzer enables
* channel coupling. Setting has no effect on monophonic encoding or
* multichannel counts that do not offer coupling. At present, coupling is
* available for stereo and 5.1 encoding.
*/
#define OV_ECTL_COUPLING_SET 0x41
/* deprecated rate management supported only for compatibility */
/**
* Old interface to querying bitrate management settings.
*
* Deprecated after move to bit-reservoir style management in 1.1 rendered
* this interface partially obsolete.
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead.
*
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
*/
#define OV_ECTL_RATEMANAGE_GET 0x10
/**
* Old interface to modifying bitrate management settings.
*
* deprecated after move to bit-reservoir style management in 1.1 rendered
* this interface partially obsolete.
*
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
*
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
*/
#define OV_ECTL_RATEMANAGE_SET 0x11
/**
* Old interface to setting average-bitrate encoding mode.
*
* Deprecated after move to bit-reservoir style management in 1.1 rendered
* this interface partially obsolete.
*
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
*
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
*/
#define OV_ECTL_RATEMANAGE_AVG 0x12
/**
* Old interface to setting bounded-bitrate encoding modes.
*
* deprecated after move to bit-reservoir style management in 1.1 rendered
* this interface partially obsolete.
*
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
*
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
*/
#define OV_ECTL_RATEMANAGE_HARD 0x13
/*@}*/
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif #endif

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: stdio-based convenience library for opening/seeking/decoding function: stdio-based convenience library for opening/seeking/decoding
last mod: $Id: vorbisfile.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $
********************************************************************/ ********************************************************************/
@ -43,6 +43,65 @@ typedef struct {
long (*tell_func) (void *datasource); long (*tell_func) (void *datasource);
} ov_callbacks; } ov_callbacks;
#ifndef OV_EXCLUDE_STATIC_CALLBACKS
/* a few sets of convenient callbacks, especially for use under
* Windows where ov_open_callbacks() should always be used instead of
* ov_open() to avoid problems with incompatible crt.o version linking
* issues. */
static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
if(f==NULL)return(-1);
#ifdef __MINGW32__
return fseeko64(f,off,whence);
#elif defined (_WIN32)
return _fseeki64(f,off,whence);
#else
return fseek(f,off,whence);
#endif
}
/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as
* static data. That means that every file which includes this header
* will get its own copy of these structs whether it uses them or
* not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS.
* These static symbols are essential on platforms such as Windows on
* which several different versions of stdio support may be linked to
* by different DLLs, and we need to be certain we know which one
* we're using (the same one as the main application).
*/
static ov_callbacks OV_CALLBACKS_DEFAULT = {
(size_t (*)(void *, size_t, size_t, void *)) fread,
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap,
(int (*)(void *)) fclose,
(long (*)(void *)) ftell
};
static ov_callbacks OV_CALLBACKS_NOCLOSE = {
(size_t (*)(void *, size_t, size_t, void *)) fread,
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap,
(int (*)(void *)) NULL,
(long (*)(void *)) ftell
};
static ov_callbacks OV_CALLBACKS_STREAMONLY = {
(size_t (*)(void *, size_t, size_t, void *)) fread,
(int (*)(void *, ogg_int64_t, int)) NULL,
(int (*)(void *)) fclose,
(long (*)(void *)) NULL
};
static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = {
(size_t (*)(void *, size_t, size_t, void *)) fread,
(int (*)(void *, ogg_int64_t, int)) NULL,
(int (*)(void *)) NULL,
(long (*)(void *)) NULL
};
#endif
#define NOTOPEN 0 #define NOTOPEN 0
#define PARTOPEN 1 #define PARTOPEN 1
#define OPENED 2 #define OPENED 2
@ -63,7 +122,7 @@ typedef struct OggVorbis_File {
ogg_int64_t *dataoffsets; ogg_int64_t *dataoffsets;
long *serialnos; long *serialnos;
ogg_int64_t *pcmlengths; /* overloaded to maintain binary ogg_int64_t *pcmlengths; /* overloaded to maintain binary
compatability; x2 size, stores both compatibility; x2 size, stores both
beginning and end values */ beginning and end values */
vorbis_info *vi; vorbis_info *vi;
vorbis_comment *vc; vorbis_comment *vc;
@ -88,14 +147,14 @@ typedef struct OggVorbis_File {
extern int ov_clear(OggVorbis_File *vf); extern int ov_clear(OggVorbis_File *vf);
extern int ov_fopen(char *path,OggVorbis_File *vf); extern int ov_fopen(const char *path,OggVorbis_File *vf);
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks); const char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
char *initial, long ibytes, ov_callbacks callbacks); const char *initial, long ibytes, ov_callbacks callbacks);
extern int ov_test_open(OggVorbis_File *vf); extern int ov_test_open(OggVorbis_File *vf);
extern long ov_bitrate(OggVorbis_File *vf,int i); extern long ov_bitrate(OggVorbis_File *vf,int i);
@ -129,6 +188,9 @@ extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples,
int *bitstream); int *bitstream);
extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length,
int bigendianp,int word,int sgned,int *bitstream,
void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param);
extern long ov_read(OggVorbis_File *vf,char *buffer,int length, extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
int bigendianp,int word,int sgned,int *bitstream); int bigendianp,int word,int sgned,int *bitstream);
extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2);
@ -142,4 +204,3 @@ extern int ov_halfrate_p(OggVorbis_File *vf);
#endif #endif

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: single-block PCM analysis mode dispatch function: single-block PCM analysis mode dispatch
last mod: $Id: analysis.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $
********************************************************************/ ********************************************************************/
@ -26,8 +26,6 @@
#include "os.h" #include "os.h"
#include "misc.h" #include "misc.h"
int analysis_noisy=1;
/* decides between modes, dispatches to the appropriate mapping. */ /* decides between modes, dispatches to the appropriate mapping. */
int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
int ret,i; int ret,i;
@ -65,13 +63,15 @@ int vorbis_analysis(vorbis_block *vb, ogg_packet *op){
return(0); return(0);
} }
#ifdef ANALYSIS
int analysis_noisy=1;
/* there was no great place to put this.... */ /* there was no great place to put this.... */
void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){
int j; int j;
FILE *of; FILE *of;
char buffer[80]; char buffer[80];
/* if(i==5870){*/
sprintf(buffer,"%s_%d.m",base,i); sprintf(buffer,"%s_%d.m",base,i);
of=fopen(buffer,"w"); of=fopen(buffer,"w");
@ -99,7 +99,6 @@ void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg
} }
} }
fclose(of); fclose(of);
/* } */
} }
void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
@ -107,7 +106,7 @@ void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off); if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off);
} }
#endif

View file

@ -5,14 +5,14 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: libvorbis backend and mapping structures; needed for function: libvorbis backend and mapping structures; needed for
static mode headers static mode headers
last mod: $Id: backends.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: backends.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
@ -93,10 +93,10 @@ typedef struct{
void (*free_info) (vorbis_info_residue *); void (*free_info) (vorbis_info_residue *);
void (*free_look) (vorbis_look_residue *); void (*free_look) (vorbis_look_residue *);
long **(*class) (struct vorbis_block *,vorbis_look_residue *, long **(*class) (struct vorbis_block *,vorbis_look_residue *,
float **,int *,int); int **,int *,int);
int (*forward) (oggpack_buffer *,struct vorbis_block *, int (*forward) (oggpack_buffer *,struct vorbis_block *,
vorbis_look_residue *, vorbis_look_residue *,
float **,float **,int *,int,long **); int **,int *,int,long **,int);
int (*inverse) (struct vorbis_block *,vorbis_look_residue *, int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
float **,int *,int); float **,int *,int);
} vorbis_func_residue; } vorbis_func_residue;
@ -109,13 +109,13 @@ typedef struct vorbis_info_residue0{
/* first stage (lossless partitioning) */ /* first stage (lossless partitioning) */
int grouping; /* group n vectors per partition */ int grouping; /* group n vectors per partition */
int partitions; /* possible codebooks for a partition */ int partitions; /* possible codebooks for a partition */
int partvals; /* partitions ^ groupbook dim */
int groupbook; /* huffbook for partitioning */ int groupbook; /* huffbook for partitioning */
int secondstages[64]; /* expanded out to pointers in lookup */ int secondstages[64]; /* expanded out to pointers in lookup */
int booklist[256]; /* list of second stage books */ int booklist[512]; /* list of second stage books */
float classmetric1[64];
float classmetric2[64];
const int classmetric1[64];
const int classmetric2[64];
} vorbis_info_residue0; } vorbis_info_residue0;
/* Mapping backend generic *****************************************/ /* Mapping backend generic *****************************************/
@ -142,5 +142,3 @@ typedef struct vorbis_info_mapping0{
} vorbis_info_mapping0; } vorbis_info_mapping0;
#endif #endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: bitrate tracking and management function: bitrate tracking and management
last mod: $Id: bitrate.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: bitrate.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly function: PCM data vector blocking, windowing and dis/reassembly
last mod: $Id: block.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: block.c 17561 2010-10-23 10:34:24Z xiphmont $
Handle windowing, overlap-add, etc of the PCM vectors. This is made Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes. more amusing by Vorbis' current two allowed block sizes.
@ -235,7 +235,10 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
if(!ci->fullbooks){ if(!ci->fullbooks){
ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
for(i=0;i<ci->books;i++){ for(i=0;i<ci->books;i++){
vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); if(ci->book_param[i]==NULL)
goto abort_books;
if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]))
goto abort_books;
/* decode codebooks are now standalone after init */ /* decode codebooks are now standalone after init */
vorbis_staticbook_destroy(ci->book_param[i]); vorbis_staticbook_destroy(ci->book_param[i]);
ci->book_param[i]=NULL; ci->book_param[i]=NULL;
@ -277,6 +280,15 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){
look(v,ci->residue_param[i]); look(v,ci->residue_param[i]);
return 0; return 0;
abort_books:
for(i=0;i<ci->books;i++){
if(ci->book_param[i]!=NULL){
vorbis_staticbook_destroy(ci->book_param[i]);
ci->book_param[i]=NULL;
}
}
vorbis_dsp_clear(v);
return -1;
} }
/* arbitrary settings and spec-mandated numbers get filled in here */ /* arbitrary settings and spec-mandated numbers get filled in here */
@ -403,7 +415,7 @@ float **vorbis_analysis_buffer(vorbis_dsp_state *v, int vals){
static void _preextrapolate_helper(vorbis_dsp_state *v){ static void _preextrapolate_helper(vorbis_dsp_state *v){
int i; int i;
int order=32; int order=16;
float *lpc=alloca(order*sizeof(*lpc)); float *lpc=alloca(order*sizeof(*lpc));
float *work=alloca(v->pcm_current*sizeof(*work)); float *work=alloca(v->pcm_current*sizeof(*work));
long j; long j;
@ -418,6 +430,17 @@ static void _preextrapolate_helper(vorbis_dsp_state *v){
/* prime as above */ /* prime as above */
vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order); vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order);
#if 0
if(v->vi->channels==2){
if(i==0)
_analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0);
else
_analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0);
}else{
_analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0);
}
#endif
/* run the predictor filter */ /* run the predictor filter */
vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order, vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order,
order, order,
@ -683,9 +706,11 @@ int vorbis_synthesis_restart(vorbis_dsp_state *v){
} }
int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
if(_vds_shared_init(v,vi,0)) return 1; if(_vds_shared_init(v,vi,0)){
vorbis_dsp_clear(v);
return 1;
}
vorbis_synthesis_restart(v); vorbis_synthesis_restart(v);
return 0; return 0;
} }
@ -835,17 +860,32 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
if(b->sample_count>v->granulepos){ if(b->sample_count>v->granulepos){
/* corner case; if this is both the first and last audio page, /* corner case; if this is both the first and last audio page,
then spec says the end is cut, not beginning */ then spec says the end is cut, not beginning */
long extra=b->sample_count-vb->granulepos;
/* we use ogg_int64_t for granule positions because a
uint64 isn't universally available. Unfortunately,
that means granposes can be 'negative' and result in
extra being negative */
if(extra<0)
extra=0;
if(vb->eofflag){ if(vb->eofflag){
/* trim the end */ /* trim the end */
/* no preceeding granulepos; assume we started at zero (we'd /* no preceding granulepos; assume we started at zero (we'd
have to in a short single-page stream) */ have to in a short single-page stream) */
/* granulepos could be -1 due to a seek, but that would result /* granulepos could be -1 due to a seek, but that would result
in a long count, not short count */ in a long count, not short count */
v->pcm_current-=(b->sample_count-v->granulepos)>>hs; /* Guard against corrupt/malicious frames that set EOP and
a backdated granpos; don't rewind more samples than we
actually have */
if(extra > (v->pcm_current - v->pcm_returned)<<hs)
extra = (v->pcm_current - v->pcm_returned)<<hs;
v->pcm_current-=extra>>hs;
}else{ }else{
/* trim the beginning */ /* trim the beginning */
v->pcm_returned+=(b->sample_count-v->granulepos)>>hs; v->pcm_returned+=extra>>hs;
if(v->pcm_returned>v->pcm_current) if(v->pcm_returned>v->pcm_current)
v->pcm_returned=v->pcm_current; v->pcm_returned=v->pcm_current;
} }
@ -863,6 +903,20 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
if(extra) if(extra)
if(vb->eofflag){ if(vb->eofflag){
/* partial last frame. Strip the extra samples off */ /* partial last frame. Strip the extra samples off */
/* Guard against corrupt/malicious frames that set EOP and
a backdated granpos; don't rewind more samples than we
actually have */
if(extra > (v->pcm_current - v->pcm_returned)<<hs)
extra = (v->pcm_current - v->pcm_returned)<<hs;
/* we use ogg_int64_t for granule positions because a
uint64 isn't universally available. Unfortunately,
that means granposes can be 'negative' and result in
extra being negative */
if(extra<0)
extra=0;
v->pcm_current-=extra>>hs; v->pcm_current-=extra>>hs;
} /* else {Shouldn't happen *unless* the bitstream is out of } /* else {Shouldn't happen *unless* the bitstream is out of
spec. Either way, believe the bitstream } */ spec. Either way, believe the bitstream } */
@ -990,4 +1044,3 @@ float *vorbis_window(vorbis_dsp_state *v,int W){
if(b->window[W]-1<0)return NULL; if(b->window[W]-1<0)return NULL;
return _vorbis_window_get(b->window[W]-hs); return _vorbis_window_get(b->window[W]-hs);
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: basic codebook pack/unpack/code/decode operations function: basic codebook pack/unpack/code/decode operations
last mod: $Id: codebook.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: codebook.c 18183 2012-02-03 20:51:27Z xiphmont $
********************************************************************/ ********************************************************************/
@ -146,9 +146,9 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
/* unpacks a codebook from the packet buffer into the codebook struct, /* unpacks a codebook from the packet buffer into the codebook struct,
readies the codebook auxiliary structures for decode *************/ readies the codebook auxiliary structures for decode *************/
int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
long i,j; long i,j;
memset(s,0,sizeof(*s)); static_codebook *s=_ogg_calloc(1,sizeof(*s));
s->allocedp=1; s->allocedp=1;
/* make sure alignment is correct */ /* make sure alignment is correct */
@ -159,14 +159,21 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
s->entries=oggpack_read(opb,24); s->entries=oggpack_read(opb,24);
if(s->entries==-1)goto _eofout; if(s->entries==-1)goto _eofout;
if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout;
/* codeword ordering.... length ordered or unordered? */ /* codeword ordering.... length ordered or unordered? */
switch((int)oggpack_read(opb,1)){ switch((int)oggpack_read(opb,1)){
case 0: case 0:{
long unused;
/* allocated but unused entries? */
unused=oggpack_read(opb,1);
if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb))
goto _eofout;
/* unordered */ /* unordered */
s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries); s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
/* allocated but unused entries? */ /* allocated but unused entries? */
if(oggpack_read(opb,1)){ if(unused){
/* yes, unused entries */ /* yes, unused entries */
for(i=0;i<s->entries;i++){ for(i=0;i<s->entries;i++){
@ -187,16 +194,23 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
} }
break; break;
}
case 1: case 1:
/* ordered */ /* ordered */
{ {
long length=oggpack_read(opb,5)+1; long length=oggpack_read(opb,5)+1;
if(length==0)goto _eofout;
s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries); s->lengthlist=_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
for(i=0;i<s->entries;){ for(i=0;i<s->entries;){
long num=oggpack_read(opb,_ilog(s->entries-i)); long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout; if(num==-1)goto _eofout;
for(j=0;j<num && i<s->entries;j++,i++) if(length>32 || num>s->entries-i ||
(num>0 && (num-1)>>(length-1)>1)){
goto _errout;
}
if(length>32)goto _errout;
for(j=0;j<num;j++,i++)
s->lengthlist[i]=length; s->lengthlist[i]=length;
length++; length++;
} }
@ -204,7 +218,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
break; break;
default: default:
/* EOF */ /* EOF */
return(-1); goto _eofout;
} }
/* Do we have a mapping to unpack? */ /* Do we have a mapping to unpack? */
@ -220,12 +234,13 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
s->q_delta=oggpack_read(opb,32); s->q_delta=oggpack_read(opb,32);
s->q_quant=oggpack_read(opb,4)+1; s->q_quant=oggpack_read(opb,4)+1;
s->q_sequencep=oggpack_read(opb,1); s->q_sequencep=oggpack_read(opb,1);
if(s->q_sequencep==-1)goto _eofout;
{ {
int quantvals=0; int quantvals=0;
switch(s->maptype){ switch(s->maptype){
case 1: case 1:
quantvals=_book_maptype1_quantvals(s); quantvals=(s->dim==0?0:_book_maptype1_quantvals(s));
break; break;
case 2: case 2:
quantvals=s->entries*s->dim; quantvals=s->entries*s->dim;
@ -233,6 +248,8 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
} }
/* quantized values */ /* quantized values */
if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb))
goto _eofout;
s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals); s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++) for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant); s->quantlist[i]=oggpack_read(opb,s->q_quant);
@ -245,12 +262,12 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
} }
/* all set */ /* all set */
return(0); return(s);
_errout: _errout:
_eofout: _eofout:
vorbis_staticbook_clear(s); vorbis_staticbook_destroy(s);
return(-1); return(NULL);
} }
/* returns the number of bits ************************************************/ /* returns the number of bits ************************************************/
@ -260,37 +277,6 @@ int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){
return(book->c->lengthlist[a]); return(book->c->lengthlist[a]);
} }
/* One the encode side, our vector writers are each designed for a
specific purpose, and the encoder is not flexible without modification:
The LSP vector coder uses a single stage nearest-match with no
interleave, so no step and no error return. This is specced by floor0
and doesn't change.
Residue0 encoding interleaves, uses multiple stages, and each stage
peels of a specific amount of resolution from a lattice (thus we want
to match by threshold, not nearest match). Residue doesn't *have* to
be encoded that way, but to change it, one will need to add more
infrastructure on the encode side (decode side is specced and simpler) */
/* floor0 LSP (single stage, non interleaved, nearest match) */
/* returns entry number and *modifies a* to the quantization value *****/
int vorbis_book_errorv(codebook *book,float *a){
int dim=book->dim,k;
int best=_best(book,a,1);
for(k=0;k<dim;k++)
a[k]=(book->valuelist+best*dim)[k];
return(best);
}
/* returns the number of bits and *modifies a* to the quantization value *****/
int vorbis_book_encodev(codebook *book,int best,float *a,oggpack_buffer *b){
int k,dim=book->dim;
for(k=0;k<dim;k++)
a[k]=(book->valuelist+best*dim)[k];
return(vorbis_book_encode(book,best,b));
}
/* the 'eliminate the decode tree' optimization actually requires the /* the 'eliminate the decode tree' optimization actually requires the
codewords to be MSb first, not LSb. This is an annoying inelegancy codewords to be MSb first, not LSb. This is an annoying inelegancy
(and one of the first places where carefully thought out design (and one of the first places where carefully thought out design
@ -381,6 +367,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
} }
/* returns 0 on OK or -1 on eof *************************************/ /* returns 0 on OK or -1 on eof *************************************/
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){ long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){ if(book->used_entries>0){
int step=n/book->dim; int step=n/book->dim;
@ -400,6 +387,7 @@ long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
return(0); return(0);
} }
/* decode vector / dim granularity gaurding is done in the upper layer */
long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){ long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){ if(book->used_entries>0){
int i,j,entry; int i,j,entry;
@ -445,6 +433,9 @@ long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
return(0); return(0);
} }
/* unlike the others, we guard against n not being an integer number
of <dim> internally rather than in the upper layer (called only by
floor0) */
long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){ long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
if(book->used_entries>0){ if(book->used_entries>0){
int i,j,entry; int i,j,entry;
@ -454,14 +445,14 @@ long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
entry = decode_packed_entry_number(book,b); entry = decode_packed_entry_number(book,b);
if(entry==-1)return(-1); if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim; t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;) for (j=0;i<n && j<book->dim;){
a[i++]=t[j++]; a[i++]=t[j++];
} }
}
}else{ }else{
int i,j; int i,j;
for(i=0;i<n;){ for(i=0;i<n;){
for (j=0;j<book->dim;)
a[i++]=0.f; a[i++]=0.f;
} }
} }
@ -491,144 +482,3 @@ long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
} }
return(0); return(0);
} }
#ifdef _V_SELFTEST
/* Simple enough; pack a few candidate codebooks, unpack them. Code a
number of vectors through (keeping track of the quantized values),
and decode using the unpacked book. quantized version of in should
exactly equal out */
#include <stdio.h>
#include "vorbis/book/lsp20_0.vqh"
#include "vorbis/book/res0a_13.vqh"
#define TESTSIZE 40
float test1[TESTSIZE]={
0.105939f,
0.215373f,
0.429117f,
0.587974f,
0.181173f,
0.296583f,
0.515707f,
0.715261f,
0.162327f,
0.263834f,
0.342876f,
0.406025f,
0.103571f,
0.223561f,
0.368513f,
0.540313f,
0.136672f,
0.395882f,
0.587183f,
0.652476f,
0.114338f,
0.417300f,
0.525486f,
0.698679f,
0.147492f,
0.324481f,
0.643089f,
0.757582f,
0.139556f,
0.215795f,
0.324559f,
0.399387f,
0.120236f,
0.267420f,
0.446940f,
0.608760f,
0.115587f,
0.287234f,
0.571081f,
0.708603f,
};
float test3[TESTSIZE]={
0,1,-2,3,4,-5,6,7,8,9,
8,-2,7,-1,4,6,8,3,1,-9,
10,11,12,13,14,15,26,17,18,19,
30,-25,-30,-1,-5,-32,4,3,-2,0};
static_codebook *testlist[]={&_vq_book_lsp20_0,
&_vq_book_res0a_13,NULL};
float *testvec[]={test1,test3};
int main(){
oggpack_buffer write;
oggpack_buffer read;
long ptr=0,i;
oggpack_writeinit(&write);
fprintf(stderr,"Testing codebook abstraction...:\n");
while(testlist[ptr]){
codebook c;
static_codebook s;
float *qv=alloca(sizeof(*qv)*TESTSIZE);
float *iv=alloca(sizeof(*iv)*TESTSIZE);
memcpy(qv,testvec[ptr],sizeof(*qv)*TESTSIZE);
memset(iv,0,sizeof(*iv)*TESTSIZE);
fprintf(stderr,"\tpacking/coding %ld... ",ptr);
/* pack the codebook, write the testvector */
oggpack_reset(&write);
vorbis_book_init_encode(&c,testlist[ptr]); /* get it into memory
we can write */
vorbis_staticbook_pack(testlist[ptr],&write);
fprintf(stderr,"Codebook size %ld bytes... ",oggpack_bytes(&write));
for(i=0;i<TESTSIZE;i+=c.dim){
int best=_best(&c,qv+i,1);
vorbis_book_encodev(&c,best,qv+i,&write);
}
vorbis_book_clear(&c);
fprintf(stderr,"OK.\n");
fprintf(stderr,"\tunpacking/decoding %ld... ",ptr);
/* transfer the write data to a read buffer and unpack/read */
oggpack_readinit(&read,oggpack_get_buffer(&write),oggpack_bytes(&write));
if(vorbis_staticbook_unpack(&read,&s)){
fprintf(stderr,"Error unpacking codebook.\n");
exit(1);
}
if(vorbis_book_init_decode(&c,&s)){
fprintf(stderr,"Error initializing codebook.\n");
exit(1);
}
for(i=0;i<TESTSIZE;i+=c.dim)
if(vorbis_book_decodev_set(&c,iv+i,&read,c.dim)==-1){
fprintf(stderr,"Error reading codebook test data (EOP).\n");
exit(1);
}
for(i=0;i<TESTSIZE;i++)
if(fabs(qv[i]-iv[i])>.000001){
fprintf(stderr,"read (%g) != written (%g) at position (%ld)\n",
iv[i],qv[i],i);
exit(1);
}
fprintf(stderr,"OK\n");
ptr++;
}
/* The above is the trivial stuff; now try unquantizing a log scale codebook */
exit(0);
}
#endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: basic shared codebook operations function: basic shared codebook operations
last mod: $Id: codebook.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: codebook.h 17030 2010-03-25 06:52:55Z xiphmont $
********************************************************************/ ********************************************************************/
@ -52,50 +52,9 @@ typedef struct static_codebook{
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
map == 2: list of dim*entries quantized entry vals map == 2: list of dim*entries quantized entry vals
*/ */
/* encode helpers ********************************************************/
struct encode_aux_nearestmatch *nearest_tree;
struct encode_aux_threshmatch *thresh_tree;
struct encode_aux_pigeonhole *pigeon_tree;
int allocedp; int allocedp;
} static_codebook; } static_codebook;
/* this structures an arbitrary trained book to quickly find the
nearest cell match */
typedef struct encode_aux_nearestmatch{
/* pre-calculated partitioning tree */
long *ptr0;
long *ptr1;
long *p; /* decision points (each is an entry) */
long *q; /* decision points (each is an entry) */
long aux; /* number of tree entries */
long alloc;
} encode_aux_nearestmatch;
/* assumes a maptype of 1; encode side only, so that's OK */
typedef struct encode_aux_threshmatch{
float *quantthresh;
long *quantmap;
int quantvals;
int threshvals;
} encode_aux_threshmatch;
typedef struct encode_aux_pigeonhole{
float min;
float del;
int mapentries;
int quantvals;
long *pigeonmap;
long fittotal;
long *fitlist;
long *fitmap;
long *fitlength;
} encode_aux_pigeonhole;
typedef struct codebook{ typedef struct codebook{
long dim; /* codebook dimensions (elements per vector) */ long dim; /* codebook dimensions (elements per vector) */
long entries; /* codebook entries */ long entries; /* codebook entries */
@ -114,9 +73,12 @@ typedef struct codebook{
int dec_firsttablen; int dec_firsttablen;
int dec_maxlength; int dec_maxlength;
/* The current encoder uses only centered, integer-only lattice books. */
int quantvals;
int minval;
int delta;
} codebook; } codebook;
extern void vorbis_staticbook_clear(static_codebook *b);
extern void vorbis_staticbook_destroy(static_codebook *b); extern void vorbis_staticbook_destroy(static_codebook *b);
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source); extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source);
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
@ -137,12 +99,9 @@ extern long vorbis_book_codelen(codebook *book,int entry);
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b); extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c); extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b); extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b);
extern int vorbis_book_errorv(codebook *book, float *a);
extern int vorbis_book_encodev(codebook *book, int best,float *a,
oggpack_buffer *b);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
extern long vorbis_book_decodevs_add(codebook *book, float *a, extern long vorbis_book_decodevs_add(codebook *book, float *a,

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: libvorbis codec headers function: libvorbis codec headers
last mod: $Id: codec_internal.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -133,5 +133,35 @@ typedef struct codec_setup_info {
extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi); extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi);
extern void _vp_global_free(vorbis_look_psy_global *look); extern void _vp_global_free(vorbis_look_psy_global *look);
#endif
typedef struct {
int sorted_index[VIF_POSIT+2];
int forward_index[VIF_POSIT+2];
int reverse_index[VIF_POSIT+2];
int hineighbor[VIF_POSIT];
int loneighbor[VIF_POSIT];
int posts;
int n;
int quant_q;
vorbis_info_floor1 *vi;
long phrasebits;
long postbits;
long frames;
} vorbis_look_floor1;
extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
const float *logmdct, /* in */
const float *logmask);
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
int *A,int *B,
int del);
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
vorbis_look_floor1 *look,
int *post,int *ilogmask);
#endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: PCM data envelope analysis function: PCM data envelope analysis
last mod: $Id: envelope.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: envelope.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -91,8 +91,7 @@ static int _ve_amp(envelope_lookup *ve,
vorbis_info_psy_global *gi, vorbis_info_psy_global *gi,
float *data, float *data,
envelope_band *bands, envelope_band *bands,
envelope_filter_state *filters, envelope_filter_state *filters){
long pos){
long n=ve->winlength; long n=ve->winlength;
int ret=0; int ret=0;
long i,j; long i,j;
@ -240,7 +239,7 @@ long _ve_envelope_search(vorbis_dsp_state *v){
for(i=0;i<ve->ch;i++){ for(i=0;i<ve->ch;i++){
float *pcm=v->pcm[i]+ve->searchstep*(j); float *pcm=v->pcm[i]+ve->searchstep*(j);
ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS,j); ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS);
} }
ve->mark[j+VE_POST]=0; ve->mark[j+VE_POST]=0;
@ -374,9 +373,3 @@ void _ve_envelope_shift(envelope_lookup *e,long shift){
e->curmark-=shift; e->curmark-=shift;
e->cursor-=shift; e->cursor-=shift;
} }

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: PCM data envelope analysis and manipulation function: PCM data envelope analysis and manipulation
last mod: $Id: envelope.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: envelope.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -78,4 +78,3 @@ extern int _ve_envelope_mark(vorbis_dsp_state *v);
#endif #endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: floor backend 0 implementation function: floor backend 0 implementation
last mod: $Id: floor0.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: floor0.c 18184 2012-02-03 20:55:12Z xiphmont $
********************************************************************/ ********************************************************************/
@ -91,6 +91,8 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
for(j=0;j<info->numbooks;j++){ for(j=0;j<info->numbooks;j++){
info->books[j]=oggpack_read(opb,8); info->books[j]=oggpack_read(opb,8);
if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out;
if(ci->book_param[info->books[j]]->maptype==0)goto err_out;
if(ci->book_param[info->books[j]]->dim<1)goto err_out;
} }
return(info); return(info);
@ -175,10 +177,9 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
vector */ vector */
float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1)); float *lsp=_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1));
for(j=0;j<look->m;j+=b->dim) if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m)==-1)goto eop;
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
for(j=0;j<look->m;){ for(j=0;j<look->m;){
for(k=0;k<b->dim;k++,j++)lsp[j]+=last; for(k=0;j<look->m && k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1]; last=lsp[j-1];
} }
@ -214,10 +215,7 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
} }
/* export hooks */ /* export hooks */
vorbis_func_floor floor0_exportbundle={ const vorbis_func_floor floor0_exportbundle={
NULL,&floor0_unpack,&floor0_look,&floor0_free_info, NULL,&floor0_unpack,&floor0_look,&floor0_free_info,
&floor0_free_look,&floor0_inverse1,&floor0_inverse2 &floor0_free_look,&floor0_inverse1,&floor0_inverse2
}; };

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: floor backend 1 implementation function: floor backend 1 implementation
last mod: $Id: floor1.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: floor1.c 18151 2012-01-20 07:35:26Z xiphmont $
********************************************************************/ ********************************************************************/
@ -30,34 +30,23 @@
#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */ #define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
typedef struct {
int sorted_index[VIF_POSIT+2];
int forward_index[VIF_POSIT+2];
int reverse_index[VIF_POSIT+2];
int hineighbor[VIF_POSIT];
int loneighbor[VIF_POSIT];
int posts;
int n;
int quant_q;
vorbis_info_floor1 *vi;
long phrasebits;
long postbits;
long frames;
} vorbis_look_floor1;
typedef struct lsfit_acc{ typedef struct lsfit_acc{
long x0; int x0;
long x1; int x1;
long xa; int xa;
long ya; int ya;
long x2a; int x2a;
long y2a; int y2a;
long xya; int xya;
long an; int an;
int xb;
int yb;
int x2b;
int y2b;
int xyb;
int bn;
} lsfit_acc; } lsfit_acc;
/***********************************************/ /***********************************************/
@ -138,6 +127,9 @@ static void floor1_pack (vorbis_info_floor *i,oggpack_buffer *opb){
} }
} }
static int icomp(const void *a,const void *b){
return(**(int **)a-**(int **)b);
}
static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
@ -148,6 +140,7 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */ info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
for(j=0;j<info->partitions;j++){ for(j=0;j<info->partitions;j++){
info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */ info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */
if(info->partitionclass[j]<0)goto err_out;
if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j]; if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j];
} }
@ -170,9 +163,11 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
/* read the post list */ /* read the post list */
info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */ info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */
rangebits=oggpack_read(opb,4); rangebits=oggpack_read(opb,4);
if(rangebits<0)goto err_out;
for(j=0,k=0;j<info->partitions;j++){ for(j=0,k=0;j<info->partitions;j++){
count+=info->class_dim[info->partitionclass[j]]; count+=info->class_dim[info->partitionclass[j]];
if(count>VIF_POSIT) goto err_out;
for(;k<count;k++){ for(;k<count;k++){
int t=info->postlist[k+2]=oggpack_read(opb,rangebits); int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
if(t<0 || t>=(1<<rangebits)) if(t<0 || t>=(1<<rangebits))
@ -182,6 +177,17 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
info->postlist[0]=0; info->postlist[0]=0;
info->postlist[1]=1<<rangebits; info->postlist[1]=1<<rangebits;
/* don't allow repeated values in post list as they'd result in
zero-length segments */
{
int *sortpointer[VIF_POSIT+2];
for(j=0;j<count+2;j++)sortpointer[j]=info->postlist+j;
qsort(sortpointer,count+2,sizeof(*sortpointer),icomp);
for(j=1;j<count+2;j++)
if(*sortpointer[j-1]==*sortpointer[j])goto err_out;
}
return(info); return(info);
err_out: err_out:
@ -189,10 +195,6 @@ static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
return(NULL); return(NULL);
} }
static int icomp(const void *a,const void *b){
return(**(int **)a-**(int **)b);
}
static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd, static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,
vorbis_info_floor *in){ vorbis_info_floor *in){
@ -291,7 +293,7 @@ static int vorbis_dBquant(const float *x){
return i; return i;
} }
static float FLOOR1_fromdB_LOOKUP[256]={ static const float FLOOR1_fromdB_LOOKUP[256]={
1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
@ -387,7 +389,7 @@ static void render_line(int n, int x0,int x1,int y0,int y1,float *d){
} }
} }
static void render_line0(int x0,int x1,int y0,int y1,int *d){ static void render_line0(int n, int x0,int x1,int y0,int y1,int *d){
int dy=y1-y0; int dy=y1-y0;
int adx=x1-x0; int adx=x1-x0;
int ady=abs(dy); int ady=abs(dy);
@ -399,8 +401,12 @@ static void render_line0(int x0,int x1,int y0,int y1,int *d){
ady-=abs(base*adx); ady-=abs(base*adx);
if(n>x1)n=x1;
if(x<n)
d[x]=y; d[x]=y;
while(++x<x1){
while(++x<n){
err=err+ady; err=err+ady;
if(err>=adx){ if(err>=adx){
err-=adx; err-=adx;
@ -417,9 +423,8 @@ static int accumulate_fit(const float *flr,const float *mdct,
int x0, int x1,lsfit_acc *a, int x0, int x1,lsfit_acc *a,
int n,vorbis_info_floor1 *info){ int n,vorbis_info_floor1 *info){
long i; long i;
int quantized=vorbis_dBquant(flr+x0);
long xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0; int xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0;
memset(a,0,sizeof(*a)); memset(a,0,sizeof(*a));
a->x0=x0; a->x0=x0;
@ -447,69 +452,65 @@ static int accumulate_fit(const float *flr,const float *mdct,
} }
} }
xb+=xa; a->xa=xa;
yb+=ya; a->ya=ya;
x2b+=x2a; a->x2a=x2a;
y2b+=y2a; a->y2a=y2a;
xyb+=xya; a->xya=xya;
nb+=na; a->an=na;
/* weight toward the actually used frequencies if we meet the threshhold */ a->xb=xb;
{ a->yb=yb;
int weight=nb*info->twofitweight/(na+1); a->x2b=x2b;
a->y2b=y2b;
a->xa=xa*weight+xb; a->xyb=xyb;
a->ya=ya*weight+yb; a->bn=nb;
a->x2a=x2a*weight+x2b;
a->y2a=y2a*weight+y2b;
a->xya=xya*weight+xyb;
a->an=na*weight+nb;
}
return(na); return(na);
} }
static void fit_line(lsfit_acc *a,int fits,int *y0,int *y1){ static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1,
long x=0,y=0,x2=0,y2=0,xy=0,an=0,i; vorbis_info_floor1 *info){
long x0=a[0].x0; double xb=0,yb=0,x2b=0,y2b=0,xyb=0,bn=0;
long x1=a[fits-1].x1; int i;
int x0=a[0].x0;
int x1=a[fits-1].x1;
for(i=0;i<fits;i++){ for(i=0;i<fits;i++){
x+=a[i].xa; double weight = (a[i].bn+a[i].an)*info->twofitweight/(a[i].an+1)+1.;
y+=a[i].ya;
x2+=a[i].x2a; xb+=a[i].xb + a[i].xa * weight;
y2+=a[i].y2a; yb+=a[i].yb + a[i].ya * weight;
xy+=a[i].xya; x2b+=a[i].x2b + a[i].x2a * weight;
an+=a[i].an; y2b+=a[i].y2b + a[i].y2a * weight;
xyb+=a[i].xyb + a[i].xya * weight;
bn+=a[i].bn + a[i].an * weight;
} }
if(*y0>=0){ if(*y0>=0){
x+= x0; xb+= x0;
y+= *y0; yb+= *y0;
x2+= x0 * x0; x2b+= x0 * x0;
y2+= *y0 * *y0; y2b+= *y0 * *y0;
xy+= *y0 * x0; xyb+= *y0 * x0;
an++; bn++;
} }
if(*y1>=0){ if(*y1>=0){
x+= x1; xb+= x1;
y+= *y1; yb+= *y1;
x2+= x1 * x1; x2b+= x1 * x1;
y2+= *y1 * *y1; y2b+= *y1 * *y1;
xy+= *y1 * x1; xyb+= *y1 * x1;
an++; bn++;
} }
if(an){ {
/* need 64 bit multiplies, which C doesn't give portably as int */ double denom=(bn*x2b-xb*xb);
double fx=x;
double fy=y; if(denom>0.){
double fx2=x2; double a=(yb*x2b-xyb*xb)/denom;
double fxy=xy; double b=(bn*xyb-xb*yb)/denom;
double denom=1./(an*fx2-fx*fx);
double a=(fy*fx2-fxy*fx)*denom;
double b=(an*fxy-fx*fy)*denom;
*y0=rint(a+b*x0); *y0=rint(a+b*x0);
*y1=rint(a+b*x1); *y1=rint(a+b*x1);
@ -519,21 +520,14 @@ static void fit_line(lsfit_acc *a,int fits,int *y0,int *y1){
if(*y0<0)*y0=0; if(*y0<0)*y0=0;
if(*y1<0)*y1=0; if(*y1<0)*y1=0;
return 0;
}else{ }else{
*y0=0; *y0=0;
*y1=0; *y1=0;
return 1;
}
} }
} }
/*static void fit_line_point(lsfit_acc *a,int fits,int *y0,int *y1){
long y=0;
int i;
for(i=0;i<fits && y==0;i++)
y+=a[i].ya;
*y0=*y1=y;
}*/
static int inspect_error(int x0,int x1,int y0,int y1,const float *mask, static int inspect_error(int x0,int x1,int y0,int y1,const float *mask,
const float *mdct, const float *mdct,
@ -595,8 +589,6 @@ static int post_Y(int *A,int *B,int pos){
return (A[pos]+B[pos])>>1; return (A[pos]+B[pos])>>1;
} }
static int seq=0;
int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
const float *logmdct, /* in */ const float *logmdct, /* in */
const float *logmask){ const float *logmask){
@ -635,7 +627,7 @@ int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
/* start by fitting the implicit base case.... */ /* start by fitting the implicit base case.... */
int y0=-200; int y0=-200;
int y1=-200; int y1=-200;
fit_line(fits,posts-1,&y0,&y1); fit_line(fits,posts-1,&y0,&y1,info);
fit_valueA[0]=y0; fit_valueA[0]=y0;
fit_valueB[0]=y0; fit_valueB[0]=y0;
@ -675,9 +667,22 @@ int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
int ly1=-200; int ly1=-200;
int hy0=-200; int hy0=-200;
int hy1=-200; int hy1=-200;
fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1); int ret0=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1,info);
fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1); int ret1=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1,info);
if(ret0){
ly0=ly;
ly1=hy0;
}
if(ret1){
hy0=ly1;
hy1=hy;
}
if(ret0 && ret1){
fit_valueA[i]=-200;
fit_valueB[i]=-200;
}else{
/* store new edge values */ /* store new edge values */
fit_valueB[ln]=ly0; fit_valueB[ln]=ly0;
if(ln==0)fit_valueA[ln]=ly0; if(ln==0)fit_valueA[ln]=ly0;
@ -698,10 +703,9 @@ int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look,
loneighbor[j]=i; loneighbor[j]=i;
else else
break; break;
}
} }
}else{ }else{
fit_valueA[i]=-200; fit_valueA[i]=-200;
fit_valueB[i]=-200; fit_valueB[i]=-200;
} }
@ -751,6 +755,7 @@ int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look,
if(A && B){ if(A && B){
output=_vorbis_block_alloc(vb,sizeof(*output)*posts); output=_vorbis_block_alloc(vb,sizeof(*output)*posts);
/* overly simpleminded--- look again post 1.2 */
for(i=0;i<posts;i++){ for(i=0;i<posts;i++){
output[i]=((65536-del)*(A[i]&0x7fff)+del*(B[i]&0x7fff)+32768)>>16; output[i]=((65536-del)*(A[i]&0x7fff)+del*(B[i]&0x7fff)+32768)>>16;
if(A[i]&0x8000 && B[i]&0x8000)output[i]|=0x8000; if(A[i]&0x8000 && B[i]&0x8000)output[i]|=0x8000;
@ -767,13 +772,11 @@ int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
long i,j; long i,j;
vorbis_info_floor1 *info=look->vi; vorbis_info_floor1 *info=look->vi;
long n=look->n;
long posts=look->posts; long posts=look->posts;
codec_setup_info *ci=vb->vd->vi->codec_setup; codec_setup_info *ci=vb->vd->vi->codec_setup;
int out[VIF_POSIT+2]; int out[VIF_POSIT+2];
static_codebook **sbooks=ci->book_param; static_codebook **sbooks=ci->book_param;
codebook *books=ci->fullbooks; codebook *books=ci->fullbooks;
static long seq=0;
/* quantize values to multiplier spec */ /* quantize values to multiplier spec */
if(post){ if(post){
@ -937,6 +940,8 @@ int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
int hx=0; int hx=0;
int lx=0; int lx=0;
int ly=post[0]*info->mult; int ly=post[0]*info->mult;
int n=ci->blocksizes[vb->W]/2;
for(j=1;j<look->posts;j++){ for(j=1;j<look->posts;j++){
int current=look->forward_index[j]; int current=look->forward_index[j];
int hy=post[current]&0x7fff; int hy=post[current]&0x7fff;
@ -945,20 +950,18 @@ int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
hy*=info->mult; hy*=info->mult;
hx=info->postlist[current]; hx=info->postlist[current];
render_line0(lx,hx,ly,hy,ilogmask); render_line0(n,lx,hx,ly,hy,ilogmask);
lx=hx; lx=hx;
ly=hy; ly=hy;
} }
} }
for(j=hx;j<vb->pcmend/2;j++)ilogmask[j]=ly; /* be certain */ for(j=hx;j<vb->pcmend/2;j++)ilogmask[j]=ly; /* be certain */
seq++;
return(1); return(1);
} }
}else{ }else{
oggpack_write(opb,0,1); oggpack_write(opb,0,1);
memset(ilogmask,0,vb->pcmend/2*sizeof(*ilogmask)); memset(ilogmask,0,vb->pcmend/2*sizeof(*ilogmask));
seq++;
return(0); return(0);
} }
} }
@ -1033,7 +1036,7 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
} }
} }
fit_value[i]=val+predicted; fit_value[i]=(val+predicted)&0x7fff;
fit_value[look->loneighbor[i-2]]&=0x7fff; fit_value[look->loneighbor[i-2]]&=0x7fff;
fit_value[look->hineighbor[i-2]]&=0x7fff; fit_value[look->hineighbor[i-2]]&=0x7fff;
@ -1064,13 +1067,18 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
int hx=0; int hx=0;
int lx=0; int lx=0;
int ly=fit_value[0]*info->mult; int ly=fit_value[0]*info->mult;
/* guard lookup against out-of-range values */
ly=(ly<0?0:ly>255?255:ly);
for(j=1;j<look->posts;j++){ for(j=1;j<look->posts;j++){
int current=look->forward_index[j]; int current=look->forward_index[j];
int hy=fit_value[current]&0x7fff; int hy=fit_value[current]&0x7fff;
if(hy==fit_value[current]){ if(hy==fit_value[current]){
hy*=info->mult;
hx=info->postlist[current]; hx=info->postlist[current];
hy*=info->mult;
/* guard lookup against out-of-range values */
hy=(hy<0?0:hy>255?255:hy);
render_line(n,lx,hx,ly,hy,out); render_line(n,lx,hx,ly,hy,out);
@ -1086,9 +1094,7 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
} }
/* export hooks */ /* export hooks */
vorbis_func_floor floor1_exportbundle={ const vorbis_func_floor floor1_exportbundle={
&floor1_pack,&floor1_unpack,&floor1_look,&floor1_free_info, &floor1_pack,&floor1_unpack,&floor1_look,&floor1_free_info,
&floor1_free_look,&floor1_inverse1,&floor1_inverse2 &floor1_free_look,&floor1_inverse1,&floor1_inverse2
}; };

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: highlevel encoder setup struct seperated out for vorbisenc clarity function: highlevel encoder setup struct separated out for vorbisenc clarity
last mod: $Id: highlevel.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: highlevel.h 17195 2010-05-05 21:49:51Z giles $
********************************************************************/ ********************************************************************/
@ -23,14 +23,14 @@ typedef struct highlevel_byblocktype {
} highlevel_byblocktype; } highlevel_byblocktype;
typedef struct highlevel_encode_setup { typedef struct highlevel_encode_setup {
void *setup;
int set_in_stone; int set_in_stone;
const void *setup;
double base_setting; double base_setting;
double long_setting;
double short_setting;
double impulse_noisetune; double impulse_noisetune;
/* bitrate management below all settable */
float req;
int managed; int managed;
long bitrate_min; long bitrate_min;
long bitrate_av; long bitrate_av;
@ -41,9 +41,11 @@ typedef struct highlevel_encode_setup {
int impulse_block_p; int impulse_block_p;
int noise_normalize_p; int noise_normalize_p;
int coupling_p;
double stereo_point_setting; double stereo_point_setting;
double lowpass_kHz; double lowpass_kHz;
int lowpass_altered;
double ath_floating_dB; double ath_floating_dB;
double ath_absolute_dB; double ath_absolute_dB;
@ -54,4 +56,3 @@ typedef struct highlevel_encode_setup {
highlevel_byblocktype block[4]; /* padding, impulse, transition, long */ highlevel_byblocktype block[4]; /* padding, impulse, transition, long */
} highlevel_encode_setup; } highlevel_encode_setup;

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: maintain the info structure, info <-> header packets function: maintain the info structure, info <-> header packets
last mod: $Id: info.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: info.c 18186 2012-02-03 22:08:44Z xiphmont $
********************************************************************/ ********************************************************************/
@ -31,6 +31,9 @@
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.3"
#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20120203 (Omnipresent)"
/* helpers */ /* helpers */
static int ilog2(unsigned int v){ static int ilog2(unsigned int v){
int ret=0; int ret=0;
@ -42,7 +45,7 @@ static int ilog2(unsigned int v){
return(ret); return(ret);
} }
static void _v_writestring(oggpack_buffer *o,char *s, int bytes){ static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){
while(bytes--){ while(bytes--){
oggpack_write(o,*s++,8); oggpack_write(o,*s++,8);
@ -59,7 +62,7 @@ void vorbis_comment_init(vorbis_comment *vc){
memset(vc,0,sizeof(*vc)); memset(vc,0,sizeof(*vc));
} }
void vorbis_comment_add(vorbis_comment *vc,char *comment){ void vorbis_comment_add(vorbis_comment *vc,const char *comment){
vc->user_comments=_ogg_realloc(vc->user_comments, vc->user_comments=_ogg_realloc(vc->user_comments,
(vc->comments+2)*sizeof(*vc->user_comments)); (vc->comments+2)*sizeof(*vc->user_comments));
vc->comment_lengths=_ogg_realloc(vc->comment_lengths, vc->comment_lengths=_ogg_realloc(vc->comment_lengths,
@ -71,7 +74,7 @@ void vorbis_comment_add(vorbis_comment *vc,char *comment){
vc->user_comments[vc->comments]=NULL; vc->user_comments[vc->comments]=NULL;
} }
void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents){ void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){
char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */ char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
strcpy(comment, tag); strcpy(comment, tag);
strcat(comment, "="); strcat(comment, "=");
@ -91,7 +94,7 @@ static int tagcompare(const char *s1, const char *s2, int n){
return 0; return 0;
} }
char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count){
long i; long i;
int found = 0; int found = 0;
int taglen = strlen(tag)+1; /* +1 for the = we append */ int taglen = strlen(tag)+1; /* +1 for the = we append */
@ -112,7 +115,7 @@ char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
return NULL; /* didn't find anything */ return NULL; /* didn't find anything */
} }
int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){
int i,count=0; int i,count=0;
int taglen = strlen(tag)+1; /* +1 for the = we append */ int taglen = strlen(tag)+1; /* +1 for the = we append */
char *fulltag = alloca(taglen+1); char *fulltag = alloca(taglen+1);
@ -130,9 +133,11 @@ int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
void vorbis_comment_clear(vorbis_comment *vc){ void vorbis_comment_clear(vorbis_comment *vc){
if(vc){ if(vc){
long i; long i;
if(vc->user_comments){
for(i=0;i<vc->comments;i++) for(i=0;i<vc->comments;i++)
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
if(vc->user_comments)_ogg_free(vc->user_comments); _ogg_free(vc->user_comments);
}
if(vc->comment_lengths)_ogg_free(vc->comment_lengths); if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
if(vc->vendor)_ogg_free(vc->vendor); if(vc->vendor)_ogg_free(vc->vendor);
memset(vc,0,sizeof(*vc)); memset(vc,0,sizeof(*vc));
@ -236,16 +241,20 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
int i; int i;
int vendorlen=oggpack_read(opb,32); int vendorlen=oggpack_read(opb,32);
if(vendorlen<0)goto err_out; if(vendorlen<0)goto err_out;
if(vendorlen>opb->storage-8)goto err_out;
vc->vendor=_ogg_calloc(vendorlen+1,1); vc->vendor=_ogg_calloc(vendorlen+1,1);
_v_readstring(opb,vc->vendor,vendorlen); _v_readstring(opb,vc->vendor,vendorlen);
vc->comments=oggpack_read(opb,32); i=oggpack_read(opb,32);
if(vc->comments<0)goto err_out; if(i<0)goto err_out;
if(i>((opb->storage-oggpack_bytes(opb))>>2))goto err_out;
vc->comments=i;
vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments));
vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths));
for(i=0;i<vc->comments;i++){ for(i=0;i<vc->comments;i++){
int len=oggpack_read(opb,32); int len=oggpack_read(opb,32);
if(len<0)goto err_out; if(len<0)goto err_out;
if(len>opb->storage-oggpack_bytes(opb))goto err_out;
vc->comment_lengths[i]=len; vc->comment_lengths[i]=len;
vc->user_comments[i]=_ogg_calloc(len+1,1); vc->user_comments[i]=_ogg_calloc(len+1,1);
_v_readstring(opb,vc->user_comments[i],len); _v_readstring(opb,vc->user_comments[i],len);
@ -267,15 +276,16 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* codebooks */ /* codebooks */
ci->books=oggpack_read(opb,8)+1; ci->books=oggpack_read(opb,8)+1;
/*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/ if(ci->books<=0)goto err_out;
for(i=0;i<ci->books;i++){ for(i=0;i<ci->books;i++){
ci->book_param[i]=_ogg_calloc(1,sizeof(*ci->book_param[i])); ci->book_param[i]=vorbis_staticbook_unpack(opb);
if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out; if(!ci->book_param[i])goto err_out;
} }
/* time backend settings; hooks are unused */ /* time backend settings; hooks are unused */
{ {
int times=oggpack_read(opb,6)+1; int times=oggpack_read(opb,6)+1;
if(times<=0)goto err_out;
for(i=0;i<times;i++){ for(i=0;i<times;i++){
int test=oggpack_read(opb,16); int test=oggpack_read(opb,16);
if(test<0 || test>=VI_TIMEB)goto err_out; if(test<0 || test>=VI_TIMEB)goto err_out;
@ -284,8 +294,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* floor backend settings */ /* floor backend settings */
ci->floors=oggpack_read(opb,6)+1; ci->floors=oggpack_read(opb,6)+1;
/*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/ if(ci->floors<=0)goto err_out;
/*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/
for(i=0;i<ci->floors;i++){ for(i=0;i<ci->floors;i++){
ci->floor_type[i]=oggpack_read(opb,16); ci->floor_type[i]=oggpack_read(opb,16);
if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
@ -295,8 +304,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* residue backend settings */ /* residue backend settings */
ci->residues=oggpack_read(opb,6)+1; ci->residues=oggpack_read(opb,6)+1;
/*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/ if(ci->residues<=0)goto err_out;
/*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/
for(i=0;i<ci->residues;i++){ for(i=0;i<ci->residues;i++){
ci->residue_type[i]=oggpack_read(opb,16); ci->residue_type[i]=oggpack_read(opb,16);
if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out;
@ -306,8 +314,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* map backend settings */ /* map backend settings */
ci->maps=oggpack_read(opb,6)+1; ci->maps=oggpack_read(opb,6)+1;
/*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/ if(ci->maps<=0)goto err_out;
/*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/
for(i=0;i<ci->maps;i++){ for(i=0;i<ci->maps;i++){
ci->map_type[i]=oggpack_read(opb,16); ci->map_type[i]=oggpack_read(opb,16);
if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;
@ -317,7 +324,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
/* mode settings */ /* mode settings */
ci->modes=oggpack_read(opb,6)+1; ci->modes=oggpack_read(opb,6)+1;
/*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/ if(ci->modes<=0)goto err_out;
for(i=0;i<ci->modes;i++){ for(i=0;i<ci->modes;i++){
ci->mode_param[i]=_ogg_calloc(1,sizeof(*ci->mode_param[i])); ci->mode_param[i]=_ogg_calloc(1,sizeof(*ci->mode_param[i]));
ci->mode_param[i]->blockflag=oggpack_read(opb,1); ci->mode_param[i]->blockflag=oggpack_read(opb,1);
@ -328,6 +335,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out; if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;
if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out; if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;
if(ci->mode_param[i]->mapping>=ci->maps)goto err_out; if(ci->mode_param[i]->mapping>=ci->maps)goto err_out;
if(ci->mode_param[i]->mapping<0)goto err_out;
} }
if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */ if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
@ -451,8 +459,7 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
} }
static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
char temp[]="Xiph.Org libVorbis I 20070622"; int bytes = strlen(ENCODE_VENDOR_STRING);
int bytes = strlen(temp);
/* preamble */ /* preamble */
oggpack_write(opb,0x03,8); oggpack_write(opb,0x03,8);
@ -460,7 +467,7 @@ static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
/* vendor */ /* vendor */
oggpack_write(opb,bytes,32); oggpack_write(opb,bytes,32);
_v_writestring(opb,temp, bytes); _v_writestring(opb,ENCODE_VENDOR_STRING, bytes);
/* comments */ /* comments */
@ -543,7 +550,10 @@ int vorbis_commentheader_out(vorbis_comment *vc,
oggpack_buffer opb; oggpack_buffer opb;
oggpack_writeinit(&opb); oggpack_writeinit(&opb);
if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL; if(_vorbis_pack_comment(&opb,vc)){
oggpack_writeclear(&opb);
return OV_EIMPL;
}
op->packet = _ogg_malloc(oggpack_bytes(&opb)); op->packet = _ogg_malloc(oggpack_bytes(&opb));
memcpy(op->packet, opb.buffer, oggpack_bytes(&opb)); memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
@ -554,6 +564,7 @@ int vorbis_commentheader_out(vorbis_comment *vc,
op->granulepos=0; op->granulepos=0;
op->packetno=1; op->packetno=1;
oggpack_writeclear(&opb);
return 0; return 0;
} }
@ -621,12 +632,12 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v,
oggpack_writeclear(&opb); oggpack_writeclear(&opb);
return(0); return(0);
err_out: err_out:
oggpack_writeclear(&opb);
memset(op,0,sizeof(*op)); memset(op,0,sizeof(*op));
memset(op_comm,0,sizeof(*op_comm)); memset(op_comm,0,sizeof(*op_comm));
memset(op_code,0,sizeof(*op_code)); memset(op_code,0,sizeof(*op_code));
if(b){ if(b){
oggpack_writeclear(&opb);
if(b->header)_ogg_free(b->header); if(b->header)_ogg_free(b->header);
if(b->header1)_ogg_free(b->header1); if(b->header1)_ogg_free(b->header1);
if(b->header2)_ogg_free(b->header2); if(b->header2)_ogg_free(b->header2);
@ -638,7 +649,20 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v,
} }
double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){ double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){
if(granulepos>=0) if(granulepos == -1) return -1;
/* We're not guaranteed a 64 bit unsigned type everywhere, so we
have to put the unsigned granpo in a signed type. */
if(granulepos>=0){
return((double)granulepos/v->vi->rate); return((double)granulepos/v->vi->rate);
return(-1); }else{
ogg_int64_t granuleoff=0xffffffff;
granuleoff<<=31;
granuleoff|=0x7ffffffff;
return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate);
}
}
const char *vorbis_version_string(void){
return GENERAL_VENDOR_STRING;
} }

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: lookup based functions function: lookup based functions
last mod: $Id: lookup.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lookup.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: lookup based functions function: lookup based functions
last mod: $Id: lookup.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lookup.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: lookup data; generated by lookups.pl; edit there function: lookup data; generated by lookups.pl; edit there
last mod: $Id: lookup_data.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lookup_data.h 16037 2009-05-26 21:10:58Z xiphmont $
********************************************************************/ ********************************************************************/
@ -19,7 +19,7 @@
#ifdef FLOAT_LOOKUP #ifdef FLOAT_LOOKUP
#define COS_LOOKUP_SZ 128 #define COS_LOOKUP_SZ 128
static float COS_LOOKUP[COS_LOOKUP_SZ+1]={ static const float COS_LOOKUP[COS_LOOKUP_SZ+1]={
+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f, +1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f,
+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f, +0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f,
+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f, +0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f,
@ -56,7 +56,7 @@ static float COS_LOOKUP[COS_LOOKUP_SZ+1]={
}; };
#define INVSQ_LOOKUP_SZ 32 #define INVSQ_LOOKUP_SZ 32
static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={ static const float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={
1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f, 1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f,
1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f, 1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f,
1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f, 1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f,
@ -70,7 +70,7 @@ static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={
#define INVSQ2EXP_LOOKUP_MIN (-32) #define INVSQ2EXP_LOOKUP_MIN (-32)
#define INVSQ2EXP_LOOKUP_MAX 32 #define INVSQ2EXP_LOOKUP_MAX 32
static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\ static const float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
INVSQ2EXP_LOOKUP_MIN+1]={ INVSQ2EXP_LOOKUP_MIN+1]={
65536.f, 46340.95001f, 32768.f, 23170.47501f, 65536.f, 46340.95001f, 32768.f, 23170.47501f,
16384.f, 11585.2375f, 8192.f, 5792.618751f, 16384.f, 11585.2375f, 8192.f, 5792.618751f,
@ -98,7 +98,9 @@ static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\
#define FROMdB_SHIFT 5 #define FROMdB_SHIFT 5
#define FROMdB2_SHIFT 3 #define FROMdB2_SHIFT 3
#define FROMdB2_MASK 31 #define FROMdB2_MASK 31
static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
#ifdef FLOAT_LOOKUP
static const float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f, 1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f,
0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f, 0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f,
0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f, 0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f,
@ -110,7 +112,7 @@ static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={
3.981071706e-07f,2.511886432e-07f,1.584893192e-07f, 3.981071706e-07f,2.511886432e-07f,1.584893192e-07f,
}; };
static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={ static const float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f, 0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f,
0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f, 0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f,
0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f, 0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f,
@ -120,12 +122,13 @@ static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={
0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f, 0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f,
0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f, 0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f,
}; };
#endif
#ifdef INT_LOOKUP #ifdef INT_LOOKUP
#define INVSQ_LOOKUP_I_SHIFT 10 #define INVSQ_LOOKUP_I_SHIFT 10
#define INVSQ_LOOKUP_I_MASK 1023 #define INVSQ_LOOKUP_I_MASK 1023
static long INVSQ_LOOKUP_I[64+1]={ static const long INVSQ_LOOKUP_I[64+1]={
92682l, 91966l, 91267l, 90583l, 92682l, 91966l, 91267l, 90583l,
89915l, 89261l, 88621l, 87995l, 89915l, 89261l, 88621l, 87995l,
87381l, 86781l, 86192l, 85616l, 87381l, 86781l, 86192l, 85616l,
@ -148,7 +151,7 @@ static long INVSQ_LOOKUP_I[64+1]={
#define COS_LOOKUP_I_SHIFT 9 #define COS_LOOKUP_I_SHIFT 9
#define COS_LOOKUP_I_MASK 511 #define COS_LOOKUP_I_MASK 511
#define COS_LOOKUP_I_SZ 128 #define COS_LOOKUP_I_SZ 128
static long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={ static const long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={
16384l, 16379l, 16364l, 16340l, 16384l, 16379l, 16364l, 16340l,
16305l, 16261l, 16207l, 16143l, 16305l, 16261l, 16207l, 16143l,
16069l, 15986l, 15893l, 15791l, 16069l, 15986l, 15893l, 15791l,

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: LPC low level routines function: LPC low level routines
last mod: $Id: lpc.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -62,6 +62,7 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
double *aut=alloca(sizeof(*aut)*(m+1)); double *aut=alloca(sizeof(*aut)*(m+1));
double *lpc=alloca(sizeof(*lpc)*(m)); double *lpc=alloca(sizeof(*lpc)*(m));
double error; double error;
double epsilon;
int i,j; int i,j;
/* autocorrelation, p+1 lag coefficients */ /* autocorrelation, p+1 lag coefficients */
@ -74,14 +75,16 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
/* Generate lpc coefficients from autocorr values */ /* Generate lpc coefficients from autocorr values */
error=aut[0]; /* set our noise floor to about -100dB */
error=aut[0] * (1. + 1e-10);
epsilon=1e-9*aut[0]+1e-10;
for(i=0;i<m;i++){ for(i=0;i<m;i++){
double r= -aut[i+1]; double r= -aut[i+1];
if(error==0){ if(error<epsilon){
memset(lpci,0,m*sizeof(*lpci)); memset(lpc+i,0,(m-i)*sizeof(*lpc));
return 0; goto done;
} }
/* Sum up this iteration's reflection coefficient; note that in /* Sum up this iteration's reflection coefficient; note that in
@ -101,9 +104,22 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
lpc[j]+=r*lpc[i-1-j]; lpc[j]+=r*lpc[i-1-j];
lpc[i-1-j]+=r*tmp; lpc[i-1-j]+=r*tmp;
} }
if(i%2)lpc[j]+=lpc[j]*r; if(i&1)lpc[j]+=lpc[j]*r;
error*=1.f-r*r; error*=1.-r*r;
}
done:
/* slightly damp the filter */
{
double g = .99;
double damp = g;
for(j=0;j<m;j++){
lpc[j]*=damp;
damp*=g;
}
} }
for(j=0;j<m;j++)lpci[j]=(float)lpc[j]; for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
@ -142,8 +158,3 @@ void vorbis_lpc_predict(float *coeff,float *prime,int m,
data[i]=work[o]=y; data[i]=work[o]=y;
} }
} }

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: LPC low level routines function: LPC low level routines
last mod: $Id: lpc.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $
********************************************************************/ ********************************************************************/

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: LSP (also called LSF) conversion routines function: LSP (also called LSF) conversion routines
last mod: $Id: lsp.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lsp.c 17538 2010-10-15 02:52:29Z tterribe $
The LSP generation code is taken (with minimal modification and a The LSP generation code is taken (with minimal modification and a
few bugfixes) from "On the Computation of the LSP Frequencies" by few bugfixes) from "On the Computation of the LSP Frequencies" by
@ -46,13 +46,14 @@
implementation. The float lookup is likely the optimal choice on implementation. The float lookup is likely the optimal choice on
any machine with an FPU. The integer implementation is *not* fixed any machine with an FPU. The integer implementation is *not* fixed
point (due to the need for a large dynamic range and thus a point (due to the need for a large dynamic range and thus a
seperately tracked exponent) and thus much more complex than the separately tracked exponent) and thus much more complex than the
relatively simple float implementations. It's mostly for future relatively simple float implementations. It's mostly for future
work on a fully fixed point implementation for processors like the work on a fully fixed point implementation for processors like the
ARM family. */ ARM family. */
/* undefine both for the 'old' but more precise implementation */ /* define either of these (preferably FLOAT_LOOKUP) to have faster
#define FLOAT_LOOKUP but less precise implementation. */
#undef FLOAT_LOOKUP
#undef INT_LOOKUP #undef INT_LOOKUP
#ifdef FLOAT_LOOKUP #ifdef FLOAT_LOOKUP
@ -80,11 +81,11 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
float *ftmp=lsp; float *ftmp=lsp;
int c=m>>1; int c=m>>1;
do{ while(c--){
q*=ftmp[0]-w; q*=ftmp[0]-w;
p*=ftmp[1]-w; p*=ftmp[1]-w;
ftmp+=2; ftmp+=2;
}while(--c); }
if(m&1){ if(m&1){
/* odd order filter; slightly assymetric */ /* odd order filter; slightly assymetric */
@ -118,21 +119,21 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
compilers (like gcc) that can't inline across compilers (like gcc) that can't inline across
modules */ modules */
static int MLOOP_1[64]={ static const int MLOOP_1[64]={
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13, 0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
}; };
static int MLOOP_2[64]={ static const int MLOOP_2[64]={
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7, 0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
}; };
static int MLOOP_3[8]={0,1,2,2,3,3,3,3}; static const int MLOOP_3[8]={0,1,2,2,3,3,3,3};
/* side effect: changes *lsp to cosines of lsp */ /* side effect: changes *lsp to cosines of lsp */

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: LSP (also called LSF) conversion routines function: LSP (also called LSF) conversion routines
last mod: $Id: lsp.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: lsp.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: channel mapping 0 implementation function: channel mapping 0 implementation
last mod: $Id: mapping0.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: mapping0.c 17022 2010-03-25 03:45:42Z xiphmont $
********************************************************************/ ********************************************************************/
@ -100,19 +100,24 @@ static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,
/* also responsible for range checking */ /* also responsible for range checking */
static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
int i; int i,b;
vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(*info)); vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(*info));
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
memset(info,0,sizeof(*info)); memset(info,0,sizeof(*info));
if(oggpack_read(opb,1)) b=oggpack_read(opb,1);
if(b<0)goto err_out;
if(b){
info->submaps=oggpack_read(opb,4)+1; info->submaps=oggpack_read(opb,4)+1;
else if(info->submaps<=0)goto err_out;
}else
info->submaps=1; info->submaps=1;
if(oggpack_read(opb,1)){ b=oggpack_read(opb,1);
if(b<0)goto err_out;
if(b){
info->coupling_steps=oggpack_read(opb,8)+1; info->coupling_steps=oggpack_read(opb,8)+1;
if(info->coupling_steps<=0)goto err_out;
for(i=0;i<info->coupling_steps;i++){ for(i=0;i<info->coupling_steps;i++){
int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels)); int testM=info->coupling_mag[i]=oggpack_read(opb,ilog(vi->channels));
int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels)); int testA=info->coupling_ang[i]=oggpack_read(opb,ilog(vi->channels));
@ -126,20 +131,20 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
} }
if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */ if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */
if(info->submaps>1){ if(info->submaps>1){
for(i=0;i<vi->channels;i++){ for(i=0;i<vi->channels;i++){
info->chmuxlist[i]=oggpack_read(opb,4); info->chmuxlist[i]=oggpack_read(opb,4);
if(info->chmuxlist[i]>=info->submaps)goto err_out; if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out;
} }
} }
for(i=0;i<info->submaps;i++){ for(i=0;i<info->submaps;i++){
oggpack_read(opb,8); /* time submap unused */ oggpack_read(opb,8); /* time submap unused */
info->floorsubmap[i]=oggpack_read(opb,8); info->floorsubmap[i]=oggpack_read(opb,8);
if(info->floorsubmap[i]>=ci->floors)goto err_out; if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out;
info->residuesubmap[i]=oggpack_read(opb,8); info->residuesubmap[i]=oggpack_read(opb,8);
if(info->residuesubmap[i]>=ci->residues)goto err_out; if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0)goto err_out;
} }
return info; return info;
@ -229,16 +234,6 @@ static float FLOOR1_fromdB_LOOKUP[256]={
#endif #endif
extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor *look,
const float *logmdct, /* in */
const float *logmask);
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor *look,
int *A,int *B,
int del);
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb,
vorbis_look_floor *look,
int *post,int *ilogmask);
static int mapping0_forward(vorbis_block *vb){ static int mapping0_forward(vorbis_block *vb){
vorbis_dsp_state *vd=vb->vd; vorbis_dsp_state *vd=vb->vd;
@ -251,7 +246,7 @@ static int mapping0_forward(vorbis_block *vb){
int *nonzero = alloca(sizeof(*nonzero)*vi->channels); int *nonzero = alloca(sizeof(*nonzero)*vi->channels);
float **gmdct = _vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct)); float **gmdct = _vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct));
int **ilogmaskch= _vorbis_block_alloc(vb,vi->channels*sizeof(*ilogmaskch)); int **iwork = _vorbis_block_alloc(vb,vi->channels*sizeof(*iwork));
int ***floor_posts = _vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts)); int ***floor_posts = _vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts));
float global_ampmax=vbi->ampmax; float global_ampmax=vbi->ampmax;
@ -260,8 +255,7 @@ static int mapping0_forward(vorbis_block *vb){
int modenumber=vb->W; int modenumber=vb->W;
vorbis_info_mapping0 *info=ci->map_param[modenumber]; vorbis_info_mapping0 *info=ci->map_param[modenumber];
vorbis_look_psy *psy_look= vorbis_look_psy *psy_look=b->psy+blocktype+(vb->W?2:0);
b->psy+blocktype+(vb->W?2:0);
vb->mode=modenumber; vb->mode=modenumber;
@ -272,6 +266,7 @@ static int mapping0_forward(vorbis_block *vb){
float *pcm =vb->pcm[i]; float *pcm =vb->pcm[i];
float *logfft =pcm; float *logfft =pcm;
iwork[i]=_vorbis_block_alloc(vb,n/2*sizeof(**iwork));
gmdct[i]=_vorbis_block_alloc(vb,n/2*sizeof(**gmdct)); gmdct[i]=_vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
scale_dB=todB(&scale) + .345; /* + .345 is a hack; the original scale_dB=todB(&scale) + .345; /* + .345 is a hack; the original
@ -290,22 +285,28 @@ static int mapping0_forward(vorbis_block *vb){
next major model upgrade. */ next major model upgrade. */
#if 0 #if 0
if(vi->channels==2) if(vi->channels==2){
if(i==0) if(i==0)
_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2); _analysis_output("pcmL",seq,pcm,n,0,0,total-n/2);
else else
_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2); _analysis_output("pcmR",seq,pcm,n,0,0,total-n/2);
}else{
_analysis_output("pcm",seq,pcm,n,0,0,total-n/2);
}
#endif #endif
/* window the PCM data */ /* window the PCM data */
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW); _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
#if 0 #if 0
if(vi->channels==2) if(vi->channels==2){
if(i==0) if(i==0)
_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2); _analysis_output("windowedL",seq,pcm,n,0,0,total-n/2);
else else
_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2); _analysis_output("windowedR",seq,pcm,n,0,0,total-n/2);
}else{
_analysis_output("windowed",seq,pcm,n,0,0,total-n/2);
}
#endif #endif
/* transform the PCM data */ /* transform the PCM data */
@ -359,6 +360,8 @@ static int mapping0_forward(vorbis_block *vb){
}else{ }else{
_analysis_output("fftR",seq,logfft,n/2,1,0,0); _analysis_output("fftR",seq,logfft,n/2,1,0,0);
} }
}else{
_analysis_output("fft",seq,logfft,n/2,1,0,0);
} }
#endif #endif
@ -429,6 +432,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("noiseL",seq,noise,n/2,1,0,0); _analysis_output("noiseL",seq,noise,n/2,1,0,0);
else else
_analysis_output("noiseR",seq,noise,n/2,1,0,0); _analysis_output("noiseR",seq,noise,n/2,1,0,0);
}else{
_analysis_output("noise",seq,noise,n/2,1,0,0);
} }
#endif #endif
@ -448,6 +453,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("toneL",seq,tone,n/2,1,0,0); _analysis_output("toneL",seq,tone,n/2,1,0,0);
else else
_analysis_output("toneR",seq,tone,n/2,1,0,0); _analysis_output("toneR",seq,tone,n/2,1,0,0);
}else{
_analysis_output("tone",seq,tone,n/2,1,0,0);
} }
#endif #endif
@ -475,6 +482,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0); _analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0);
else else
_analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0); _analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0);
}else{
_analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0);
} }
} }
#endif #endif
@ -486,6 +495,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("mask1L",seq,logmask,n/2,1,0,0); _analysis_output("mask1L",seq,logmask,n/2,1,0,0);
else else
_analysis_output("mask1R",seq,logmask,n/2,1,0,0); _analysis_output("mask1R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask1",seq,logmask,n/2,1,0,0);
} }
#endif #endif
@ -518,6 +529,8 @@ static int mapping0_forward(vorbis_block *vb){
_analysis_output("mask2L",seq,logmask,n/2,1,0,0); _analysis_output("mask2L",seq,logmask,n/2,1,0,0);
else else
_analysis_output("mask2R",seq,logmask,n/2,1,0,0); _analysis_output("mask2R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask2",seq,logmask,n/2,1,0,0);
} }
#endif #endif
@ -536,11 +549,14 @@ static int mapping0_forward(vorbis_block *vb){
logmdct); logmdct);
#if 0 #if 0
if(vi->channels==2) if(vi->channels==2){
if(i==0) if(i==0)
_analysis_output("mask0L",seq,logmask,n/2,1,0,0); _analysis_output("mask0L",seq,logmask,n/2,1,0,0);
else else
_analysis_output("mask0R",seq,logmask,n/2,1,0,0); _analysis_output("mask0R",seq,logmask,n/2,1,0,0);
}else{
_analysis_output("mask0",seq,logmask,n/2,1,0,0);
}
#endif #endif
floor_posts[i][0]= floor_posts[i][0]=
@ -582,39 +598,8 @@ static int mapping0_forward(vorbis_block *vb){
/* iterate over the many masking curve fits we've created */ /* iterate over the many masking curve fits we've created */
{ {
float **res_bundle=alloca(sizeof(*res_bundle)*vi->channels); int **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
float **couple_bundle=alloca(sizeof(*couple_bundle)*vi->channels);
int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels); int *zerobundle=alloca(sizeof(*zerobundle)*vi->channels);
int **sortindex=alloca(sizeof(*sortindex)*vi->channels);
float **mag_memo;
int **mag_sort;
if(info->coupling_steps){
mag_memo=_vp_quantize_couple_memo(vb,
&ci->psy_g_param,
psy_look,
info,
gmdct);
mag_sort=_vp_quantize_couple_sort(vb,
psy_look,
info,
mag_memo);
hf_reduction(&ci->psy_g_param,
psy_look,
info,
mag_memo);
}
memset(sortindex,0,sizeof(*sortindex)*vi->channels);
if(psy_look->vi->normal_channel_p){
for(i=0;i<vi->channels;i++){
float *mdct =gmdct[i];
sortindex[i]=alloca(sizeof(**sortindex)*n/2);
_vp_noise_normalize_sort(psy_look,mdct,sortindex[i]);
}
}
for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2); for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2);
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2); k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2);
@ -635,10 +620,7 @@ static int mapping0_forward(vorbis_block *vb){
/* encode floor, compute masking curve, sep out residue */ /* encode floor, compute masking curve, sep out residue */
for(i=0;i<vi->channels;i++){ for(i=0;i<vi->channels;i++){
int submap=info->chmuxlist[i]; int submap=info->chmuxlist[i];
float *mdct =gmdct[i]; int *ilogmask=iwork[i];
float *res =vb->pcm[i];
int *ilogmask=ilogmaskch[i]=
_vorbis_block_alloc(vb,n/2*sizeof(**gmdct));
nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]], nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]],
floor_posts[i][k], floor_posts[i][k],
@ -649,29 +631,9 @@ static int mapping0_forward(vorbis_block *vb){
sprintf(buf,"maskI%c%d",i?'R':'L',k); sprintf(buf,"maskI%c%d",i?'R':'L',k);
float work[n/2]; float work[n/2];
for(j=0;j<n/2;j++) for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]; work[j]=FLOOR1_fromdB_LOOKUP[iwork[i][j]];
_analysis_output(buf,seq,work,n/2,1,1,0); _analysis_output(buf,seq,work,n/2,1,1,0);
} }
#endif
_vp_remove_floor(psy_look,
mdct,
ilogmask,
res,
ci->psy_g_param.sliding_lowpass[vb->W][k]);
_vp_noise_normalize(psy_look,res,res+n/2,sortindex[i]);
#if 0
{
char buf[80];
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]*(res+n/2)[j];
sprintf(buf,"resI%c%d",i?'R':'L',k);
_analysis_output(buf,seq,work,n/2,1,1,0);
}
#endif #endif
} }
@ -681,18 +643,26 @@ static int mapping0_forward(vorbis_block *vb){
/* quantize/couple */ /* quantize/couple */
/* incomplete implementation that assumes the tree is all depth /* incomplete implementation that assumes the tree is all depth
one, or no tree at all */ one, or no tree at all */
if(info->coupling_steps){ _vp_couple_quantize_normalize(k,
_vp_couple(k,
&ci->psy_g_param, &ci->psy_g_param,
psy_look, psy_look,
info, info,
vb->pcm, gmdct,
mag_memo, iwork,
mag_sort,
ilogmaskch,
nonzero, nonzero,
ci->psy_g_param.sliding_lowpass[vb->W][k]); ci->psy_g_param.sliding_lowpass[vb->W][k],
vi->channels);
#if 0
for(i=0;i<vi->channels;i++){
char buf[80];
sprintf(buf,"res%c%d",i?'R':'L',k);
float work[n/2];
for(j=0;j<n/2;j++)
work[j]=iwork[i][j];
_analysis_output(buf,seq,work,n/2,1,0,0);
} }
#endif
/* classify and encode by submap */ /* classify and encode by submap */
for(i=0;i<info->submaps;i++){ for(i=0;i<info->submaps;i++){
@ -704,17 +674,21 @@ static int mapping0_forward(vorbis_block *vb){
if(info->chmuxlist[j]==i){ if(info->chmuxlist[j]==i){
zerobundle[ch_in_bundle]=0; zerobundle[ch_in_bundle]=0;
if(nonzero[j])zerobundle[ch_in_bundle]=1; if(nonzero[j])zerobundle[ch_in_bundle]=1;
res_bundle[ch_in_bundle]=vb->pcm[j]; couple_bundle[ch_in_bundle++]=iwork[j];
couple_bundle[ch_in_bundle++]=vb->pcm[j]+n/2;
} }
} }
classifications=_residue_P[ci->residue_type[resnum]]-> classifications=_residue_P[ci->residue_type[resnum]]->
class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle); class(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
ch_in_bundle=0;
for(j=0;j<vi->channels;j++)
if(info->chmuxlist[j]==i)
couple_bundle[ch_in_bundle++]=iwork[j];
_residue_P[ci->residue_type[resnum]]-> _residue_P[ci->residue_type[resnum]]->
forward(opb,vb,b->residue[resnum], forward(opb,vb,b->residue[resnum],
couple_bundle,NULL,zerobundle,ch_in_bundle,classifications); couple_bundle,zerobundle,ch_in_bundle,classifications,i);
} }
/* ok, done encoding. Next protopacket. */ /* ok, done encoding. Next protopacket. */
@ -735,7 +709,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
private_state *b=vd->backend_state; private_state *b=vd->backend_state;
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l; vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l;
int hs=ci->halfrate_flag;
int i,j; int i,j;
long n=vb->pcmend=ci->blocksizes[vb->W]; long n=vb->pcmend=ci->blocksizes[vb->W];
@ -834,11 +807,10 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
} }
/* export hooks */ /* export hooks */
vorbis_func_mapping mapping0_exportbundle={ const vorbis_func_mapping mapping0_exportbundle={
&mapping0_pack, &mapping0_pack,
&mapping0_unpack, &mapping0_unpack,
&mapping0_free_info, &mapping0_free_info,
&mapping0_forward, &mapping0_forward,
&mapping0_inverse &mapping0_inverse
}; };

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: masking curve data for psychoacoustics function: masking curve data for psychoacoustics
last mod: $Id: masking.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: masking.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -22,7 +22,7 @@
overly for only a bin or two of savings. */ overly for only a bin or two of savings. */
#define MAX_ATH 88 #define MAX_ATH 88
static float ATH[]={ static const float ATH[]={
/*15*/ -51, -52, -53, -54, -55, -56, -57, -58, /*15*/ -51, -52, -53, -54, -55, -56, -57, -58,
/*31*/ -59, -60, -61, -62, -63, -64, -65, -66, /*31*/ -59, -60, -61, -62, -63, -64, -65, -66,
/*63*/ -67, -68, -69, -70, -71, -72, -73, -74, /*63*/ -67, -68, -69, -70, -71, -72, -73, -74,
@ -48,7 +48,7 @@ static float ATH[]={
/* (Vorbis 0dB, the loudest possible tone, is assumed to be ~100dB SPL /* (Vorbis 0dB, the loudest possible tone, is assumed to be ~100dB SPL
for collection of these curves) */ for collection of these curves) */
static float tonemasks[P_BANDS][6][EHMER_MAX]={ static const float tonemasks[P_BANDS][6][EHMER_MAX]={
/* 62.5 Hz */ /* 62.5 Hz */
{{ -60, -60, -60, -60, -60, -60, -60, -60, {{ -60, -60, -60, -60, -60, -60, -60, -60,
-60, -60, -60, -60, -62, -62, -65, -73, -60, -60, -60, -60, -62, -62, -65, -73,

View file

@ -5,14 +5,14 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: normalized modified discrete cosine transform function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ] power of two length transform only [64 <= n ]
last mod: $Id: mdct.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: mdct.c 16227 2009-07-08 06:58:46Z xiphmont $
Original algorithm adapted long ago from _The use of multirate filter Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer, banks for coding of high quality digital audio_, by T. Sporer,
@ -561,4 +561,3 @@ void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){
T+=2; T+=2;
} }
} }

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: modified discrete cosine transform prototypes function: modified discrete cosine transform prototypes
last mod: $Id: mdct.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: mdct.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -69,15 +69,3 @@ extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out);
extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out);
#endif #endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: miscellaneous prototypes function: miscellaneous prototypes
last mod: $Id: misc.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: misc.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -19,16 +19,21 @@
#define _V_RANDOM_H_ #define _V_RANDOM_H_
#include "vorbis/codec.h" #include "vorbis/codec.h"
extern int analysis_noisy;
extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
extern void _vorbis_block_ripcord(vorbis_block *vb); extern void _vorbis_block_ripcord(vorbis_block *vb);
#ifdef ANALYSIS
extern int analysis_noisy;
extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB,
ogg_int64_t off); ogg_int64_t off);
extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,
ogg_int64_t off);
#endif
#ifdef DEBUG_MALLOC #ifdef DEBUG_MALLOC
#define _VDBG_GRAPHFILE "malloc.m" #define _VDBG_GRAPHFILE "malloc.m"
#undef _VDBG_GRAPHFILE
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line);
extern void _VDBG_free(void *ptr,char *file,long line); extern void _VDBG_free(void *ptr,char *file,long line);

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: key floor settings function: key floor settings
last mod: $Id: floor_all.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: floor_all.h 17050 2010-03-26 01:34:42Z xiphmont $
********************************************************************/ ********************************************************************/
@ -19,21 +19,21 @@
#include "backends.h" #include "backends.h"
#include "books/floor/floor_books.h" #include "books/floor/floor_books.h"
static static_codebook *_floor_128x4_books[]={ static const static_codebook*const _floor_128x4_books[]={
&_huff_book_line_128x4_class0, &_huff_book_line_128x4_class0,
&_huff_book_line_128x4_0sub0, &_huff_book_line_128x4_0sub0,
&_huff_book_line_128x4_0sub1, &_huff_book_line_128x4_0sub1,
&_huff_book_line_128x4_0sub2, &_huff_book_line_128x4_0sub2,
&_huff_book_line_128x4_0sub3, &_huff_book_line_128x4_0sub3,
}; };
static static_codebook *_floor_256x4_books[]={ static const static_codebook*const _floor_256x4_books[]={
&_huff_book_line_256x4_class0, &_huff_book_line_256x4_class0,
&_huff_book_line_256x4_0sub0, &_huff_book_line_256x4_0sub0,
&_huff_book_line_256x4_0sub1, &_huff_book_line_256x4_0sub1,
&_huff_book_line_256x4_0sub2, &_huff_book_line_256x4_0sub2,
&_huff_book_line_256x4_0sub3, &_huff_book_line_256x4_0sub3,
}; };
static static_codebook *_floor_128x7_books[]={ static const static_codebook*const _floor_128x7_books[]={
&_huff_book_line_128x7_class0, &_huff_book_line_128x7_class0,
&_huff_book_line_128x7_class1, &_huff_book_line_128x7_class1,
@ -44,7 +44,7 @@ static static_codebook *_floor_128x7_books[]={
&_huff_book_line_128x7_1sub2, &_huff_book_line_128x7_1sub2,
&_huff_book_line_128x7_1sub3, &_huff_book_line_128x7_1sub3,
}; };
static static_codebook *_floor_256x7_books[]={ static const static_codebook*const _floor_256x7_books[]={
&_huff_book_line_256x7_class0, &_huff_book_line_256x7_class0,
&_huff_book_line_256x7_class1, &_huff_book_line_256x7_class1,
@ -55,7 +55,7 @@ static static_codebook *_floor_256x7_books[]={
&_huff_book_line_256x7_1sub2, &_huff_book_line_256x7_1sub2,
&_huff_book_line_256x7_1sub3, &_huff_book_line_256x7_1sub3,
}; };
static static_codebook *_floor_128x11_books[]={ static const static_codebook*const _floor_128x11_books[]={
&_huff_book_line_128x11_class1, &_huff_book_line_128x11_class1,
&_huff_book_line_128x11_class2, &_huff_book_line_128x11_class2,
&_huff_book_line_128x11_class3, &_huff_book_line_128x11_class3,
@ -70,7 +70,7 @@ static static_codebook *_floor_128x11_books[]={
&_huff_book_line_128x11_3sub2, &_huff_book_line_128x11_3sub2,
&_huff_book_line_128x11_3sub3, &_huff_book_line_128x11_3sub3,
}; };
static static_codebook *_floor_128x17_books[]={ static const static_codebook*const _floor_128x17_books[]={
&_huff_book_line_128x17_class1, &_huff_book_line_128x17_class1,
&_huff_book_line_128x17_class2, &_huff_book_line_128x17_class2,
&_huff_book_line_128x17_class3, &_huff_book_line_128x17_class3,
@ -85,14 +85,14 @@ static static_codebook *_floor_128x17_books[]={
&_huff_book_line_128x17_3sub2, &_huff_book_line_128x17_3sub2,
&_huff_book_line_128x17_3sub3, &_huff_book_line_128x17_3sub3,
}; };
static static_codebook *_floor_256x4low_books[]={ static const static_codebook*const _floor_256x4low_books[]={
&_huff_book_line_256x4low_class0, &_huff_book_line_256x4low_class0,
&_huff_book_line_256x4low_0sub0, &_huff_book_line_256x4low_0sub0,
&_huff_book_line_256x4low_0sub1, &_huff_book_line_256x4low_0sub1,
&_huff_book_line_256x4low_0sub2, &_huff_book_line_256x4low_0sub2,
&_huff_book_line_256x4low_0sub3, &_huff_book_line_256x4low_0sub3,
}; };
static static_codebook *_floor_1024x27_books[]={ static const static_codebook*const _floor_1024x27_books[]={
&_huff_book_line_1024x27_class1, &_huff_book_line_1024x27_class1,
&_huff_book_line_1024x27_class2, &_huff_book_line_1024x27_class2,
&_huff_book_line_1024x27_class3, &_huff_book_line_1024x27_class3,
@ -110,7 +110,7 @@ static static_codebook *_floor_1024x27_books[]={
&_huff_book_line_1024x27_4sub2, &_huff_book_line_1024x27_4sub2,
&_huff_book_line_1024x27_4sub3, &_huff_book_line_1024x27_4sub3,
}; };
static static_codebook *_floor_2048x27_books[]={ static const static_codebook*const _floor_2048x27_books[]={
&_huff_book_line_2048x27_class1, &_huff_book_line_2048x27_class1,
&_huff_book_line_2048x27_class2, &_huff_book_line_2048x27_class2,
&_huff_book_line_2048x27_class3, &_huff_book_line_2048x27_class3,
@ -129,7 +129,7 @@ static static_codebook *_floor_2048x27_books[]={
&_huff_book_line_2048x27_4sub3, &_huff_book_line_2048x27_4sub3,
}; };
static static_codebook *_floor_512x17_books[]={ static const static_codebook*const _floor_512x17_books[]={
&_huff_book_line_512x17_class1, &_huff_book_line_512x17_class1,
&_huff_book_line_512x17_class2, &_huff_book_line_512x17_class2,
&_huff_book_line_512x17_class3, &_huff_book_line_512x17_class3,
@ -145,7 +145,11 @@ static static_codebook *_floor_512x17_books[]={
&_huff_book_line_512x17_3sub3, &_huff_book_line_512x17_3sub3,
}; };
static static_codebook **_floor_books[10]={ static const static_codebook*const _floor_Xx0_books[]={
0
};
static const static_codebook*const *const _floor_books[11]={
_floor_128x4_books, _floor_128x4_books,
_floor_256x4_books, _floor_256x4_books,
_floor_128x7_books, _floor_128x7_books,
@ -156,93 +160,101 @@ static static_codebook **_floor_books[10]={
_floor_1024x27_books, _floor_1024x27_books,
_floor_2048x27_books, _floor_2048x27_books,
_floor_512x17_books, _floor_512x17_books,
_floor_Xx0_books,
}; };
static vorbis_info_floor1 _floor[10]={ static const vorbis_info_floor1 _floor[11]={
/* 128 x 4 */ /* 0: 128 x 4 */
{ {
1,{0},{4},{2},{0}, 1,{0},{4},{2},{0},
{{1,2,3,4}}, {{1,2,3,4}},
4,{0,128, 33,8,16,70}, 4,{0,128, 33,8,16,70},
60,30,500, 1.,18., -1 60,30,500, 1.,18., 128
}, },
/* 256 x 4 */ /* 1: 256 x 4 */
{ {
1,{0},{4},{2},{0}, 1,{0},{4},{2},{0},
{{1,2,3,4}}, {{1,2,3,4}},
4,{0,256, 66,16,32,140}, 4,{0,256, 66,16,32,140},
60,30,500, 1.,18., -1 60,30,500, 1.,18., 256
}, },
/* 128 x 7 */ /* 2: 128 x 7 */
{ {
2,{0,1},{3,4},{2,2},{0,1}, 2,{0,1},{3,4},{2,2},{0,1},
{{-1,2,3,4},{-1,5,6,7}}, {{-1,2,3,4},{-1,5,6,7}},
4,{0,128, 14,4,58, 2,8,28,90}, 4,{0,128, 14,4,58, 2,8,28,90},
60,30,500, 1.,18., -1 60,30,500, 1.,18., 128
}, },
/* 256 x 7 */ /* 3: 256 x 7 */
{ {
2,{0,1},{3,4},{2,2},{0,1}, 2,{0,1},{3,4},{2,2},{0,1},
{{-1,2,3,4},{-1,5,6,7}}, {{-1,2,3,4},{-1,5,6,7}},
4,{0,256, 28,8,116, 4,16,56,180}, 4,{0,256, 28,8,116, 4,16,56,180},
60,30,500, 1.,18., -1 60,30,500, 1.,18., 256
}, },
/* 128 x 11 */ /* 4: 128 x 11 */
{ {
4,{0,1,2,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, 4,{0,1,2,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2},
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, {{3},{4,5},{-1,6,7,8},{-1,9,10,11}},
2,{0,128, 8,33, 4,16,70, 2,6,12, 23,46,90}, 2,{0,128, 8,33, 4,16,70, 2,6,12, 23,46,90},
60,30,500, 1,18., -1 60,30,500, 1,18., 128
}, },
/* 128 x 17 */ /* 5: 128 x 17 */
{ {
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, 6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2},
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, {{3},{4,5},{-1,6,7,8},{-1,9,10,11}},
2,{0,128, 12,46, 4,8,16, 23,33,70, 2,6,10, 14,19,28, 39,58,90}, 2,{0,128, 12,46, 4,8,16, 23,33,70, 2,6,10, 14,19,28, 39,58,90},
60,30,500, 1,18., -1 60,30,500, 1,18., 128
}, },
/* 256 x 4 (low bitrate version) */ /* 6: 256 x 4 (low bitrate version) */
{ {
1,{0},{4},{2},{0}, 1,{0},{4},{2},{0},
{{1,2,3,4}}, {{1,2,3,4}},
4,{0,256, 66,16,32,140}, 4,{0,256, 66,16,32,140},
60,30,500, 1.,18., -1 60,30,500, 1.,18., 256
}, },
/* 1024 x 27 */ /* 7: 1024 x 27 */
{ {
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, 8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3},
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, {{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}},
2,{0,1024, 93,23,372, 6,46,186,750, 14,33,65, 130,260,556, 2,{0,1024, 93,23,372, 6,46,186,750, 14,33,65, 130,260,556,
3,10,18,28, 39,55,79,111, 158,220,312, 464,650,850}, 3,10,18,28, 39,55,79,111, 158,220,312, 464,650,850},
60,30,500, 3,18., -1 /* lowpass */ 60,30,500, 3,18., 1024
}, },
/* 2048 x 27 */ /* 8: 2048 x 27 */
{ {
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, 8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3},
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, {{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}},
2,{0,2048, 186,46,744, 12,92,372,1500, 28,66,130, 260,520,1112, 2,{0,2048, 186,46,744, 12,92,372,1500, 28,66,130, 260,520,1112,
6,20,36,56, 78,110,158,222, 316,440,624, 928,1300,1700}, 6,20,36,56, 78,110,158,222, 316,440,624, 928,1300,1700},
60,30,500, 3,18., -1 /* lowpass */ 60,30,500, 3,18., 2048
}, },
/* 512 x 17 */ /* 9: 512 x 17 */
{ {
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, 6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2},
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, {{3},{4,5},{-1,6,7,8},{-1,9,10,11}},
2,{0,512, 46,186, 16,33,65, 93,130,278, 2,{0,512, 46,186, 16,33,65, 93,130,278,
7,23,39, 55,79,110, 156,232,360}, 7,23,39, 55,79,110, 156,232,360},
60,30,500, 1,18., -1 /* lowpass! */ 60,30,500, 1,18., 512
},
/* 10: X x 0 (LFE floor; edge posts only) */
{
0,{0}, {0},{0},{-1},
{{-1}},
2,{0,12},
60,30,500, 1.,18., 10
}, },
}; };

View file

@ -5,25 +5,25 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 11kHz settings function: 11kHz settings
last mod: $Id: psych_11.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: psych_11.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
static double _psy_lowpass_11[3]={4.5,5.5,30.,}; static const double _psy_lowpass_11[3]={4.5,5.5,30.,};
static att3 _psy_tone_masteratt_11[3]={ static const att3 _psy_tone_masteratt_11[3]={
{{ 30, 25, 12}, 0, 0}, /* 0 */ {{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 30, 25, 12}, 0, 0}, /* 0 */ {{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 20, 0, -14}, 0, 0}, /* 0 */ {{ 20, 0, -14}, 0, 0}, /* 0 */
}; };
static vp_adjblock _vp_tonemask_adj_11[3]={ static const vp_adjblock _vp_tonemask_adj_11[3]={
/* adjust for mode zero */ /* adjust for mode zero */
/* 63 125 250 500 1 2 4 8 16 */ /* 63 125 250 500 1 2 4 8 16 */
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 2, 0,99,99,99}}, /* 0 */ {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 2, 0,99,99,99}}, /* 0 */
@ -32,7 +32,7 @@ static vp_adjblock _vp_tonemask_adj_11[3]={
}; };
static noise3 _psy_noisebias_11[3]={ static const noise3 _psy_noisebias_11[3]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99},
{-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 4, 5, 5, 10, 99, 99, 99}, {-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 4, 5, 5, 10, 99, 99, 99},
@ -47,5 +47,5 @@ static noise3 _psy_noisebias_11[3]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}},
}; };
static double _noise_thresh_11[3]={ .3,.5,.5 }; static const double _noise_thresh_11[3]={ .3,.5,.5 };

View file

@ -5,18 +5,18 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 16kHz settings function: 16kHz settings
last mod: $Id: psych_16.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: psych_16.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
/* stereo mode by base quality level */ /* stereo mode by base quality level */
static adj_stereo _psy_stereo_modes_16[4]={ static const adj_stereo _psy_stereo_modes_16[4]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, {{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, { 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
@ -36,16 +36,16 @@ static adj_stereo _psy_stereo_modes_16[4]={
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
}; };
static double _psy_lowpass_16[4]={6.5,8,30.,99.}; static const double _psy_lowpass_16[4]={6.5,8,30.,99.};
static att3 _psy_tone_masteratt_16[4]={ static const att3 _psy_tone_masteratt_16[4]={
{{ 30, 25, 12}, 0, 0}, /* 0 */ {{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 25, 22, 12}, 0, 0}, /* 0 */ {{ 25, 22, 12}, 0, 0}, /* 0 */
{{ 20, 12, 0}, 0, 0}, /* 0 */ {{ 20, 12, 0}, 0, 0}, /* 0 */
{{ 15, 0, -14}, 0, 0}, /* 0 */ {{ 15, 0, -14}, 0, 0}, /* 0 */
}; };
static vp_adjblock _vp_tonemask_adj_16[4]={ static const vp_adjblock _vp_tonemask_adj_16[4]={
/* adjust for mode zero */ /* adjust for mode zero */
/* 63 125 250 500 1 2 4 8 16 */ /* 63 125 250 500 1 2 4 8 16 */
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */ {{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */
@ -55,7 +55,7 @@ static vp_adjblock _vp_tonemask_adj_16[4]={
}; };
static noise3 _psy_noisebias_16_short[4]={ static const noise3 _psy_noisebias_16_short[4]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, {{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20},
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, {-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15},
@ -74,7 +74,7 @@ static noise3 _psy_noisebias_16_short[4]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}},
}; };
static noise3 _psy_noisebias_16_impulse[4]={ static const noise3 _psy_noisebias_16_impulse[4]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, {{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20},
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, {-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15},
@ -93,7 +93,7 @@ static noise3 _psy_noisebias_16_impulse[4]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}},
}; };
static noise3 _psy_noisebias_16[4]={ static const noise3 _psy_noisebias_16[4]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 8, 8, 10, 10, 10, 14, 20}, {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 8, 8, 10, 10, 10, 14, 20},
{-10,-10,-10,-10,-10, -5, -2, -2, 0, 0, 0, 4, 5, 6, 8, 8, 15}, {-10,-10,-10,-10,-10, -5, -2, -2, 0, 0, 0, 4, 5, 6, 8, 8, 15},
@ -112,25 +112,22 @@ static noise3 _psy_noisebias_16[4]={
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, {-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}},
}; };
static noiseguard _psy_noiseguards_16[4]={ static const noiseguard _psy_noiseguards_16[4]={
{10,10,-1}, {10,10,-1},
{10,10,-1}, {10,10,-1},
{20,20,-1}, {20,20,-1},
{20,20,-1}, {20,20,-1},
}; };
static double _noise_thresh_16[4]={ .3,.5,.5,.5 }; static const double _noise_thresh_16[4]={ .3,.5,.5,.5 };
static int _noise_start_16[3]={ 256,256,9999 }; static const int _noise_start_16[3]={ 256,256,9999 };
static int _noise_part_16[4]={ 8,8,8,8 }; static const int _noise_part_16[4]={ 8,8,8,8 };
static int _psy_ath_floater_16[4]={ static const int _psy_ath_floater_16[4]={
-100,-100,-100,-105, -100,-100,-100,-105,
}; };
static int _psy_ath_abs_16[4]={ static const int _psy_ath_abs_16[4]={
-130,-130,-130,-140, -130,-130,-130,-140,
}; };

View file

@ -5,20 +5,20 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: key psychoacoustic settings for 44.1/48kHz function: key psychoacoustic settings for 44.1/48kHz
last mod: $Id: psych_44.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: psych_44.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
/* preecho trigger settings *****************************************/ /* preecho trigger settings *****************************************/
static vorbis_info_psy_global _psy_global_44[5]={ static const vorbis_info_psy_global _psy_global_44[5]={
{8, /* lines per eighth octave */ {8, /* lines per eighth octave */
{20.f,14.f,12.f,12.f,12.f,12.f,12.f}, {20.f,14.f,12.f,12.f,12.f,12.f,12.f},
@ -53,7 +53,7 @@ static vorbis_info_psy_global _psy_global_44[5]={
}; };
/* noise compander lookups * low, mid, high quality ****************/ /* noise compander lookups * low, mid, high quality ****************/
static compandblock _psy_compand_44[6]={ static const compandblock _psy_compand_44[6]={
/* sub-mode Z short */ /* sub-mode Z short */
{{ {{
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */
@ -106,7 +106,7 @@ static compandblock _psy_compand_44[6]={
/* tonal masking curve level adjustments *************************/ /* tonal masking curve level adjustments *************************/
static vp_adjblock _vp_tonemask_adj_longblock[12]={ static const vp_adjblock _vp_tonemask_adj_longblock[12]={
/* 63 125 250 500 1 2 4 8 16 */ /* 63 125 250 500 1 2 4 8 16 */
@ -146,7 +146,7 @@ static vp_adjblock _vp_tonemask_adj_longblock[12]={
{{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 10 */ {{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 10 */
}; };
static vp_adjblock _vp_tonemask_adj_otherblock[12]={ static const vp_adjblock _vp_tonemask_adj_otherblock[12]={
/* 63 125 250 500 1 2 4 8 16 */ /* 63 125 250 500 1 2 4 8 16 */
{{ -3, -8,-13,-15,-10,-10, -9, -9, -9, -9, -9, 1, 1, 1, 1, 1, 1}}, /* -1 */ {{ -3, -8,-13,-15,-10,-10, -9, -9, -9, -9, -9, 1, 1, 1, 1, 1, 1}}, /* -1 */
@ -186,7 +186,7 @@ static vp_adjblock _vp_tonemask_adj_otherblock[12]={
}; };
/* noise bias (transition block) */ /* noise bias (transition block) */
static noise3 _psy_noisebias_trans[12]={ static const noise3 _psy_noisebias_trans[12]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */ /* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20},
@ -269,7 +269,7 @@ static noise3 _psy_noisebias_trans[12]={
}; };
/* noise bias (long block) */ /* noise bias (long block) */
static noise3 _psy_noisebias_long[12]={ static const noise3 _psy_noisebias_long[12]={
/*63 125 250 500 1k 2k 4k 8k 16k*/ /*63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */ /* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 0, 6, 6, 6, 6, 10, 10, 12, 20}, {{{-10,-10,-10,-10,-10, -4, 0, 0, 0, 6, 6, 6, 6, 10, 10, 12, 20},
@ -344,7 +344,7 @@ static noise3 _psy_noisebias_long[12]={
}; };
/* noise bias (impulse block) */ /* noise bias (impulse block) */
static noise3 _psy_noisebias_impulse[12]={ static const noise3 _psy_noisebias_impulse[12]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */ /* -1 */
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, {{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20},
@ -413,7 +413,7 @@ static noise3 _psy_noisebias_impulse[12]={
}; };
/* noise bias (padding block) */ /* noise bias (padding block) */
static noise3 _psy_noisebias_padding[12]={ static const noise3 _psy_noisebias_padding[12]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
/* -1 */ /* -1 */
@ -471,24 +471,24 @@ static noise3 _psy_noisebias_padding[12]={
}; };
static noiseguard _psy_noiseguards_44[4]={ static const noiseguard _psy_noiseguards_44[4]={
{3,3,15}, {3,3,15},
{3,3,15}, {3,3,15},
{10,10,100}, {10,10,100},
{10,10,100}, {10,10,100},
}; };
static int _psy_tone_suppress[12]={ static const int _psy_tone_suppress[12]={
-20,-20,-20,-20,-20,-24,-30,-40,-40,-45,-45,-45, -20,-20,-20,-20,-20,-24,-30,-40,-40,-45,-45,-45,
}; };
static int _psy_tone_0dB[12]={ static const int _psy_tone_0dB[12]={
90,90,95,95,95,95,105,105,105,105,105,105, 90,90,95,95,95,95,105,105,105,105,105,105,
}; };
static int _psy_noise_suppress[12]={ static const int _psy_noise_suppress[12]={
-20,-20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45, -20,-20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45,
}; };
static vorbis_info_psy _psy_info_template={ static const vorbis_info_psy _psy_info_template={
/* blockflag */ /* blockflag */
-1, -1,
/* ath_adjatt, ath_maxatt */ /* ath_adjatt, ath_maxatt */
@ -500,16 +500,16 @@ static vorbis_info_psy _psy_info_template={
1, -0.f, .5f, .5f, 0,0,0, 1, -0.f, .5f, .5f, 0,0,0,
/* noiseoffset*3, noisecompand, max_curve_dB */ /* noiseoffset*3, noisecompand, max_curve_dB */
{{-1},{-1},{-1}},{-1},105.f, {{-1},{-1},{-1}},{-1},105.f,
/* noise normalization - channel_p, point_p, start, partition, thresh. */ /* noise normalization - noise_p, start, partition, thresh. */
0,0,-1,-1,0., 0,-1,-1,0.,
}; };
/* ath ****************/ /* ath ****************/
static int _psy_ath_floater[12]={ static const int _psy_ath_floater[12]={
-100,-100,-100,-100,-100,-100,-105,-105,-105,-105,-110,-120, -100,-100,-100,-100,-100,-100,-105,-105,-105,-105,-110,-120,
}; };
static int _psy_ath_abs[12]={ static const int _psy_ath_abs[12]={
-130,-130,-130,-130,-140,-140,-140,-140,-140,-140,-140,-150, -130,-130,-130,-130,-140,-140,-140,-140,-140,-140,-140,-150,
}; };
@ -522,7 +522,7 @@ static int _psy_ath_abs[12]={
/* various stereo possibilities */ /* various stereo possibilities */
/* stereo mode by base quality level */ /* stereo mode by base quality level */
static adj_stereo _psy_stereo_modes_44[12]={ static const adj_stereo _psy_stereo_modes_44[12]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -1 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -1 */
{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0}, {{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3}, { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3},
@ -530,10 +530,6 @@ static adj_stereo _psy_stereo_modes_44[12]={
{ 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}}, { 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 */
/*{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0},
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3},
{ 1, 2, 3, 4, 5, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8},
{ 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0}, {{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0},
{ 8, 8, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3}, { 8, 8, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3},
{ 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 8, 8}, { 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 8, 8},
@ -548,10 +544,6 @@ static adj_stereo _psy_stereo_modes_44[12]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 */
/* {{ 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 0, 0, 0, 0, 0},
{ 8, 8, 8, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1},
{ 3, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, */
{{ 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0}, {{ 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0},
{ 8, 8, 6, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 2, 1}, { 8, 8, 6, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 2, 1},
{ 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8}, { 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8},
@ -567,37 +559,21 @@ static adj_stereo _psy_stereo_modes_44[12]={
{ 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10}, { 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 */
/* {{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0},
{ 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0}, { 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0},
{ 6, 7, 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12}, { 6, 7, 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 */
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, */
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, { 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 */
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, { 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 8 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 8 */
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, { 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
@ -615,7 +591,7 @@ static adj_stereo _psy_stereo_modes_44[12]={
}; };
/* tone master attenuation by base quality mode and bitrate tweak */ /* tone master attenuation by base quality mode and bitrate tweak */
static att3 _psy_tone_masteratt_44[12]={ static const att3 _psy_tone_masteratt_44[12]={
{{ 35, 21, 9}, 0, 0}, /* -1 */ {{ 35, 21, 9}, 0, 0}, /* -1 */
{{ 30, 20, 8}, -2, 1.25}, /* 0 */ {{ 30, 20, 8}, -2, 1.25}, /* 0 */
/* {{ 25, 14, 4}, 0, 0}, *//* 1 */ /* {{ 25, 14, 4}, 0, 0}, *//* 1 */
@ -633,34 +609,34 @@ static att3 _psy_tone_masteratt_44[12]={
}; };
/* lowpass by mode **************/ /* lowpass by mode **************/
static double _psy_lowpass_44[12]={ static const double _psy_lowpass_44[12]={
/* 15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999. */ /* 15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999. */
13.9,15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999. 13.9,15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999.
}; };
/* noise normalization **********/ /* noise normalization **********/
static int _noise_start_short_44[11]={ static const int _noise_start_short_44[11]={
/* 16,16,16,16,32,32,9999,9999,9999,9999 */ /* 16,16,16,16,32,32,9999,9999,9999,9999 */
32,16,16,16,32,9999,9999,9999,9999,9999,9999 32,16,16,16,32,9999,9999,9999,9999,9999,9999
}; };
static int _noise_start_long_44[11]={ static const int _noise_start_long_44[11]={
/* 128,128,128,256,512,512,9999,9999,9999,9999 */ /* 128,128,128,256,512,512,9999,9999,9999,9999 */
256,128,128,256,512,9999,9999,9999,9999,9999,9999 256,128,128,256,512,9999,9999,9999,9999,9999,9999
}; };
static int _noise_part_short_44[11]={ static const int _noise_part_short_44[11]={
8,8,8,8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8,8,8,8
}; };
static int _noise_part_long_44[11]={ static const int _noise_part_long_44[11]={
32,32,32,32,32,32,32,32,32,32,32 32,32,32,32,32,32,32,32,32,32,32
}; };
static double _noise_thresh_44[11]={ static const double _noise_thresh_44[11]={
/* .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999., */ /* .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999., */
.2,.2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999., .2,.2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999.,
}; };
static double _noise_thresh_5only[2]={ static const double _noise_thresh_5only[2]={
.5,.5, .5,.5,
}; };

View file

@ -5,23 +5,23 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 8kHz psychoacoustic settings function: 8kHz psychoacoustic settings
last mod: $Id: psych_8.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: psych_8.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
static att3 _psy_tone_masteratt_8[3]={ static const att3 _psy_tone_masteratt_8[3]={
{{ 32, 25, 12}, 0, 0}, /* 0 */ {{ 32, 25, 12}, 0, 0}, /* 0 */
{{ 30, 25, 12}, 0, 0}, /* 0 */ {{ 30, 25, 12}, 0, 0}, /* 0 */
{{ 20, 0, -14}, 0, 0}, /* 0 */ {{ 20, 0, -14}, 0, 0}, /* 0 */
}; };
static vp_adjblock _vp_tonemask_adj_8[3]={ static const vp_adjblock _vp_tonemask_adj_8[3]={
/* adjust for mode zero */ /* adjust for mode zero */
/* 63 125 250 500 1 2 4 8 16 */ /* 63 125 250 500 1 2 4 8 16 */
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ {{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */
@ -30,7 +30,7 @@ static vp_adjblock _vp_tonemask_adj_8[3]={
}; };
static noise3 _psy_noisebias_8[3]={ static const noise3 _psy_noisebias_8[3]={
/* 63 125 250 500 1k 2k 4k 8k 16k*/ /* 63 125 250 500 1k 2k 4k 8k 16k*/
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, {{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99},
{-10,-10,-10,-10, -5, -5, -5, 0, 0, 4, 4, 4, 4, 4, 99, 99, 99}, {-10,-10,-10,-10, -5, -5, -5, 0, 0, 4, 4, 4, 4, 4, 99, 99, 99},
@ -46,7 +46,7 @@ static noise3 _psy_noisebias_8[3]={
}; };
/* stereo mode by base quality level */ /* stereo mode by base quality level */
static adj_stereo _psy_stereo_modes_8[3]={ static const adj_stereo _psy_stereo_modes_8[3]={
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, {{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, { 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
@ -62,12 +62,12 @@ static adj_stereo _psy_stereo_modes_8[3]={
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, { 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},
}; };
static noiseguard _psy_noiseguards_8[2]={ static const noiseguard _psy_noiseguards_8[2]={
{10,10,-1}, {10,10,-1},
{10,10,-1}, {10,10,-1},
}; };
static compandblock _psy_compand_8[2]={ static const compandblock _psy_compand_8[2]={
{{ {{
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ 0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */
8, 8, 9, 9,10,10,11, 11, /* 15dB */ 8, 8, 9, 9,10,10,11, 11, /* 15dB */
@ -84,19 +84,18 @@ static compandblock _psy_compand_8[2]={
}}, }},
}; };
static double _psy_lowpass_8[3]={3.,4.,4.}; static const double _psy_lowpass_8[3]={3.,4.,4.};
static int _noise_start_8[2]={ static const int _noise_start_8[2]={
64,64, 64,64,
}; };
static int _noise_part_8[2]={ static const int _noise_part_8[2]={
8,8, 8,8,
}; };
static int _psy_ath_floater_8[3]={ static const int _psy_ath_floater_8[3]={
-100,-100,-105, -100,-100,-105,
}; };
static int _psy_ath_abs_8[3]={ static const int _psy_ath_abs_8[3]={
-130,-130,-140, -130,-130,-140,
}; };

View file

@ -1,23 +1,23 @@
/******************************************************************** /********************************************************************
* * * *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * * This FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: toplevel residue templates 16/22kHz function: toplevel residue templates 16/22kHz
last mod: $Id: residue_16.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: residue_16.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
/***** residue backends *********************************************/ /***** residue backends *********************************************/
static static_bookblock _resbook_16s_0={ static const static_bookblock _resbook_16s_0={
{ {
{0}, {0},
{0,0,&_16c0_s_p1_0}, {0,0,&_16c0_s_p1_0},
@ -31,7 +31,7 @@ static static_bookblock _resbook_16s_0={
{&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2} {&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2}
} }
}; };
static static_bookblock _resbook_16s_1={ static const static_bookblock _resbook_16s_1={
{ {
{0}, {0},
{0,0,&_16c1_s_p1_0}, {0,0,&_16c1_s_p1_0},
@ -45,7 +45,7 @@ static static_bookblock _resbook_16s_1={
{&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2} {&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2}
} }
}; };
static static_bookblock _resbook_16s_2={ static const static_bookblock _resbook_16s_2={
{ {
{0}, {0},
{0,0,&_16c2_s_p1_0}, {0,0,&_16c2_s_p1_0},
@ -60,37 +60,37 @@ static static_bookblock _resbook_16s_2={
} }
}; };
static vorbis_residue_template _res_16s_0[]={ static const vorbis_residue_template _res_16s_0[]={
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__16c0_s_single,&_huff_book__16c0_s_single, &_huff_book__16c0_s_single,&_huff_book__16c0_s_single,
&_resbook_16s_0,&_resbook_16s_0}, &_resbook_16s_0,&_resbook_16s_0},
}; };
static vorbis_residue_template _res_16s_1[]={ static const vorbis_residue_template _res_16s_1[]={
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__16c1_s_short,&_huff_book__16c1_s_short, &_huff_book__16c1_s_short,&_huff_book__16c1_s_short,
&_resbook_16s_1,&_resbook_16s_1}, &_resbook_16s_1,&_resbook_16s_1},
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__16c1_s_long,&_huff_book__16c1_s_long, &_huff_book__16c1_s_long,&_huff_book__16c1_s_long,
&_resbook_16s_1,&_resbook_16s_1} &_resbook_16s_1,&_resbook_16s_1}
}; };
static vorbis_residue_template _res_16s_2[]={ static const vorbis_residue_template _res_16s_2[]={
{2,0, &_residue_44_high, {2,0,32, &_residue_44_high,
&_huff_book__16c2_s_short,&_huff_book__16c2_s_short, &_huff_book__16c2_s_short,&_huff_book__16c2_s_short,
&_resbook_16s_2,&_resbook_16s_2}, &_resbook_16s_2,&_resbook_16s_2},
{2,0, &_residue_44_high, {2,0,32, &_residue_44_high,
&_huff_book__16c2_s_long,&_huff_book__16c2_s_long, &_huff_book__16c2_s_long,&_huff_book__16c2_s_long,
&_resbook_16s_2,&_resbook_16s_2} &_resbook_16s_2,&_resbook_16s_2}
}; };
static vorbis_mapping_template _mapres_template_16_stereo[3]={ static const vorbis_mapping_template _mapres_template_16_stereo[3]={
{ _map_nominal, _res_16s_0 }, /* 0 */ { _map_nominal, _res_16s_0 }, /* 0 */
{ _map_nominal, _res_16s_1 }, /* 1 */ { _map_nominal, _res_16s_1 }, /* 1 */
{ _map_nominal, _res_16s_2 }, /* 2 */ { _map_nominal, _res_16s_2 }, /* 2 */
}; };
static static_bookblock _resbook_16u_0={ static const static_bookblock _resbook_16u_0={
{ {
{0}, {0},
{0,0,&_16u0__p1_0}, {0,0,&_16u0__p1_0},
@ -102,7 +102,7 @@ static static_bookblock _resbook_16u_0={
{&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2} {&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2}
} }
}; };
static static_bookblock _resbook_16u_1={ static const static_bookblock _resbook_16u_1={
{ {
{0}, {0},
{0,0,&_16u1__p1_0}, {0,0,&_16u1__p1_0},
@ -116,7 +116,7 @@ static static_bookblock _resbook_16u_1={
{&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2} {&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2}
} }
}; };
static static_bookblock _resbook_16u_2={ static const static_bookblock _resbook_16u_2={
{ {
{0}, {0},
{0,0,&_16u2_p1_0}, {0,0,&_16u2_p1_0},
@ -131,32 +131,32 @@ static static_bookblock _resbook_16u_2={
} }
}; };
static vorbis_residue_template _res_16u_0[]={ static const vorbis_residue_template _res_16u_0[]={
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__16u0__single,&_huff_book__16u0__single, &_huff_book__16u0__single,&_huff_book__16u0__single,
&_resbook_16u_0,&_resbook_16u_0}, &_resbook_16u_0,&_resbook_16u_0},
}; };
static vorbis_residue_template _res_16u_1[]={ static const vorbis_residue_template _res_16u_1[]={
{1,0, &_residue_44_mid_un, {1,0,32, &_residue_44_mid_un,
&_huff_book__16u1__short,&_huff_book__16u1__short, &_huff_book__16u1__short,&_huff_book__16u1__short,
&_resbook_16u_1,&_resbook_16u_1}, &_resbook_16u_1,&_resbook_16u_1},
{1,0, &_residue_44_mid_un, {1,0,32, &_residue_44_mid_un,
&_huff_book__16u1__long,&_huff_book__16u1__long, &_huff_book__16u1__long,&_huff_book__16u1__long,
&_resbook_16u_1,&_resbook_16u_1} &_resbook_16u_1,&_resbook_16u_1}
}; };
static vorbis_residue_template _res_16u_2[]={ static const vorbis_residue_template _res_16u_2[]={
{1,0, &_residue_44_hi_un, {1,0,32, &_residue_44_hi_un,
&_huff_book__16u2__short,&_huff_book__16u2__short, &_huff_book__16u2__short,&_huff_book__16u2__short,
&_resbook_16u_2,&_resbook_16u_2}, &_resbook_16u_2,&_resbook_16u_2},
{1,0, &_residue_44_hi_un, {1,0,32, &_residue_44_hi_un,
&_huff_book__16u2__long,&_huff_book__16u2__long, &_huff_book__16u2__long,&_huff_book__16u2__long,
&_resbook_16u_2,&_resbook_16u_2} &_resbook_16u_2,&_resbook_16u_2}
}; };
static vorbis_mapping_template _mapres_template_16_uncoupled[3]={ static const vorbis_mapping_template _mapres_template_16_uncoupled[3]={
{ _map_nominal_u, _res_16u_0 }, /* 0 */ { _map_nominal_u, _res_16u_0 }, /* 0 */
{ _map_nominal_u, _res_16u_1 }, /* 1 */ { _map_nominal_u, _res_16u_1 }, /* 1 */
{ _map_nominal_u, _res_16u_2 }, /* 2 */ { _map_nominal_u, _res_16u_2 }, /* 2 */

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: toplevel residue templates for 32/44.1/48kHz function: toplevel residue templates for 32/44.1/48kHz
last mod: $Id: residue_44.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: residue_44.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
@ -21,34 +21,34 @@
/***** residue backends *********************************************/ /***** residue backends *********************************************/
static vorbis_info_residue0 _residue_44_low={ static const vorbis_info_residue0 _residue_44_low={
0,-1, -1, 9,-1, 0,-1, -1, 9,-1,-1,
/* 0 1 2 3 4 5 6 7 */ /* 0 1 2 3 4 5 6 7 */
{0}, {0},
{-1}, {-1},
{ .5, 1.5, 2.5, 2.5, 4.5, 8.5, 16.5, 32.5}, { 0, 1, 2, 2, 4, 8, 16, 32},
{ .5, .5, .5, 999., 4.5, 8.5, 16.5, 32.5}, { 0, 0, 0,999, 4, 8, 16, 32},
}; };
static vorbis_info_residue0 _residue_44_mid={ static const vorbis_info_residue0 _residue_44_mid={
0,-1, -1, 10,-1, 0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 */ /* 0 1 2 3 4 5 6 7 8 */
{0}, {0},
{-1}, {-1},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 8.5, 16.5, 32.5}, { 0, 1, 1, 2, 2, 4, 8, 16, 32},
{ .5, .5, 999., .5, 999., 4.5, 8.5, 16.5, 32.5}, { 0, 0,999, 0,999, 4, 8, 16, 32},
}; };
static vorbis_info_residue0 _residue_44_high={ static const vorbis_info_residue0 _residue_44_high={
0,-1, -1, 10,-1, 0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 */ /* 0 1 2 3 4 5 6 7 8 */
{0}, {0},
{-1}, {-1},
{ .5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 71.5,157.5}, { 0, 1, 2, 4, 8, 16, 32, 71,157},
{ .5, 1.5, 2.5, 3.5, 4.5, 8.5, 16.5, 71.5,157.5}, { 0, 1, 2, 3, 4, 8, 16, 71,157},
}; };
static static_bookblock _resbook_44s_n1={ static const static_bookblock _resbook_44s_n1={
{ {
{0},{0,0,&_44cn1_s_p1_0},{0,0,&_44cn1_s_p2_0}, {0},{0,0,&_44cn1_s_p1_0},{0,0,&_44cn1_s_p2_0},
{0,0,&_44cn1_s_p3_0},{0,0,&_44cn1_s_p4_0},{0,0,&_44cn1_s_p5_0}, {0,0,&_44cn1_s_p3_0},{0,0,&_44cn1_s_p4_0},{0,0,&_44cn1_s_p5_0},
@ -56,7 +56,7 @@ static static_bookblock _resbook_44s_n1={
{&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2} {&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2}
} }
}; };
static static_bookblock _resbook_44sm_n1={ static const static_bookblock _resbook_44sm_n1={
{ {
{0},{0,0,&_44cn1_sm_p1_0},{0,0,&_44cn1_sm_p2_0}, {0},{0,0,&_44cn1_sm_p1_0},{0,0,&_44cn1_sm_p2_0},
{0,0,&_44cn1_sm_p3_0},{0,0,&_44cn1_sm_p4_0},{0,0,&_44cn1_sm_p5_0}, {0,0,&_44cn1_sm_p3_0},{0,0,&_44cn1_sm_p4_0},{0,0,&_44cn1_sm_p5_0},
@ -65,7 +65,7 @@ static static_bookblock _resbook_44sm_n1={
} }
}; };
static static_bookblock _resbook_44s_0={ static const static_bookblock _resbook_44s_0={
{ {
{0},{0,0,&_44c0_s_p1_0},{0,0,&_44c0_s_p2_0}, {0},{0,0,&_44c0_s_p1_0},{0,0,&_44c0_s_p2_0},
{0,0,&_44c0_s_p3_0},{0,0,&_44c0_s_p4_0},{0,0,&_44c0_s_p5_0}, {0,0,&_44c0_s_p3_0},{0,0,&_44c0_s_p4_0},{0,0,&_44c0_s_p5_0},
@ -73,7 +73,7 @@ static static_bookblock _resbook_44s_0={
{&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2} {&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2}
} }
}; };
static static_bookblock _resbook_44sm_0={ static const static_bookblock _resbook_44sm_0={
{ {
{0},{0,0,&_44c0_sm_p1_0},{0,0,&_44c0_sm_p2_0}, {0},{0,0,&_44c0_sm_p1_0},{0,0,&_44c0_sm_p2_0},
{0,0,&_44c0_sm_p3_0},{0,0,&_44c0_sm_p4_0},{0,0,&_44c0_sm_p5_0}, {0,0,&_44c0_sm_p3_0},{0,0,&_44c0_sm_p4_0},{0,0,&_44c0_sm_p5_0},
@ -82,7 +82,7 @@ static static_bookblock _resbook_44sm_0={
} }
}; };
static static_bookblock _resbook_44s_1={ static const static_bookblock _resbook_44s_1={
{ {
{0},{0,0,&_44c1_s_p1_0},{0,0,&_44c1_s_p2_0}, {0},{0,0,&_44c1_s_p1_0},{0,0,&_44c1_s_p2_0},
{0,0,&_44c1_s_p3_0},{0,0,&_44c1_s_p4_0},{0,0,&_44c1_s_p5_0}, {0,0,&_44c1_s_p3_0},{0,0,&_44c1_s_p4_0},{0,0,&_44c1_s_p5_0},
@ -90,7 +90,7 @@ static static_bookblock _resbook_44s_1={
{&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2} {&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2}
} }
}; };
static static_bookblock _resbook_44sm_1={ static const static_bookblock _resbook_44sm_1={
{ {
{0},{0,0,&_44c1_sm_p1_0},{0,0,&_44c1_sm_p2_0}, {0},{0,0,&_44c1_sm_p1_0},{0,0,&_44c1_sm_p2_0},
{0,0,&_44c1_sm_p3_0},{0,0,&_44c1_sm_p4_0},{0,0,&_44c1_sm_p5_0}, {0,0,&_44c1_sm_p3_0},{0,0,&_44c1_sm_p4_0},{0,0,&_44c1_sm_p5_0},
@ -99,7 +99,7 @@ static static_bookblock _resbook_44sm_1={
} }
}; };
static static_bookblock _resbook_44s_2={ static const static_bookblock _resbook_44s_2={
{ {
{0},{0,0,&_44c2_s_p1_0},{0,0,&_44c2_s_p2_0},{0,0,&_44c2_s_p3_0}, {0},{0,0,&_44c2_s_p1_0},{0,0,&_44c2_s_p2_0},{0,0,&_44c2_s_p3_0},
{0,0,&_44c2_s_p4_0},{0,0,&_44c2_s_p5_0},{0,0,&_44c2_s_p6_0}, {0,0,&_44c2_s_p4_0},{0,0,&_44c2_s_p5_0},{0,0,&_44c2_s_p6_0},
@ -107,7 +107,7 @@ static static_bookblock _resbook_44s_2={
{&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2} {&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_3={ static const static_bookblock _resbook_44s_3={
{ {
{0},{0,0,&_44c3_s_p1_0},{0,0,&_44c3_s_p2_0},{0,0,&_44c3_s_p3_0}, {0},{0,0,&_44c3_s_p1_0},{0,0,&_44c3_s_p2_0},{0,0,&_44c3_s_p3_0},
{0,0,&_44c3_s_p4_0},{0,0,&_44c3_s_p5_0},{0,0,&_44c3_s_p6_0}, {0,0,&_44c3_s_p4_0},{0,0,&_44c3_s_p5_0},{0,0,&_44c3_s_p6_0},
@ -115,7 +115,7 @@ static static_bookblock _resbook_44s_3={
{&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2} {&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_4={ static const static_bookblock _resbook_44s_4={
{ {
{0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0}, {0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0},
{0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0}, {0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0},
@ -123,7 +123,7 @@ static static_bookblock _resbook_44s_4={
{&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2} {&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_5={ static const static_bookblock _resbook_44s_5={
{ {
{0},{0,0,&_44c5_s_p1_0},{0,0,&_44c5_s_p2_0},{0,0,&_44c5_s_p3_0}, {0},{0,0,&_44c5_s_p1_0},{0,0,&_44c5_s_p2_0},{0,0,&_44c5_s_p3_0},
{0,0,&_44c5_s_p4_0},{0,0,&_44c5_s_p5_0},{0,0,&_44c5_s_p6_0}, {0,0,&_44c5_s_p4_0},{0,0,&_44c5_s_p5_0},{0,0,&_44c5_s_p6_0},
@ -131,7 +131,7 @@ static static_bookblock _resbook_44s_5={
{&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2} {&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_6={ static const static_bookblock _resbook_44s_6={
{ {
{0},{0,0,&_44c6_s_p1_0},{0,0,&_44c6_s_p2_0},{0,0,&_44c6_s_p3_0}, {0},{0,0,&_44c6_s_p1_0},{0,0,&_44c6_s_p2_0},{0,0,&_44c6_s_p3_0},
{0,0,&_44c6_s_p4_0}, {0,0,&_44c6_s_p4_0},
@ -142,7 +142,7 @@ static static_bookblock _resbook_44s_6={
{&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2} {&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_7={ static const static_bookblock _resbook_44s_7={
{ {
{0},{0,0,&_44c7_s_p1_0},{0,0,&_44c7_s_p2_0},{0,0,&_44c7_s_p3_0}, {0},{0,0,&_44c7_s_p1_0},{0,0,&_44c7_s_p2_0},{0,0,&_44c7_s_p3_0},
{0,0,&_44c7_s_p4_0}, {0,0,&_44c7_s_p4_0},
@ -153,7 +153,7 @@ static static_bookblock _resbook_44s_7={
{&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2} {&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_8={ static const static_bookblock _resbook_44s_8={
{ {
{0},{0,0,&_44c8_s_p1_0},{0,0,&_44c8_s_p2_0},{0,0,&_44c8_s_p3_0}, {0},{0,0,&_44c8_s_p1_0},{0,0,&_44c8_s_p2_0},{0,0,&_44c8_s_p3_0},
{0,0,&_44c8_s_p4_0}, {0,0,&_44c8_s_p4_0},
@ -164,7 +164,7 @@ static static_bookblock _resbook_44s_8={
{&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2} {&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2}
} }
}; };
static static_bookblock _resbook_44s_9={ static const static_bookblock _resbook_44s_9={
{ {
{0},{0,0,&_44c9_s_p1_0},{0,0,&_44c9_s_p2_0},{0,0,&_44c9_s_p3_0}, {0},{0,0,&_44c9_s_p1_0},{0,0,&_44c9_s_p2_0},{0,0,&_44c9_s_p3_0},
{0,0,&_44c9_s_p4_0}, {0,0,&_44c9_s_p4_0},
@ -176,108 +176,108 @@ static static_bookblock _resbook_44s_9={
} }
}; };
static vorbis_residue_template _res_44s_n1[]={ static const vorbis_residue_template _res_44s_n1[]={
{2,0, &_residue_44_low, {2,0,32, &_residue_44_low,
&_huff_book__44cn1_s_short,&_huff_book__44cn1_sm_short, &_huff_book__44cn1_s_short,&_huff_book__44cn1_sm_short,
&_resbook_44s_n1,&_resbook_44sm_n1}, &_resbook_44s_n1,&_resbook_44sm_n1},
{2,0, &_residue_44_low, {2,0,32, &_residue_44_low,
&_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long, &_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long,
&_resbook_44s_n1,&_resbook_44sm_n1} &_resbook_44s_n1,&_resbook_44sm_n1}
}; };
static vorbis_residue_template _res_44s_0[]={ static const vorbis_residue_template _res_44s_0[]={
{2,0, &_residue_44_low, {2,0,16, &_residue_44_low,
&_huff_book__44c0_s_short,&_huff_book__44c0_sm_short, &_huff_book__44c0_s_short,&_huff_book__44c0_sm_short,
&_resbook_44s_0,&_resbook_44sm_0}, &_resbook_44s_0,&_resbook_44sm_0},
{2,0, &_residue_44_low, {2,0,32, &_residue_44_low,
&_huff_book__44c0_s_long,&_huff_book__44c0_sm_long, &_huff_book__44c0_s_long,&_huff_book__44c0_sm_long,
&_resbook_44s_0,&_resbook_44sm_0} &_resbook_44s_0,&_resbook_44sm_0}
}; };
static vorbis_residue_template _res_44s_1[]={ static const vorbis_residue_template _res_44s_1[]={
{2,0, &_residue_44_low, {2,0,16, &_residue_44_low,
&_huff_book__44c1_s_short,&_huff_book__44c1_sm_short, &_huff_book__44c1_s_short,&_huff_book__44c1_sm_short,
&_resbook_44s_1,&_resbook_44sm_1}, &_resbook_44s_1,&_resbook_44sm_1},
{2,0, &_residue_44_low, {2,0,32, &_residue_44_low,
&_huff_book__44c1_s_long,&_huff_book__44c1_sm_long, &_huff_book__44c1_s_long,&_huff_book__44c1_sm_long,
&_resbook_44s_1,&_resbook_44sm_1} &_resbook_44s_1,&_resbook_44sm_1}
}; };
static vorbis_residue_template _res_44s_2[]={ static const vorbis_residue_template _res_44s_2[]={
{2,0, &_residue_44_mid, {2,0,16, &_residue_44_mid,
&_huff_book__44c2_s_short,&_huff_book__44c2_s_short, &_huff_book__44c2_s_short,&_huff_book__44c2_s_short,
&_resbook_44s_2,&_resbook_44s_2}, &_resbook_44s_2,&_resbook_44s_2},
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__44c2_s_long,&_huff_book__44c2_s_long, &_huff_book__44c2_s_long,&_huff_book__44c2_s_long,
&_resbook_44s_2,&_resbook_44s_2} &_resbook_44s_2,&_resbook_44s_2}
}; };
static vorbis_residue_template _res_44s_3[]={ static const vorbis_residue_template _res_44s_3[]={
{2,0, &_residue_44_mid, {2,0,16, &_residue_44_mid,
&_huff_book__44c3_s_short,&_huff_book__44c3_s_short, &_huff_book__44c3_s_short,&_huff_book__44c3_s_short,
&_resbook_44s_3,&_resbook_44s_3}, &_resbook_44s_3,&_resbook_44s_3},
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__44c3_s_long,&_huff_book__44c3_s_long, &_huff_book__44c3_s_long,&_huff_book__44c3_s_long,
&_resbook_44s_3,&_resbook_44s_3} &_resbook_44s_3,&_resbook_44s_3}
}; };
static vorbis_residue_template _res_44s_4[]={ static const vorbis_residue_template _res_44s_4[]={
{2,0, &_residue_44_mid, {2,0,16, &_residue_44_mid,
&_huff_book__44c4_s_short,&_huff_book__44c4_s_short, &_huff_book__44c4_s_short,&_huff_book__44c4_s_short,
&_resbook_44s_4,&_resbook_44s_4}, &_resbook_44s_4,&_resbook_44s_4},
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__44c4_s_long,&_huff_book__44c4_s_long, &_huff_book__44c4_s_long,&_huff_book__44c4_s_long,
&_resbook_44s_4,&_resbook_44s_4} &_resbook_44s_4,&_resbook_44s_4}
}; };
static vorbis_residue_template _res_44s_5[]={ static const vorbis_residue_template _res_44s_5[]={
{2,0, &_residue_44_mid, {2,0,16, &_residue_44_mid,
&_huff_book__44c5_s_short,&_huff_book__44c5_s_short, &_huff_book__44c5_s_short,&_huff_book__44c5_s_short,
&_resbook_44s_5,&_resbook_44s_5}, &_resbook_44s_5,&_resbook_44s_5},
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__44c5_s_long,&_huff_book__44c5_s_long, &_huff_book__44c5_s_long,&_huff_book__44c5_s_long,
&_resbook_44s_5,&_resbook_44s_5} &_resbook_44s_5,&_resbook_44s_5}
}; };
static vorbis_residue_template _res_44s_6[]={ static const vorbis_residue_template _res_44s_6[]={
{2,0, &_residue_44_high, {2,0,16, &_residue_44_high,
&_huff_book__44c6_s_short,&_huff_book__44c6_s_short, &_huff_book__44c6_s_short,&_huff_book__44c6_s_short,
&_resbook_44s_6,&_resbook_44s_6}, &_resbook_44s_6,&_resbook_44s_6},
{2,0, &_residue_44_high, {2,0,32, &_residue_44_high,
&_huff_book__44c6_s_long,&_huff_book__44c6_s_long, &_huff_book__44c6_s_long,&_huff_book__44c6_s_long,
&_resbook_44s_6,&_resbook_44s_6} &_resbook_44s_6,&_resbook_44s_6}
}; };
static vorbis_residue_template _res_44s_7[]={ static const vorbis_residue_template _res_44s_7[]={
{2,0, &_residue_44_high, {2,0,16, &_residue_44_high,
&_huff_book__44c7_s_short,&_huff_book__44c7_s_short, &_huff_book__44c7_s_short,&_huff_book__44c7_s_short,
&_resbook_44s_7,&_resbook_44s_7}, &_resbook_44s_7,&_resbook_44s_7},
{2,0, &_residue_44_high, {2,0,32, &_residue_44_high,
&_huff_book__44c7_s_long,&_huff_book__44c7_s_long, &_huff_book__44c7_s_long,&_huff_book__44c7_s_long,
&_resbook_44s_7,&_resbook_44s_7} &_resbook_44s_7,&_resbook_44s_7}
}; };
static vorbis_residue_template _res_44s_8[]={ static const vorbis_residue_template _res_44s_8[]={
{2,0, &_residue_44_high, {2,0,16, &_residue_44_high,
&_huff_book__44c8_s_short,&_huff_book__44c8_s_short, &_huff_book__44c8_s_short,&_huff_book__44c8_s_short,
&_resbook_44s_8,&_resbook_44s_8}, &_resbook_44s_8,&_resbook_44s_8},
{2,0, &_residue_44_high, {2,0,32, &_residue_44_high,
&_huff_book__44c8_s_long,&_huff_book__44c8_s_long, &_huff_book__44c8_s_long,&_huff_book__44c8_s_long,
&_resbook_44s_8,&_resbook_44s_8} &_resbook_44s_8,&_resbook_44s_8}
}; };
static vorbis_residue_template _res_44s_9[]={ static const vorbis_residue_template _res_44s_9[]={
{2,0, &_residue_44_high, {2,0,16, &_residue_44_high,
&_huff_book__44c9_s_short,&_huff_book__44c9_s_short, &_huff_book__44c9_s_short,&_huff_book__44c9_s_short,
&_resbook_44s_9,&_resbook_44s_9}, &_resbook_44s_9,&_resbook_44s_9},
{2,0, &_residue_44_high, {2,0,32, &_residue_44_high,
&_huff_book__44c9_s_long,&_huff_book__44c9_s_long, &_huff_book__44c9_s_long,&_huff_book__44c9_s_long,
&_resbook_44s_9,&_resbook_44s_9} &_resbook_44s_9,&_resbook_44s_9}
}; };
static vorbis_mapping_template _mapres_template_44_stereo[]={ static const vorbis_mapping_template _mapres_template_44_stereo[]={
{ _map_nominal, _res_44s_n1 }, /* -1 */ { _map_nominal, _res_44s_n1 }, /* -1 */
{ _map_nominal, _res_44s_0 }, /* 0 */ { _map_nominal, _res_44s_0 }, /* 0 */
{ _map_nominal, _res_44s_1 }, /* 1 */ { _map_nominal, _res_44s_1 }, /* 1 */
@ -290,5 +290,3 @@ static vorbis_mapping_template _mapres_template_44_stereo[]={
{ _map_nominal, _res_44s_8 }, /* 8 */ { _map_nominal, _res_44s_8 }, /* 8 */
{ _map_nominal, _res_44s_9 }, /* 9 */ { _map_nominal, _res_44s_9 }, /* 9 */
}; };

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: toplevel residue templates for 32/44.1/48kHz uncoupled function: toplevel residue templates for 32/44.1/48kHz uncoupled
last mod: $Id: residue_44u.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: residue_44u.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
@ -22,41 +22,41 @@
/***** residue backends *********************************************/ /***** residue backends *********************************************/
static vorbis_info_residue0 _residue_44_low_un={ static const vorbis_info_residue0 _residue_44_low_un={
0,-1, -1, 8,-1, 0,-1, -1, 8,-1,-1,
{0}, {0},
{-1}, {-1},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 28.5}, { 0, 1, 1, 2, 2, 4, 28},
{ -1, 25, -1, 45, -1, -1, -1} { -1, 25, -1, 45, -1, -1, -1}
}; };
static vorbis_info_residue0 _residue_44_mid_un={ static const vorbis_info_residue0 _residue_44_mid_un={
0,-1, -1, 10,-1, 0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 9 */ /* 0 1 2 3 4 5 6 7 8 9 */
{0}, {0},
{-1}, {-1},
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 4.5, 16.5, 60.5}, { 0, 1, 1, 2, 2, 4, 4, 16, 60},
{ -1, 30, -1, 50, -1, 80, -1, -1, -1} { -1, 30, -1, 50, -1, 80, -1, -1, -1}
}; };
static vorbis_info_residue0 _residue_44_hi_un={ static const vorbis_info_residue0 _residue_44_hi_un={
0,-1, -1, 10,-1, 0,-1, -1, 10,-1,-1,
/* 0 1 2 3 4 5 6 7 8 9 */ /* 0 1 2 3 4 5 6 7 8 9 */
{0}, {0},
{-1}, {-1},
{ .5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 71.5,157.5}, { 0, 1, 2, 4, 8, 16, 32, 71,157},
{ -1, -1, -1, -1, -1, -1, -1, -1, -1} { -1, -1, -1, -1, -1, -1, -1, -1, -1}
}; };
/* mapping conventions: /* mapping conventions:
only one submap (this would change for efficient 5.1 support for example)*/ only one submap (this would change for efficient 5.1 support for example)*/
/* Four psychoacoustic profiles are used, one for each blocktype */ /* Four psychoacoustic profiles are used, one for each blocktype */
static vorbis_info_mapping0 _map_nominal_u[2]={ static const vorbis_info_mapping0 _map_nominal_u[2]={
{1, {0,0}, {0}, {0}, 0,{0},{0}}, {1, {0,0,0,0,0,0}, {0}, {0}, 0,{0},{0}},
{1, {0,0}, {1}, {1}, 0,{0},{0}} {1, {0,0,0,0,0,0}, {1}, {1}, 0,{0},{0}}
}; };
static static_bookblock _resbook_44u_n1={ static const static_bookblock _resbook_44u_n1={
{ {
{0}, {0},
{0,0,&_44un1__p1_0}, {0,0,&_44un1__p1_0},
@ -68,7 +68,7 @@ static static_bookblock _resbook_44u_n1={
{&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2} {&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2}
} }
}; };
static static_bookblock _resbook_44u_0={ static const static_bookblock _resbook_44u_0={
{ {
{0}, {0},
{0,0,&_44u0__p1_0}, {0,0,&_44u0__p1_0},
@ -80,7 +80,7 @@ static static_bookblock _resbook_44u_0={
{&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2} {&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2}
} }
}; };
static static_bookblock _resbook_44u_1={ static const static_bookblock _resbook_44u_1={
{ {
{0}, {0},
{0,0,&_44u1__p1_0}, {0,0,&_44u1__p1_0},
@ -92,7 +92,7 @@ static static_bookblock _resbook_44u_1={
{&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2} {&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2}
} }
}; };
static static_bookblock _resbook_44u_2={ static const static_bookblock _resbook_44u_2={
{ {
{0}, {0},
{0,0,&_44u2__p1_0}, {0,0,&_44u2__p1_0},
@ -104,7 +104,7 @@ static static_bookblock _resbook_44u_2={
{&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2} {&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2}
} }
}; };
static static_bookblock _resbook_44u_3={ static const static_bookblock _resbook_44u_3={
{ {
{0}, {0},
{0,0,&_44u3__p1_0}, {0,0,&_44u3__p1_0},
@ -116,7 +116,7 @@ static static_bookblock _resbook_44u_3={
{&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2} {&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2}
} }
}; };
static static_bookblock _resbook_44u_4={ static const static_bookblock _resbook_44u_4={
{ {
{0}, {0},
{0,0,&_44u4__p1_0}, {0,0,&_44u4__p1_0},
@ -128,7 +128,7 @@ static static_bookblock _resbook_44u_4={
{&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2} {&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2}
} }
}; };
static static_bookblock _resbook_44u_5={ static const static_bookblock _resbook_44u_5={
{ {
{0}, {0},
{0,0,&_44u5__p1_0}, {0,0,&_44u5__p1_0},
@ -142,7 +142,7 @@ static static_bookblock _resbook_44u_5={
{&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2} {&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2}
} }
}; };
static static_bookblock _resbook_44u_6={ static const static_bookblock _resbook_44u_6={
{ {
{0}, {0},
{0,0,&_44u6__p1_0}, {0,0,&_44u6__p1_0},
@ -156,7 +156,7 @@ static static_bookblock _resbook_44u_6={
{&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2} {&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2}
} }
}; };
static static_bookblock _resbook_44u_7={ static const static_bookblock _resbook_44u_7={
{ {
{0}, {0},
{0,0,&_44u7__p1_0}, {0,0,&_44u7__p1_0},
@ -170,7 +170,7 @@ static static_bookblock _resbook_44u_7={
{&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2} {&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2}
} }
}; };
static static_bookblock _resbook_44u_8={ static const static_bookblock _resbook_44u_8={
{ {
{0}, {0},
{0,0,&_44u8_p1_0}, {0,0,&_44u8_p1_0},
@ -184,7 +184,7 @@ static static_bookblock _resbook_44u_8={
{&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2} {&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2}
} }
}; };
static static_bookblock _resbook_44u_9={ static const static_bookblock _resbook_44u_9={
{ {
{0}, {0},
{0,0,&_44u9_p1_0}, {0,0,&_44u9_p1_0},
@ -199,111 +199,111 @@ static static_bookblock _resbook_44u_9={
} }
}; };
static vorbis_residue_template _res_44u_n1[]={ static const vorbis_residue_template _res_44u_n1[]={
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44un1__short,&_huff_book__44un1__short, &_huff_book__44un1__short,&_huff_book__44un1__short,
&_resbook_44u_n1,&_resbook_44u_n1}, &_resbook_44u_n1,&_resbook_44u_n1},
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44un1__long,&_huff_book__44un1__long, &_huff_book__44un1__long,&_huff_book__44un1__long,
&_resbook_44u_n1,&_resbook_44u_n1} &_resbook_44u_n1,&_resbook_44u_n1}
}; };
static vorbis_residue_template _res_44u_0[]={ static const vorbis_residue_template _res_44u_0[]={
{1,0, &_residue_44_low_un, {1,0,16, &_residue_44_low_un,
&_huff_book__44u0__short,&_huff_book__44u0__short, &_huff_book__44u0__short,&_huff_book__44u0__short,
&_resbook_44u_0,&_resbook_44u_0}, &_resbook_44u_0,&_resbook_44u_0},
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44u0__long,&_huff_book__44u0__long, &_huff_book__44u0__long,&_huff_book__44u0__long,
&_resbook_44u_0,&_resbook_44u_0} &_resbook_44u_0,&_resbook_44u_0}
}; };
static vorbis_residue_template _res_44u_1[]={ static const vorbis_residue_template _res_44u_1[]={
{1,0, &_residue_44_low_un, {1,0,16, &_residue_44_low_un,
&_huff_book__44u1__short,&_huff_book__44u1__short, &_huff_book__44u1__short,&_huff_book__44u1__short,
&_resbook_44u_1,&_resbook_44u_1}, &_resbook_44u_1,&_resbook_44u_1},
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44u1__long,&_huff_book__44u1__long, &_huff_book__44u1__long,&_huff_book__44u1__long,
&_resbook_44u_1,&_resbook_44u_1} &_resbook_44u_1,&_resbook_44u_1}
}; };
static vorbis_residue_template _res_44u_2[]={ static const vorbis_residue_template _res_44u_2[]={
{1,0, &_residue_44_low_un, {1,0,16, &_residue_44_low_un,
&_huff_book__44u2__short,&_huff_book__44u2__short, &_huff_book__44u2__short,&_huff_book__44u2__short,
&_resbook_44u_2,&_resbook_44u_2}, &_resbook_44u_2,&_resbook_44u_2},
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44u2__long,&_huff_book__44u2__long, &_huff_book__44u2__long,&_huff_book__44u2__long,
&_resbook_44u_2,&_resbook_44u_2} &_resbook_44u_2,&_resbook_44u_2}
}; };
static vorbis_residue_template _res_44u_3[]={ static const vorbis_residue_template _res_44u_3[]={
{1,0, &_residue_44_low_un, {1,0,16, &_residue_44_low_un,
&_huff_book__44u3__short,&_huff_book__44u3__short, &_huff_book__44u3__short,&_huff_book__44u3__short,
&_resbook_44u_3,&_resbook_44u_3}, &_resbook_44u_3,&_resbook_44u_3},
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44u3__long,&_huff_book__44u3__long, &_huff_book__44u3__long,&_huff_book__44u3__long,
&_resbook_44u_3,&_resbook_44u_3} &_resbook_44u_3,&_resbook_44u_3}
}; };
static vorbis_residue_template _res_44u_4[]={ static const vorbis_residue_template _res_44u_4[]={
{1,0, &_residue_44_low_un, {1,0,16, &_residue_44_low_un,
&_huff_book__44u4__short,&_huff_book__44u4__short, &_huff_book__44u4__short,&_huff_book__44u4__short,
&_resbook_44u_4,&_resbook_44u_4}, &_resbook_44u_4,&_resbook_44u_4},
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__44u4__long,&_huff_book__44u4__long, &_huff_book__44u4__long,&_huff_book__44u4__long,
&_resbook_44u_4,&_resbook_44u_4} &_resbook_44u_4,&_resbook_44u_4}
}; };
static vorbis_residue_template _res_44u_5[]={ static const vorbis_residue_template _res_44u_5[]={
{1,0, &_residue_44_mid_un, {1,0,16, &_residue_44_mid_un,
&_huff_book__44u5__short,&_huff_book__44u5__short, &_huff_book__44u5__short,&_huff_book__44u5__short,
&_resbook_44u_5,&_resbook_44u_5}, &_resbook_44u_5,&_resbook_44u_5},
{1,0, &_residue_44_mid_un, {1,0,32, &_residue_44_mid_un,
&_huff_book__44u5__long,&_huff_book__44u5__long, &_huff_book__44u5__long,&_huff_book__44u5__long,
&_resbook_44u_5,&_resbook_44u_5} &_resbook_44u_5,&_resbook_44u_5}
}; };
static vorbis_residue_template _res_44u_6[]={ static const vorbis_residue_template _res_44u_6[]={
{1,0, &_residue_44_mid_un, {1,0,16, &_residue_44_mid_un,
&_huff_book__44u6__short,&_huff_book__44u6__short, &_huff_book__44u6__short,&_huff_book__44u6__short,
&_resbook_44u_6,&_resbook_44u_6}, &_resbook_44u_6,&_resbook_44u_6},
{1,0, &_residue_44_mid_un, {1,0,32, &_residue_44_mid_un,
&_huff_book__44u6__long,&_huff_book__44u6__long, &_huff_book__44u6__long,&_huff_book__44u6__long,
&_resbook_44u_6,&_resbook_44u_6} &_resbook_44u_6,&_resbook_44u_6}
}; };
static vorbis_residue_template _res_44u_7[]={ static const vorbis_residue_template _res_44u_7[]={
{1,0, &_residue_44_mid_un, {1,0,16, &_residue_44_mid_un,
&_huff_book__44u7__short,&_huff_book__44u7__short, &_huff_book__44u7__short,&_huff_book__44u7__short,
&_resbook_44u_7,&_resbook_44u_7}, &_resbook_44u_7,&_resbook_44u_7},
{1,0, &_residue_44_mid_un, {1,0,32, &_residue_44_mid_un,
&_huff_book__44u7__long,&_huff_book__44u7__long, &_huff_book__44u7__long,&_huff_book__44u7__long,
&_resbook_44u_7,&_resbook_44u_7} &_resbook_44u_7,&_resbook_44u_7}
}; };
static vorbis_residue_template _res_44u_8[]={ static const vorbis_residue_template _res_44u_8[]={
{1,0, &_residue_44_hi_un, {1,0,16, &_residue_44_hi_un,
&_huff_book__44u8__short,&_huff_book__44u8__short, &_huff_book__44u8__short,&_huff_book__44u8__short,
&_resbook_44u_8,&_resbook_44u_8}, &_resbook_44u_8,&_resbook_44u_8},
{1,0, &_residue_44_hi_un, {1,0,32, &_residue_44_hi_un,
&_huff_book__44u8__long,&_huff_book__44u8__long, &_huff_book__44u8__long,&_huff_book__44u8__long,
&_resbook_44u_8,&_resbook_44u_8} &_resbook_44u_8,&_resbook_44u_8}
}; };
static vorbis_residue_template _res_44u_9[]={ static const vorbis_residue_template _res_44u_9[]={
{1,0, &_residue_44_hi_un, {1,0,16, &_residue_44_hi_un,
&_huff_book__44u9__short,&_huff_book__44u9__short, &_huff_book__44u9__short,&_huff_book__44u9__short,
&_resbook_44u_9,&_resbook_44u_9}, &_resbook_44u_9,&_resbook_44u_9},
{1,0, &_residue_44_hi_un, {1,0,32, &_residue_44_hi_un,
&_huff_book__44u9__long,&_huff_book__44u9__long, &_huff_book__44u9__long,&_huff_book__44u9__long,
&_resbook_44u_9,&_resbook_44u_9} &_resbook_44u_9,&_resbook_44u_9}
}; };
static vorbis_mapping_template _mapres_template_44_uncoupled[]={ static const vorbis_mapping_template _mapres_template_44_uncoupled[]={
{ _map_nominal_u, _res_44u_n1 }, /* -1 */ { _map_nominal_u, _res_44u_n1 }, /* -1 */
{ _map_nominal_u, _res_44u_0 }, /* 0 */ { _map_nominal_u, _res_44u_0 }, /* 0 */
{ _map_nominal_u, _res_44u_1 }, /* 1 */ { _map_nominal_u, _res_44u_1 }, /* 1 */

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: toplevel residue templates 8/11kHz function: toplevel residue templates 8/11kHz
last mod: $Id: residue_8.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: residue_8.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
@ -20,7 +20,7 @@
/***** residue backends *********************************************/ /***** residue backends *********************************************/
static static_bookblock _resbook_8s_0={ static const static_bookblock _resbook_8s_0={
{ {
{0}, {0},
{0,0,&_8c0_s_p1_0}, {0,0,&_8c0_s_p1_0},
@ -34,7 +34,7 @@ static static_bookblock _resbook_8s_0={
{&_8c0_s_p9_0,&_8c0_s_p9_1,&_8c0_s_p9_2} {&_8c0_s_p9_0,&_8c0_s_p9_1,&_8c0_s_p9_2}
} }
}; };
static static_bookblock _resbook_8s_1={ static const static_bookblock _resbook_8s_1={
{ {
{0}, {0},
{0,0,&_8c1_s_p1_0}, {0,0,&_8c1_s_p1_0},
@ -49,23 +49,23 @@ static static_bookblock _resbook_8s_1={
} }
}; };
static vorbis_residue_template _res_8s_0[]={ static const vorbis_residue_template _res_8s_0[]={
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__8c0_s_single,&_huff_book__8c0_s_single, &_huff_book__8c0_s_single,&_huff_book__8c0_s_single,
&_resbook_8s_0,&_resbook_8s_0}, &_resbook_8s_0,&_resbook_8s_0},
}; };
static vorbis_residue_template _res_8s_1[]={ static const vorbis_residue_template _res_8s_1[]={
{2,0, &_residue_44_mid, {2,0,32, &_residue_44_mid,
&_huff_book__8c1_s_single,&_huff_book__8c1_s_single, &_huff_book__8c1_s_single,&_huff_book__8c1_s_single,
&_resbook_8s_1,&_resbook_8s_1}, &_resbook_8s_1,&_resbook_8s_1},
}; };
static vorbis_mapping_template _mapres_template_8_stereo[2]={ static const vorbis_mapping_template _mapres_template_8_stereo[2]={
{ _map_nominal, _res_8s_0 }, /* 0 */ { _map_nominal, _res_8s_0 }, /* 0 */
{ _map_nominal, _res_8s_1 }, /* 1 */ { _map_nominal, _res_8s_1 }, /* 1 */
}; };
static static_bookblock _resbook_8u_0={ static const static_bookblock _resbook_8u_0={
{ {
{0}, {0},
{0,0,&_8u0__p1_0}, {0,0,&_8u0__p1_0},
@ -77,7 +77,7 @@ static static_bookblock _resbook_8u_0={
{&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2} {&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2}
} }
}; };
static static_bookblock _resbook_8u_1={ static const static_bookblock _resbook_8u_1={
{ {
{0}, {0},
{0,0,&_8u1__p1_0}, {0,0,&_8u1__p1_0},
@ -92,18 +92,18 @@ static static_bookblock _resbook_8u_1={
} }
}; };
static vorbis_residue_template _res_8u_0[]={ static const vorbis_residue_template _res_8u_0[]={
{1,0, &_residue_44_low_un, {1,0,32, &_residue_44_low_un,
&_huff_book__8u0__single,&_huff_book__8u0__single, &_huff_book__8u0__single,&_huff_book__8u0__single,
&_resbook_8u_0,&_resbook_8u_0}, &_resbook_8u_0,&_resbook_8u_0},
}; };
static vorbis_residue_template _res_8u_1[]={ static const vorbis_residue_template _res_8u_1[]={
{1,0, &_residue_44_mid_un, {1,0,32, &_residue_44_mid_un,
&_huff_book__8u1__single,&_huff_book__8u1__single, &_huff_book__8u1__single,&_huff_book__8u1__single,
&_resbook_8u_1,&_resbook_8u_1}, &_resbook_8u_1,&_resbook_8u_1},
}; };
static vorbis_mapping_template _mapres_template_8_uncoupled[2]={ static const vorbis_mapping_template _mapres_template_8_uncoupled[2]={
{ _map_nominal_u, _res_8u_0 }, /* 0 */ { _map_nominal_u, _res_8u_0 }, /* 0 */
{ _map_nominal_u, _res_8u_1 }, /* 1 */ { _map_nominal_u, _res_8u_1 }, /* 1 */
}; };

View file

@ -5,39 +5,42 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 11kHz settings function: 11kHz settings
last mod: $Id: setup_11.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_11.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/ ********************************************************************/
#include "psych_11.h" #include "psych_11.h"
static int blocksize_11[2]={ static const int blocksize_11[2]={
512,512 512,512
}; };
static int _floor_mapping_11[2]={ static const int _floor_mapping_11a[]={
6,6, 6,6
};
static const int *_floor_mapping_11[]={
_floor_mapping_11a
}; };
static double rate_mapping_11[3]={ static const double rate_mapping_11[3]={
8000.,13000.,44000., 8000.,13000.,44000.,
}; };
static double rate_mapping_11_uncoupled[3]={ static const double rate_mapping_11_uncoupled[3]={
12000.,20000.,50000., 12000.,20000.,50000.,
}; };
static double quality_mapping_11[3]={ static const double quality_mapping_11[3]={
-.1,.0,1. -.1,.0,1.
}; };
ve_setup_data_template ve_setup_11_stereo={ static const ve_setup_data_template ve_setup_11_stereo={
2, 2,
rate_mapping_11, rate_mapping_11,
quality_mapping_11, quality_mapping_11,
@ -82,13 +85,13 @@ ve_setup_data_template ve_setup_11_stereo={
_floor_books, _floor_books,
_floor, _floor,
1,
_floor_mapping_11, _floor_mapping_11,
NULL,
_mapres_template_8_stereo _mapres_template_8_stereo
}; };
ve_setup_data_template ve_setup_11_uncoupled={ static const ve_setup_data_template ve_setup_11_uncoupled={
2, 2,
rate_mapping_11_uncoupled, rate_mapping_11_uncoupled,
quality_mapping_11, quality_mapping_11,
@ -133,9 +136,8 @@ ve_setup_data_template ve_setup_11_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
1,
_floor_mapping_11, _floor_mapping_11,
NULL,
_mapres_template_8_uncoupled _mapres_template_8_uncoupled
}; };

View file

@ -5,48 +5,52 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 16kHz settings function: 16kHz settings
last mod: $Id: setup_16.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_16.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/ ********************************************************************/
#include "psych_16.h" #include "psych_16.h"
#include "residue_16.h" #include "residue_16.h"
static int blocksize_16_short[3]={ static const int blocksize_16_short[3]={
1024,512,512 1024,512,512
}; };
static int blocksize_16_long[3]={ static const int blocksize_16_long[3]={
1024,1024,1024 1024,1024,1024
}; };
static int _floor_mapping_16_short[3]={ static const int _floor_mapping_16a[]={
9,3,3 9,3,3
}; };
static int _floor_mapping_16[3]={ static const int _floor_mapping_16b[]={
9,9,9 9,9,9
}; };
static const int *_floor_mapping_16[]={
_floor_mapping_16a,
_floor_mapping_16b
};
static double rate_mapping_16[4]={ static const double rate_mapping_16[4]={
12000.,20000.,44000.,86000. 12000.,20000.,44000.,86000.
}; };
static double rate_mapping_16_uncoupled[4]={ static const double rate_mapping_16_uncoupled[4]={
16000.,28000.,64000.,100000. 16000.,28000.,64000.,100000.
}; };
static double _global_mapping_16[4]={ 1., 2., 3., 4. }; static const double _global_mapping_16[4]={ 1., 2., 3., 4. };
static double quality_mapping_16[4]={ -.1,.05,.5,1. }; static const double quality_mapping_16[4]={ -.1,.05,.5,1. };
static double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.}; static const double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.};
ve_setup_data_template ve_setup_16_stereo={ static const ve_setup_data_template ve_setup_16_stereo={
3, 3,
rate_mapping_16, rate_mapping_16,
quality_mapping_16, quality_mapping_16,
@ -91,13 +95,13 @@ ve_setup_data_template ve_setup_16_stereo={
_floor_books, _floor_books,
_floor, _floor,
_floor_mapping_16_short, 2,
_floor_mapping_16, _floor_mapping_16,
_mapres_template_16_stereo _mapres_template_16_stereo
}; };
ve_setup_data_template ve_setup_16_uncoupled={ static const ve_setup_data_template ve_setup_16_uncoupled={
3, 3,
rate_mapping_16_uncoupled, rate_mapping_16_uncoupled,
quality_mapping_16, quality_mapping_16,
@ -116,7 +120,7 @@ ve_setup_data_template ve_setup_16_uncoupled={
_vp_tonemask_adj_16, _vp_tonemask_adj_16,
_vp_tonemask_adj_16, _vp_tonemask_adj_16,
_psy_noiseguards_8, _psy_noiseguards_16,
_psy_noisebias_16_impulse, _psy_noisebias_16_impulse,
_psy_noisebias_16_short, _psy_noisebias_16_short,
_psy_noisebias_16_short, _psy_noisebias_16_short,
@ -142,7 +146,7 @@ ve_setup_data_template ve_setup_16_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
_floor_mapping_16_short, 2,
_floor_mapping_16, _floor_mapping_16,
_mapres_template_16_uncoupled _mapres_template_16_uncoupled

View file

@ -5,27 +5,27 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 22kHz settings function: 22kHz settings
last mod: $Id: setup_22.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_22.h 17026 2010-03-25 05:00:27Z xiphmont $
********************************************************************/ ********************************************************************/
static double rate_mapping_22[4]={ static const double rate_mapping_22[4]={
15000.,20000.,44000.,86000. 15000.,20000.,44000.,86000.
}; };
static double rate_mapping_22_uncoupled[4]={ static const double rate_mapping_22_uncoupled[4]={
16000.,28000.,50000.,90000. 16000.,28000.,50000.,90000.
}; };
static double _psy_lowpass_22[4]={9.5,11.,30.,99.}; static const double _psy_lowpass_22[4]={9.5,11.,30.,99.};
ve_setup_data_template ve_setup_22_stereo={ static const ve_setup_data_template ve_setup_22_stereo={
3, 3,
rate_mapping_22, rate_mapping_22,
quality_mapping_16, quality_mapping_16,
@ -52,8 +52,8 @@ ve_setup_data_template ve_setup_22_stereo={
_psy_noise_suppress, _psy_noise_suppress,
_psy_compand_8, _psy_compand_8,
_psy_compand_8_mapping, _psy_compand_16_mapping,
_psy_compand_8_mapping, _psy_compand_16_mapping,
{_noise_start_16,_noise_start_16}, {_noise_start_16,_noise_start_16},
{ _noise_part_16, _noise_part_16}, { _noise_part_16, _noise_part_16},
@ -70,13 +70,13 @@ ve_setup_data_template ve_setup_22_stereo={
_floor_books, _floor_books,
_floor, _floor,
_floor_mapping_16_short, 2,
_floor_mapping_16, _floor_mapping_16,
_mapres_template_16_stereo _mapres_template_16_stereo
}; };
ve_setup_data_template ve_setup_22_uncoupled={ static const ve_setup_data_template ve_setup_22_uncoupled={
3, 3,
rate_mapping_22_uncoupled, rate_mapping_22_uncoupled,
quality_mapping_16, quality_mapping_16,
@ -95,7 +95,7 @@ ve_setup_data_template ve_setup_22_uncoupled={
_vp_tonemask_adj_16, _vp_tonemask_adj_16,
_vp_tonemask_adj_16, _vp_tonemask_adj_16,
_psy_noiseguards_8, _psy_noiseguards_16,
_psy_noisebias_16_impulse, _psy_noisebias_16_impulse,
_psy_noisebias_16_short, _psy_noisebias_16_short,
_psy_noisebias_16_short, _psy_noisebias_16_short,
@ -103,8 +103,8 @@ ve_setup_data_template ve_setup_22_uncoupled={
_psy_noise_suppress, _psy_noise_suppress,
_psy_compand_8, _psy_compand_8,
_psy_compand_8_mapping, _psy_compand_16_mapping,
_psy_compand_8_mapping, _psy_compand_16_mapping,
{_noise_start_16,_noise_start_16}, {_noise_start_16,_noise_start_16},
{ _noise_part_16, _noise_part_16}, { _noise_part_16, _noise_part_16},
@ -121,7 +121,7 @@ ve_setup_data_template ve_setup_22_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
_floor_mapping_16_short, 2,
_floor_mapping_16, _floor_mapping_16,
_mapres_template_16_uncoupled _mapres_template_16_uncoupled

View file

@ -5,31 +5,31 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: toplevel settings for 32kHz function: toplevel settings for 32kHz
last mod: $Id: setup_32.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_32.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/ ********************************************************************/
static double rate_mapping_32[12]={ static const double rate_mapping_32[12]={
18000.,28000.,35000.,45000.,56000.,60000., 18000.,28000.,35000.,45000.,56000.,60000.,
75000.,90000.,100000.,115000.,150000.,190000., 75000.,90000.,100000.,115000.,150000.,190000.,
}; };
static double rate_mapping_32_un[12]={ static const double rate_mapping_32_un[12]={
30000.,42000.,52000.,64000.,72000.,78000., 30000.,42000.,52000.,64000.,72000.,78000.,
86000.,92000.,110000.,120000.,140000.,190000., 86000.,92000.,110000.,120000.,140000.,190000.,
}; };
static double _psy_lowpass_32[12]={ static const double _psy_lowpass_32[12]={
12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99. 12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99.
}; };
ve_setup_data_template ve_setup_32_stereo={ static const ve_setup_data_template ve_setup_32_stereo={
11, 11,
rate_mapping_32, rate_mapping_32,
quality_mapping_44, quality_mapping_44,
@ -74,13 +74,13 @@ ve_setup_data_template ve_setup_32_stereo={
_floor_books, _floor_books,
_floor, _floor,
_floor_short_mapping_44, 2,
_floor_long_mapping_44, _floor_mapping_44,
_mapres_template_44_stereo _mapres_template_44_stereo
}; };
ve_setup_data_template ve_setup_32_uncoupled={ static const ve_setup_data_template ve_setup_32_uncoupled={
11, 11,
rate_mapping_32_un, rate_mapping_32_un,
quality_mapping_44, quality_mapping_44,
@ -125,8 +125,8 @@ ve_setup_data_template ve_setup_32_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
_floor_short_mapping_44, 2,
_floor_long_mapping_44, _floor_mapping_44,
_mapres_template_44_uncoupled _mapres_template_44_uncoupled
}; };

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: toplevel settings for 44.1/48kHz function: toplevel settings for 44.1/48kHz
last mod: $Id: setup_44.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_44.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
@ -19,42 +19,53 @@
#include "modes/residue_44.h" #include "modes/residue_44.h"
#include "modes/psych_44.h" #include "modes/psych_44.h"
static double rate_mapping_44_stereo[12]={ static const double rate_mapping_44_stereo[12]={
22500.,32000.,40000.,48000.,56000.,64000., 22500.,32000.,40000.,48000.,56000.,64000.,
80000.,96000.,112000.,128000.,160000.,250001. 80000.,96000.,112000.,128000.,160000.,250001.
}; };
static double quality_mapping_44[12]={ static const double quality_mapping_44[12]={
-.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0 -.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0
}; };
static int blocksize_short_44[11]={ static const int blocksize_short_44[11]={
512,256,256,256,256,256,256,256,256,256,256 512,256,256,256,256,256,256,256,256,256,256
}; };
static int blocksize_long_44[11]={ static const int blocksize_long_44[11]={
4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048 4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048
}; };
static double _psy_compand_short_mapping[12]={ static const double _psy_compand_short_mapping[12]={
0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2. 0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2.
}; };
static double _psy_compand_long_mapping[12]={ static const double _psy_compand_long_mapping[12]={
3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5. 3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5.
}; };
static double _global_mapping_44[12]={ static const double _global_mapping_44[12]={
/* 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.5, 4., 4. */ /* 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.5, 4., 4. */
0., 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.7, 4., 4. 0., 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.7, 4., 4.
}; };
static int _floor_short_mapping_44[11]={ static const int _floor_mapping_44a[11]={
1,0,0,2,2,4,5,5,5,5,5 1,0,0,2,2,4,5,5,5,5,5
}; };
static int _floor_long_mapping_44[11]={
static const int _floor_mapping_44b[11]={
8,7,7,7,7,7,7,7,7,7,7 8,7,7,7,7,7,7,7,7,7,7
}; };
ve_setup_data_template ve_setup_44_stereo={ static const int _floor_mapping_44c[11]={
10,10,10,10,10,10,10,10,10,10,10
};
static const int *_floor_mapping_44[]={
_floor_mapping_44a,
_floor_mapping_44b,
_floor_mapping_44c,
};
static const ve_setup_data_template ve_setup_44_stereo={
11, 11,
rate_mapping_44_stereo, rate_mapping_44_stereo,
quality_mapping_44, quality_mapping_44,
@ -99,9 +110,8 @@ ve_setup_data_template ve_setup_44_stereo={
_floor_books, _floor_books,
_floor, _floor,
_floor_short_mapping_44, 2,
_floor_long_mapping_44, _floor_mapping_44,
_mapres_template_44_stereo _mapres_template_44_stereo
}; };

View file

@ -5,24 +5,24 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: toplevel settings for 44.1/48kHz uncoupled modes function: toplevel settings for 44.1/48kHz uncoupled modes
last mod: $Id: setup_44u.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_44u.h 16962 2010-03-11 07:30:34Z xiphmont $
********************************************************************/ ********************************************************************/
#include "modes/residue_44u.h" #include "modes/residue_44u.h"
static double rate_mapping_44_un[12]={ static const double rate_mapping_44_un[12]={
32000.,48000.,60000.,70000.,80000.,86000., 32000.,48000.,60000.,70000.,80000.,86000.,
96000.,110000.,120000.,140000.,160000.,240001. 96000.,110000.,120000.,140000.,160000.,240001.
}; };
ve_setup_data_template ve_setup_44_uncoupled={ static const ve_setup_data_template ve_setup_44_uncoupled={
11, 11,
rate_mapping_44_un, rate_mapping_44_un,
quality_mapping_44, quality_mapping_44,
@ -63,12 +63,12 @@ ve_setup_data_template ve_setup_44_uncoupled={
_psy_global_44, _psy_global_44,
_global_mapping_44, _global_mapping_44,
NULL, _psy_stereo_modes_44,
_floor_books, _floor_books,
_floor, _floor,
_floor_short_mapping_44, 2,
_floor_long_mapping_44, _floor_mapping_44,
_mapres_template_44_uncoupled _mapres_template_44_uncoupled
}; };

View file

@ -5,44 +5,48 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: 8kHz settings function: 8kHz settings
last mod: $Id: setup_8.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_8.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/ ********************************************************************/
#include "psych_8.h" #include "psych_8.h"
#include "residue_8.h" #include "residue_8.h"
static int blocksize_8[2]={ static const int blocksize_8[2]={
512,512 512,512
}; };
static int _floor_mapping_8[2]={ static const int _floor_mapping_8a[]={
6,6, 6,6
}; };
static double rate_mapping_8[3]={ static const int *_floor_mapping_8[]={
_floor_mapping_8a
};
static const double rate_mapping_8[3]={
6000.,9000.,32000., 6000.,9000.,32000.,
}; };
static double rate_mapping_8_uncoupled[3]={ static const double rate_mapping_8_uncoupled[3]={
8000.,14000.,42000., 8000.,14000.,42000.,
}; };
static double quality_mapping_8[3]={ static const double quality_mapping_8[3]={
-.1,.0,1. -.1,.0,1.
}; };
static double _psy_compand_8_mapping[3]={ 0., 1., 1.}; static const double _psy_compand_8_mapping[3]={ 0., 1., 1.};
static double _global_mapping_8[3]={ 1., 2., 3. }; static const double _global_mapping_8[3]={ 1., 2., 3. };
ve_setup_data_template ve_setup_8_stereo={ static const ve_setup_data_template ve_setup_8_stereo={
2, 2,
rate_mapping_8, rate_mapping_8,
quality_mapping_8, quality_mapping_8,
@ -87,13 +91,13 @@ ve_setup_data_template ve_setup_8_stereo={
_floor_books, _floor_books,
_floor, _floor,
1,
_floor_mapping_8, _floor_mapping_8,
NULL,
_mapres_template_8_stereo _mapres_template_8_stereo
}; };
ve_setup_data_template ve_setup_8_uncoupled={ static const ve_setup_data_template ve_setup_8_uncoupled={
2, 2,
rate_mapping_8_uncoupled, rate_mapping_8_uncoupled,
quality_mapping_8, quality_mapping_8,
@ -138,9 +142,8 @@ ve_setup_data_template ve_setup_8_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
1,
_floor_mapping_8, _floor_mapping_8,
NULL,
_mapres_template_8_uncoupled _mapres_template_8_uncoupled
}; };

View file

@ -5,22 +5,22 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: catch-all toplevel settings for q modes only function: catch-all toplevel settings for q modes only
last mod: $Id: setup_X.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: setup_X.h 16894 2010-02-12 20:32:12Z xiphmont $
********************************************************************/ ********************************************************************/
static double rate_mapping_X[12]={ static const double rate_mapping_X[12]={
-1.,-1.,-1.,-1.,-1.,-1., -1.,-1.,-1.,-1.,-1.,-1.,
-1.,-1.,-1.,-1.,-1.,-1. -1.,-1.,-1.,-1.,-1.,-1.
}; };
ve_setup_data_template ve_setup_X_stereo={ static const ve_setup_data_template ve_setup_X_stereo={
11, 11,
rate_mapping_X, rate_mapping_X,
quality_mapping_44, quality_mapping_44,
@ -65,13 +65,13 @@ ve_setup_data_template ve_setup_X_stereo={
_floor_books, _floor_books,
_floor, _floor,
_floor_short_mapping_44, 2,
_floor_long_mapping_44, _floor_mapping_44,
_mapres_template_44_stereo _mapres_template_44_stereo
}; };
ve_setup_data_template ve_setup_X_uncoupled={ static const ve_setup_data_template ve_setup_X_uncoupled={
11, 11,
rate_mapping_X, rate_mapping_X,
quality_mapping_44, quality_mapping_44,
@ -116,13 +116,13 @@ ve_setup_data_template ve_setup_X_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
_floor_short_mapping_44, 2,
_floor_long_mapping_44, _floor_mapping_44,
_mapres_template_44_uncoupled _mapres_template_44_uncoupled
}; };
ve_setup_data_template ve_setup_XX_stereo={ static const ve_setup_data_template ve_setup_XX_stereo={
2, 2,
rate_mapping_X, rate_mapping_X,
quality_mapping_8, quality_mapping_8,
@ -167,13 +167,13 @@ ve_setup_data_template ve_setup_XX_stereo={
_floor_books, _floor_books,
_floor, _floor,
1,
_floor_mapping_8, _floor_mapping_8,
NULL,
_mapres_template_8_stereo _mapres_template_8_stereo
}; };
ve_setup_data_template ve_setup_XX_uncoupled={ static const ve_setup_data_template ve_setup_XX_uncoupled={
2, 2,
rate_mapping_X, rate_mapping_X,
quality_mapping_8, quality_mapping_8,
@ -218,9 +218,8 @@ ve_setup_data_template ve_setup_XX_uncoupled={
_floor_books, _floor_books,
_floor, _floor,
1,
_floor_mapping_8, _floor_mapping_8,
NULL,
_mapres_template_8_uncoupled _mapres_template_8_uncoupled
}; };

View file

@ -7,13 +7,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: #ifdef jail to whip a few platforms into the UNIX ideal. function: #ifdef jail to whip a few platforms into the UNIX ideal.
last mod: $Id: os.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: os.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -79,6 +79,8 @@ void *_alloca(size_t size);
# define max(x,y) ((x)<(y)?(y):(x)) # define max(x,y) ((x)<(y)?(y):(x))
#endif #endif
/* Special i386 GCC implementation */
#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) #if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__)
# define VORBIS_FPU_CONTROL # define VORBIS_FPU_CONTROL
/* both GCC and MSVC are kinda stupid about rounding/casting to int. /* both GCC and MSVC are kinda stupid about rounding/casting to int.
@ -95,7 +97,7 @@ static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
ogg_int16_t temp; ogg_int16_t temp;
__asm__ __volatile__("fnstcw %0\n\t" __asm__ __volatile__("fnstcw %0\n\t"
"movw %0,%%dx\n\t" "movw %0,%%dx\n\t"
"orw $62463,%%dx\n\t" "andw $62463,%%dx\n\t"
"movw %%dx,%1\n\t" "movw %%dx,%1\n\t"
"fldcw %1\n\t":"=m"(ret):"m"(temp): "dx"); "fldcw %1\n\t":"=m"(ret):"m"(temp): "dx");
*fpu=ret; *fpu=ret;
@ -113,10 +115,12 @@ static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise,
__asm__("fistl %0": "=m"(i) : "t"(f)); __asm__("fistl %0": "=m"(i) : "t"(f));
return(i); return(i);
} }
#endif #endif /* Special i386 GCC implementation */
#if defined(_WIN32) && !defined(__GNUC__) && !defined(__BORLANDC__) && !defined(_XBOX_VER) /* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the
* 64 bit compiler */
#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_WIN32_WCE)
# define VORBIS_FPU_CONTROL # define VORBIS_FPU_CONTROL
typedef ogg_int16_t vorbis_fpu_control; typedef ogg_int16_t vorbis_fpu_control;
@ -136,21 +140,47 @@ static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
} }
#endif #endif /* Special MSVC 32 bit implementation */
/* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be
done safely because all x86_64 CPUs supports SSE2. */
#if (defined(_MSC_VER) && defined(_WIN64)) || (defined(__GNUC__) && defined (__x86_64__))
# define VORBIS_FPU_CONTROL
typedef ogg_int16_t vorbis_fpu_control;
#include <emmintrin.h>
static __inline int vorbis_ftoi(double f){
return _mm_cvtsd_si32(_mm_load_sd(&f));
}
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){
}
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){
}
#endif /* Special MSVC x64 implementation */
/* If no special implementation was found for the current compiler / platform,
use the default implementation here: */
#ifndef VORBIS_FPU_CONTROL #ifndef VORBIS_FPU_CONTROL
typedef int vorbis_fpu_control; typedef int vorbis_fpu_control;
static int vorbis_ftoi(double f){ static int vorbis_ftoi(double f){
return (int)(f+.5); /* Note: MSVC and GCC (at least on some systems) round towards zero, thus,
the floor() call is required to ensure correct roudning of
negative numbers */
return (int)floor(f+.5);
} }
/* We don't have special code for this compiler/arch, so do it the slow way */ /* We don't have special code for this compiler/arch, so do it the slow way */
# define vorbis_fpu_setround(vorbis_fpu_control) {} # define vorbis_fpu_setround(vorbis_fpu_control) {}
# define vorbis_fpu_restore(vorbis_fpu_control) {} # define vorbis_fpu_restore(vorbis_fpu_control) {}
#endif #endif /* default implementation */
#endif /* _OS_H */ #endif /* _OS_H */

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: psychoacoustics not including preecho function: psychoacoustics not including preecho
last mod: $Id: psy.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: psy.c 18077 2011-09-02 02:49:00Z giles $
********************************************************************/ ********************************************************************/
@ -30,8 +30,8 @@
#include "misc.h" #include "misc.h"
#define NEGINF -9999.f #define NEGINF -9999.f
static double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10}; static const double stereo_threshholds[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10};
static double stereo_threshholds_limited[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10}; static const double stereo_threshholds_limited[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10};
vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){ vorbis_look_psy_global *_vp_global_look(vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
@ -304,6 +304,10 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,
} }
} }
for(;j<n;j++){
p->ath[j]=p->ath[j-1];
}
for(i=0;i<n;i++){ for(i=0;i<n;i++){
float bark=toBARK(rate/(2*n)*i); float bark=toBARK(rate/(2*n)*i);
@ -692,92 +696,6 @@ static void bark_noise_hybridmp(int n,const long *b,
} }
} }
static float FLOOR1_fromdB_INV_LOOKUP[256]={
0.F, 8.81683e+06F, 8.27882e+06F, 7.77365e+06F,
7.29930e+06F, 6.85389e+06F, 6.43567e+06F, 6.04296e+06F,
5.67422e+06F, 5.32798e+06F, 5.00286e+06F, 4.69759e+06F,
4.41094e+06F, 4.14178e+06F, 3.88905e+06F, 3.65174e+06F,
3.42891e+06F, 3.21968e+06F, 3.02321e+06F, 2.83873e+06F,
2.66551e+06F, 2.50286e+06F, 2.35014e+06F, 2.20673e+06F,
2.07208e+06F, 1.94564e+06F, 1.82692e+06F, 1.71544e+06F,
1.61076e+06F, 1.51247e+06F, 1.42018e+06F, 1.33352e+06F,
1.25215e+06F, 1.17574e+06F, 1.10400e+06F, 1.03663e+06F,
973377.F, 913981.F, 858210.F, 805842.F,
756669.F, 710497.F, 667142.F, 626433.F,
588208.F, 552316.F, 518613.F, 486967.F,
457252.F, 429351.F, 403152.F, 378551.F,
355452.F, 333762.F, 313396.F, 294273.F,
276316.F, 259455.F, 243623.F, 228757.F,
214798.F, 201691.F, 189384.F, 177828.F,
166977.F, 156788.F, 147221.F, 138237.F,
129802.F, 121881.F, 114444.F, 107461.F,
100903.F, 94746.3F, 88964.9F, 83536.2F,
78438.8F, 73652.5F, 69158.2F, 64938.1F,
60975.6F, 57254.9F, 53761.2F, 50480.6F,
47400.3F, 44507.9F, 41792.0F, 39241.9F,
36847.3F, 34598.9F, 32487.7F, 30505.3F,
28643.8F, 26896.0F, 25254.8F, 23713.7F,
22266.7F, 20908.0F, 19632.2F, 18434.2F,
17309.4F, 16253.1F, 15261.4F, 14330.1F,
13455.7F, 12634.6F, 11863.7F, 11139.7F,
10460.0F, 9821.72F, 9222.39F, 8659.64F,
8131.23F, 7635.06F, 7169.17F, 6731.70F,
6320.93F, 5935.23F, 5573.06F, 5232.99F,
4913.67F, 4613.84F, 4332.30F, 4067.94F,
3819.72F, 3586.64F, 3367.78F, 3162.28F,
2969.31F, 2788.13F, 2617.99F, 2458.24F,
2308.24F, 2167.39F, 2035.14F, 1910.95F,
1794.35F, 1684.85F, 1582.04F, 1485.51F,
1394.86F, 1309.75F, 1229.83F, 1154.78F,
1084.32F, 1018.15F, 956.024F, 897.687F,
842.910F, 791.475F, 743.179F, 697.830F,
655.249F, 615.265F, 577.722F, 542.469F,
509.367F, 478.286F, 449.101F, 421.696F,
395.964F, 371.803F, 349.115F, 327.812F,
307.809F, 289.026F, 271.390F, 254.830F,
239.280F, 224.679F, 210.969F, 198.096F,
186.008F, 174.658F, 164.000F, 153.993F,
144.596F, 135.773F, 127.488F, 119.708F,
112.404F, 105.545F, 99.1046F, 93.0572F,
87.3788F, 82.0469F, 77.0404F, 72.3394F,
67.9252F, 63.7804F, 59.8885F, 56.2341F,
52.8027F, 49.5807F, 46.5553F, 43.7144F,
41.0470F, 38.5423F, 36.1904F, 33.9821F,
31.9085F, 29.9614F, 28.1332F, 26.4165F,
24.8045F, 23.2910F, 21.8697F, 20.5352F,
19.2822F, 18.1056F, 17.0008F, 15.9634F,
14.9893F, 14.0746F, 13.2158F, 12.4094F,
11.6522F, 10.9411F, 10.2735F, 9.64662F,
9.05798F, 8.50526F, 7.98626F, 7.49894F,
7.04135F, 6.61169F, 6.20824F, 5.82941F,
5.47370F, 5.13970F, 4.82607F, 4.53158F,
4.25507F, 3.99542F, 3.75162F, 3.52269F,
3.30774F, 3.10590F, 2.91638F, 2.73842F,
2.57132F, 2.41442F, 2.26709F, 2.12875F,
1.99885F, 1.87688F, 1.76236F, 1.65482F,
1.55384F, 1.45902F, 1.36999F, 1.28640F,
1.20790F, 1.13419F, 1.06499F, 1.F
};
void _vp_remove_floor(vorbis_look_psy *p,
float *mdct,
int *codedflr,
float *residue,
int sliding_lowpass){
int i,n=p->n;
if(sliding_lowpass>n)sliding_lowpass=n;
for(i=0;i<sliding_lowpass;i++){
residue[i]=
mdct[i]*FLOOR1_fromdB_INV_LOOKUP[codedflr[i]];
}
for(;i<n;i++)
residue[i]=0.;
}
void _vp_noisemask(vorbis_look_psy *p, void _vp_noisemask(vorbis_look_psy *p,
float *logmdct, float *logmdct,
float *logmask){ float *logmask){
@ -922,306 +840,367 @@ float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){
return(amp); return(amp);
} }
static void couple_lossless(float A, float B, static float FLOOR1_fromdB_LOOKUP[256]={
float *qA, float *qB){ 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
int test1=fabs(*qA)>fabs(*qB); 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
test1-= fabs(*qA)<fabs(*qB); 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F,
if(!test1)test1=((fabs(A)>fabs(B))<<1)-1; 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F,
if(test1==1){ 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F,
*qB=(*qA>0.f?*qA-*qB:*qB-*qA); 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F,
}else{ 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F,
float temp=*qB; 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F,
*qB=(*qB>0.f?*qA-*qB:*qB-*qA); 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F,
*qA=temp; 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F,
} 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F,
2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F,
if(*qB>fabs(*qA)*1.9999f){ 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F,
*qB= -fabs(*qA)*2.f; 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F,
*qA= -*qA; 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F,
} 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F,
} 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F,
9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F,
static float hypot_lookup[32]={ 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F,
-0.009935, -0.011245, -0.012726, -0.014397, 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F,
-0.016282, -0.018407, -0.020800, -0.023494, 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F,
-0.026522, -0.029923, -0.033737, -0.038010, 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F,
-0.042787, -0.048121, -0.054064, -0.060671, 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F,
-0.068000, -0.076109, -0.085054, -0.094892, 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F,
-0.105675, -0.117451, -0.130260, -0.144134, 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F,
-0.159093, -0.175146, -0.192286, -0.210490, 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F,
-0.229718, -0.249913, -0.271001, -0.292893}; 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
static void precomputed_couple_point(float premag, 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
int floorA,int floorB, 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
float *mag, float *ang){ 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
int test=(floorA>floorB)-1; 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
int offset=31-abs(floorA-floorB); 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
float floormag=hypot_lookup[((offset<0)-1)&offset]+1.f; 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
floormag*=FLOOR1_fromdB_INV_LOOKUP[(floorB&test)|(floorA&(~test))]; 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
*mag=premag*floormag; 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
*ang=0.f; 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
} 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
/* just like below, this is currently set up to only do 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
single-step-depth coupling. Otherwise, we'd have to do more 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
copying (which will be inevitable later) */ 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
/* doing the real circular magnitude calculation is audibly superior 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
to (A+B)/sqrt(2) */ 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
static float dipole_hypot(float a, float b){ 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
if(a>0.){ 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
if(b>0.)return sqrt(a*a+b*b); 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
if(a>-b)return sqrt(a*a-b*b); 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
return -sqrt(b*b-a*a); 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
} 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
if(b<0.)return -sqrt(a*a+b*b); 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
if(-a>b)return -sqrt(a*a-b*b); 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
return sqrt(b*b-a*a); 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
} 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
static float round_hypot(float a, float b){ 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
if(a>0.){ 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
if(b>0.)return sqrt(a*a+b*b); 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
if(a>-b)return sqrt(a*a+b*b); 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
return -sqrt(b*b+a*a); 0.82788260F, 0.88168307F, 0.9389798F, 1.F,
} };
if(b<0.)return -sqrt(a*a+b*b);
if(-a>b)return -sqrt(a*a+b*b);
return sqrt(b*b+a*a);
}
/* revert to round hypot for now */
float **_vp_quantize_couple_memo(vorbis_block *vb,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct){
int i,j,n=p->n;
float **ret=_vorbis_block_alloc(vb,vi->coupling_steps*sizeof(*ret));
int limit=g->coupling_pointlimit[p->vi->blockflag][PACKETBLOBS/2];
for(i=0;i<vi->coupling_steps;i++){
float *mdctM=mdct[vi->coupling_mag[i]];
float *mdctA=mdct[vi->coupling_ang[i]];
ret[i]=_vorbis_block_alloc(vb,n*sizeof(**ret));
for(j=0;j<limit;j++)
ret[i][j]=dipole_hypot(mdctM[j],mdctA[j]);
for(;j<n;j++)
ret[i][j]=round_hypot(mdctM[j],mdctA[j]);
}
return(ret);
}
/* this is for per-channel noise normalization */ /* this is for per-channel noise normalization */
static int apsort(const void *a, const void *b){ static int apsort(const void *a, const void *b){
float f1=fabs(**(float**)a); float f1=**(float**)a;
float f2=fabs(**(float**)b); float f2=**(float**)b;
return (f1<f2)-(f1>f2); return (f1<f2)-(f1>f2);
} }
int **_vp_quantize_couple_sort(vorbis_block *vb, static void flag_lossless(int limit, float prepoint, float postpoint, float *mdct,
vorbis_look_psy *p, float *floor, int *flag, int i, int jn){
vorbis_info_mapping0 *vi, int j;
float **mags){ for(j=0;j<jn;j++){
float point = j>=limit-i ? postpoint : prepoint;
float r = fabs(mdct[j])/floor[j];
if(p->vi->normal_point_p){ if(r<point)
int i,j,k,n=p->n; flag[j]=0;
int **ret=_vorbis_block_alloc(vb,vi->coupling_steps*sizeof(*ret)); else
int partition=p->vi->normal_partition; flag[j]=1;
float **work=alloca(sizeof(*work)*partition);
for(i=0;i<vi->coupling_steps;i++){
ret[i]=_vorbis_block_alloc(vb,n*sizeof(**ret));
for(j=0;j<n;j+=partition){
for(k=0;k<partition;k++)work[k]=mags[i]+k+j;
qsort(work,partition,sizeof(*work),apsort);
for(k=0;k<partition;k++)ret[i][k+j]=work[k]-mags[i];
} }
} }
return(ret);
}
return(NULL);
}
void _vp_noise_normalize_sort(vorbis_look_psy *p, /* Overload/Side effect: On input, the *q vector holds either the
float *magnitudes,int *sortedindex){ quantized energy (for elements with the flag set) or the absolute
int i,j,n=p->n; values of the *r vector (for elements with flag unset). On output,
*q holds the quantized energy for all elements */
static float noise_normalize(vorbis_look_psy *p, int limit, float *r, float *q, float *f, int *flags, float acc, int i, int n, int *out){
vorbis_info_psy *vi=p->vi; vorbis_info_psy *vi=p->vi;
int partition=vi->normal_partition; float **sort = alloca(n*sizeof(*sort));
float **work=alloca(sizeof(*work)*partition); int j,count=0;
int start=vi->normal_start; int start = (vi->normal_p ? vi->normal_start-i : n);
for(j=start;j<n;j+=partition){
if(j+partition>n)partition=n-j;
for(i=0;i<partition;i++)work[i]=magnitudes+i+j;
qsort(work,partition,sizeof(*work),apsort);
for(i=0;i<partition;i++){
sortedindex[i+j-start]=work[i]-magnitudes;
}
}
}
void _vp_noise_normalize(vorbis_look_psy *p,
float *in,float *out,int *sortedindex){
int flag=0,i,j=0,n=p->n;
vorbis_info_psy *vi=p->vi;
int partition=vi->normal_partition;
int start=vi->normal_start;
if(start>n)start=n; if(start>n)start=n;
if(vi->normal_channel_p){ /* force classic behavior where only energy in the current band is considered */
for(;j<start;j++) acc=0.f;
out[j]=rint(in[j]);
for(;j+partition<=n;j+=partition){ /* still responsible for populating *out where noise norm not in
float acc=0.; effect. There's no need to [re]populate *q in these areas */
int k; for(j=0;j<start;j++){
if(!flags || !flags[j]){ /* lossless coupling already quantized.
Don't touch; requantizing based on
energy would be incorrect. */
float ve = q[j]/f[j];
if(r[j]<0)
out[j] = -rint(sqrt(ve));
else
out[j] = rint(sqrt(ve));
}
}
for(i=j;i<j+partition;i++) /* sort magnitudes for noise norm portion of partition */
acc+=in[i]*in[i]; for(;j<n;j++){
if(!flags || !flags[j]){ /* can't noise norm elements that have
for(i=0;i<partition;i++){ already been loslessly coupled; we can
k=sortedindex[i+j-start]; only account for their energy error */
float ve = q[j]/f[j];
if(in[k]*in[k]>=.25f){ /* Despite all the new, more capable coupling code, for now we
out[k]=rint(in[k]); implement noise norm as it has been up to this point. Only
acc-=in[k]*in[k]; consider promotions to unit magnitude from 0. In addition
flag=1; the only energy error counted is quantizations to zero. */
/* also-- the original point code only applied noise norm at > pointlimit */
if(ve<.25f && (!flags || j>=limit-i)){
acc += ve;
sort[count++]=q+j; /* q is fabs(r) for unflagged element */
}else{ }else{
if(acc<vi->normal_thresh)break; /* For now: no acc adjustment for nonzero quantization. populate *out and q as this value is final. */
out[k]=unitnorm(in[k]); if(r[j]<0)
acc-=1.; out[j] = -rint(sqrt(ve));
else
out[j] = rint(sqrt(ve));
q[j] = out[j]*out[j]*f[j];
} }
}/* else{
again, no energy adjustment for error in nonzero quant-- for now
}*/
} }
for(;i<partition;i++){ if(count){
k=sortedindex[i+j-start]; /* noise norm to do */
out[k]=0.; qsort(sort,count,sizeof(*sort),apsort);
for(j=0;j<count;j++){
int k=sort[j]-q;
if(acc>=vi->normal_thresh){
out[k]=unitnorm(r[k]);
acc-=1.f;
q[k]=f[k];
}else{
out[k]=0;
q[k]=0.f;
} }
} }
} }
for(;j<n;j++) return acc;
out[j]=rint(in[j]);
} }
void _vp_couple(int blobno, /* Noise normalization, quantization and coupling are not wholly
seperable processes in depth>1 coupling. */
void _vp_couple_quantize_normalize(int blobno,
vorbis_info_psy_global *g, vorbis_info_psy_global *g,
vorbis_look_psy *p, vorbis_look_psy *p,
vorbis_info_mapping0 *vi, vorbis_info_mapping0 *vi,
float **res, float **mdct,
float **mag_memo, int **iwork,
int **mag_sort,
int **ifloor,
int *nonzero, int *nonzero,
int sliding_lowpass){ int sliding_lowpass,
int ch){
int i,j,k,n=p->n; int i;
int n = p->n;
/* perform any requested channel coupling */ int partition=(p->vi->normal_p ? p->vi->normal_partition : 16);
/* point stereo can only be used in a first stage (in this encoder) int limit = g->coupling_pointlimit[p->vi->blockflag][blobno];
because of the dependency on floor lookups */
for(i=0;i<vi->coupling_steps;i++){
/* once we're doing multistage coupling in which a channel goes
through more than one coupling step, the floor vector
magnitudes will also have to be recalculated an propogated
along with PCM. Right now, we're not (that will wait until 5.1
most likely), so the code isn't here yet. The memory management
here is all assuming single depth couplings anyway. */
/* make sure coupling a zero and a nonzero channel results in two
nonzero channels. */
if(nonzero[vi->coupling_mag[i]] ||
nonzero[vi->coupling_ang[i]]){
float *rM=res[vi->coupling_mag[i]];
float *rA=res[vi->coupling_ang[i]];
float *qM=rM+n;
float *qA=rA+n;
int *floorM=ifloor[vi->coupling_mag[i]];
int *floorA=ifloor[vi->coupling_ang[i]];
float prepoint=stereo_threshholds[g->coupling_prepointamp[blobno]]; float prepoint=stereo_threshholds[g->coupling_prepointamp[blobno]];
float postpoint=stereo_threshholds[g->coupling_postpointamp[blobno]]; float postpoint=stereo_threshholds[g->coupling_postpointamp[blobno]];
int partition=(p->vi->normal_point_p?p->vi->normal_partition:p->n); #if 0
int limit=g->coupling_pointlimit[p->vi->blockflag][blobno]; float de=0.1*p->m_val; /* a blend of the AoTuV M2 and M3 code here and below */
int pointlimit=limit; #endif
nonzero[vi->coupling_mag[i]]=1; /* mdct is our raw mdct output, floor not removed. */
nonzero[vi->coupling_ang[i]]=1; /* inout passes in the ifloor, passes back quantized result */
/* unquantized energy (negative indicates amplitude has negative sign) */
float **raw = alloca(ch*sizeof(*raw));
/* dual pupose; quantized energy (if flag set), othersize fabs(raw) */
float **quant = alloca(ch*sizeof(*quant));
/* floor energy */
float **floor = alloca(ch*sizeof(*floor));
/* flags indicating raw/quantized status of elements in raw vector */
int **flag = alloca(ch*sizeof(*flag));
/* non-zero flag working vector */
int *nz = alloca(ch*sizeof(*nz));
/* energy surplus/defecit tracking */
float *acc = alloca((ch+vi->coupling_steps)*sizeof(*acc));
/* The threshold of a stereo is changed with the size of n */ /* The threshold of a stereo is changed with the size of n */
if(n > 1000) if(n > 1000)
postpoint=stereo_threshholds_limited[g->coupling_postpointamp[blobno]]; postpoint=stereo_threshholds_limited[g->coupling_postpointamp[blobno]];
for(j=0;j<p->n;j+=partition){ raw[0] = alloca(ch*partition*sizeof(**raw));
float acc=0.f; quant[0] = alloca(ch*partition*sizeof(**quant));
floor[0] = alloca(ch*partition*sizeof(**floor));
flag[0] = alloca(ch*partition*sizeof(**flag));
for(k=0;k<partition;k++){ for(i=1;i<ch;i++){
int l=k+j; raw[i] = &raw[0][partition*i];
quant[i] = &quant[0][partition*i];
floor[i] = &floor[0][partition*i];
flag[i] = &flag[0][partition*i];
}
for(i=0;i<ch+vi->coupling_steps;i++)
acc[i]=0.f;
if(l<sliding_lowpass){ for(i=0;i<n;i+=partition){
if((l>=limit && fabs(rM[l])<postpoint && fabs(rA[l])<postpoint) || int k,j,jn = partition > n-i ? n-i : partition;
(fabs(rM[l])<prepoint && fabs(rA[l])<prepoint)){ int step,track = 0;
memcpy(nz,nonzero,sizeof(*nz)*ch);
precomputed_couple_point(mag_memo[i][l], /* prefill */
floorM[l],floorA[l], memset(flag[0],0,ch*partition*sizeof(**flag));
qM+l,qA+l); for(k=0;k<ch;k++){
int *iout = &iwork[k][i];
if(nz[k]){
for(j=0;j<jn;j++)
floor[k][j] = FLOOR1_fromdB_LOOKUP[iout[j]];
flag_lossless(limit,prepoint,postpoint,&mdct[k][i],floor[k],flag[k],i,jn);
for(j=0;j<jn;j++){
quant[k][j] = raw[k][j] = mdct[k][i+j]*mdct[k][i+j];
if(mdct[k][i+j]<0.f) raw[k][j]*=-1.f;
floor[k][j]*=floor[k][j];
}
acc[track]=noise_normalize(p,limit,raw[k],quant[k],floor[k],NULL,acc[track],i,jn,iout);
if(rint(qM[l])==0.f)acc+=qM[l]*qM[l];
}else{ }else{
couple_lossless(rM[l],rA[l],qM+l,qA+l); for(j=0;j<jn;j++){
floor[k][j] = 1e-10f;
raw[k][j] = 0.f;
quant[k][j] = 0.f;
flag[k][j] = 0;
iout[j]=0;
} }
acc[track]=0.f;
}
track++;
}
/* coupling */
for(step=0;step<vi->coupling_steps;step++){
int Mi = vi->coupling_mag[step];
int Ai = vi->coupling_ang[step];
int *iM = &iwork[Mi][i];
int *iA = &iwork[Ai][i];
float *reM = raw[Mi];
float *reA = raw[Ai];
float *qeM = quant[Mi];
float *qeA = quant[Ai];
float *floorM = floor[Mi];
float *floorA = floor[Ai];
int *fM = flag[Mi];
int *fA = flag[Ai];
if(nz[Mi] || nz[Ai]){
nz[Mi] = nz[Ai] = 1;
for(j=0;j<jn;j++){
if(j<sliding_lowpass-i){
if(fM[j] || fA[j]){
/* lossless coupling */
reM[j] = fabs(reM[j])+fabs(reA[j]);
qeM[j] = qeM[j]+qeA[j];
fM[j]=fA[j]=1;
/* couple iM/iA */
{
int A = iM[j];
int B = iA[j];
if(abs(A)>abs(B)){
iA[j]=(A>0?A-B:B-A);
}else{ }else{
qM[l]=0.; iA[j]=(B>0?A-B:B-A);
qA[l]=0.; iM[j]=B;
}
} }
if(p->vi->normal_point_p){ /* collapse two equivalent tuples to one */
for(k=0;k<partition && acc>=p->vi->normal_thresh;k++){ if(iA[j]>=abs(iM[j])*2){
int l=mag_sort[i][j+k]; iA[j]= -iA[j];
if(l<sliding_lowpass && l>=pointlimit && rint(qM[l])==0.f){ iM[j]= -iM[j];
qM[l]=unitnorm(qM[l]);
acc-=1.f;
}
}
}
}
}
}
} }
}
}else{
/* lossy (point) coupling */
if(j<limit-i){
/* dipole */
reM[j] += reA[j];
qeM[j] = fabs(reM[j]);
}else{
#if 0
/* AoTuV */ /* AoTuV */
/** @ M2 ** /** @ M2 **
The boost problem by the combination of noise normalization and point stereo is eased. The boost problem by the combination of noise normalization and point stereo is eased.
However, this is a temporary patch. However, this is a temporary patch.
by Aoyumi @ 2004/04/18 by Aoyumi @ 2004/04/18
*/ */
float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit)));
/* elliptical */
if(reM[j]+reA[j]<0){
reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
}else{
reM[j] = (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
}
#else
/* elliptical */
if(reM[j]+reA[j]<0){
reM[j] = - (qeM[j] = fabs(reM[j])+fabs(reA[j]));
}else{
reM[j] = (qeM[j] = fabs(reM[j])+fabs(reA[j]));
}
#endif
void hf_reduction(vorbis_info_psy_global *g, }
vorbis_look_psy *p, reA[j]=qeA[j]=0.f;
vorbis_info_mapping0 *vi, fA[j]=1;
float **mdct){ iA[j]=0;
}
int i,j,n=p->n, de=0.3*p->m_val; }
int limit=g->coupling_pointlimit[p->vi->blockflag][PACKETBLOBS/2]; floorM[j]=floorA[j]=floorM[j]+floorA[j];
int start=p->vi->normal_start; }
/* normalize the resulting mag vector */
acc[track]=noise_normalize(p,limit,raw[Mi],quant[Mi],floor[Mi],flag[Mi],acc[track],i,jn,iM);
track++;
}
}
}
for(i=0;i<vi->coupling_steps;i++){ for(i=0;i<vi->coupling_steps;i++){
/* for(j=start; j<limit; j++){} // ???*/ /* make sure coupling a zero and a nonzero channel results in two
for(j=limit; j<n; j++) nonzero channels. */
mdct[i][j] *= (1.0 - de*((float)(j-limit) / (float)(n-limit))); if(nonzero[vi->coupling_mag[i]] ||
nonzero[vi->coupling_ang[i]]){
nonzero[vi->coupling_mag[i]]=1;
nonzero[vi->coupling_ang[i]]=1;
}
} }
} }

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: random psychoacoustics (not including preecho) function: random psychoacoustics (not including preecho)
last mod: $Id: psy.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $
********************************************************************/ ********************************************************************/
@ -57,8 +57,7 @@ typedef struct vorbis_info_psy{
float max_curve_dB; float max_curve_dB;
int normal_channel_p; int normal_p;
int normal_point_p;
int normal_start; int normal_start;
int normal_partition; int normal_partition;
double normal_thresh; double normal_thresh;
@ -122,12 +121,6 @@ extern void *_vi_psy_dup(void *source);
extern void _vi_psy_free(vorbis_info_psy *i); extern void _vi_psy_free(vorbis_info_psy *i);
extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i);
extern void _vp_remove_floor(vorbis_look_psy *p,
float *mdct,
int *icodedflr,
float *residue,
int sliding_lowpass);
extern void _vp_noisemask(vorbis_look_psy *p, extern void _vp_noisemask(vorbis_look_psy *p,
float *logmdct, float *logmdct,
float *logmask); float *logmask);
@ -148,39 +141,14 @@ extern void _vp_offset_and_mix(vorbis_look_psy *p,
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
extern float **_vp_quantize_couple_memo(vorbis_block *vb, extern void _vp_couple_quantize_normalize(int blobno,
vorbis_info_psy_global *g, vorbis_info_psy_global *g,
vorbis_look_psy *p, vorbis_look_psy *p,
vorbis_info_mapping0 *vi, vorbis_info_mapping0 *vi,
float **mdct); float **mdct,
int **iwork,
extern void _vp_couple(int blobno,
vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **res,
float **mag_memo,
int **mag_sort,
int **ifloor,
int *nonzero, int *nonzero,
int sliding_lowpass); int sliding_lowpass,
int ch);
extern void _vp_noise_normalize(vorbis_look_psy *p,
float *in,float *out,int *sortedindex);
extern void _vp_noise_normalize_sort(vorbis_look_psy *p,
float *magnitudes,int *sortedindex);
extern int **_vp_quantize_couple_sort(vorbis_block *vb,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mags);
extern void hf_reduction(vorbis_info_psy_global *g,
vorbis_look_psy *p,
vorbis_info_mapping0 *vi,
float **mdct);
#endif #endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: registry for time, floor, res backends and channel mappings function: registry for time, floor, res backends and channel mappings
last mod: $Id: registry.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -22,25 +22,24 @@
/* seems like major overkill now; the backend numbers will grow into /* seems like major overkill now; the backend numbers will grow into
the infrastructure soon enough */ the infrastructure soon enough */
extern vorbis_func_floor floor0_exportbundle; extern const vorbis_func_floor floor0_exportbundle;
extern vorbis_func_floor floor1_exportbundle; extern const vorbis_func_floor floor1_exportbundle;
extern vorbis_func_residue residue0_exportbundle; extern const vorbis_func_residue residue0_exportbundle;
extern vorbis_func_residue residue1_exportbundle; extern const vorbis_func_residue residue1_exportbundle;
extern vorbis_func_residue residue2_exportbundle; extern const vorbis_func_residue residue2_exportbundle;
extern vorbis_func_mapping mapping0_exportbundle; extern const vorbis_func_mapping mapping0_exportbundle;
vorbis_func_floor *_floor_P[]={ const vorbis_func_floor *const _floor_P[]={
&floor0_exportbundle, &floor0_exportbundle,
&floor1_exportbundle, &floor1_exportbundle,
}; };
vorbis_func_residue *_residue_P[]={ const vorbis_func_residue *const _residue_P[]={
&residue0_exportbundle, &residue0_exportbundle,
&residue1_exportbundle, &residue1_exportbundle,
&residue2_exportbundle, &residue2_exportbundle,
}; };
vorbis_func_mapping *_mapping_P[]={ const vorbis_func_mapping *const _mapping_P[]={
&mapping0_exportbundle, &mapping0_exportbundle,
}; };

View file

@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: registry for time, floor, res backends and channel mappings function: registry for time, floor, res backends and channel mappings
last mod: $Id: registry.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $
********************************************************************/ ********************************************************************/
@ -25,8 +25,8 @@
#define VI_RESB 3 #define VI_RESB 3
#define VI_MAPB 1 #define VI_MAPB 1
extern vorbis_func_floor *_floor_P[]; extern const vorbis_func_floor *const _floor_P[];
extern vorbis_func_residue *_residue_P[]; extern const vorbis_func_residue *const _residue_P[];
extern vorbis_func_mapping *_mapping_P[]; extern const vorbis_func_mapping *const _mapping_P[];
#endif #endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: residue backend 0, 1 and 2 implementation function: residue backend 0, 1 and 2 implementation
last mod: $Id: res0.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: res0.c 17556 2010-10-21 18:25:19Z tterribe $
********************************************************************/ ********************************************************************/
@ -31,6 +31,9 @@
#include "misc.h" #include "misc.h"
#include "os.h" #include "os.h"
//#define TRAIN_RES 1
//#define TRAIN_RESAUX 1
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX) #if defined(TRAIN_RES) || defined (TRAIN_RESAUX)
#include <stdio.h> #include <stdio.h>
#endif #endif
@ -58,6 +61,7 @@ typedef struct {
float training_min[8][64]; float training_min[8][64];
float tmin; float tmin;
float tmax; float tmax;
int submap;
#endif #endif
} vorbis_look_residue0; } vorbis_look_residue0;
@ -88,7 +92,7 @@ void res0_free_look(vorbis_look_residue *i){
codebook *statebook=look->partbooks[j][k]; codebook *statebook=look->partbooks[j][k];
/* long and short into the same bucket by current convention */ /* long and short into the same bucket by current convention */
sprintf(buffer,"res_part%d_pass%d.vqd",j,k); sprintf(buffer,"res_sub%d_part%d_pass%d.vqd",look->submap,j,k);
of=fopen(buffer,"a"); of=fopen(buffer,"a");
for(l=0;l<statebook->entries;l++) for(l=0;l<statebook->entries;l++)
@ -208,20 +212,52 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
info->partitions=oggpack_read(opb,6)+1; info->partitions=oggpack_read(opb,6)+1;
info->groupbook=oggpack_read(opb,8); info->groupbook=oggpack_read(opb,8);
/* check for premature EOP */
if(info->groupbook<0)goto errout;
for(j=0;j<info->partitions;j++){ for(j=0;j<info->partitions;j++){
int cascade=oggpack_read(opb,3); int cascade=oggpack_read(opb,3);
if(oggpack_read(opb,1)) int cflag=oggpack_read(opb,1);
cascade|=(oggpack_read(opb,5)<<3); if(cflag<0) goto errout;
if(cflag){
int c=oggpack_read(opb,5);
if(c<0) goto errout;
cascade|=(c<<3);
}
info->secondstages[j]=cascade; info->secondstages[j]=cascade;
acc+=icount(cascade); acc+=icount(cascade);
} }
for(j=0;j<acc;j++) for(j=0;j<acc;j++){
info->booklist[j]=oggpack_read(opb,8); int book=oggpack_read(opb,8);
if(book<0) goto errout;
info->booklist[j]=book;
}
if(info->groupbook>=ci->books)goto errout; if(info->groupbook>=ci->books)goto errout;
for(j=0;j<acc;j++) for(j=0;j<acc;j++){
if(info->booklist[j]>=ci->books)goto errout; if(info->booklist[j]>=ci->books)goto errout;
if(ci->book_param[info->booklist[j]]->maptype==0)goto errout;
}
/* verify the phrasebook is not specifying an impossible or
inconsistent partitioning scheme. */
/* modify the phrasebook ranging check from r16327; an early beta
encoder had a bug where it used an oversized phrasebook by
accident. These files should continue to be playable, but don't
allow an exploit */
{
int entries = ci->book_param[info->groupbook]->entries;
int dim = ci->book_param[info->groupbook]->dim;
int partvals = 1;
if (dim<1) goto errout;
while(dim>0){
partvals *= info->partitions;
if(partvals > entries) goto errout;
dim--;
}
info->partvals = partvals;
}
return(info); return(info);
errout: errout:
@ -263,7 +299,10 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
} }
} }
look->partvals=rint(pow((float)look->parts,(float)dim)); look->partvals=1;
for(j=0;j<dim;j++)
look->partvals*=look->parts;
look->stages=maxstage; look->stages=maxstage;
look->decodemap=_ogg_malloc(look->partvals*sizeof(*look->decodemap)); look->decodemap=_ogg_malloc(look->partvals*sizeof(*look->decodemap));
for(j=0;j<look->partvals;j++){ for(j=0;j<look->partvals;j++){
@ -287,65 +326,71 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,
} }
/* break an abstraction and copy some code for performance purposes */ /* break an abstraction and copy some code for performance purposes */
static int local_book_besterror(codebook *book,float *a){ static int local_book_besterror(codebook *book,int *a){
int dim=book->dim,i,k,o; int dim=book->dim;
int best=0; int i,j,o;
encode_aux_threshmatch *tt=book->c->thresh_tree; int minval=book->minval;
int del=book->delta;
int qv=book->quantvals;
int ze=(qv>>1);
int index=0;
/* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */
int p[8]={0,0,0,0,0,0,0,0};
/* find the quant val of each scalar */ if(del!=1){
for(k=0,o=dim;k<dim;++k){ for(i=0,o=dim;i<dim;i++){
float val=a[--o]; int v = (a[--o]-minval+(del>>1))/del;
i=tt->threshvals>>1; int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1));
index = index*qv+ (m<0?0:(m>=qv?qv-1:m));
if(val<tt->quantthresh[i]){ p[o]=v*del+minval;
if(val<tt->quantthresh[i-1]){
for(--i;i>0;--i)
if(val>=tt->quantthresh[i-1])
break;
} }
}else{ }else{
for(i=0,o=dim;i<dim;i++){
for(++i;i<tt->threshvals-1;++i) int v = a[--o]-minval;
if(val<tt->quantthresh[i])break; int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1));
index = index*qv+ (m<0?0:(m>=qv?qv-1:m));
p[o]=v*del+minval;
}
} }
best=(best*tt->quantvals)+tt->quantmap[i]; if(book->c->lengthlist[index]<=0){
}
/* regular lattices are easy :-) */
if(book->c->lengthlist[best]<=0){
const static_codebook *c=book->c; const static_codebook *c=book->c;
int i,j; int best=-1;
float bestf=0.f; /* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */
float *e=book->valuelist; int e[8]={0,0,0,0,0,0,0,0};
best=-1; int maxval = book->minval + book->delta*(book->quantvals-1);
for(i=0;i<book->entries;i++){ for(i=0;i<book->entries;i++){
if(c->lengthlist[i]>0){ if(c->lengthlist[i]>0){
float this=0.f; int this=0;
for(j=0;j<dim;j++){ for(j=0;j<dim;j++){
float val=(e[j]-a[j]); int val=(e[j]-a[j]);
this+=val*val; this+=val*val;
} }
if(best==-1 || this<bestf){ if(best==-1 || this<best){
bestf=this; memcpy(p,e,sizeof(p));
best=i; best=this;
index=i;
} }
} }
e+=dim; /* assumes the value patterning created by the tools in vq/ */
j=0;
while(e[j]>=maxval)
e[j++]=0;
if(e[j]>=0)
e[j]+=book->delta;
e[j]= -e[j];
} }
} }
if(best>-1){ if(index>-1){
float *ptr=book->valuelist+best*dim;
for(i=0;i<dim;i++) for(i=0;i<dim;i++)
*a++ -= *ptr++; *a++ -= p[i];
} }
return(best); return(index);
} }
static int _encodepart(oggpack_buffer *opb,float *vec, int n, static int _encodepart(oggpack_buffer *opb,int *vec, int n,
codebook *book,long *acc){ codebook *book,long *acc){
int i,bits=0; int i,bits=0;
int dim=book->dim; int dim=book->dim;
@ -355,7 +400,7 @@ static int _encodepart(oggpack_buffer *opb,float *vec, int n,
int entry=local_book_besterror(book,vec+i*dim); int entry=local_book_besterror(book,vec+i*dim);
#ifdef TRAIN_RES #ifdef TRAIN_RES
if(entry>0) if(entry>=0)
acc[entry]++; acc[entry]++;
#endif #endif
@ -367,12 +412,10 @@ static int _encodepart(oggpack_buffer *opb,float *vec, int n,
} }
static long **_01class(vorbis_block *vb,vorbis_look_residue *vl, static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int ch){ int **in,int ch){
long i,j,k; long i,j,k;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info; vorbis_info_residue0 *info=look->info;
vorbis_info *vi=vb->vd->vi;
codec_setup_info *ci=vi->codec_setup;
/* move all this setup out later */ /* move all this setup out later */
int samples_per_partition=info->grouping; int samples_per_partition=info->grouping;
@ -395,17 +438,17 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
for(i=0;i<partvals;i++){ for(i=0;i<partvals;i++){
int offset=i*samples_per_partition+info->begin; int offset=i*samples_per_partition+info->begin;
for(j=0;j<ch;j++){ for(j=0;j<ch;j++){
float max=0.; int max=0;
float ent=0.; int ent=0;
for(k=0;k<samples_per_partition;k++){ for(k=0;k<samples_per_partition;k++){
if(fabs(in[j][offset+k])>max)max=fabs(in[j][offset+k]); if(abs(in[j][offset+k])>max)max=abs(in[j][offset+k]);
ent+=fabs(rint(in[j][offset+k])); ent+=abs(in[j][offset+k]);
} }
ent*=scale; ent*=scale;
for(k=0;k<possible_partitions-1;k++) for(k=0;k<possible_partitions-1;k++)
if(max<=info->classmetric1[k] && if(max<=info->classmetric1[k] &&
(info->classmetric2[k]<0 || (int)ent<info->classmetric2[k])) (info->classmetric2[k]<0 || ent<info->classmetric2[k]))
break; break;
partword[j][i]=k; partword[j][i]=k;
@ -435,7 +478,7 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl,
/* designed for stereo or other modes where the partition size is an /* designed for stereo or other modes where the partition size is an
integer multiple of the number of channels encoded in the current integer multiple of the number of channels encoded in the current
submap */ submap */
static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in, static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in,
int ch){ int ch){
long i,j,k,l; long i,j,k,l;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
@ -454,16 +497,16 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in,
char buffer[80]; char buffer[80];
#endif #endif
partword[0]=_vorbis_block_alloc(vb,n*ch/samples_per_partition*sizeof(*partword[0])); partword[0]=_vorbis_block_alloc(vb,partvals*sizeof(*partword[0]));
memset(partword[0],0,n*ch/samples_per_partition*sizeof(*partword[0])); memset(partword[0],0,partvals*sizeof(*partword[0]));
for(i=0,l=info->begin/ch;i<partvals;i++){ for(i=0,l=info->begin/ch;i<partvals;i++){
float magmax=0.f; int magmax=0;
float angmax=0.f; int angmax=0;
for(j=0;j<samples_per_partition;j+=ch){ for(j=0;j<samples_per_partition;j+=ch){
if(fabs(in[0][l])>magmax)magmax=fabs(in[0][l]); if(abs(in[0][l])>magmax)magmax=abs(in[0][l]);
for(k=1;k<ch;k++) for(k=1;k<ch;k++)
if(fabs(in[k][l])>angmax)angmax=fabs(in[k][l]); if(abs(in[k][l])>angmax)angmax=abs(in[k][l]);
l++; l++;
} }
@ -492,15 +535,18 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in,
static int _01forward(oggpack_buffer *opb, static int _01forward(oggpack_buffer *opb,
vorbis_block *vb,vorbis_look_residue *vl, vorbis_block *vb,vorbis_look_residue *vl,
float **in,int ch, int **in,int ch,
long **partword, long **partword,
int (*encode)(oggpack_buffer *,float *,int, int (*encode)(oggpack_buffer *,int *,int,
codebook *,long *)){ codebook *,long *),
int submap){
long i,j,k,s; long i,j,k,s;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info; vorbis_info_residue0 *info=look->info;
vorbis_dsp_state *vd=vb->vd; #ifdef TRAIN_RES
look->submap=submap;
#endif
/* move all this setup out later */ /* move all this setup out later */
int samples_per_partition=info->grouping; int samples_per_partition=info->grouping;
@ -514,7 +560,7 @@ static int _01forward(oggpack_buffer *opb,
#ifdef TRAIN_RES #ifdef TRAIN_RES
for(i=0;i<ch;i++) for(i=0;i<ch;i++)
for(j=info->begin;j<end;j++){ for(j=info->begin;j<info->end;j++){
if(in[i][j]>look->tmax)look->tmax=in[i][j]; if(in[i][j]>look->tmax)look->tmax=in[i][j];
if(in[i][j]<look->tmin)look->tmin=in[i][j]; if(in[i][j]<look->tmin)look->tmin=in[i][j];
} }
@ -569,7 +615,7 @@ static int _01forward(oggpack_buffer *opb,
accumulator=look->training_data[s][partword[j][i]]; accumulator=look->training_data[s][partword[j][i]];
{ {
int l; int l;
float *samples=in[j]+offset; int *samples=in[j]+offset;
for(l=0;l<samples_per_partition;l++){ for(l=0;l<samples_per_partition;l++){
if(samples[l]<look->training_min[s][partword[j][i]]) if(samples[l]<look->training_min[s][partword[j][i]])
look->training_min[s][partword[j][i]]=samples[l]; look->training_min[s][partword[j][i]]=samples[l];
@ -642,7 +688,7 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
for(j=0;j<ch;j++){ for(j=0;j<ch;j++){
int temp=vorbis_book_decode(look->phrasebook,&vb->opb); int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
if(temp==-1)goto eopbreak; if(temp==-1 || temp>=info->partvals)goto eopbreak;
partword[j][l]=look->decodemap[temp]; partword[j][l]=look->decodemap[temp];
if(partword[j][l]==NULL)goto errout; if(partword[j][l]==NULL)goto errout;
} }
@ -668,54 +714,6 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
return(0); return(0);
} }
#if 0
/* residue 0 and 1 are just slight variants of one another. 0 is
interleaved, 1 is not */
long **res0_class(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int *nonzero,int ch){
/* we encode only the nonzero parts of a bundle */
int i,used=0;
for(i=0;i<ch;i++)
if(nonzero[i])
in[used++]=in[i];
if(used)
/*return(_01class(vb,vl,in,used,_interleaved_testhack));*/
return(_01class(vb,vl,in,used));
else
return(0);
}
int res0_forward(vorbis_block *vb,vorbis_look_residue *vl,
float **in,float **out,int *nonzero,int ch,
long **partword){
/* we encode only the nonzero parts of a bundle */
int i,j,used=0,n=vb->pcmend/2;
for(i=0;i<ch;i++)
if(nonzero[i]){
if(out)
for(j=0;j<n;j++)
out[i][j]+=in[i][j];
in[used++]=in[i];
}
if(used){
int ret=_01forward(vb,vl,in,used,partword,
_interleaved_encodepart);
if(out){
used=0;
for(i=0;i<ch;i++)
if(nonzero[i]){
for(j=0;j<n;j++)
out[i][j]-=in[used][j];
used++;
}
}
return(ret);
}else{
return(0);
}
}
#endif
int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int *nonzero,int ch){ float **in,int *nonzero,int ch){
int i,used=0; int i,used=0;
@ -729,36 +727,21 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
} }
int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl, int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl,
float **in,float **out,int *nonzero,int ch, int **in,int *nonzero,int ch, long **partword, int submap){
long **partword){ int i,used=0;
int i,j,used=0,n=vb->pcmend/2;
for(i=0;i<ch;i++) for(i=0;i<ch;i++)
if(nonzero[i]){ if(nonzero[i])
if(out)
for(j=0;j<n;j++)
out[i][j]+=in[i][j];
in[used++]=in[i]; in[used++]=in[i];
}
if(used){ if(used){
int ret=_01forward(opb,vb,vl,in,used,partword,_encodepart); return _01forward(opb,vb,vl,in,used,partword,_encodepart,submap);
if(out){
used=0;
for(i=0;i<ch;i++)
if(nonzero[i]){
for(j=0;j<n;j++)
out[i][j]-=in[used][j];
used++;
}
}
return(ret);
}else{ }else{
return(0); return(0);
} }
} }
long **res1_class(vorbis_block *vb,vorbis_look_residue *vl, long **res1_class(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int *nonzero,int ch){ int **in,int *nonzero,int ch){
int i,used=0; int i,used=0;
for(i=0;i<ch;i++) for(i=0;i<ch;i++)
if(nonzero[i]) if(nonzero[i])
@ -782,7 +765,7 @@ int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
} }
long **res2_class(vorbis_block *vb,vorbis_look_residue *vl, long **res2_class(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int *nonzero,int ch){ int **in,int *nonzero,int ch){
int i,used=0; int i,used=0;
for(i=0;i<ch;i++) for(i=0;i<ch;i++)
if(nonzero[i])used++; if(nonzero[i])used++;
@ -797,34 +780,22 @@ long **res2_class(vorbis_block *vb,vorbis_look_residue *vl,
int res2_forward(oggpack_buffer *opb, int res2_forward(oggpack_buffer *opb,
vorbis_block *vb,vorbis_look_residue *vl, vorbis_block *vb,vorbis_look_residue *vl,
float **in,float **out,int *nonzero,int ch, int **in,int *nonzero,int ch, long **partword,int submap){
long **partword){
long i,j,k,n=vb->pcmend/2,used=0; long i,j,k,n=vb->pcmend/2,used=0;
/* don't duplicate the code; use a working vector hack for now and /* don't duplicate the code; use a working vector hack for now and
reshape ourselves into a single channel res1 */ reshape ourselves into a single channel res1 */
/* ugly; reallocs for each coupling pass :-( */ /* ugly; reallocs for each coupling pass :-( */
float *work=_vorbis_block_alloc(vb,ch*n*sizeof(*work)); int *work=_vorbis_block_alloc(vb,ch*n*sizeof(*work));
for(i=0;i<ch;i++){ for(i=0;i<ch;i++){
float *pcm=in[i]; int *pcm=in[i];
if(nonzero[i])used++; if(nonzero[i])used++;
for(j=0,k=i;j<n;j++,k+=ch) for(j=0,k=i;j<n;j++,k+=ch)
work[k]=pcm[j]; work[k]=pcm[j];
} }
if(used){ if(used){
int ret=_01forward(opb,vb,vl,&work,1,partword,_encodepart); return _01forward(opb,vb,vl,&work,1,partword,_encodepart,submap);
/* update the sofar vector */
if(out){
for(i=0;i<ch;i++){
float *pcm=in[i];
float *sofar=out[i];
for(j=0,k=i;j<n;j++,k+=ch)
sofar[j]+=pcm[j]-work[k];
}
}
return(ret);
}else{ }else{
return(0); return(0);
} }
@ -858,7 +829,7 @@ int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
if(s==0){ if(s==0){
/* fetch the partition word */ /* fetch the partition word */
int temp=vorbis_book_decode(look->phrasebook,&vb->opb); int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
if(temp==-1)goto eopbreak; if(temp==-1 || temp>=info->partvals)goto eopbreak;
partword[l]=look->decodemap[temp]; partword[l]=look->decodemap[temp];
if(partword[l]==NULL)goto errout; if(partword[l]==NULL)goto errout;
} }
@ -884,7 +855,7 @@ int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
} }
vorbis_func_residue residue0_exportbundle={ const vorbis_func_residue residue0_exportbundle={
NULL, NULL,
&res0_unpack, &res0_unpack,
&res0_look, &res0_look,
@ -895,7 +866,7 @@ vorbis_func_residue residue0_exportbundle={
&res0_inverse &res0_inverse
}; };
vorbis_func_residue residue1_exportbundle={ const vorbis_func_residue residue1_exportbundle={
&res0_pack, &res0_pack,
&res0_unpack, &res0_unpack,
&res0_look, &res0_look,
@ -906,7 +877,7 @@ vorbis_func_residue residue1_exportbundle={
&res1_inverse &res1_inverse
}; };
vorbis_func_residue residue2_exportbundle={ const vorbis_func_residue residue2_exportbundle={
&res0_pack, &res0_pack,
&res0_unpack, &res0_unpack,
&res0_look, &res0_look,
@ -916,4 +887,3 @@ vorbis_func_residue residue2_exportbundle={
&res2_forward, &res2_forward,
&res2_inverse &res2_inverse
}; };

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: linear scale -> dB, Bark and Mel scales function: linear scale -> dB, Bark and Mel scales
last mod: $Id: scales.h 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: scales.h 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -21,11 +21,16 @@
#include <math.h> #include <math.h>
#include "os.h" #include "os.h"
#ifdef _MSC_VER
/* MS Visual Studio doesn't have C99 inline keyword. */
#define inline __inline
#endif
/* 20log10(x) */ /* 20log10(x) */
#define VORBIS_IEEE_FLOAT32 1 #define VORBIS_IEEE_FLOAT32 1
#ifdef VORBIS_IEEE_FLOAT32 #ifdef VORBIS_IEEE_FLOAT32
static float unitnorm(float x){ static inline float unitnorm(float x){
union { union {
ogg_uint32_t i; ogg_uint32_t i;
float f; float f;
@ -36,7 +41,7 @@ static float unitnorm(float x){
} }
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */ /* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */
static float todB(const float *x){ static inline float todB(const float *x){
union { union {
ogg_uint32_t i; ogg_uint32_t i;
float f; float f;
@ -83,4 +88,3 @@ static float unitnorm(float x){
#define fromOC(o) (exp(((o)+5.965784f)*.693147f)) #define fromOC(o) (exp(((o)+5.965784f)*.693147f))
#endif #endif

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: basic shared codebook operations function: basic shared codebook operations
last mod: $Id: sharedbook.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: sharedbook.c 17030 2010-03-25 06:52:55Z xiphmont $
********************************************************************/ ********************************************************************/
@ -52,7 +52,7 @@ long _float32_pack(float val){
sign=0x80000000; sign=0x80000000;
val= -val; val= -val;
} }
exp= floor(log(val)/log(2.f)); exp= floor(log(val)/log(2.f)+.001); //+epsilon
mant=rint(ldexp(val,(VQ_FMAN-1)-exp)); mant=rint(ldexp(val,(VQ_FMAN-1)-exp));
exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN; exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN;
@ -125,6 +125,19 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
if(sparsecount==0)count++; if(sparsecount==0)count++;
} }
/* sanity check the huffman tree; an underpopulated tree must be
rejected. The only exception is the one-node pseudo-nil tree,
which appears to be underpopulated because the tree doesn't
really exist; there's only one possible 'codeword' or zero bits,
but the above tree-gen code doesn't mark that. */
if(sparsecount != 1){
for(i=1;i<33;i++)
if(marker[i] & (0xffffffffUL>>(32-i))){
_ogg_free(r);
return(NULL);
}
}
/* bitreverse the words because our bitwise packer/unpacker is LSb /* bitreverse the words because our bitwise packer/unpacker is LSb
endian */ endian */
for(i=0,count=0;i<n;i++){ for(i=0,count=0;i<n;i++){
@ -245,34 +258,13 @@ float *_book_unquantize(const static_codebook *b,int n,int *sparsemap){
return(NULL); return(NULL);
} }
void vorbis_staticbook_clear(static_codebook *b){ void vorbis_staticbook_destroy(static_codebook *b){
if(b->allocedp){ if(b->allocedp){
if(b->quantlist)_ogg_free(b->quantlist); if(b->quantlist)_ogg_free(b->quantlist);
if(b->lengthlist)_ogg_free(b->lengthlist); if(b->lengthlist)_ogg_free(b->lengthlist);
if(b->nearest_tree){
_ogg_free(b->nearest_tree->ptr0);
_ogg_free(b->nearest_tree->ptr1);
_ogg_free(b->nearest_tree->p);
_ogg_free(b->nearest_tree->q);
memset(b->nearest_tree,0,sizeof(*b->nearest_tree));
_ogg_free(b->nearest_tree);
}
if(b->thresh_tree){
_ogg_free(b->thresh_tree->quantthresh);
_ogg_free(b->thresh_tree->quantmap);
memset(b->thresh_tree,0,sizeof(*b->thresh_tree));
_ogg_free(b->thresh_tree);
}
memset(b,0,sizeof(*b)); memset(b,0,sizeof(*b));
}
}
void vorbis_staticbook_destroy(static_codebook *b){
if(b->allocedp){
vorbis_staticbook_clear(b);
_ogg_free(b); _ogg_free(b);
} } /* otherwise, it is in static memory */
} }
void vorbis_book_clear(codebook *b){ void vorbis_book_clear(codebook *b){
@ -296,7 +288,10 @@ int vorbis_book_init_encode(codebook *c,const static_codebook *s){
c->used_entries=s->entries; c->used_entries=s->entries;
c->dim=s->dim; c->dim=s->dim;
c->codelist=_make_words(s->lengthlist,s->entries,0); c->codelist=_make_words(s->lengthlist,s->entries,0);
c->valuelist=_book_unquantize(s,s->entries,NULL); //c->valuelist=_book_unquantize(s,s->entries,NULL);
c->quantvals=_book_maptype1_quantvals(s);
c->minval=(int)rint(_float32_unpack(s->q_min));
c->delta=(int)rint(_float32_unpack(s->q_delta));
return(0); return(0);
} }
@ -432,157 +427,6 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
return(-1); return(-1);
} }
static float _dist(int el,float *ref, float *b,int step){
int i;
float acc=0.f;
for(i=0;i<el;i++){
float val=(ref[i]-b[i*step]);
acc+=val*val;
}
return(acc);
}
int _best(codebook *book, float *a, int step){
encode_aux_threshmatch *tt=book->c->thresh_tree;
#if 0
encode_aux_nearestmatch *nt=book->c->nearest_tree;
encode_aux_pigeonhole *pt=book->c->pigeon_tree;
#endif
int dim=book->dim;
int k,o;
/*int savebest=-1;
float saverr;*/
/* do we have a threshhold encode hint? */
if(tt){
int index=0,i;
/* find the quant val of each scalar */
for(k=0,o=step*(dim-1);k<dim;k++,o-=step){
i=tt->threshvals>>1;
if(a[o]<tt->quantthresh[i]){
for(;i>0;i--)
if(a[o]>=tt->quantthresh[i-1])
break;
}else{
for(i++;i<tt->threshvals-1;i++)
if(a[o]<tt->quantthresh[i])break;
}
index=(index*tt->quantvals)+tt->quantmap[i];
}
/* regular lattices are easy :-) */
if(book->c->lengthlist[index]>0) /* is this unused? If so, we'll
use a decision tree after all
and fall through*/
return(index);
}
#if 0
/* do we have a pigeonhole encode hint? */
if(pt){
const static_codebook *c=book->c;
int i,besti=-1;
float best=0.f;
int entry=0;
/* dealing with sequentialness is a pain in the ass */
if(c->q_sequencep){
int pv;
long mul=1;
float qlast=0;
for(k=0,o=0;k<dim;k++,o+=step){
pv=(int)((a[o]-qlast-pt->min)/pt->del);
if(pv<0 || pv>=pt->mapentries)break;
entry+=pt->pigeonmap[pv]*mul;
mul*=pt->quantvals;
qlast+=pv*pt->del+pt->min;
}
}else{
for(k=0,o=step*(dim-1);k<dim;k++,o-=step){
int pv=(int)((a[o]-pt->min)/pt->del);
if(pv<0 || pv>=pt->mapentries)break;
entry=entry*pt->quantvals+pt->pigeonmap[pv];
}
}
/* must be within the pigeonholable range; if we quant outside (or
in an entry that we define no list for), brute force it */
if(k==dim && pt->fitlength[entry]){
/* search the abbreviated list */
long *list=pt->fitlist+pt->fitmap[entry];
for(i=0;i<pt->fitlength[entry];i++){
float this=_dist(dim,book->valuelist+list[i]*dim,a,step);
if(besti==-1 || this<best){
best=this;
besti=list[i];
}
}
return(besti);
}
}
if(nt){
/* optimized using the decision tree */
while(1){
float c=0.f;
float *p=book->valuelist+nt->p[ptr];
float *q=book->valuelist+nt->q[ptr];
for(k=0,o=0;k<dim;k++,o+=step)
c+=(p[k]-q[k])*(a[o]-(p[k]+q[k])*.5);
if(c>0.f) /* in A */
ptr= -nt->ptr0[ptr];
else /* in B */
ptr= -nt->ptr1[ptr];
if(ptr<=0)break;
}
return(-ptr);
}
#endif
/* brute force it! */
{
const static_codebook *c=book->c;
int i,besti=-1;
float best=0.f;
float *e=book->valuelist;
for(i=0;i<book->entries;i++){
if(c->lengthlist[i]>0){
float this=_dist(dim,e,a,step);
if(besti==-1 || this<best){
best=this;
besti=i;
}
}
e+=dim;
}
/*if(savebest!=-1 && savebest!=besti){
fprintf(stderr,"brute force/pigeonhole disagreement:\n"
"original:");
for(i=0;i<dim*step;i+=step)fprintf(stderr,"%g,",a[i]);
fprintf(stderr,"\n"
"pigeonhole (entry %d, err %g):",savebest,saverr);
for(i=0;i<dim;i++)fprintf(stderr,"%g,",
(book->valuelist+savebest*dim)[i]);
fprintf(stderr,"\n"
"bruteforce (entry %d, err %g):",besti,best);
for(i=0;i<dim;i++)fprintf(stderr,"%g,",
(book->valuelist+besti*dim)[i]);
fprintf(stderr,"\n");
}*/
return(besti);
}
}
long vorbis_book_codeword(codebook *book,int entry){ long vorbis_book_codeword(codebook *book,int entry){
if(book->c) /* only use with encode; decode optimizations are if(book->c) /* only use with encode; decode optimizations are
allowed to break this */ allowed to break this */
@ -625,7 +469,7 @@ static_codebook test1={
0, 0,
0,0,0,0, 0,0,0,0,
NULL, NULL,
NULL,NULL 0
}; };
static float *test1_result=NULL; static float *test1_result=NULL;
@ -636,7 +480,7 @@ static_codebook test2={
2, 2,
-533200896,1611661312,4,0, -533200896,1611661312,4,0,
full_quantlist1, full_quantlist1,
NULL,NULL 0
}; };
static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2}; static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2};
@ -647,7 +491,7 @@ static_codebook test3={
2, 2,
-533200896,1611661312,4,1, -533200896,1611661312,4,1,
full_quantlist1, full_quantlist1,
NULL,NULL 0
}; };
static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6}; static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6};
@ -658,7 +502,7 @@ static_codebook test4={
1, 1,
-533200896,1611661312,4,0, -533200896,1611661312,4,0,
partial_quantlist1, partial_quantlist1,
NULL,NULL 0
}; };
static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3, static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3,
-3, 4,-3, 4, 4,-3, -1, 4,-3, -3, 4,-3, 4, 4,-3, -1, 4,-3,
@ -677,7 +521,7 @@ static_codebook test5={
1, 1,
-533200896,1611661312,4,1, -533200896,1611661312,4,1,
partial_quantlist1, partial_quantlist1,
NULL,NULL 0
}; };
static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7, static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7,
-3, 1,-2, 4, 8, 5, -1, 3, 0, -3, 1,-2, 4, 8, 5, -1, 3, 0,

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: *unnormalized* fft transform function: *unnormalized* fft transform
last mod: $Id: smallft.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: smallft.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: single-block PCM synthesis function: single-block PCM synthesis
last mod: $Id: synthesis.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: synthesis.c 17474 2010-09-30 03:41:41Z gmaxwell $
********************************************************************/ ********************************************************************/
@ -24,13 +24,17 @@
#include "os.h" #include "os.h"
int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
vorbis_dsp_state *vd=vb->vd; vorbis_dsp_state *vd= vb ? vb->vd : 0;
private_state *b=vd->backend_state; private_state *b= vd ? vd->backend_state : 0;
vorbis_info *vi=vd->vi; vorbis_info *vi= vd ? vd->vi : 0;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci= vi ? vi->codec_setup : 0;
oggpack_buffer *opb=&vb->opb; oggpack_buffer *opb=vb ? &vb->opb : 0;
int type,mode,i; int type,mode,i;
if (!vd || !b || !vi || !ci || !opb) {
return OV_EBADPACKET;
}
/* first things first. Make sure decode is ready */ /* first things first. Make sure decode is ready */
_vorbis_block_ripcord(vb); _vorbis_block_ripcord(vb);
oggpack_readinit(opb,op->packet,op->bytes); oggpack_readinit(opb,op->packet,op->bytes);
@ -43,9 +47,15 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
/* read our mode and pre/post windowsize */ /* read our mode and pre/post windowsize */
mode=oggpack_read(opb,b->modebits); mode=oggpack_read(opb,b->modebits);
if(mode==-1)return(OV_EBADPACKET); if(mode==-1){
return(OV_EBADPACKET);
}
vb->mode=mode; vb->mode=mode;
if(!ci->mode_param[mode]){
return(OV_EBADPACKET);
}
vb->W=ci->mode_param[mode]->blockflag; vb->W=ci->mode_param[mode]->blockflag;
if(vb->W){ if(vb->W){
@ -53,7 +63,9 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
only for window selection */ only for window selection */
vb->lW=oggpack_read(opb,1); vb->lW=oggpack_read(opb,1);
vb->nW=oggpack_read(opb,1); vb->nW=oggpack_read(opb,1);
if(vb->nW==-1) return(OV_EBADPACKET); if(vb->nW==-1){
return(OV_EBADPACKET);
}
}else{ }else{
vb->lW=0; vb->lW=0;
vb->nW=0; vb->nW=0;
@ -102,6 +114,10 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
if(mode==-1)return(OV_EBADPACKET); if(mode==-1)return(OV_EBADPACKET);
vb->mode=mode; vb->mode=mode;
if(!ci->mode_param[mode]){
return(OV_EBADPACKET);
}
vb->W=ci->mode_param[mode]->blockflag; vb->W=ci->mode_param[mode]->blockflag;
if(vb->W){ if(vb->W){
vb->lW=oggpack_read(opb,1); vb->lW=oggpack_read(opb,1);
@ -166,5 +182,3 @@ int vorbis_synthesis_halfrate_p(vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
return ci->halfrate_flag; return ci->halfrate_flag;
} }

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: simple programmatic interface for encoder mode setup function: simple programmatic interface for encoder mode setup
last mod: $Id: vorbisenc.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: vorbisenc.c 17028 2010-03-25 05:22:15Z xiphmont $
********************************************************************/ ********************************************************************/
@ -32,22 +32,23 @@
with > 12 partition types, or a different division of iteration, with > 12 partition types, or a different division of iteration,
this needs to be updated. */ this needs to be updated. */
typedef struct { typedef struct {
static_codebook *books[12][3]; const static_codebook *books[12][4];
} static_bookblock; } static_bookblock;
typedef struct { typedef struct {
int res_type; int res_type;
int limit_type; /* 0 lowpass limited, 1 point stereo limited */ int limit_type; /* 0 lowpass limited, 1 point stereo limited */
vorbis_info_residue0 *res; int grouping;
static_codebook *book_aux; const vorbis_info_residue0 *res;
static_codebook *book_aux_managed; const static_codebook *book_aux;
static_bookblock *books_base; const static_codebook *book_aux_managed;
static_bookblock *books_base_managed; const static_bookblock *books_base;
const static_bookblock *books_base_managed;
} vorbis_residue_template; } vorbis_residue_template;
typedef struct { typedef struct {
vorbis_info_mapping0 *map; const vorbis_info_mapping0 *map;
vorbis_residue_template *res; const vorbis_residue_template *res;
} vorbis_mapping_template; } vorbis_mapping_template;
typedef struct vp_adjblock{ typedef struct vp_adjblock{
@ -90,69 +91,70 @@ typedef struct {
typedef struct { typedef struct {
int mappings; int mappings;
double *rate_mapping; const double *rate_mapping;
double *quality_mapping; const double *quality_mapping;
int coupling_restriction; int coupling_restriction;
long samplerate_min_restriction; long samplerate_min_restriction;
long samplerate_max_restriction; long samplerate_max_restriction;
int *blocksize_short; const int *blocksize_short;
int *blocksize_long; const int *blocksize_long;
att3 *psy_tone_masteratt; const att3 *psy_tone_masteratt;
int *psy_tone_0dB; const int *psy_tone_0dB;
int *psy_tone_dBsuppress; const int *psy_tone_dBsuppress;
vp_adjblock *psy_tone_adj_impulse; const vp_adjblock *psy_tone_adj_impulse;
vp_adjblock *psy_tone_adj_long; const vp_adjblock *psy_tone_adj_long;
vp_adjblock *psy_tone_adj_other; const vp_adjblock *psy_tone_adj_other;
noiseguard *psy_noiseguards; const noiseguard *psy_noiseguards;
noise3 *psy_noise_bias_impulse; const noise3 *psy_noise_bias_impulse;
noise3 *psy_noise_bias_padding; const noise3 *psy_noise_bias_padding;
noise3 *psy_noise_bias_trans; const noise3 *psy_noise_bias_trans;
noise3 *psy_noise_bias_long; const noise3 *psy_noise_bias_long;
int *psy_noise_dBsuppress; const int *psy_noise_dBsuppress;
compandblock *psy_noise_compand; const compandblock *psy_noise_compand;
double *psy_noise_compand_short_mapping; const double *psy_noise_compand_short_mapping;
double *psy_noise_compand_long_mapping; const double *psy_noise_compand_long_mapping;
int *psy_noise_normal_start[2]; const int *psy_noise_normal_start[2];
int *psy_noise_normal_partition[2]; const int *psy_noise_normal_partition[2];
double *psy_noise_normal_thresh; const double *psy_noise_normal_thresh;
int *psy_ath_float; const int *psy_ath_float;
int *psy_ath_abs; const int *psy_ath_abs;
double *psy_lowpass; const double *psy_lowpass;
vorbis_info_psy_global *global_params; const vorbis_info_psy_global *global_params;
double *global_mapping; const double *global_mapping;
adj_stereo *stereo_modes; const adj_stereo *stereo_modes;
static_codebook ***floor_books; const static_codebook *const *const *const floor_books;
vorbis_info_floor1 *floor_params; const vorbis_info_floor1 *floor_params;
int *floor_short_mapping; const int floor_mappings;
int *floor_long_mapping; const int **floor_mapping_list;
vorbis_mapping_template *maps; const vorbis_mapping_template *maps;
} ve_setup_data_template; } ve_setup_data_template;
/* a few static coder conventions */ /* a few static coder conventions */
static vorbis_info_mode _mode_template[2]={ static const vorbis_info_mode _mode_template[2]={
{0,0,0,0}, {0,0,0,0},
{1,0,0,1} {1,0,0,1}
}; };
static vorbis_info_mapping0 _map_nominal[2]={ static const vorbis_info_mapping0 _map_nominal[2]={
{1, {0,0}, {0}, {0}, 1,{0},{1}}, {1, {0,0}, {0}, {0}, 1,{0},{1}},
{1, {0,0}, {1}, {1}, 1,{0},{1}} {1, {0,0}, {1}, {1}, 1,{0},{1}}
}; };
#include "modes/setup_44.h" #include "modes/setup_44.h"
#include "modes/setup_44u.h" #include "modes/setup_44u.h"
#include "modes/setup_44p51.h"
#include "modes/setup_32.h" #include "modes/setup_32.h"
#include "modes/setup_8.h" #include "modes/setup_8.h"
#include "modes/setup_11.h" #include "modes/setup_11.h"
@ -160,8 +162,9 @@ static vorbis_info_mapping0 _map_nominal[2]={
#include "modes/setup_22.h" #include "modes/setup_22.h"
#include "modes/setup_X.h" #include "modes/setup_X.h"
static ve_setup_data_template *setup_list[]={ static const ve_setup_data_template *const setup_list[]={
&ve_setup_44_stereo, &ve_setup_44_stereo,
&ve_setup_44_51,
&ve_setup_44_uncoupled, &ve_setup_44_uncoupled,
&ve_setup_32_stereo, &ve_setup_32_stereo,
@ -184,29 +187,15 @@ static ve_setup_data_template *setup_list[]={
0 0
}; };
static int vorbis_encode_toplevel_setup(vorbis_info *vi,int ch,long rate){ static void vorbis_encode_floor_setup(vorbis_info *vi,int s,
if(vi && vi->codec_setup){ const static_codebook *const *const *const books,
const vorbis_info_floor1 *in,
vi->version=0; const int *x){
vi->channels=ch;
vi->rate=rate;
return(0);
}
return(OV_EINVAL);
}
static void vorbis_encode_floor_setup(vorbis_info *vi,double s,int block,
static_codebook ***books,
vorbis_info_floor1 *in,
int *x){
int i,k,is=s; int i,k,is=s;
vorbis_info_floor1 *f=_ogg_calloc(1,sizeof(*f)); vorbis_info_floor1 *f=_ogg_calloc(1,sizeof(*f));
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
memcpy(f,in+x[is],sizeof(*f)); memcpy(f,in+x[is],sizeof(*f));
/* fill in the lowpass field, even if it's temporary */
f->n=ci->blocksizes[block]>>1;
/* books */ /* books */
{ {
@ -225,7 +214,7 @@ static void vorbis_encode_floor_setup(vorbis_info *vi,double s,int block,
} }
for(i=0;i<=maxbook;i++) for(i=0;i<=maxbook;i++)
ci->book_param[ci->books++]=books[x[is]][i]; ci->book_param[ci->books++]=(static_codebook *)books[x[is]][i];
} }
/* for now, we're only using floor 1 */ /* for now, we're only using floor 1 */
@ -237,8 +226,8 @@ static void vorbis_encode_floor_setup(vorbis_info *vi,double s,int block,
} }
static void vorbis_encode_global_psych_setup(vorbis_info *vi,double s, static void vorbis_encode_global_psych_setup(vorbis_info *vi,double s,
vorbis_info_psy_global *in, const vorbis_info_psy_global *in,
double *x){ const double *x){
int i,is=s; int i,is=s;
double ds=s-is; double ds=s-is;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
@ -264,8 +253,8 @@ static void vorbis_encode_global_psych_setup(vorbis_info *vi,double s,
} }
static void vorbis_encode_global_stereo(vorbis_info *vi, static void vorbis_encode_global_stereo(vorbis_info *vi,
highlevel_encode_setup *hi, const highlevel_encode_setup *const hi,
adj_stereo *p){ const adj_stereo *p){
float s=hi->stereo_point_setting; float s=hi->stereo_point_setting;
int i,is=s; int i,is=s;
double ds=s-is; double ds=s-is;
@ -313,9 +302,9 @@ static void vorbis_encode_global_stereo(vorbis_info *vi,
} }
static void vorbis_encode_psyset_setup(vorbis_info *vi,double s, static void vorbis_encode_psyset_setup(vorbis_info *vi,double s,
int *nn_start, const int *nn_start,
int *nn_partition, const int *nn_partition,
double *nn_thresh, const double *nn_thresh,
int block){ int block){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
vorbis_info_psy *p=ci->psy_param[block]; vorbis_info_psy *p=ci->psy_param[block];
@ -333,8 +322,7 @@ static void vorbis_encode_psyset_setup(vorbis_info *vi,double s,
p->blockflag=block>>1; p->blockflag=block>>1;
if(hi->noise_normalize_p){ if(hi->noise_normalize_p){
p->normal_channel_p=1; p->normal_p=1;
p->normal_point_p=1;
p->normal_start=nn_start[is]; p->normal_start=nn_start[is];
p->normal_partition=nn_partition[is]; p->normal_partition=nn_partition[is];
p->normal_thresh=nn_thresh[is]; p->normal_thresh=nn_thresh[is];
@ -344,9 +332,9 @@ static void vorbis_encode_psyset_setup(vorbis_info *vi,double s,
} }
static void vorbis_encode_tonemask_setup(vorbis_info *vi,double s,int block, static void vorbis_encode_tonemask_setup(vorbis_info *vi,double s,int block,
att3 *att, const att3 *att,
int *max, const int *max,
vp_adjblock *in){ const vp_adjblock *in){
int i,is=s; int i,is=s;
double ds=s-is; double ds=s-is;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
@ -369,7 +357,8 @@ static void vorbis_encode_tonemask_setup(vorbis_info *vi,double s,int block,
static void vorbis_encode_compand_setup(vorbis_info *vi,double s,int block, static void vorbis_encode_compand_setup(vorbis_info *vi,double s,int block,
compandblock *in, double *x){ const compandblock *in,
const double *x){
int i,is=s; int i,is=s;
double ds=s-is; double ds=s-is;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
@ -390,7 +379,7 @@ static void vorbis_encode_compand_setup(vorbis_info *vi,double s,int block,
} }
static void vorbis_encode_peak_setup(vorbis_info *vi,double s,int block, static void vorbis_encode_peak_setup(vorbis_info *vi,double s,int block,
int *suppress){ const int *suppress){
int is=s; int is=s;
double ds=s-is; double ds=s-is;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
@ -402,9 +391,9 @@ static void vorbis_encode_peak_setup(vorbis_info *vi,double s,int block,
} }
static void vorbis_encode_noisebias_setup(vorbis_info *vi,double s,int block, static void vorbis_encode_noisebias_setup(vorbis_info *vi,double s,int block,
int *suppress, const int *suppress,
noise3 *in, const noise3 *in,
noiseguard *guard, const noiseguard *guard,
double userbias){ double userbias){
int i,is=s,j; int i,is=s,j;
double ds=s-is; double ds=s-is;
@ -443,7 +432,7 @@ static void vorbis_encode_ath_setup(vorbis_info *vi,int block){
} }
static int book_dup_or_new(codec_setup_info *ci,static_codebook *book){ static int book_dup_or_new(codec_setup_info *ci,const static_codebook *book){
int i; int i;
for(i=0;i<ci->books;i++) for(i=0;i<ci->books;i++)
if(ci->book_param[i]==book)return(i); if(ci->book_param[i]==book)return(i);
@ -452,7 +441,7 @@ static int book_dup_or_new(codec_setup_info *ci,static_codebook *book){
} }
static void vorbis_encode_blocksize_setup(vorbis_info *vi,double s, static void vorbis_encode_blocksize_setup(vorbis_info *vi,double s,
int *shortb,int *longb){ const int *shortb,const int *longb){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
int is=s; int is=s;
@ -466,10 +455,10 @@ static void vorbis_encode_blocksize_setup(vorbis_info *vi,double s,
static void vorbis_encode_residue_setup(vorbis_info *vi, static void vorbis_encode_residue_setup(vorbis_info *vi,
int number, int block, int number, int block,
vorbis_residue_template *res){ const vorbis_residue_template *res){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
int i,n; int i;
vorbis_info_residue0 *r=ci->residue_param[number]= vorbis_info_residue0 *r=ci->residue_param[number]=
_ogg_malloc(sizeof(*r)); _ogg_malloc(sizeof(*r));
@ -477,40 +466,28 @@ static void vorbis_encode_residue_setup(vorbis_info *vi,
memcpy(r,res->res,sizeof(*r)); memcpy(r,res->res,sizeof(*r));
if(ci->residues<=number)ci->residues=number+1; if(ci->residues<=number)ci->residues=number+1;
switch(ci->blocksizes[block]){ r->grouping=res->grouping;
case 64:case 128:case 256:
r->grouping=16;
break;
default:
r->grouping=32;
break;
}
ci->residue_type[number]=res->res_type; ci->residue_type[number]=res->res_type;
/* to be adjusted by lowpass/pointlimit later */
n=r->end=ci->blocksizes[block]>>1;
if(res->res_type==2)
n=r->end*=vi->channels;
/* fill in all the books */ /* fill in all the books */
{ {
int booklist=0,k; int booklist=0,k;
if(ci->hi.managed){ if(ci->hi.managed){
for(i=0;i<r->partitions;i++) for(i=0;i<r->partitions;i++)
for(k=0;k<3;k++) for(k=0;k<4;k++)
if(res->books_base_managed->books[i][k]) if(res->books_base_managed->books[i][k])
r->secondstages[i]|=(1<<k); r->secondstages[i]|=(1<<k);
r->groupbook=book_dup_or_new(ci,res->book_aux_managed); r->groupbook=book_dup_or_new(ci,res->book_aux_managed);
ci->book_param[r->groupbook]=res->book_aux_managed; ci->book_param[r->groupbook]=(static_codebook *)res->book_aux_managed;
for(i=0;i<r->partitions;i++){ for(i=0;i<r->partitions;i++){
for(k=0;k<3;k++){ for(k=0;k<4;k++){
if(res->books_base_managed->books[i][k]){ if(res->books_base_managed->books[i][k]){
int bookid=book_dup_or_new(ci,res->books_base_managed->books[i][k]); int bookid=book_dup_or_new(ci,res->books_base_managed->books[i][k]);
r->booklist[booklist++]=bookid; r->booklist[booklist++]=bookid;
ci->book_param[bookid]=res->books_base_managed->books[i][k]; ci->book_param[bookid]=(static_codebook *)res->books_base_managed->books[i][k];
} }
} }
} }
@ -518,19 +495,19 @@ static void vorbis_encode_residue_setup(vorbis_info *vi,
}else{ }else{
for(i=0;i<r->partitions;i++) for(i=0;i<r->partitions;i++)
for(k=0;k<3;k++) for(k=0;k<4;k++)
if(res->books_base->books[i][k]) if(res->books_base->books[i][k])
r->secondstages[i]|=(1<<k); r->secondstages[i]|=(1<<k);
r->groupbook=book_dup_or_new(ci,res->book_aux); r->groupbook=book_dup_or_new(ci,res->book_aux);
ci->book_param[r->groupbook]=res->book_aux; ci->book_param[r->groupbook]=(static_codebook *)res->book_aux;
for(i=0;i<r->partitions;i++){ for(i=0;i<r->partitions;i++){
for(k=0;k<3;k++){ for(k=0;k<4;k++){
if(res->books_base->books[i][k]){ if(res->books_base->books[i][k]){
int bookid=book_dup_or_new(ci,res->books_base->books[i][k]); int bookid=book_dup_or_new(ci,res->books_base->books[i][k]);
r->booklist[booklist++]=bookid; r->booklist[booklist++]=bookid;
ci->book_param[bookid]=res->books_base->books[i][k]; ci->book_param[bookid]=(static_codebook *)res->books_base->books[i][k];
} }
} }
} }
@ -553,36 +530,70 @@ static void vorbis_encode_residue_setup(vorbis_info *vi,
/* this res may by limited by the maximum pointlimit of the mode, /* this res may by limited by the maximum pointlimit of the mode,
not the lowpass. the floor is always lowpass limited. */ not the lowpass. the floor is always lowpass limited. */
if(res->limit_type){ switch(res->limit_type){
case 1: /* point stereo limited */
if(ci->hi.managed) if(ci->hi.managed)
freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS-1]*1000.; freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS-1]*1000.;
else else
freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS/2]*1000.; freq=ci->psy_g_param.coupling_pkHz[PACKETBLOBS/2]*1000.;
if(freq>nyq)freq=nyq; if(freq>nyq)freq=nyq;
break;
case 2: /* LFE channel; lowpass at ~ 250Hz */
freq=250;
break;
default:
/* already set */
break;
} }
/* in the residue, we're constrained, physically, by partition /* in the residue, we're constrained, physically, by partition
boundaries. We still lowpass 'wherever', but we have to round up boundaries. We still lowpass 'wherever', but we have to round up
here to next boundary, or the vorbis spec will round it *down* to here to next boundary, or the vorbis spec will round it *down* to
previous boundary in encode/decode */ previous boundary in encode/decode */
if(ci->residue_type[block]==2) if(ci->residue_type[number]==2){
r->end=(int)((freq/nyq*blocksize*2)/r->grouping+.9)* /* round up only if we're well past */ /* residue 2 bundles together multiple channels; used by stereo
and surround. Count the channels in use */
/* Multiple maps/submaps can point to the same residue. In the case
of residue 2, they all better have the same number of
channels/samples. */
int j,k,ch=0;
for(i=0;i<ci->maps&&ch==0;i++){
vorbis_info_mapping0 *mi=(vorbis_info_mapping0 *)ci->map_param[i];
for(j=0;j<mi->submaps && ch==0;j++)
if(mi->residuesubmap[j]==number) /* we found a submap referencing theis residue backend */
for(k=0;k<vi->channels;k++)
if(mi->chmuxlist[k]==j) /* this channel belongs to the submap */
ch++;
}
r->end=(int)((freq/nyq*blocksize*ch)/r->grouping+.9)* /* round up only if we're well past */
r->grouping; r->grouping;
else /* the blocksize and grouping may disagree at the end */
if(r->end>blocksize*ch)r->end=blocksize*ch/r->grouping*r->grouping;
}else{
r->end=(int)((freq/nyq*blocksize)/r->grouping+.9)* /* round up only if we're well past */ r->end=(int)((freq/nyq*blocksize)/r->grouping+.9)* /* round up only if we're well past */
r->grouping; r->grouping;
/* the blocksize and grouping may disagree at the end */
if(r->end>blocksize)r->end=blocksize/r->grouping*r->grouping;
}
if(r->end==0)r->end=r->grouping; /* LFE channel */
} }
} }
/* we assume two maps in this encoder */ /* we assume two maps in this encoder */
static void vorbis_encode_map_n_res_setup(vorbis_info *vi,double s, static void vorbis_encode_map_n_res_setup(vorbis_info *vi,double s,
vorbis_mapping_template *maps){ const vorbis_mapping_template *maps){
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
int i,j,is=s,modes=2; int i,j,is=s,modes=2;
vorbis_info_mapping0 *map=maps[is].map; const vorbis_info_mapping0 *map=maps[is].map;
vorbis_info_mode *mode=_mode_template; const vorbis_info_mode *mode=_mode_template;
vorbis_residue_template *res=maps[is].res; const vorbis_residue_template *res=maps[is].res;
if(ci->blocksizes[0]==ci->blocksizes[1])modes=1; if(ci->blocksizes[0]==ci->blocksizes[1])modes=1;
@ -611,7 +622,7 @@ static double setting_to_approx_bitrate(vorbis_info *vi){
int is=hi->base_setting; int is=hi->base_setting;
double ds=hi->base_setting-is; double ds=hi->base_setting-is;
int ch=vi->channels; int ch=vi->channels;
double *r=setup->rate_mapping; const double *r=setup->rate_mapping;
if(r==NULL) if(r==NULL)
return(-1); return(-1);
@ -619,12 +630,10 @@ static double setting_to_approx_bitrate(vorbis_info *vi){
return((r[is]*(1.-ds)+r[is+1]*ds)*ch); return((r[is]*(1.-ds)+r[is+1]*ds)*ch);
} }
static void get_setup_template(vorbis_info *vi, static const void *get_setup_template(long ch,long srate,
long ch,long srate, double req,int q_or_bitrate,
double req,int q_or_bitrate){ double *base_setting){
int i=0,j; int i=0,j;
codec_setup_info *ci=vi->codec_setup;
highlevel_encode_setup *hi=&ci->hi;
if(q_or_bitrate)req/=ch; if(q_or_bitrate)req/=ch;
while(setup_list[i]){ while(setup_list[i]){
@ -633,7 +642,7 @@ static void get_setup_template(vorbis_info *vi,
if(srate>=setup_list[i]->samplerate_min_restriction && if(srate>=setup_list[i]->samplerate_min_restriction &&
srate<=setup_list[i]->samplerate_max_restriction){ srate<=setup_list[i]->samplerate_max_restriction){
int mappings=setup_list[i]->mappings; int mappings=setup_list[i]->mappings;
double *map=(q_or_bitrate? const double *map=(q_or_bitrate?
setup_list[i]->rate_mapping: setup_list[i]->rate_mapping:
setup_list[i]->quality_mapping); setup_list[i]->quality_mapping);
@ -644,23 +653,22 @@ static void get_setup_template(vorbis_info *vi,
for(j=0;j<mappings;j++) for(j=0;j<mappings;j++)
if(req>=map[j] && req<map[j+1])break; if(req>=map[j] && req<map[j+1])break;
/* an all-points match */ /* an all-points match */
hi->setup=setup_list[i];
if(j==mappings) if(j==mappings)
hi->base_setting=j-.001; *base_setting=j-.001;
else{ else{
float low=map[j]; float low=map[j];
float high=map[j+1]; float high=map[j+1];
float del=(req-low)/(high-low); float del=(req-low)/(high-low);
hi->base_setting=j+del; *base_setting=j+del;
} }
return; return(setup_list[i]);
} }
} }
i++; i++;
} }
hi->setup=NULL; return NULL;
} }
/* encoders will need to use vorbis_info_init beforehand and call /* encoders will need to use vorbis_info_init beforehand and call
@ -671,7 +679,7 @@ static void get_setup_template(vorbis_info *vi,
/* the final setup call */ /* the final setup call */
int vorbis_encode_setup_init(vorbis_info *vi){ int vorbis_encode_setup_init(vorbis_info *vi){
int i0=0,singleblock=0; int i,i0=0,singleblock=0;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
ve_setup_data_template *setup=NULL; ve_setup_data_template *setup=NULL;
highlevel_encode_setup *hi=&ci->hi; highlevel_encode_setup *hi=&ci->hi;
@ -704,16 +712,12 @@ int vorbis_encode_setup_init(vorbis_info *vi){
if(ci->blocksizes[0]==ci->blocksizes[1])singleblock=1; if(ci->blocksizes[0]==ci->blocksizes[1])singleblock=1;
/* floor setup; choose proper floor params. Allocated on the floor /* floor setup; choose proper floor params. Allocated on the floor
stack in order; if we alloc only long floor, it's 0 */ stack in order; if we alloc only a single long floor, it's 0 */
vorbis_encode_floor_setup(vi,hi->short_setting,0, for(i=0;i<setup->floor_mappings;i++)
vorbis_encode_floor_setup(vi,hi->base_setting,
setup->floor_books, setup->floor_books,
setup->floor_params, setup->floor_params,
setup->floor_short_mapping); setup->floor_mapping_list[i]);
if(!singleblock)
vorbis_encode_floor_setup(vi,hi->long_setting,1,
setup->floor_books,
setup->floor_params,
setup->floor_long_mapping);
/* setup of [mostly] short block detection and stereo*/ /* setup of [mostly] short block detection and stereo*/
vorbis_encode_global_psych_setup(vi,hi->trigger_setting, vorbis_encode_global_psych_setup(vi,hi->trigger_setting,
@ -722,23 +726,23 @@ int vorbis_encode_setup_init(vorbis_info *vi){
vorbis_encode_global_stereo(vi,hi,setup->stereo_modes); vorbis_encode_global_stereo(vi,hi,setup->stereo_modes);
/* basic psych setup and noise normalization */ /* basic psych setup and noise normalization */
vorbis_encode_psyset_setup(vi,hi->short_setting, vorbis_encode_psyset_setup(vi,hi->base_setting,
setup->psy_noise_normal_start[0], setup->psy_noise_normal_start[0],
setup->psy_noise_normal_partition[0], setup->psy_noise_normal_partition[0],
setup->psy_noise_normal_thresh, setup->psy_noise_normal_thresh,
0); 0);
vorbis_encode_psyset_setup(vi,hi->short_setting, vorbis_encode_psyset_setup(vi,hi->base_setting,
setup->psy_noise_normal_start[0], setup->psy_noise_normal_start[0],
setup->psy_noise_normal_partition[0], setup->psy_noise_normal_partition[0],
setup->psy_noise_normal_thresh, setup->psy_noise_normal_thresh,
1); 1);
if(!singleblock){ if(!singleblock){
vorbis_encode_psyset_setup(vi,hi->long_setting, vorbis_encode_psyset_setup(vi,hi->base_setting,
setup->psy_noise_normal_start[1], setup->psy_noise_normal_start[1],
setup->psy_noise_normal_partition[1], setup->psy_noise_normal_partition[1],
setup->psy_noise_normal_thresh, setup->psy_noise_normal_thresh,
2); 2);
vorbis_encode_psyset_setup(vi,hi->long_setting, vorbis_encode_psyset_setup(vi,hi->base_setting,
setup->psy_noise_normal_start[1], setup->psy_noise_normal_start[1],
setup->psy_noise_normal_partition[1], setup->psy_noise_normal_partition[1],
setup->psy_noise_normal_thresh, setup->psy_noise_normal_thresh,
@ -854,30 +858,28 @@ int vorbis_encode_setup_init(vorbis_info *vi){
} }
static int vorbis_encode_setup_setting(vorbis_info *vi, static void vorbis_encode_setup_setting(vorbis_info *vi,
long channels, long channels,
long rate){ long rate){
int ret=0,i,is; int i,is;
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
highlevel_encode_setup *hi=&ci->hi; highlevel_encode_setup *hi=&ci->hi;
ve_setup_data_template *setup=hi->setup; const ve_setup_data_template *setup=hi->setup;
double ds; double ds;
ret=vorbis_encode_toplevel_setup(vi,channels,rate); vi->version=0;
if(ret)return(ret); vi->channels=channels;
vi->rate=rate;
is=hi->base_setting;
ds=hi->base_setting-is;
hi->short_setting=hi->base_setting;
hi->long_setting=hi->base_setting;
hi->managed=0;
hi->impulse_block_p=1; hi->impulse_block_p=1;
hi->noise_normalize_p=1; hi->noise_normalize_p=1;
is=hi->base_setting;
ds=hi->base_setting-is;
hi->stereo_point_setting=hi->base_setting; hi->stereo_point_setting=hi->base_setting;
if(!hi->lowpass_altered)
hi->lowpass_kHz= hi->lowpass_kHz=
setup->psy_lowpass[is]*(1.-ds)+setup->psy_lowpass[is+1]*ds; setup->psy_lowpass[is]*(1.-ds)+setup->psy_lowpass[is+1]*ds;
@ -895,8 +897,6 @@ static int vorbis_encode_setup_setting(vorbis_info *vi,
hi->block[i].noise_bias_setting=hi->base_setting; hi->block[i].noise_bias_setting=hi->base_setting;
hi->block[i].noise_compand_setting=hi->base_setting; hi->block[i].noise_compand_setting=hi->base_setting;
} }
return(ret);
} }
int vorbis_encode_setup_vbr(vorbis_info *vi, int vorbis_encode_setup_vbr(vorbis_info *vi,
@ -909,10 +909,15 @@ int vorbis_encode_setup_vbr(vorbis_info *vi,
quality+=.0000001; quality+=.0000001;
if(quality>=1.)quality=.9999; if(quality>=1.)quality=.9999;
get_setup_template(vi,channels,rate,quality,0); hi->req=quality;
hi->setup=get_setup_template(channels,rate,quality,0,&hi->base_setting);
if(!hi->setup)return OV_EIMPL; if(!hi->setup)return OV_EIMPL;
return vorbis_encode_setup_setting(vi,channels,rate); vorbis_encode_setup_setting(vi,channels,rate);
hi->managed=0;
hi->coupling_p=1;
return 0;
} }
int vorbis_encode_init_vbr(vorbis_info *vi, int vorbis_encode_init_vbr(vorbis_info *vi,
@ -946,7 +951,6 @@ int vorbis_encode_setup_managed(vorbis_info *vi,
codec_setup_info *ci=vi->codec_setup; codec_setup_info *ci=vi->codec_setup;
highlevel_encode_setup *hi=&ci->hi; highlevel_encode_setup *hi=&ci->hi;
double tnominal=nominal_bitrate; double tnominal=nominal_bitrate;
int ret=0;
if(nominal_bitrate<=0.){ if(nominal_bitrate<=0.){
if(max_bitrate>0.){ if(max_bitrate>0.){
@ -963,16 +967,14 @@ int vorbis_encode_setup_managed(vorbis_info *vi,
} }
} }
get_setup_template(vi,channels,rate,nominal_bitrate,1); hi->req=nominal_bitrate;
hi->setup=get_setup_template(channels,rate,nominal_bitrate,1,&hi->base_setting);
if(!hi->setup)return OV_EIMPL; if(!hi->setup)return OV_EIMPL;
ret=vorbis_encode_setup_setting(vi,channels,rate); vorbis_encode_setup_setting(vi,channels,rate);
if(ret){
vorbis_info_clear(vi);
return ret;
}
/* initialize management with sane defaults */ /* initialize management with sane defaults */
hi->coupling_p=1;
hi->managed=1; hi->managed=1;
hi->bitrate_min=min_bitrate; hi->bitrate_min=min_bitrate;
hi->bitrate_max=max_bitrate; hi->bitrate_max=max_bitrate;
@ -981,7 +983,7 @@ int vorbis_encode_setup_managed(vorbis_info *vi,
hi->bitrate_reservoir=nominal_bitrate*2; hi->bitrate_reservoir=nominal_bitrate*2;
hi->bitrate_reservoir_bias=.1; /* bias toward hoarding bits */ hi->bitrate_reservoir_bias=.1; /* bias toward hoarding bits */
return(ret); return(0);
} }
@ -1158,6 +1160,7 @@ int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg){
if(hi->lowpass_kHz<2.)hi->lowpass_kHz=2.; if(hi->lowpass_kHz<2.)hi->lowpass_kHz=2.;
if(hi->lowpass_kHz>99.)hi->lowpass_kHz=99.; if(hi->lowpass_kHz>99.)hi->lowpass_kHz=99.;
hi->lowpass_altered=1;
} }
return(0); return(0);
case OV_ECTL_IBLOCK_GET: case OV_ECTL_IBLOCK_GET:
@ -1175,9 +1178,37 @@ int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg){
if(hi->impulse_noisetune<-15.)hi->impulse_noisetune=-15.; if(hi->impulse_noisetune<-15.)hi->impulse_noisetune=-15.;
} }
return(0); return(0);
case OV_ECTL_COUPLING_GET:
{
int *iarg=(int *)arg;
*iarg=hi->coupling_p;
} }
return(0);
case OV_ECTL_COUPLING_SET:
{
const void *new_template;
double new_base=0.;
int *iarg=(int *)arg;
hi->coupling_p=((*iarg)!=0);
/* Fetching a new template can alter the base_setting, which
many other parameters are based on. Right now, the only
parameter drawn from the base_setting that can be altered
by an encctl is the lowpass, so that is explictly flagged
to not be overwritten when we fetch a new template and
recompute the dependant settings */
new_template = get_setup_template(hi->coupling_p?vi->channels:-1,
vi->rate,
hi->req,
hi->managed,
&new_base);
if(!hi->setup)return OV_EIMPL;
hi->setup=new_template;
hi->base_setting=new_base;
vorbis_encode_setup_setting(vi,vi->channels,vi->rate);
}
return(0);
}
return(OV_EIMPL); return(OV_EIMPL);
} }
return(OV_EINVAL); return(OV_EINVAL);

File diff suppressed because it is too large Load diff

View file

@ -5,13 +5,13 @@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* * * *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 *
* by the Xiph.Org Foundation http://www.xiph.org/ * * by the Xiph.Org Foundation http://www.xiph.org/ *
* * * *
******************************************************************** ********************************************************************
function: window functions function: window functions
last mod: $Id: window.c 13293 2007-07-24 00:09:47Z xiphmont $ last mod: $Id: window.c 16227 2009-07-08 06:58:46Z xiphmont $
********************************************************************/ ********************************************************************/
@ -20,7 +20,7 @@
#include "os.h" #include "os.h"
#include "misc.h" #include "misc.h"
static float vwin64[32] = { static const float vwin64[32] = {
0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F, 0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F,
0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F, 0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F,
0.2551056759F, 0.3122276645F, 0.3724270287F, 0.4346027792F, 0.2551056759F, 0.3122276645F, 0.3724270287F, 0.4346027792F,
@ -31,7 +31,7 @@ static float vwin64[32] = {
0.9989462667F, 0.9997230082F, 0.9999638688F, 0.9999995525F, 0.9989462667F, 0.9997230082F, 0.9999638688F, 0.9999995525F,
}; };
static float vwin128[64] = { static const float vwin128[64] = {
0.0002365472F, 0.0021280687F, 0.0059065254F, 0.0115626550F, 0.0002365472F, 0.0021280687F, 0.0059065254F, 0.0115626550F,
0.0190823442F, 0.0284463735F, 0.0396300935F, 0.0526030430F, 0.0190823442F, 0.0284463735F, 0.0396300935F, 0.0526030430F,
0.0673285281F, 0.0837631763F, 0.1018564887F, 0.1215504095F, 0.0673285281F, 0.0837631763F, 0.1018564887F, 0.1215504095F,
@ -50,7 +50,7 @@ static float vwin128[64] = {
0.9999331503F, 0.9999825563F, 0.9999977357F, 0.9999999720F, 0.9999331503F, 0.9999825563F, 0.9999977357F, 0.9999999720F,
}; };
static float vwin256[128] = { static const float vwin256[128] = {
0.0000591390F, 0.0005321979F, 0.0014780301F, 0.0028960636F, 0.0000591390F, 0.0005321979F, 0.0014780301F, 0.0028960636F,
0.0047854363F, 0.0071449926F, 0.0099732775F, 0.0132685298F, 0.0047854363F, 0.0071449926F, 0.0099732775F, 0.0132685298F,
0.0170286741F, 0.0212513119F, 0.0259337111F, 0.0310727950F, 0.0170286741F, 0.0212513119F, 0.0259337111F, 0.0310727950F,
@ -85,7 +85,7 @@ static float vwin256[128] = {
0.9999958064F, 0.9999989077F, 0.9999998584F, 0.9999999983F, 0.9999958064F, 0.9999989077F, 0.9999998584F, 0.9999999983F,
}; };
static float vwin512[256] = { static const float vwin512[256] = {
0.0000147849F, 0.0001330607F, 0.0003695946F, 0.0007243509F, 0.0000147849F, 0.0001330607F, 0.0003695946F, 0.0007243509F,
0.0011972759F, 0.0017882983F, 0.0024973285F, 0.0033242588F, 0.0011972759F, 0.0017882983F, 0.0024973285F, 0.0033242588F,
0.0042689632F, 0.0053312973F, 0.0065110982F, 0.0078081841F, 0.0042689632F, 0.0053312973F, 0.0065110982F, 0.0078081841F,
@ -152,7 +152,7 @@ static float vwin512[256] = {
0.9999997377F, 0.9999999317F, 0.9999999911F, 0.9999999999F, 0.9999997377F, 0.9999999317F, 0.9999999911F, 0.9999999999F,
}; };
static float vwin1024[512] = { static const float vwin1024[512] = {
0.0000036962F, 0.0000332659F, 0.0000924041F, 0.0001811086F, 0.0000036962F, 0.0000332659F, 0.0000924041F, 0.0001811086F,
0.0002993761F, 0.0004472021F, 0.0006245811F, 0.0008315063F, 0.0002993761F, 0.0004472021F, 0.0006245811F, 0.0008315063F,
0.0010679699F, 0.0013339631F, 0.0016294757F, 0.0019544965F, 0.0010679699F, 0.0013339631F, 0.0016294757F, 0.0019544965F,
@ -283,7 +283,7 @@ static float vwin1024[512] = {
0.9999999836F, 0.9999999957F, 0.9999999994F, 1.0000000000F, 0.9999999836F, 0.9999999957F, 0.9999999994F, 1.0000000000F,
}; };
static float vwin2048[1024] = { static const float vwin2048[1024] = {
0.0000009241F, 0.0000083165F, 0.0000231014F, 0.0000452785F, 0.0000009241F, 0.0000083165F, 0.0000231014F, 0.0000452785F,
0.0000748476F, 0.0001118085F, 0.0001561608F, 0.0002079041F, 0.0000748476F, 0.0001118085F, 0.0001561608F, 0.0002079041F,
0.0002670379F, 0.0003335617F, 0.0004074748F, 0.0004887765F, 0.0002670379F, 0.0003335617F, 0.0004074748F, 0.0004887765F,
@ -542,7 +542,7 @@ static float vwin2048[1024] = {
0.9999999990F, 0.9999999997F, 1.0000000000F, 1.0000000000F, 0.9999999990F, 0.9999999997F, 1.0000000000F, 1.0000000000F,
}; };
static float vwin4096[2048] = { static const float vwin4096[2048] = {
0.0000002310F, 0.0000020791F, 0.0000057754F, 0.0000113197F, 0.0000002310F, 0.0000020791F, 0.0000057754F, 0.0000113197F,
0.0000187121F, 0.0000279526F, 0.0000390412F, 0.0000519777F, 0.0000187121F, 0.0000279526F, 0.0000390412F, 0.0000519777F,
0.0000667623F, 0.0000833949F, 0.0001018753F, 0.0001222036F, 0.0000667623F, 0.0000833949F, 0.0001018753F, 0.0001222036F,
@ -1057,7 +1057,7 @@ static float vwin4096[2048] = {
0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F,
}; };
static float vwin8192[4096] = { static const float vwin8192[4096] = {
0.0000000578F, 0.0000005198F, 0.0000014438F, 0.0000028299F, 0.0000000578F, 0.0000005198F, 0.0000014438F, 0.0000028299F,
0.0000046780F, 0.0000069882F, 0.0000097604F, 0.0000129945F, 0.0000046780F, 0.0000069882F, 0.0000097604F, 0.0000129945F,
0.0000166908F, 0.0000208490F, 0.0000254692F, 0.0000305515F, 0.0000166908F, 0.0000208490F, 0.0000254692F, 0.0000305515F,
@ -2084,7 +2084,7 @@ static float vwin8192[4096] = {
1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F,
}; };
static float *vwin[8] = { static const float *const vwin[8] = {
vwin64, vwin64,
vwin128, vwin128,
vwin256, vwin256,
@ -2095,7 +2095,7 @@ static float *vwin[8] = {
vwin8192, vwin8192,
}; };
float *_vorbis_window_get(int n){ const float *_vorbis_window_get(int n){
return vwin[n]; return vwin[n];
} }
@ -2105,8 +2105,8 @@ void _vorbis_apply_window(float *d,int *winno,long *blocksizes,
nW=(W?nW:0); nW=(W?nW:0);
{ {
float *windowLW=vwin[winno[lW]]; const float *windowLW=vwin[winno[lW]];
float *windowNW=vwin[winno[nW]]; const float *windowNW=vwin[winno[nW]];
long n=blocksizes[W]; long n=blocksizes[W];
long ln=blocksizes[lW]; long ln=blocksizes[lW];
@ -2133,4 +2133,3 @@ void _vorbis_apply_window(float *d,int *winno,long *blocksizes,
d[i]=0.f; d[i]=0.f;
} }
} }