From f0296255918f6665fe9910874df2fd39ca039f30 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cristian=20Rodr=C3=ADguez?= Date: Thu, 5 Apr 2012 19:39:37 -0300 Subject: [PATCH] V2: Use a single definition of MIN and MAX in sources --- configure.ac | 7 ++++++ src/libFLAC/bitreader.c | 12 ++------- src/libFLAC/bitwriter.c | 8 ++---- src/libFLAC/fixed.c | 18 ++++++------- src/libFLAC/format.c | 8 ++---- src/libFLAC/include/private/macros.h | 29 +++++++++++++++++++++ src/libFLAC/metadata_iterators.c | 17 +++---------- src/libFLAC/ogg_decoder_aspect.c | 7 ++---- src/libFLAC/stream_decoder.c | 8 ++---- src/libFLAC/stream_encoder.c | 49 +++++++++++++++--------------------- src/libFLAC/stream_encoder_framing.c | 5 ---- 11 files changed, 77 insertions(+), 91 deletions(-) create mode 100644 src/libFLAC/include/private/macros.h diff --git a/configure.ac b/configure.ac index d2501bb..7627fb7 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,10 @@ AC_INIT(src/flac/main.c) AM_INIT_AUTOMAKE(flac, 1.2.1) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +#Prefer whatever the current ISO standard is. +AC_PROG_CC_STDC +AC_USE_SYSTEM_EXTENSIONS # Enable the generation of shared libraries under Win32 AC_LIBTOOL_WIN32_DLL @@ -60,6 +64,7 @@ AC_HEADER_STDC AM_PROG_CC_C_O AC_C_INLINE AC_C_VARARRAYS +AC_C_TYPEOF AC_CHECK_HEADERS(stdint.h) AC_SUBST(HAVE_STDINT_H) @@ -68,6 +73,8 @@ AC_SUBST(HAVE_INTTYPES_H) AC_CHECK_HEADERS(byteswap.h) AC_SUBST(HAVE_BYTESWAP_H) +AC_CHECK_HEADERS([sys/param.h]) + XIPH_C_BSWAP32 XIPH_C_FIND_ENDIAN diff --git a/src/libFLAC/bitreader.c b/src/libFLAC/bitreader.c index cd05a62..7e17fd8 100644 --- a/src/libFLAC/bitreader.c +++ b/src/libFLAC/bitreader.c @@ -38,6 +38,7 @@ #include "private/bitmath.h" #include "private/bitreader.h" #include "private/crc.h" +#include "private/macros.h" #include "FLAC/assert.h" #include "share/endswap.h" @@ -109,15 +110,6 @@ static const unsigned char byte_to_unary_table[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -#ifdef min -#undef min -#endif -#define min(x,y) ((x)<(y)?(x):(y)) -#ifdef max -#undef max -#endif -#define max(x,y) ((x)>(y)?(x):(y)) - /* adjust for compilers that can't understand using LLU suffix for uint64_t literals */ #ifdef _MSC_VER #define FLAC__U64L(x) x @@ -547,7 +539,7 @@ FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits) FLAC__uint32 x; if(n != 0) { - m = min(8-n, bits); + m = flac_min(8-n, bits); if(!FLAC__bitreader_read_raw_uint32(br, &x, m)) return false; bits -= m; diff --git a/src/libFLAC/bitwriter.c b/src/libFLAC/bitwriter.c index 7da4b15..44914d1 100644 --- a/src/libFLAC/bitwriter.c +++ b/src/libFLAC/bitwriter.c @@ -37,6 +37,7 @@ #include #include "private/bitwriter.h" #include "private/crc.h" +#include "private/macros.h" #include "FLAC/assert.h" #include "share/alloc.h" #include "share/endswap.h" @@ -67,11 +68,6 @@ static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(uint32_ #define FLAC__WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD) #define FLAC__TOTAL_BITS(bw) (FLAC__WORDS_TO_BITS((bw)->words) + (bw)->bits) -#ifdef min -#undef min -#endif -#define min(x,y) ((x)<(y)?(x):(y)) - /* adjust for compilers that can't understand using LLU suffix for uint64_t literals */ #ifdef _MSC_VER #define FLAC__U64L(x) x @@ -288,7 +284,7 @@ FLaC__INLINE FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsign return false; /* first part gets to word alignment */ if(bw->bits) { - n = min(FLAC__BITS_PER_WORD - bw->bits, bits); + n = flac_min(FLAC__BITS_PER_WORD - bw->bits, bits); bw->accum <<= n; bits -= n; bw->bits += n; diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c index 1a57cf4..05b289a 100644 --- a/src/libFLAC/fixed.c +++ b/src/libFLAC/fixed.c @@ -37,6 +37,7 @@ #include #include "private/bitmath.h" #include "private/fixed.h" +#include "private/macros.h" #include "FLAC/assert.h" #ifndef M_LN2 @@ -44,11 +45,6 @@ #define M_LN2 0.69314718055994530942 #endif -#ifdef min -#undef min -#endif -#define min(x,y) ((x) < (y)? (x) : (y)) - #ifdef local_abs #undef local_abs #endif @@ -242,11 +238,11 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save; } - if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4)) + if(total_error_0 < flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) order = 0; - else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4)) + else if(total_error_1 < flac_min(flac_min(total_error_2, total_error_3), total_error_4)) order = 1; - else if(total_error_2 < min(total_error_3, total_error_4)) + else if(total_error_2 < flac_min(total_error_3, total_error_4)) order = 2; else if(total_error_3 < total_error_4) order = 3; @@ -304,11 +300,11 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save; } - if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4)) + if(total_error_0 < flac_min(flac_min(flac_min(total_error_1, total_error_2), total_error_3), total_error_4)) order = 0; - else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4)) + else if(total_error_1 < flac_min(flac_min(total_error_2, total_error_3), total_error_4)) order = 1; - else if(total_error_2 < min(total_error_3, total_error_4)) + else if(total_error_2 < flac_min(total_error_3, total_error_4)) order = 2; else if(total_error_3 < total_error_4) order = 3; diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c index c7454f8..d796547 100644 --- a/src/libFLAC/format.c +++ b/src/libFLAC/format.c @@ -39,11 +39,7 @@ #include "FLAC/assert.h" #include "FLAC/format.h" #include "private/format.h" - -#ifdef min -#undef min -#endif -#define min(a,b) ((a)<(b)?(a):(b)) +#include "private/macros.h" /* adjust for compilers that can't understand using LLU suffix for uint64_t literals */ #ifdef _MSC_VER @@ -542,7 +538,7 @@ unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned block max_rice_partition_order++; blocksize >>= 1; } - return min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order); + 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) diff --git a/src/libFLAC/include/private/macros.h b/src/libFLAC/include/private/macros.h new file mode 100644 index 0000000..1718005 --- /dev/null +++ b/src/libFLAC/include/private/macros.h @@ -0,0 +1,29 @@ +#ifndef FLAC__PRIVATE__MACROS_H +#define FLAC__PRIVATE__MACROS_H + +#if defined(__GNUC__) + +#define flac_max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) + +#define flac_min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) + +/* Whatever other unix that has sys/param.h */ +#elif defined(HAVE_SYS_PARAM_H) +#include +#define flac_max(a,b) MAX(a,b) +#define flac_min(a,b) MIN(a,b) + +/* Windows VS has them in stdlib.h.. XXX:Untested */ +#elif defined(_MSC_VER) +#include +#define flac_max(a,b) __max(a,b) +#define flac_min(a,b) __min(a,b) +#endif + +#endif \ No newline at end of file diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index 0ba0d20..4fbe678 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -59,16 +59,7 @@ #include "FLAC/stream_decoder.h" #include "share/alloc.h" #include "share/compat.h" - -#ifdef max -#undef max -#endif -#define max(a,b) ((a)>(b)?(a):(b)) -#ifdef min -#undef min -#endif -#define min(a,b) ((a)<(b)?(a):(b)) - +#include "private/macros.h" /**************************************************************************** * @@ -2634,7 +2625,7 @@ FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, F const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; FLAC__byte buffer[4]; /* magic number is asserted below */ - FLAC__ASSERT(max(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN, FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8 == sizeof(buffer)); + FLAC__ASSERT(flac_max(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN, FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8 == sizeof(buffer)); pack_uint32_little_endian_(block->vendor_string.length, buffer, entry_length_len); if(write_cb(buffer, 1, entry_length_len, handle) != entry_length_len) @@ -3134,7 +3125,7 @@ FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, off_t bytes, FLAC FLAC__ASSERT(bytes >= 0); while(bytes > 0) { - n = min(sizeof(buffer), (size_t)bytes); + n = flac_min(sizeof(buffer), (size_t)bytes); if(fread(buffer, 1, n, file) != n) { *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; return false; @@ -3156,7 +3147,7 @@ FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Re FLAC__ASSERT(bytes >= 0); while(bytes > 0) { - n = min(sizeof(buffer), (size_t)bytes); + n = flac_min(sizeof(buffer), (size_t)bytes); if(read_cb(buffer, 1, n, handle) != n) { *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; return false; diff --git a/src/libFLAC/ogg_decoder_aspect.c b/src/libFLAC/ogg_decoder_aspect.c index 0e8519c..f67fb40 100644 --- a/src/libFLAC/ogg_decoder_aspect.c +++ b/src/libFLAC/ogg_decoder_aspect.c @@ -37,11 +37,8 @@ #include "FLAC/assert.h" #include "private/ogg_decoder_aspect.h" #include "private/ogg_mapping.h" +#include "private/macros.h" -#ifdef max -#undef max -#endif -#define max(x,y) ((x)>(y)?(x):(y)) /*********************************************************************** * @@ -210,7 +207,7 @@ FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper( } else if (ret == 0) { /* need more data */ - const size_t ogg_bytes_to_read = max(bytes_requested - *bytes, OGG_BYTES_CHUNK); + const size_t ogg_bytes_to_read = flac_max(bytes_requested - *bytes, OGG_BYTES_CHUNK); char *oggbuf = ogg_sync_buffer(&aspect->sync_state, ogg_bytes_to_read); if(0 == oggbuf) { diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index 6f96023..5b3c3cd 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -59,11 +59,7 @@ #include "private/lpc.h" #include "private/md5.h" #include "private/memory.h" - -#ifdef max -#undef max -#endif -#define max(a,b) ((a)>(b)?(a):(b)) +#include "private/macros.h" /* adjust for compilers that can't understand using LLU suffix for uint64_t literals */ #ifdef _MSC_VER @@ -2732,7 +2728,7 @@ FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigne } } - if(!FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, max(6, partition_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; return false; } diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index dd36b70..ce0c8da 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -60,6 +60,7 @@ #include "private/lpc.h" #include "private/md5.h" #include "private/memory.h" +#include "private/macros.h" #if FLAC__HAS_OGG #include "private/ogg_helper.h" #include "private/ogg_mapping.h" @@ -71,16 +72,6 @@ #define FLaC__INLINE #endif -#ifdef min -#undef min -#endif -#define min(x,y) ((x)<(y)?(x):(y)) - -#ifdef max -#undef max -#endif -#define max(x,y) ((x)>(y)?(x):(y)) - /* Exact Rice codeword length calculation is off by default. The simple * (and fast) estimation (of how many bits a residual value will be * encoded with) in this encoder is very good, almost always yielding @@ -691,7 +682,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( if(encoder->protected_->bits_per_sample < 16) { /* @@@ need some data about how to set this here w.r.t. blocksize and sample rate */ /* @@@ until then we'll make a guess */ - encoder->protected_->qlp_coeff_precision = max(FLAC__MIN_QLP_COEFF_PRECISION, 2 + encoder->protected_->bits_per_sample / 2); + encoder->protected_->qlp_coeff_precision = flac_max(FLAC__MIN_QLP_COEFF_PRECISION, 2 + encoder->protected_->bits_per_sample / 2); } else if(encoder->protected_->bits_per_sample == 16) { if(encoder->protected_->blocksize <= 192) @@ -880,7 +871,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( encoder->private_->current_frame_number = 0; encoder->private_->use_wide_by_block = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(encoder->protected_->blocksize)+1 > 30); - encoder->private_->use_wide_by_order = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(max(encoder->protected_->max_lpc_order, FLAC__MAX_FIXED_ORDER))+1 > 30); /*@@@ need to use this? */ + encoder->private_->use_wide_by_order = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(flac_max(encoder->protected_->max_lpc_order, FLAC__MAX_FIXED_ORDER))+1 > 30); /*@@@ need to use this? */ encoder->private_->use_wide_by_partition = (false); /*@@@ need to set this */ /* @@ -1971,7 +1962,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, c FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK); do { - const unsigned n = min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j); + const unsigned n = flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j); if(encoder->protected_->verify) append_to_verify_fifo_(&encoder->private_->verify.input_fifo, buffer, j, channels, n); @@ -2034,7 +2025,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder */ do { if(encoder->protected_->verify) - append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); + append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */ for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { @@ -2069,7 +2060,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder */ do { if(encoder->protected_->verify) - append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); + append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j)); /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */ for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) { @@ -2411,8 +2402,8 @@ FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, unsigned samples, FLAC FLAC__bitwriter_clear(encoder->private_->frame); if(samples > 0) { - encoder->private_->streaminfo.data.stream_info.min_framesize = min(bytes, encoder->private_->streaminfo.data.stream_info.min_framesize); - encoder->private_->streaminfo.data.stream_info.max_framesize = max(bytes, encoder->private_->streaminfo.data.stream_info.max_framesize); + encoder->private_->streaminfo.data.stream_info.min_framesize = flac_min(bytes, encoder->private_->streaminfo.data.stream_info.min_framesize); + encoder->private_->streaminfo.data.stream_info.max_framesize = flac_max(bytes, encoder->private_->streaminfo.data.stream_info.max_framesize); } return true; @@ -2499,7 +2490,7 @@ FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const * when the encoder goes back to write metadata, 'current_frame' * will drop back to 0. */ - encoder->private_->frames_written = max(encoder->private_->frames_written, encoder->private_->current_frame_number+1); + encoder->private_->frames_written = flac_max(encoder->private_->frames_written, encoder->private_->current_frame_number+1); } else encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR; @@ -2510,7 +2501,7 @@ FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const /* Gets called when the encoding process has finished so that we can update the STREAMINFO and SEEKTABLE blocks. */ void update_metadata_(const FLAC__StreamEncoder *encoder) { - FLAC__byte b[max(6, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)]; + FLAC__byte b[flac_max(6u, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)]; const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo; const FLAC__uint64 samples = metadata->data.stream_info.total_samples; const unsigned min_framesize = metadata->data.stream_info.min_framesize; @@ -2675,7 +2666,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH + FLAC__STREAM_SYNC_LENGTH ; - FLAC__byte b[max(6, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)]; + FLAC__byte b[flac_max(6u, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)]; const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo; const FLAC__uint64 samples = metadata->data.stream_info.total_samples; const unsigned min_framesize = metadata->data.stream_info.min_framesize; @@ -2926,9 +2917,9 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fracti } else { max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize(encoder->protected_->blocksize); - max_partition_order = min(max_partition_order, encoder->protected_->max_residual_partition_order); + max_partition_order = flac_min(max_partition_order, encoder->protected_->max_residual_partition_order); } - min_partition_order = min(min_partition_order, max_partition_order); + min_partition_order = flac_min(min_partition_order, max_partition_order); /* * Setup the frame @@ -3332,8 +3323,8 @@ FLAC__bool process_subframe_( min_qlp_coeff_precision = FLAC__MIN_QLP_COEFF_PRECISION; /* try to ensure a 32-bit datapath throughout for 16bps(+1bps for side channel) or less */ if(subframe_bps <= 17) { - max_qlp_coeff_precision = min(32 - subframe_bps - lpc_order, FLAC__MAX_QLP_COEFF_PRECISION); - max_qlp_coeff_precision = max(max_qlp_coeff_precision, min_qlp_coeff_precision); + max_qlp_coeff_precision = flac_min(32 - subframe_bps - lpc_order, FLAC__MAX_QLP_COEFF_PRECISION); + max_qlp_coeff_precision = flac_max(max_qlp_coeff_precision, min_qlp_coeff_precision); } else max_qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION; @@ -3577,7 +3568,7 @@ unsigned evaluate_lpc_subframe_( if(subframe_bps <= 16) { FLAC__ASSERT(order > 0); FLAC__ASSERT(order <= FLAC__MAX_LPC_ORDER); - qlp_coeff_precision = min(qlp_coeff_precision, 32 - subframe_bps - FLAC__bitmath_ilog2(order)); + qlp_coeff_precision = flac_min(qlp_coeff_precision, 32 - subframe_bps - FLAC__bitmath_ilog2(order)); } ret = FLAC__lpc_quantize_coefficients(lp_coeff, order, qlp_coeff_precision, qlp_coeff, &quantization); @@ -3681,7 +3672,7 @@ unsigned find_best_partition_order_( const unsigned blocksize = residual_samples + predictor_order; max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(max_partition_order, blocksize, predictor_order); - min_partition_order = min(min_partition_order, max_partition_order); + min_partition_order = flac_min(min_partition_order, max_partition_order); precompute_partition_info_sums_(residual, abs_residual_partition_sums, residual_samples, predictor_order, min_partition_order, max_partition_order, bps); @@ -3735,7 +3726,7 @@ unsigned find_best_partition_order_( unsigned partition; /* save best parameters and raw_bits */ - FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(prc, max(6, best_partition_order)); + FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(prc, flac_max(6u, best_partition_order)); memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(unsigned)*(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))); @@ -3887,7 +3878,7 @@ void precompute_partition_info_escapes_( for(i = 0; i < partitions; i++) { m = raw_bits_per_partition[from_partition]; from_partition++; - raw_bits_per_partition[to_partition] = max(m, raw_bits_per_partition[from_partition]); + raw_bits_per_partition[to_partition] = flac_max(m, raw_bits_per_partition[from_partition]); from_partition++; to_partition++; } @@ -3965,7 +3956,7 @@ FLAC__bool set_partitioned_rice_( FLAC__ASSERT(suggested_rice_parameter < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER); FLAC__ASSERT(rice_parameter_limit <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER); - FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, max(6, partition_order)); + FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, flac_max(6u, partition_order)); parameters = partitioned_rice_contents->parameters; raw_bits = partitioned_rice_contents->raw_bits; diff --git a/src/libFLAC/stream_encoder_framing.c b/src/libFLAC/stream_encoder_framing.c index c883429..a415ad6 100644 --- a/src/libFLAC/stream_encoder_framing.c +++ b/src/libFLAC/stream_encoder_framing.c @@ -39,11 +39,6 @@ #include "private/crc.h" #include "FLAC/assert.h" -#ifdef max -#undef max -#endif -#define max(x,y) ((x)>(y)?(x):(y)) - 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); -- 2.7.4