libFLAC: 1.3.1 -> 1.3.3
This commit is contained in:
parent
ffd9c39d1c
commit
e55ee7fafd
60 changed files with 3034 additions and 2689 deletions
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -176,7 +176,7 @@
|
|||
* #endif
|
||||
* \endcode
|
||||
*
|
||||
* The the source will work for multiple versions and the legacy code can
|
||||
* The source will work for multiple versions and the legacy code can
|
||||
* easily be removed when the transition is complete.
|
||||
*
|
||||
* Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in
|
||||
|
@ -321,7 +321,7 @@
|
|||
*
|
||||
* The \a bytes parameter to FLAC__StreamDecoderReadCallback,
|
||||
* FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback
|
||||
* is now \c size_t instead of \c unsigned.
|
||||
* is now \c size_t instead of \c uint32_t.
|
||||
*/
|
||||
|
||||
/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -34,7 +34,7 @@
|
|||
#define FLAC__ASSERT_H
|
||||
|
||||
/* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */
|
||||
#ifdef DEBUG
|
||||
#ifndef NDEBUG
|
||||
#include <assert.h>
|
||||
#define FLAC__ASSERT(x) assert(x)
|
||||
#define FLAC__ASSERT_DECLARATION(x) x
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -165,7 +165,7 @@ typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle);
|
|||
* required may be set to NULL.
|
||||
*
|
||||
* If the seek requirement for an interface is optional, you can signify that
|
||||
* a data sorce is not seekable by setting the \a seek field to \c NULL.
|
||||
* a data source is not seekable by setting the \a seek field to \c NULL.
|
||||
*/
|
||||
typedef struct {
|
||||
FLAC__IOCallback_Read read;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -173,10 +173,10 @@ extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */
|
|||
/** The 32-bit integer big-endian representation of the beginning of
|
||||
* a FLAC stream.
|
||||
*/
|
||||
extern FLAC_API const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_SYNC; /* = 0x664C6143 */
|
||||
|
||||
/** The length of the FLAC signature in bits. */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN; /* = 32 bits */
|
||||
|
||||
/** The length of the FLAC signature in bytes. */
|
||||
#define FLAC__STREAM_SYNC_LENGTH (4u)
|
||||
|
@ -213,15 +213,15 @@ extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
|
|||
*/
|
||||
typedef struct {
|
||||
|
||||
unsigned *parameters;
|
||||
uint32_t *parameters;
|
||||
/**< The Rice parameters for each context. */
|
||||
|
||||
unsigned *raw_bits;
|
||||
uint32_t *raw_bits;
|
||||
/**< Widths for escape-coded partitions. Will be non-zero for escaped
|
||||
* partitions and zero for unescaped partitions.
|
||||
*/
|
||||
|
||||
unsigned capacity_by_order;
|
||||
uint32_t capacity_by_order;
|
||||
/**< The capacity of the \a parameters and \a raw_bits arrays
|
||||
* specified as an order, i.e. the number of array elements
|
||||
* allocated is 2 ^ \a capacity_by_order.
|
||||
|
@ -232,7 +232,7 @@ typedef struct {
|
|||
*/
|
||||
typedef struct {
|
||||
|
||||
unsigned order;
|
||||
uint32_t order;
|
||||
/**< The partition order, i.e. # of contexts = 2 ^ \a order. */
|
||||
|
||||
const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
|
||||
|
@ -240,14 +240,14 @@ typedef struct {
|
|||
|
||||
} FLAC__EntropyCodingMethod_PartitionedRice;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */
|
||||
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
|
||||
/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER;
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER;
|
||||
/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
|
||||
|
||||
/** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>)
|
||||
|
@ -259,7 +259,7 @@ typedef struct {
|
|||
} data;
|
||||
} FLAC__EntropyCodingMethod;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -299,7 +299,7 @@ typedef struct {
|
|||
FLAC__EntropyCodingMethod entropy_coding_method;
|
||||
/**< The residual coding method. */
|
||||
|
||||
unsigned order;
|
||||
uint32_t order;
|
||||
/**< The polynomial order. */
|
||||
|
||||
FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
|
||||
|
@ -316,10 +316,10 @@ typedef struct {
|
|||
FLAC__EntropyCodingMethod entropy_coding_method;
|
||||
/**< The residual coding method. */
|
||||
|
||||
unsigned order;
|
||||
uint32_t order;
|
||||
/**< The FIR order. */
|
||||
|
||||
unsigned qlp_coeff_precision;
|
||||
uint32_t qlp_coeff_precision;
|
||||
/**< Quantized FIR filter coefficient precision in bits. */
|
||||
|
||||
int quantization_level;
|
||||
|
@ -335,8 +335,8 @@ typedef struct {
|
|||
/**< The residual signal, length == (blocksize minus order) samples. */
|
||||
} FLAC__Subframe_LPC;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */
|
||||
|
||||
|
||||
/** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>)
|
||||
|
@ -349,7 +349,7 @@ typedef struct {
|
|||
FLAC__Subframe_LPC lpc;
|
||||
FLAC__Subframe_Verbatim verbatim;
|
||||
} data;
|
||||
unsigned wasted_bits;
|
||||
uint32_t wasted_bits;
|
||||
} FLAC__Subframe;
|
||||
|
||||
/** == 1 (bit)
|
||||
|
@ -359,14 +359,14 @@ typedef struct {
|
|||
* mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1
|
||||
* to mean something else.
|
||||
*/
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN;
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN;
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */
|
||||
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */
|
||||
extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */
|
||||
extern FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -409,19 +409,19 @@ extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
|
|||
/** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>)
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned blocksize;
|
||||
uint32_t blocksize;
|
||||
/**< The number of samples per subframe. */
|
||||
|
||||
unsigned sample_rate;
|
||||
uint32_t sample_rate;
|
||||
/**< The sample rate in Hz. */
|
||||
|
||||
unsigned channels;
|
||||
uint32_t channels;
|
||||
/**< The number of channels (== number of subframes). */
|
||||
|
||||
FLAC__ChannelAssignment channel_assignment;
|
||||
/**< The channel assignment for the frame. */
|
||||
|
||||
unsigned bits_per_sample;
|
||||
uint32_t bits_per_sample;
|
||||
/**< The sample resolution. */
|
||||
|
||||
FLAC__FrameNumberType number_type;
|
||||
|
@ -443,16 +443,16 @@ typedef struct {
|
|||
*/
|
||||
} FLAC__FrameHeader;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */
|
||||
|
||||
|
||||
/** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>)
|
||||
|
@ -465,7 +465,7 @@ typedef struct {
|
|||
*/
|
||||
} FLAC__FrameFooter;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */
|
||||
|
||||
|
||||
/** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>)
|
||||
|
@ -512,8 +512,8 @@ typedef enum {
|
|||
FLAC__METADATA_TYPE_UNDEFINED = 7,
|
||||
/**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
|
||||
|
||||
FLAC__MAX_METADATA_TYPE = FLAC__MAX_METADATA_TYPE_CODE,
|
||||
/**< No type will ever be greater than this. There is not enough room in the protocol block. */
|
||||
FLAC__MAX_METADATA_TYPE = FLAC__MAX_METADATA_TYPE_CODE,
|
||||
/**< No type will ever be greater than this. There is not enough room in the protocol block. */
|
||||
} FLAC__MetadataType;
|
||||
|
||||
/** Maps a FLAC__MetadataType to a C string.
|
||||
|
@ -527,24 +527,24 @@ extern FLAC_API const char * const FLAC__MetadataTypeString[];
|
|||
/** FLAC STREAMINFO structure. (c.f. <A HREF="../format.html#metadata_block_streaminfo">format specification</A>)
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned min_blocksize, max_blocksize;
|
||||
unsigned min_framesize, max_framesize;
|
||||
unsigned sample_rate;
|
||||
unsigned channels;
|
||||
unsigned bits_per_sample;
|
||||
uint32_t min_blocksize, max_blocksize;
|
||||
uint32_t min_framesize, max_framesize;
|
||||
uint32_t sample_rate;
|
||||
uint32_t channels;
|
||||
uint32_t bits_per_sample;
|
||||
FLAC__uint64 total_samples;
|
||||
FLAC__byte md5sum[16];
|
||||
} FLAC__StreamMetadata_StreamInfo;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */
|
||||
|
||||
/** The total stream length of the STREAMINFO block in bytes. */
|
||||
#define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
|
||||
|
@ -567,7 +567,7 @@ typedef struct {
|
|||
FLAC__byte *data;
|
||||
} FLAC__StreamMetadata_Application;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */
|
||||
|
||||
/** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A HREF="../format.html#seekpoint">format specification</A>)
|
||||
*/
|
||||
|
@ -579,13 +579,13 @@ typedef struct {
|
|||
/**< The offset, in bytes, of the target frame with respect to
|
||||
* beginning of the first frame. */
|
||||
|
||||
unsigned frame_samples;
|
||||
uint32_t frame_samples;
|
||||
/**< The number of samples in the target frame. */
|
||||
} FLAC__StreamMetadata_SeekPoint;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */
|
||||
|
||||
/** The total stream length of a seek point in bytes. */
|
||||
#define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u)
|
||||
|
@ -610,7 +610,7 @@ extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
|
|||
* present in a stream.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned num_points;
|
||||
uint32_t num_points;
|
||||
FLAC__StreamMetadata_SeekPoint *points;
|
||||
} FLAC__StreamMetadata_SeekTable;
|
||||
|
||||
|
@ -626,7 +626,7 @@ typedef struct {
|
|||
FLAC__byte *entry;
|
||||
} FLAC__StreamMetadata_VorbisComment_Entry;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */
|
||||
|
||||
|
||||
/** FLAC VORBIS_COMMENT structure. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
|
||||
|
@ -637,7 +637,7 @@ typedef struct {
|
|||
FLAC__StreamMetadata_VorbisComment_Entry *comments;
|
||||
} FLAC__StreamMetadata_VorbisComment;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */
|
||||
|
||||
|
||||
/** FLAC CUESHEET track index structure. (See the
|
||||
|
@ -654,9 +654,9 @@ typedef struct {
|
|||
/**< The index point number. */
|
||||
} FLAC__StreamMetadata_CueSheet_Index;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */
|
||||
|
||||
|
||||
/** FLAC CUESHEET track structure. (See the
|
||||
|
@ -673,10 +673,10 @@ typedef struct {
|
|||
char isrc[13];
|
||||
/**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */
|
||||
|
||||
unsigned type:1;
|
||||
uint32_t type:1;
|
||||
/**< The track type: 0 for audio, 1 for non-audio. */
|
||||
|
||||
unsigned pre_emphasis:1;
|
||||
uint32_t pre_emphasis:1;
|
||||
/**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */
|
||||
|
||||
FLAC__byte num_indices;
|
||||
|
@ -687,13 +687,13 @@ typedef struct {
|
|||
|
||||
} FLAC__StreamMetadata_CueSheet_Track;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */
|
||||
|
||||
|
||||
/** FLAC CUESHEET structure. (See the
|
||||
|
@ -713,7 +713,7 @@ typedef struct {
|
|||
FLAC__bool is_cd;
|
||||
/**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */
|
||||
|
||||
unsigned num_tracks;
|
||||
uint32_t num_tracks;
|
||||
/**< The number of tracks. */
|
||||
|
||||
FLAC__StreamMetadata_CueSheet_Track *tracks;
|
||||
|
@ -721,11 +721,11 @@ typedef struct {
|
|||
|
||||
} FLAC__StreamMetadata_CueSheet;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */
|
||||
|
||||
|
||||
/** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */
|
||||
|
@ -810,14 +810,14 @@ typedef struct {
|
|||
|
||||
} FLAC__StreamMetadata_Picture;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */
|
||||
|
||||
|
||||
/** Structure that is used when a metadata block of unknown type is loaded.
|
||||
|
@ -840,7 +840,7 @@ typedef struct {
|
|||
FLAC__bool is_last;
|
||||
/**< \c true if this metadata block is the last, else \a false */
|
||||
|
||||
unsigned length;
|
||||
uint32_t length;
|
||||
/**< Length, in bytes, of the block data as it appears in the stream. */
|
||||
|
||||
union {
|
||||
|
@ -857,9 +857,9 @@ typedef struct {
|
|||
* to use. */
|
||||
} FLAC__StreamMetadata;
|
||||
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */
|
||||
extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */
|
||||
extern FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */
|
||||
|
||||
/** The total stream length of a metadata block header in bytes. */
|
||||
#define FLAC__STREAM_METADATA_HEADER_LENGTH (4u)
|
||||
|
@ -880,7 +880,7 @@ extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bit
|
|||
* \c true if the given sample rate conforms to the specification, else
|
||||
* \c false.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate);
|
||||
|
||||
/** Tests that a blocksize at the given sample rate is valid for the FLAC
|
||||
* subset.
|
||||
|
@ -892,7 +892,7 @@ FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
|
|||
* \c true if the given blocksize conforms to the specification for the
|
||||
* subset at the given sample rate, else \c false.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigned sample_rate);
|
||||
FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate);
|
||||
|
||||
/** Tests that a sample rate is valid for the FLAC subset. The subset rules
|
||||
* for valid sample rates are slightly more complex since the rate has to
|
||||
|
@ -903,7 +903,7 @@ FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigne
|
|||
* \c true if the given sample rate conforms to the specification for the
|
||||
* subset, else \c false.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate);
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate);
|
||||
|
||||
/** Check a Vorbis comment entry name to see if it conforms to the Vorbis
|
||||
* comment specification.
|
||||
|
@ -926,14 +926,14 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *n
|
|||
*
|
||||
* \param value A string to be checked.
|
||||
* \param length A the length of \a value in bytes. May be
|
||||
* \c (unsigned)(-1) to indicate that \a value is a plain
|
||||
* \c (uint32_t)(-1) to indicate that \a value is a plain
|
||||
* UTF-8 NUL-terminated string.
|
||||
* \assert
|
||||
* \code value != NULL \endcode
|
||||
* \retval FLAC__bool
|
||||
* \c false if entry name is illegal, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length);
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length);
|
||||
|
||||
/** Check a Vorbis comment entry to see if it conforms to the Vorbis
|
||||
* comment specification.
|
||||
|
@ -950,7 +950,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__
|
|||
* \retval FLAC__bool
|
||||
* \c false if entry name is illegal, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length);
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length);
|
||||
|
||||
/** Check a seek table to see if it conforms to the FLAC specification.
|
||||
* See the format specification for limits on the contents of the
|
||||
|
@ -973,10 +973,10 @@ FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_S
|
|||
* \param seek_table A pointer to a seek table to be sorted.
|
||||
* \assert
|
||||
* \code seek_table != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* The number of duplicate seek points converted into placeholders.
|
||||
*/
|
||||
FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
|
||||
FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
|
||||
|
||||
/** Check a cue sheet to see if it conforms to the FLAC specification.
|
||||
* See the format specification for limits on the contents of the
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -93,7 +93,7 @@
|
|||
* Efficient means the whole file is rewritten at most one time, and only
|
||||
* when necessary. Level 1 is not efficient only in the case that you
|
||||
* cause more than one metadata block to grow or shrink beyond what can
|
||||
* be accomodated by padding. In this case you should probably use level
|
||||
* be accommodated by padding. In this case you should probably use level
|
||||
* 2, which allows you to edit all the metadata for a file in memory and
|
||||
* write it out all at once.
|
||||
*
|
||||
|
@ -217,13 +217,13 @@ FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__Stre
|
|||
* matched exactly. Use \c NULL to mean "any
|
||||
* description".
|
||||
* \param max_width The maximum width in pixels desired. Use
|
||||
* \c (unsigned)(-1) to mean "any width".
|
||||
* \c (uint32_t)(-1) to mean "any width".
|
||||
* \param max_height The maximum height in pixels desired. Use
|
||||
* \c (unsigned)(-1) to mean "any height".
|
||||
* \c (uint32_t)(-1) to mean "any height".
|
||||
* \param max_depth The maximum color depth in bits-per-pixel desired.
|
||||
* Use \c (unsigned)(-1) to mean "any depth".
|
||||
* Use \c (uint32_t)(-1) to mean "any depth".
|
||||
* \param max_colors The maximum number of colors desired. Use
|
||||
* \c (unsigned)(-1) to mean "any number of colors".
|
||||
* \c (uint32_t)(-1) to mean "any number of colors".
|
||||
* \assert
|
||||
* \code filename != NULL \endcode
|
||||
* \code picture != NULL \endcode
|
||||
|
@ -234,7 +234,7 @@ FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__Stre
|
|||
* error, a file decoder error, or the file contained no PICTURE
|
||||
* block, and \a *picture will be set to \c NULL.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors);
|
||||
FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors);
|
||||
|
||||
/* \} */
|
||||
|
||||
|
@ -497,13 +497,13 @@ FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const
|
|||
* \code iterator != NULL \endcode
|
||||
* \a iterator has been successfully initialized with
|
||||
* FLAC__metadata_simple_iterator_init()
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* The length of the metadata block at the current iterator position.
|
||||
* The is same length as that in the
|
||||
* <a href="http://xiph.org/flac/format.html#metadata_block_header">metadata block header</a>,
|
||||
* i.e. the length of the metadata body that follows the header.
|
||||
*/
|
||||
FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
|
||||
FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
|
||||
|
||||
/** Get the application ID of the \c APPLICATION block at the current
|
||||
* position. This avoids reading the actual block data which can save
|
||||
|
@ -667,7 +667,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_S
|
|||
*
|
||||
* - Create a new chain using FLAC__metadata_chain_new(). A chain is a
|
||||
* linked list of FLAC metadata blocks.
|
||||
* - Read all metadata into the the chain from a FLAC file using
|
||||
* - Read all metadata into the chain from a FLAC file using
|
||||
* FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and
|
||||
* check the status.
|
||||
* - Optionally, consolidate the padding using
|
||||
|
@ -764,7 +764,7 @@ typedef enum {
|
|||
FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH,
|
||||
/**< FLAC__metadata_chain_write() was called on a chain read by
|
||||
* FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
|
||||
* or
|
||||
* or
|
||||
* FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile()
|
||||
* was called on a chain read by
|
||||
* FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
|
||||
|
@ -1373,7 +1373,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *b
|
|||
* \retval FLAC__bool
|
||||
* \c false if \a copy is \c true and malloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, unsigned length, FLAC__bool copy);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, uint32_t length, FLAC__bool copy);
|
||||
|
||||
/** Resize the seekpoint array.
|
||||
*
|
||||
|
@ -1390,7 +1390,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetad
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation error, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, unsigned new_num_points);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, uint32_t new_num_points);
|
||||
|
||||
/** Set a seekpoint in a seektable.
|
||||
*
|
||||
|
@ -1402,7 +1402,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMe
|
|||
* \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
|
||||
* \code object->data.seek_table.num_points > point_num \endcode
|
||||
*/
|
||||
FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
|
||||
FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point);
|
||||
|
||||
/** Insert a seekpoint into a seektable.
|
||||
*
|
||||
|
@ -1416,7 +1416,7 @@ FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *ob
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation error, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point);
|
||||
|
||||
/** Delete a seekpoint from a seektable.
|
||||
*
|
||||
|
@ -1429,7 +1429,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMet
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation error, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, unsigned point_num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, uint32_t point_num);
|
||||
|
||||
/** Check a seektable to see if it conforms to the FLAC specification.
|
||||
* See the format specification for limits on the contents of the
|
||||
|
@ -1459,7 +1459,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamM
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, unsigned num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, uint32_t num);
|
||||
|
||||
/** Append a specific seek point template to the end of a seek table.
|
||||
*
|
||||
|
@ -1494,7 +1494,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], unsigned num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], uint32_t num);
|
||||
|
||||
/** Append a set of evenly-spaced seek point templates to the end of a
|
||||
* seek table.
|
||||
|
@ -1516,7 +1516,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC_
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, uint32_t num, FLAC__uint64 total_samples);
|
||||
|
||||
/** Append a set of evenly-spaced seek point templates to the end of a
|
||||
* seek table.
|
||||
|
@ -1544,7 +1544,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, unsigned samples, FLAC__uint64 total_samples);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, uint32_t samples, FLAC__uint64 total_samples);
|
||||
|
||||
/** Sort a seek table's seek points according to the format specification,
|
||||
* removing duplicates.
|
||||
|
@ -1603,7 +1603,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, uint32_t new_num_comments);
|
||||
|
||||
/** Sets a comment in a VORBIS_COMMENT block.
|
||||
*
|
||||
|
@ -1630,7 +1630,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__St
|
|||
* \c false if memory allocation fails or \a entry does not comply with the
|
||||
* Vorbis comment specification, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
|
||||
|
||||
/** Insert a comment in a VORBIS_COMMENT block at the given index.
|
||||
*
|
||||
|
@ -1660,7 +1660,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__Stream
|
|||
* \c false if memory allocation fails or \a entry does not comply with the
|
||||
* Vorbis comment specification, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
|
||||
|
||||
/** Appends a comment to a VORBIS_COMMENT block.
|
||||
*
|
||||
|
@ -1692,7 +1692,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__Str
|
|||
* For convenience, a trailing NUL is added to the entry if it doesn't have
|
||||
* one already.
|
||||
*
|
||||
* Depending on the the value of \a all, either all or just the first comment
|
||||
* Depending on the value of \a all, either all or just the first comment
|
||||
* whose field name(s) match the given entry's name will be replaced by the
|
||||
* given entry. If no comments match, \a entry will simply be appended.
|
||||
*
|
||||
|
@ -1733,7 +1733,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__St
|
|||
* \retval FLAC__bool
|
||||
* \c false if realloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, uint32_t comment_num);
|
||||
|
||||
/** Creates a Vorbis comment entry from NUL-terminated name and value strings.
|
||||
*
|
||||
|
@ -1789,7 +1789,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair
|
|||
* \retval FLAC__bool
|
||||
* \c true if the field names match, else \c false
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, unsigned field_name_length);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, uint32_t field_name_length);
|
||||
|
||||
/** Find a Vorbis comment with the given field name.
|
||||
*
|
||||
|
@ -1808,7 +1808,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC
|
|||
* The offset in the comment array of the first comment whose field
|
||||
* name matches \a field_name, or \c -1 if no match was found.
|
||||
*/
|
||||
FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name);
|
||||
FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name);
|
||||
|
||||
/** Remove first Vorbis comment matching the given field name.
|
||||
*
|
||||
|
@ -1886,7 +1886,7 @@ FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_C
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation error, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, unsigned track_num, unsigned new_num_indices);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t new_num_indices);
|
||||
|
||||
/** Insert an index point in a CUESHEET track at the given index.
|
||||
*
|
||||
|
@ -1909,7 +1909,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__St
|
|||
* \retval FLAC__bool
|
||||
* \c false if realloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num, FLAC__StreamMetadata_CueSheet_Index index);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num, FLAC__StreamMetadata_CueSheet_Index index);
|
||||
|
||||
/** Insert a blank index point in a CUESHEET track at the given index.
|
||||
*
|
||||
|
@ -1933,7 +1933,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__Stre
|
|||
* \retval FLAC__bool
|
||||
* \c false if realloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num);
|
||||
|
||||
/** Delete an index point in a CUESHEET track at the given index.
|
||||
*
|
||||
|
@ -1952,7 +1952,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC
|
|||
* \retval FLAC__bool
|
||||
* \c false if realloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num);
|
||||
|
||||
/** Resize the track array.
|
||||
*
|
||||
|
@ -1969,7 +1969,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__Stre
|
|||
* \retval FLAC__bool
|
||||
* \c false if memory allocation error, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, unsigned new_num_tracks);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, uint32_t new_num_tracks);
|
||||
|
||||
/** Sets a track in a CUESHEET block.
|
||||
*
|
||||
|
@ -1991,7 +1991,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMet
|
|||
* \retval FLAC__bool
|
||||
* \c false if \a copy is \c true and malloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
|
||||
|
||||
/** Insert a track in a CUESHEET block at the given index.
|
||||
*
|
||||
|
@ -2014,7 +2014,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadat
|
|||
* \retval FLAC__bool
|
||||
* \c false if \a copy is \c true and malloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
|
||||
|
||||
/** Insert a blank track in a CUESHEET block at the given index.
|
||||
*
|
||||
|
@ -2033,7 +2033,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMeta
|
|||
* \retval FLAC__bool
|
||||
* \c false if \a copy is \c true and malloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, unsigned track_num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, uint32_t track_num);
|
||||
|
||||
/** Delete a track in a CUESHEET block at the given index.
|
||||
*
|
||||
|
@ -2048,7 +2048,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__Stre
|
|||
* \retval FLAC__bool
|
||||
* \c false if realloc() fails, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, unsigned track_num);
|
||||
FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, uint32_t track_num);
|
||||
|
||||
/** Check a cue sheet to see if it conforms to the FLAC specification.
|
||||
* See the format specification for limits on the contents of the
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -39,12 +39,11 @@
|
|||
* the 1999 ISO C Standard header file <stdint.h>.
|
||||
*/
|
||||
|
||||
typedef __int8 FLAC__int8;
|
||||
typedef signed __int8 FLAC__int8;
|
||||
typedef signed __int16 FLAC__int16;
|
||||
typedef signed __int32 FLAC__int32;
|
||||
typedef signed __int64 FLAC__int64;
|
||||
typedef unsigned __int8 FLAC__uint8;
|
||||
|
||||
typedef __int16 FLAC__int16;
|
||||
typedef __int32 FLAC__int32;
|
||||
typedef __int64 FLAC__int64;
|
||||
typedef unsigned __int16 FLAC__uint16;
|
||||
typedef unsigned __int32 FLAC__uint32;
|
||||
typedef unsigned __int64 FLAC__uint64;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -228,7 +228,7 @@ typedef enum {
|
|||
*/
|
||||
|
||||
FLAC__STREAM_DECODER_ABORTED,
|
||||
/**< The decoder was aborted by the read callback. */
|
||||
/**< The decoder was aborted by the read or write callback. */
|
||||
|
||||
FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
|
||||
/**< An error occurred allocating memory. The decoder is in an invalid
|
||||
|
@ -920,7 +920,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDeco
|
|||
* \param decoder A decoder instance to query.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See above.
|
||||
*/
|
||||
FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder);
|
||||
|
@ -932,10 +932,10 @@ FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamD
|
|||
* \param decoder A decoder instance to query.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See above.
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Get the current channel assignment in the stream being decoded.
|
||||
* Will only be valid after decoding has started and will contain the
|
||||
|
@ -956,10 +956,10 @@ FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(con
|
|||
* \param decoder A decoder instance to query.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See above.
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder);
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Get the current sample rate in Hz of the stream being decoded.
|
||||
* Will only be valid after decoding has started and will contain the
|
||||
|
@ -968,10 +968,10 @@ FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDec
|
|||
* \param decoder A decoder instance to query.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See above.
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder);
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Get the current blocksize of the stream being decoded.
|
||||
* Will only be valid after decoding has started and will contain the
|
||||
|
@ -980,10 +980,10 @@ FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder
|
|||
* \param decoder A decoder instance to query.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See above.
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Returns the decoder's current read position within the stream.
|
||||
* The position is the byte offset from the start of the stream.
|
||||
|
@ -1184,7 +1184,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
|
|||
* Unless \a file is \c stdin, it will be closed
|
||||
* when FLAC__stream_decoder_finish() is called.
|
||||
* Note however that seeking will not work when
|
||||
* decoding from \c stdout since it is not seekable.
|
||||
* decoding from \c stdin since it is not seekable.
|
||||
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
|
||||
* pointer must not be \c NULL.
|
||||
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
|
||||
|
@ -1234,7 +1234,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
|
|||
* Unless \a file is \c stdin, it will be closed
|
||||
* when FLAC__stream_decoder_finish() is called.
|
||||
* Note however that seeking will not work when
|
||||
* decoding from \c stdout since it is not seekable.
|
||||
* decoding from \c stdin since it is not seekable.
|
||||
* \param write_callback See FLAC__StreamDecoderWriteCallback. This
|
||||
* pointer must not be \c NULL.
|
||||
* \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
|
||||
|
@ -1403,8 +1403,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
|
|||
* and is not seekable (i.e. no seek callback was provided or the seek
|
||||
* callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it
|
||||
* is the duty of the client to start feeding data from the beginning of
|
||||
* the stream on the next FLAC__stream_decoder_process() or
|
||||
* FLAC__stream_decoder_process_interleaved() call.
|
||||
* the stream on the next FLAC__stream_decoder_process_*() call.
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -554,7 +554,7 @@ typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const F
|
|||
* \retval FLAC__StreamEncoderWriteStatus
|
||||
* The callee's return status.
|
||||
*/
|
||||
typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
|
||||
|
||||
/** Signature for the seek callback.
|
||||
*
|
||||
|
@ -675,7 +675,7 @@ typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *e
|
|||
* \param client_data The callee's client data set through
|
||||
* FLAC__stream_encoder_init_*().
|
||||
*/
|
||||
typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
|
||||
typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data);
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -771,7 +771,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncod
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set the sample resolution of the input to be encoded.
|
||||
*
|
||||
|
@ -787,7 +787,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encod
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set the sample rate (in Hz) of the input to be encoded.
|
||||
*
|
||||
|
@ -799,7 +799,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set the compression level
|
||||
*
|
||||
|
@ -862,7 +862,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *en
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set the blocksize to use while encoding.
|
||||
*
|
||||
|
@ -877,13 +877,13 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncod
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set to \c true to enable mid-side encoding on stereo input. The
|
||||
* number of channels must be 2 for this to have any effect. Set to
|
||||
* \c false to use only independent channel coding.
|
||||
*
|
||||
* \default \c false
|
||||
* \default \c true
|
||||
* \param encoder An encoder instance to set.
|
||||
* \param value Flag value (see above).
|
||||
* \assert
|
||||
|
@ -977,7 +977,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *en
|
|||
|
||||
/** Set the maximum LPC order, or \c 0 to use only the fixed predictors.
|
||||
*
|
||||
* \default \c 0
|
||||
* \default \c 8
|
||||
* \param encoder An encoder instance to set.
|
||||
* \param value See above.
|
||||
* \assert
|
||||
|
@ -985,7 +985,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *en
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set the precision, in bits, of the quantized linear predictor
|
||||
* coefficients, or \c 0 to let the encoder select it based on the
|
||||
|
@ -1003,7 +1003,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set to \c false to use only the specified quantized linear predictor
|
||||
* coefficient precision, or \c true to search neighboring precision
|
||||
|
@ -1066,7 +1066,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__St
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set the maximum partition order to search when coding the residual.
|
||||
* This is used in tandem with
|
||||
|
@ -1081,7 +1081,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__
|
|||
* all orders, using the mean of each context for its Rice parameter,
|
||||
* and use the best.
|
||||
*
|
||||
* \default \c 0
|
||||
* \default \c 5
|
||||
* \param encoder An encoder instance to set.
|
||||
* \param value See above.
|
||||
* \assert
|
||||
|
@ -1089,7 +1089,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Deprecated. Setting this value has no effect.
|
||||
*
|
||||
|
@ -1101,7 +1101,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__
|
|||
* \retval FLAC__bool
|
||||
* \c false if the encoder is already initialized, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, uint32_t value);
|
||||
|
||||
/** Set an estimate of the total samples that will be encoded.
|
||||
* This is merely an estimate and may be set to \c 0 if unknown.
|
||||
|
@ -1200,7 +1200,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__Stream
|
|||
* \c false if the encoder is already initialized, or if
|
||||
* \a num_blocks > 65535 if encoding to Ogg FLAC, else \c true.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, uint32_t num_blocks);
|
||||
|
||||
/** Get the current encoder state.
|
||||
*
|
||||
|
@ -1254,7 +1254,7 @@ FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__
|
|||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
*/
|
||||
FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
|
||||
FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got);
|
||||
|
||||
/** Get the "verify" flag.
|
||||
*
|
||||
|
@ -1281,40 +1281,40 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__Strea
|
|||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_channels().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the input sample resolution setting.
|
||||
*
|
||||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_bits_per_sample().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the input sample rate setting.
|
||||
*
|
||||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_sample_rate().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the blocksize setting.
|
||||
*
|
||||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_blocksize().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the "mid/side stereo coding" flag.
|
||||
*
|
||||
|
@ -1341,20 +1341,20 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__S
|
|||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_max_lpc_order().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the quantized linear predictor coefficient precision setting.
|
||||
*
|
||||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_qlp_coeff_precision().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the qlp coefficient precision search flag.
|
||||
*
|
||||
|
@ -1391,30 +1391,30 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FL
|
|||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_min_residual_partition_order().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get maximum residual partition order setting.
|
||||
*
|
||||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_max_residual_partition_order().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the Rice parameter search distance setting.
|
||||
*
|
||||
* \param encoder An encoder instance to query.
|
||||
* \assert
|
||||
* \code encoder != NULL \endcode
|
||||
* \retval unsigned
|
||||
* \retval uint32_t
|
||||
* See FLAC__stream_encoder_set_rice_parameter_search_dist().
|
||||
*/
|
||||
FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
|
||||
FLAC_API uint32_t FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
|
||||
|
||||
/** Get the previously set estimate of the total samples to be encoded.
|
||||
* The encoder merely mimics back the value given to
|
||||
|
@ -1747,7 +1747,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder);
|
|||
* encoder state with FLAC__stream_encoder_get_state() to see what
|
||||
* went wrong.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], uint32_t samples);
|
||||
|
||||
/** Submit data for encoding.
|
||||
* This version allows you to supply the input data where the channels
|
||||
|
@ -1779,7 +1779,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, c
|
|||
* encoder state with FLAC__stream_encoder_get_state() to see what
|
||||
* went wrong.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], uint32_t samples);
|
||||
|
||||
/* \} */
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -60,50 +60,14 @@
|
|||
* silog2( 9) = 5
|
||||
* silog2( 10) = 5
|
||||
*/
|
||||
unsigned FLAC__bitmath_silog2(int v)
|
||||
uint32_t FLAC__bitmath_silog2(FLAC__int64 v)
|
||||
{
|
||||
while(1) {
|
||||
if(v == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if(v > 0) {
|
||||
unsigned l = 0;
|
||||
while(v) {
|
||||
l++;
|
||||
v >>= 1;
|
||||
}
|
||||
return l+1;
|
||||
}
|
||||
else if(v == -1) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
v++;
|
||||
v = -v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(v == 0)
|
||||
return 0;
|
||||
|
||||
unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v)
|
||||
{
|
||||
while(1) {
|
||||
if(v == 0) {
|
||||
return 0;
|
||||
}
|
||||
else if(v > 0) {
|
||||
unsigned l = 0;
|
||||
while(v) {
|
||||
l++;
|
||||
v >>= 1;
|
||||
}
|
||||
return l+1;
|
||||
}
|
||||
else if(v == -1) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
v++;
|
||||
v = -v;
|
||||
}
|
||||
}
|
||||
if(v == -1)
|
||||
return 2;
|
||||
|
||||
v = (v < 0) ? (-(v+1)) : v;
|
||||
return FLAC__bitmath_ilog2_wide(v)+2;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2018 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -45,17 +45,42 @@
|
|||
#include "share/endswap.h"
|
||||
|
||||
/* Things should be fastest when this matches the machine word size */
|
||||
/* WATCHOUT: if you change this you must also change the following #defines down to FLAC__clz_uint32 below to match */
|
||||
/* WATCHOUT: there are a few places where the code will not work unless uint32_t is >= 32 bits wide */
|
||||
/* WATCHOUT: if you change this you must also change the following #defines down to COUNT_ZERO_MSBS2 below to match */
|
||||
/* WATCHOUT: there are a few places where the code will not work unless brword is >= 32 bits wide */
|
||||
/* also, some sections currently only have fast versions for 4 or 8 bytes per word */
|
||||
#define FLAC__BYTES_PER_WORD 4 /* sizeof uint32_t */
|
||||
#define FLAC__BITS_PER_WORD (8 * FLAC__BYTES_PER_WORD)
|
||||
|
||||
#if (ENABLE_64_BIT_WORDS == 0)
|
||||
|
||||
typedef FLAC__uint32 brword;
|
||||
#define FLAC__BYTES_PER_WORD 4 /* sizeof brword */
|
||||
#define FLAC__BITS_PER_WORD 32
|
||||
#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff)
|
||||
/* SWAP_BE_WORD_TO_HOST swaps bytes in a uint32_t (which is always big-endian) if necessary to match host byte order */
|
||||
/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */
|
||||
#if WORDS_BIGENDIAN
|
||||
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
||||
#else
|
||||
#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_32(x)
|
||||
#endif
|
||||
/* counts the # of zero MSBs in a word */
|
||||
#define COUNT_ZERO_MSBS(word) FLAC__clz_uint32(word)
|
||||
#define COUNT_ZERO_MSBS2(word) FLAC__clz2_uint32(word)
|
||||
|
||||
#else
|
||||
|
||||
typedef FLAC__uint64 brword;
|
||||
#define FLAC__BYTES_PER_WORD 8 /* sizeof brword */
|
||||
#define FLAC__BITS_PER_WORD 64
|
||||
#define FLAC__WORD_ALL_ONES ((FLAC__uint64)FLAC__U64L(0xffffffffffffffff))
|
||||
/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */
|
||||
#if WORDS_BIGENDIAN
|
||||
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
||||
#else
|
||||
#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_64(x)
|
||||
#endif
|
||||
/* counts the # of zero MSBs in a word */
|
||||
#define COUNT_ZERO_MSBS(word) FLAC__clz_uint64(word)
|
||||
#define COUNT_ZERO_MSBS2(word) FLAC__clz2_uint64(word)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -72,60 +97,64 @@
|
|||
* also depends on the CPU cache size and other factors; some twiddling
|
||||
* may be necessary to squeeze out the best performance.
|
||||
*/
|
||||
static const unsigned FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */
|
||||
static const uint32_t FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */
|
||||
|
||||
struct FLAC__BitReader {
|
||||
/* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */
|
||||
/* any incomplete word at the tail will be left-justified, and bytes from the read callback are added on the right */
|
||||
uint32_t *buffer;
|
||||
unsigned capacity; /* in words */
|
||||
unsigned words; /* # of completed words in buffer */
|
||||
unsigned bytes; /* # of bytes in incomplete word at buffer[words] */
|
||||
unsigned consumed_words; /* #words ... */
|
||||
unsigned consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */
|
||||
unsigned read_crc16; /* the running frame CRC */
|
||||
unsigned crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */
|
||||
brword *buffer;
|
||||
uint32_t capacity; /* in words */
|
||||
uint32_t words; /* # of completed words in buffer */
|
||||
uint32_t bytes; /* # of bytes in incomplete word at buffer[words] */
|
||||
uint32_t consumed_words; /* #words ... */
|
||||
uint32_t consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */
|
||||
uint32_t read_crc16; /* the running frame CRC */
|
||||
uint32_t crc16_offset; /* the number of words in the current buffer that should not be CRC'd */
|
||||
uint32_t crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */
|
||||
FLAC__BitReaderReadCallback read_callback;
|
||||
void *client_data;
|
||||
};
|
||||
|
||||
static inline void crc16_update_word_(FLAC__BitReader *br, uint32_t word)
|
||||
static inline void crc16_update_word_(FLAC__BitReader *br, brword word)
|
||||
{
|
||||
register unsigned crc = br->read_crc16;
|
||||
#if FLAC__BYTES_PER_WORD == 4
|
||||
switch(br->crc16_align) {
|
||||
case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 24), crc);
|
||||
case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc);
|
||||
case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc);
|
||||
case 24: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc);
|
||||
}
|
||||
#elif FLAC__BYTES_PER_WORD == 8
|
||||
switch(br->crc16_align) {
|
||||
case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 56), crc);
|
||||
case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 48) & 0xff), crc);
|
||||
case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 40) & 0xff), crc);
|
||||
case 24: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 32) & 0xff), crc);
|
||||
case 32: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 24) & 0xff), crc);
|
||||
case 40: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc);
|
||||
case 48: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc);
|
||||
case 56: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc);
|
||||
}
|
||||
#else
|
||||
register uint32_t crc = br->read_crc16;
|
||||
|
||||
for( ; br->crc16_align < FLAC__BITS_PER_WORD; br->crc16_align += 8)
|
||||
crc = FLAC__CRC16_UPDATE((unsigned)((word >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), crc);
|
||||
crc = FLAC__CRC16_UPDATE((uint32_t)((word >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), crc);
|
||||
|
||||
br->read_crc16 = crc;
|
||||
#endif
|
||||
br->crc16_align = 0;
|
||||
}
|
||||
|
||||
static inline void crc16_update_block_(FLAC__BitReader *br)
|
||||
{
|
||||
if(br->consumed_words > br->crc16_offset && br->crc16_align)
|
||||
crc16_update_word_(br, br->buffer[br->crc16_offset++]);
|
||||
|
||||
#if FLAC__BYTES_PER_WORD == 4
|
||||
br->read_crc16 = FLAC__crc16_update_words32(br->buffer + br->crc16_offset, br->consumed_words - br->crc16_offset, br->read_crc16);
|
||||
#elif FLAC__BYTES_PER_WORD == 8
|
||||
br->read_crc16 = FLAC__crc16_update_words64(br->buffer + br->crc16_offset, br->consumed_words - br->crc16_offset, br->read_crc16);
|
||||
#else
|
||||
unsigned i;
|
||||
|
||||
for(i = br->crc16_offset; i < br->consumed_words; i++)
|
||||
crc16_update_word_(br, br->buffer[i]);
|
||||
#endif
|
||||
|
||||
br->crc16_offset = 0;
|
||||
}
|
||||
|
||||
static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
||||
{
|
||||
unsigned start, end;
|
||||
uint32_t start, end;
|
||||
size_t bytes;
|
||||
FLAC__byte *target;
|
||||
|
||||
/* first shift the unconsumed buffer data toward the front as much as possible */
|
||||
if(br->consumed_words > 0) {
|
||||
crc16_update_block_(br); /* CRC consumed words */
|
||||
|
||||
start = br->consumed_words;
|
||||
end = br->words + (br->bytes? 1:0);
|
||||
memmove(br->buffer, br->buffer+start, FLAC__BYTES_PER_WORD * (end - start));
|
||||
|
@ -142,9 +171,9 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
|||
return false; /* no space left, buffer is too small; see note for FLAC__BITREADER_DEFAULT_CAPACITY */
|
||||
target = ((FLAC__byte*)(br->buffer+br->words)) + br->bytes;
|
||||
|
||||
/* before reading, if the existing reader looks like this (say uint32_t is 32 bits wide)
|
||||
/* before reading, if the existing reader looks like this (say brword is 32 bits wide)
|
||||
* bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 (partial tail word is left-justified)
|
||||
* buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown layed out as bytes sequentially in memory)
|
||||
* buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown laid out as bytes sequentially in memory)
|
||||
* buffer[LE]: 44 33 22 11 ?? ?? ?? 55 (?? being don't-care)
|
||||
* ^^-------target, bytes=3
|
||||
* on LE machines, have to byteswap the odd tail word so nothing is
|
||||
|
@ -175,7 +204,7 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
|||
*/
|
||||
#if WORDS_BIGENDIAN
|
||||
#else
|
||||
end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD;
|
||||
end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD;
|
||||
for(start = br->words; start < end; start++)
|
||||
br->buffer[start] = SWAP_BE_WORD_TO_HOST(br->buffer[start]);
|
||||
#endif
|
||||
|
@ -186,7 +215,7 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
|
|||
* buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD
|
||||
* finally we'll update the reader values:
|
||||
*/
|
||||
end = br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes;
|
||||
end = br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes;
|
||||
br->words = end / FLAC__BYTES_PER_WORD;
|
||||
br->bytes = end % FLAC__BYTES_PER_WORD;
|
||||
|
||||
|
@ -236,7 +265,7 @@ FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__BitReaderReadCallback
|
|||
br->words = br->bytes = 0;
|
||||
br->consumed_words = br->consumed_bits = 0;
|
||||
br->capacity = FLAC__BITREADER_DEFAULT_CAPACITY;
|
||||
br->buffer = malloc(sizeof(uint32_t) * br->capacity);
|
||||
br->buffer = malloc(sizeof(brword) * br->capacity);
|
||||
if(br->buffer == 0)
|
||||
return false;
|
||||
br->read_callback = rcb;
|
||||
|
@ -268,7 +297,7 @@ FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br)
|
|||
|
||||
void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
if(br == 0) {
|
||||
fprintf(out, "bitreader is NULL\n");
|
||||
}
|
||||
|
@ -281,7 +310,7 @@ void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out)
|
|||
if(i < br->consumed_words || (i == br->consumed_words && j < br->consumed_bits))
|
||||
fprintf(out, ".");
|
||||
else
|
||||
fprintf(out, "%01u", br->buffer[i] & (1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0);
|
||||
fprintf(out, "%01d", br->buffer[i] & ((brword)1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
if(br->bytes > 0) {
|
||||
|
@ -290,7 +319,7 @@ void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out)
|
|||
if(i < br->consumed_words || (i == br->consumed_words && j < br->consumed_bits))
|
||||
fprintf(out, ".");
|
||||
else
|
||||
fprintf(out, "%01u", br->buffer[i] & (1 << (br->bytes*8-j-1)) ? 1:0);
|
||||
fprintf(out, "%01d", br->buffer[i] & ((brword)1 << (br->bytes*8-j-1)) ? 1:0);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +331,8 @@ void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed)
|
|||
FLAC__ASSERT(0 != br->buffer);
|
||||
FLAC__ASSERT((br->consumed_bits & 7) == 0);
|
||||
|
||||
br->read_crc16 = (unsigned)seed;
|
||||
br->read_crc16 = (uint32_t)seed;
|
||||
br->crc16_offset = br->consumed_words;
|
||||
br->crc16_align = br->consumed_bits;
|
||||
}
|
||||
|
||||
|
@ -310,14 +340,18 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br)
|
|||
{
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
||||
/* CRC consumed words up to here */
|
||||
crc16_update_block_(br);
|
||||
|
||||
FLAC__ASSERT((br->consumed_bits & 7) == 0);
|
||||
FLAC__ASSERT(br->crc16_align <= br->consumed_bits);
|
||||
|
||||
/* CRC any tail bytes in a partially-consumed word */
|
||||
if(br->consumed_bits) {
|
||||
const uint32_t tail = br->buffer[br->consumed_words];
|
||||
const brword tail = br->buffer[br->consumed_words];
|
||||
for( ; br->crc16_align < br->consumed_bits; br->crc16_align += 8)
|
||||
br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16);
|
||||
br->read_crc16 = FLAC__CRC16_UPDATE((uint32_t)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16);
|
||||
}
|
||||
return br->read_crc16;
|
||||
}
|
||||
|
@ -327,17 +361,17 @@ inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader
|
|||
return ((br->consumed_bits & 7) == 0);
|
||||
}
|
||||
|
||||
inline unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
|
||||
inline uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
|
||||
{
|
||||
return 8 - (br->consumed_bits & 7);
|
||||
}
|
||||
|
||||
inline unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br)
|
||||
inline uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br)
|
||||
{
|
||||
return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits)
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits)
|
||||
{
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
@ -362,35 +396,34 @@ FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *va
|
|||
/* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */
|
||||
if(br->consumed_bits) {
|
||||
/* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
|
||||
const unsigned n = FLAC__BITS_PER_WORD - br->consumed_bits;
|
||||
const uint32_t word = br->buffer[br->consumed_words];
|
||||
const uint32_t n = FLAC__BITS_PER_WORD - br->consumed_bits;
|
||||
const brword word = br->buffer[br->consumed_words];
|
||||
if(bits < n) {
|
||||
*val = (word & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (n-bits);
|
||||
*val = (FLAC__uint32)((word & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (n-bits)); /* The result has <= 32 non-zero bits */
|
||||
br->consumed_bits += bits;
|
||||
return true;
|
||||
}
|
||||
*val = word & (FLAC__WORD_ALL_ONES >> br->consumed_bits);
|
||||
/* (FLAC__BITS_PER_WORD - br->consumed_bits <= bits) ==> (FLAC__WORD_ALL_ONES >> br->consumed_bits) has no more than 'bits' non-zero bits */
|
||||
*val = (FLAC__uint32)(word & (FLAC__WORD_ALL_ONES >> br->consumed_bits));
|
||||
bits -= n;
|
||||
crc16_update_word_(br, word);
|
||||
br->consumed_words++;
|
||||
br->consumed_bits = 0;
|
||||
if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
|
||||
*val <<= bits;
|
||||
*val |= (br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
|
||||
*val |= (FLAC__uint32)(br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
|
||||
br->consumed_bits = bits;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
const uint32_t word = br->buffer[br->consumed_words];
|
||||
else { /* br->consumed_bits == 0 */
|
||||
const brword word = br->buffer[br->consumed_words];
|
||||
if(bits < FLAC__BITS_PER_WORD) {
|
||||
*val = word >> (FLAC__BITS_PER_WORD-bits);
|
||||
*val = (FLAC__uint32)(word >> (FLAC__BITS_PER_WORD-bits));
|
||||
br->consumed_bits = bits;
|
||||
return true;
|
||||
}
|
||||
/* at this point 'bits' must be == FLAC__BITS_PER_WORD; because of previous assertions, it can't be larger */
|
||||
*val = word;
|
||||
crc16_update_word_(br, word);
|
||||
/* at this point bits == FLAC__BITS_PER_WORD == 32; because of previous assertions, it can't be larger */
|
||||
*val = (FLAC__uint32)word;
|
||||
br->consumed_words++;
|
||||
return true;
|
||||
}
|
||||
|
@ -404,30 +437,32 @@ FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *va
|
|||
if(br->consumed_bits) {
|
||||
/* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
|
||||
FLAC__ASSERT(br->consumed_bits + bits <= br->bytes*8);
|
||||
*val = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits);
|
||||
*val = (FLAC__uint32)((br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits));
|
||||
br->consumed_bits += bits;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
*val = br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits);
|
||||
*val = (FLAC__uint32)(br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
|
||||
br->consumed_bits += bits;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits)
|
||||
FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits)
|
||||
{
|
||||
FLAC__uint32 uval, mask;
|
||||
/* OPT: inline raw uint32 code here, or make into a macro if possible in the .h file */
|
||||
if(!FLAC__bitreader_read_raw_uint32(br, (FLAC__uint32*)val, bits))
|
||||
if(!FLAC__bitreader_read_raw_uint32(br, &uval, bits))
|
||||
return false;
|
||||
/* sign-extend: */
|
||||
*val <<= (32-bits);
|
||||
*val >>= (32-bits);
|
||||
/* sign-extend *val assuming it is currently bits wide. */
|
||||
/* From: https://graphics.stanford.edu/~seander/bithacks.html#FixedSignExtend */
|
||||
mask = 1u << (bits - 1);
|
||||
*val = (uval ^ mask) - mask;
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits)
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits)
|
||||
{
|
||||
FLAC__uint32 hi, lo;
|
||||
|
||||
|
@ -473,7 +508,7 @@ inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br,
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
|
||||
FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits)
|
||||
{
|
||||
/*
|
||||
* OPT: a faster implementation is possible but probably not that useful
|
||||
|
@ -483,8 +518,8 @@ FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
|
|||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
||||
if(bits > 0) {
|
||||
const unsigned n = br->consumed_bits & 7;
|
||||
unsigned m;
|
||||
const uint32_t n = br->consumed_bits & 7;
|
||||
uint32_t m;
|
||||
FLAC__uint32 x;
|
||||
|
||||
if(n != 0) {
|
||||
|
@ -508,7 +543,7 @@ FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals)
|
||||
FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals)
|
||||
{
|
||||
FLAC__uint32 x;
|
||||
|
||||
|
@ -543,7 +578,7 @@ FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, u
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals)
|
||||
FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals)
|
||||
{
|
||||
FLAC__uint32 x;
|
||||
|
||||
|
@ -563,7 +598,7 @@ FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, F
|
|||
/* step 2: read whole words in chunks */
|
||||
while(nvals >= FLAC__BYTES_PER_WORD) {
|
||||
if(br->consumed_words < br->words) {
|
||||
const uint32_t word = br->buffer[br->consumed_words++];
|
||||
const brword word = br->buffer[br->consumed_words++];
|
||||
#if FLAC__BYTES_PER_WORD == 4
|
||||
val[0] = (FLAC__byte)(word >> 24);
|
||||
val[1] = (FLAC__byte)(word >> 16);
|
||||
|
@ -599,10 +634,10 @@ FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, F
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val)
|
||||
FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val)
|
||||
#if 0 /* slow but readable version */
|
||||
{
|
||||
unsigned bit;
|
||||
uint32_t bit;
|
||||
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
@ -620,7 +655,7 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va
|
|||
}
|
||||
#else
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
@ -628,14 +663,13 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va
|
|||
*val = 0;
|
||||
while(1) {
|
||||
while(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */
|
||||
uint32_t b = br->buffer[br->consumed_words] << br->consumed_bits;
|
||||
brword b = br->buffer[br->consumed_words] << br->consumed_bits;
|
||||
if(b) {
|
||||
i = FLAC__clz_uint32(b);
|
||||
i = COUNT_ZERO_MSBS(b);
|
||||
*val += i;
|
||||
i++;
|
||||
br->consumed_bits += i;
|
||||
if(br->consumed_bits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(br->consumed_bits == FLAC__BITS_PER_WORD) */
|
||||
crc16_update_word_(br, br->buffer[br->consumed_words]);
|
||||
br->consumed_words++;
|
||||
br->consumed_bits = 0;
|
||||
}
|
||||
|
@ -643,7 +677,6 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va
|
|||
}
|
||||
else {
|
||||
*val += FLAC__BITS_PER_WORD - br->consumed_bits;
|
||||
crc16_update_word_(br, br->buffer[br->consumed_words]);
|
||||
br->consumed_words++;
|
||||
br->consumed_bits = 0;
|
||||
/* didn't find stop bit yet, have to keep going... */
|
||||
|
@ -657,10 +690,10 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va
|
|||
* be zero.
|
||||
*/
|
||||
if(br->bytes*8 > br->consumed_bits) {
|
||||
const unsigned end = br->bytes * 8;
|
||||
uint32_t b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits;
|
||||
const uint32_t end = br->bytes * 8;
|
||||
brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits;
|
||||
if(b) {
|
||||
i = FLAC__clz_uint32(b);
|
||||
i = COUNT_ZERO_MSBS(b);
|
||||
*val += i;
|
||||
i++;
|
||||
br->consumed_bits += i;
|
||||
|
@ -680,10 +713,10 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va
|
|||
}
|
||||
#endif
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter)
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter)
|
||||
{
|
||||
FLAC__uint32 lsbs = 0, msbs = 0;
|
||||
unsigned uval;
|
||||
uint32_t uval;
|
||||
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
@ -708,14 +741,14 @@ FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsig
|
|||
}
|
||||
|
||||
/* this is by far the most heavily used reader call. it ain't pretty but it's fast */
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter)
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter)
|
||||
{
|
||||
/* try and get br->consumed_words and br->consumed_bits into register;
|
||||
* must remember to flush them back to *br before calling other
|
||||
* bitreader functions that use them, and before returning */
|
||||
unsigned cwords, words, lsbs, msbs, x, y;
|
||||
unsigned ucbits; /* keep track of the number of unconsumed bits in word */
|
||||
uint32_t b;
|
||||
uint32_t cwords, words, lsbs, msbs, x, y;
|
||||
uint32_t ucbits; /* keep track of the number of unconsumed bits in word */
|
||||
brword b;
|
||||
int *val, *end;
|
||||
|
||||
FLAC__ASSERT(0 != br);
|
||||
|
@ -756,16 +789,16 @@ FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[
|
|||
|
||||
while(val < end) {
|
||||
/* read the unary MSBs and end bit */
|
||||
x = y = FLAC__clz2_uint32(b);
|
||||
x = y = COUNT_ZERO_MSBS2(b);
|
||||
if(x == FLAC__BITS_PER_WORD) {
|
||||
x = ucbits;
|
||||
do {
|
||||
/* didn't find stop bit yet, have to keep going... */
|
||||
crc16_update_word_(br, br->buffer[cwords++]);
|
||||
cwords++;
|
||||
if (cwords >= words)
|
||||
goto incomplete_msbs;
|
||||
b = br->buffer[cwords];
|
||||
y = FLAC__clz2_uint32(b);
|
||||
y = COUNT_ZERO_MSBS2(b);
|
||||
x += y;
|
||||
} while(y == FLAC__BITS_PER_WORD);
|
||||
}
|
||||
|
@ -775,18 +808,18 @@ FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[
|
|||
msbs = x;
|
||||
|
||||
/* read the binary LSBs */
|
||||
x = b >> (FLAC__BITS_PER_WORD - parameter);
|
||||
x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit uint32_t */
|
||||
if(parameter <= ucbits) {
|
||||
ucbits -= parameter;
|
||||
b <<= parameter;
|
||||
} else {
|
||||
/* there are still bits left to read, they will all be in the next word */
|
||||
crc16_update_word_(br, br->buffer[cwords++]);
|
||||
cwords++;
|
||||
if (cwords >= words)
|
||||
goto incomplete_lsbs;
|
||||
b = br->buffer[cwords];
|
||||
ucbits += FLAC__BITS_PER_WORD - parameter;
|
||||
x |= b >> ucbits;
|
||||
x |= (FLAC__uint32)(b >> ucbits);
|
||||
b <<= FLAC__BITS_PER_WORD - ucbits;
|
||||
}
|
||||
lsbs = x;
|
||||
|
@ -837,7 +870,7 @@ incomplete_lsbs:
|
|||
|
||||
if(ucbits == 0 && cwords < words) {
|
||||
/* don't leave the head word with no unconsumed bits */
|
||||
crc16_update_word_(br, br->buffer[cwords++]);
|
||||
cwords++;
|
||||
ucbits = FLAC__BITS_PER_WORD;
|
||||
}
|
||||
|
||||
|
@ -848,10 +881,10 @@ incomplete_lsbs:
|
|||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter)
|
||||
FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter)
|
||||
{
|
||||
FLAC__uint32 lsbs = 0, msbs = 0;
|
||||
unsigned bit, uval, k;
|
||||
uint32_t bit, uval, k;
|
||||
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
@ -871,7 +904,7 @@ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uns
|
|||
uval = (msbs << k) | lsbs;
|
||||
}
|
||||
else {
|
||||
unsigned d = (1 << (k+1)) - parameter;
|
||||
uint32_t d = (1 << (k+1)) - parameter;
|
||||
if(lsbs >= d) {
|
||||
if(!FLAC__bitreader_read_bit(br, &bit))
|
||||
return false;
|
||||
|
@ -883,7 +916,7 @@ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uns
|
|||
uval = msbs * parameter + lsbs;
|
||||
}
|
||||
|
||||
/* unfold unsigned to signed */
|
||||
/* unfold uint32_t to signed */
|
||||
if(uval & 1)
|
||||
*val = -((int)(uval >> 1)) - 1;
|
||||
else
|
||||
|
@ -892,10 +925,10 @@ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uns
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter)
|
||||
FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter)
|
||||
{
|
||||
FLAC__uint32 lsbs, msbs = 0;
|
||||
unsigned bit, k;
|
||||
uint32_t bit, k;
|
||||
|
||||
FLAC__ASSERT(0 != br);
|
||||
FLAC__ASSERT(0 != br->buffer);
|
||||
|
@ -915,7 +948,7 @@ FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *v
|
|||
*val = (msbs << k) | lsbs;
|
||||
}
|
||||
else {
|
||||
unsigned d = (1 << (k+1)) - parameter;
|
||||
uint32_t d = (1 << (k+1)) - parameter;
|
||||
if(lsbs >= d) {
|
||||
if(!FLAC__bitreader_read_bit(br, &bit))
|
||||
return false;
|
||||
|
@ -932,11 +965,11 @@ FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *v
|
|||
#endif /* UNUSED */
|
||||
|
||||
/* on return, if *val == 0xffffffff then the utf-8 sequence was invalid, but the return value will be true */
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen)
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen)
|
||||
{
|
||||
FLAC__uint32 v = 0;
|
||||
FLAC__uint32 x;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
|
||||
return false;
|
||||
|
@ -987,11 +1020,11 @@ FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *v
|
|||
}
|
||||
|
||||
/* on return, if *val == 0xffffffffffffffff then the utf-8 sequence was invalid, but the return value will be true */
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen)
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen)
|
||||
{
|
||||
FLAC__uint64 v = 0;
|
||||
FLAC__uint32 x;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
|
||||
return false;
|
||||
|
@ -1054,6 +1087,6 @@ FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *v
|
|||
* fix that we add extern declarations here.
|
||||
*/
|
||||
extern FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br);
|
||||
extern unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
|
||||
extern unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
|
||||
extern uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
|
||||
extern uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
|
||||
extern FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -46,46 +46,63 @@
|
|||
|
||||
/* Things should be fastest when this matches the machine word size */
|
||||
/* WATCHOUT: if you change this you must also change the following #defines down to SWAP_BE_WORD_TO_HOST below to match */
|
||||
/* WATCHOUT: there are a few places where the code will not work unless uint32_t is >= 32 bits wide */
|
||||
#define FLAC__BYTES_PER_WORD 4
|
||||
/* WATCHOUT: there are a few places where the code will not work unless bwword is >= 32 bits wide */
|
||||
|
||||
#if (ENABLE_64_BIT_WORDS == 0)
|
||||
|
||||
typedef FLAC__uint32 bwword;
|
||||
#define FLAC__BYTES_PER_WORD 4 /* sizeof bwword */
|
||||
#define FLAC__BITS_PER_WORD 32
|
||||
#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff)
|
||||
/* SWAP_BE_WORD_TO_HOST swaps bytes in a uint32_t (which is always big-endian) if necessary to match host byte order */
|
||||
/* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */
|
||||
#if WORDS_BIGENDIAN
|
||||
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
||||
#else
|
||||
#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_32(x)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
typedef FLAC__uint64 bwword;
|
||||
#define FLAC__BYTES_PER_WORD 8 /* sizeof bwword */
|
||||
#define FLAC__BITS_PER_WORD 64
|
||||
/* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */
|
||||
#if WORDS_BIGENDIAN
|
||||
#define SWAP_BE_WORD_TO_HOST(x) (x)
|
||||
#else
|
||||
#define SWAP_BE_WORD_TO_HOST(x) ENDSWAP_64(x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The default capacity here doesn't matter too much. The buffer always grows
|
||||
* to hold whatever is written to it. Usually the encoder will stop adding at
|
||||
* a frame or metadata block, then write that out and clear the buffer for the
|
||||
* next one.
|
||||
*/
|
||||
static const unsigned FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(uint32_t); /* size in words */
|
||||
static const uint32_t FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(bwword); /* size in words */
|
||||
/* When growing, increment 4K at a time */
|
||||
static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(uint32_t); /* size in words */
|
||||
static const uint32_t FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword); /* size in words */
|
||||
|
||||
#define FLAC__WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD)
|
||||
#define FLAC__TOTAL_BITS(bw) (FLAC__WORDS_TO_BITS((bw)->words) + (bw)->bits)
|
||||
|
||||
struct FLAC__BitWriter {
|
||||
uint32_t *buffer;
|
||||
uint32_t accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */
|
||||
unsigned capacity; /* capacity of buffer in words */
|
||||
unsigned words; /* # of complete words in buffer */
|
||||
unsigned bits; /* # of used bits in accum */
|
||||
bwword *buffer;
|
||||
bwword accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */
|
||||
uint32_t capacity; /* capacity of buffer in words */
|
||||
uint32_t words; /* # of complete words in buffer */
|
||||
uint32_t bits; /* # of used bits in accum */
|
||||
};
|
||||
|
||||
/* * WATCHOUT: The current implementation only grows the buffer. */
|
||||
#ifndef __SUNPRO_C
|
||||
static
|
||||
#endif
|
||||
FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add)
|
||||
FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, uint32_t bits_to_add)
|
||||
{
|
||||
unsigned new_capacity;
|
||||
uint32_t *new_buffer;
|
||||
uint32_t new_capacity;
|
||||
bwword *new_buffer;
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
|
@ -107,7 +124,7 @@ FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add)
|
|||
FLAC__ASSERT(new_capacity > bw->capacity);
|
||||
FLAC__ASSERT(new_capacity >= bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD));
|
||||
|
||||
new_buffer = safe_realloc_mul_2op_(bw->buffer, sizeof(uint32_t), /*times*/new_capacity);
|
||||
new_buffer = safe_realloc_mul_2op_(bw->buffer, sizeof(bwword), /*times*/new_capacity);
|
||||
if(new_buffer == 0)
|
||||
return false;
|
||||
bw->buffer = new_buffer;
|
||||
|
@ -149,7 +166,7 @@ FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw)
|
|||
|
||||
bw->words = bw->bits = 0;
|
||||
bw->capacity = FLAC__BITWRITER_DEFAULT_CAPACITY;
|
||||
bw->buffer = malloc(sizeof(uint32_t) * bw->capacity);
|
||||
bw->buffer = malloc(sizeof(bwword) * bw->capacity);
|
||||
if(bw->buffer == 0)
|
||||
return false;
|
||||
|
||||
|
@ -174,7 +191,7 @@ void FLAC__bitwriter_clear(FLAC__BitWriter *bw)
|
|||
|
||||
void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
if(bw == 0) {
|
||||
fprintf(out, "bitwriter is NULL\n");
|
||||
}
|
||||
|
@ -184,13 +201,13 @@ void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out)
|
|||
for(i = 0; i < bw->words; i++) {
|
||||
fprintf(out, "%08X: ", i);
|
||||
for(j = 0; j < FLAC__BITS_PER_WORD; j++)
|
||||
fprintf(out, "%01u", bw->buffer[i] & (1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0);
|
||||
fprintf(out, "%01d", bw->buffer[i] & ((bwword)1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
if(bw->bits > 0) {
|
||||
fprintf(out, "%08X: ", i);
|
||||
for(j = 0; j < bw->bits; j++)
|
||||
fprintf(out, "%01u", bw->accum & (1 << (bw->bits-j-1)) ? 1:0);
|
||||
fprintf(out, "%01d", bw->accum & ((bwword)1 << (bw->bits-j-1)) ? 1:0);
|
||||
fprintf(out, "\n");
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +248,7 @@ FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw)
|
|||
return ((bw->bits & 7) == 0);
|
||||
}
|
||||
|
||||
unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw)
|
||||
uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw)
|
||||
{
|
||||
return FLAC__TOTAL_BITS(bw);
|
||||
}
|
||||
|
@ -264,9 +281,9 @@ void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw)
|
|||
(void)bw;
|
||||
}
|
||||
|
||||
inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits)
|
||||
inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits)
|
||||
{
|
||||
unsigned n;
|
||||
uint32_t n;
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
|
@ -302,20 +319,24 @@ inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bit
|
|||
return true;
|
||||
}
|
||||
|
||||
inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits)
|
||||
static inline FLAC__bool FLAC__bitwriter_write_raw_uint32_nocheck(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits)
|
||||
{
|
||||
register unsigned left;
|
||||
register uint32_t left;
|
||||
|
||||
/* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
|
||||
FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
if(bw == 0 || bw->buffer == 0)
|
||||
return false;
|
||||
|
||||
if (bits > 32)
|
||||
return false;
|
||||
|
||||
FLAC__ASSERT(bits <= 32);
|
||||
if(bits == 0)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT((bits == 32) || (val>>bits == 0));
|
||||
|
||||
/* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */
|
||||
if(bw->capacity <= bw->words + bits && !bitwriter_grow_(bw, bits))
|
||||
return false;
|
||||
|
@ -330,33 +351,40 @@ inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__ui
|
|||
bw->accum <<= left;
|
||||
bw->accum |= val >> (bw->bits = bits - left);
|
||||
bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
|
||||
bw->accum = val;
|
||||
bw->accum = val; /* unused top bits can contain garbage */
|
||||
}
|
||||
else {
|
||||
bw->accum = val;
|
||||
bw->bits = 0;
|
||||
bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(val);
|
||||
else { /* at this point bits == FLAC__BITS_PER_WORD == 32 and bw->bits == 0 */
|
||||
bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST((bwword)val);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits)
|
||||
inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits)
|
||||
{
|
||||
/* check that unused bits are unset */
|
||||
if((bits < 32) && (val>>bits != 0))
|
||||
return false;
|
||||
|
||||
return FLAC__bitwriter_write_raw_uint32_nocheck(bw, val, bits);
|
||||
}
|
||||
|
||||
inline FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits)
|
||||
{
|
||||
/* zero-out unused bits */
|
||||
if(bits < 32)
|
||||
val &= (~(0xffffffff << bits));
|
||||
|
||||
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
|
||||
return FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, bits);
|
||||
}
|
||||
|
||||
inline FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits)
|
||||
inline FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits)
|
||||
{
|
||||
/* this could be a little faster but it's not used for much */
|
||||
if(bits > 32) {
|
||||
return
|
||||
FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)(val>>32), bits-32) &&
|
||||
FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, 32);
|
||||
FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, 32);
|
||||
}
|
||||
else
|
||||
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
|
||||
|
@ -366,66 +394,72 @@ inline FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter
|
|||
{
|
||||
/* this doesn't need to be that fast as currently it is only used for vorbis comments */
|
||||
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, val & 0xff, 8))
|
||||
if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, val & 0xff, 8))
|
||||
return false;
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, (val>>8) & 0xff, 8))
|
||||
if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, (val>>8) & 0xff, 8))
|
||||
return false;
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, (val>>16) & 0xff, 8))
|
||||
if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, (val>>16) & 0xff, 8))
|
||||
return false;
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, val>>24, 8))
|
||||
if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, val>>24, 8))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals)
|
||||
inline FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
/* grow capacity upfront to prevent constant reallocation during writes */
|
||||
if(bw->capacity <= bw->words + nvals / (FLAC__BITS_PER_WORD / 8) + 1 && !bitwriter_grow_(bw, nvals * 8))
|
||||
return false;
|
||||
|
||||
/* this could be faster but currently we don't need it to be since it's only used for writing metadata */
|
||||
for(i = 0; i < nvals; i++) {
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)(vals[i]), 8))
|
||||
if(!FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)(vals[i]), 8))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val)
|
||||
FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val)
|
||||
{
|
||||
if(val < 32)
|
||||
return FLAC__bitwriter_write_raw_uint32(bw, 1, ++val);
|
||||
return FLAC__bitwriter_write_raw_uint32_nocheck(bw, 1, ++val);
|
||||
else
|
||||
return
|
||||
FLAC__bitwriter_write_zeroes(bw, val) &&
|
||||
FLAC__bitwriter_write_raw_uint32(bw, 1, 1);
|
||||
FLAC__bitwriter_write_raw_uint32_nocheck(bw, 1, 1);
|
||||
}
|
||||
|
||||
unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter)
|
||||
uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter)
|
||||
{
|
||||
FLAC__uint32 uval;
|
||||
|
||||
FLAC__ASSERT(parameter < sizeof(unsigned)*8);
|
||||
FLAC__ASSERT(parameter < 32);
|
||||
|
||||
/* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */
|
||||
uval = (val<<1) ^ (val>>31);
|
||||
/* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */
|
||||
uval = val;
|
||||
uval <<= 1;
|
||||
uval ^= (val>>31);
|
||||
|
||||
return 1 + parameter + (uval >> parameter);
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter)
|
||||
uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter)
|
||||
{
|
||||
unsigned bits, msbs, uval;
|
||||
unsigned k;
|
||||
uint32_t bits, msbs, uval;
|
||||
uint32_t k;
|
||||
|
||||
FLAC__ASSERT(parameter > 0);
|
||||
|
||||
/* fold signed to unsigned */
|
||||
/* fold signed to uint32_t */
|
||||
if(val < 0)
|
||||
uval = (unsigned)(((-(++val)) << 1) + 1);
|
||||
uval = (uint32_t)(((-(++val)) << 1) + 1);
|
||||
else
|
||||
uval = (unsigned)(val << 1);
|
||||
uval = (uint32_t)(val << 1);
|
||||
|
||||
k = FLAC__bitmath_ilog2(parameter);
|
||||
if(parameter == 1u<<k) {
|
||||
|
@ -435,7 +469,7 @@ unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter)
|
|||
bits = 1 + k + msbs;
|
||||
}
|
||||
else {
|
||||
unsigned q, r, d;
|
||||
uint32_t q, r, d;
|
||||
|
||||
d = (1 << (k+1)) - parameter;
|
||||
q = uval / parameter;
|
||||
|
@ -448,10 +482,10 @@ unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter)
|
|||
return bits;
|
||||
}
|
||||
|
||||
unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter)
|
||||
uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t uval, uint32_t parameter)
|
||||
{
|
||||
unsigned bits, msbs;
|
||||
unsigned k;
|
||||
uint32_t bits, msbs;
|
||||
uint32_t k;
|
||||
|
||||
FLAC__ASSERT(parameter > 0);
|
||||
|
||||
|
@ -463,7 +497,7 @@ unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter)
|
|||
bits = 1 + k + msbs;
|
||||
}
|
||||
else {
|
||||
unsigned q, r, d;
|
||||
uint32_t q, r, d;
|
||||
|
||||
d = (1 << (k+1)) - parameter;
|
||||
q = uval / parameter;
|
||||
|
@ -477,17 +511,19 @@ unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter)
|
|||
}
|
||||
#endif /* UNUSED */
|
||||
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter)
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter)
|
||||
{
|
||||
unsigned total_bits, interesting_bits, msbs;
|
||||
uint32_t total_bits, interesting_bits, msbs;
|
||||
FLAC__uint32 uval, pattern;
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
FLAC__ASSERT(parameter < 8*sizeof(uval));
|
||||
FLAC__ASSERT(parameter < 32);
|
||||
|
||||
/* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */
|
||||
uval = (val<<1) ^ (val>>31);
|
||||
/* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */
|
||||
uval = val;
|
||||
uval <<= 1;
|
||||
uval ^= (val>>31);
|
||||
|
||||
msbs = uval >> parameter;
|
||||
interesting_bits = 1 + parameter;
|
||||
|
@ -503,39 +539,42 @@ FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 va
|
|||
FLAC__bitwriter_write_raw_uint32(bw, pattern, interesting_bits); /* write the unary end bit and binary LSBs */
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter)
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter)
|
||||
{
|
||||
const FLAC__uint32 mask1 = FLAC__WORD_ALL_ONES << parameter; /* we val|=mask1 to set the stop bit above it... */
|
||||
const FLAC__uint32 mask2 = FLAC__WORD_ALL_ONES >> (31-parameter); /* ...then mask off the bits above the stop bit with val&=mask2*/
|
||||
const FLAC__uint32 mask1 = (FLAC__uint32)0xffffffff << parameter; /* we val|=mask1 to set the stop bit above it... */
|
||||
const FLAC__uint32 mask2 = (FLAC__uint32)0xffffffff >> (31-parameter); /* ...then mask off the bits above the stop bit with val&=mask2 */
|
||||
FLAC__uint32 uval;
|
||||
unsigned left;
|
||||
const unsigned lsbits = 1 + parameter;
|
||||
unsigned msbits;
|
||||
uint32_t left;
|
||||
const uint32_t lsbits = 1 + parameter;
|
||||
uint32_t msbits, total_bits;
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
FLAC__ASSERT(parameter < 8*sizeof(uint32_t)-1);
|
||||
FLAC__ASSERT(parameter < 31);
|
||||
/* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
|
||||
FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
|
||||
|
||||
while(nvals) {
|
||||
/* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */
|
||||
uval = (*vals<<1) ^ (*vals>>31);
|
||||
/* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */
|
||||
uval = *vals;
|
||||
uval <<= 1;
|
||||
uval ^= (*vals>>31);
|
||||
|
||||
msbits = uval >> parameter;
|
||||
total_bits = lsbits + msbits;
|
||||
|
||||
if(bw->bits && bw->bits + msbits + lsbits < FLAC__BITS_PER_WORD) { /* i.e. if the whole thing fits in the current uint32_t */
|
||||
/* ^^^ if bw->bits is 0 then we may have filled the buffer and have no free uint32_t to work in */
|
||||
bw->bits = bw->bits + msbits + lsbits;
|
||||
if(bw->bits && bw->bits + total_bits < FLAC__BITS_PER_WORD) { /* i.e. if the whole thing fits in the current bwword */
|
||||
/* ^^^ if bw->bits is 0 then we may have filled the buffer and have no free bwword to work in */
|
||||
bw->bits += total_bits;
|
||||
uval |= mask1; /* set stop bit */
|
||||
uval &= mask2; /* mask off unused top bits */
|
||||
bw->accum <<= msbits + lsbits;
|
||||
bw->accum <<= total_bits;
|
||||
bw->accum |= uval;
|
||||
}
|
||||
else {
|
||||
/* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+msbits+lsbits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */
|
||||
/* OPT: pessimism may cause flurry of false calls to grow_ which eat up all savings before it */
|
||||
if(bw->capacity <= bw->words + bw->bits + msbits + 1/*lsbits always fit in 1 uint32_t*/ && !bitwriter_grow_(bw, msbits+lsbits))
|
||||
if(bw->capacity <= bw->words + bw->bits + msbits + 1 /* lsbits always fit in 1 bwword */ && !bitwriter_grow_(bw, total_bits))
|
||||
return false;
|
||||
|
||||
if(msbits) {
|
||||
|
@ -585,7 +624,7 @@ break1:
|
|||
bw->accum <<= left;
|
||||
bw->accum |= uval >> (bw->bits = lsbits - left);
|
||||
bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
|
||||
bw->accum = uval;
|
||||
bw->accum = uval; /* unused top bits can contain garbage */
|
||||
}
|
||||
}
|
||||
vals++;
|
||||
|
@ -595,24 +634,24 @@ break1:
|
|||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter)
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter)
|
||||
{
|
||||
unsigned total_bits, msbs, uval;
|
||||
unsigned k;
|
||||
uint32_t total_bits, msbs, uval;
|
||||
uint32_t k;
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
FLAC__ASSERT(parameter > 0);
|
||||
|
||||
/* fold signed to unsigned */
|
||||
/* fold signed to uint32_t */
|
||||
if(val < 0)
|
||||
uval = (unsigned)(((-(++val)) << 1) + 1);
|
||||
uval = (uint32_t)(((-(++val)) << 1) + 1);
|
||||
else
|
||||
uval = (unsigned)(val << 1);
|
||||
uval = (uint32_t)(val << 1);
|
||||
|
||||
k = FLAC__bitmath_ilog2(parameter);
|
||||
if(parameter == 1u<<k) {
|
||||
unsigned pattern;
|
||||
uint32_t pattern;
|
||||
|
||||
FLAC__ASSERT(k <= 30);
|
||||
|
||||
|
@ -635,7 +674,7 @@ FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uns
|
|||
}
|
||||
}
|
||||
else {
|
||||
unsigned q, r, d;
|
||||
uint32_t q, r, d;
|
||||
|
||||
d = (1 << (k+1)) - parameter;
|
||||
q = uval / parameter;
|
||||
|
@ -659,10 +698,10 @@ FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uns
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned uval, unsigned parameter)
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t uval, uint32_t parameter)
|
||||
{
|
||||
unsigned total_bits, msbs;
|
||||
unsigned k;
|
||||
uint32_t total_bits, msbs;
|
||||
uint32_t k;
|
||||
|
||||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
|
@ -670,7 +709,7 @@ FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned u
|
|||
|
||||
k = FLAC__bitmath_ilog2(parameter);
|
||||
if(parameter == 1u<<k) {
|
||||
unsigned pattern;
|
||||
uint32_t pattern;
|
||||
|
||||
FLAC__ASSERT(k <= 30);
|
||||
|
||||
|
@ -693,7 +732,7 @@ FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned u
|
|||
}
|
||||
}
|
||||
else {
|
||||
unsigned q, r, d;
|
||||
uint32_t q, r, d;
|
||||
|
||||
d = (1 << (k+1)) - parameter;
|
||||
q = uval / parameter;
|
||||
|
@ -725,40 +764,41 @@ FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 v
|
|||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
|
||||
FLAC__ASSERT(!(val & 0x80000000)); /* this version only handles 31 bits */
|
||||
if((val & 0x80000000) != 0) /* this version only handles 31 bits */
|
||||
return false;
|
||||
|
||||
if(val < 0x80) {
|
||||
return FLAC__bitwriter_write_raw_uint32(bw, val, 8);
|
||||
return FLAC__bitwriter_write_raw_uint32_nocheck(bw, val, 8);
|
||||
}
|
||||
else if(val < 0x800) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xC0 | (val>>6), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xC0 | (val>>6), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x10000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xE0 | (val>>12), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xE0 | (val>>12), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x200000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF0 | (val>>18), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF0 | (val>>18), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x4000000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF8 | (val>>24), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF8 | (val>>24), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8);
|
||||
}
|
||||
else {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xFC | (val>>30), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>24)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xFC | (val>>30), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>24)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | ((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (val&0x3F), 8);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -771,49 +811,50 @@ FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 v
|
|||
FLAC__ASSERT(0 != bw);
|
||||
FLAC__ASSERT(0 != bw->buffer);
|
||||
|
||||
FLAC__ASSERT(!(val & FLAC__U64L(0xFFFFFFF000000000))); /* this version only handles 36 bits */
|
||||
if((val & FLAC__U64L(0xFFFFFFF000000000)) != 0) /* this version only handles 36 bits */
|
||||
return false;
|
||||
|
||||
if(val < 0x80) {
|
||||
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, 8);
|
||||
return FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, 8);
|
||||
}
|
||||
else if(val < 0x800) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xC0 | (FLAC__uint32)(val>>6), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xC0 | (FLAC__uint32)(val>>6), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x10000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xE0 | (FLAC__uint32)(val>>12), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xE0 | (FLAC__uint32)(val>>12), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x200000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF0 | (FLAC__uint32)(val>>18), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF0 | (FLAC__uint32)(val>>18), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x4000000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF8 | (FLAC__uint32)(val>>24), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xF8 | (FLAC__uint32)(val>>24), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
}
|
||||
else if(val < 0x80000000) {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xFC | (FLAC__uint32)(val>>30), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xFC | (FLAC__uint32)(val>>30), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
}
|
||||
else {
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xFE, 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>30)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0xFE, 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>30)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
|
||||
ok &= FLAC__bitwriter_write_raw_uint32_nocheck(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
@ -836,8 +877,9 @@ FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw)
|
|||
* Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To
|
||||
* fix that we add extern declarations here.
|
||||
*/
|
||||
extern FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits);
|
||||
extern FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val);
|
||||
extern FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals);
|
||||
extern FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -35,371 +35,9 @@
|
|||
#endif
|
||||
|
||||
#include "private/cpu.h"
|
||||
#include "private/memory.h"
|
||||
#include "share/compat.h"
|
||||
#include <stdlib.h>
|
||||
#ifdef DEBUG
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#if defined FLAC__CPU_IA32
|
||||
# include <signal.h>
|
||||
|
||||
static void disable_sse(FLAC__CPUInfo *info)
|
||||
{
|
||||
info->ia32.sse = false;
|
||||
info->ia32.sse2 = false;
|
||||
info->ia32.sse3 = false;
|
||||
info->ia32.ssse3 = false;
|
||||
info->ia32.sse41 = false;
|
||||
info->ia32.sse42 = false;
|
||||
}
|
||||
|
||||
static void disable_avx(FLAC__CPUInfo *info)
|
||||
{
|
||||
info->ia32.avx = false;
|
||||
info->ia32.avx2 = false;
|
||||
info->ia32.fma = false;
|
||||
}
|
||||
|
||||
#elif defined FLAC__CPU_X86_64
|
||||
|
||||
static void disable_avx(FLAC__CPUInfo *info)
|
||||
{
|
||||
info->x86.avx = false;
|
||||
info->x86.avx2 = false;
|
||||
info->x86.fma = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/cpu.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
/* how to get sysctlbyname()? */
|
||||
#endif
|
||||
|
||||
#ifdef FLAC__CPU_IA32
|
||||
/* these are flags in EDX of CPUID AX=00000001 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_FXSR = 0x01000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000;
|
||||
#endif
|
||||
|
||||
/* these are flags in ECX of CPUID AX=00000001 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE41 = 0x00080000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE42 = 0x00100000;
|
||||
|
||||
#if defined FLAC__AVX_SUPPORTED
|
||||
/* these are flags in ECX of CPUID AX=00000001 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_OSXSAVE = 0x08000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_AVX = 0x10000000;
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_FMA = 0x00001000;
|
||||
/* these are flags in EBX of CPUID AX=00000007 */
|
||||
static const unsigned FLAC__CPUINFO_IA32_CPUID_AVX2 = 0x00000020;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Extra stuff needed for detection of OS support for SSE on IA-32
|
||||
*/
|
||||
#if defined(FLAC__CPU_IA32) && !defined FLAC__NO_ASM && (defined FLAC__HAS_NASM || defined FLAC__HAS_X86INTRIN) && !defined FLAC__NO_SSE_OS && !defined FLAC__SSE_OS
|
||||
# if defined(__linux__)
|
||||
/*
|
||||
* If the OS doesn't support SSE, we will get here with a SIGILL. We
|
||||
* modify the return address to jump over the offending SSE instruction
|
||||
* and also the operation following it that indicates the instruction
|
||||
* executed successfully. In this way we use no global variables and
|
||||
* stay thread-safe.
|
||||
*
|
||||
* 3 + 3 + 6:
|
||||
* 3 bytes for "xorps xmm0,xmm0"
|
||||
* 3 bytes for estimate of how long the follwing "inc var" instruction is
|
||||
* 6 bytes extra in case our estimate is wrong
|
||||
* 12 bytes puts us in the NOP "landing zone"
|
||||
*/
|
||||
# include <sys/ucontext.h>
|
||||
static void sigill_handler_sse_os(int signal, siginfo_t *si, void *uc)
|
||||
{
|
||||
(void)signal, (void)si;
|
||||
((ucontext_t*)uc)->uc_mcontext.gregs[14/*REG_EIP*/] += 3 + 3 + 6;
|
||||
}
|
||||
# elif defined(_MSC_VER)
|
||||
# include <windows.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
void FLAC__cpu_info(FLAC__CPUInfo *info)
|
||||
{
|
||||
/*
|
||||
* IA32-specific
|
||||
*/
|
||||
#ifdef FLAC__CPU_IA32
|
||||
FLAC__bool ia32_fxsr = false;
|
||||
FLAC__bool ia32_osxsave = false;
|
||||
(void) ia32_fxsr; (void) ia32_osxsave; /* to avoid warnings about unused variables */
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->type = FLAC__CPUINFO_TYPE_IA32;
|
||||
#if !defined FLAC__NO_ASM && (defined FLAC__HAS_NASM || defined FLAC__HAS_X86INTRIN)
|
||||
info->use_asm = true; /* we assume a minimum of 80386 with FLAC__CPU_IA32 */
|
||||
#ifdef FLAC__HAS_X86INTRIN
|
||||
if(!FLAC__cpu_have_cpuid_x86())
|
||||
return;
|
||||
#else
|
||||
if(!FLAC__cpu_have_cpuid_asm_ia32())
|
||||
return;
|
||||
#endif
|
||||
{
|
||||
/* http://www.sandpile.org/x86/cpuid.htm */
|
||||
#ifdef FLAC__HAS_X86INTRIN
|
||||
FLAC__uint32 flags_eax, flags_ebx, flags_ecx, flags_edx;
|
||||
FLAC__cpu_info_x86(1, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
#else
|
||||
FLAC__uint32 flags_ecx, flags_edx;
|
||||
FLAC__cpu_info_asm_ia32(&flags_edx, &flags_ecx);
|
||||
#endif
|
||||
info->ia32.cmov = (flags_edx & FLAC__CPUINFO_IA32_CPUID_CMOV )? true : false;
|
||||
info->ia32.mmx = (flags_edx & FLAC__CPUINFO_IA32_CPUID_MMX )? true : false;
|
||||
ia32_fxsr = (flags_edx & FLAC__CPUINFO_IA32_CPUID_FXSR )? true : false;
|
||||
info->ia32.sse = (flags_edx & FLAC__CPUINFO_IA32_CPUID_SSE )? true : false;
|
||||
info->ia32.sse2 = (flags_edx & FLAC__CPUINFO_IA32_CPUID_SSE2 )? true : false;
|
||||
info->ia32.sse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE3 )? true : false;
|
||||
info->ia32.ssse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSSE3)? true : false;
|
||||
info->ia32.sse41 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE41)? true : false;
|
||||
info->ia32.sse42 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE42)? true : false;
|
||||
#if defined FLAC__HAS_X86INTRIN && defined FLAC__AVX_SUPPORTED
|
||||
ia32_osxsave = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_OSXSAVE)? true : false;
|
||||
info->ia32.avx = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_AVX )? true : false;
|
||||
info->ia32.fma = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_FMA )? true : false;
|
||||
FLAC__cpu_info_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
info->ia32.avx2 = (flags_ebx & FLAC__CPUINFO_IA32_CPUID_AVX2 )? true : false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "CPU info (IA-32):\n");
|
||||
fprintf(stderr, " CMOV ....... %c\n", info->ia32.cmov ? 'Y' : 'n');
|
||||
fprintf(stderr, " MMX ........ %c\n", info->ia32.mmx ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE ........ %c\n", info->ia32.sse ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE2 ....... %c\n", info->ia32.sse2 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE3 ....... %c\n", info->ia32.sse3 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSSE3 ...... %c\n", info->ia32.ssse3 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE41 ...... %c\n", info->ia32.sse41 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE42 ...... %c\n", info->ia32.sse42 ? 'Y' : 'n');
|
||||
# if defined FLAC__HAS_X86INTRIN && defined FLAC__AVX_SUPPORTED
|
||||
fprintf(stderr, " AVX ........ %c\n", info->ia32.avx ? 'Y' : 'n');
|
||||
fprintf(stderr, " FMA ........ %c\n", info->ia32.fma ? 'Y' : 'n');
|
||||
fprintf(stderr, " AVX2 ....... %c\n", info->ia32.avx2 ? 'Y' : 'n');
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* now have to check for OS support of SSE instructions
|
||||
*/
|
||||
if(info->ia32.sse) {
|
||||
#if defined FLAC__NO_SSE_OS
|
||||
/* assume user knows better than us; turn it off */
|
||||
disable_sse(info);
|
||||
#elif defined FLAC__SSE_OS
|
||||
/* assume user knows better than us; leave as detected above */
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__APPLE__)
|
||||
int sse = 0;
|
||||
size_t len;
|
||||
/* at least one of these must work: */
|
||||
len = sizeof(sse); sse = sse || (sysctlbyname("hw.instruction_sse", &sse, &len, NULL, 0) == 0 && sse);
|
||||
len = sizeof(sse); sse = sse || (sysctlbyname("hw.optional.sse" , &sse, &len, NULL, 0) == 0 && sse); /* __APPLE__ ? */
|
||||
if(!sse)
|
||||
disable_sse(info);
|
||||
#elif defined(__NetBSD__) || defined (__OpenBSD__)
|
||||
# if __NetBSD_Version__ >= 105250000 || (defined __OpenBSD__)
|
||||
int val = 0, mib[2] = { CTL_MACHDEP, CPU_SSE };
|
||||
size_t len = sizeof(val);
|
||||
if(sysctl(mib, 2, &val, &len, NULL, 0) < 0 || !val)
|
||||
disable_sse(info);
|
||||
else { /* double-check SSE2 */
|
||||
mib[1] = CPU_SSE2;
|
||||
len = sizeof(val);
|
||||
if(sysctl(mib, 2, &val, &len, NULL, 0) < 0 || !val) {
|
||||
disable_sse(info);
|
||||
info->ia32.sse = true;
|
||||
}
|
||||
}
|
||||
# else
|
||||
disable_sse(info);
|
||||
# endif
|
||||
#elif defined(__linux__)
|
||||
int sse = 0;
|
||||
struct sigaction sigill_save;
|
||||
struct sigaction sigill_sse;
|
||||
sigill_sse.sa_sigaction = sigill_handler_sse_os;
|
||||
__sigemptyset(&sigill_sse.sa_mask);
|
||||
sigill_sse.sa_flags = SA_SIGINFO | SA_RESETHAND; /* SA_RESETHAND just in case our SIGILL return jump breaks, so we don't get stuck in a loop */
|
||||
if(0 == sigaction(SIGILL, &sigill_sse, &sigill_save))
|
||||
{
|
||||
/* http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html */
|
||||
/* see sigill_handler_sse_os() for an explanation of the following: */
|
||||
asm volatile (
|
||||
"xorps %%xmm0,%%xmm0\n\t" /* will cause SIGILL if unsupported by OS */
|
||||
"incl %0\n\t" /* SIGILL handler will jump over this */
|
||||
/* landing zone */
|
||||
"nop\n\t" /* SIGILL jump lands here if "inc" is 9 bytes */
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t"
|
||||
"nop\n\t" /* SIGILL jump lands here if "inc" is 3 bytes (expected) */
|
||||
"nop\n\t"
|
||||
"nop" /* SIGILL jump lands here if "inc" is 1 byte */
|
||||
: "=r"(sse)
|
||||
: "0"(sse)
|
||||
);
|
||||
|
||||
sigaction(SIGILL, &sigill_save, NULL);
|
||||
}
|
||||
|
||||
if(!sse)
|
||||
disable_sse(info);
|
||||
#elif defined(_MSC_VER)
|
||||
__try {
|
||||
__asm {
|
||||
xorps xmm0,xmm0
|
||||
}
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
|
||||
disable_sse(info);
|
||||
}
|
||||
#elif defined(__GNUC__) /* MinGW goes here */
|
||||
int sse = 0;
|
||||
/* Based on the idea described in Agner Fog's manual "Optimizing subroutines in assembly language" */
|
||||
/* In theory, not guaranteed to detect lack of OS SSE support on some future Intel CPUs, but in practice works (see the aforementioned manual) */
|
||||
if (ia32_fxsr) {
|
||||
struct {
|
||||
FLAC__uint32 buff[128];
|
||||
} __attribute__((aligned(16))) fxsr;
|
||||
FLAC__uint32 old_val, new_val;
|
||||
|
||||
asm volatile ("fxsave %0" : "=m" (fxsr) : "m" (fxsr));
|
||||
old_val = fxsr.buff[50];
|
||||
fxsr.buff[50] ^= 0x0013c0de; /* change value in the buffer */
|
||||
asm volatile ("fxrstor %0" : "=m" (fxsr) : "m" (fxsr)); /* try to change SSE register */
|
||||
fxsr.buff[50] = old_val; /* restore old value in the buffer */
|
||||
asm volatile ("fxsave %0 " : "=m" (fxsr) : "m" (fxsr)); /* old value will be overwritten if SSE register was changed */
|
||||
new_val = fxsr.buff[50]; /* == old_val if FXRSTOR didn't change SSE register and (old_val ^ 0x0013c0de) otherwise */
|
||||
fxsr.buff[50] = old_val; /* again restore old value in the buffer */
|
||||
asm volatile ("fxrstor %0" : "=m" (fxsr) : "m" (fxsr)); /* restore old values of registers */
|
||||
|
||||
if ((old_val^new_val) == 0x0013c0de)
|
||||
sse = 1;
|
||||
}
|
||||
if(!sse)
|
||||
disable_sse(info);
|
||||
#else
|
||||
/* no way to test, disable to be safe */
|
||||
disable_sse(info);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " SSE OS sup . %c\n", info->ia32.sse ? 'Y' : 'n');
|
||||
#endif
|
||||
}
|
||||
else /* info->ia32.sse == false */
|
||||
disable_sse(info);
|
||||
|
||||
/*
|
||||
* now have to check for OS support of AVX instructions
|
||||
*/
|
||||
if(info->ia32.avx && ia32_osxsave) {
|
||||
FLAC__uint32 ecr = FLAC__cpu_xgetbv_x86();
|
||||
if ((ecr & 0x6) != 0x6)
|
||||
disable_avx(info);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " AVX OS sup . %c\n", info->ia32.avx ? 'Y' : 'n');
|
||||
#endif
|
||||
}
|
||||
else /* no OS AVX support*/
|
||||
disable_avx(info);
|
||||
#else
|
||||
info->use_asm = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* x86-64-specific
|
||||
*/
|
||||
#elif defined FLAC__CPU_X86_64
|
||||
FLAC__bool x86_osxsave = false;
|
||||
(void) x86_osxsave; /* to avoid warnings about unused variables */
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->type = FLAC__CPUINFO_TYPE_X86_64;
|
||||
#if !defined FLAC__NO_ASM && defined FLAC__HAS_X86INTRIN
|
||||
info->use_asm = true;
|
||||
{
|
||||
/* http://www.sandpile.org/x86/cpuid.htm */
|
||||
FLAC__uint32 flags_eax, flags_ebx, flags_ecx, flags_edx;
|
||||
FLAC__cpu_info_x86(1, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
info->x86.sse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE3 )? true : false;
|
||||
info->x86.ssse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSSE3)? true : false;
|
||||
info->x86.sse41 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE41)? true : false;
|
||||
info->x86.sse42 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE42)? true : false;
|
||||
#if defined FLAC__AVX_SUPPORTED
|
||||
x86_osxsave = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_OSXSAVE)? true : false;
|
||||
info->x86.avx = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_AVX )? true : false;
|
||||
info->x86.fma = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_FMA )? true : false;
|
||||
FLAC__cpu_info_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_IA32_CPUID_AVX2 )? true : false;
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "CPU info (x86-64):\n");
|
||||
fprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n');
|
||||
fprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n');
|
||||
# if defined FLAC__AVX_SUPPORTED
|
||||
fprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n');
|
||||
fprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n');
|
||||
fprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n');
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* now have to check for OS support of AVX instructions
|
||||
*/
|
||||
if(info->x86.avx && x86_osxsave) {
|
||||
FLAC__uint32 ecr = FLAC__cpu_xgetbv_x86();
|
||||
if ((ecr & 0x6) != 0x6)
|
||||
disable_avx(info);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n');
|
||||
#endif
|
||||
}
|
||||
else /* no OS AVX support*/
|
||||
disable_avx(info);
|
||||
#else
|
||||
info->use_asm = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* unknown CPU
|
||||
*/
|
||||
#else
|
||||
info->type = FLAC__CPUINFO_TYPE_UNKNOWN;
|
||||
info->use_asm = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN
|
||||
#include <string.h>
|
||||
|
||||
#if defined _MSC_VER
|
||||
#include <intrin.h> /* for __cpuid() and _xgetbv() */
|
||||
|
@ -407,12 +45,66 @@ void FLAC__cpu_info(FLAC__CPUInfo *info)
|
|||
#include <cpuid.h> /* for __get_cpuid() and __get_cpuid_max() */
|
||||
#endif
|
||||
|
||||
FLAC__uint32 FLAC__cpu_have_cpuid_x86(void)
|
||||
{
|
||||
#ifdef FLAC__CPU_X86_64
|
||||
return 1;
|
||||
#ifndef NDEBUG
|
||||
#include <stdio.h>
|
||||
#define dfprintf fprintf
|
||||
#else
|
||||
# if defined _MSC_VER || defined __INTEL_COMPILER /* Do they support CPUs w/o CPUID support (or OSes that work on those CPUs)? */
|
||||
/* This is bad practice, it should be a static void empty function */
|
||||
#define dfprintf(file, format, ...)
|
||||
#endif
|
||||
|
||||
#if defined FLAC__CPU_PPC
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
|
||||
#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && (defined FLAC__HAS_NASM || FLAC__HAS_X86INTRIN) && !defined FLAC__NO_ASM
|
||||
|
||||
/* these are flags in EDX of CPUID AX=00000001 */
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_CMOV = 0x00008000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_MMX = 0x00800000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE = 0x02000000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE2 = 0x04000000;
|
||||
|
||||
/* these are flags in ECX of CPUID AX=00000001 */
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE3 = 0x00000001;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_SSSE3 = 0x00000200;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE41 = 0x00080000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_SSE42 = 0x00100000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_OSXSAVE = 0x08000000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX = 0x10000000;
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_FMA = 0x00001000;
|
||||
|
||||
/* these are flags in EBX of CPUID AX=00000007 */
|
||||
static const uint32_t FLAC__CPUINFO_X86_CPUID_AVX2 = 0x00000020;
|
||||
|
||||
static uint32_t
|
||||
cpu_xgetbv_x86(void)
|
||||
{
|
||||
#if (defined _MSC_VER || defined __INTEL_COMPILER) && FLAC__AVX_SUPPORTED
|
||||
return (uint32_t)_xgetbv(0);
|
||||
#elif defined __GNUC__
|
||||
uint32_t lo, hi;
|
||||
__asm__ volatile (".byte 0x0f, 0x01, 0xd0" : "=a"(lo), "=d"(hi) : "c" (0));
|
||||
return lo;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
cpu_have_cpuid(void)
|
||||
{
|
||||
#if defined FLAC__CPU_X86_64 || defined __i686__ || defined __SSE__ || (defined _M_IX86_FP && _M_IX86_FP > 0)
|
||||
/* target CPU does have CPUID instruction */
|
||||
return 1;
|
||||
#elif defined FLAC__HAS_NASM
|
||||
return FLAC__cpu_have_cpuid_asm_ia32();
|
||||
#elif defined __GNUC__ && defined HAVE_CPUID_H
|
||||
if (__get_cpuid_max(0, 0) != 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
#elif defined _MSC_VER
|
||||
FLAC__uint32 flags1, flags2;
|
||||
__asm {
|
||||
pushfd
|
||||
|
@ -431,57 +123,163 @@ FLAC__uint32 FLAC__cpu_have_cpuid_x86(void)
|
|||
return 1;
|
||||
else
|
||||
return 0;
|
||||
# elif defined __GNUC__ && defined HAVE_CPUID_H
|
||||
if (__get_cpuid_max(0, 0) != 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
# else
|
||||
#else
|
||||
return 0;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx)
|
||||
static void
|
||||
cpuinfo_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx)
|
||||
{
|
||||
#if defined _MSC_VER || defined __INTEL_COMPILER
|
||||
#if defined _MSC_VER
|
||||
int cpuinfo[4];
|
||||
int ext = level & 0x80000000;
|
||||
__cpuid(cpuinfo, ext);
|
||||
if((unsigned)cpuinfo[0] < level) {
|
||||
*eax = *ebx = *ecx = *edx = 0;
|
||||
if ((uint32_t)cpuinfo[0] >= level) {
|
||||
#if FLAC__AVX_SUPPORTED
|
||||
__cpuidex(cpuinfo, level, 0); /* for AVX2 detection */
|
||||
#else
|
||||
__cpuid(cpuinfo, level); /* some old compilers don't support __cpuidex */
|
||||
#endif
|
||||
*eax = cpuinfo[0]; *ebx = cpuinfo[1]; *ecx = cpuinfo[2]; *edx = cpuinfo[3];
|
||||
return;
|
||||
}
|
||||
#if defined FLAC__AVX_SUPPORTED
|
||||
__cpuidex(cpuinfo, level, 0); /* for AVX2 detection */
|
||||
#else
|
||||
__cpuid(cpuinfo, level); /* some old compilers don't support __cpuidex */
|
||||
#endif
|
||||
*eax = cpuinfo[0]; *ebx = cpuinfo[1]; *ecx = cpuinfo[2]; *edx = cpuinfo[3];
|
||||
#elif defined __GNUC__ && defined HAVE_CPUID_H
|
||||
FLAC__uint32 ext = level & 0x80000000;
|
||||
__cpuid(ext, *eax, *ebx, *ecx, *edx);
|
||||
if (*eax < level) {
|
||||
*eax = *ebx = *ecx = *edx = 0;
|
||||
if (*eax >= level) {
|
||||
__cpuid_count(level, 0, *eax, *ebx, *ecx, *edx);
|
||||
return;
|
||||
}
|
||||
__cpuid_count(level, 0, *eax, *ebx, *ecx, *edx);
|
||||
#else
|
||||
#elif defined FLAC__HAS_NASM && defined FLAC__CPU_IA32
|
||||
FLAC__cpu_info_asm_ia32(level, eax, ebx, ecx, edx);
|
||||
return;
|
||||
#endif
|
||||
*eax = *ebx = *ecx = *edx = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
FLAC__uint32 FLAC__cpu_xgetbv_x86(void)
|
||||
#endif
|
||||
|
||||
static void
|
||||
x86_cpu_info (FLAC__CPUInfo *info)
|
||||
{
|
||||
#if (defined _MSC_VER || defined __INTEL_COMPILER) && defined FLAC__AVX_SUPPORTED
|
||||
return (FLAC__uint32)_xgetbv(0);
|
||||
#elif defined __GNUC__
|
||||
FLAC__uint32 lo, hi;
|
||||
asm volatile (".byte 0x0f, 0x01, 0xd0" : "=a"(lo), "=d"(hi) : "c" (0));
|
||||
return lo;
|
||||
#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && (defined FLAC__HAS_NASM || FLAC__HAS_X86INTRIN) && !defined FLAC__NO_ASM
|
||||
FLAC__bool x86_osxsave = false;
|
||||
FLAC__bool os_avx = false;
|
||||
FLAC__uint32 flags_eax, flags_ebx, flags_ecx, flags_edx;
|
||||
|
||||
info->use_asm = true; /* we assume a minimum of 80386 */
|
||||
if (!cpu_have_cpuid())
|
||||
return;
|
||||
|
||||
cpuinfo_x86(0, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
info->x86.intel = (flags_ebx == 0x756E6547 && flags_edx == 0x49656E69 && flags_ecx == 0x6C65746E) ? true : false; /* GenuineIntel */
|
||||
cpuinfo_x86(1, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
|
||||
info->x86.cmov = (flags_edx & FLAC__CPUINFO_X86_CPUID_CMOV ) ? true : false;
|
||||
info->x86.mmx = (flags_edx & FLAC__CPUINFO_X86_CPUID_MMX ) ? true : false;
|
||||
info->x86.sse = (flags_edx & FLAC__CPUINFO_X86_CPUID_SSE ) ? true : false;
|
||||
info->x86.sse2 = (flags_edx & FLAC__CPUINFO_X86_CPUID_SSE2 ) ? true : false;
|
||||
info->x86.sse3 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE3 ) ? true : false;
|
||||
info->x86.ssse3 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSSE3) ? true : false;
|
||||
info->x86.sse41 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE41) ? true : false;
|
||||
info->x86.sse42 = (flags_ecx & FLAC__CPUINFO_X86_CPUID_SSE42) ? true : false;
|
||||
|
||||
if (FLAC__AVX_SUPPORTED) {
|
||||
x86_osxsave = (flags_ecx & FLAC__CPUINFO_X86_CPUID_OSXSAVE) ? true : false;
|
||||
info->x86.avx = (flags_ecx & FLAC__CPUINFO_X86_CPUID_AVX ) ? true : false;
|
||||
info->x86.fma = (flags_ecx & FLAC__CPUINFO_X86_CPUID_FMA ) ? true : false;
|
||||
cpuinfo_x86(7, &flags_eax, &flags_ebx, &flags_ecx, &flags_edx);
|
||||
info->x86.avx2 = (flags_ebx & FLAC__CPUINFO_X86_CPUID_AVX2 ) ? true : false;
|
||||
}
|
||||
|
||||
#if defined FLAC__CPU_IA32
|
||||
dfprintf(stderr, "CPU info (IA-32):\n");
|
||||
#else
|
||||
return 0;
|
||||
dfprintf(stderr, "CPU info (x86-64):\n");
|
||||
#endif
|
||||
dfprintf(stderr, " CMOV ....... %c\n", info->x86.cmov ? 'Y' : 'n');
|
||||
dfprintf(stderr, " MMX ........ %c\n", info->x86.mmx ? 'Y' : 'n');
|
||||
dfprintf(stderr, " SSE ........ %c\n", info->x86.sse ? 'Y' : 'n');
|
||||
dfprintf(stderr, " SSE2 ....... %c\n", info->x86.sse2 ? 'Y' : 'n');
|
||||
dfprintf(stderr, " SSE3 ....... %c\n", info->x86.sse3 ? 'Y' : 'n');
|
||||
dfprintf(stderr, " SSSE3 ...... %c\n", info->x86.ssse3 ? 'Y' : 'n');
|
||||
dfprintf(stderr, " SSE41 ...... %c\n", info->x86.sse41 ? 'Y' : 'n');
|
||||
dfprintf(stderr, " SSE42 ...... %c\n", info->x86.sse42 ? 'Y' : 'n');
|
||||
|
||||
if (FLAC__AVX_SUPPORTED) {
|
||||
dfprintf(stderr, " AVX ........ %c\n", info->x86.avx ? 'Y' : 'n');
|
||||
dfprintf(stderr, " FMA ........ %c\n", info->x86.fma ? 'Y' : 'n');
|
||||
dfprintf(stderr, " AVX2 ....... %c\n", info->x86.avx2 ? 'Y' : 'n');
|
||||
}
|
||||
|
||||
/*
|
||||
* now have to check for OS support of AVX instructions
|
||||
*/
|
||||
if (FLAC__AVX_SUPPORTED && info->x86.avx && x86_osxsave && (cpu_xgetbv_x86() & 0x6) == 0x6) {
|
||||
os_avx = true;
|
||||
}
|
||||
if (os_avx) {
|
||||
dfprintf(stderr, " AVX OS sup . %c\n", info->x86.avx ? 'Y' : 'n');
|
||||
}
|
||||
if (!os_avx) {
|
||||
/* no OS AVX support */
|
||||
info->x86.avx = false;
|
||||
info->x86.avx2 = false;
|
||||
info->x86.fma = false;
|
||||
}
|
||||
#else
|
||||
info->use_asm = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */
|
||||
static void
|
||||
ppc_cpu_info (FLAC__CPUInfo *info)
|
||||
{
|
||||
#if defined FLAC__CPU_PPC
|
||||
#ifndef PPC_FEATURE2_ARCH_3_00
|
||||
#define PPC_FEATURE2_ARCH_3_00 0x00800000
|
||||
#endif
|
||||
|
||||
#ifndef PPC_FEATURE2_ARCH_2_07
|
||||
#define PPC_FEATURE2_ARCH_2_07 0x80000000
|
||||
#endif
|
||||
|
||||
if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00) {
|
||||
info->ppc.arch_3_00 = true;
|
||||
} else if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07) {
|
||||
info->ppc.arch_2_07 = true;
|
||||
}
|
||||
#else
|
||||
info->ppc.arch_2_07 = false;
|
||||
info->ppc.arch_3_00 = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void FLAC__cpu_info (FLAC__CPUInfo *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
|
||||
#ifdef FLAC__CPU_IA32
|
||||
info->type = FLAC__CPUINFO_TYPE_IA32;
|
||||
#elif defined FLAC__CPU_X86_64
|
||||
info->type = FLAC__CPUINFO_TYPE_X86_64;
|
||||
#elif defined FLAC__CPU_PPC
|
||||
info->type = FLAC__CPUINFO_TYPE_PPC;
|
||||
#else
|
||||
info->type = FLAC__CPUINFO_TYPE_UNKNOWN;
|
||||
#endif
|
||||
|
||||
switch (info->type) {
|
||||
case FLAC__CPUINFO_TYPE_IA32: /* fallthrough */
|
||||
case FLAC__CPUINFO_TYPE_X86_64:
|
||||
x86_cpu_info (info);
|
||||
break;
|
||||
case FLAC__CPUINFO_TYPE_PPC:
|
||||
ppc_cpu_info (info);
|
||||
break;
|
||||
default:
|
||||
info->use_asm = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2018 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
/* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */
|
||||
|
||||
FLAC__byte const FLAC__crc8_table[256] = {
|
||||
FLAC__uint8 const FLAC__crc8_table[256] = {
|
||||
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15,
|
||||
0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
|
||||
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
|
||||
|
@ -75,8 +75,8 @@ FLAC__byte const FLAC__crc8_table[256] = {
|
|||
|
||||
/* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */
|
||||
|
||||
unsigned const FLAC__crc16_table[256] = {
|
||||
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
|
||||
FLAC__uint16 const FLAC__crc16_table[8][256] = {
|
||||
{ 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
|
||||
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
|
||||
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
|
||||
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
|
||||
|
@ -107,22 +107,263 @@ unsigned const FLAC__crc16_table[256] = {
|
|||
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
|
||||
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
|
||||
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
|
||||
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
|
||||
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202 },
|
||||
|
||||
{ 0x0000, 0x8603, 0x8c03, 0x0a00, 0x9803, 0x1e00, 0x1400, 0x9203,
|
||||
0xb003, 0x3600, 0x3c00, 0xba03, 0x2800, 0xae03, 0xa403, 0x2200,
|
||||
0xe003, 0x6600, 0x6c00, 0xea03, 0x7800, 0xfe03, 0xf403, 0x7200,
|
||||
0x5000, 0xd603, 0xdc03, 0x5a00, 0xc803, 0x4e00, 0x4400, 0xc203,
|
||||
0x4003, 0xc600, 0xcc00, 0x4a03, 0xd800, 0x5e03, 0x5403, 0xd200,
|
||||
0xf000, 0x7603, 0x7c03, 0xfa00, 0x6803, 0xee00, 0xe400, 0x6203,
|
||||
0xa000, 0x2603, 0x2c03, 0xaa00, 0x3803, 0xbe00, 0xb400, 0x3203,
|
||||
0x1003, 0x9600, 0x9c00, 0x1a03, 0x8800, 0x0e03, 0x0403, 0x8200,
|
||||
0x8006, 0x0605, 0x0c05, 0x8a06, 0x1805, 0x9e06, 0x9406, 0x1205,
|
||||
0x3005, 0xb606, 0xbc06, 0x3a05, 0xa806, 0x2e05, 0x2405, 0xa206,
|
||||
0x6005, 0xe606, 0xec06, 0x6a05, 0xf806, 0x7e05, 0x7405, 0xf206,
|
||||
0xd006, 0x5605, 0x5c05, 0xda06, 0x4805, 0xce06, 0xc406, 0x4205,
|
||||
0xc005, 0x4606, 0x4c06, 0xca05, 0x5806, 0xde05, 0xd405, 0x5206,
|
||||
0x7006, 0xf605, 0xfc05, 0x7a06, 0xe805, 0x6e06, 0x6406, 0xe205,
|
||||
0x2006, 0xa605, 0xac05, 0x2a06, 0xb805, 0x3e06, 0x3406, 0xb205,
|
||||
0x9005, 0x1606, 0x1c06, 0x9a05, 0x0806, 0x8e05, 0x8405, 0x0206,
|
||||
0x8009, 0x060a, 0x0c0a, 0x8a09, 0x180a, 0x9e09, 0x9409, 0x120a,
|
||||
0x300a, 0xb609, 0xbc09, 0x3a0a, 0xa809, 0x2e0a, 0x240a, 0xa209,
|
||||
0x600a, 0xe609, 0xec09, 0x6a0a, 0xf809, 0x7e0a, 0x740a, 0xf209,
|
||||
0xd009, 0x560a, 0x5c0a, 0xda09, 0x480a, 0xce09, 0xc409, 0x420a,
|
||||
0xc00a, 0x4609, 0x4c09, 0xca0a, 0x5809, 0xde0a, 0xd40a, 0x5209,
|
||||
0x7009, 0xf60a, 0xfc0a, 0x7a09, 0xe80a, 0x6e09, 0x6409, 0xe20a,
|
||||
0x2009, 0xa60a, 0xac0a, 0x2a09, 0xb80a, 0x3e09, 0x3409, 0xb20a,
|
||||
0x900a, 0x1609, 0x1c09, 0x9a0a, 0x0809, 0x8e0a, 0x840a, 0x0209,
|
||||
0x000f, 0x860c, 0x8c0c, 0x0a0f, 0x980c, 0x1e0f, 0x140f, 0x920c,
|
||||
0xb00c, 0x360f, 0x3c0f, 0xba0c, 0x280f, 0xae0c, 0xa40c, 0x220f,
|
||||
0xe00c, 0x660f, 0x6c0f, 0xea0c, 0x780f, 0xfe0c, 0xf40c, 0x720f,
|
||||
0x500f, 0xd60c, 0xdc0c, 0x5a0f, 0xc80c, 0x4e0f, 0x440f, 0xc20c,
|
||||
0x400c, 0xc60f, 0xcc0f, 0x4a0c, 0xd80f, 0x5e0c, 0x540c, 0xd20f,
|
||||
0xf00f, 0x760c, 0x7c0c, 0xfa0f, 0x680c, 0xee0f, 0xe40f, 0x620c,
|
||||
0xa00f, 0x260c, 0x2c0c, 0xaa0f, 0x380c, 0xbe0f, 0xb40f, 0x320c,
|
||||
0x100c, 0x960f, 0x9c0f, 0x1a0c, 0x880f, 0x0e0c, 0x040c, 0x820f },
|
||||
|
||||
{ 0x0000, 0x8017, 0x802b, 0x003c, 0x8053, 0x0044, 0x0078, 0x806f,
|
||||
0x80a3, 0x00b4, 0x0088, 0x809f, 0x00f0, 0x80e7, 0x80db, 0x00cc,
|
||||
0x8143, 0x0154, 0x0168, 0x817f, 0x0110, 0x8107, 0x813b, 0x012c,
|
||||
0x01e0, 0x81f7, 0x81cb, 0x01dc, 0x81b3, 0x01a4, 0x0198, 0x818f,
|
||||
0x8283, 0x0294, 0x02a8, 0x82bf, 0x02d0, 0x82c7, 0x82fb, 0x02ec,
|
||||
0x0220, 0x8237, 0x820b, 0x021c, 0x8273, 0x0264, 0x0258, 0x824f,
|
||||
0x03c0, 0x83d7, 0x83eb, 0x03fc, 0x8393, 0x0384, 0x03b8, 0x83af,
|
||||
0x8363, 0x0374, 0x0348, 0x835f, 0x0330, 0x8327, 0x831b, 0x030c,
|
||||
0x8503, 0x0514, 0x0528, 0x853f, 0x0550, 0x8547, 0x857b, 0x056c,
|
||||
0x05a0, 0x85b7, 0x858b, 0x059c, 0x85f3, 0x05e4, 0x05d8, 0x85cf,
|
||||
0x0440, 0x8457, 0x846b, 0x047c, 0x8413, 0x0404, 0x0438, 0x842f,
|
||||
0x84e3, 0x04f4, 0x04c8, 0x84df, 0x04b0, 0x84a7, 0x849b, 0x048c,
|
||||
0x0780, 0x8797, 0x87ab, 0x07bc, 0x87d3, 0x07c4, 0x07f8, 0x87ef,
|
||||
0x8723, 0x0734, 0x0708, 0x871f, 0x0770, 0x8767, 0x875b, 0x074c,
|
||||
0x86c3, 0x06d4, 0x06e8, 0x86ff, 0x0690, 0x8687, 0x86bb, 0x06ac,
|
||||
0x0660, 0x8677, 0x864b, 0x065c, 0x8633, 0x0624, 0x0618, 0x860f,
|
||||
0x8a03, 0x0a14, 0x0a28, 0x8a3f, 0x0a50, 0x8a47, 0x8a7b, 0x0a6c,
|
||||
0x0aa0, 0x8ab7, 0x8a8b, 0x0a9c, 0x8af3, 0x0ae4, 0x0ad8, 0x8acf,
|
||||
0x0b40, 0x8b57, 0x8b6b, 0x0b7c, 0x8b13, 0x0b04, 0x0b38, 0x8b2f,
|
||||
0x8be3, 0x0bf4, 0x0bc8, 0x8bdf, 0x0bb0, 0x8ba7, 0x8b9b, 0x0b8c,
|
||||
0x0880, 0x8897, 0x88ab, 0x08bc, 0x88d3, 0x08c4, 0x08f8, 0x88ef,
|
||||
0x8823, 0x0834, 0x0808, 0x881f, 0x0870, 0x8867, 0x885b, 0x084c,
|
||||
0x89c3, 0x09d4, 0x09e8, 0x89ff, 0x0990, 0x8987, 0x89bb, 0x09ac,
|
||||
0x0960, 0x8977, 0x894b, 0x095c, 0x8933, 0x0924, 0x0918, 0x890f,
|
||||
0x0f00, 0x8f17, 0x8f2b, 0x0f3c, 0x8f53, 0x0f44, 0x0f78, 0x8f6f,
|
||||
0x8fa3, 0x0fb4, 0x0f88, 0x8f9f, 0x0ff0, 0x8fe7, 0x8fdb, 0x0fcc,
|
||||
0x8e43, 0x0e54, 0x0e68, 0x8e7f, 0x0e10, 0x8e07, 0x8e3b, 0x0e2c,
|
||||
0x0ee0, 0x8ef7, 0x8ecb, 0x0edc, 0x8eb3, 0x0ea4, 0x0e98, 0x8e8f,
|
||||
0x8d83, 0x0d94, 0x0da8, 0x8dbf, 0x0dd0, 0x8dc7, 0x8dfb, 0x0dec,
|
||||
0x0d20, 0x8d37, 0x8d0b, 0x0d1c, 0x8d73, 0x0d64, 0x0d58, 0x8d4f,
|
||||
0x0cc0, 0x8cd7, 0x8ceb, 0x0cfc, 0x8c93, 0x0c84, 0x0cb8, 0x8caf,
|
||||
0x8c63, 0x0c74, 0x0c48, 0x8c5f, 0x0c30, 0x8c27, 0x8c1b, 0x0c0c },
|
||||
|
||||
{ 0x0000, 0x9403, 0xa803, 0x3c00, 0xd003, 0x4400, 0x7800, 0xec03,
|
||||
0x2003, 0xb400, 0x8800, 0x1c03, 0xf000, 0x6403, 0x5803, 0xcc00,
|
||||
0x4006, 0xd405, 0xe805, 0x7c06, 0x9005, 0x0406, 0x3806, 0xac05,
|
||||
0x6005, 0xf406, 0xc806, 0x5c05, 0xb006, 0x2405, 0x1805, 0x8c06,
|
||||
0x800c, 0x140f, 0x280f, 0xbc0c, 0x500f, 0xc40c, 0xf80c, 0x6c0f,
|
||||
0xa00f, 0x340c, 0x080c, 0x9c0f, 0x700c, 0xe40f, 0xd80f, 0x4c0c,
|
||||
0xc00a, 0x5409, 0x6809, 0xfc0a, 0x1009, 0x840a, 0xb80a, 0x2c09,
|
||||
0xe009, 0x740a, 0x480a, 0xdc09, 0x300a, 0xa409, 0x9809, 0x0c0a,
|
||||
0x801d, 0x141e, 0x281e, 0xbc1d, 0x501e, 0xc41d, 0xf81d, 0x6c1e,
|
||||
0xa01e, 0x341d, 0x081d, 0x9c1e, 0x701d, 0xe41e, 0xd81e, 0x4c1d,
|
||||
0xc01b, 0x5418, 0x6818, 0xfc1b, 0x1018, 0x841b, 0xb81b, 0x2c18,
|
||||
0xe018, 0x741b, 0x481b, 0xdc18, 0x301b, 0xa418, 0x9818, 0x0c1b,
|
||||
0x0011, 0x9412, 0xa812, 0x3c11, 0xd012, 0x4411, 0x7811, 0xec12,
|
||||
0x2012, 0xb411, 0x8811, 0x1c12, 0xf011, 0x6412, 0x5812, 0xcc11,
|
||||
0x4017, 0xd414, 0xe814, 0x7c17, 0x9014, 0x0417, 0x3817, 0xac14,
|
||||
0x6014, 0xf417, 0xc817, 0x5c14, 0xb017, 0x2414, 0x1814, 0x8c17,
|
||||
0x803f, 0x143c, 0x283c, 0xbc3f, 0x503c, 0xc43f, 0xf83f, 0x6c3c,
|
||||
0xa03c, 0x343f, 0x083f, 0x9c3c, 0x703f, 0xe43c, 0xd83c, 0x4c3f,
|
||||
0xc039, 0x543a, 0x683a, 0xfc39, 0x103a, 0x8439, 0xb839, 0x2c3a,
|
||||
0xe03a, 0x7439, 0x4839, 0xdc3a, 0x3039, 0xa43a, 0x983a, 0x0c39,
|
||||
0x0033, 0x9430, 0xa830, 0x3c33, 0xd030, 0x4433, 0x7833, 0xec30,
|
||||
0x2030, 0xb433, 0x8833, 0x1c30, 0xf033, 0x6430, 0x5830, 0xcc33,
|
||||
0x4035, 0xd436, 0xe836, 0x7c35, 0x9036, 0x0435, 0x3835, 0xac36,
|
||||
0x6036, 0xf435, 0xc835, 0x5c36, 0xb035, 0x2436, 0x1836, 0x8c35,
|
||||
0x0022, 0x9421, 0xa821, 0x3c22, 0xd021, 0x4422, 0x7822, 0xec21,
|
||||
0x2021, 0xb422, 0x8822, 0x1c21, 0xf022, 0x6421, 0x5821, 0xcc22,
|
||||
0x4024, 0xd427, 0xe827, 0x7c24, 0x9027, 0x0424, 0x3824, 0xac27,
|
||||
0x6027, 0xf424, 0xc824, 0x5c27, 0xb024, 0x2427, 0x1827, 0x8c24,
|
||||
0x802e, 0x142d, 0x282d, 0xbc2e, 0x502d, 0xc42e, 0xf82e, 0x6c2d,
|
||||
0xa02d, 0x342e, 0x082e, 0x9c2d, 0x702e, 0xe42d, 0xd82d, 0x4c2e,
|
||||
0xc028, 0x542b, 0x682b, 0xfc28, 0x102b, 0x8428, 0xb828, 0x2c2b,
|
||||
0xe02b, 0x7428, 0x4828, 0xdc2b, 0x3028, 0xa42b, 0x982b, 0x0c28 },
|
||||
|
||||
{ 0x0000, 0x807b, 0x80f3, 0x0088, 0x81e3, 0x0198, 0x0110, 0x816b,
|
||||
0x83c3, 0x03b8, 0x0330, 0x834b, 0x0220, 0x825b, 0x82d3, 0x02a8,
|
||||
0x8783, 0x07f8, 0x0770, 0x870b, 0x0660, 0x861b, 0x8693, 0x06e8,
|
||||
0x0440, 0x843b, 0x84b3, 0x04c8, 0x85a3, 0x05d8, 0x0550, 0x852b,
|
||||
0x8f03, 0x0f78, 0x0ff0, 0x8f8b, 0x0ee0, 0x8e9b, 0x8e13, 0x0e68,
|
||||
0x0cc0, 0x8cbb, 0x8c33, 0x0c48, 0x8d23, 0x0d58, 0x0dd0, 0x8dab,
|
||||
0x0880, 0x88fb, 0x8873, 0x0808, 0x8963, 0x0918, 0x0990, 0x89eb,
|
||||
0x8b43, 0x0b38, 0x0bb0, 0x8bcb, 0x0aa0, 0x8adb, 0x8a53, 0x0a28,
|
||||
0x9e03, 0x1e78, 0x1ef0, 0x9e8b, 0x1fe0, 0x9f9b, 0x9f13, 0x1f68,
|
||||
0x1dc0, 0x9dbb, 0x9d33, 0x1d48, 0x9c23, 0x1c58, 0x1cd0, 0x9cab,
|
||||
0x1980, 0x99fb, 0x9973, 0x1908, 0x9863, 0x1818, 0x1890, 0x98eb,
|
||||
0x9a43, 0x1a38, 0x1ab0, 0x9acb, 0x1ba0, 0x9bdb, 0x9b53, 0x1b28,
|
||||
0x1100, 0x917b, 0x91f3, 0x1188, 0x90e3, 0x1098, 0x1010, 0x906b,
|
||||
0x92c3, 0x12b8, 0x1230, 0x924b, 0x1320, 0x935b, 0x93d3, 0x13a8,
|
||||
0x9683, 0x16f8, 0x1670, 0x960b, 0x1760, 0x971b, 0x9793, 0x17e8,
|
||||
0x1540, 0x953b, 0x95b3, 0x15c8, 0x94a3, 0x14d8, 0x1450, 0x942b,
|
||||
0xbc03, 0x3c78, 0x3cf0, 0xbc8b, 0x3de0, 0xbd9b, 0xbd13, 0x3d68,
|
||||
0x3fc0, 0xbfbb, 0xbf33, 0x3f48, 0xbe23, 0x3e58, 0x3ed0, 0xbeab,
|
||||
0x3b80, 0xbbfb, 0xbb73, 0x3b08, 0xba63, 0x3a18, 0x3a90, 0xbaeb,
|
||||
0xb843, 0x3838, 0x38b0, 0xb8cb, 0x39a0, 0xb9db, 0xb953, 0x3928,
|
||||
0x3300, 0xb37b, 0xb3f3, 0x3388, 0xb2e3, 0x3298, 0x3210, 0xb26b,
|
||||
0xb0c3, 0x30b8, 0x3030, 0xb04b, 0x3120, 0xb15b, 0xb1d3, 0x31a8,
|
||||
0xb483, 0x34f8, 0x3470, 0xb40b, 0x3560, 0xb51b, 0xb593, 0x35e8,
|
||||
0x3740, 0xb73b, 0xb7b3, 0x37c8, 0xb6a3, 0x36d8, 0x3650, 0xb62b,
|
||||
0x2200, 0xa27b, 0xa2f3, 0x2288, 0xa3e3, 0x2398, 0x2310, 0xa36b,
|
||||
0xa1c3, 0x21b8, 0x2130, 0xa14b, 0x2020, 0xa05b, 0xa0d3, 0x20a8,
|
||||
0xa583, 0x25f8, 0x2570, 0xa50b, 0x2460, 0xa41b, 0xa493, 0x24e8,
|
||||
0x2640, 0xa63b, 0xa6b3, 0x26c8, 0xa7a3, 0x27d8, 0x2750, 0xa72b,
|
||||
0xad03, 0x2d78, 0x2df0, 0xad8b, 0x2ce0, 0xac9b, 0xac13, 0x2c68,
|
||||
0x2ec0, 0xaebb, 0xae33, 0x2e48, 0xaf23, 0x2f58, 0x2fd0, 0xafab,
|
||||
0x2a80, 0xaafb, 0xaa73, 0x2a08, 0xab63, 0x2b18, 0x2b90, 0xabeb,
|
||||
0xa943, 0x2938, 0x29b0, 0xa9cb, 0x28a0, 0xa8db, 0xa853, 0x2828 },
|
||||
|
||||
{ 0x0000, 0xf803, 0x7003, 0x8800, 0xe006, 0x1805, 0x9005, 0x6806,
|
||||
0x4009, 0xb80a, 0x300a, 0xc809, 0xa00f, 0x580c, 0xd00c, 0x280f,
|
||||
0x8012, 0x7811, 0xf011, 0x0812, 0x6014, 0x9817, 0x1017, 0xe814,
|
||||
0xc01b, 0x3818, 0xb018, 0x481b, 0x201d, 0xd81e, 0x501e, 0xa81d,
|
||||
0x8021, 0x7822, 0xf022, 0x0821, 0x6027, 0x9824, 0x1024, 0xe827,
|
||||
0xc028, 0x382b, 0xb02b, 0x4828, 0x202e, 0xd82d, 0x502d, 0xa82e,
|
||||
0x0033, 0xf830, 0x7030, 0x8833, 0xe035, 0x1836, 0x9036, 0x6835,
|
||||
0x403a, 0xb839, 0x3039, 0xc83a, 0xa03c, 0x583f, 0xd03f, 0x283c,
|
||||
0x8047, 0x7844, 0xf044, 0x0847, 0x6041, 0x9842, 0x1042, 0xe841,
|
||||
0xc04e, 0x384d, 0xb04d, 0x484e, 0x2048, 0xd84b, 0x504b, 0xa848,
|
||||
0x0055, 0xf856, 0x7056, 0x8855, 0xe053, 0x1850, 0x9050, 0x6853,
|
||||
0x405c, 0xb85f, 0x305f, 0xc85c, 0xa05a, 0x5859, 0xd059, 0x285a,
|
||||
0x0066, 0xf865, 0x7065, 0x8866, 0xe060, 0x1863, 0x9063, 0x6860,
|
||||
0x406f, 0xb86c, 0x306c, 0xc86f, 0xa069, 0x586a, 0xd06a, 0x2869,
|
||||
0x8074, 0x7877, 0xf077, 0x0874, 0x6072, 0x9871, 0x1071, 0xe872,
|
||||
0xc07d, 0x387e, 0xb07e, 0x487d, 0x207b, 0xd878, 0x5078, 0xa87b,
|
||||
0x808b, 0x7888, 0xf088, 0x088b, 0x608d, 0x988e, 0x108e, 0xe88d,
|
||||
0xc082, 0x3881, 0xb081, 0x4882, 0x2084, 0xd887, 0x5087, 0xa884,
|
||||
0x0099, 0xf89a, 0x709a, 0x8899, 0xe09f, 0x189c, 0x909c, 0x689f,
|
||||
0x4090, 0xb893, 0x3093, 0xc890, 0xa096, 0x5895, 0xd095, 0x2896,
|
||||
0x00aa, 0xf8a9, 0x70a9, 0x88aa, 0xe0ac, 0x18af, 0x90af, 0x68ac,
|
||||
0x40a3, 0xb8a0, 0x30a0, 0xc8a3, 0xa0a5, 0x58a6, 0xd0a6, 0x28a5,
|
||||
0x80b8, 0x78bb, 0xf0bb, 0x08b8, 0x60be, 0x98bd, 0x10bd, 0xe8be,
|
||||
0xc0b1, 0x38b2, 0xb0b2, 0x48b1, 0x20b7, 0xd8b4, 0x50b4, 0xa8b7,
|
||||
0x00cc, 0xf8cf, 0x70cf, 0x88cc, 0xe0ca, 0x18c9, 0x90c9, 0x68ca,
|
||||
0x40c5, 0xb8c6, 0x30c6, 0xc8c5, 0xa0c3, 0x58c0, 0xd0c0, 0x28c3,
|
||||
0x80de, 0x78dd, 0xf0dd, 0x08de, 0x60d8, 0x98db, 0x10db, 0xe8d8,
|
||||
0xc0d7, 0x38d4, 0xb0d4, 0x48d7, 0x20d1, 0xd8d2, 0x50d2, 0xa8d1,
|
||||
0x80ed, 0x78ee, 0xf0ee, 0x08ed, 0x60eb, 0x98e8, 0x10e8, 0xe8eb,
|
||||
0xc0e4, 0x38e7, 0xb0e7, 0x48e4, 0x20e2, 0xd8e1, 0x50e1, 0xa8e2,
|
||||
0x00ff, 0xf8fc, 0x70fc, 0x88ff, 0xe0f9, 0x18fa, 0x90fa, 0x68f9,
|
||||
0x40f6, 0xb8f5, 0x30f5, 0xc8f6, 0xa0f0, 0x58f3, 0xd0f3, 0x28f0 },
|
||||
|
||||
{ 0x0000, 0x8113, 0x8223, 0x0330, 0x8443, 0x0550, 0x0660, 0x8773,
|
||||
0x8883, 0x0990, 0x0aa0, 0x8bb3, 0x0cc0, 0x8dd3, 0x8ee3, 0x0ff0,
|
||||
0x9103, 0x1010, 0x1320, 0x9233, 0x1540, 0x9453, 0x9763, 0x1670,
|
||||
0x1980, 0x9893, 0x9ba3, 0x1ab0, 0x9dc3, 0x1cd0, 0x1fe0, 0x9ef3,
|
||||
0xa203, 0x2310, 0x2020, 0xa133, 0x2640, 0xa753, 0xa463, 0x2570,
|
||||
0x2a80, 0xab93, 0xa8a3, 0x29b0, 0xaec3, 0x2fd0, 0x2ce0, 0xadf3,
|
||||
0x3300, 0xb213, 0xb123, 0x3030, 0xb743, 0x3650, 0x3560, 0xb473,
|
||||
0xbb83, 0x3a90, 0x39a0, 0xb8b3, 0x3fc0, 0xbed3, 0xbde3, 0x3cf0,
|
||||
0xc403, 0x4510, 0x4620, 0xc733, 0x4040, 0xc153, 0xc263, 0x4370,
|
||||
0x4c80, 0xcd93, 0xcea3, 0x4fb0, 0xc8c3, 0x49d0, 0x4ae0, 0xcbf3,
|
||||
0x5500, 0xd413, 0xd723, 0x5630, 0xd143, 0x5050, 0x5360, 0xd273,
|
||||
0xdd83, 0x5c90, 0x5fa0, 0xdeb3, 0x59c0, 0xd8d3, 0xdbe3, 0x5af0,
|
||||
0x6600, 0xe713, 0xe423, 0x6530, 0xe243, 0x6350, 0x6060, 0xe173,
|
||||
0xee83, 0x6f90, 0x6ca0, 0xedb3, 0x6ac0, 0xebd3, 0xe8e3, 0x69f0,
|
||||
0xf703, 0x7610, 0x7520, 0xf433, 0x7340, 0xf253, 0xf163, 0x7070,
|
||||
0x7f80, 0xfe93, 0xfda3, 0x7cb0, 0xfbc3, 0x7ad0, 0x79e0, 0xf8f3,
|
||||
0x0803, 0x8910, 0x8a20, 0x0b33, 0x8c40, 0x0d53, 0x0e63, 0x8f70,
|
||||
0x8080, 0x0193, 0x02a3, 0x83b0, 0x04c3, 0x85d0, 0x86e0, 0x07f3,
|
||||
0x9900, 0x1813, 0x1b23, 0x9a30, 0x1d43, 0x9c50, 0x9f60, 0x1e73,
|
||||
0x1183, 0x9090, 0x93a0, 0x12b3, 0x95c0, 0x14d3, 0x17e3, 0x96f0,
|
||||
0xaa00, 0x2b13, 0x2823, 0xa930, 0x2e43, 0xaf50, 0xac60, 0x2d73,
|
||||
0x2283, 0xa390, 0xa0a0, 0x21b3, 0xa6c0, 0x27d3, 0x24e3, 0xa5f0,
|
||||
0x3b03, 0xba10, 0xb920, 0x3833, 0xbf40, 0x3e53, 0x3d63, 0xbc70,
|
||||
0xb380, 0x3293, 0x31a3, 0xb0b0, 0x37c3, 0xb6d0, 0xb5e0, 0x34f3,
|
||||
0xcc00, 0x4d13, 0x4e23, 0xcf30, 0x4843, 0xc950, 0xca60, 0x4b73,
|
||||
0x4483, 0xc590, 0xc6a0, 0x47b3, 0xc0c0, 0x41d3, 0x42e3, 0xc3f0,
|
||||
0x5d03, 0xdc10, 0xdf20, 0x5e33, 0xd940, 0x5853, 0x5b63, 0xda70,
|
||||
0xd580, 0x5493, 0x57a3, 0xd6b0, 0x51c3, 0xd0d0, 0xd3e0, 0x52f3,
|
||||
0x6e03, 0xef10, 0xec20, 0x6d33, 0xea40, 0x6b53, 0x6863, 0xe970,
|
||||
0xe680, 0x6793, 0x64a3, 0xe5b0, 0x62c3, 0xe3d0, 0xe0e0, 0x61f3,
|
||||
0xff00, 0x7e13, 0x7d23, 0xfc30, 0x7b43, 0xfa50, 0xf960, 0x7873,
|
||||
0x7783, 0xf690, 0xf5a0, 0x74b3, 0xf3c0, 0x72d3, 0x71e3, 0xf0f0 },
|
||||
|
||||
{ 0x0000, 0x1006, 0x200c, 0x300a, 0x4018, 0x501e, 0x6014, 0x7012,
|
||||
0x8030, 0x9036, 0xa03c, 0xb03a, 0xc028, 0xd02e, 0xe024, 0xf022,
|
||||
0x8065, 0x9063, 0xa069, 0xb06f, 0xc07d, 0xd07b, 0xe071, 0xf077,
|
||||
0x0055, 0x1053, 0x2059, 0x305f, 0x404d, 0x504b, 0x6041, 0x7047,
|
||||
0x80cf, 0x90c9, 0xa0c3, 0xb0c5, 0xc0d7, 0xd0d1, 0xe0db, 0xf0dd,
|
||||
0x00ff, 0x10f9, 0x20f3, 0x30f5, 0x40e7, 0x50e1, 0x60eb, 0x70ed,
|
||||
0x00aa, 0x10ac, 0x20a6, 0x30a0, 0x40b2, 0x50b4, 0x60be, 0x70b8,
|
||||
0x809a, 0x909c, 0xa096, 0xb090, 0xc082, 0xd084, 0xe08e, 0xf088,
|
||||
0x819b, 0x919d, 0xa197, 0xb191, 0xc183, 0xd185, 0xe18f, 0xf189,
|
||||
0x01ab, 0x11ad, 0x21a7, 0x31a1, 0x41b3, 0x51b5, 0x61bf, 0x71b9,
|
||||
0x01fe, 0x11f8, 0x21f2, 0x31f4, 0x41e6, 0x51e0, 0x61ea, 0x71ec,
|
||||
0x81ce, 0x91c8, 0xa1c2, 0xb1c4, 0xc1d6, 0xd1d0, 0xe1da, 0xf1dc,
|
||||
0x0154, 0x1152, 0x2158, 0x315e, 0x414c, 0x514a, 0x6140, 0x7146,
|
||||
0x8164, 0x9162, 0xa168, 0xb16e, 0xc17c, 0xd17a, 0xe170, 0xf176,
|
||||
0x8131, 0x9137, 0xa13d, 0xb13b, 0xc129, 0xd12f, 0xe125, 0xf123,
|
||||
0x0101, 0x1107, 0x210d, 0x310b, 0x4119, 0x511f, 0x6115, 0x7113,
|
||||
0x8333, 0x9335, 0xa33f, 0xb339, 0xc32b, 0xd32d, 0xe327, 0xf321,
|
||||
0x0303, 0x1305, 0x230f, 0x3309, 0x431b, 0x531d, 0x6317, 0x7311,
|
||||
0x0356, 0x1350, 0x235a, 0x335c, 0x434e, 0x5348, 0x6342, 0x7344,
|
||||
0x8366, 0x9360, 0xa36a, 0xb36c, 0xc37e, 0xd378, 0xe372, 0xf374,
|
||||
0x03fc, 0x13fa, 0x23f0, 0x33f6, 0x43e4, 0x53e2, 0x63e8, 0x73ee,
|
||||
0x83cc, 0x93ca, 0xa3c0, 0xb3c6, 0xc3d4, 0xd3d2, 0xe3d8, 0xf3de,
|
||||
0x8399, 0x939f, 0xa395, 0xb393, 0xc381, 0xd387, 0xe38d, 0xf38b,
|
||||
0x03a9, 0x13af, 0x23a5, 0x33a3, 0x43b1, 0x53b7, 0x63bd, 0x73bb,
|
||||
0x02a8, 0x12ae, 0x22a4, 0x32a2, 0x42b0, 0x52b6, 0x62bc, 0x72ba,
|
||||
0x8298, 0x929e, 0xa294, 0xb292, 0xc280, 0xd286, 0xe28c, 0xf28a,
|
||||
0x82cd, 0x92cb, 0xa2c1, 0xb2c7, 0xc2d5, 0xd2d3, 0xe2d9, 0xf2df,
|
||||
0x02fd, 0x12fb, 0x22f1, 0x32f7, 0x42e5, 0x52e3, 0x62e9, 0x72ef,
|
||||
0x8267, 0x9261, 0xa26b, 0xb26d, 0xc27f, 0xd279, 0xe273, 0xf275,
|
||||
0x0257, 0x1251, 0x225b, 0x325d, 0x424f, 0x5249, 0x6243, 0x7245,
|
||||
0x0202, 0x1204, 0x220e, 0x3208, 0x421a, 0x521c, 0x6216, 0x7210,
|
||||
0x8232, 0x9234, 0xa23e, 0xb238, 0xc22a, 0xd22c, 0xe226, 0xf220 }
|
||||
};
|
||||
|
||||
|
||||
void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc)
|
||||
#if 0
|
||||
void FLAC__crc16_init_table(void)
|
||||
{
|
||||
*crc = FLAC__crc8_table[*crc ^ data];
|
||||
}
|
||||
int i, j;
|
||||
FLAC__uint16 polynomial, crc;
|
||||
polynomial = 0x8005;
|
||||
|
||||
void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc)
|
||||
{
|
||||
while(len--)
|
||||
*crc = FLAC__crc8_table[*crc ^ *data++];
|
||||
}
|
||||
for(i = 0; i <= 0xFF; i++){
|
||||
crc = i << 8;
|
||||
|
||||
FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len)
|
||||
for(j = 0; j < 8; j++)
|
||||
crc = (crc << 1) ^ (crc & (1 << 15) ? polynomial : 0);
|
||||
|
||||
FLAC__crc16_table[0][i] = crc;
|
||||
}
|
||||
|
||||
for(i = 0; i <= 0xFF; i++)
|
||||
for(j = 1; j < 8; j++)
|
||||
FLAC__crc16_table[j][i] = FLAC__crc16_table[0][FLAC__crc16_table[j - 1][i] >> 8] ^ (FLAC__crc16_table[j - 1][i] << 8);
|
||||
}
|
||||
#endif
|
||||
|
||||
FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len)
|
||||
{
|
||||
FLAC__uint8 crc = 0;
|
||||
|
||||
|
@ -132,12 +373,64 @@ FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len)
|
|||
return crc;
|
||||
}
|
||||
|
||||
unsigned FLAC__crc16(const FLAC__byte *data, unsigned len)
|
||||
FLAC__uint16 FLAC__crc16(const FLAC__byte *data, uint32_t len)
|
||||
{
|
||||
unsigned crc = 0;
|
||||
FLAC__uint16 crc = 0;
|
||||
|
||||
while(len >= 8){
|
||||
crc ^= data[0] << 8 | data[1];
|
||||
|
||||
crc = FLAC__crc16_table[7][crc >> 8] ^ FLAC__crc16_table[6][crc & 0xFF] ^
|
||||
FLAC__crc16_table[5][data[2] ] ^ FLAC__crc16_table[4][data[3] ] ^
|
||||
FLAC__crc16_table[3][data[4] ] ^ FLAC__crc16_table[2][data[5] ] ^
|
||||
FLAC__crc16_table[1][data[6] ] ^ FLAC__crc16_table[0][data[7] ];
|
||||
|
||||
data += 8;
|
||||
len -= 8;
|
||||
}
|
||||
|
||||
while(len--)
|
||||
crc = ((crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]) & 0xffff;
|
||||
crc = (crc<<8) ^ FLAC__crc16_table[0][(crc>>8) ^ *data++];
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
FLAC__uint16 FLAC__crc16_update_words32(const FLAC__uint32 *words, uint32_t len, FLAC__uint16 crc)
|
||||
{
|
||||
while (len >= 2) {
|
||||
crc ^= words[0] >> 16;
|
||||
|
||||
crc = FLAC__crc16_table[7][crc >> 8 ] ^ FLAC__crc16_table[6][crc & 0xFF ] ^
|
||||
FLAC__crc16_table[5][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[4][ words[0] & 0xFF] ^
|
||||
FLAC__crc16_table[3][ words[1] >> 24 ] ^ FLAC__crc16_table[2][(words[1] >> 16) & 0xFF] ^
|
||||
FLAC__crc16_table[1][(words[1] >> 8) & 0xFF] ^ FLAC__crc16_table[0][ words[1] & 0xFF];
|
||||
|
||||
words += 2;
|
||||
len -= 2;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
crc ^= words[0] >> 16;
|
||||
|
||||
crc = FLAC__crc16_table[3][crc >> 8 ] ^ FLAC__crc16_table[2][crc & 0xFF ] ^
|
||||
FLAC__crc16_table[1][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[0][words[0] & 0xFF];
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
FLAC__uint16 FLAC__crc16_update_words64(const FLAC__uint64 *words, uint32_t len, FLAC__uint16 crc)
|
||||
{
|
||||
while (len--) {
|
||||
crc ^= words[0] >> 48;
|
||||
|
||||
crc = FLAC__crc16_table[7][crc >> 8 ] ^ FLAC__crc16_table[6][crc & 0xFF ] ^
|
||||
FLAC__crc16_table[5][(words[0] >> 40) & 0xFF] ^ FLAC__crc16_table[4][(words[0] >> 32) & 0xFF] ^
|
||||
FLAC__crc16_table[3][(words[0] >> 24) & 0xFF] ^ FLAC__crc16_table[2][(words[0] >> 16) & 0xFF] ^
|
||||
FLAC__crc16_table[1][(words[0] >> 8) & 0xFF] ^ FLAC__crc16_table[0][ words[0] & 0xFF];
|
||||
|
||||
words++;
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -45,7 +45,7 @@
|
|||
#ifdef local_abs
|
||||
#undef local_abs
|
||||
#endif
|
||||
#define local_abs(x) ((unsigned)((x)<0? -(x) : (x)))
|
||||
#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x)))
|
||||
|
||||
#ifdef FLAC__INTEGER_ONLY_LIBRARY
|
||||
/* rbps stands for residual bits per sample
|
||||
|
@ -57,7 +57,7 @@
|
|||
static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n)
|
||||
{
|
||||
FLAC__uint32 rbps;
|
||||
unsigned bits; /* the number of bits required to represent a number */
|
||||
uint32_t bits; /* the number of bits required to represent a number */
|
||||
int fracbits; /* the number of bits of rbps that comprise the fractional part */
|
||||
|
||||
FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint));
|
||||
|
@ -105,7 +105,7 @@ static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__
|
|||
}
|
||||
}
|
||||
|
||||
rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1));
|
||||
rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1));
|
||||
|
||||
if(rbps == 0)
|
||||
return 0;
|
||||
|
@ -136,7 +136,7 @@ static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__
|
|||
static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n)
|
||||
{
|
||||
FLAC__uint32 rbps;
|
||||
unsigned bits; /* the number of bits required to represent a number */
|
||||
uint32_t bits; /* the number of bits required to represent a number */
|
||||
int fracbits; /* the number of bits of rbps that comprise the fractional part */
|
||||
|
||||
FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint));
|
||||
|
@ -184,7 +184,7 @@ static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, F
|
|||
}
|
||||
}
|
||||
|
||||
rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1));
|
||||
rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1));
|
||||
|
||||
if(rbps == 0)
|
||||
return 0;
|
||||
|
@ -214,9 +214,9 @@ static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, F
|
|||
#endif
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#else
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#endif
|
||||
{
|
||||
FLAC__int32 last_error_0 = data[-1];
|
||||
|
@ -225,7 +225,7 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d
|
|||
FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
|
||||
FLAC__int32 error, save;
|
||||
FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
|
||||
unsigned i, order;
|
||||
uint32_t i, order;
|
||||
|
||||
for(i = 0; i < data_len; i++) {
|
||||
error = data[i] ; total_error_0 += local_abs(error); save = error;
|
||||
|
@ -255,11 +255,11 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d
|
|||
FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0);
|
||||
#else
|
||||
residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_integerized(total_error_0, data_len) : 0;
|
||||
residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_integerized(total_error_1, data_len) : 0;
|
||||
|
@ -272,9 +272,9 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d
|
|||
}
|
||||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#else
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
|
||||
#endif
|
||||
{
|
||||
FLAC__int32 last_error_0 = data[-1];
|
||||
|
@ -287,7 +287,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig
|
|||
* large.
|
||||
*/
|
||||
FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
|
||||
unsigned i, order;
|
||||
uint32_t i, order;
|
||||
|
||||
for(i = 0; i < data_len; i++) {
|
||||
error = data[i] ; total_error_0 += local_abs(error); save = error;
|
||||
|
@ -317,11 +317,11 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig
|
|||
FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
|
||||
FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[0] = (float)((total_error_0 > 0) ? log(M_LN2 * (double)total_error_0 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[1] = (float)((total_error_1 > 0) ? log(M_LN2 * (double)total_error_1 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[2] = (float)((total_error_2 > 0) ? log(M_LN2 * (double)total_error_2 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[3] = (float)((total_error_3 > 0) ? log(M_LN2 * (double)total_error_3 / (double)data_len) / M_LN2 : 0.0);
|
||||
residual_bits_per_sample[4] = (float)((total_error_4 > 0) ? log(M_LN2 * (double)total_error_4 / (double)data_len) / M_LN2 : 0.0);
|
||||
#else
|
||||
residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_wide_integerized(total_error_0, data_len) : 0;
|
||||
residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_wide_integerized(total_error_1, data_len) : 0;
|
||||
|
@ -333,7 +333,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig
|
|||
return order;
|
||||
}
|
||||
|
||||
void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[])
|
||||
void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[])
|
||||
{
|
||||
const int idata_len = (int)data_len;
|
||||
int i;
|
||||
|
@ -349,34 +349,22 @@ void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, u
|
|||
break;
|
||||
case 2:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
residual[i] = data[i] - (data[i-1] << 1) + data[i-2];
|
||||
#else
|
||||
residual[i] = data[i] - 2*data[i-1] + data[i-2];
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3];
|
||||
#else
|
||||
residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3];
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4];
|
||||
#else
|
||||
residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4];
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[])
|
||||
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[])
|
||||
{
|
||||
int i, idata_len = (int)data_len;
|
||||
|
||||
|
@ -391,27 +379,15 @@ void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len,
|
|||
break;
|
||||
case 2:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
data[i] = residual[i] + (data[i-1]<<1) - data[i-2];
|
||||
#else
|
||||
data[i] = residual[i] + 2*data[i-1] - data[i-2];
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
data[i] = residual[i] + (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) + data[i-3];
|
||||
#else
|
||||
data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3];
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
for(i = 0; i < idata_len; i++)
|
||||
#if 1 /* OPT: may be faster with some compilers on some systems */
|
||||
data[i] = residual[i] + ((data[i-1]+data[i-3])<<2) - ((data[i-2]<<2) + (data[i-2]<<1)) - data[i-4];
|
||||
#else
|
||||
data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4];
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -266,7 +266,7 @@ static const FLAC__uint64 log2_lookup_wide[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision)
|
||||
FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, uint32_t fracbits, uint32_t precision)
|
||||
{
|
||||
const FLAC__uint32 ONE = (1u << fracbits);
|
||||
const FLAC__uint32 *table = log2_lookup[fracbits >> 2];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -39,109 +39,111 @@
|
|||
#include <string.h> /* for memset() */
|
||||
#include "FLAC/assert.h"
|
||||
#include "FLAC/format.h"
|
||||
#include "share/alloc.h"
|
||||
#include "share/compat.h"
|
||||
#include "private/format.h"
|
||||
#include "private/macros.h"
|
||||
|
||||
/* VERSION should come from configure */
|
||||
FLAC_API const char *FLAC__VERSION_STRING = VERSION;
|
||||
#define PACKAGE_VERSION "1.3.3"
|
||||
|
||||
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20141125";
|
||||
FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION;
|
||||
|
||||
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20190804";
|
||||
|
||||
FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
|
||||
FLAC_API const unsigned FLAC__STREAM_SYNC = 0x664C6143;
|
||||
FLAC_API const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_SYNC = 0x664C6143;
|
||||
FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */
|
||||
|
||||
FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff);
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
|
||||
FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
|
||||
FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC = 0x3ffe;
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC = 0x3ffe;
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */
|
||||
FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
|
||||
FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
|
||||
FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
|
||||
|
||||
FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[] = {
|
||||
"PARTITIONED_RICE",
|
||||
"PARTITIONED_RICE2"
|
||||
};
|
||||
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */
|
||||
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00;
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02;
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10;
|
||||
FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40;
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00;
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02;
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10;
|
||||
FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40;
|
||||
|
||||
FLAC_API const char * const FLAC__SubframeTypeString[] = {
|
||||
"CONSTANT",
|
||||
|
@ -196,7 +198,7 @@ FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = {
|
|||
"Publisher/Studio logotype"
|
||||
};
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate)
|
||||
{
|
||||
if(sample_rate == 0 || sample_rate > FLAC__MAX_SAMPLE_RATE) {
|
||||
return false;
|
||||
|
@ -205,7 +207,7 @@ FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigned sample_rate)
|
||||
FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate)
|
||||
{
|
||||
if(blocksize > 16384)
|
||||
return false;
|
||||
|
@ -215,7 +217,7 @@ FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigne
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate)
|
||||
FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate)
|
||||
{
|
||||
if(
|
||||
!FLAC__format_sample_rate_is_valid(sample_rate) ||
|
||||
|
@ -233,7 +235,7 @@ FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate)
|
|||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__uint64 prev_sample_number = 0;
|
||||
FLAC__bool got_prev = false;
|
||||
|
||||
|
@ -267,13 +269,16 @@ static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLA
|
|||
}
|
||||
|
||||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table)
|
||||
FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
FLAC__bool first;
|
||||
|
||||
FLAC__ASSERT(0 != seek_table);
|
||||
|
||||
if (seek_table->num_points == 0)
|
||||
return 0;
|
||||
|
||||
/* sort the seekpoints */
|
||||
qsort(seek_table->points, seek_table->num_points, sizeof(FLAC__StreamMetadata_SeekPoint), (int (*)(const void *, const void *))seekpoint_compare_);
|
||||
|
||||
|
@ -305,7 +310,7 @@ FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *se
|
|||
* and a more clear explanation at the end of this section:
|
||||
* http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
*/
|
||||
static unsigned utf8len_(const FLAC__byte *utf8)
|
||||
static uint32_t utf8len_(const FLAC__byte *utf8)
|
||||
{
|
||||
FLAC__ASSERT(0 != utf8);
|
||||
if ((utf8[0] & 0x80) == 0) {
|
||||
|
@ -355,11 +360,11 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *n
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length)
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length)
|
||||
{
|
||||
if(length == (unsigned)(-1)) {
|
||||
if(length == (uint32_t)(-1)) {
|
||||
while(*value) {
|
||||
unsigned n = utf8len_(value);
|
||||
uint32_t n = utf8len_(value);
|
||||
if(n == 0)
|
||||
return false;
|
||||
value += n;
|
||||
|
@ -368,7 +373,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__
|
|||
else {
|
||||
const FLAC__byte *end = value + length;
|
||||
while(value < end) {
|
||||
unsigned n = utf8len_(value);
|
||||
uint32_t n = utf8len_(value);
|
||||
if(n == 0)
|
||||
return false;
|
||||
value += n;
|
||||
|
@ -379,7 +384,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length)
|
||||
FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length)
|
||||
{
|
||||
const FLAC__byte *s, *end;
|
||||
|
||||
|
@ -393,7 +398,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *
|
|||
s++; /* skip '=' */
|
||||
|
||||
while(s < end) {
|
||||
unsigned n = utf8len_(s);
|
||||
uint32_t n = utf8len_(s);
|
||||
if(n == 0)
|
||||
return false;
|
||||
s += n;
|
||||
|
@ -407,7 +412,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *
|
|||
/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
|
||||
FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
|
||||
if(check_cd_da_subset) {
|
||||
if(cue_sheet->lead_in < 2 * 44100) {
|
||||
|
@ -497,7 +502,7 @@ FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Pic
|
|||
}
|
||||
|
||||
for(b = picture->description; *b; ) {
|
||||
unsigned n = utf8len_(b);
|
||||
uint32_t n = utf8len_(b);
|
||||
if(n == 0) {
|
||||
if(violation) *violation = "description string must be valid UTF-8";
|
||||
return false;
|
||||
|
@ -511,7 +516,7 @@ FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Pic
|
|||
/*
|
||||
* These routines are private to libFLAC
|
||||
*/
|
||||
unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order)
|
||||
uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order)
|
||||
{
|
||||
return
|
||||
FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(
|
||||
|
@ -521,9 +526,9 @@ unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned
|
|||
);
|
||||
}
|
||||
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize)
|
||||
uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize)
|
||||
{
|
||||
unsigned max_rice_partition_order = 0;
|
||||
uint32_t max_rice_partition_order = 0;
|
||||
while(!(blocksize & 1)) {
|
||||
max_rice_partition_order++;
|
||||
blocksize >>= 1;
|
||||
|
@ -531,9 +536,9 @@ unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned block
|
|||
return flac_min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order);
|
||||
}
|
||||
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order)
|
||||
uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order)
|
||||
{
|
||||
unsigned max_rice_partition_order = limit;
|
||||
uint32_t max_rice_partition_order = limit;
|
||||
|
||||
while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order)
|
||||
max_rice_partition_order--;
|
||||
|
@ -566,18 +571,18 @@ void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__En
|
|||
FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order)
|
||||
FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order)
|
||||
{
|
||||
FLAC__ASSERT(0 != object);
|
||||
|
||||
FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits));
|
||||
|
||||
if(object->capacity_by_order < max_partition_order) {
|
||||
if(0 == (object->parameters = realloc(object->parameters, sizeof(unsigned)*(1 << max_partition_order))))
|
||||
if(0 == (object->parameters = safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order))))
|
||||
return false;
|
||||
if(0 == (object->raw_bits = realloc(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order))))
|
||||
if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order))))
|
||||
return false;
|
||||
memset(object->raw_bits, 0, sizeof(unsigned)*(1 << max_partition_order));
|
||||
memset(object->raw_bits, 0, sizeof(uint32_t)*(1 << max_partition_order));
|
||||
object->capacity_by_order = max_partition_order;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -42,7 +42,7 @@
|
|||
#include "private/bitmath.h"
|
||||
#include "private/lpc.h"
|
||||
#include "private/macros.h"
|
||||
#if defined DEBUG || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE
|
||||
#if !defined(NDEBUG) || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
@ -51,34 +51,33 @@
|
|||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
|
||||
#if !defined(HAVE_LROUND)
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1800)
|
||||
#include <float.h>
|
||||
#define copysign _copysign
|
||||
#elif defined(__GNUC__)
|
||||
#define copysign __builtin_copysign
|
||||
#elif defined(Plan9)
|
||||
#define copysign(x,y) ((x > 0.0 && y < 0.0) || (x < 0.0 && y > 0.0)) ? -x : x
|
||||
#endif
|
||||
static inline long int lround(double x) {
|
||||
return (long)(x + copysign (0.5, x));
|
||||
return (long)(x + copysign(0.5, x));
|
||||
}
|
||||
#elif !defined(HAVE_LROUND) && defined(__GNUC__)
|
||||
static inline long int lround(double x) {
|
||||
return (long)(x + __builtin_copysign(0.5, x));
|
||||
}
|
||||
/* If this fails, we are in the presence of a mid 90's compiler, move along... */
|
||||
#endif
|
||||
|
||||
void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len)
|
||||
void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
for(i = 0; i < data_len; i++)
|
||||
out[i] = in[i] * window[i];
|
||||
}
|
||||
|
||||
void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[])
|
||||
void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[])
|
||||
{
|
||||
/* a readable, but slower, version */
|
||||
#if 0
|
||||
FLAC__real d;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
FLAC__ASSERT(lag > 0);
|
||||
FLAC__ASSERT(lag <= data_len);
|
||||
|
@ -102,8 +101,8 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
|
|||
* ('data_len' is usually much larger than 'lag')
|
||||
*/
|
||||
FLAC__real d;
|
||||
unsigned sample, coeff;
|
||||
const unsigned limit = data_len - lag;
|
||||
uint32_t sample, coeff;
|
||||
const uint32_t limit = data_len - lag;
|
||||
|
||||
FLAC__ASSERT(lag > 0);
|
||||
FLAC__ASSERT(lag <= data_len);
|
||||
|
@ -122,10 +121,10 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
|
|||
}
|
||||
}
|
||||
|
||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[])
|
||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[])
|
||||
{
|
||||
unsigned i, j;
|
||||
FLAC__double r, err, lpc[FLAC__MAX_LPC_ORDER];
|
||||
uint32_t i, j;
|
||||
double r, err, lpc[FLAC__MAX_LPC_ORDER];
|
||||
|
||||
FLAC__ASSERT(0 != max_order);
|
||||
FLAC__ASSERT(0 < *max_order);
|
||||
|
@ -144,7 +143,7 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_o
|
|||
/* Update LPC coefficients and total error. */
|
||||
lpc[i]=r;
|
||||
for(j = 0; j < (i>>1); j++) {
|
||||
FLAC__double tmp = lpc[j];
|
||||
double tmp = lpc[j];
|
||||
lpc[j] += r * lpc[i-1-j];
|
||||
lpc[i-1-j] += r * tmp;
|
||||
}
|
||||
|
@ -166,10 +165,10 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_o
|
|||
}
|
||||
}
|
||||
|
||||
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift)
|
||||
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift)
|
||||
{
|
||||
unsigned i;
|
||||
FLAC__double cmax;
|
||||
uint32_t i;
|
||||
double cmax;
|
||||
FLAC__int32 qmax, qmin;
|
||||
|
||||
FLAC__ASSERT(precision > 0);
|
||||
|
@ -184,7 +183,7 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
|
|||
/* calc cmax = max( |lp_coeff[i]| ) */
|
||||
cmax = 0.0;
|
||||
for(i = 0; i < order; i++) {
|
||||
const FLAC__double d = fabs(lp_coeff[i]);
|
||||
const double d = fabs(lp_coeff[i]);
|
||||
if(d > cmax)
|
||||
cmax = d;
|
||||
}
|
||||
|
@ -209,7 +208,7 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
|
|||
}
|
||||
|
||||
if(*shift >= 0) {
|
||||
FLAC__double error = 0.0;
|
||||
double error = 0.0;
|
||||
FLAC__int32 q;
|
||||
for(i = 0; i < order; i++) {
|
||||
error += lp_coeff[i] * (1 << *shift);
|
||||
|
@ -230,14 +229,14 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
|
|||
}
|
||||
}
|
||||
/* negative shift is very rare but due to design flaw, negative shift is
|
||||
* a NOP in the decoder, so it must be handled specially by scaling down
|
||||
* coeffs
|
||||
* not allowed in the decoder, so it must be handled specially by scaling
|
||||
* down coeffs
|
||||
*/
|
||||
else {
|
||||
const int nshift = -(*shift);
|
||||
FLAC__double error = 0.0;
|
||||
double error = 0.0;
|
||||
FLAC__int32 q;
|
||||
#ifdef DEBUG
|
||||
#ifndef NDEBUG
|
||||
fprintf(stderr,"FLAC__lpc_quantize_coefficients: negative shift=%d order=%u cmax=%f\n", *shift, order, cmax);
|
||||
#endif
|
||||
for(i = 0; i < order; i++) {
|
||||
|
@ -267,11 +266,11 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
|
|||
#pragma warning ( disable : 4028 )
|
||||
#endif
|
||||
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_restrict data, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict residual)
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual)
|
||||
#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
|
||||
{
|
||||
FLAC__int64 sumo;
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
FLAC__int32 sum;
|
||||
const FLAC__int32 *history;
|
||||
|
||||
|
@ -290,6 +289,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_r
|
|||
for(j = 0; j < order; j++) {
|
||||
sum += qlp_coeff[j] * (*(--history));
|
||||
sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
|
||||
if(sumo > 2147483647ll || sumo < -2147483648ll)
|
||||
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo);
|
||||
}
|
||||
*(residual++) = *(data++) - (sum >> lp_quantization);
|
||||
|
@ -488,25 +488,25 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_r
|
|||
for(i = 0; i < (int)data_len; i++) {
|
||||
sum = 0;
|
||||
switch(order) {
|
||||
case 32: sum += qlp_coeff[31] * data[i-32];
|
||||
case 31: sum += qlp_coeff[30] * data[i-31];
|
||||
case 30: sum += qlp_coeff[29] * data[i-30];
|
||||
case 29: sum += qlp_coeff[28] * data[i-29];
|
||||
case 28: sum += qlp_coeff[27] * data[i-28];
|
||||
case 27: sum += qlp_coeff[26] * data[i-27];
|
||||
case 26: sum += qlp_coeff[25] * data[i-26];
|
||||
case 25: sum += qlp_coeff[24] * data[i-25];
|
||||
case 24: sum += qlp_coeff[23] * data[i-24];
|
||||
case 23: sum += qlp_coeff[22] * data[i-23];
|
||||
case 22: sum += qlp_coeff[21] * data[i-22];
|
||||
case 21: sum += qlp_coeff[20] * data[i-21];
|
||||
case 20: sum += qlp_coeff[19] * data[i-20];
|
||||
case 19: sum += qlp_coeff[18] * data[i-19];
|
||||
case 18: sum += qlp_coeff[17] * data[i-18];
|
||||
case 17: sum += qlp_coeff[16] * data[i-17];
|
||||
case 16: sum += qlp_coeff[15] * data[i-16];
|
||||
case 15: sum += qlp_coeff[14] * data[i-15];
|
||||
case 14: sum += qlp_coeff[13] * data[i-14];
|
||||
case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */
|
||||
case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */
|
||||
case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */
|
||||
case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */
|
||||
case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */
|
||||
case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */
|
||||
case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */
|
||||
case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */
|
||||
case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */
|
||||
case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */
|
||||
case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */
|
||||
case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */
|
||||
case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */
|
||||
case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */
|
||||
case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */
|
||||
case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */
|
||||
case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */
|
||||
case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */
|
||||
case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */
|
||||
case 13: sum += qlp_coeff[12] * data[i-13];
|
||||
sum += qlp_coeff[11] * data[i-12];
|
||||
sum += qlp_coeff[10] * data[i-11];
|
||||
|
@ -527,10 +527,10 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_r
|
|||
}
|
||||
#endif
|
||||
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * flac_restrict data, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict residual)
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual)
|
||||
#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
FLAC__int64 sum;
|
||||
const FLAC__int32 *history;
|
||||
|
||||
|
@ -547,11 +547,11 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * f
|
|||
history = data;
|
||||
for(j = 0; j < order; j++)
|
||||
sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
|
||||
if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
|
||||
if(FLAC__bitmath_silog2(sum >> lp_quantization) > 32) {
|
||||
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%" PRId64 "\n", i, (sum >> lp_quantization));
|
||||
break;
|
||||
}
|
||||
if(FLAC__bitmath_silog2_wide((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) {
|
||||
if(FLAC__bitmath_silog2((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) {
|
||||
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%" PRId64 ", residual=%" PRId64 "\n", i, *data, (int64_t)(sum >> lp_quantization), ((FLAC__int64)(*data) - (sum >> lp_quantization)));
|
||||
break;
|
||||
}
|
||||
|
@ -742,25 +742,25 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * f
|
|||
for(i = 0; i < (int)data_len; i++) {
|
||||
sum = 0;
|
||||
switch(order) {
|
||||
case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32];
|
||||
case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31];
|
||||
case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30];
|
||||
case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29];
|
||||
case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28];
|
||||
case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27];
|
||||
case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26];
|
||||
case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25];
|
||||
case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24];
|
||||
case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23];
|
||||
case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22];
|
||||
case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21];
|
||||
case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20];
|
||||
case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19];
|
||||
case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18];
|
||||
case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17];
|
||||
case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16];
|
||||
case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15];
|
||||
case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14];
|
||||
case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */
|
||||
case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */
|
||||
case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */
|
||||
case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */
|
||||
case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */
|
||||
case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */
|
||||
case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */
|
||||
case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */
|
||||
case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */
|
||||
case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */
|
||||
case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */
|
||||
case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */
|
||||
case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */
|
||||
case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */
|
||||
case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */
|
||||
case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */
|
||||
case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */
|
||||
case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */
|
||||
case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */
|
||||
case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13];
|
||||
sum += qlp_coeff[11] * (FLAC__int64)data[i-12];
|
||||
sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
|
||||
|
@ -783,11 +783,11 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * f
|
|||
|
||||
#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
|
||||
|
||||
void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict data)
|
||||
void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data)
|
||||
#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
|
||||
{
|
||||
FLAC__int64 sumo;
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
FLAC__int32 sum;
|
||||
const FLAC__int32 *r = residual, *history;
|
||||
|
||||
|
@ -1005,25 +1005,25 @@ void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, unsign
|
|||
for(i = 0; i < (int)data_len; i++) {
|
||||
sum = 0;
|
||||
switch(order) {
|
||||
case 32: sum += qlp_coeff[31] * data[i-32];
|
||||
case 31: sum += qlp_coeff[30] * data[i-31];
|
||||
case 30: sum += qlp_coeff[29] * data[i-30];
|
||||
case 29: sum += qlp_coeff[28] * data[i-29];
|
||||
case 28: sum += qlp_coeff[27] * data[i-28];
|
||||
case 27: sum += qlp_coeff[26] * data[i-27];
|
||||
case 26: sum += qlp_coeff[25] * data[i-26];
|
||||
case 25: sum += qlp_coeff[24] * data[i-25];
|
||||
case 24: sum += qlp_coeff[23] * data[i-24];
|
||||
case 23: sum += qlp_coeff[22] * data[i-23];
|
||||
case 22: sum += qlp_coeff[21] * data[i-22];
|
||||
case 21: sum += qlp_coeff[20] * data[i-21];
|
||||
case 20: sum += qlp_coeff[19] * data[i-20];
|
||||
case 19: sum += qlp_coeff[18] * data[i-19];
|
||||
case 18: sum += qlp_coeff[17] * data[i-18];
|
||||
case 17: sum += qlp_coeff[16] * data[i-17];
|
||||
case 16: sum += qlp_coeff[15] * data[i-16];
|
||||
case 15: sum += qlp_coeff[14] * data[i-15];
|
||||
case 14: sum += qlp_coeff[13] * data[i-14];
|
||||
case 32: sum += qlp_coeff[31] * data[i-32]; /* Falls through. */
|
||||
case 31: sum += qlp_coeff[30] * data[i-31]; /* Falls through. */
|
||||
case 30: sum += qlp_coeff[29] * data[i-30]; /* Falls through. */
|
||||
case 29: sum += qlp_coeff[28] * data[i-29]; /* Falls through. */
|
||||
case 28: sum += qlp_coeff[27] * data[i-28]; /* Falls through. */
|
||||
case 27: sum += qlp_coeff[26] * data[i-27]; /* Falls through. */
|
||||
case 26: sum += qlp_coeff[25] * data[i-26]; /* Falls through. */
|
||||
case 25: sum += qlp_coeff[24] * data[i-25]; /* Falls through. */
|
||||
case 24: sum += qlp_coeff[23] * data[i-24]; /* Falls through. */
|
||||
case 23: sum += qlp_coeff[22] * data[i-23]; /* Falls through. */
|
||||
case 22: sum += qlp_coeff[21] * data[i-22]; /* Falls through. */
|
||||
case 21: sum += qlp_coeff[20] * data[i-21]; /* Falls through. */
|
||||
case 20: sum += qlp_coeff[19] * data[i-20]; /* Falls through. */
|
||||
case 19: sum += qlp_coeff[18] * data[i-19]; /* Falls through. */
|
||||
case 18: sum += qlp_coeff[17] * data[i-18]; /* Falls through. */
|
||||
case 17: sum += qlp_coeff[16] * data[i-17]; /* Falls through. */
|
||||
case 16: sum += qlp_coeff[15] * data[i-16]; /* Falls through. */
|
||||
case 15: sum += qlp_coeff[14] * data[i-15]; /* Falls through. */
|
||||
case 14: sum += qlp_coeff[13] * data[i-14]; /* Falls through. */
|
||||
case 13: sum += qlp_coeff[12] * data[i-13];
|
||||
sum += qlp_coeff[11] * data[i-12];
|
||||
sum += qlp_coeff[10] * data[i-11];
|
||||
|
@ -1044,10 +1044,10 @@ void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, unsign
|
|||
}
|
||||
#endif
|
||||
|
||||
void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict data)
|
||||
void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data)
|
||||
#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
|
||||
{
|
||||
unsigned i, j;
|
||||
uint32_t i, j;
|
||||
FLAC__int64 sum;
|
||||
const FLAC__int32 *r = residual, *history;
|
||||
|
||||
|
@ -1064,11 +1064,11 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, u
|
|||
history = data;
|
||||
for(j = 0; j < order; j++)
|
||||
sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
|
||||
if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
|
||||
if(FLAC__bitmath_silog2(sum >> lp_quantization) > 32) {
|
||||
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%" PRId64 "\n", i, (sum >> lp_quantization));
|
||||
break;
|
||||
}
|
||||
if(FLAC__bitmath_silog2_wide((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) {
|
||||
if(FLAC__bitmath_silog2((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) {
|
||||
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization)));
|
||||
break;
|
||||
}
|
||||
|
@ -1259,25 +1259,25 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, u
|
|||
for(i = 0; i < (int)data_len; i++) {
|
||||
sum = 0;
|
||||
switch(order) {
|
||||
case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32];
|
||||
case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31];
|
||||
case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30];
|
||||
case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29];
|
||||
case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28];
|
||||
case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27];
|
||||
case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26];
|
||||
case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25];
|
||||
case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24];
|
||||
case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23];
|
||||
case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22];
|
||||
case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21];
|
||||
case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20];
|
||||
case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19];
|
||||
case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18];
|
||||
case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17];
|
||||
case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16];
|
||||
case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15];
|
||||
case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14];
|
||||
case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32]; /* Falls through. */
|
||||
case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31]; /* Falls through. */
|
||||
case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30]; /* Falls through. */
|
||||
case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29]; /* Falls through. */
|
||||
case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28]; /* Falls through. */
|
||||
case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27]; /* Falls through. */
|
||||
case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26]; /* Falls through. */
|
||||
case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25]; /* Falls through. */
|
||||
case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24]; /* Falls through. */
|
||||
case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23]; /* Falls through. */
|
||||
case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22]; /* Falls through. */
|
||||
case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21]; /* Falls through. */
|
||||
case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20]; /* Falls through. */
|
||||
case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19]; /* Falls through. */
|
||||
case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18]; /* Falls through. */
|
||||
case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17]; /* Falls through. */
|
||||
case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16]; /* Falls through. */
|
||||
case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15]; /* Falls through. */
|
||||
case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14]; /* Falls through. */
|
||||
case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13];
|
||||
sum += qlp_coeff[11] * (FLAC__int64)data[i-12];
|
||||
sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
|
||||
|
@ -1304,21 +1304,21 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, u
|
|||
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
|
||||
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples)
|
||||
double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples)
|
||||
{
|
||||
FLAC__double error_scale;
|
||||
double error_scale;
|
||||
|
||||
FLAC__ASSERT(total_samples > 0);
|
||||
|
||||
error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__double)total_samples;
|
||||
error_scale = 0.5 / (double)total_samples;
|
||||
|
||||
return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error, error_scale);
|
||||
}
|
||||
|
||||
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale)
|
||||
double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale)
|
||||
{
|
||||
if(lpc_error > 0.0) {
|
||||
FLAC__double bps = (FLAC__double)0.5 * log(error_scale * lpc_error) / M_LN2;
|
||||
double bps = (double)0.5 * log(error_scale * lpc_error) / M_LN2;
|
||||
if(bps >= 0.0)
|
||||
return bps;
|
||||
else
|
||||
|
@ -1332,21 +1332,21 @@ FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scal
|
|||
}
|
||||
}
|
||||
|
||||
unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order)
|
||||
uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order)
|
||||
{
|
||||
unsigned order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */
|
||||
FLAC__double bits, best_bits, error_scale;
|
||||
uint32_t order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */
|
||||
double bits, best_bits, error_scale;
|
||||
|
||||
FLAC__ASSERT(max_order > 0);
|
||||
FLAC__ASSERT(total_samples > 0);
|
||||
|
||||
error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__double)total_samples;
|
||||
error_scale = 0.5 / (double)total_samples;
|
||||
|
||||
best_index = 0;
|
||||
best_bits = (unsigned)(-1);
|
||||
best_bits = (uint32_t)(-1);
|
||||
|
||||
for(indx = 0, order = 1; indx < max_order; indx++, order++) {
|
||||
bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[indx], error_scale) * (FLAC__double)(total_samples - order) + (FLAC__double)(order * overhead_bits_per_order);
|
||||
bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[indx], error_scale) * (double)(total_samples - order) + (double)(order * overhead_bits_per_order);
|
||||
if(bits < best_bits) {
|
||||
best_index = indx;
|
||||
best_bits = bits;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "private/md5.h"
|
||||
#include "share/alloc.h"
|
||||
#include "share/compat.h"
|
||||
#include "share/endswap.h"
|
||||
|
||||
/*
|
||||
|
@ -136,7 +137,7 @@ static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
|
|||
|
||||
#if WORDS_BIGENDIAN
|
||||
//@@@@@@ OPT: use bswap/intrinsics
|
||||
static void byteSwap(FLAC__uint32 *buf, unsigned words)
|
||||
static void byteSwap(FLAC__uint32 *buf, uint32_t words)
|
||||
{
|
||||
register FLAC__uint32 x;
|
||||
do {
|
||||
|
@ -175,7 +176,7 @@ static void byteSwapX16(FLAC__uint32 *buf)
|
|||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, unsigned len)
|
||||
static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, uint32_t len)
|
||||
{
|
||||
FLAC__uint32 t;
|
||||
|
||||
|
@ -224,7 +225,7 @@ void FLAC__MD5Init(FLAC__MD5Context *ctx)
|
|||
ctx->bytes[0] = 0;
|
||||
ctx->bytes[1] = 0;
|
||||
|
||||
ctx->internal_buf.p8= 0;
|
||||
ctx->internal_buf.p8 = 0;
|
||||
ctx->capacity = 0;
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,7 @@ void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
|
|||
memcpy(digest, ctx->buf, 16);
|
||||
if (0 != ctx->internal_buf.p8) {
|
||||
free(ctx->internal_buf.p8);
|
||||
ctx->internal_buf.p8= 0;
|
||||
ctx->internal_buf.p8 = 0;
|
||||
ctx->capacity = 0;
|
||||
}
|
||||
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
||||
|
@ -271,13 +272,13 @@ void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
|
|||
/*
|
||||
* Convert the incoming audio signal to a byte stream
|
||||
*/
|
||||
static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
|
||||
static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample)
|
||||
{
|
||||
FLAC__byte *buf_ = mbuf->p8;
|
||||
FLAC__int16 *buf16 = mbuf->p16;
|
||||
FLAC__int32 *buf32 = mbuf->p32;
|
||||
FLAC__int32 a_word;
|
||||
unsigned channel, sample;
|
||||
uint32_t channel, sample;
|
||||
|
||||
/* Storage in the output buffer, buf, is little endian. */
|
||||
|
||||
|
@ -488,7 +489,7 @@ static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signa
|
|||
/*
|
||||
* Convert the incoming audio signal to a byte stream and FLAC__MD5Update it.
|
||||
*/
|
||||
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
|
||||
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample)
|
||||
{
|
||||
const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample;
|
||||
|
||||
|
@ -499,14 +500,12 @@ FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const
|
|||
return false;
|
||||
|
||||
if (ctx->capacity < bytes_needed) {
|
||||
FLAC__byte *tmp = realloc(ctx->internal_buf.p8, bytes_needed);
|
||||
if (0 == tmp) {
|
||||
free(ctx->internal_buf.p8);
|
||||
if (0 == (ctx->internal_buf.p8= safe_malloc_(bytes_needed)))
|
||||
if (0 == (ctx->internal_buf.p8 = safe_realloc_(ctx->internal_buf.p8, bytes_needed))) {
|
||||
if (0 == (ctx->internal_buf.p8 = safe_malloc_(bytes_needed))) {
|
||||
ctx->capacity = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
ctx->internal_buf.p8= tmp;
|
||||
ctx->capacity = bytes_needed;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "private/memory.h"
|
||||
#include "FLAC/assert.h"
|
||||
#include "share/compat.h"
|
||||
#include "share/alloc.h"
|
||||
|
||||
void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
|
||||
|
@ -146,11 +147,11 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64
|
|||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer)
|
||||
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, uint32_t **unaligned_pointer, uint32_t **aligned_pointer)
|
||||
{
|
||||
unsigned *pu; /* unaligned pointer */
|
||||
uint32_t *pu; /* unaligned pointer */
|
||||
union { /* union needed to comply with C99 pointer aliasing rules */
|
||||
unsigned *pa; /* aligned pointer */
|
||||
uint32_t *pa; /* aligned pointer */
|
||||
void *pv; /* aligned pointer alias */
|
||||
} u;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -62,50 +62,50 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
static void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes);
|
||||
static void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes);
|
||||
static void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes);
|
||||
static FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes);
|
||||
static FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes);
|
||||
static FLAC__uint64 unpack_uint64_(FLAC__byte *b, unsigned bytes);
|
||||
static void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes);
|
||||
static void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes);
|
||||
static void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, uint32_t bytes);
|
||||
static FLAC__uint32 unpack_uint32_(FLAC__byte *b, uint32_t bytes);
|
||||
static FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, uint32_t bytes);
|
||||
static FLAC__uint64 unpack_uint64_(FLAC__byte *b, uint32_t bytes);
|
||||
|
||||
static FLAC__bool read_metadata_block_header_(FLAC__Metadata_SimpleIterator *iterator);
|
||||
static FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block);
|
||||
static FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, unsigned *length);
|
||||
static FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, uint32_t *length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata *block);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_StreamInfo *block);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, unsigned block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, unsigned block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, unsigned block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, unsigned max_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, unsigned block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, uint32_t block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, uint32_t block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, uint32_t block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, uint32_t max_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, uint32_t block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Picture *block);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, unsigned block_length);
|
||||
static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, uint32_t block_length);
|
||||
|
||||
static FLAC__bool write_metadata_block_header_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block);
|
||||
static FLAC__bool write_metadata_block_data_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block);
|
||||
static FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block);
|
||||
static FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block);
|
||||
static FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block);
|
||||
static FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, unsigned block_length);
|
||||
static FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, unsigned block_length);
|
||||
static FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, uint32_t block_length);
|
||||
static FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, uint32_t block_length);
|
||||
static FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block);
|
||||
static FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block);
|
||||
static FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block);
|
||||
static FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block);
|
||||
static FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, unsigned block_length);
|
||||
static FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, uint32_t block_length);
|
||||
|
||||
static FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block);
|
||||
static FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, unsigned padding_length, FLAC__bool padding_is_last);
|
||||
static FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, uint32_t padding_length, FLAC__bool padding_is_last);
|
||||
static FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool append);
|
||||
|
||||
static void simple_iterator_push_(FLAC__Metadata_SimpleIterator *iterator);
|
||||
static FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator);
|
||||
|
||||
static unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb);
|
||||
static unsigned seek_to_first_metadata_block_(FILE *f);
|
||||
static uint32_t seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb);
|
||||
static uint32_t seek_to_first_metadata_block_(FILE *f);
|
||||
|
||||
static FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append);
|
||||
static FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, FLAC__off_t fixup_is_last_flag_offset, FLAC__bool backup);
|
||||
|
@ -265,7 +265,7 @@ void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErro
|
|||
cd->got_error = true;
|
||||
}
|
||||
|
||||
FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors)
|
||||
FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors)
|
||||
{
|
||||
FLAC__Metadata_SimpleIterator *it;
|
||||
FLAC__uint64 max_area_seen = 0;
|
||||
|
@ -334,11 +334,11 @@ struct FLAC__Metadata_SimpleIterator {
|
|||
FLAC__Metadata_SimpleIteratorStatus status;
|
||||
FLAC__off_t offset[SIMPLE_ITERATOR_MAX_PUSH_DEPTH];
|
||||
FLAC__off_t first_offset; /* this is the offset to the STREAMINFO block */
|
||||
unsigned depth;
|
||||
uint32_t depth;
|
||||
/* this is the metadata block header of the current block we are pointing to: */
|
||||
FLAC__bool is_last;
|
||||
FLAC__MetadataType type;
|
||||
unsigned length;
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[] = {
|
||||
|
@ -417,7 +417,7 @@ FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_stat
|
|||
|
||||
static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool read_only)
|
||||
{
|
||||
unsigned ret;
|
||||
uint32_t ret;
|
||||
|
||||
FLAC__ASSERT(0 != iterator);
|
||||
|
||||
|
@ -588,7 +588,7 @@ FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const
|
|||
}
|
||||
|
||||
/*@@@@add to tests*/
|
||||
FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator)
|
||||
FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator)
|
||||
{
|
||||
FLAC__ASSERT(0 != iterator);
|
||||
FLAC__ASSERT(0 != iterator->file);
|
||||
|
@ -599,7 +599,7 @@ FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Me
|
|||
/*@@@@add to tests*/
|
||||
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id)
|
||||
{
|
||||
const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
|
||||
FLAC__ASSERT(0 != iterator);
|
||||
FLAC__ASSERT(0 != iterator->file);
|
||||
|
@ -693,7 +693,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp
|
|||
}
|
||||
}
|
||||
else /* iterator->length < block->length */ {
|
||||
unsigned padding_leftover = 0;
|
||||
uint32_t padding_leftover = 0;
|
||||
FLAC__bool padding_is_last = false;
|
||||
if(use_padding) {
|
||||
/* first see if we can even use padding */
|
||||
|
@ -701,7 +701,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp
|
|||
use_padding = false;
|
||||
}
|
||||
else {
|
||||
const unsigned extra_padding_bytes_required = block->length - iterator->length;
|
||||
const uint32_t extra_padding_bytes_required = block->length - iterator->length;
|
||||
simple_iterator_push_(iterator);
|
||||
if(!FLAC__metadata_simple_iterator_next(iterator)) {
|
||||
(void)simple_iterator_pop_(iterator);
|
||||
|
@ -753,7 +753,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp
|
|||
|
||||
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding)
|
||||
{
|
||||
unsigned padding_leftover = 0;
|
||||
uint32_t padding_leftover = 0;
|
||||
FLAC__bool padding_is_last = false;
|
||||
|
||||
FLAC__ASSERT_DECLARATION(FLAC__off_t debug_target_offset = iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length;)
|
||||
|
@ -837,6 +837,11 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_S
|
|||
FLAC__ASSERT_DECLARATION(FLAC__off_t debug_target_offset = iterator->offset[iterator->depth];)
|
||||
FLAC__bool ret;
|
||||
|
||||
if(!iterator->is_writable) {
|
||||
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(iterator->type == FLAC__METADATA_TYPE_STREAMINFO) {
|
||||
iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT;
|
||||
return false;
|
||||
|
@ -887,7 +892,7 @@ struct FLAC__Metadata_Chain {
|
|||
FLAC__bool is_ogg;
|
||||
FLAC__Metadata_Node *head;
|
||||
FLAC__Metadata_Node *tail;
|
||||
unsigned nodes;
|
||||
uint32_t nodes;
|
||||
FLAC__Metadata_ChainStatus status;
|
||||
FLAC__off_t first_offset, last_offset;
|
||||
/*
|
||||
|
@ -1084,8 +1089,8 @@ static void iterator_insert_node_after_(FLAC__Metadata_Iterator *iterator, FLAC_
|
|||
static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node)
|
||||
{
|
||||
if(node->data->type == FLAC__METADATA_TYPE_PADDING && 0 != node->next && node->next->data->type == FLAC__METADATA_TYPE_PADDING) {
|
||||
const unsigned growth = FLAC__STREAM_METADATA_HEADER_LENGTH + node->next->data->length;
|
||||
node->data->length += growth;
|
||||
const uint32_t growth = FLAC__STREAM_METADATA_HEADER_LENGTH + node->next->data->length;
|
||||
node->data->length += growth; /* new block size can be greater than max metadata block size, but it'll be fixed later in chain_prepare_for_write_() */
|
||||
|
||||
chain_delete_node_(chain, node->next);
|
||||
return true;
|
||||
|
@ -1152,6 +1157,22 @@ static FLAC__off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__b
|
|||
}
|
||||
}
|
||||
|
||||
/* check sizes of all metadata blocks; reduce padding size if necessary */
|
||||
{
|
||||
FLAC__Metadata_Node *node;
|
||||
for (node = chain->head; node; node = node->next) {
|
||||
if(node->data->length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) {
|
||||
if(node->data->type == FLAC__METADATA_TYPE_PADDING) {
|
||||
node->data->length = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1;
|
||||
current_length = chain_calculate_length_(chain);
|
||||
} else {
|
||||
chain->status = FLAC__METADATA_CHAIN_STATUS_BAD_METADATA;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return current_length;
|
||||
}
|
||||
|
||||
|
@ -1192,7 +1213,7 @@ static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle han
|
|||
{
|
||||
FLAC__bool is_last;
|
||||
FLAC__MetadataType type;
|
||||
unsigned length;
|
||||
uint32_t length;
|
||||
|
||||
do {
|
||||
node = node_new_();
|
||||
|
@ -1597,37 +1618,87 @@ FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_
|
|||
return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/true);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
LBS_NONE = 0,
|
||||
LBS_SIZE_CHANGED,
|
||||
LBS_BLOCK_ADDED,
|
||||
LBS_BLOCK_REMOVED
|
||||
} LastBlockState;
|
||||
|
||||
FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding)
|
||||
{
|
||||
/* This does all the same checks that are in chain_prepare_for_write_()
|
||||
* but doesn't actually alter the chain. Make sure to update the logic
|
||||
* here if chain_prepare_for_write_() changes.
|
||||
*/
|
||||
const FLAC__off_t current_length = chain_calculate_length_(chain);
|
||||
FLAC__off_t current_length;
|
||||
LastBlockState lbs_state = LBS_NONE;
|
||||
uint32_t lbs_size = 0;
|
||||
|
||||
FLAC__ASSERT(0 != chain);
|
||||
|
||||
current_length = chain_calculate_length_(chain);
|
||||
|
||||
if(use_padding) {
|
||||
const FLAC__Metadata_Node * const node = chain->tail;
|
||||
/* if the metadata shrank and the last block is padding, we just extend the last padding block */
|
||||
if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDING)
|
||||
return false;
|
||||
if(current_length < chain->initial_length && node->data->type == FLAC__METADATA_TYPE_PADDING) {
|
||||
lbs_state = LBS_SIZE_CHANGED;
|
||||
lbs_size = node->data->length + (chain->initial_length - current_length);
|
||||
}
|
||||
/* if the metadata shrank more than 4 bytes then there's room to add another padding block */
|
||||
else if(current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length)
|
||||
return false;
|
||||
else if(current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) {
|
||||
lbs_state = LBS_BLOCK_ADDED;
|
||||
lbs_size = chain->initial_length - (current_length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
|
||||
}
|
||||
/* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */
|
||||
else if(current_length > chain->initial_length) {
|
||||
const FLAC__off_t delta = current_length - chain->initial_length;
|
||||
if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) {
|
||||
if(node->data->type == FLAC__METADATA_TYPE_PADDING) {
|
||||
/* if the delta is exactly the size of the last padding block, remove the padding block */
|
||||
if((FLAC__off_t)chain->tail->data->length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta)
|
||||
return false;
|
||||
if((FLAC__off_t)node->data->length + (FLAC__off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta) {
|
||||
lbs_state = LBS_BLOCK_REMOVED;
|
||||
lbs_size = 0;
|
||||
}
|
||||
/* if there is at least 'delta' bytes of padding, trim the padding down */
|
||||
else if((FLAC__off_t)chain->tail->data->length >= delta)
|
||||
return false;
|
||||
else if((FLAC__off_t)node->data->length >= delta) {
|
||||
lbs_state = LBS_SIZE_CHANGED;
|
||||
lbs_size = node->data->length - delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current_length = 0;
|
||||
/* check sizes of all metadata blocks; reduce padding size if necessary */
|
||||
{
|
||||
const FLAC__Metadata_Node *node;
|
||||
for(node = chain->head; node; node = node->next) {
|
||||
uint32_t block_len = node->data->length;
|
||||
if(node == chain->tail) {
|
||||
if(lbs_state == LBS_BLOCK_REMOVED)
|
||||
continue;
|
||||
else if(lbs_state == LBS_SIZE_CHANGED)
|
||||
block_len = lbs_size;
|
||||
}
|
||||
if(block_len >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) {
|
||||
if(node->data->type == FLAC__METADATA_TYPE_PADDING)
|
||||
block_len = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1;
|
||||
else
|
||||
return false /* the return value doesn't matter */;
|
||||
}
|
||||
current_length += (FLAC__STREAM_METADATA_HEADER_LENGTH + block_len);
|
||||
}
|
||||
|
||||
if(lbs_state == LBS_BLOCK_ADDED) {
|
||||
/* test added padding block */
|
||||
uint32_t block_len = lbs_size;
|
||||
if(block_len >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
|
||||
block_len = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1;
|
||||
current_length += (FLAC__STREAM_METADATA_HEADER_LENGTH + block_len);
|
||||
}
|
||||
}
|
||||
|
||||
return (current_length != chain->initial_length);
|
||||
}
|
||||
|
||||
|
@ -1793,7 +1864,7 @@ FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain)
|
|||
FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain)
|
||||
{
|
||||
FLAC__Metadata_Node *node, *save;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
FLAC__ASSERT(0 != chain);
|
||||
|
||||
|
@ -1970,9 +2041,9 @@ FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_It
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes)
|
||||
void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
b += bytes;
|
||||
|
||||
|
@ -1982,9 +2053,9 @@ void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes)
|
|||
}
|
||||
}
|
||||
|
||||
void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes)
|
||||
void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < bytes; i++) {
|
||||
*(b++) = (FLAC__byte)(val & 0xff);
|
||||
|
@ -1992,9 +2063,9 @@ void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes)
|
|||
}
|
||||
}
|
||||
|
||||
void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes)
|
||||
void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, uint32_t bytes)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
b += bytes;
|
||||
|
||||
|
@ -2004,10 +2075,10 @@ void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes)
|
|||
}
|
||||
}
|
||||
|
||||
FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes)
|
||||
FLAC__uint32 unpack_uint32_(FLAC__byte *b, uint32_t bytes)
|
||||
{
|
||||
FLAC__uint32 ret = 0;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < bytes; i++)
|
||||
ret = (ret << 8) | (FLAC__uint32)(*b++);
|
||||
|
@ -2015,10 +2086,10 @@ FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes)
|
|||
return ret;
|
||||
}
|
||||
|
||||
FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes)
|
||||
FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, uint32_t bytes)
|
||||
{
|
||||
FLAC__uint32 ret = 0;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
b += bytes;
|
||||
|
||||
|
@ -2028,10 +2099,10 @@ FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes)
|
|||
return ret;
|
||||
}
|
||||
|
||||
FLAC__uint64 unpack_uint64_(FLAC__byte *b, unsigned bytes)
|
||||
FLAC__uint64 unpack_uint64_(FLAC__byte *b, uint32_t bytes)
|
||||
{
|
||||
FLAC__uint64 ret = 0;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < bytes; i++)
|
||||
ret = (ret << 8) | (FLAC__uint64)(*b++);
|
||||
|
@ -2062,7 +2133,7 @@ FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FL
|
|||
return (iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK);
|
||||
}
|
||||
|
||||
FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, unsigned *length)
|
||||
FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, uint32_t *length)
|
||||
{
|
||||
FLAC__byte raw_header[FLAC__STREAM_METADATA_HEADER_LENGTH];
|
||||
|
||||
|
@ -2120,16 +2191,16 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC
|
|||
block->max_blocksize = unpack_uint32_(b, 2); b += 2;
|
||||
block->min_framesize = unpack_uint32_(b, 3); b += 3;
|
||||
block->max_framesize = unpack_uint32_(b, 3); b += 3;
|
||||
block->sample_rate = (unpack_uint32_(b, 2) << 4) | ((unsigned)(b[2] & 0xf0) >> 4);
|
||||
block->channels = (unsigned)((b[2] & 0x0e) >> 1) + 1;
|
||||
block->bits_per_sample = ((((unsigned)(b[2] & 0x01)) << 4) | (((unsigned)(b[3] & 0xf0)) >> 4)) + 1;
|
||||
block->sample_rate = (unpack_uint32_(b, 2) << 4) | ((uint32_t)(b[2] & 0xf0) >> 4);
|
||||
block->channels = (uint32_t)((b[2] & 0x0e) >> 1) + 1;
|
||||
block->bits_per_sample = ((((uint32_t)(b[2] & 0x01)) << 4) | (((uint32_t)(b[3] & 0xf0)) >> 4)) + 1;
|
||||
block->total_samples = (((FLAC__uint64)(b[3] & 0x0f)) << 32) | unpack_uint64_(b+4, 4);
|
||||
memcpy(block->md5sum, b+8, 16);
|
||||
|
||||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, unsigned block_length)
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, uint32_t block_length)
|
||||
{
|
||||
(void)block; /* nothing to do; we don't care about reading the padding bytes */
|
||||
|
||||
|
@ -2139,9 +2210,9 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__I
|
|||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, unsigned block_length)
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, uint32_t block_length)
|
||||
{
|
||||
const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
|
||||
if(read_cb(block->id, 1, id_bytes, handle) != id_bytes)
|
||||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
|
||||
|
@ -2165,9 +2236,9 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLA
|
|||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, unsigned block_length)
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, uint32_t block_length)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH];
|
||||
|
||||
FLAC__ASSERT(block_length % FLAC__STREAM_METADATA_SEEKPOINT_LENGTH == 0);
|
||||
|
@ -2191,9 +2262,9 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC_
|
|||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, unsigned max_length)
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, uint32_t max_length)
|
||||
{
|
||||
const unsigned entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
|
||||
const uint32_t entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
|
||||
FLAC__byte buffer[4]; /* magic number is asserted below */
|
||||
|
||||
FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8 == sizeof(buffer));
|
||||
|
@ -2229,11 +2300,11 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entr
|
|||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, unsigned block_length)
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, uint32_t block_length)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__Metadata_SimpleIteratorStatus status;
|
||||
const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
|
||||
const uint32_t num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
|
||||
FLAC__byte buffer[4]; /* magic number is asserted below */
|
||||
|
||||
FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8 == sizeof(buffer));
|
||||
|
@ -2255,8 +2326,10 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(
|
|||
if(block->num_comments == 0) {
|
||||
block->comments = 0;
|
||||
}
|
||||
else if(0 == (block->comments = calloc(block->num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry))))
|
||||
else if(0 == (block->comments = calloc(block->num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
|
||||
block->num_comments = 0;
|
||||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
|
||||
for(i = 0; i < block->num_comments; i++) {
|
||||
status = read_metadata_block_data_vorbis_comment_entry_cb_(handle, read_cb, block->comments + i, block_length);
|
||||
|
@ -2281,7 +2354,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(
|
|||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track)
|
||||
{
|
||||
unsigned i, len;
|
||||
uint32_t i, len;
|
||||
FLAC__byte buffer[32]; /* asserted below that this is big enough */
|
||||
|
||||
FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64));
|
||||
|
@ -2350,7 +2423,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(
|
|||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block)
|
||||
{
|
||||
unsigned i, len;
|
||||
uint32_t i, len;
|
||||
FLAC__Metadata_SimpleIteratorStatus status;
|
||||
FLAC__byte buffer[1024]; /* MSVC needs a constant expression so we put a magic number and assert */
|
||||
|
||||
|
@ -2480,7 +2553,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__I
|
|||
return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
|
||||
}
|
||||
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, unsigned block_length)
|
||||
FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, uint32_t block_length)
|
||||
{
|
||||
if(block_length == 0) {
|
||||
block->data = 0;
|
||||
|
@ -2529,6 +2602,9 @@ FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallba
|
|||
FLAC__byte buffer[FLAC__STREAM_METADATA_HEADER_LENGTH];
|
||||
|
||||
FLAC__ASSERT(block->length < (1u << FLAC__STREAM_METADATA_LENGTH_LEN));
|
||||
/* double protection */
|
||||
if(block->length >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
|
||||
return false;
|
||||
|
||||
buffer[0] = (block->is_last? 0x80 : 0) | (FLAC__byte)block->type;
|
||||
pack_uint32_(block->length, buffer + 1, 3);
|
||||
|
@ -2566,8 +2642,8 @@ FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback
|
|||
FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block)
|
||||
{
|
||||
FLAC__byte buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH];
|
||||
const unsigned channels1 = block->channels - 1;
|
||||
const unsigned bps1 = block->bits_per_sample - 1;
|
||||
const uint32_t channels1 = block->channels - 1;
|
||||
const uint32_t bps1 = block->bits_per_sample - 1;
|
||||
|
||||
/* we are using hardcoded numbers for simplicity but we should
|
||||
* probably eventually write a bit-level packer and use the
|
||||
|
@ -2590,9 +2666,9 @@ FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC_
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, unsigned block_length)
|
||||
FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, uint32_t block_length)
|
||||
{
|
||||
unsigned i, n = block_length;
|
||||
uint32_t i, n = block_length;
|
||||
FLAC__byte buffer[1024];
|
||||
|
||||
(void)block;
|
||||
|
@ -2611,9 +2687,9 @@ FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IO
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, unsigned block_length)
|
||||
FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, uint32_t block_length)
|
||||
{
|
||||
const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
|
||||
|
||||
if(write_cb(block->id, 1, id_bytes, handle) != id_bytes)
|
||||
return false;
|
||||
|
@ -2628,7 +2704,7 @@ FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC
|
|||
|
||||
FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH];
|
||||
|
||||
for(i = 0; i < block->num_points; i++) {
|
||||
|
@ -2645,9 +2721,9 @@ FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__
|
|||
|
||||
FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block)
|
||||
{
|
||||
unsigned i;
|
||||
const unsigned entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
|
||||
const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
|
||||
uint32_t i;
|
||||
const uint32_t entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
|
||||
const uint32_t num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
|
||||
FLAC__byte buffer[4]; /* magic number is asserted below */
|
||||
|
||||
FLAC__ASSERT(flac_max(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN, FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8 == sizeof(buffer));
|
||||
|
@ -2675,7 +2751,7 @@ FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, F
|
|||
|
||||
FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block)
|
||||
{
|
||||
unsigned i, j, len;
|
||||
uint32_t i, j, len;
|
||||
FLAC__byte buffer[1024]; /* asserted below that this is big enough */
|
||||
|
||||
FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64));
|
||||
|
@ -2769,7 +2845,7 @@ FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__I
|
|||
|
||||
FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block)
|
||||
{
|
||||
unsigned len;
|
||||
uint32_t len;
|
||||
size_t slen;
|
||||
FLAC__byte buffer[4]; /* magic number is asserted below */
|
||||
|
||||
|
@ -2841,7 +2917,7 @@ FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IO
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, unsigned block_length)
|
||||
FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, uint32_t block_length)
|
||||
{
|
||||
if(write_cb(block->data, 1, block_length, handle) != block_length)
|
||||
return false;
|
||||
|
@ -2870,7 +2946,7 @@ FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *itera
|
|||
return read_metadata_block_header_(iterator);
|
||||
}
|
||||
|
||||
FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, unsigned padding_length, FLAC__bool padding_is_last)
|
||||
FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, uint32_t padding_length, FLAC__bool padding_is_last)
|
||||
{
|
||||
FLAC__StreamMetadata *padding;
|
||||
|
||||
|
@ -2989,11 +3065,11 @@ FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator)
|
|||
* 2: seek error
|
||||
* 3: not a FLAC file
|
||||
*/
|
||||
unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb)
|
||||
uint32_t seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb)
|
||||
{
|
||||
FLAC__byte buffer[4];
|
||||
size_t n;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
FLAC__ASSERT(FLAC__STREAM_SYNC_LENGTH == sizeof(buffer));
|
||||
|
||||
|
@ -3005,7 +3081,7 @@ unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallbac
|
|||
else if(n != 4)
|
||||
return 3;
|
||||
else if(0 == memcmp(buffer, "ID3", 3)) {
|
||||
unsigned tag_length = 0;
|
||||
uint32_t tag_length = 0;
|
||||
|
||||
/* skip to the tag length */
|
||||
if(seek_cb(handle, 2, SEEK_CUR) < 0)
|
||||
|
@ -3039,7 +3115,7 @@ unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallbac
|
|||
return 3;
|
||||
}
|
||||
|
||||
unsigned seek_to_first_metadata_block_(FILE *f)
|
||||
uint32_t seek_to_first_metadata_block_(FILE *f)
|
||||
{
|
||||
return seek_to_first_metadata_block_cb_((FLAC__IOHandle)f, (FLAC__IOCallback_Read)fread, fseek_wrapper_);
|
||||
}
|
||||
|
@ -3233,11 +3309,14 @@ local_snprintf(char *str, size_t size, const char *fmt, ...)
|
|||
va_list va;
|
||||
int rc;
|
||||
|
||||
va_start (va, fmt);
|
||||
|
||||
#if defined _MSC_VER
|
||||
if (size == 0)
|
||||
return 1024;
|
||||
#endif
|
||||
|
||||
va_start (va, fmt);
|
||||
|
||||
#if defined _MSC_VER
|
||||
rc = vsnprintf_s (str, size, _TRUNCATE, fmt, va);
|
||||
if (rc < 0)
|
||||
rc = size - 1;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -111,7 +111,7 @@ FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(
|
|||
* decoder will eventually call the read callback to supply some data,
|
||||
* but how much it asks for depends on how much free space it has in
|
||||
* its internal buffer. It does not try to grow its internal buffer
|
||||
* to accomodate a whole frame because then the internal buffer size
|
||||
* to accommodate a whole frame because then the internal buffer size
|
||||
* could not be limited, which is necessary in embedded applications.
|
||||
*
|
||||
* Ogg however grows its internal buffer until a whole page is present;
|
||||
|
@ -161,7 +161,7 @@ FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(
|
|||
/* if it is the first header packet, check for magic and a supported Ogg FLAC mapping version */
|
||||
if (aspect->working_packet.bytes > 0 && aspect->working_packet.packet[0] == FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE) {
|
||||
const FLAC__byte *b = aspect->working_packet.packet;
|
||||
const unsigned header_length =
|
||||
const uint32_t header_length =
|
||||
FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH +
|
||||
FLAC__OGG_MAPPING_MAGIC_LENGTH +
|
||||
FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH +
|
||||
|
@ -173,9 +173,9 @@ FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(
|
|||
if (memcmp(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH))
|
||||
return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC;
|
||||
b += FLAC__OGG_MAPPING_MAGIC_LENGTH;
|
||||
aspect->version_major = (unsigned)(*b);
|
||||
aspect->version_major = (uint32_t)(*b);
|
||||
b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH;
|
||||
aspect->version_minor = (unsigned)(*b);
|
||||
aspect->version_minor = (uint32_t)(*b);
|
||||
if (aspect->version_major != 1)
|
||||
return FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION;
|
||||
aspect->working_packet.packet += header_length;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -72,7 +72,7 @@ void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect,
|
|||
aspect->serial_number = value;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, unsigned value)
|
||||
FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, uint32_t value)
|
||||
{
|
||||
if(value < (1u << FLAC__OGG_MAPPING_NUM_HEADERS_LEN)) {
|
||||
aspect->num_metadata = value;
|
||||
|
@ -109,7 +109,7 @@ void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect)
|
|||
* separate write callback for the fLaC magic, and then separate write
|
||||
* callbacks for each metadata block and audio frame.
|
||||
*/
|
||||
FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data)
|
||||
FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data)
|
||||
{
|
||||
/* WATCHOUT:
|
||||
* This depends on the behavior of FLAC__StreamEncoder that 'samples'
|
||||
|
@ -170,14 +170,14 @@ FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(F
|
|||
/* add STREAMINFO */
|
||||
memcpy(b, buffer, bytes);
|
||||
FLAC__ASSERT(b + bytes - synthetic_first_packet_body == sizeof(synthetic_first_packet_body));
|
||||
packet.packet = (unsigned char *)synthetic_first_packet_body;
|
||||
packet.packet = (uint8_t *)synthetic_first_packet_body;
|
||||
packet.bytes = sizeof(synthetic_first_packet_body);
|
||||
|
||||
packet.b_o_s = 1;
|
||||
aspect->is_first_packet = false;
|
||||
}
|
||||
else {
|
||||
packet.packet = (unsigned char *)buffer;
|
||||
packet.packet = (uint8_t *)buffer;
|
||||
packet.bytes = bytes;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -94,8 +94,8 @@ void simple_ogg_page__clear(ogg_page *page)
|
|||
|
||||
FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data)
|
||||
{
|
||||
static const unsigned OGG_HEADER_FIXED_PORTION_LEN = 27;
|
||||
static const unsigned OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255;
|
||||
static const uint32_t OGG_HEADER_FIXED_PORTION_LEN = 27;
|
||||
static const uint32_t OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255;
|
||||
FLAC__byte crc[4];
|
||||
FLAC__StreamEncoderSeekStatus seek_status;
|
||||
|
||||
|
@ -142,10 +142,10 @@ FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 po
|
|||
return false;
|
||||
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
/* check to see that it specifies a single packet */
|
||||
for(i = 0; i < (unsigned)page->header[26] - 1; i++) {
|
||||
for(i = 0; i < (uint32_t)page->header[26] - 1; i++) {
|
||||
if(page->header[i + OGG_HEADER_FIXED_PORTION_LEN] != 255) {
|
||||
encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
|
||||
return false;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -36,13 +36,13 @@
|
|||
|
||||
#include "private/ogg_mapping.h"
|
||||
|
||||
const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */
|
||||
const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */
|
||||
|
||||
const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE = 0x7f;
|
||||
|
||||
const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC = (const FLAC__byte * const)"FLAC";
|
||||
|
||||
const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */
|
||||
const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */
|
||||
const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */
|
||||
const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */
|
||||
|
||||
const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */
|
||||
const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -36,69 +36,98 @@
|
|||
#include "FLAC/ordinals.h"
|
||||
#include "FLAC/assert.h"
|
||||
|
||||
/* for CHAR_BIT */
|
||||
#include <limits.h>
|
||||
#include "share/compat.h"
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#if defined(_MSC_VER)
|
||||
#include <intrin.h> /* for _BitScanReverse* */
|
||||
#endif
|
||||
|
||||
/* Will never be emitted for MSVC, GCC, Intel compilers */
|
||||
static inline unsigned int FLAC__clz_soft_uint32(unsigned int word)
|
||||
static inline uint32_t FLAC__clz_soft_uint32(FLAC__uint32 word)
|
||||
{
|
||||
static const unsigned char byte_to_unary_table[] = {
|
||||
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
static const uint8_t byte_to_unary_table[] = {
|
||||
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
return (word) > 0xffffff ? byte_to_unary_table[(word) >> 24] :
|
||||
(word) > 0xffff ? byte_to_unary_table[(word) >> 16] + 8 :
|
||||
(word) > 0xff ? byte_to_unary_table[(word) >> 8] + 16 :
|
||||
byte_to_unary_table[(word)] + 24;
|
||||
return word > 0xffffff ? byte_to_unary_table[word >> 24] :
|
||||
word > 0xffff ? byte_to_unary_table[word >> 16] + 8 :
|
||||
word > 0xff ? byte_to_unary_table[word >> 8] + 16 :
|
||||
byte_to_unary_table[word] + 24;
|
||||
}
|
||||
|
||||
static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v)
|
||||
static inline uint32_t FLAC__clz_uint32(FLAC__uint32 v)
|
||||
{
|
||||
/* Never used with input 0 */
|
||||
FLAC__ASSERT(v > 0);
|
||||
FLAC__ASSERT(v > 0);
|
||||
#if defined(__INTEL_COMPILER)
|
||||
return _bit_scan_reverse(v) ^ 31U;
|
||||
return _bit_scan_reverse(v) ^ 31U;
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
/* This will translate either to (bsr ^ 31U), clz , ctlz, cntlz, lzcnt depending on
|
||||
* -march= setting or to a software routine in exotic machines. */
|
||||
return __builtin_clz(v);
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
{
|
||||
unsigned long idx;
|
||||
_BitScanReverse(&idx, v);
|
||||
return idx ^ 31U;
|
||||
}
|
||||
return __builtin_clz(v);
|
||||
#elif defined(_MSC_VER)
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse(&idx, v);
|
||||
return idx ^ 31U;
|
||||
}
|
||||
#else
|
||||
return FLAC__clz_soft_uint32(v);
|
||||
return FLAC__clz_soft_uint32(v);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This one works with input 0 */
|
||||
static inline unsigned int FLAC__clz2_uint32(FLAC__uint32 v)
|
||||
/* Used when 64-bit bsr/clz is unavailable; can use 32-bit bsr/clz when possible */
|
||||
static inline uint32_t FLAC__clz_soft_uint64(FLAC__uint64 word)
|
||||
{
|
||||
if (!v)
|
||||
return 32;
|
||||
return FLAC__clz_uint32(v);
|
||||
return (FLAC__uint32)(word>>32) ? FLAC__clz_uint32((FLAC__uint32)(word>>32)) :
|
||||
FLAC__clz_uint32((FLAC__uint32)word) + 32;
|
||||
}
|
||||
|
||||
static inline uint32_t FLAC__clz_uint64(FLAC__uint64 v)
|
||||
{
|
||||
/* Never used with input 0 */
|
||||
FLAC__ASSERT(v > 0);
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
return __builtin_clzll(v);
|
||||
#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64))
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse64(&idx, v);
|
||||
return idx ^ 63U;
|
||||
}
|
||||
#else
|
||||
return FLAC__clz_soft_uint64(v);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* These two functions work with input 0 */
|
||||
static inline uint32_t FLAC__clz2_uint32(FLAC__uint32 v)
|
||||
{
|
||||
if (!v)
|
||||
return 32;
|
||||
return FLAC__clz_uint32(v);
|
||||
}
|
||||
|
||||
static inline uint32_t FLAC__clz2_uint64(FLAC__uint64 v)
|
||||
{
|
||||
if (!v)
|
||||
return 64;
|
||||
return FLAC__clz_uint64(v);
|
||||
}
|
||||
|
||||
/* An example of what FLAC__bitmath_ilog2() computes:
|
||||
|
@ -124,63 +153,58 @@ static inline unsigned int FLAC__clz2_uint32(FLAC__uint32 v)
|
|||
* ilog2(18) = 4
|
||||
*/
|
||||
|
||||
static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v)
|
||||
static inline uint32_t FLAC__bitmath_ilog2(FLAC__uint32 v)
|
||||
{
|
||||
FLAC__ASSERT(v > 0);
|
||||
FLAC__ASSERT(v > 0);
|
||||
#if defined(__INTEL_COMPILER)
|
||||
return _bit_scan_reverse(v);
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
{
|
||||
unsigned long idx;
|
||||
_BitScanReverse(&idx, v);
|
||||
return idx;
|
||||
}
|
||||
return _bit_scan_reverse(v);
|
||||
#elif defined(_MSC_VER)
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse(&idx, v);
|
||||
return idx;
|
||||
}
|
||||
#else
|
||||
return sizeof(FLAC__uint32) * CHAR_BIT - 1 - FLAC__clz_uint32(v);
|
||||
return FLAC__clz_uint32(v) ^ 31U;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef FLAC__INTEGER_ONLY_LIBRARY /* Unused otherwise */
|
||||
|
||||
static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
|
||||
static inline uint32_t FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
|
||||
{
|
||||
FLAC__ASSERT(v > 0);
|
||||
FLAC__ASSERT(v > 0);
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
return sizeof(FLAC__uint64) * CHAR_BIT - 1 - __builtin_clzll(v);
|
||||
return __builtin_clzll(v) ^ 63U;
|
||||
/* Sorry, only supported in x64/Itanium.. and both have fast FPU which makes integer-only encoder pointless */
|
||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && (defined(_M_IA64) || defined(_M_X64))
|
||||
{
|
||||
unsigned long idx;
|
||||
_BitScanReverse64(&idx, v);
|
||||
return idx;
|
||||
}
|
||||
#elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64))
|
||||
{
|
||||
uint32_t idx;
|
||||
_BitScanReverse64(&idx, v);
|
||||
return idx;
|
||||
}
|
||||
#else
|
||||
/* Brain-damaged compilers will use the fastest possible way that is,
|
||||
de Bruijn sequences (http://supertech.csail.mit.edu/papers/debruijn.pdf)
|
||||
(C) Timothy B. Terriberry (tterribe@xiph.org) 2001-2009 CC0 (Public domain).
|
||||
de Bruijn sequences (http://supertech.csail.mit.edu/papers/debruijn.pdf)
|
||||
(C) Timothy B. Terriberry (tterribe@xiph.org) 2001-2009 CC0 (Public domain).
|
||||
*/
|
||||
{
|
||||
static const unsigned char DEBRUIJN_IDX64[64]={
|
||||
0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40,
|
||||
5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57,
|
||||
63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56,
|
||||
62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58
|
||||
};
|
||||
v|= v>>1;
|
||||
v|= v>>2;
|
||||
v|= v>>4;
|
||||
v|= v>>8;
|
||||
v|= v>>16;
|
||||
v|= v>>32;
|
||||
v= (v>>1)+1;
|
||||
return DEBRUIJN_IDX64[v*0x218A392CD3D5DBF>>58&0x3F];
|
||||
}
|
||||
{
|
||||
static const uint8_t DEBRUIJN_IDX64[64]={
|
||||
0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40,
|
||||
5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57,
|
||||
63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56,
|
||||
62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58
|
||||
};
|
||||
v|= v>>1;
|
||||
v|= v>>2;
|
||||
v|= v>>4;
|
||||
v|= v>>8;
|
||||
v|= v>>16;
|
||||
v|= v>>32;
|
||||
v= (v>>1)+1;
|
||||
return DEBRUIJN_IDX64[v*FLAC__U64L(0x218A392CD3D5DBF)>>58&0x3F];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned FLAC__bitmath_silog2(int v);
|
||||
unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v);
|
||||
uint32_t FLAC__bitmath_silog2(FLAC__int64 v);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -65,27 +65,27 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br);
|
|||
* info functions
|
||||
*/
|
||||
FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br);
|
||||
unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
|
||||
unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
|
||||
uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
|
||||
uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
|
||||
|
||||
/*
|
||||
* read functions
|
||||
*/
|
||||
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits);
|
||||
FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits);
|
||||
FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/
|
||||
FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */
|
||||
FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
|
||||
FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
|
||||
FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val);
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
|
||||
FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */
|
||||
FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */
|
||||
FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */
|
||||
FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val);
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter);
|
||||
FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter);
|
||||
#if 0 /* UNUSED */
|
||||
FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter);
|
||||
FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter);
|
||||
#endif
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen);
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen);
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen);
|
||||
FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen);
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -64,7 +64,7 @@ FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc);
|
|||
* info functions
|
||||
*/
|
||||
FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw);
|
||||
unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */
|
||||
uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */
|
||||
|
||||
/*
|
||||
* direct buffer access
|
||||
|
@ -79,23 +79,23 @@ void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw);
|
|||
/*
|
||||
* write functions
|
||||
*/
|
||||
FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits);
|
||||
FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits);
|
||||
FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); /*only for bits=32*/
|
||||
FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals);
|
||||
FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val);
|
||||
unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals);
|
||||
FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val);
|
||||
uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter);
|
||||
#if 0 /* UNUSED */
|
||||
unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter);
|
||||
unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned val, unsigned parameter);
|
||||
uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter);
|
||||
uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t val, uint32_t parameter);
|
||||
#endif
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter);
|
||||
#if 0 /* UNUSED */
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned val, unsigned parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter);
|
||||
FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t val, uint32_t parameter);
|
||||
#endif
|
||||
FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val);
|
||||
FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -39,7 +39,27 @@
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined FLAC__HAS_X86INTRIN
|
||||
#ifndef FLAC__CPU_X86_64
|
||||
|
||||
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
|
||||
#define FLAC__CPU_X86_64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef FLAC__CPU_IA32
|
||||
|
||||
#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)
|
||||
#define FLAC__CPU_IA32
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if FLAC__HAS_X86INTRIN
|
||||
/* SSE intrinsics support by ICC/MSVC/GCC */
|
||||
#if defined __INTEL_COMPILER
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
|
@ -56,6 +76,34 @@
|
|||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#elif defined __clang__ && __has_attribute(__target__) /* clang */
|
||||
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
|
||||
#if __has_builtin(__builtin_ia32_maxps)
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#endif
|
||||
#if __has_builtin(__builtin_ia32_pmuludq128)
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#endif
|
||||
#if __has_builtin(__builtin_ia32_pabsd128)
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#endif
|
||||
#if __has_builtin(__builtin_ia32_pmuldq128)
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#endif
|
||||
#if __has_builtin(__builtin_ia32_pabsd256)
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#endif
|
||||
#elif defined __GNUC__ && !defined __clang__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* GCC 4.9+ */
|
||||
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#ifdef FLAC__USE_AVX
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#elif defined _MSC_VER
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
|
@ -71,66 +119,52 @@
|
|||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#elif defined __GNUC__
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* since GCC 4.9 -msse.. compiler options aren't necessary */
|
||||
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
|
||||
#else
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
#ifdef __SSE__
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE2__
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSSE3__
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE4_1__
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __AVX__
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __AVX2__
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __FMA__
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#else /* for GCC older than 4.9 */
|
||||
#define FLAC__SSE_TARGET(x)
|
||||
#ifdef __SSE__
|
||||
#define FLAC__SSE_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE2__
|
||||
#define FLAC__SSE2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSSE3__
|
||||
#define FLAC__SSSE3_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __SSE4_1__
|
||||
#define FLAC__SSE4_1_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __AVX__
|
||||
#define FLAC__AVX_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __AVX2__
|
||||
#define FLAC__AVX2_SUPPORTED 1
|
||||
#endif
|
||||
#ifdef __FMA__
|
||||
#define FLAC__FMA_SUPPORTED 1
|
||||
#endif
|
||||
#endif /* GCC version */
|
||||
#endif
|
||||
#endif /* compiler version */
|
||||
#endif /* intrinsics support */
|
||||
|
||||
|
||||
#ifndef FLAC__AVX_SUPPORTED
|
||||
#define FLAC__AVX_SUPPORTED 0
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
FLAC__CPUINFO_TYPE_IA32,
|
||||
FLAC__CPUINFO_TYPE_X86_64,
|
||||
FLAC__CPUINFO_TYPE_PPC,
|
||||
FLAC__CPUINFO_TYPE_UNKNOWN
|
||||
} FLAC__CPUInfo_Type;
|
||||
|
||||
#if defined FLAC__CPU_IA32
|
||||
typedef struct {
|
||||
FLAC__bool intel;
|
||||
|
||||
FLAC__bool cmov;
|
||||
FLAC__bool mmx;
|
||||
FLAC__bool sse;
|
||||
FLAC__bool sse2;
|
||||
|
||||
FLAC__bool sse3;
|
||||
FLAC__bool ssse3;
|
||||
FLAC__bool sse41;
|
||||
FLAC__bool sse42;
|
||||
FLAC__bool avx;
|
||||
FLAC__bool avx2;
|
||||
FLAC__bool fma;
|
||||
} FLAC__CPUInfo_IA32;
|
||||
#elif defined FLAC__CPU_X86_64
|
||||
typedef struct {
|
||||
FLAC__bool sse3;
|
||||
FLAC__bool ssse3;
|
||||
FLAC__bool sse41;
|
||||
|
@ -139,30 +173,23 @@ typedef struct {
|
|||
FLAC__bool avx2;
|
||||
FLAC__bool fma;
|
||||
} FLAC__CPUInfo_x86;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
FLAC__bool arch_3_00;
|
||||
FLAC__bool arch_2_07;
|
||||
} FLAC__CPUInfo_ppc;
|
||||
|
||||
typedef struct {
|
||||
FLAC__bool use_asm;
|
||||
FLAC__CPUInfo_Type type;
|
||||
#if defined FLAC__CPU_IA32
|
||||
FLAC__CPUInfo_IA32 ia32;
|
||||
#elif defined FLAC__CPU_X86_64
|
||||
FLAC__CPUInfo_x86 x86;
|
||||
#endif
|
||||
FLAC__CPUInfo_ppc ppc;
|
||||
} FLAC__CPUInfo;
|
||||
|
||||
void FLAC__cpu_info(FLAC__CPUInfo *info);
|
||||
|
||||
#ifndef FLAC__NO_ASM
|
||||
# if defined FLAC__CPU_IA32 && defined FLAC__HAS_NASM
|
||||
FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void);
|
||||
void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx);
|
||||
# endif
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN
|
||||
FLAC__uint32 FLAC__cpu_have_cpuid_x86(void);
|
||||
void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx);
|
||||
FLAC__uint32 FLAC__cpu_xgetbv_x86(void);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
void FLAC__cpu_info_asm_ia32(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2018 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -39,24 +39,22 @@
|
|||
** polynomial = x^8 + x^2 + x^1 + x^0
|
||||
** init = 0
|
||||
*/
|
||||
extern FLAC__byte const FLAC__crc8_table[256];
|
||||
#define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)];
|
||||
void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc);
|
||||
void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc);
|
||||
FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len);
|
||||
FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len);
|
||||
|
||||
/* 16 bit CRC generator, MSB shifted first
|
||||
** polynomial = x^16 + x^15 + x^2 + x^0
|
||||
** init = 0
|
||||
*/
|
||||
extern unsigned const FLAC__crc16_table[256];
|
||||
extern FLAC__uint16 const FLAC__crc16_table[8][256];
|
||||
|
||||
#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)])
|
||||
#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[0][((crc)>>8) ^ (data)])
|
||||
/* this alternate may be faster on some systems/compilers */
|
||||
#if 0
|
||||
#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff)
|
||||
#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[0][((crc)>>8) ^ (data)]) & 0xffff)
|
||||
#endif
|
||||
|
||||
unsigned FLAC__crc16(const FLAC__byte *data, unsigned len);
|
||||
FLAC__uint16 FLAC__crc16(const FLAC__byte *data, uint32_t len);
|
||||
FLAC__uint16 FLAC__crc16_update_words32(const FLAC__uint32 *words, uint32_t len, FLAC__uint16 crc);
|
||||
FLAC__uint16 FLAC__crc16_update_words64(const FLAC__uint64 *words, uint32_t len, FLAC__uint16 crc);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -54,26 +54,26 @@
|
|||
* OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
|
||||
*/
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
# ifndef FLAC__NO_ASM
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN
|
||||
# ifdef FLAC__SSE2_SUPPORTED
|
||||
unsigned FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]);
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide_intrin_sse2(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]);
|
||||
# endif
|
||||
# ifdef FLAC__SSSE3_SUPPORTED
|
||||
unsigned FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide_intrin_ssse3(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]);
|
||||
# endif
|
||||
# endif
|
||||
# if defined FLAC__CPU_IA32 && defined FLAC__HAS_NASM
|
||||
unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -87,7 +87,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig
|
|||
* IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
|
||||
* OUT residual[0,data_len-1] residual signal
|
||||
*/
|
||||
void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]);
|
||||
void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]);
|
||||
|
||||
/*
|
||||
* FLAC__fixed_restore_signal()
|
||||
|
@ -102,6 +102,6 @@ void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, u
|
|||
* IN data[-order,-1] previously-reconstructed historical samples
|
||||
* OUT data[0,data_len-1] original signal
|
||||
*/
|
||||
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]);
|
||||
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -40,18 +40,15 @@
|
|||
#include "FLAC/ordinals.h"
|
||||
|
||||
/*
|
||||
* These typedefs make it easier to ensure that integer versions of
|
||||
* the library really only contain integer operations. All the code
|
||||
* in libFLAC should use FLAC__float and FLAC__double in place of
|
||||
* float and double, and be protected by checks of the macro
|
||||
* All the code in libFLAC that uses float and double
|
||||
* should be protected by checks of the macro
|
||||
* FLAC__INTEGER_ONLY_LIBRARY.
|
||||
*
|
||||
* FLAC__real is the basic floating point type used in LPC analysis.
|
||||
*/
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
typedef double FLAC__double;
|
||||
typedef float FLAC__float;
|
||||
/*
|
||||
* FLAC__real is the basic floating point type used in LPC analysis.
|
||||
*
|
||||
* WATCHOUT: changing FLAC__real will change the signatures of many
|
||||
* functions that have assembly language equivalents and break them.
|
||||
*/
|
||||
|
@ -84,14 +81,14 @@ extern const FLAC__fixedpoint FLAC__FP_E;
|
|||
* be < 32 and evenly divisible by 4 (0 is OK but not very precise).
|
||||
*
|
||||
* 'precision' roughly limits the number of iterations that are done;
|
||||
* use (unsigned)(-1) for maximum precision.
|
||||
* use (uint32_t)(-1) for maximum precision.
|
||||
*
|
||||
* If 'x' is less than one -- that is, x < (1<<fracbits) -- then this
|
||||
* function will punt and return 0.
|
||||
*
|
||||
* The return value will also have 'fracbits' fractional bits.
|
||||
*/
|
||||
FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision);
|
||||
FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, uint32_t fracbits, uint32_t precision);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -35,11 +35,11 @@
|
|||
|
||||
#include "FLAC/format.h"
|
||||
|
||||
unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order);
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize);
|
||||
unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order);
|
||||
uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order);
|
||||
uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize);
|
||||
uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order);
|
||||
void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object);
|
||||
void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object);
|
||||
FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order);
|
||||
FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -54,7 +54,7 @@
|
|||
* OUT out[0,lag-1]
|
||||
* IN data_len
|
||||
*/
|
||||
void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len);
|
||||
void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_autocorrelation()
|
||||
|
@ -68,25 +68,43 @@ void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FL
|
|||
* IN 0 < lag <= data_len
|
||||
* OUT autoc[0,lag-1]
|
||||
*/
|
||||
void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_16(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_16_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
# endif
|
||||
# endif
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN
|
||||
# ifdef FLAC__SSE_SUPPORTED
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
# endif
|
||||
# endif
|
||||
#if defined(FLAC__CPU_PPC64) && defined(FLAC__USE_VSX)
|
||||
#ifdef FLAC__HAS_TARGET_POWER9
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power9_vsx_lag_4(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power9_vsx_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power9_vsx_lag_12(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power9_vsx_lag_16(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
#endif
|
||||
#ifdef FLAC__HAS_TARGET_POWER8
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power8_vsx_lag_4(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power8_vsx_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power8_vsx_lag_12(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
void FLAC__lpc_compute_autocorrelation_intrin_power8_vsx_lag_16(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -110,7 +128,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16(const FLAC__real data[]
|
|||
* in lp_coeff[8][0,8], the LP coefficients for order 8 will be
|
||||
* in lp_coeff[7][0,7], etc.
|
||||
*/
|
||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]);
|
||||
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_quantize_coefficients()
|
||||
|
@ -132,7 +150,7 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_o
|
|||
* 2 => coefficients are all zero, which is bad. 'shift' is
|
||||
* unset.
|
||||
*/
|
||||
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift);
|
||||
int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_residual_from_qlp_coefficients()
|
||||
|
@ -147,29 +165,29 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
|
|||
* IN lp_quantization quantization of LP coefficients in bits
|
||||
* OUT residual[0,data_len-1] residual signal
|
||||
*/
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_asm_ia32(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
# endif
|
||||
# endif
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN
|
||||
# ifdef FLAC__SSE2_SUPPORTED
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
# endif
|
||||
# ifdef FLAC__SSE4_1_SUPPORTED
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
# endif
|
||||
# ifdef FLAC__AVX2_SUPPORTED
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
@ -191,22 +209,21 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLA
|
|||
* IN data[-order,-1] previously-reconstructed historical samples
|
||||
* OUT data[0,data_len-1] original signal
|
||||
*/
|
||||
void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
#ifndef FLAC__NO_ASM
|
||||
# ifdef FLAC__CPU_IA32
|
||||
# ifdef FLAC__HAS_NASM
|
||||
void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_wide_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_wide_asm_ia32(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
# endif /* FLAC__HAS_NASM */
|
||||
# endif /* FLAC__CPU_IA32 */
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X86INTRIN
|
||||
# ifdef FLAC__SSE2_SUPPORTED
|
||||
void FLAC__lpc_restore_signal_16_intrin_sse2(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
# endif
|
||||
# if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN
|
||||
# ifdef FLAC__SSE4_1_SUPPORTED
|
||||
void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_intrin_sse41(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_16_intrin_sse41(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
# endif
|
||||
# endif
|
||||
#endif /* FLAC__NO_ASM */
|
||||
|
@ -223,8 +240,8 @@ void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], un
|
|||
* IN total_samples > 0 # of samples in residual signal
|
||||
* RETURN expected bits per sample
|
||||
*/
|
||||
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples);
|
||||
FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale);
|
||||
double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples);
|
||||
double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale);
|
||||
|
||||
/*
|
||||
* FLAC__lpc_compute_best_order()
|
||||
|
@ -239,7 +256,7 @@ FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scal
|
|||
* (includes warmup sample size and quantized LP coefficient)
|
||||
* RETURN [1,max_order] best order
|
||||
*/
|
||||
unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order);
|
||||
uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order);
|
||||
|
||||
#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2012-2014 Xiph.org Foundation
|
||||
* Copyright (C) 2012-2016 Xiph.org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -32,24 +32,19 @@
|
|||
#ifndef FLAC__PRIVATE__MACROS_H
|
||||
#define FLAC__PRIVATE__MACROS_H
|
||||
|
||||
#ifdef Plan9
|
||||
#define flac_min(x,y) MIN(x,y)
|
||||
#define flac_max(x,y) MAX(x,y)
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
||||
|
||||
#define flac_max(a,b) \
|
||||
({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a > _b ? _a : _b; })
|
||||
({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
_a > _b ? _a : _b; })
|
||||
|
||||
#define MIN_PASTE(A,B) A##B
|
||||
#define MIN_IMPL(A,B,L) ({ \
|
||||
__typeof__(A) MIN_PASTE(__a,L) = (A); \
|
||||
__typeof__(B) MIN_PASTE(__b,L) = (B); \
|
||||
MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); \
|
||||
})
|
||||
__typeof__(A) MIN_PASTE(__a,L) = (A); \
|
||||
__typeof__(B) MIN_PASTE(__b,L) = (B); \
|
||||
MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); \
|
||||
})
|
||||
|
||||
#define flac_min(A,B) MIN_IMPL(A,B,__COUNTER__)
|
||||
|
||||
|
@ -66,12 +61,12 @@
|
|||
#define flac_min(a,b) __min(a,b)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) ((x) <= (y) ? (x) : (y))
|
||||
#ifndef flac_min
|
||||
#define flac_min(x,y) ((x) <= (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x) >= (y) ? (x) : (y))
|
||||
#ifndef flac_max
|
||||
#define flac_max(x,y) ((x) >= (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,6 @@ typedef struct {
|
|||
void FLAC__MD5Init(FLAC__MD5Context *context);
|
||||
void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context);
|
||||
|
||||
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample);
|
||||
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -49,7 +49,7 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address);
|
|||
FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer);
|
||||
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, uint32_t **unaligned_pointer, uint32_t **aligned_pointer);
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer);
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -46,7 +46,7 @@ typedef struct FLAC__OggDecoderAspect {
|
|||
/* these are for internal state related to Ogg decoding */
|
||||
ogg_stream_state stream_state;
|
||||
ogg_sync_state sync_state;
|
||||
unsigned version_major, version_minor;
|
||||
uint32_t version_major, version_minor;
|
||||
FLAC__bool need_serial_number;
|
||||
FLAC__bool end_of_stream;
|
||||
FLAC__bool have_working_page; /* only if true will the following vars be valid */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2002-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -41,7 +41,7 @@
|
|||
typedef struct FLAC__OggEncoderAspect {
|
||||
/* these are storage for values that can be set through the API */
|
||||
long serial_number;
|
||||
unsigned num_metadata;
|
||||
uint32_t num_metadata;
|
||||
|
||||
/* these are for internal state related to Ogg encoding */
|
||||
ogg_stream_state stream_state;
|
||||
|
@ -52,12 +52,12 @@ typedef struct FLAC__OggEncoderAspect {
|
|||
} FLAC__OggEncoderAspect;
|
||||
|
||||
void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, long value);
|
||||
FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, unsigned value);
|
||||
FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, uint32_t value);
|
||||
void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect);
|
||||
FLAC__bool FLAC__ogg_encoder_aspect_init(FLAC__OggEncoderAspect *aspect);
|
||||
void FLAC__ogg_encoder_aspect_finish(FLAC__OggEncoderAspect *aspect);
|
||||
|
||||
typedef FLAC__StreamEncoderWriteStatus (*FLAC__OggEncoderAspectWriteCallbackProxy)(const void *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
|
||||
typedef FLAC__StreamEncoderWriteStatus (*FLAC__OggEncoderAspectWriteCallbackProxy)(const void *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data);
|
||||
|
||||
FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data);
|
||||
FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data);
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec
|
||||
* Copyright (C) 2004-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -38,7 +38,7 @@
|
|||
/** The length of the packet type field in bytes. */
|
||||
#define FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH (1u)
|
||||
|
||||
extern const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */
|
||||
extern const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */
|
||||
|
||||
extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */
|
||||
|
||||
|
@ -47,8 +47,8 @@ extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */
|
|||
|
||||
extern const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC; /* = "FLAC" */
|
||||
|
||||
extern const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */
|
||||
extern const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */
|
||||
extern const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */
|
||||
extern const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */
|
||||
|
||||
/** The length of the Ogg FLAC mapping major version number in bytes. */
|
||||
#define FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH (1u)
|
||||
|
@ -56,7 +56,7 @@ extern const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */
|
|||
/** The length of the Ogg FLAC mapping minor version number in bytes. */
|
||||
#define FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH (1u)
|
||||
|
||||
extern const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */
|
||||
extern const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */
|
||||
|
||||
/** The length of the #-of-header-packets number bytes. */
|
||||
#define FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH (2u)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -49,17 +49,17 @@
|
|||
|
||||
#ifdef FLAC__SSE2_SUPPORTED
|
||||
extern void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[],
|
||||
unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps);
|
||||
uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps);
|
||||
#endif
|
||||
|
||||
#ifdef FLAC__SSSE3_SUPPORTED
|
||||
extern void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[],
|
||||
unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps);
|
||||
uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps);
|
||||
#endif
|
||||
|
||||
#ifdef FLAC__AVX2_SUPPORTED
|
||||
extern void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[],
|
||||
unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps);
|
||||
uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -38,9 +38,9 @@
|
|||
|
||||
FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw);
|
||||
FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2006-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -41,11 +41,11 @@
|
|||
typedef struct FLAC__StreamDecoderProtected {
|
||||
FLAC__StreamDecoderState state;
|
||||
FLAC__StreamDecoderInitStatus initstate;
|
||||
unsigned channels;
|
||||
uint32_t channels;
|
||||
FLAC__ChannelAssignment channel_assignment;
|
||||
unsigned bits_per_sample;
|
||||
unsigned sample_rate; /* in Hz */
|
||||
unsigned blocksize; /* in samples (per channel) */
|
||||
uint32_t bits_per_sample;
|
||||
uint32_t sample_rate; /* in Hz */
|
||||
uint32_t blocksize; /* in samples (per channel) */
|
||||
FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */
|
||||
#if FLAC__HAS_OGG
|
||||
FLAC__OggDecoderAspect ogg_decoder_aspect;
|
||||
|
@ -55,6 +55,11 @@ typedef struct FLAC__StreamDecoderProtected {
|
|||
/*
|
||||
* return the number of input bytes consumed
|
||||
*/
|
||||
unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder);
|
||||
uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder);
|
||||
|
||||
/*
|
||||
* return client_data from decoder
|
||||
*/
|
||||
FLAC_API void *get_client_data_from_decoder(FLAC__StreamDecoder *decoder);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2001-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -81,7 +81,7 @@ typedef struct {
|
|||
} parameters;
|
||||
} FLAC__ApodizationSpecification;
|
||||
|
||||
#endif
|
||||
#endif // #ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
|
||||
typedef struct FLAC__StreamEncoderProtected {
|
||||
FLAC__StreamEncoderState state;
|
||||
|
@ -90,25 +90,25 @@ typedef struct FLAC__StreamEncoderProtected {
|
|||
FLAC__bool do_md5;
|
||||
FLAC__bool do_mid_side_stereo;
|
||||
FLAC__bool loose_mid_side_stereo;
|
||||
unsigned channels;
|
||||
unsigned bits_per_sample;
|
||||
unsigned sample_rate;
|
||||
unsigned blocksize;
|
||||
uint32_t channels;
|
||||
uint32_t bits_per_sample;
|
||||
uint32_t sample_rate;
|
||||
uint32_t blocksize;
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
unsigned num_apodizations;
|
||||
uint32_t num_apodizations;
|
||||
FLAC__ApodizationSpecification apodizations[FLAC__MAX_APODIZATION_FUNCTIONS];
|
||||
#endif
|
||||
unsigned max_lpc_order;
|
||||
unsigned qlp_coeff_precision;
|
||||
uint32_t max_lpc_order;
|
||||
uint32_t qlp_coeff_precision;
|
||||
FLAC__bool do_qlp_coeff_prec_search;
|
||||
FLAC__bool do_exhaustive_model_search;
|
||||
FLAC__bool do_escape_coding;
|
||||
unsigned min_residual_partition_order;
|
||||
unsigned max_residual_partition_order;
|
||||
unsigned rice_parameter_search_dist;
|
||||
uint32_t min_residual_partition_order;
|
||||
uint32_t max_residual_partition_order;
|
||||
uint32_t rice_parameter_search_dist;
|
||||
FLAC__uint64 total_samples_estimate;
|
||||
FLAC__StreamMetadata **metadata;
|
||||
unsigned num_metadata_blocks;
|
||||
uint32_t num_metadata_blocks;
|
||||
FLAC__uint64 streaminfo_offset, seektable_offset, audio_offset;
|
||||
#if FLAC__HAS_OGG
|
||||
FLAC__OggEncoderAspect ogg_encoder_aspect;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* alloc - Convenience routines for safely allocating memory
|
||||
* Copyright (C) 2007-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -52,7 +52,7 @@
|
|||
# ifndef SIZE_T_MAX
|
||||
# ifdef _MSC_VER
|
||||
# ifdef _WIN64
|
||||
# define SIZE_T_MAX 0xffffffffffffffffui64
|
||||
# define SIZE_T_MAX FLAC__U64L(0xffffffffffffffff)
|
||||
# else
|
||||
# define SIZE_T_MAX 0xffffffff
|
||||
# endif
|
||||
|
@ -153,11 +153,21 @@ static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size
|
|||
return malloc(size1*size2);
|
||||
}
|
||||
|
||||
static inline void *safe_realloc_(void *ptr, size_t size)
|
||||
{
|
||||
void *oldptr = ptr;
|
||||
void *newptr = realloc(ptr, size);
|
||||
if(size > 0 && newptr == 0)
|
||||
free(oldptr);
|
||||
return newptr;
|
||||
}
|
||||
static inline void *safe_realloc_add_2op_(void *ptr, size_t size1, size_t size2)
|
||||
{
|
||||
size2 += size1;
|
||||
if(size2 < size1)
|
||||
if(size2 < size1) {
|
||||
free(ptr);
|
||||
return 0;
|
||||
}
|
||||
return realloc(ptr, size2);
|
||||
}
|
||||
|
||||
|
@ -192,7 +202,7 @@ static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
|
|||
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
|
||||
if(size1 > SIZE_MAX / size2)
|
||||
return 0;
|
||||
return realloc(ptr, size1*size2);
|
||||
return safe_realloc_(ptr, size1*size2);
|
||||
}
|
||||
|
||||
/* size1 * (size2 + size3) */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2012-2014 Xiph.org Foundation
|
||||
* Copyright (C) 2012-2016 Xiph.org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -29,7 +29,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* This is the prefered location of all CPP hackery to make $random_compiler
|
||||
/* This is the preferred location of all CPP hackery to make $random_compiler
|
||||
* work like something approaching a C99 (or maybe more accurately GNU99)
|
||||
* compiler.
|
||||
*
|
||||
|
@ -72,7 +72,7 @@
|
|||
#define strtoull _strtoui64
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
|
@ -87,7 +87,10 @@
|
|||
|
||||
#define FLAC__U64L(x) x##ULL
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
#define FLAC__STRCASECMP _stricmp
|
||||
#define FLAC__STRNCASECMP _strnicmp
|
||||
#elif defined __BORLANDC__
|
||||
#define FLAC__STRCASECMP stricmp
|
||||
#define FLAC__STRNCASECMP strnicmp
|
||||
#else
|
||||
|
@ -95,7 +98,7 @@
|
|||
#define FLAC__STRNCASECMP strncasecmp
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ || defined __EMX__
|
||||
#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__
|
||||
#include <io.h> /* for _setmode(), chmod() */
|
||||
#include <fcntl.h> /* for _O_BINARY */
|
||||
#else
|
||||
|
@ -114,7 +117,9 @@
|
|||
#endif
|
||||
|
||||
#if defined _MSC_VER
|
||||
# if _MSC_VER >= 1600
|
||||
# if _MSC_VER >= 1800
|
||||
# include <inttypes.h>
|
||||
# elif _MSC_VER >= 1600
|
||||
/* Visual Studio 2010 has decent C99 support */
|
||||
# include <stdint.h>
|
||||
# define PRIu64 "llu"
|
||||
|
@ -125,14 +130,6 @@
|
|||
# ifndef UINT32_MAX
|
||||
# define UINT32_MAX _UI32_MAX
|
||||
# endif
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int8 int8_t;
|
||||
# define PRIu64 "I64u"
|
||||
# define PRId64 "I64d"
|
||||
# define PRIx64 "I64x"
|
||||
|
@ -141,23 +138,26 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
/* All char* strings are in UTF-8 format. Added to support Unicode files on Windows */
|
||||
#include "share/win_utf8_io.h"
|
||||
|
||||
#include "share/win_utf8_io.h"
|
||||
#define flac_printf printf_utf8
|
||||
#define flac_fprintf fprintf_utf8
|
||||
#define flac_vfprintf vfprintf_utf8
|
||||
#define flac_fopen fopen_utf8
|
||||
#define flac_chmod chmod_utf8
|
||||
#define flac_utime utime_utf8
|
||||
#define flac_unlink unlink_utf8
|
||||
#define flac_rename rename_utf8
|
||||
#define flac_stat _stat64_utf8
|
||||
|
||||
#include "share/windows_unicode_filenames.h"
|
||||
#define flac_fopen flac_internal_fopen_utf8
|
||||
#define flac_chmod flac_internal_chmod_utf8
|
||||
#define flac_utime flac_internal_utime_utf8
|
||||
#define flac_unlink flac_internal_unlink_utf8
|
||||
#define flac_rename flac_internal_rename_utf8
|
||||
#define flac_stat flac_internal_stat64_utf8
|
||||
|
||||
#else
|
||||
|
||||
#define flac_printf printf
|
||||
#define flac_fprintf fprintf
|
||||
#define flac_vfprintf vfprintf
|
||||
|
||||
#define flac_fopen fopen
|
||||
#define flac_chmod chmod
|
||||
#define flac_utime utime
|
||||
|
@ -175,6 +175,10 @@
|
|||
#define flac_fstat fstat
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef M_LN2
|
||||
#define M_LN2 0.69314718055994530942
|
||||
#endif
|
||||
|
@ -186,7 +190,7 @@
|
|||
* snprintf as well as Microsoft Visual Studio which has an non-standards
|
||||
* conformant snprint_s function.
|
||||
*
|
||||
* This function wraps the MS version to behave more like the the ISO version.
|
||||
* This function wraps the MS version to behave more like the ISO version.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2012-2014 Xiph.org Foundation
|
||||
* Copyright (C) 2012-2016 Xiph.org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -43,11 +43,15 @@ static inline unsigned short __builtin_bswap16(unsigned short a)
|
|||
|
||||
#define ENDSWAP_16(x) (__builtin_bswap16 (x))
|
||||
#define ENDSWAP_32(x) (__builtin_bswap32 (x))
|
||||
#define ENDSWAP_64(x) (__builtin_bswap64 (x))
|
||||
|
||||
#elif defined _MSC_VER /* Windows. Apparently in <stdlib.h>. */
|
||||
#elif defined _MSC_VER /* Windows */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ENDSWAP_16(x) (_byteswap_ushort (x))
|
||||
#define ENDSWAP_32(x) (_byteswap_ulong (x))
|
||||
#define ENDSWAP_64(x) (_byteswap_uint64 (x))
|
||||
|
||||
#elif defined HAVE_BYTESWAP_H /* Linux */
|
||||
|
||||
|
@ -55,16 +59,18 @@ static inline unsigned short __builtin_bswap16(unsigned short a)
|
|||
|
||||
#define ENDSWAP_16(x) (bswap_16 (x))
|
||||
#define ENDSWAP_32(x) (bswap_32 (x))
|
||||
#define ENDSWAP_64(x) (bswap_64 (x))
|
||||
|
||||
#else
|
||||
|
||||
#define ENDSWAP_16(x) ((((x) >> 8) & 0xFF) | (((x) & 0xFF) << 8))
|
||||
#define ENDSWAP_32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) & 0xFF00) << 8) | (((x) & 0xFF) << 24))
|
||||
#define ENDSWAP_64(x) ((ENDSWAP_32(((x) >> 32) & 0xFFFFFFFF)) | (ENDSWAP_32((x) & 0xFFFFFFFF) << 32))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Host to little-endian byte swapping. */
|
||||
/* Host to little-endian byte swapping (for MD5 calculation) */
|
||||
#if CPU_IS_BIG_ENDIAN
|
||||
|
||||
#define H2LE_16(x) ENDSWAP_16 (x)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013-2014 Xiph.org Foundation
|
||||
* Copyright (C) 2013-2016 Xiph.org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -31,11 +31,15 @@
|
|||
|
||||
#include <errno.h>
|
||||
|
||||
/* FLAC_CHECK_RETURN : Check the return value of of the provided function and
|
||||
* print and error message if it fails (ie returns a value < 0).
|
||||
/* FLAC_CHECK_RETURN : Check the return value of the provided function and
|
||||
* print an error message if it fails (ie returns a value < 0).
|
||||
*
|
||||
* Ideally, a library should not print anything, but this macro is only used
|
||||
* for things that extremely unlikely to fail, like `chown` to a previoulsy
|
||||
* saved `uid`.
|
||||
*/
|
||||
|
||||
#define FLAC_CHECK_RETURN(x) \
|
||||
{ if ((x) < 0) \
|
||||
printf ("%s : %s\n", #x, strerror (errno)) ; \
|
||||
fprintf (stderr, "%s : %s\n", #x, strerror (errno)) ; \
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013-2014 Xiph.org Foundation
|
||||
* Copyright (C) 2013-2016 Xiph.org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -33,7 +33,7 @@
|
|||
#define FLAC__SHARE__PRIVATE_H
|
||||
|
||||
/*
|
||||
* Unpublished debug routines from libFLAC> This should not be used from any
|
||||
* Unpublished debug routines from libFLAC. This should not be used from any
|
||||
* client code other than code shipped with the FLAC sources.
|
||||
*/
|
||||
FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2013-2014 Xiph.org Foundation
|
||||
* Copyright (C) 2013-2016 Xiph.org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -56,13 +56,7 @@
|
|||
|
||||
|
||||
/* technically this should be in an "export.c" but this is convenient enough */
|
||||
FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC =
|
||||
#if FLAC__HAS_OGG
|
||||
1
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
;
|
||||
FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC = FLAC__HAS_OGG;
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -81,25 +75,25 @@ static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' };
|
|||
|
||||
static void set_defaults_(FLAC__StreamDecoder *decoder);
|
||||
static FILE *get_binary_stdin_(void);
|
||||
static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels);
|
||||
static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels);
|
||||
static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id);
|
||||
static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder);
|
||||
static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder);
|
||||
static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length);
|
||||
static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length);
|
||||
static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, unsigned length);
|
||||
static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length);
|
||||
static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length);
|
||||
static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length);
|
||||
static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj);
|
||||
static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj);
|
||||
static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder);
|
||||
static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder);
|
||||
static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder);
|
||||
static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended);
|
||||
static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode);
|
||||
static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended);
|
||||
static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder);
|
||||
static FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data);
|
||||
#if FLAC__HAS_OGG
|
||||
|
@ -125,9 +119,7 @@ static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *c
|
|||
***********************************************************************/
|
||||
|
||||
typedef struct FLAC__StreamDecoderPrivate {
|
||||
#if FLAC__HAS_OGG
|
||||
FLAC__bool is_ogg;
|
||||
#endif
|
||||
FLAC__StreamDecoderReadCallback read_callback;
|
||||
FLAC__StreamDecoderSeekCallback seek_callback;
|
||||
FLAC__StreamDecoderTellCallback tell_callback;
|
||||
|
@ -137,18 +129,18 @@ typedef struct FLAC__StreamDecoderPrivate {
|
|||
FLAC__StreamDecoderMetadataCallback metadata_callback;
|
||||
FLAC__StreamDecoderErrorCallback error_callback;
|
||||
/* generic 32-bit datapath: */
|
||||
void (*local_lpc_restore_signal)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void (*local_lpc_restore_signal)(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
/* generic 64-bit datapath: */
|
||||
void (*local_lpc_restore_signal_64bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void (*local_lpc_restore_signal_64bit)(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
/* for use when the signal is <= 16 bits-per-sample, or <= 15 bits-per-sample on a side channel (which requires 1 extra bit): */
|
||||
void (*local_lpc_restore_signal_16bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
|
||||
void (*local_lpc_restore_signal_16bit)(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]);
|
||||
void *client_data;
|
||||
FILE *file; /* only used if FLAC__stream_decoder_init_file()/FLAC__stream_decoder_init_file() called, else NULL */
|
||||
FLAC__BitReader *input;
|
||||
FLAC__int32 *output[FLAC__MAX_CHANNELS];
|
||||
FLAC__int32 *residual[FLAC__MAX_CHANNELS]; /* WATCHOUT: these are the aligned pointers; the real pointers that should be free()'d are residual_unaligned[] below */
|
||||
FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents[FLAC__MAX_CHANNELS];
|
||||
unsigned output_capacity, output_channels;
|
||||
uint32_t output_capacity, output_channels;
|
||||
FLAC__uint32 fixed_block_size, next_fixed_block_size;
|
||||
FLAC__uint64 samples_decoded;
|
||||
FLAC__bool has_stream_info, has_seek_table;
|
||||
|
@ -173,10 +165,8 @@ typedef struct FLAC__StreamDecoderPrivate {
|
|||
FLAC__Frame last_frame; /* holds the info of the last frame we seeked to */
|
||||
FLAC__uint64 first_frame_offset; /* hint to the seek routine of where in the stream the first audio frame starts */
|
||||
FLAC__uint64 target_sample;
|
||||
unsigned unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */
|
||||
#if FLAC__HAS_OGG
|
||||
uint32_t unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */
|
||||
FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */
|
||||
#endif
|
||||
} FLAC__StreamDecoderPrivate;
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -251,7 +241,7 @@ FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[] = {
|
|||
FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void)
|
||||
{
|
||||
FLAC__StreamDecoder *decoder;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */
|
||||
|
||||
|
@ -313,7 +303,7 @@ FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void)
|
|||
|
||||
FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if (decoder == NULL)
|
||||
return ;
|
||||
|
@ -362,10 +352,8 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
|
|||
if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
|
||||
return FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
|
||||
|
||||
#if !FLAC__HAS_OGG
|
||||
if(is_ogg)
|
||||
if(FLAC__HAS_OGG == 0 && is_ogg)
|
||||
return FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
|
||||
#endif
|
||||
|
||||
if(
|
||||
0 == read_callback ||
|
||||
|
@ -396,7 +384,7 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
|
|||
FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
|
||||
#ifdef FLAC__HAS_NASM
|
||||
decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide_asm_ia32; /* OPT_IA32: was really necessary for GCC < 4.9 */
|
||||
if(decoder->private_->cpuinfo.ia32.mmx) {
|
||||
if (decoder->private_->cpuinfo.x86.mmx) {
|
||||
decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
|
||||
decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32_mmx;
|
||||
}
|
||||
|
@ -405,14 +393,13 @@ static FLAC__StreamDecoderInitStatus init_stream_internal_(
|
|||
decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32;
|
||||
}
|
||||
#endif
|
||||
#ifdef FLAC__HAS_X86INTRIN
|
||||
# if defined FLAC__SSE2_SUPPORTED && !defined FLAC__HAS_NASM /* OPT_SSE: not better than MMX asm */
|
||||
if(decoder->private_->cpuinfo.ia32.sse2) {
|
||||
decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_16_intrin_sse2;
|
||||
}
|
||||
# endif
|
||||
#if FLAC__HAS_X86INTRIN && ! defined FLAC__INTEGER_ONLY_LIBRARY
|
||||
# if defined FLAC__SSE4_1_SUPPORTED
|
||||
if(decoder->private_->cpuinfo.ia32.sse41) {
|
||||
if (decoder->private_->cpuinfo.x86.sse41) {
|
||||
# if !defined FLAC__HAS_NASM /* these are not undoubtedly faster than their MMX ASM counterparts */
|
||||
decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_intrin_sse41;
|
||||
decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_16_intrin_sse41;
|
||||
# endif
|
||||
decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide_intrin_sse41;
|
||||
}
|
||||
# endif
|
||||
|
@ -641,7 +628,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
|
|||
FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool md5_failed = false;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->private_);
|
||||
|
@ -655,18 +642,17 @@ FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
|
|||
*/
|
||||
FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
|
||||
|
||||
if(decoder->private_->has_seek_table && 0 != decoder->private_->seek_table.data.seek_table.points) {
|
||||
free(decoder->private_->seek_table.data.seek_table.points);
|
||||
decoder->private_->seek_table.data.seek_table.points = 0;
|
||||
decoder->private_->has_seek_table = false;
|
||||
}
|
||||
free(decoder->private_->seek_table.data.seek_table.points);
|
||||
decoder->private_->seek_table.data.seek_table.points = 0;
|
||||
decoder->private_->has_seek_table = false;
|
||||
|
||||
FLAC__bitreader_free(decoder->private_->input);
|
||||
for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
|
||||
/* WATCHOUT:
|
||||
* FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
|
||||
* output arrays have a buffer of up to 3 zeroes in front
|
||||
* (at negative indices) for alignment purposes; we use 4
|
||||
* to keep the data well-aligned.
|
||||
* FLAC__lpc_restore_signal_asm_ia32_mmx() and ..._intrin_sseN()
|
||||
* require that the output arrays have a buffer of up to 3 zeroes
|
||||
* in front (at negative indices) for alignment purposes;
|
||||
* we use 4 to keep the data well-aligned.
|
||||
*/
|
||||
if(0 != decoder->private_->output[i]) {
|
||||
free(decoder->private_->output[i]-4);
|
||||
|
@ -736,9 +722,9 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecode
|
|||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->private_);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
FLAC__ASSERT((unsigned)type <= FLAC__MAX_METADATA_TYPE_CODE);
|
||||
FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE);
|
||||
/* double protection */
|
||||
if((unsigned)type > FLAC__MAX_METADATA_TYPE_CODE)
|
||||
if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE)
|
||||
return false;
|
||||
if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
|
||||
return false;
|
||||
|
@ -778,7 +764,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__
|
|||
|
||||
FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->private_);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
@ -795,9 +781,9 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder
|
|||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->private_);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
FLAC__ASSERT((unsigned)type <= FLAC__MAX_METADATA_TYPE_CODE);
|
||||
FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE);
|
||||
/* double protection */
|
||||
if((unsigned)type > FLAC__MAX_METADATA_TYPE_CODE)
|
||||
if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE)
|
||||
return false;
|
||||
if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
|
||||
return false;
|
||||
|
@ -873,7 +859,7 @@ FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamD
|
|||
return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_samples : 0;
|
||||
}
|
||||
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder)
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
@ -887,21 +873,21 @@ FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(con
|
|||
return decoder->protected_->channel_assignment;
|
||||
}
|
||||
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder)
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
return decoder->protected_->bits_per_sample;
|
||||
}
|
||||
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder)
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
return decoder->protected_->sample_rate;
|
||||
}
|
||||
|
||||
FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder)
|
||||
FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
@ -914,10 +900,9 @@ FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamD
|
|||
FLAC__ASSERT(0 != decoder->private_);
|
||||
FLAC__ASSERT(0 != position);
|
||||
|
||||
#if FLAC__HAS_OGG
|
||||
if(decoder->private_->is_ogg)
|
||||
if(FLAC__HAS_OGG && decoder->private_->is_ogg)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if(0 == decoder->private_->tell_callback)
|
||||
return false;
|
||||
if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__STREAM_DECODER_TELL_STATUS_OK)
|
||||
|
@ -936,6 +921,9 @@ FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder)
|
|||
FLAC__ASSERT(0 != decoder->private_);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
||||
if(!decoder->private_->internal_reset_hack && decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED)
|
||||
return false;
|
||||
|
||||
decoder->private_->samples_decoded = 0;
|
||||
decoder->private_->do_md5_checking = false;
|
||||
|
||||
|
@ -987,11 +975,11 @@ FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder)
|
|||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
|
||||
|
||||
decoder->private_->has_stream_info = false;
|
||||
if(decoder->private_->has_seek_table && 0 != decoder->private_->seek_table.data.seek_table.points) {
|
||||
free(decoder->private_->seek_table.data.seek_table.points);
|
||||
decoder->private_->seek_table.data.seek_table.points = 0;
|
||||
decoder->private_->has_seek_table = false;
|
||||
}
|
||||
|
||||
free(decoder->private_->seek_table.data.seek_table.points);
|
||||
decoder->private_->seek_table.data.seek_table.points = 0;
|
||||
decoder->private_->has_seek_table = false;
|
||||
|
||||
decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
|
||||
/*
|
||||
* This goes in reset() and not flush() because according to the spec, a
|
||||
|
@ -1215,7 +1203,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *deco
|
|||
*
|
||||
***********************************************************************/
|
||||
|
||||
unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder)
|
||||
uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
|
||||
|
@ -1231,9 +1219,7 @@ unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecod
|
|||
|
||||
void set_defaults_(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
#if FLAC__HAS_OGG
|
||||
decoder->private_->is_ogg = false;
|
||||
#endif
|
||||
decoder->private_->read_callback = 0;
|
||||
decoder->private_->seek_callback = 0;
|
||||
decoder->private_->tell_callback = 0;
|
||||
|
@ -1266,9 +1252,6 @@ FILE *get_binary_stdin_(void)
|
|||
*/
|
||||
#if defined _MSC_VER || defined __MINGW32__
|
||||
_setmode(_fileno(stdin), _O_BINARY);
|
||||
#elif defined __CYGWIN__
|
||||
/* almost certainly not needed for any modern Cygwin, but let's be safe... */
|
||||
setmode(_fileno(stdin), _O_BINARY);
|
||||
#elif defined __EMX__
|
||||
setmode(fileno(stdin), O_BINARY);
|
||||
#endif
|
||||
|
@ -1276,9 +1259,9 @@ FILE *get_binary_stdin_(void)
|
|||
return stdin;
|
||||
}
|
||||
|
||||
FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels)
|
||||
FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__int32 *tmp;
|
||||
|
||||
if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels)
|
||||
|
@ -1299,10 +1282,10 @@ FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigne
|
|||
|
||||
for(i = 0; i < channels; i++) {
|
||||
/* WATCHOUT:
|
||||
* FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
|
||||
* output arrays have a buffer of up to 3 zeroes in front
|
||||
* (at negative indices) for alignment purposes; we use 4
|
||||
* to keep the data well-aligned.
|
||||
* FLAC__lpc_restore_signal_asm_ia32_mmx() and ..._intrin_sseN()
|
||||
* require that the output arrays have a buffer of up to 3 zeroes
|
||||
* in front (at negative indices) for alignment purposes;
|
||||
* we use 4 to keep the data well-aligned.
|
||||
*/
|
||||
tmp = safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/);
|
||||
if(tmp == 0) {
|
||||
|
@ -1341,7 +1324,7 @@ FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id)
|
|||
FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__uint32 x;
|
||||
unsigned i, id;
|
||||
uint32_t i, id;
|
||||
FLAC__bool first = true;
|
||||
|
||||
FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
|
||||
|
@ -1431,6 +1414,9 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
|
|||
decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data);
|
||||
}
|
||||
else if(type == FLAC__METADATA_TYPE_SEEKTABLE) {
|
||||
/* just in case we already have a seek table, and reading the next one fails: */
|
||||
decoder->private_->has_seek_table = false;
|
||||
|
||||
if(!read_metadata_seektable_(decoder, is_last, length))
|
||||
return false;
|
||||
|
||||
|
@ -1440,7 +1426,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
|
|||
}
|
||||
else {
|
||||
FLAC__bool skip_it = !decoder->private_->metadata_filter[type];
|
||||
unsigned real_length = length;
|
||||
uint32_t real_length = length;
|
||||
FLAC__StreamMetadata block;
|
||||
|
||||
memset(&block, 0, sizeof(block));
|
||||
|
@ -1578,10 +1564,10 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length)
|
||||
FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length)
|
||||
{
|
||||
FLAC__uint32 x;
|
||||
unsigned bits, used_bits = 0;
|
||||
uint32_t bits, used_bits = 0;
|
||||
|
||||
FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
|
||||
|
||||
|
@ -1649,7 +1635,7 @@ FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length)
|
||||
FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length)
|
||||
{
|
||||
FLAC__uint32 i, x;
|
||||
FLAC__uint64 xx;
|
||||
|
@ -1691,7 +1677,7 @@ FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, unsigned length)
|
||||
FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length)
|
||||
{
|
||||
FLAC__uint32 i;
|
||||
|
||||
|
@ -1728,12 +1714,22 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
|
|||
return false; /* read_callback_ sets the state for us */
|
||||
|
||||
/* read comments */
|
||||
if (obj->num_comments > 100000) {
|
||||
/* Possibly malicious file. */
|
||||
obj->num_comments = 0;
|
||||
return false;
|
||||
}
|
||||
if (obj->num_comments > 0) {
|
||||
if (0 == (obj->comments = safe_malloc_mul_2op_p(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
|
||||
obj->num_comments = 0;
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < obj->num_comments; i++) {
|
||||
/* Initialize here just to make sure. */
|
||||
obj->comments[i].length = 0;
|
||||
obj->comments[i].entry = 0;
|
||||
|
||||
FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32);
|
||||
if (length < 4) {
|
||||
obj->num_comments = i;
|
||||
|
@ -1741,12 +1737,12 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
|
|||
}
|
||||
else
|
||||
length -= 4;
|
||||
if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length))
|
||||
if (!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length)) {
|
||||
obj->num_comments = i;
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
}
|
||||
if (obj->comments[i].length > 0) {
|
||||
if (length < obj->comments[i].length) {
|
||||
obj->comments[i].length = 0;
|
||||
obj->comments[i].entry = 0;
|
||||
obj->num_comments = i;
|
||||
goto skip;
|
||||
}
|
||||
|
@ -1754,23 +1750,32 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
|
|||
length -= obj->comments[i].length;
|
||||
if (0 == (obj->comments[i].entry = safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
obj->num_comments = i;
|
||||
return false;
|
||||
}
|
||||
if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
memset (obj->comments[i].entry, 0, obj->comments[i].length) ;
|
||||
if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) {
|
||||
/* Current i-th entry is bad, so we delete it. */
|
||||
free (obj->comments[i].entry) ;
|
||||
obj->comments[i].entry = NULL ;
|
||||
obj->num_comments = i;
|
||||
goto skip;
|
||||
}
|
||||
obj->comments[i].entry[obj->comments[i].length] = '\0';
|
||||
}
|
||||
else
|
||||
obj->comments[i].entry = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
obj->comments = 0;
|
||||
}
|
||||
|
||||
skip:
|
||||
if (length > 0) {
|
||||
/* This will only happen on files with invalid data in comments */
|
||||
/* length > 0 can only happen on files with invalid data in comments */
|
||||
if(obj->num_comments < 1) {
|
||||
free(obj->comments);
|
||||
obj->comments = NULL;
|
||||
}
|
||||
if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
}
|
||||
|
@ -1932,7 +1937,7 @@ FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMeta
|
|||
FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__uint32 x;
|
||||
unsigned i, skip;
|
||||
uint32_t i, skip;
|
||||
|
||||
/* skip the version and flags bytes */
|
||||
if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24))
|
||||
|
@ -2008,10 +2013,10 @@ FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder)
|
|||
|
||||
FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode)
|
||||
{
|
||||
unsigned channel;
|
||||
unsigned i;
|
||||
uint32_t channel;
|
||||
uint32_t i;
|
||||
FLAC__int32 mid, side;
|
||||
unsigned frame_crc; /* the one we calculate from the input stream */
|
||||
uint32_t frame_crc; /* the one we calculate from the input stream */
|
||||
FLAC__uint32 x;
|
||||
|
||||
*got_a_frame = false;
|
||||
|
@ -2032,7 +2037,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
|
|||
/*
|
||||
* first figure the correct bits-per-sample of the subframe
|
||||
*/
|
||||
unsigned bps = decoder->private_->frame.header.bits_per_sample;
|
||||
uint32_t bps = decoder->private_->frame.header.bits_per_sample;
|
||||
switch(decoder->private_->frame.header.channel_assignment) {
|
||||
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
|
||||
/* no adjustment needed */
|
||||
|
@ -2097,7 +2102,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
|
|||
#if 1
|
||||
mid = decoder->private_->output[0][i];
|
||||
side = decoder->private_->output[1][i];
|
||||
mid <<= 1;
|
||||
mid = ((uint32_t) mid) << 1;
|
||||
mid |= (side & 1); /* i.e. if 'side' is odd... */
|
||||
decoder->private_->output[0][i] = (mid + side) >> 1;
|
||||
decoder->private_->output[1][i] = (mid - side) >> 1;
|
||||
|
@ -2143,8 +2148,10 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
|
|||
|
||||
/* write it */
|
||||
if(do_full_decode) {
|
||||
if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE)
|
||||
if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
|
@ -2155,9 +2162,9 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
|||
{
|
||||
FLAC__uint32 x;
|
||||
FLAC__uint64 xx;
|
||||
unsigned i, blocksize_hint = 0, sample_rate_hint = 0;
|
||||
uint32_t i, blocksize_hint = 0, sample_rate_hint = 0;
|
||||
FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */
|
||||
unsigned raw_header_len;
|
||||
uint32_t raw_header_len;
|
||||
FLAC__bool is_unparseable = false;
|
||||
|
||||
FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
|
||||
|
@ -2292,7 +2299,7 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
|||
FLAC__ASSERT(0);
|
||||
}
|
||||
|
||||
x = (unsigned)(raw_header[3] >> 4);
|
||||
x = (uint32_t)(raw_header[3] >> 4);
|
||||
if(x & 8) {
|
||||
decoder->private_->frame.header.channels = 2;
|
||||
switch(x & 7) {
|
||||
|
@ -2311,11 +2318,11 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
|||
}
|
||||
}
|
||||
else {
|
||||
decoder->private_->frame.header.channels = (unsigned)x + 1;
|
||||
decoder->private_->frame.header.channels = (uint32_t)x + 1;
|
||||
decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
|
||||
}
|
||||
|
||||
switch(x = (unsigned)(raw_header[3] & 0x0e) >> 1) {
|
||||
switch(x = (uint32_t)(raw_header[3] & 0x0e) >> 1) {
|
||||
case 0:
|
||||
if(decoder->private_->has_stream_info)
|
||||
decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.bits_per_sample;
|
||||
|
@ -2460,11 +2467,11 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode)
|
||||
FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode)
|
||||
{
|
||||
FLAC__uint32 x;
|
||||
FLAC__bool wasted_bits;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
|
@ -2473,10 +2480,12 @@ FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsign
|
|||
x &= 0xfe;
|
||||
|
||||
if(wasted_bits) {
|
||||
unsigned u;
|
||||
uint32_t u;
|
||||
if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
decoder->private_->frame.subframes[channel].wasted_bits = u+1;
|
||||
if (decoder->private_->frame.subframes[channel].wasted_bits >= bps)
|
||||
return false;
|
||||
bps -= decoder->private_->frame.subframes[channel].wasted_bits;
|
||||
}
|
||||
else
|
||||
|
@ -2523,18 +2532,20 @@ FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsign
|
|||
|
||||
if(wasted_bits && do_full_decode) {
|
||||
x = decoder->private_->frame.subframes[channel].wasted_bits;
|
||||
for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
|
||||
decoder->private_->output[channel][i] <<= x;
|
||||
for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
|
||||
uint32_t val = decoder->private_->output[channel][i];
|
||||
decoder->private_->output[channel][i] = (val << x);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode)
|
||||
FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode)
|
||||
{
|
||||
FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant;
|
||||
FLAC__int32 x;
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
FLAC__int32 *output = decoder->private_->output[channel];
|
||||
|
||||
decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT;
|
||||
|
@ -2553,12 +2564,12 @@ FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channe
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode)
|
||||
FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode)
|
||||
{
|
||||
FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed;
|
||||
FLAC__int32 i32;
|
||||
FLAC__uint32 u32;
|
||||
unsigned u;
|
||||
uint32_t u;
|
||||
|
||||
decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED;
|
||||
|
||||
|
@ -2581,6 +2592,11 @@ FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel,
|
|||
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
|
||||
if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
if(decoder->private_->frame.header.blocksize >> u32 < order) {
|
||||
send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
return true;
|
||||
}
|
||||
subframe->entropy_coding_method.data.partitioned_rice.order = u32;
|
||||
subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel];
|
||||
break;
|
||||
|
@ -2610,12 +2626,12 @@ FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel,
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode)
|
||||
FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode)
|
||||
{
|
||||
FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc;
|
||||
FLAC__int32 i32;
|
||||
FLAC__uint32 u32;
|
||||
unsigned u;
|
||||
uint32_t u;
|
||||
|
||||
decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC;
|
||||
|
||||
|
@ -2642,6 +2658,11 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, un
|
|||
/* read qlp shift */
|
||||
if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
if(i32 < 0) {
|
||||
send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
return true;
|
||||
}
|
||||
subframe->quantization_level = i32;
|
||||
|
||||
/* read quantized lp coefficiencts */
|
||||
|
@ -2660,6 +2681,11 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, un
|
|||
case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
|
||||
if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
|
||||
return false; /* read_callback_ sets the state for us */
|
||||
if(decoder->private_->frame.header.blocksize >> u32 < order) {
|
||||
send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
return true;
|
||||
}
|
||||
subframe->entropy_coding_method.data.partitioned_rice.order = u32;
|
||||
subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel];
|
||||
break;
|
||||
|
@ -2683,9 +2709,6 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, un
|
|||
/* decode the subframe */
|
||||
if(do_full_decode) {
|
||||
memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
|
||||
/*@@@@@@ technically not pessimistic enough, should be more like
|
||||
if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) )
|
||||
*/
|
||||
if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)
|
||||
if(bps <= 16 && subframe->qlp_coeff_precision <= 16)
|
||||
decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
|
||||
|
@ -2698,11 +2721,11 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, un
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode)
|
||||
FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode)
|
||||
{
|
||||
FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim;
|
||||
FLAC__int32 x, *residual = decoder->private_->residual[channel];
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM;
|
||||
|
||||
|
@ -2721,33 +2744,18 @@ FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channe
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended)
|
||||
FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended)
|
||||
{
|
||||
FLAC__uint32 rice_parameter;
|
||||
int i;
|
||||
unsigned partition, sample, u;
|
||||
const unsigned partitions = 1u << partition_order;
|
||||
const unsigned partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_order : decoder->private_->frame.header.blocksize - predictor_order;
|
||||
const unsigned plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
|
||||
const unsigned pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
|
||||
uint32_t partition, sample, u;
|
||||
const uint32_t partitions = 1u << partition_order;
|
||||
const uint32_t partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_order : decoder->private_->frame.header.blocksize - predictor_order;
|
||||
const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
|
||||
const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
|
||||
|
||||
/* sanity checks */
|
||||
if(partition_order == 0) {
|
||||
if(decoder->private_->frame.header.blocksize < predictor_order) {
|
||||
send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
/* We have received a potentially malicious bit stream. All we can do is error out to avoid a heap overflow. */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(partition_samples < predictor_order) {
|
||||
send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
|
||||
/* We have received a potentially malicious bit stream. All we can do is error out to avoid a heap overflow. */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* invalid predictor and partition orders mush be handled in the callers */
|
||||
FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.header.blocksize >= predictor_order);
|
||||
|
||||
if(!FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, flac_max(6u, partition_order))) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
|
@ -2935,12 +2943,12 @@ FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder
|
|||
#endif
|
||||
decoder->private_->last_frame = *frame; /* save the frame */
|
||||
if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */
|
||||
unsigned delta = (unsigned)(target_sample - this_frame_sample);
|
||||
uint32_t delta = (uint32_t)(target_sample - this_frame_sample);
|
||||
/* kick out of seek mode */
|
||||
decoder->private_->is_seeking = false;
|
||||
/* shift out the samples before target_sample */
|
||||
if(delta > 0) {
|
||||
unsigned channel;
|
||||
uint32_t channel;
|
||||
const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS];
|
||||
for(channel = 0; channel < frame->header.channels; channel++)
|
||||
newbuffer[channel] = buffer[channel] + delta;
|
||||
|
@ -2986,16 +2994,16 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||
FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound, lower_bound_sample, upper_bound_sample, this_frame_sample;
|
||||
FLAC__int64 pos = -1;
|
||||
int i;
|
||||
unsigned approx_bytes_per_frame;
|
||||
uint32_t approx_bytes_per_frame;
|
||||
FLAC__bool first_seek = true;
|
||||
const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder);
|
||||
const unsigned min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize;
|
||||
const unsigned max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize;
|
||||
const unsigned max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize;
|
||||
const unsigned min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize;
|
||||
const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize;
|
||||
const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize;
|
||||
const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize;
|
||||
const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize;
|
||||
/* take these from the current frame in case they've changed mid-stream */
|
||||
unsigned channels = FLAC__stream_decoder_get_channels(decoder);
|
||||
unsigned bps = FLAC__stream_decoder_get_bits_per_sample(decoder);
|
||||
uint32_t channels = FLAC__stream_decoder_get_channels(decoder);
|
||||
uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder);
|
||||
const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->private_->seek_table.data.seek_table : 0;
|
||||
|
||||
/* use values from stream info if we didn't decode a frame */
|
||||
|
@ -3014,7 +3022,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||
* min_blocksize might be zero.
|
||||
*/
|
||||
else if(min_blocksize == max_blocksize && min_blocksize > 0) {
|
||||
/* note there are no () around 'bps/8' to keep precision up since it's an integer calulation */
|
||||
/* note there are no () around 'bps/8' to keep precision up since it's an integer calculation */
|
||||
approx_bytes_per_frame = min_blocksize * channels * bps/8 + 64;
|
||||
}
|
||||
else
|
||||
|
@ -3104,7 +3112,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||
return false;
|
||||
}
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
pos = (FLAC__int64)lower_bound + (FLAC__int64)((FLAC__double)(target_sample - lower_bound_sample) / (FLAC__double)(upper_bound_sample - lower_bound_sample) * (FLAC__double)(upper_bound - lower_bound)) - approx_bytes_per_frame;
|
||||
pos = (FLAC__int64)lower_bound + (FLAC__int64)((double)(target_sample - lower_bound_sample) / (double)(upper_bound_sample - lower_bound_sample) * (double)(upper_bound - lower_bound)) - approx_bytes_per_frame;
|
||||
#else
|
||||
/* a little less accurate: */
|
||||
if(upper_bound - lower_bound < 0xffffffff)
|
||||
|
@ -3131,7 +3139,8 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||
* FLAC__stream_decoder_process_single() to return false.
|
||||
*/
|
||||
decoder->private_->unparseable_frame_count = 0;
|
||||
if(!FLAC__stream_decoder_process_single(decoder)) {
|
||||
if(!FLAC__stream_decoder_process_single(decoder) ||
|
||||
decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -3175,7 +3184,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||
decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
approx_bytes_per_frame = (unsigned)(2 * (upper_bound - pos) / 3 + 16);
|
||||
approx_bytes_per_frame = (uint32_t)(2 * (upper_bound - pos) / 3 + 16);
|
||||
}
|
||||
else { /* target_sample >= this_frame_sample + this frame's blocksize */
|
||||
lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize;
|
||||
|
@ -3183,7 +3192,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
|
|||
decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
approx_bytes_per_frame = (unsigned)(2 * (lower_bound - pos) / 3 + 16);
|
||||
approx_bytes_per_frame = (uint32_t)(2 * (lower_bound - pos) / 3 + 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3198,14 +3207,14 @@ FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint
|
|||
FLAC__uint64 this_frame_sample = (FLAC__uint64)0 - 1;
|
||||
FLAC__uint64 pos = 0; /* only initialized to avoid compiler warning */
|
||||
FLAC__bool did_a_seek;
|
||||
unsigned iteration = 0;
|
||||
uint32_t iteration = 0;
|
||||
|
||||
/* In the first iterations, we will calculate the target byte position
|
||||
* by the distance from the target sample to left_sample and
|
||||
* right_sample (let's call it "proportional search"). After that, we
|
||||
* will switch to binary search.
|
||||
*/
|
||||
unsigned BINARY_SEARCH_AFTER_ITERATION = 2;
|
||||
uint32_t BINARY_SEARCH_AFTER_ITERATION = 2;
|
||||
|
||||
/* We will switch to a linear search once our current sample is less
|
||||
* than this number of samples ahead of the target sample
|
||||
|
@ -3228,7 +3237,7 @@ FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint
|
|||
}
|
||||
else {
|
||||
#ifndef FLAC__INTEGER_ONLY_LIBRARY
|
||||
pos = (FLAC__uint64)((FLAC__double)(target_sample - left_sample) / (FLAC__double)(right_sample - left_sample) * (FLAC__double)(right_pos - left_pos));
|
||||
pos = (FLAC__uint64)((double)(target_sample - left_sample) / (double)(right_sample - left_sample) * (double)(right_pos - left_pos));
|
||||
#else
|
||||
/* a little less accurate: */
|
||||
if ((target_sample-left_sample <= 0xffffffff) && (right_pos-left_pos <= 0xffffffff))
|
||||
|
@ -3258,7 +3267,8 @@ FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint
|
|||
did_a_seek = false;
|
||||
|
||||
decoder->private_->got_a_frame = false;
|
||||
if(!FLAC__stream_decoder_process_single(decoder)) {
|
||||
if(!FLAC__stream_decoder_process_single(decoder) ||
|
||||
decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -3387,3 +3397,8 @@ FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_d
|
|||
|
||||
return feof(decoder->private_->file)? true : false;
|
||||
}
|
||||
|
||||
void *get_client_data_from_decoder(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
return decoder->private_->client_data;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2000-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -39,14 +39,15 @@
|
|||
#include "private/stream_encoder_framing.h"
|
||||
#include "private/crc.h"
|
||||
#include "FLAC/assert.h"
|
||||
#include "share/compat.h"
|
||||
|
||||
static FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCodingMethod *method);
|
||||
static FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order, const FLAC__bool is_extended);
|
||||
static FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended);
|
||||
|
||||
FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw)
|
||||
{
|
||||
unsigned i, j;
|
||||
const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING);
|
||||
uint32_t i, j;
|
||||
const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING);
|
||||
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->is_last, FLAC__STREAM_METADATA_IS_LAST_LEN))
|
||||
return false;
|
||||
|
@ -64,6 +65,9 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
|
|||
i += vendor_string_length;
|
||||
}
|
||||
FLAC__ASSERT(i < (1u << FLAC__STREAM_METADATA_LENGTH_LEN));
|
||||
/* double protection */
|
||||
if(i >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN))
|
||||
return false;
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, i, FLAC__STREAM_METADATA_LENGTH_LEN))
|
||||
return false;
|
||||
|
||||
|
@ -92,6 +96,7 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
|
|||
FLAC__ASSERT(metadata->data.stream_info.bits_per_sample <= (1u << FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN));
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.bits_per_sample-1, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN))
|
||||
return false;
|
||||
FLAC__ASSERT(metadata->data.stream_info.total_samples < (FLAC__U64L(1) << FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN));
|
||||
if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN))
|
||||
return false;
|
||||
if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.stream_info.md5sum, 16))
|
||||
|
@ -214,7 +219,7 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__
|
|||
|
||||
FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw)
|
||||
{
|
||||
unsigned u, blocksize_hint, sample_rate_hint;
|
||||
uint32_t u, blocksize_hint, sample_rate_hint;
|
||||
FLAC__byte crc;
|
||||
|
||||
FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw));
|
||||
|
@ -359,7 +364,7 @@ FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWrit
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
|
||||
FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw)
|
||||
{
|
||||
FLAC__bool ok;
|
||||
|
||||
|
@ -372,9 +377,9 @@ FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe,
|
|||
return ok;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
|
||||
FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK | (subframe->order<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN))
|
||||
return false;
|
||||
|
@ -410,9 +415,9 @@ FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsign
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
|
||||
FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK | ((subframe->order-1)<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN))
|
||||
return false;
|
||||
|
@ -456,9 +461,9 @@ FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned r
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
|
||||
FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw)
|
||||
{
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
const FLAC__int32 *signal = subframe->data;
|
||||
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN))
|
||||
|
@ -490,13 +495,13 @@ FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCo
|
|||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order, const FLAC__bool is_extended)
|
||||
FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended)
|
||||
{
|
||||
const unsigned plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
|
||||
const unsigned pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
|
||||
const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
|
||||
const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
|
||||
|
||||
if(partition_order == 0) {
|
||||
unsigned i;
|
||||
uint32_t i;
|
||||
|
||||
if(raw_bits[0] == 0) {
|
||||
if(!FLAC__bitwriter_write_raw_uint32(bw, rice_parameters[0], plen))
|
||||
|
@ -518,9 +523,9 @@ FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
unsigned i, j, k = 0, k_last = 0;
|
||||
unsigned partition_samples;
|
||||
const unsigned default_partition_samples = (residual_samples+predictor_order) >> partition_order;
|
||||
uint32_t i, j, k = 0, k_last = 0;
|
||||
uint32_t partition_samples;
|
||||
const uint32_t default_partition_samples = (residual_samples+predictor_order) >> partition_order;
|
||||
for(i = 0; i < (1u<<partition_order); i++) {
|
||||
partition_samples = default_partition_samples;
|
||||
if(i == 0)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* libFLAC - Free Lossless Audio Codec library
|
||||
* Copyright (C) 2006-2009 Josh Coalson
|
||||
* Copyright (C) 2011-2014 Xiph.Org Foundation
|
||||
* Copyright (C) 2011-2016 Xiph.Org Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -109,7 +109,7 @@ void FLAC__window_flattop(FLAC__real *window, const FLAC__int32 L)
|
|||
FLAC__int32 n;
|
||||
|
||||
for (n = 0; n < L; n++)
|
||||
window[n] = (FLAC__real)(1.0f - 1.93f * cos(2.0f * M_PI * n / N) + 1.29f * cos(4.0f * M_PI * n / N) - 0.388f * cos(6.0f * M_PI * n / N) + 0.0322f * cos(8.0f * M_PI * n / N));
|
||||
window[n] = (FLAC__real)(0.21557895f - 0.41663158f * cos(2.0f * M_PI * n / N) + 0.277263158f * cos(4.0f * M_PI * n / N) - 0.083578947f * cos(6.0f * M_PI * n / N) + 0.006947368f * cos(8.0f * M_PI * n / N));
|
||||
}
|
||||
|
||||
void FLAC__window_gauss(FLAC__real *window, const FLAC__int32 L, const FLAC__real stddev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue