Update and improve autotools build

- INCLUDES is deprecated, and CPPFLAGS is an user-defined
  variable, use the proper AM_CPPFLAGS instead

- Remove FLAC__INLINE definition, providing proper
  replacement for MSVC compilers.

- Detect if we have C99 's lround and provide a replacement
  for windows...
This commit is contained in:
Cristian Rodríguez
2012-04-07 19:24:21 -03:00
committed by Erik de Castro Lopo
parent 8340ab3bc8
commit 9b7cb22f84
30 changed files with 68 additions and 86 deletions

View File

@@ -28,6 +28,7 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
lib_LTLIBRARIES = libFLAC.la
if DEBUG
DEBUGCFLAGS = -DFLAC__OVERFLOW_DETECT
@@ -77,7 +78,7 @@ endif
endif
endif
libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@
libFLAC_la_LIBADD = $(LOCAL_EXTRA_LIBADD) @OGG_LIBS@ -lm
SUBDIRS = $(ARCH_SUBDIRS) include .
@@ -104,7 +105,7 @@ extra_ogg_sources = \
ogg_mapping.c
endif
# see 'http://www.gnu.org/software/libtool/manual.html#Libtool-versioning' for numbering convention
libFLAC_la_LDFLAGS = -version-info 10:0:2 -lm $(LOCAL_EXTRA_LDFLAGS) @LT_NO_UNDEFINED@
libFLAC_la_LDFLAGS = -version-info 10:0:2 $(LOCAL_EXTRA_LDFLAGS) @LT_NO_UNDEFINED@
libFLAC_la_SOURCES = \
bitmath.c \
bitreader.c \

View File

@@ -117,10 +117,6 @@ static const unsigned char byte_to_unary_table[] = {
#define FLAC__U64L(x) x##LLU
#endif
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
/* WATCHOUT: assembly routines rely on the order in which these fields are declared */
struct FLAC__BitReader {
/* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */
@@ -138,7 +134,7 @@ struct FLAC__BitReader {
FLAC__CPUInfo cpu_info;
};
static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, uint32_t word)
static inline void crc16_update_word_(FLAC__BitReader *br, uint32_t word)
{
register unsigned crc = br->read_crc16;
#if FLAC__BYTES_PER_WORD == 4
@@ -373,17 +369,17 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br)
return br->read_crc16;
}
FLaC__INLINE FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br)
inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br)
{
return ((br->consumed_bits & 7) == 0);
}
FLaC__INLINE unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
inline unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
{
return 8 - (br->consumed_bits & 7);
}
FLaC__INLINE unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br)
inline unsigned 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;
}
@@ -499,7 +495,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *va
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val)
inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val)
{
FLAC__uint32 x8, x32 = 0;

View File

@@ -75,10 +75,6 @@ static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(uint32_
#define FLAC__U64L(x) x##LLU
#endif
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
struct FLAC__BitWriter {
uint32_t *buffer;
uint32_t accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */
@@ -270,7 +266,7 @@ void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw)
(void)bw;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits)
{
unsigned n;
@@ -308,7 +304,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsign
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits)
{
register unsigned left;
@@ -347,7 +343,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FL
return true;
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits)
inline FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits)
{
/* zero-out unused bits */
if(bits < 32)
@@ -356,7 +352,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLA
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
}
FLaC__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, unsigned bits)
{
/* this could be a little faster but it's not used for much */
if(bits > 32) {
@@ -368,7 +364,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FL
return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
}
FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val)
inline FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val)
{
/* this doesn't need to be that fast as currently it is only used for vorbis comments */
@@ -384,7 +380,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__Bit
return true;
}
FLaC__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[], unsigned nvals)
{
unsigned i;

View File

@@ -31,7 +31,7 @@
SUFFIXES = .nasm .lo
STRIP_NON_ASM = sh $(top_srcdir)/strip_non_asm_libtool_args.sh
AM_CPPFLAGS = -I$(top_builddir) -I$(srcdir)/include -I$(top_srcdir)/include
.nasm.lo:
$(LIBTOOL) --tag=CC --mode=compile $(STRIP_NON_ASM) $(NASM) -f $(OBJ_FORMAT) -d OBJ_FORMAT_$(OBJ_FORMAT) -i$(srcdir)/ $< -o $@

View File

@@ -57,4 +57,10 @@
#define flac_min(a,b) __min(a,b)
#endif
#if !defined(__cplusplus) && defined(_MSC_VER)
#ifndef inline
#define inline __inline
#endif
#endif
#endif

View File

@@ -38,6 +38,7 @@
#include "FLAC/format.h"
#include "private/bitmath.h"
#include "private/lpc.h"
#include "private/macros.h"
#if defined DEBUG || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE
#include <stdio.h>
#endif
@@ -52,6 +53,18 @@
#define M_LN2 0.69314718055994530942
#endif
#if !defined(HAVE_LROUND)
#if defined(_MSC_VER)
#include <float.h>
#define copysign _copysign
#elif defined(__GNUC__)
#define copysign __builtin_copysign
#endif
static inline long int lround(double x) {
return (long)(x + copysign (0.5, x));
}
//If this fails, we are in the precence 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)
{
@@ -199,14 +212,8 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
FLAC__int32 q;
for(i = 0; i < order; i++) {
error += lp_coeff[i] * (1 << *shift);
#if 1 /* unfortunately lround() is C99 */
if(error >= 0.0)
q = (FLAC__int32)(error + 0.5);
else
q = (FLAC__int32)(error - 0.5);
#else
q = lround(error);
#endif
#ifdef FLAC__OVERFLOW_DETECT
if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);
@@ -234,14 +241,7 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order,
#endif
for(i = 0; i < order; i++) {
error += lp_coeff[i] / (1 << nshift);
#if 1 /* unfortunately lround() is C99 */
if(error >= 0.0)
q = (FLAC__int32)(error + 0.5);
else
q = (FLAC__int32)(error - 0.5);
#else
q = lround(error);
#endif
#ifdef FLAC__OVERFLOW_DETECT
if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);

View File

@@ -68,9 +68,6 @@
#include "private/stream_encoder_framing.h"
#include "private/window.h"
#ifndef FLaC__INLINE
#define FLaC__INLINE
#endif
/* Exact Rice codeword length calculation is off by default. The simple
* (and fast) estimation (of how many bits a residual value will be
@@ -3886,7 +3883,7 @@ void precompute_partition_info_escapes_(
}
#ifdef EXACT_RICE_BITS_CALCULATION
static FLaC__INLINE unsigned count_rice_bits_in_partition_(
static inline unsigned count_rice_bits_in_partition_(
const unsigned rice_parameter,
const unsigned partition_samples,
const FLAC__int32 *residual
@@ -3901,7 +3898,7 @@ static FLaC__INLINE unsigned count_rice_bits_in_partition_(
return partition_bits;
}
#else
static FLaC__INLINE unsigned count_rice_bits_in_partition_(
static inline unsigned count_rice_bits_in_partition_(
const unsigned rice_parameter,
const unsigned partition_samples,
const FLAC__uint64 abs_residual_partition_sum