* level idea of the structure and how to find the information you
* need. As a prerequisite you should have at least a basic
* knowledge of the FLAC format, documented
- * <A HREF="../format.html">here</A>.
+ * <A HREF="https://xiph.org/flac/format.html">here</A>.
*
* \section c_api FLAC C API
*
*
* By writing a little code and linking against libFLAC, it is
* relatively easy to add FLAC support to another program. The
- * library is licensed under <A HREF="../license.html">Xiph's BSD license</A>.
+ * library is licensed under <A HREF="https://xiph.org/flac/license.html">Xiph's BSD license</A>.
* Complete source code of libFLAC as well as the command-line
* encoder and plugins is available and is a useful source of
* examples.
* example /usr/include/FLAC++/...).
*
* libFLAC++ is also licensed under
- * <A HREF="../license.html">Xiph's BSD license</A>.
+ * <A HREF="https://xiph.org/flac/license.html">Xiph's BSD license</A>.
*
* \section getting_started Getting Started
*
* functions through the links in top bar across this page.
*
* If you prefer a more hands-on approach, you can jump right to some
- * <A HREF="../documentation_example_code.html">example code</A>.
+ * <A HREF="https://xiph.org/flac/documentation_example_code.html">example code</A>.
*
* \section porting_guide Porting Guide
*
* structures used by the rest of the interfaces.
*
* First, you should be familiar with the
- * <A HREF="../format.html">FLAC format</A>. Many of the values here
+ * <A HREF="https://xiph.org/flac/format.html">FLAC format</A>. Many of the values here
* follow directly from the specification. As a user of libFLAC, the
* interesting parts really are the structures that describe the frame
* header and metadata blocks.
*/
} FLAC__EntropyCodingMethod_PartitionedRiceContents;
-/** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>)
+/** Header for a Rice partitioned residual. (c.f. <A HREF="https://xiph.org/flac/format.html#partitioned_rice">format specification</A>)
*/
typedef struct {
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>)
+/** Header for the entropy coding method. (c.f. <A HREF="https://xiph.org/flac/format.html#residual">format specification</A>)
*/
typedef struct {
FLAC__EntropyCodingMethodType type;
extern FLAC_API const char * const FLAC__SubframeTypeString[];
-/** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>)
+/** CONSTANT subframe. (c.f. <A HREF="https://xiph.org/flac/format.html#subframe_constant">format specification</A>)
*/
typedef struct {
FLAC__int64 value; /**< The constant signal value. */
} FLAC__VerbatimSubframeDataType;
-/** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>)
+/** VERBATIM subframe. (c.f. <A HREF="https://xiph.org/flac/format.html#subframe_verbatim">format specification</A>)
*/
typedef struct {
union {
} FLAC__Subframe_Verbatim;
-/** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>)
+/** FIXED subframe. (c.f. <A HREF="https://xiph.org/flac/format.html#subframe_fixed">format specification</A>)
*/
typedef struct {
FLAC__EntropyCodingMethod entropy_coding_method;
} FLAC__Subframe_Fixed;
-/** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>)
+/** LPC subframe. (c.f. <A HREF="https://xiph.org/flac/format.html#subframe_lpc">format specification</A>)
*/
typedef struct {
FLAC__EntropyCodingMethod entropy_coding_method;
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>)
+/** FLAC subframe structure. (c.f. <A HREF="https://xiph.org/flac/format.html#subframe">format specification</A>)
*/
typedef struct {
FLAC__SubframeType type;
extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
-/** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>)
+/** FLAC frame header structure. (c.f. <A HREF="https://xiph.org/flac/format.html#frame_header">format specification</A>)
*/
typedef struct {
uint32_t blocksize;
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>)
+/** FLAC frame footer structure. (c.f. <A HREF="https://xiph.org/flac/format.html#frame_footer">format specification</A>)
*/
typedef struct {
FLAC__uint16 crc;
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>)
+/** FLAC frame structure. (c.f. <A HREF="https://xiph.org/flac/format.html#frame">format specification</A>)
*/
typedef struct {
FLAC__FrameHeader header;
typedef enum {
FLAC__METADATA_TYPE_STREAMINFO = 0,
- /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_streaminfo">STREAMINFO</A> block */
FLAC__METADATA_TYPE_PADDING = 1,
- /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_padding">PADDING</A> block */
FLAC__METADATA_TYPE_APPLICATION = 2,
- /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_application">APPLICATION</A> block */
FLAC__METADATA_TYPE_SEEKTABLE = 3,
- /**< <A HREF="../format.html#metadata_block_seektable">SEEKTABLE</A> block */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_seektable">SEEKTABLE</A> block */
FLAC__METADATA_TYPE_VORBIS_COMMENT = 4,
- /**< <A HREF="../format.html#metadata_block_vorbis_comment">VORBISCOMMENT</A> block (a.k.a. FLAC tags) */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_vorbis_comment">VORBISCOMMENT</A> block (a.k.a. FLAC tags) */
FLAC__METADATA_TYPE_CUESHEET = 5,
- /**< <A HREF="../format.html#metadata_block_cuesheet">CUESHEET</A> block */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_cuesheet">CUESHEET</A> block */
FLAC__METADATA_TYPE_PICTURE = 6,
- /**< <A HREF="../format.html#metadata_block_picture">PICTURE</A> block */
+ /**< <A HREF="https://xiph.org/flac/format.html#metadata_block_picture">PICTURE</A> block */
FLAC__METADATA_TYPE_UNDEFINED = 7,
/**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
extern FLAC_API const char * const FLAC__MetadataTypeString[];
-/** FLAC STREAMINFO structure. (c.f. <A HREF="../format.html#metadata_block_streaminfo">format specification</A>)
+/** FLAC STREAMINFO structure. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block_streaminfo">format specification</A>)
*/
typedef struct {
uint32_t min_blocksize, max_blocksize;
/** The total stream length of the STREAMINFO block in bytes. */
#define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
-/** FLAC PADDING structure. (c.f. <A HREF="../format.html#metadata_block_padding">format specification</A>)
+/** FLAC PADDING structure. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block_padding">format specification</A>)
*/
typedef struct {
int dummy;
} FLAC__StreamMetadata_Padding;
-/** FLAC APPLICATION structure. (c.f. <A HREF="../format.html#metadata_block_application">format specification</A>)
+/** FLAC APPLICATION structure. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block_application">format specification</A>)
*/
typedef struct {
FLAC__byte id[4];
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>)
+/** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A HREF="https://xiph.org/flac/format.html#seekpoint">format specification</A>)
*/
typedef struct {
FLAC__uint64 sample_number;
extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
-/** FLAC SEEKTABLE structure. (c.f. <A HREF="../format.html#metadata_block_seektable">format specification</A>)
+/** FLAC SEEKTABLE structure. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block_seektable">format specification</A>)
*
* \note From the format specification:
* - The seek points must be sorted by ascending sample number.
} FLAC__StreamMetadata_SeekTable;
-/** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
+/** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block_vorbis_comment">format specification</A>)
*
* For convenience, the APIs maintain a trailing NUL character at the end of
* \a entry which is not counted toward \a length, i.e.
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>)
+/** FLAC VORBIS_COMMENT structure. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block_vorbis_comment">format specification</A>)
*/
typedef struct {
FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
/** FLAC CUESHEET track index structure. (See the
- * <A HREF="../format.html#cuesheet_track_index">format specification</A> for
+ * <A HREF="https://xiph.org/flac/format.html#cuesheet_track_index">format specification</A> for
* the full description of each field.)
*/
typedef struct {
/** FLAC CUESHEET track structure. (See the
- * <A HREF="../format.html#cuesheet_track">format specification</A> for
+ * <A HREF="https://xiph.org/flac/format.html#cuesheet_track">format specification</A> for
* the full description of each field.)
*/
typedef struct {
/** FLAC CUESHEET structure. (See the
- * <A HREF="../format.html#metadata_block_cuesheet">format specification</A>
+ * <A HREF="https://xiph.org/flac/format.html#metadata_block_cuesheet">format specification</A>
* for the full description of each field.)
*/
typedef struct {
extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[];
/** FLAC PICTURE structure. (See the
- * <A HREF="../format.html#metadata_block_picture">format specification</A>
+ * <A HREF="https://xiph.org/flac/format.html#metadata_block_picture">format specification</A>
* for the full description of each field.)
*/
typedef struct {
} FLAC__StreamMetadata_Unknown;
-/** FLAC metadata block structure. (c.f. <A HREF="../format.html#metadata_block">format specification</A>)
+/** FLAC metadata block structure. (c.f. <A HREF="https://xiph.org/flac/format.html#metadata_block">format specification</A>)
*/
typedef struct FLAC__StreamMetadata {
FLAC__MetadataType type;
* \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>,
+ * <a href="http://xiph.org/flhttps://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 uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
* samples of length \a frame->header.blocksize.
* Channels will be ordered according to the FLAC
* specification; see the documentation for the
- * <A HREF="../format.html#frame_header">frame header</A>.
+ * <A HREF="https://xiph.org/flac/format.html#frame_header">frame header</A>.
* \param client_data The callee's client data set through
* FLAC__stream_decoder_init_*().
* \retval FLAC__StreamDecoderWriteStatus
* Unlike the decoders, the stream encoder has many options that can
* affect the speed and compression ratio. When setting these parameters
* you should have some basic knowledge of the format (see the
- * <A HREF="../documentation_format_overview.html">user-level documentation</A>
- * or the <A HREF="../format.html">formal description</A>). The
+ * <A HREF="https://xiph.org/flac/documentation_format_overview.html">user-level documentation</A>
+ * or the <A HREF="https://xiph.org/flac/format.html">formal description</A>). The
* FLAC__stream_encoder_set_*() functions themselves do not validate the
* values as many are interdependent. The FLAC__stream_encoder_init_*()
* functions will do this, so make sure to pay attention to the state
/**< The specified block size is less than the maximum LPC order. */
FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE,
- /**< The encoder is bound to the <A HREF="../format.html#subset">Subset</A> but other settings violate it. */
+ /**< The encoder is bound to the <A HREF="https://xiph.org/flac/format.html#subset">Subset</A> but other settings violate it. */
FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA,
/**< The metadata input to the encoder is invalid, in one of the following ways:
*/
FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value);
-/** Set the <A HREF="../format.html#subset">Subset</A> flag. If \c true,
+/** Set the <A HREF="https://xiph.org/flac/format.html#subset">Subset</A> flag. If \c true,
* the encoder will comply with the Subset and will check the
* settings during FLAC__stream_encoder_init_*() to see if all settings
* comply. If \c false, the settings may take advantage of the full
*/
FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder);
-/** Get the <A HREF="../format.html#subset>Subset</A> flag.
+/** Get the <A HREF="https://xiph.org/flac/format.html#subset">Subset</A> flag.
*
* \param encoder An encoder instance to query.
* \assert
*
* For applications where channel order is important, channels must
* follow the order as described in the
- * <A HREF="../format.html#frame_header">frame header</A>.
+ * <A HREF="https://xiph.org/flac/format.html#frame_header">frame header</A>.
*
* \param encoder An initialized encoder instance in the OK state.
* \param buffer An array of pointers to each channel's signal.
*
* For applications where channel order is important, channels must
* follow the order as described in the
- * <A HREF="../format.html#frame_header">frame header</A>.
+ * <A HREF="https://xiph.org/flac/format.html#frame_header">frame header</A>.
*
* \param encoder An initialized encoder instance in the OK state.
* \param buffer An array of channel-interleaved data (see above).
#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
+#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && 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;
#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;
__cpuid_count(level, 0, *eax, *ebx, *ecx, *edx);
return;
}
-#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;
}
static void
x86_cpu_info (FLAC__CPUInfo *info)
{
-#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && (defined FLAC__HAS_NASM || FLAC__HAS_X86INTRIN) && !defined FLAC__NO_ASM
+#if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && 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;
+ int i, j;
(void) lag;
FLAC__ASSERT(lag <= MAX_LAG);
- for(int i = 0; i < MAX_LAG; i++)
+ for(i = 0; i < MAX_LAG; i++)
autoc[i] = 0.0;
- for(int i = 0; i < MAX_LAG; i++)
- for(int j = 0; j <= i; j++)
+ for(i = 0; i < MAX_LAG; i++)
+ for(j = 0; j <= i; j++)
autoc[j] += (double)data[i] * (double)data[i-j];
- for(int i = MAX_LAG; i < (int)data_len; i++)
- for(int j = 0; j < MAX_LAG; j++)
+ for(i = MAX_LAG; i < (int)data_len; i++)
+ for(j = 0; j < MAX_LAG; j++)
autoc[j] += (double)data[i] * (double)data[i-j];
FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
FLAC__int32 error, save;
+ uint32_t i;
/* total_error_* are 64-bits to avoid overflow when encoding
* erratic signals when the bits-per-sample and blocksize are
* large.
*/
- for(uint32_t i = 0; i < data_len; i++) {
+ for(i = 0; i < data_len; i++) {
error = data[i] ; total_error_0 += local_abs(error); save = error;
error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
}
#else
- for(int i = 0; i < (int)data_len; i++) {
+ int i;
+ for(i = 0; i < (int)data_len; i++) {
total_error_0 += local_abs(data[i]);
total_error_1 += local_abs(data[i] - data[i-1]);
total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]);
{
FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
uint32_t order;
+ int i;
- for(int i = 0; i < (int)data_len; i++) {
+ for(i = 0; i < (int)data_len; i++) {
total_error_0 += local_abs(data[i]);
total_error_1 += local_abs(data[i] - data[i-1]);
total_error_2 += local_abs(data[i] - 2 * data[i-1] + data[i-2]);
FLAC__uint64 error_0, error_1, error_2, error_3, error_4;
FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true;
uint32_t order = 0;
+ int i;
- for(int i = 0; i < (int)data_len; i++) {
+ for(i = 0; i < (int)data_len; i++) {
error_0 = local_abs64((FLAC__int64)data[i]);
error_1 = (i > 0) ? local_abs64((FLAC__int64)data[i] - data[i-1]) : 0 ;
error_2 = (i > 1) ? local_abs64((FLAC__int64)data[i] - 2 * (FLAC__int64)data[i-1] + data[i-2]) : 0;
FLAC__uint64 error_0, error_1, error_2, error_3, error_4;
FLAC__bool order_0_is_valid = true, order_1_is_valid = true, order_2_is_valid = true, order_3_is_valid = true, order_4_is_valid = true;
uint32_t order = 0;
+ int i;
- for(int i = 0; i < (int)data_len; i++) {
+ for(i = 0; i < (int)data_len; i++) {
error_0 = local_abs64(data[i]);
error_1 = (i > 0) ? local_abs64(data[i] - data[i-1]) : 0 ;
error_2 = (i > 1) ? local_abs64(data[i] - 2 * data[i-1] + data[i-2]) : 0;
#else
/* PACKAGE_VERSION should come from configure */
FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION;
-FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20220922";
+FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20221022";
#endif
FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
autoc[lag] = d;
}
#endif
+ if (data_len < FLAC__MAX_LPC_ORDER || lag > 16) {
+ /*
+ * this version tends to run faster because of better data locality
+ * ('data_len' is usually much larger than 'lag')
+ */
+ double d;
+ uint32_t sample, coeff;
+ const uint32_t limit = data_len - lag;
+
+ FLAC__ASSERT(lag > 0);
+ FLAC__ASSERT(lag <= data_len);
- /*
- * this version tends to run faster because of better data locality
- * ('data_len' is usually much larger than 'lag')
- */
- double d;
- uint32_t sample, coeff;
- const uint32_t limit = data_len - lag;
-
- FLAC__ASSERT(lag > 0);
- FLAC__ASSERT(lag <= data_len);
-
- for(coeff = 0; coeff < lag; coeff++)
- autoc[coeff] = 0.0;
- for(sample = 0; sample <= limit; sample++) {
- d = data[sample];
for(coeff = 0; coeff < lag; coeff++)
- autoc[coeff] += d * data[sample+coeff];
+ autoc[coeff] = 0.0;
+ for(sample = 0; sample <= limit; sample++) {
+ d = data[sample];
+ for(coeff = 0; coeff < lag; coeff++)
+ autoc[coeff] += d * data[sample+coeff];
+ }
+ for(; sample < data_len; sample++) {
+ d = data[sample];
+ for(coeff = 0; coeff < data_len - sample; coeff++)
+ autoc[coeff] += d * data[sample+coeff];
+ }
+ }
+ else if(lag <= 8) {
+ #undef MAX_LAG
+ #define MAX_LAG 8
+ #include "deduplication/lpc_compute_autocorrelation_intrin.c"
}
- for(; sample < data_len; sample++) {
- d = data[sample];
- for(coeff = 0; coeff < data_len - sample; coeff++)
- autoc[coeff] += d * data[sample+coeff];
+ else if(lag <= 12) {
+ #undef MAX_LAG
+ #define MAX_LAG 12
+ #include "deduplication/lpc_compute_autocorrelation_intrin.c"
}
+ else if(lag <= 16) {
+ #undef MAX_LAG
+ #define MAX_LAG 16
+ #include "deduplication/lpc_compute_autocorrelation_intrin.c"
+ }
+
}
void FLAC__lpc_compute_lp_coefficients(const double autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[])
* predictor is known however, so taking the log2 of the sum of the absolute values
* of all coefficients is a more accurate representation of the predictor */
FLAC__int32 abs_sum_of_qlp_coeff = 0;
- for(uint32_t i = 0; i < order; i++)
+ uint32_t i;
+ for(i = 0; i < order; i++)
abs_sum_of_qlp_coeff += abs(qlp_coeff[i]);
if(abs_sum_of_qlp_coeff == 0)
abs_sum_of_qlp_coeff = 1;
#include "FLAC/assert.h"
-FLAC__FAST_MATH_TARGET("fma")
+FLAC__SSE_TARGET("fma")
void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_8(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[])
{
#undef MAX_LAG
#include "deduplication/lpc_compute_autocorrelation_intrin.c"
}
-FLAC__FAST_MATH_TARGET("fma")
+FLAC__SSE_TARGET("fma")
void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_12(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[])
{
#undef MAX_LAG
#define MAX_LAG 12
#include "deduplication/lpc_compute_autocorrelation_intrin.c"
}
-FLAC__FAST_MATH_TARGET("fma")
+FLAC__SSE_TARGET("fma")
void FLAC__lpc_compute_autocorrelation_intrin_fma_lag_16(const FLAC__real data[], uint32_t data_len, uint32_t lag, double autoc[])
{
#undef MAX_LAG
if (new_num_comments == 0)
return true;
else {
+ uint32_t i;
if ((object->data.vorbis_comment.comments = vorbiscomment_entry_array_new_(new_num_comments)) == NULL)
return false;
- for (uint32_t i = 0; i < new_num_comments; i++) {
+ for (i = 0; i < new_num_comments; i++) {
object->data.vorbis_comment.comments[i].length = 0;
if ((object->data.vorbis_comment.comments[i].entry = safe_malloc_(1)) == NULL) {
object->data.vorbis_comment.num_comments = i+1;
/* if growing, zero all the length/pointers of new elements */
if (new_size > old_size) {
- for (uint32_t i = object->data.vorbis_comment.num_comments; i < new_num_comments; i++) {
+ uint32_t i;
+ for (i = object->data.vorbis_comment.num_comments; i < new_num_comments; i++) {
object->data.vorbis_comment.comments[i].length = 0;
if ((object->data.vorbis_comment.comments[i].entry = safe_malloc_(1)) == NULL) {
object->data.vorbis_comment.num_comments = i+1;
/* SSE intrinsics support by ICC/MSVC/GCC */
#if defined __INTEL_COMPILER
#define FLAC__SSE_TARGET(x)
- #define FLAC__FAST_MATH_TARGET(x)
#define FLAC__SSE_SUPPORTED 1
#define FLAC__SSE2_SUPPORTED 1
#if (__INTEL_COMPILER >= 1000) /* Intel C++ Compiler 10.0 */
#endif
#elif defined __clang__ && __has_attribute(__target__) /* clang */
#define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x)))
- #define FLAC__FAST_MATH_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
+ #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
- #if __has_builtin(__builtin_ia32_maxps256)
- #define FLAC__AVX_SUPPORTED 1
- #endif
- #if __has_builtin(__builtin_ia32_pabsd256)
- #define FLAC__AVX2_SUPPORTED 1
- #endif
- #if __has_builtin(__builtin_ia32_vfmaddps)
- #define FLAC__FMA_SUPPORTED 1
- #endif
+ #define FLAC__AVX_SUPPORTED 1
+ #define FLAC__AVX2_SUPPORTED 1
+ #define FLAC__FMA_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__FAST_MATH_TARGET(x) __attribute__ ((__target__ (x), optimize("-ffast-math")))
#define FLAC__SSE_SUPPORTED 1
#define FLAC__SSE2_SUPPORTED 1
#define FLAC__SSSE3_SUPPORTED 1
#endif
#elif defined _MSC_VER
#define FLAC__SSE_TARGET(x)
- #define FLAC__FAST_MATH_TARGET(x)
#define FLAC__SSE_SUPPORTED 1
#define FLAC__SSE2_SUPPORTED 1
#if (_MSC_VER >= 1500) /* MS Visual Studio 2008 */
#endif
#else
#define FLAC__SSE_TARGET(x)
- #define FLAC__FAST_MATH_TARGET(x)
#ifdef __SSE__
#define FLAC__SSE_SUPPORTED 1
#endif
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
-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
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]);
void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_neon(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__CPU_IA32
-# ifdef FLAC__HAS_NASM
-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) && FLAC__HAS_X86INTRIN
# ifdef FLAC__SSE2_SUPPORTED
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[]);
decoder->private_->samples_decoded = 0;
decoder->private_->do_md5_checking = false;
decoder->private_->last_seen_framesync = 0;
+ decoder->private_->last_frame_is_set = false;
#if FLAC__HAS_OGG
if(decoder->private_->is_ogg)
/* decode the subframe */
if(do_full_decode) {
if(bps < 33){
- for(uint32_t i = 0; i < order; i++)
+ uint32_t i;
+ for(i = 0; i < order; i++)
decoder->private_->output[channel][i] = subframe->warmup[i];
if(bps+order <= 32)
FLAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order);
/* decode the subframe */
if(do_full_decode) {
if(bps <= 32) {
- for(uint32_t i = 0; i < order; i++)
+ uint32_t i;
+ for(i = 0; i < order; i++)
decoder->private_->output[channel][i] = subframe->warmup[i];
if(FLAC__lpc_max_residual_bps(bps, subframe->qlp_coeff, order, subframe->quantization_level) <= 32 &&
FLAC__lpc_max_prediction_before_shift_bps(bps, subframe->qlp_coeff, order) <= 32)
__attribute__((no_sanitize("signed-integer-overflow")))
#endif
void undo_channel_coding(FLAC__StreamDecoder *decoder) {
+ uint32_t i;
switch(decoder->private_->frame.header.channel_assignment) {
case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
/* do nothing */
case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32));
- for(uint32_t i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
if(decoder->private_->side_subframe_in_use)
decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->side_subframe[i];
else
case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32));
- for(uint32_t i = 0; i < decoder->private_->frame.header.blocksize; i++)
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
if(decoder->private_->side_subframe_in_use)
decoder->private_->output[0][i] = decoder->private_->output[1][i] + decoder->private_->side_subframe[i];
else
case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
FLAC__ASSERT(decoder->private_->side_subframe_in_use != /* logical XOR */ (decoder->private_->frame.header.bits_per_sample < 32));
- for(uint32_t i = 0; i < decoder->private_->frame.header.blocksize; i++) {
+ for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
if(!decoder->private_->side_subframe_in_use){
FLAC__int32 mid, side;
mid = decoder->private_->output[0][i];
if(encoder->private_->cpuinfo.use_asm) {
# ifdef FLAC__CPU_IA32
FLAC__ASSERT(encoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
-# ifdef FLAC__HAS_NASM
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide_asm_ia32; /* OPT_IA32: was really necessary for GCC < 4.9 */
- if (encoder->private_->cpuinfo.x86.mmx) {
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx;
- }
- else {
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- }
-
- if (encoder->private_->cpuinfo.x86.mmx && encoder->private_->cpuinfo.x86.cmov)
- encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov;
-# endif /* FLAC__HAS_NASM */
# if FLAC__HAS_X86INTRIN
# ifdef FLAC__SSE2_SUPPORTED
if (encoder->private_->cpuinfo.x86.sse2) {
if(encoder->protected_->state == FLAC__STREAM_ENCODER_OK && !encoder->private_->is_being_deleted) {
if(encoder->private_->current_sample_number != 0) {
encoder->protected_->blocksize = encoder->private_->current_sample_number;
+ if(!resize_buffers_(encoder, encoder->protected_->blocksize)) {
+ /* the above function sets the state for us in case of an error */
+ return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
+ }
if(!process_frame_(encoder, /*is_last_block=*/true))
error = true;
}
FLAC__ASSERT(new_blocksize > 0);
FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
- FLAC__ASSERT(encoder->private_->current_sample_number == 0);
-
- /* To avoid excessive malloc'ing, we only grow the buffer; no shrinking. */
- if(new_blocksize <= encoder->private_->input_capacity)
- return true;
ok = true;
- /* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx() and ..._intrin_sse2()
- * require that the input arrays (in our case the integer signals)
- * have a buffer of up to 3 zeroes in front (at negative indices) for
- * alignment purposes; we use 4 in front to keep the data well-aligned.
- */
+ /* To avoid excessive malloc'ing, we only grow the buffer; no shrinking. */
+ if(new_blocksize > encoder->private_->input_capacity) {
+
+ /* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx() and ..._intrin_sse2()
+ * require that the input arrays (in our case the integer signals)
+ * have a buffer of up to 3 zeroes in front (at negative indices) for
+ * alignment purposes; we use 4 in front to keep the data well-aligned.
+ */
- for(i = 0; ok && i < encoder->protected_->channels; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]);
- if(ok) {
- memset(encoder->private_->integer_signal[i], 0, sizeof(FLAC__int32)*4);
- encoder->private_->integer_signal[i] += 4;
+ for(i = 0; ok && i < encoder->protected_->channels; i++) {
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]);
+ if(ok) {
+ memset(encoder->private_->integer_signal[i], 0, sizeof(FLAC__int32)*4);
+ encoder->private_->integer_signal[i] += 4;
+ }
}
- }
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_mid_side_unaligned[i], &encoder->private_->integer_signal_mid_side[i]);
- if(ok) {
- memset(encoder->private_->integer_signal_mid_side[i], 0, sizeof(FLAC__int32)*4);
- encoder->private_->integer_signal_mid_side[i] += 4;
+ for(i = 0; ok && i < 2; i++) {
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_mid_side_unaligned[i], &encoder->private_->integer_signal_mid_side[i]);
+ if(ok) {
+ memset(encoder->private_->integer_signal_mid_side[i], 0, sizeof(FLAC__int32)*4);
+ encoder->private_->integer_signal_mid_side[i] += 4;
+ }
}
- }
- ok = ok && FLAC__memory_alloc_aligned_int64_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_33bit_side_unaligned, &encoder->private_->integer_signal_33bit_side);
+ ok = ok && FLAC__memory_alloc_aligned_int64_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_33bit_side_unaligned, &encoder->private_->integer_signal_33bit_side);
#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(ok && encoder->protected_->max_lpc_order > 0) {
- for(i = 0; ok && i < encoder->protected_->num_apodizations; i++)
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->window_unaligned[i], &encoder->private_->window[i]);
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->windowed_signal_unaligned, &encoder->private_->windowed_signal);
- }
+ if(ok && encoder->protected_->max_lpc_order > 0) {
+ for(i = 0; ok && i < encoder->protected_->num_apodizations; i++)
+ ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->window_unaligned[i], &encoder->private_->window[i]);
+ ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->windowed_signal_unaligned, &encoder->private_->windowed_signal);
+ }
#endif
- for(channel = 0; ok && channel < encoder->protected_->channels; channel++) {
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_unaligned[channel][i], &encoder->private_->residual_workspace[channel][i]);
+ for(channel = 0; ok && channel < encoder->protected_->channels; channel++) {
+ for(i = 0; ok && i < 2; i++) {
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_unaligned[channel][i], &encoder->private_->residual_workspace[channel][i]);
+ }
}
- }
- for(channel = 0; ok && channel < encoder->protected_->channels; channel++) {
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace[channel][i], encoder->protected_->max_residual_partition_order);
- ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace[channel][i], encoder->protected_->max_residual_partition_order);
+ for(channel = 0; ok && channel < encoder->protected_->channels; channel++) {
+ for(i = 0; ok && i < 2; i++) {
+ ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace[channel][i], encoder->protected_->max_residual_partition_order);
+ ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace[channel][i], encoder->protected_->max_residual_partition_order);
+ }
}
- }
- for(channel = 0; ok && channel < 2; channel++) {
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_mid_side_unaligned[channel][i], &encoder->private_->residual_workspace_mid_side[channel][i]);
+ for(channel = 0; ok && channel < 2; channel++) {
+ for(i = 0; ok && i < 2; i++) {
+ ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_mid_side_unaligned[channel][i], &encoder->private_->residual_workspace_mid_side[channel][i]);
+ }
+ }
+
+ for(channel = 0; ok && channel < 2; channel++) {
+ for(i = 0; ok && i < 2; i++) {
+ ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace_mid_side[channel][i], encoder->protected_->max_residual_partition_order);
+ }
}
- }
- for(channel = 0; ok && channel < 2; channel++) {
for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_workspace_mid_side[channel][i], encoder->protected_->max_residual_partition_order);
+ ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_extra[i], encoder->protected_->max_residual_partition_order);
}
- }
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(&encoder->private_->partitioned_rice_contents_extra[i], encoder->protected_->max_residual_partition_order);
- }
+ /* the *2 is an approximation to the series 1 + 1/2 + 1/4 + ... that sums tree occupies in a flat array */
+ /*@@@ new_blocksize*2 is too pessimistic, but to fix, we need smarter logic because a smaller new_blocksize can actually increase the # of partitions; would require moving this out into a separate function, then checking its capacity against the need of the current blocksize&min/max_partition_order (and maybe predictor order) */
+ ok = ok && FLAC__memory_alloc_aligned_uint64_array(new_blocksize * 2, &encoder->private_->abs_residual_partition_sums_unaligned, &encoder->private_->abs_residual_partition_sums);
+ if(encoder->protected_->do_escape_coding)
+ ok = ok && FLAC__memory_alloc_aligned_unsigned_array(new_blocksize * 2, &encoder->private_->raw_bits_per_partition_unaligned, &encoder->private_->raw_bits_per_partition);
+}
+ if(ok)
+ encoder->private_->input_capacity = new_blocksize;
+ else {
+ encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
+ return ok;
+ }
- /* the *2 is an approximation to the series 1 + 1/2 + 1/4 + ... that sums tree occupies in a flat array */
- /*@@@ new_blocksize*2 is too pessimistic, but to fix, we need smarter logic because a smaller new_blocksize can actually increase the # of partitions; would require moving this out into a separate function, then checking its capacity against the need of the current blocksize&min/max_partition_order (and maybe predictor order) */
- ok = ok && FLAC__memory_alloc_aligned_uint64_array(new_blocksize * 2, &encoder->private_->abs_residual_partition_sums_unaligned, &encoder->private_->abs_residual_partition_sums);
- if(encoder->protected_->do_escape_coding)
- ok = ok && FLAC__memory_alloc_aligned_unsigned_array(new_blocksize * 2, &encoder->private_->raw_bits_per_partition_unaligned, &encoder->private_->raw_bits_per_partition);
/* now adjust the windows if the blocksize has changed */
#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(ok && new_blocksize != encoder->private_->input_capacity && encoder->protected_->max_lpc_order > 0) {
- for(i = 0; ok && i < encoder->protected_->num_apodizations; i++) {
+ if(encoder->protected_->max_lpc_order > 0 && new_blocksize > 1) {
+ for(i = 0; i < encoder->protected_->num_apodizations; i++) {
switch(encoder->protected_->apodizations[i].type) {
case FLAC__APODIZATION_BARTLETT:
FLAC__window_bartlett(encoder->private_->window[i], new_blocksize);
}
}
}
+ if (new_blocksize <= FLAC__MAX_LPC_ORDER) {
+ /* intrinsics autocorrelation routines do not all handle cases in which lag might be
+ * larger than data_len. Lag is one larger than the LPC order */
+ encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation;
+ }
#endif
- if(ok)
- encoder->private_->input_capacity = new_blocksize;
- else
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
-
- return ok;
+ return true;
}
FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC__bool is_last_block)
FLAC__lpc_window_data_wide(integer_signal, encoder->private_->window[a], encoder->private_->windowed_signal, frame_header->blocksize);
encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, frame_header->blocksize, max_lpc_order_this_apodization+1, autoc);
if(encoder->protected_->apodizations[a].type == FLAC__APODIZATION_SUBDIVIDE_TUKEY){
- for(uint32_t i = 0; i < max_lpc_order_this_apodization; i++)
+ uint32_t i;
+ for(i = 0; i < max_lpc_order_this_apodization; i++)
autoc_root[i] = autoc[i];
b++;
}else{
}
else {
/* window part of subblock */
- if(max_lpc_order_this_apodization >= frame_header->blocksize/b) {
- max_lpc_order_this_apodization = frame_header->blocksize/b - 1;
- if(frame_header->blocksize/b > 0)
- max_lpc_order_this_apodization = frame_header->blocksize/b - 1;
- else {
- set_next_subdivide_tukey(encoder->protected_->apodizations[a].parameters.subdivide_tukey.parts, &a, &b, &c);
- continue;
- }
+ if(frame_header->blocksize/b <= FLAC__MAX_LPC_ORDER) {
+ /* intrinsics autocorrelation routines do not all handle cases in which lag might be
+ * larger than data_len, and some routines round lag up to the nearest multiple of 4
+ * As little gain is expected from using LPC on part of a signal as small as 32 samples
+ * and to enable widening this rounding up to larger values in the future, windowing
+ * parts smaller than or equal to FLAC__MAX_LPC_ORDER (which is 32) samples is not supported */
+ set_next_subdivide_tukey(encoder->protected_->apodizations[a].parameters.subdivide_tukey.parts, &a, &b, &c);
+ continue;
}
if(!(c % 2)){
/* on even c, evaluate the (c/2)th partial window of size blocksize/b */
}else{
/* on uneven c, evaluate the root window (over the whole block) minus the previous partial window
* similar to tukey_punchout apodization but more efficient */
- for(uint32_t i = 0; i < max_lpc_order_this_apodization; i++)
+ uint32_t i;
+ for(i = 0; i < max_lpc_order_this_apodization; i++)
autoc[i] = autoc_root[i] - autoc[i];
}
/* Next function sets a, b and c appropriate for next iteration */