Updated flac so it can compile, applied changes from previous source (nw)

This commit is contained in:
Miodrag Milanovic 2015-01-10 19:14:57 +01:00
parent fa3f99377c
commit 4663084cfa
24 changed files with 77 additions and 57 deletions

View File

@ -19,7 +19,7 @@
#ifndef FLAC__SHARE__ALLOC_H
#define FLAC__SHARE__ALLOC_H
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -156,6 +156,8 @@ static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x)
x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
return (x>>16) | (x<<16);
}
#if defined(_M_IX86)
static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len)
{
__asm {
@ -174,6 +176,7 @@ done1:
}
}
#endif
#endif
static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, brword word)
{
@ -263,7 +266,7 @@ 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;
# if defined(_MSC_VER) && (FLAC__BYTES_PER_WORD == 4)
# if defined(_MSC_VER) && (FLAC__BYTES_PER_WORD == 4) && defined(_M_IX86)
if(br->cpu_info.type == FLAC__CPUINFO_TYPE_IA32 && br->cpu_info.data.ia32.bswap) {
start = br->words;
local_swap32_block_(br->buffer + start, end - start);

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -86,6 +86,7 @@ static void sigill_handler (int sig)
/* how to get sysctlbyname()? */
#endif
#if defined(FLAC__CPU_IA32) && !defined(FLAC__NO_ASM) && defined (FLAC__HAS_NASM)
/* 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;
@ -95,10 +96,13 @@ static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000;
/* these are flags in ECX of CPUID AX=00000001 */
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001;
static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200;
#ifdef FLAC__USE_3DNOW
/* these are flags in EDX of CPUID AX=80000001 */
static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW = 0x80000000;
static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW = 0x40000000;
static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX = 0x00400000;
#endif
#endif
/*

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -581,11 +581,11 @@ FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_s
FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits));
if(object->capacity_by_order < max_partition_order) {
if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned)*(1 << max_partition_order))))
if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned)*((unsigned long long)1 << max_partition_order))))
return false;
if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order))))
if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned)*((unsigned long long)1 << max_partition_order))))
return false;
memset(object->raw_bits, 0, sizeof(unsigned)*(1 << max_partition_order));
memset(object->raw_bits, 0, sizeof(unsigned)*((unsigned long long)1 << max_partition_order));
object->capacity_by_order = max_partition_order;
}

View File

@ -45,12 +45,12 @@
* Use free() on this address to deallocate.
*/
void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address);
FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer);
FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer);
FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer);
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer);
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);
#ifndef FLAC__INTEGER_ONLY_LIBRARY
FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer);
FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer);
#endif
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -60,6 +60,9 @@ void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FL
out[i] = in[i] * window[i];
}
#if defined(__GNUC__) && defined(__i386__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
__attribute__((optimize("O0")))
#endif
void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[])
{
/* a readable, but slower, version */
@ -88,7 +91,7 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
* this version tends to run faster because of better data locality
* ('data_len' is usually much larger than 'lag')
*/
FLAC__real d;
FLAC__real d, tmp;
unsigned sample, coeff;
const unsigned limit = data_len - lag;
@ -99,20 +102,24 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le
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(coeff = 0; coeff < lag; coeff++) {
tmp = d * data[sample+coeff];
autoc[coeff] += tmp;
}
}
for(; sample < data_len; sample++) {
d = data[sample];
for(coeff = 0; coeff < data_len - sample; coeff++)
autoc[coeff] += d * data[sample+coeff];
for(coeff = 0; coeff < data_len - sample; coeff++) {
tmp = d * data[sample+coeff];
autoc[coeff] += tmp;
}
}
}
void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[])
{
unsigned i, j;
FLAC__double r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER];
FLAC__double r, err, lpc[FLAC__MAX_LPC_ORDER];
FLAC__ASSERT(0 != max_order);
FLAC__ASSERT(0 < *max_order);
@ -126,7 +133,7 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_o
r = -autoc[i+1];
for(j = 0; j < i; j++)
r -= lpc[j] * autoc[i-j];
ref[i] = (r/=err);
r/=err;
/* Update LPC coefficients and total error. */
lpc[i]=r;

View File

@ -1,4 +1,4 @@
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -263,12 +263,12 @@ void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
byteSwap(ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
if(0 != ctx->internal_buf) {
free(ctx->internal_buf);
ctx->internal_buf = 0;
ctx->capacity = 0;
}
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
/*

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -71,7 +71,7 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
return x;
}
FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer)
FLAC__bool FLAC__memory_alloc_aligned_int32_array(size_t elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer)
{
FLAC__int32 *pu; /* unaligned pointer */
union { /* union needed to comply with C99 pointer aliasing rules */
@ -84,10 +84,10 @@ FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * (size_t)elements, &u.pv);
pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
if(0 == pu) {
return false;
}
@ -100,7 +100,8 @@ FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32
}
}
FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer)
FLAC__bool FLAC__memory_alloc_aligned_uint32_array(size_t elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer)
{
FLAC__uint32 *pu; /* unaligned pointer */
union { /* union needed to comply with C99 pointer aliasing rules */
@ -113,7 +114,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
@ -129,7 +130,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint
}
}
FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer)
FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer)
{
FLAC__uint64 *pu; /* unaligned pointer */
union { /* union needed to comply with C99 pointer aliasing rules */
@ -142,7 +143,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
@ -158,7 +159,7 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint
}
}
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer)
FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer)
{
unsigned *pu; /* unaligned pointer */
union { /* union needed to comply with C99 pointer aliasing rules */
@ -171,7 +172,7 @@ FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
@ -189,7 +190,7 @@ FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned
#ifndef FLAC__INTEGER_ONLY_LIBRARY
FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer)
FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer)
{
FLAC__real *pu; /* unaligned pointer */
union { /* union needed to comply with C99 pointer aliasing rules */
@ -202,7 +203,7 @@ FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real *
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
if(elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -46,9 +46,11 @@
#include <string.h> /* for memset/memcpy() */
#include <sys/stat.h> /* for stat() */
#include <sys/types.h> /* for off_t */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
@ -1467,6 +1469,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
block.is_last = is_last;
block.type = (FLAC__MetadataType)type;
block.length = length;
memset(&block.data, 0, sizeof(block.data));
if(type == FLAC__METADATA_TYPE_APPLICATION) {
if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8))

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@ -46,9 +46,11 @@
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memcpy() */
#include <sys/types.h> /* for off_t */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
#if _MSC_VER <= 1600 || defined __BORLANDC__ /* @@@ [2G limit] */
#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ /* @@@ [2G limit] */
#ifndef fseeko
#define fseeko fseek
#endif
#ifndef ftello
#define ftello ftell
#endif
#endif
@ -3750,9 +3752,9 @@ unsigned find_best_partition_order_(
/* save best parameters and raw_bits */
FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(prc, max(6, best_partition_order));
memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(unsigned)*(1<<(best_partition_order)));
memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(unsigned)*((unsigned long long)1<<(best_partition_order)));
if(do_escape_coding)
memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*(1<<(best_partition_order)));
memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*((unsigned long long)1<<(best_partition_order)));
/*
* Now need to check if the type should be changed to
* FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -399,7 +399,7 @@ $(OBJ)/libflac.a: $(LIBFLACOBJS)
$(LIBOBJ)/libflac/%.o: $(3RDPARTY)/libflac/src/libFLAC/%.c | $(OSPREBUILD)
@echo Compiling $<...
$(CC) $(CDEFS) $(CONLYFLAGS) $(CCOMFLAGS) $(FLACOPTS) -I$(LIBSRC)/libflac/include -I$(LIBSRC)/libflac/libFLAC/include -c $< -o $@
$(CC) $(CDEFS) $(CONLYFLAGS) $(CCOMFLAGS) $(FLACOPTS) -I$(3RDPARTY)/libflac/include -I$(3RDPARTY)/libflac/src/libFLAC/include -c $< -o $@