And again (nw)

This commit is contained in:
R. Belmont 2012-03-04 15:25:10 +00:00
parent 9358a319fa
commit 79738a59ed
17 changed files with 78 additions and 133 deletions

View File

@ -281,7 +281,25 @@ $(LIBOBJ)/libjpeg/%.o: $(LIBSRC)/libjpeg/%.c | $(OSPREBUILD)
# libflac library objects
#-------------------------------------------------
FLACOPTS=-DFLAC__NO_ASM -DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
ifeq ($(TARGETOS),macosx)
ifdef BIGENDIAN
ifeq ($(PTR64),1)
ARCHFLAGS = -arch ppc64 -DWORDS_BIGENDIAN=1
else
ARCHFLAGS = -arch ppc -DWORDS_BIGENDIAN=1
endif
else # BIGENDIAN
ifeq ($(PTR64),1)
ARCHFLAGS = -arch x86_64 -DWORDS_BIGENDIAN=0
else
ARCHFLAGS = -m32 -arch i386 -DWORDS_BIGENDIAN=0
endif
endif # BIGENDIAN
else # ifeq ($(TARGETOS),macosx)
ARCHFLAGS = -DWORDS_BIGENDIAN=0
endif # ifeq ($(TARGETOS),macosx)
FLACOPTS=-DFLAC__NO_ASM -DHAVE_INTTYPES_H -DHAVE_ICONV -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(ARCHFLAGS)
LIBFLACOBJS = \
$(LIBOBJ)/libflac/bitmath.o \
@ -304,7 +322,7 @@ $(OBJ)/libflac.a: $(LIBFLACOBJS)
$(LIBOBJ)/libflac/%.o: $(LIBSRC)/libflac/libflac/%.c | $(OSPREBUILD)
@echo Compiling $<...
$(CC) $(CDEFS) $(FLACOPTS) $(CCOMFLAGS) $(CONLYFLAGS) -I$(LIBSRC)/libflac/include -c $< -o $@
$(CC) $(CDEFS) $(FLACOPTS) $(CONLYFLAGS) -I$(LIBSRC)/libflac/include -c $< -o $@

View File

@ -19,7 +19,7 @@
#ifndef FLAC__SHARE__ALLOC_H
#define FLAC__SHARE__ALLOC_H
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@ -55,7 +55,6 @@
/* avoid malloc()ing 0 bytes, see:
* https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003
*/
#if 0
static FLaC__INLINE void *safe_malloc_(size_t size)
{
/* malloc(0) is undefined; FLAC src convention is to always allocate */
@ -63,8 +62,7 @@ static FLaC__INLINE void *safe_malloc_(size_t size)
size++;
return malloc(size);
}
#endif
#if 0
static FLaC__INLINE void *safe_calloc_(size_t nmemb, size_t size)
{
if(!nmemb || !size)
@ -106,8 +104,29 @@ static FLaC__INLINE void *safe_malloc_add_4op_(size_t size1, size_t size2, size_
return 0;
return safe_malloc_(size4);
}
#endif
static FLaC__INLINE void *safe_malloc_mul_2op_(size_t size1, size_t size2)
#if 0
needs support for cases where sizeof(size_t) != 4
{
/* could be faster #ifdef'ing off SIZEOF_SIZE_T */
if(sizeof(size_t) == 4) {
if ((double)size1 * (double)size2 < 4294967296.0)
return malloc(size1*size2);
}
return 0;
}
#else
/* better? */
{
if(!size1 || !size2)
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
if(size1 > SIZE_MAX / size2)
return 0;
return malloc(size1*size2);
}
#endif
static FLaC__INLINE void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3)
{
if(!size1 || !size2 || !size3)
@ -119,9 +138,8 @@ static FLaC__INLINE void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_
return 0;
return malloc(size1*size3);
}
#endif
/* size1*size2 + size3 */
#if 0
static FLaC__INLINE void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3)
{
if(!size1 || !size2)
@ -174,8 +192,7 @@ static FLaC__INLINE void *safe_realloc_add_4op_(void *ptr, size_t size1, size_t
return 0;
return realloc(ptr, size4);
}
#endif
#if 0
static FLaC__INLINE void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
{
if(!size1 || !size2)
@ -184,9 +201,8 @@ static FLaC__INLINE void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t
return 0;
return realloc(ptr, size1*size2);
}
#endif
/* size1 * (size2 + size3) */
#if 0
static FLaC__INLINE void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
{
if(!size1 || (!size2 && !size3))
@ -196,5 +212,5 @@ static FLaC__INLINE void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t
return 0;
return safe_realloc_mul_2op_(ptr, size1, size2);
}
#endif
#endif

View File

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

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@ -51,7 +51,7 @@ typedef FLAC__uint32 brword;
#define FLAC__BITS_PER_WORD 32
#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff)
/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */
#ifndef LSB_FIRST
#if WORDS_BIGENDIAN
#define SWAP_BE_WORD_TO_HOST(x) (x)
#else
#ifdef _MSC_VER
@ -143,7 +143,7 @@ struct FLAC__BitReader {
};
#ifdef LSB_FIRST
#if !WORDS_BIGENDIAN
static FLAC__uint32 local_swap32_(FLAC__uint32 x)
{
x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
@ -234,7 +234,7 @@ FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
* on LE machines, have to byteswap the odd tail word so nothing is
* overwritten:
*/
#ifndef LSB_FIRST
#if WORDS_BIGENDIAN
#else
if(br->bytes)
br->buffer[br->words] = SWAP_BE_WORD_TO_HOST(br->buffer[br->words]);
@ -257,7 +257,7 @@ FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
* buffer[LE]: 44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ??
* now have to byteswap on LE machines:
*/
#ifndef LSB_FIRST
#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) && defined(_M_IX86)

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@ -54,7 +54,7 @@ typedef FLAC__uint32 bwword;
#define FLAC__BITS_PER_WORD 32
#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff)
/* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */
#ifndef LSB_FIRST
#if WORDS_BIGENDIAN
#define SWAP_BE_WORD_TO_HOST(x) (x)
#else
#ifdef _MSC_VER
@ -64,15 +64,6 @@ typedef FLAC__uint32 bwword;
#endif
#endif
static FLaC__INLINE void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
{
if(!size1 || !size2)
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
if(size1 > SIZE_MAX / size2)
return 0;
return realloc(ptr, size1*size2);
}
/*
* 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
@ -112,7 +103,7 @@ struct FLAC__BitWriter {
/* OPT: an MSVC built-in would be better */
#ifdef LSB_FIRST
#if !WORDS_BIGENDIAN
static FLAC__uint32 local_swap32_(FLAC__uint32 x)
{
x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@ -112,7 +112,7 @@ 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[])
{
unsigned i, j;
FLAC__double r, err, lpc[FLAC__MAX_LPC_ORDER];
FLAC__double r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER];
FLAC__ASSERT(0 != max_order);
FLAC__ASSERT(0 < *max_order);
@ -126,7 +126,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);
ref[i] = (r/=err);
/* Update LPC coefficients and total error. */
lpc[i]=r;

View File

@ -1,4 +1,4 @@
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@ -137,7 +137,7 @@ static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
buf[3] += d;
}
#ifndef LSB_FIRST
#if WORDS_BIGENDIAN
//@@@@@@ OPT: use bswap/intrinsics
static void byteSwap(FLAC__uint32 *buf, unsigned words)
{
@ -280,7 +280,7 @@ static void format_input_(FLAC__byte *buf, const FLAC__int32 * const signal[], u
register FLAC__int32 a_word;
register FLAC__byte *buf_ = buf;
#ifndef LSB_FIRST
#if WORDS_BIGENDIAN
#else
if(channels == 2 && bytes_per_sample == 2) {
FLAC__int16 *buf1_ = ((FLAC__int16*)buf_) + 1;
@ -395,14 +395,6 @@ static void format_input_(FLAC__byte *buf, const FLAC__int32 * const signal[], u
/*
* Convert the incoming audio signal to a byte stream and FLAC__MD5Update it.
*/
static FLaC__INLINE void *safe_malloc_(size_t size)
{
/* malloc(0) is undefined; FLAC src convention is to always allocate */
if(!size)
size++;
return malloc(size);
}
FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
{
const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample;

View File

@ -29,7 +29,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
@ -37,14 +37,6 @@
#include "flac/assert.h"
#include "share/alloc.h"
static FLaC__INLINE void *safe_malloc_(size_t size)
{
/* malloc(0) is undefined; FLAC src convention is to always allocate */
if(!size)
size++;
return malloc(size);
}
void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
{
void *x;
@ -92,7 +84,7 @@ FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if(elements > (unsigned)(SIZE_MAX / sizeof(*pu))) /* overflow check */
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * (size_t)elements, &u.pv);
@ -121,7 +113,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(elements > (unsigned)(SIZE_MAX / sizeof(*pu))) /* overflow check */
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
@ -150,7 +142,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(elements > (unsigned)(SIZE_MAX / sizeof(*pu))) /* overflow check */
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
@ -179,7 +171,7 @@ FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned
FLAC__ASSERT(0 != aligned_pointer);
FLAC__ASSERT(unaligned_pointer != aligned_pointer);
if(elements > (unsigned)(SIZE_MAX / sizeof(*pu))) /* overflow check */
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
@ -210,7 +202,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(elements > (unsigned)(SIZE_MAX / sizeof(*pu))) /* overflow check */
if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
return false;
pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);

View File

@ -29,12 +29,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#define FLAC__HAS_OGG 0
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for memset/memcpy() */
@ -81,56 +79,6 @@ FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC =
#endif
;
static FLaC__INLINE void *safe_malloc_(size_t size)
{
/* malloc(0) is undefined; FLAC src convention is to always allocate */
if(!size)
size++;
return malloc(size);
}
static FLaC__INLINE void *safe_calloc_(size_t nmemb, size_t size)
{
if(!nmemb || !size)
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
return calloc(nmemb, size);
}
static FLaC__INLINE void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
{
if(!size1 || !size2)
return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
if(size1 > SIZE_MAX / size2)
return 0;
return realloc(ptr, size1*size2);
}
static FLaC__INLINE void *safe_malloc_add_2op_(size_t size1, size_t size2)
{
size2 += size1;
if(size2 < size1)
return 0;
return safe_malloc_(size2);
}
static FLaC__INLINE void *safe_malloc_mul_2op_(size_t size1, size_t size2)
{
if(!size1 || !size2)
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
if(size1 > SIZE_MAX / size2)
return 0;
return malloc(size1*size2);
}
static FLaC__INLINE void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
{
if(!size1 || (!size2 && !size3))
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
size2 += size3;
if(size2 < size3)
return 0;
return safe_malloc_mul_2op_(size1, size2);
}
/***********************************************************************
*

View File

@ -29,12 +29,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#define FLAC__HAS_OGG 0
#include <limits.h>
#include <stdio.h>
#include <stdlib.h> /* for malloc() */
@ -92,14 +90,6 @@
*/
#undef ENABLE_RICE_PARAMETER_SEARCH
static FLaC__INLINE void *safe_malloc_mul_2op_(size_t size1, size_t size2)
{
if(!size1 || !size2)
return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
if(size1 > SIZE_MAX / size2)
return 0;
return malloc(size1*size2);
}
typedef struct {
FLAC__int32 *data[FLAC__MAX_CHANNELS];

View File

@ -29,12 +29,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#define FLAC__HAS_OGG 0
#include <stdio.h>
#include <string.h> /* for strlen() */
#include "private/stream_encoder_framing.h"

View File

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