diff options
75 files changed, 1351 insertions, 1350 deletions
diff --git a/src/libFLAC/bitmath.c b/src/libFLAC/bitmath.c index b3d797d3..32e31a79 100644 --- a/src/libFLAC/bitmath.c +++ b/src/libFLAC/bitmath.c @@ -60,7 +60,7 @@ * silog2( 9) = 5 * silog2( 10) = 5 */ -unsigned FLAC__bitmath_silog2(FLAC__int64 v) +uint32_t FLAC__bitmath_silog2(FLAC__int64 v) { if(v == 0) return 0; diff --git a/src/libFLAC/bitreader.c b/src/libFLAC/bitreader.c index ab62d414..386f4200 100644 --- a/src/libFLAC/bitreader.c +++ b/src/libFLAC/bitreader.c @@ -97,47 +97,47 @@ typedef FLAC__uint64 brword; * also depends on the CPU cache size and other factors; some twiddling * may be necessary to squeeze out the best performance. */ -static const unsigned FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */ +static const uint32_t FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */ struct FLAC__BitReader { /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */ /* any incomplete word at the tail will be left-justified, and bytes from the read callback are added on the right */ brword *buffer; - unsigned capacity; /* in words */ - unsigned words; /* # of completed words in buffer */ - unsigned bytes; /* # of bytes in incomplete word at buffer[words] */ - unsigned consumed_words; /* #words ... */ - unsigned consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */ - unsigned read_crc16; /* the running frame CRC */ - unsigned crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */ + uint32_t capacity; /* in words */ + uint32_t words; /* # of completed words in buffer */ + uint32_t bytes; /* # of bytes in incomplete word at buffer[words] */ + uint32_t consumed_words; /* #words ... */ + uint32_t consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */ + uint32_t read_crc16; /* the running frame CRC */ + uint32_t crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */ FLAC__BitReaderReadCallback read_callback; void *client_data; }; static inline void crc16_update_word_(FLAC__BitReader *br, brword word) { - register unsigned crc = br->read_crc16; + register uint32_t crc = br->read_crc16; #if FLAC__BYTES_PER_WORD == 4 switch(br->crc16_align) { - case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 24), crc); - case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc); - case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc); - case 24: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc); + case 0: crc = FLAC__CRC16_UPDATE((uint32_t)(word >> 24), crc); + case 8: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 16) & 0xff), crc); + case 16: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 8) & 0xff), crc); + case 24: br->read_crc16 = FLAC__CRC16_UPDATE((uint32_t)(word & 0xff), crc); } #elif FLAC__BYTES_PER_WORD == 8 switch(br->crc16_align) { - case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 56), crc); - case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 48) & 0xff), crc); - case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 40) & 0xff), crc); - case 24: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 32) & 0xff), crc); - case 32: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 24) & 0xff), crc); - case 40: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc); - case 48: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc); - case 56: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc); + case 0: crc = FLAC__CRC16_UPDATE((uint32_t)(word >> 56), crc); + case 8: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 48) & 0xff), crc); + case 16: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 40) & 0xff), crc); + case 24: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 32) & 0xff), crc); + case 32: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 24) & 0xff), crc); + case 40: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 16) & 0xff), crc); + case 48: crc = FLAC__CRC16_UPDATE((uint32_t)((word >> 8) & 0xff), crc); + case 56: br->read_crc16 = FLAC__CRC16_UPDATE((uint32_t)(word & 0xff), crc); } #else for( ; br->crc16_align < FLAC__BITS_PER_WORD; br->crc16_align += 8) - crc = FLAC__CRC16_UPDATE((unsigned)((word >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), crc); + crc = FLAC__CRC16_UPDATE((uint32_t)((word >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), crc); br->read_crc16 = crc; #endif br->crc16_align = 0; @@ -145,7 +145,7 @@ static inline void crc16_update_word_(FLAC__BitReader *br, brword word) static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br) { - unsigned start, end; + uint32_t start, end; size_t bytes; FLAC__byte *target; @@ -200,7 +200,7 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br) */ #if WORDS_BIGENDIAN #else - end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + (unsigned)bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD; + end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD; for(start = br->words; start < end; start++) br->buffer[start] = SWAP_BE_WORD_TO_HOST(br->buffer[start]); #endif @@ -211,7 +211,7 @@ static FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br) * buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD * finally we'll update the reader values: */ - end = br->words*FLAC__BYTES_PER_WORD + br->bytes + (unsigned)bytes; + end = br->words*FLAC__BYTES_PER_WORD + br->bytes + (uint32_t)bytes; br->words = end / FLAC__BYTES_PER_WORD; br->bytes = end % FLAC__BYTES_PER_WORD; @@ -293,7 +293,7 @@ FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br) void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out) { - unsigned i, j; + uint32_t i, j; if(br == 0) { fprintf(out, "bitreader is NULL\n"); } @@ -327,7 +327,7 @@ void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed) FLAC__ASSERT(0 != br->buffer); FLAC__ASSERT((br->consumed_bits & 7) == 0); - br->read_crc16 = (unsigned)seed; + br->read_crc16 = (uint32_t)seed; br->crc16_align = br->consumed_bits; } @@ -342,7 +342,7 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br) if(br->consumed_bits) { const brword tail = br->buffer[br->consumed_words]; for( ; br->crc16_align < br->consumed_bits; br->crc16_align += 8) - br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16); + br->read_crc16 = FLAC__CRC16_UPDATE((uint32_t)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16); } return br->read_crc16; } @@ -352,17 +352,17 @@ inline FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader return ((br->consumed_bits & 7) == 0); } -inline unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) +inline uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br) { return 8 - (br->consumed_bits & 7); } -inline unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br) +inline uint32_t 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; } -FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits) +FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits) { FLAC__ASSERT(0 != br); FLAC__ASSERT(0 != br->buffer); @@ -387,7 +387,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *va /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */ if(br->consumed_bits) { /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */ - const unsigned n = FLAC__BITS_PER_WORD - br->consumed_bits; + const uint32_t n = FLAC__BITS_PER_WORD - br->consumed_bits; const brword word = br->buffer[br->consumed_words]; if(bits < n) { *val = (FLAC__uint32)((word & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (n-bits)); /* The result has <= 32 non-zero bits */ @@ -442,7 +442,7 @@ FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *va } } -FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits) +FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits) { FLAC__uint32 uval, mask; /* OPT: inline raw uint32 code here, or make into a macro if possible in the .h file */ @@ -455,7 +455,7 @@ FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, return true; } -FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits) +FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits) { FLAC__uint32 hi, lo; @@ -501,7 +501,7 @@ inline FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, return true; } -FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits) +FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits) { /* * OPT: a faster implementation is possible but probably not that useful @@ -511,8 +511,8 @@ FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits) FLAC__ASSERT(0 != br->buffer); if(bits > 0) { - const unsigned n = br->consumed_bits & 7; - unsigned m; + const uint32_t n = br->consumed_bits & 7; + uint32_t m; FLAC__uint32 x; if(n != 0) { @@ -536,7 +536,7 @@ FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits) return true; } -FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals) +FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals) { FLAC__uint32 x; @@ -571,7 +571,7 @@ FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, u return true; } -FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals) +FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals) { FLAC__uint32 x; @@ -627,10 +627,10 @@ FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, F return true; } -FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val) +FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val) #if 0 /* slow but readable version */ { - unsigned bit; + uint32_t bit; FLAC__ASSERT(0 != br); FLAC__ASSERT(0 != br->buffer); @@ -648,7 +648,7 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va } #else { - unsigned i; + uint32_t i; FLAC__ASSERT(0 != br); FLAC__ASSERT(0 != br->buffer); @@ -685,7 +685,7 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va * be zero. */ if(br->bytes*8 > br->consumed_bits) { - const unsigned end = br->bytes * 8; + const uint32_t end = br->bytes * 8; brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits; if(b) { i = COUNT_ZERO_MSBS(b); @@ -708,10 +708,10 @@ FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *va } #endif -FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter) +FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter) { FLAC__uint32 lsbs = 0, msbs = 0; - unsigned uval; + uint32_t uval; FLAC__ASSERT(0 != br); FLAC__ASSERT(0 != br->buffer); @@ -736,13 +736,13 @@ FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsig } /* this is by far the most heavily used reader call. it ain't pretty but it's fast */ -FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter) +FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter) { /* try and get br->consumed_words and br->consumed_bits into register; * must remember to flush them back to *br before calling other * bitreader functions that use them, and before returning */ - unsigned cwords, words, lsbs, msbs, x, y; - unsigned ucbits; /* keep track of the number of unconsumed bits in word */ + uint32_t cwords, words, lsbs, msbs, x, y; + uint32_t ucbits; /* keep track of the number of unconsumed bits in word */ brword b; int *val, *end; @@ -803,7 +803,7 @@ FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[ msbs = x; /* read the binary LSBs */ - x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit unsigned */ + x = (FLAC__uint32)(b >> (FLAC__BITS_PER_WORD - parameter)); /* parameter < 32, so we can cast to 32-bit uint32_t */ if(parameter <= ucbits) { ucbits -= parameter; b <<= parameter; @@ -876,10 +876,10 @@ incomplete_lsbs: } #if 0 /* UNUSED */ -FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter) +FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter) { FLAC__uint32 lsbs = 0, msbs = 0; - unsigned bit, uval, k; + uint32_t bit, uval, k; FLAC__ASSERT(0 != br); FLAC__ASSERT(0 != br->buffer); @@ -899,7 +899,7 @@ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uns uval = (msbs << k) | lsbs; } else { - unsigned d = (1 << (k+1)) - parameter; + uint32_t d = (1 << (k+1)) - parameter; if(lsbs >= d) { if(!FLAC__bitreader_read_bit(br, &bit)) return false; @@ -911,7 +911,7 @@ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uns uval = msbs * parameter + lsbs; } - /* unfold unsigned to signed */ + /* unfold uint32_t to signed */ if(uval & 1) *val = -((int)(uval >> 1)) - 1; else @@ -920,10 +920,10 @@ FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uns return true; } -FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter) +FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, uint32_t *val, uint32_t parameter) { FLAC__uint32 lsbs, msbs = 0; - unsigned bit, k; + uint32_t bit, k; FLAC__ASSERT(0 != br); FLAC__ASSERT(0 != br->buffer); @@ -943,7 +943,7 @@ FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *v *val = (msbs << k) | lsbs; } else { - unsigned d = (1 << (k+1)) - parameter; + uint32_t d = (1 << (k+1)) - parameter; if(lsbs >= d) { if(!FLAC__bitreader_read_bit(br, &bit)) return false; @@ -960,11 +960,11 @@ FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *v #endif /* UNUSED */ /* on return, if *val == 0xffffffff then the utf-8 sequence was invalid, but the return value will be true */ -FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen) +FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen) { FLAC__uint32 v = 0; FLAC__uint32 x; - unsigned i; + uint32_t i; if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) return false; @@ -1015,11 +1015,11 @@ FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *v } /* on return, if *val == 0xffffffffffffffff then the utf-8 sequence was invalid, but the return value will be true */ -FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen) +FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen) { FLAC__uint64 v = 0; FLAC__uint32 x; - unsigned i; + uint32_t i; if(!FLAC__bitreader_read_raw_uint32(br, &x, 8)) return false; @@ -1082,6 +1082,6 @@ FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *v * fix that we add extern declarations here. */ extern FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); -extern unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); -extern unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); +extern uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); +extern uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); extern FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); diff --git a/src/libFLAC/bitwriter.c b/src/libFLAC/bitwriter.c index 402b1c49..8f475d59 100644 --- a/src/libFLAC/bitwriter.c +++ b/src/libFLAC/bitwriter.c @@ -80,9 +80,9 @@ typedef FLAC__uint64 bwword; * a frame or metadata block, then write that out and clear the buffer for the * next one. */ -static const unsigned FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(bwword); /* size in words */ +static const uint32_t FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(bwword); /* size in words */ /* When growing, increment 4K at a time */ -static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword); /* size in words */ +static const uint32_t FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword); /* size in words */ #define FLAC__WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD) #define FLAC__TOTAL_BITS(bw) (FLAC__WORDS_TO_BITS((bw)->words) + (bw)->bits) @@ -90,18 +90,18 @@ static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword) struct FLAC__BitWriter { bwword *buffer; bwword accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */ - unsigned capacity; /* capacity of buffer in words */ - unsigned words; /* # of complete words in buffer */ - unsigned bits; /* # of used bits in accum */ + uint32_t capacity; /* capacity of buffer in words */ + uint32_t words; /* # of complete words in buffer */ + uint32_t bits; /* # of used bits in accum */ }; /* * WATCHOUT: The current implementation only grows the buffer. */ #ifndef __SUNPRO_C static #endif -FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add) +FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, uint32_t bits_to_add) { - unsigned new_capacity; + uint32_t new_capacity; bwword *new_buffer; FLAC__ASSERT(0 != bw); @@ -191,7 +191,7 @@ void FLAC__bitwriter_clear(FLAC__BitWriter *bw) void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out) { - unsigned i, j; + uint32_t i, j; if(bw == 0) { fprintf(out, "bitwriter is NULL\n"); } @@ -248,7 +248,7 @@ FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw) return ((bw->bits & 7) == 0); } -unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw) +uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw) { return FLAC__TOTAL_BITS(bw); } @@ -281,9 +281,9 @@ void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw) (void)bw; } -inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits) +inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits) { - unsigned n; + uint32_t n; FLAC__ASSERT(0 != bw); FLAC__ASSERT(0 != bw->buffer); @@ -319,9 +319,9 @@ inline FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bit return true; } -static inline FLAC__bool FLAC__bitwriter_write_raw_uint32_nocheck(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits) +static inline FLAC__bool FLAC__bitwriter_write_raw_uint32_nocheck(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits) { - register unsigned left; + register uint32_t left; /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */ FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); @@ -360,7 +360,7 @@ static inline FLAC__bool FLAC__bitwriter_write_raw_uint32_nocheck(FLAC__BitWrite return true; } -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, uint32_t bits) { /* check that unused bits are unset */ if((bits < 32) && (val>>bits != 0)) @@ -369,7 +369,7 @@ inline FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__ui return FLAC__bitwriter_write_raw_uint32_nocheck(bw, val, bits); } -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, uint32_t bits) { /* zero-out unused bits */ if(bits < 32) @@ -378,7 +378,7 @@ inline FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int return FLAC__bitwriter_write_raw_uint32_nocheck(bw, (FLAC__uint32)val, bits); } -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, uint32_t bits) { /* this could be a little faster but it's not used for much */ if(bits > 32) { @@ -406,9 +406,9 @@ inline FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter return true; } -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[], uint32_t nvals) { - unsigned i; + uint32_t i; /* this could be faster but currently we don't need it to be since it's only used for writing metadata */ for(i = 0; i < nvals; i++) { @@ -419,7 +419,7 @@ inline FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FL return true; } -FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val) +FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val) { if(val < 32) return FLAC__bitwriter_write_raw_uint32_nocheck(bw, 1, ++val); @@ -429,13 +429,13 @@ FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned va FLAC__bitwriter_write_raw_uint32_nocheck(bw, 1, 1); } -unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter) +uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter) { FLAC__uint32 uval; FLAC__ASSERT(parameter < 32); - /* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */ + /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ uval = val; uval <<= 1; uval ^= (val>>31); @@ -444,18 +444,18 @@ unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter) } #if 0 /* UNUSED */ -unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter) +uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter) { - unsigned bits, msbs, uval; - unsigned k; + uint32_t bits, msbs, uval; + uint32_t k; FLAC__ASSERT(parameter > 0); - /* fold signed to unsigned */ + /* fold signed to uint32_t */ if(val < 0) - uval = (unsigned)(((-(++val)) << 1) + 1); + uval = (uint32_t)(((-(++val)) << 1) + 1); else - uval = (unsigned)(val << 1); + uval = (uint32_t)(val << 1); k = FLAC__bitmath_ilog2(parameter); if(parameter == 1u<<k) { @@ -465,7 +465,7 @@ unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter) bits = 1 + k + msbs; } else { - unsigned q, r, d; + uint32_t q, r, d; d = (1 << (k+1)) - parameter; q = uval / parameter; @@ -478,10 +478,10 @@ unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter) return bits; } -unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter) +uint32_t FLAC__bitwriter_golomb_bits_unsigned(uint32_t uval, uint32_t parameter) { - unsigned bits, msbs; - unsigned k; + uint32_t bits, msbs; + uint32_t k; FLAC__ASSERT(parameter > 0); @@ -493,7 +493,7 @@ unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter) bits = 1 + k + msbs; } else { - unsigned q, r, d; + uint32_t q, r, d; d = (1 << (k+1)) - parameter; q = uval / parameter; @@ -507,16 +507,16 @@ unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter) } #endif /* UNUSED */ -FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter) +FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter) { - unsigned total_bits, interesting_bits, msbs; + uint32_t total_bits, interesting_bits, msbs; FLAC__uint32 uval, pattern; FLAC__ASSERT(0 != bw); FLAC__ASSERT(0 != bw->buffer); FLAC__ASSERT(parameter < 32); - /* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */ + /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ uval = val; uval <<= 1; uval ^= (val>>31); @@ -535,14 +535,14 @@ FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 va FLAC__bitwriter_write_raw_uint32(bw, pattern, interesting_bits); /* write the unary end bit and binary LSBs */ } -FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter) +FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter) { const FLAC__uint32 mask1 = (FLAC__uint32)0xffffffff << parameter; /* we val|=mask1 to set the stop bit above it... */ const FLAC__uint32 mask2 = (FLAC__uint32)0xffffffff >> (31-parameter); /* ...then mask off the bits above the stop bit with val&=mask2 */ FLAC__uint32 uval; - unsigned left; - const unsigned lsbits = 1 + parameter; - unsigned msbits, total_bits; + uint32_t left; + const uint32_t lsbits = 1 + parameter; + uint32_t msbits, total_bits; FLAC__ASSERT(0 != bw); FLAC__ASSERT(0 != bw->buffer); @@ -551,7 +551,7 @@ FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FL FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32); while(nvals) { - /* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */ + /* fold signed to uint32_t; actual formula is: negative(v)? -2v-1 : 2v */ uval = *vals; uval <<= 1; uval ^= (*vals>>31); @@ -630,24 +630,24 @@ break1: } #if 0 /* UNUSED */ -FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter) +FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter) { - unsigned total_bits, msbs, uval; - unsigned k; + uint32_t total_bits, msbs, uval; + uint32_t k; FLAC__ASSERT(0 != bw); FLAC__ASSERT(0 != bw->buffer); FLAC__ASSERT(parameter > 0); - /* fold signed to unsigned */ + /* fold signed to uint32_t */ if(val < 0) - uval = (unsigned)(((-(++val)) << 1) + 1); + uval = (uint32_t)(((-(++val)) << 1) + 1); else - uval = (unsigned)(val << 1); + uval = (uint32_t)(val << 1); k = FLAC__bitmath_ilog2(parameter); if(parameter == 1u<<k) { - unsigned pattern; + uint32_t pattern; FLAC__ASSERT(k <= 30); @@ -670,7 +670,7 @@ FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uns } } else { - unsigned q, r, d; + uint32_t q, r, d; d = (1 << (k+1)) - parameter; q = uval / parameter; @@ -694,10 +694,10 @@ FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uns return true; } -FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned uval, unsigned parameter) +FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, uint32_t uval, uint32_t parameter) { - unsigned total_bits, msbs; - unsigned k; + uint32_t total_bits, msbs; + uint32_t k; FLAC__ASSERT(0 != bw); FLAC__ASSERT(0 != bw->buffer); @@ -705,7 +705,7 @@ FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned u k = FLAC__bitmath_ilog2(parameter); if(parameter == 1u<<k) { - unsigned pattern; + uint32_t pattern; FLAC__ASSERT(k <= 30); @@ -728,7 +728,7 @@ FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned u } } else { - unsigned q, r, d; + uint32_t q, r, d; d = (1 << (k+1)) - parameter; q = uval / parameter; @@ -873,9 +873,9 @@ FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw) * Unfortunately, the Microsoft VS compiler doesn't pick them up externally. To * fix that we add extern declarations here. */ -extern FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits); -extern FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits); -extern FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits); -extern FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits); +extern FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits); +extern FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits); +extern FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits); +extern FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits); extern FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); -extern FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals); +extern FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals); diff --git a/src/libFLAC/cpu.c b/src/libFLAC/cpu.c index 12d46191..1c80a728 100644 --- a/src/libFLAC/cpu.c +++ b/src/libFLAC/cpu.c @@ -59,25 +59,25 @@ #if defined FLAC__CPU_IA32 /* 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; -static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000; -static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000; #endif #if FLAC__HAS_X86INTRIN || FLAC__AVX_SUPPORTED || defined FLAC__HAS_NASM /* 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; -static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE41 = 0x00080000; -static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE42 = 0x00100000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_SSE41 = 0x00080000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_SSE42 = 0x00100000; /* these are flags in ECX of CPUID AX=00000001 */ -static const unsigned FLAC__CPUINFO_IA32_CPUID_OSXSAVE = 0x08000000; -static const unsigned FLAC__CPUINFO_IA32_CPUID_AVX = 0x10000000; -static const unsigned FLAC__CPUINFO_IA32_CPUID_FMA = 0x00001000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_OSXSAVE = 0x08000000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_AVX = 0x10000000; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_FMA = 0x00001000; /* these are flags in EBX of CPUID AX=00000007 */ -static const unsigned FLAC__CPUINFO_IA32_CPUID_AVX2 = 0x00000020; +static const uint32_t FLAC__CPUINFO_IA32_CPUID_AVX2 = 0x00000020; #endif #if defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64 @@ -267,7 +267,7 @@ void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx int cpuinfo[4]; int ext = level & 0x80000000; __cpuid(cpuinfo, ext); - if((unsigned)cpuinfo[0] >= level) { + if((uint32_t)cpuinfo[0] >= level) { #if FLAC__AVX_SUPPORTED __cpuidex(cpuinfo, level, 0); /* for AVX2 detection */ #else diff --git a/src/libFLAC/crc.c b/src/libFLAC/crc.c index 8123c3b6..a36d9470 100644 --- a/src/libFLAC/crc.c +++ b/src/libFLAC/crc.c @@ -75,7 +75,7 @@ FLAC__byte const FLAC__crc8_table[256] = { /* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */ -unsigned const FLAC__crc16_table[256] = { +uint32_t const FLAC__crc16_table[256] = { 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, @@ -116,13 +116,13 @@ void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc) *crc = FLAC__crc8_table[*crc ^ data]; } -void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc) +void FLAC__crc8_update_block(const FLAC__byte *data, uint32_t len, FLAC__uint8 *crc) { while(len--) *crc = FLAC__crc8_table[*crc ^ *data++]; } -FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len) +FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len) { FLAC__uint8 crc = 0; @@ -132,9 +132,9 @@ FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len) return crc; } -unsigned FLAC__crc16(const FLAC__byte *data, unsigned len) +uint32_t FLAC__crc16(const FLAC__byte *data, uint32_t len) { - unsigned crc = 0; + uint32_t crc = 0; while(len--) crc = ((crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]) & 0xffff; diff --git a/src/libFLAC/fixed.c b/src/libFLAC/fixed.c index 1e2d5b28..98f42a2f 100644 --- a/src/libFLAC/fixed.c +++ b/src/libFLAC/fixed.c @@ -45,7 +45,7 @@ #ifdef local_abs #undef local_abs #endif -#define local_abs(x) ((unsigned)((x)<0? -(x) : (x))) +#define local_abs(x) ((uint32_t)((x)<0? -(x) : (x))) #ifdef FLAC__INTEGER_ONLY_LIBRARY /* rbps stands for residual bits per sample @@ -57,7 +57,7 @@ static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n) { FLAC__uint32 rbps; - unsigned bits; /* the number of bits required to represent a number */ + uint32_t bits; /* the number of bits required to represent a number */ int fracbits; /* the number of bits of rbps that comprise the fractional part */ FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); @@ -105,7 +105,7 @@ static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__ } } - rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1)); + rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1)); if(rbps == 0) return 0; @@ -136,7 +136,7 @@ static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__ static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n) { FLAC__uint32 rbps; - unsigned bits; /* the number of bits required to represent a number */ + uint32_t bits; /* the number of bits required to represent a number */ int fracbits; /* the number of bits of rbps that comprise the fractional part */ FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); @@ -184,7 +184,7 @@ static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, F } } - rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1)); + rbps = FLAC__fixedpoint_log2(rbps, fracbits, (uint32_t)(-1)); if(rbps == 0) return 0; @@ -214,9 +214,9 @@ static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, F #endif #ifndef FLAC__INTEGER_ONLY_LIBRARY -unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) #else -unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +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]) #endif { FLAC__int32 last_error_0 = data[-1]; @@ -225,7 +225,7 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]); FLAC__int32 error, save; FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; - unsigned i, order; + uint32_t i, order; for(i = 0; i < data_len; i++) { error = data[i] ; total_error_0 += local_abs(error); save = error; @@ -272,9 +272,9 @@ unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned d } #ifndef FLAC__INTEGER_ONLY_LIBRARY -unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) #else -unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]) #endif { FLAC__int32 last_error_0 = data[-1]; @@ -287,7 +287,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig * large. */ FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0; - unsigned i, order; + uint32_t i, order; for(i = 0; i < data_len; i++) { error = data[i] ; total_error_0 += local_abs(error); save = error; @@ -333,7 +333,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig return order; } -void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]) +void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]) { const int idata_len = (int)data_len; int i; @@ -364,7 +364,7 @@ void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, u } } -void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]) +void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]) { int i, idata_len = (int)data_len; diff --git a/src/libFLAC/fixed_intrin_sse2.c b/src/libFLAC/fixed_intrin_sse2.c index 6a9b4dd0..47258e94 100644 --- a/src/libFLAC/fixed_intrin_sse2.c +++ b/src/libFLAC/fixed_intrin_sse2.c @@ -55,10 +55,10 @@ #endif FLAC__SSE_TARGET("sse2") -unsigned FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) +uint32_t FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) { FLAC__uint32 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - unsigned i, order; + uint32_t i, order; __m128i total_err0, total_err1, total_err2; @@ -152,10 +152,10 @@ unsigned FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[] } FLAC__SSE_TARGET("sse2") -unsigned FLAC__fixed_compute_best_predictor_wide_intrin_sse2(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) +uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) { FLAC__uint64 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - unsigned i, order; + uint32_t i, order; __m128i total_err0, total_err1, total_err3; diff --git a/src/libFLAC/fixed_intrin_ssse3.c b/src/libFLAC/fixed_intrin_ssse3.c index f4d93e8f..2a61e833 100644 --- a/src/libFLAC/fixed_intrin_ssse3.c +++ b/src/libFLAC/fixed_intrin_ssse3.c @@ -55,10 +55,10 @@ #endif FLAC__SSE_TARGET("ssse3") -unsigned FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) +uint32_t FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) { FLAC__uint32 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - unsigned i, order; + uint32_t i, order; __m128i total_err0, total_err1, total_err2; @@ -146,10 +146,10 @@ unsigned FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[ } FLAC__SSE_TARGET("ssse3") -unsigned FLAC__fixed_compute_best_predictor_wide_intrin_ssse3(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]) +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]) { FLAC__uint64 total_error_0, total_error_1, total_error_2, total_error_3, total_error_4; - unsigned i, order; + uint32_t i, order; __m128i total_err0, total_err1, total_err3; diff --git a/src/libFLAC/float.c b/src/libFLAC/float.c index 25d1a786..a49a083f 100644 --- a/src/libFLAC/float.c +++ b/src/libFLAC/float.c @@ -266,7 +266,7 @@ static const FLAC__uint64 log2_lookup_wide[] = { }; #endif -FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision) +FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, uint32_t fracbits, uint32_t precision) { const FLAC__uint32 ONE = (1u << fracbits); const FLAC__uint32 *table = log2_lookup[fracbits >> 2]; diff --git a/src/libFLAC/format.c b/src/libFLAC/format.c index 214bd09a..6caa69fe 100644 --- a/src/libFLAC/format.c +++ b/src/libFLAC/format.c @@ -50,99 +50,99 @@ FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION; FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20170101"; FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' }; -FLAC_API const unsigned FLAC__STREAM_SYNC = 0x664C6143; -FLAC_API const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_SYNC = 0x664C6143; +FLAC_API const uint32_t FLAC__STREAM_SYNC_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */ FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff); -FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */ - -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */ - -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */ - -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */ - -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */ - -FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */ -FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */ - -FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC = 0x3ffe; -FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */ -FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */ - -FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */ - -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */ -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */ -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */ -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */ -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */ - -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */ -FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */ + +FLAC_API const uint32_t FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */ +FLAC_API const uint32_t FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */ + +FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC = 0x3ffe; +FLAC_API const uint32_t FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */ + +FLAC_API const uint32_t FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */ + +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */ + +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */ +FLAC_API const uint32_t FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */ FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[] = { "PARTITIONED_RICE", "PARTITIONED_RICE2" }; -FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */ -FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */ +FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */ +FLAC_API const uint32_t FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */ -FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */ -FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */ -FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */ +FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */ +FLAC_API const uint32_t FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */ -FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00; -FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02; -FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10; -FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40; +FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00; +FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02; +FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10; +FLAC_API const uint32_t FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40; FLAC_API const char * const FLAC__SubframeTypeString[] = { "CONSTANT", @@ -197,7 +197,7 @@ FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = { "Publisher/Studio logotype" }; -FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate) +FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(uint32_t sample_rate) { if(sample_rate == 0 || sample_rate > FLAC__MAX_SAMPLE_RATE) { return false; @@ -206,7 +206,7 @@ FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate) return true; } -FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigned sample_rate) +FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(uint32_t blocksize, uint32_t sample_rate) { if(blocksize > 16384) return false; @@ -216,7 +216,7 @@ FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigne return true; } -FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate) +FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(uint32_t sample_rate) { if( !FLAC__format_sample_rate_is_valid(sample_rate) || @@ -234,7 +234,7 @@ FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate) /* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table) { - unsigned i; + uint32_t i; FLAC__uint64 prev_sample_number = 0; FLAC__bool got_prev = false; @@ -268,9 +268,9 @@ static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLA } /* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ -FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table) +FLAC_API uint32_t FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table) { - unsigned i, j; + uint32_t i, j; FLAC__bool first; FLAC__ASSERT(0 != seek_table); @@ -309,7 +309,7 @@ FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *se * and a more clear explanation at the end of this section: * http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 */ -static unsigned utf8len_(const FLAC__byte *utf8) +static uint32_t utf8len_(const FLAC__byte *utf8) { FLAC__ASSERT(0 != utf8); if ((utf8[0] & 0x80) == 0) { @@ -359,11 +359,11 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *n return true; } -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length) +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, uint32_t length) { - if(length == (unsigned)(-1)) { + if(length == (uint32_t)(-1)) { while(*value) { - unsigned n = utf8len_(value); + uint32_t n = utf8len_(value); if(n == 0) return false; value += n; @@ -372,7 +372,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__ else { const FLAC__byte *end = value + length; while(value < end) { - unsigned n = utf8len_(value); + uint32_t n = utf8len_(value); if(n == 0) return false; value += n; @@ -383,7 +383,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__ return true; } -FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length) +FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, uint32_t length) { const FLAC__byte *s, *end; @@ -397,7 +397,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte * s++; /* skip '=' */ while(s < end) { - unsigned n = utf8len_(s); + uint32_t n = utf8len_(s); if(n == 0) return false; s += n; @@ -411,7 +411,7 @@ FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte * /* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */ FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation) { - unsigned i, j; + uint32_t i, j; if(check_cd_da_subset) { if(cue_sheet->lead_in < 2 * 44100) { @@ -501,7 +501,7 @@ FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Pic } for(b = picture->description; *b; ) { - unsigned n = utf8len_(b); + uint32_t n = utf8len_(b); if(n == 0) { if(violation) *violation = "description string must be valid UTF-8"; return false; @@ -515,7 +515,7 @@ FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Pic /* * These routines are private to libFLAC */ -unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order) +uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order) { return FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order( @@ -525,9 +525,9 @@ unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned ); } -unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize) +uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize) { - unsigned max_rice_partition_order = 0; + uint32_t max_rice_partition_order = 0; while(!(blocksize & 1)) { max_rice_partition_order++; blocksize >>= 1; @@ -535,9 +535,9 @@ unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned block 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) +uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order) { - unsigned max_rice_partition_order = limit; + uint32_t max_rice_partition_order = limit; while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order) max_rice_partition_order--; @@ -570,18 +570,18 @@ void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__En FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object); } -FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order) +FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order) { FLAC__ASSERT(0 != object); 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 = safe_realloc_(object->parameters, sizeof(unsigned)*(1 << max_partition_order)))) + if(0 == (object->parameters = safe_realloc_(object->parameters, sizeof(uint32_t)*(1 << max_partition_order)))) return false; - if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order)))) + if(0 == (object->raw_bits = safe_realloc_(object->raw_bits, sizeof(uint32_t)*(1 << max_partition_order)))) return false; - memset(object->raw_bits, 0, sizeof(unsigned)*(1 << max_partition_order)); + memset(object->raw_bits, 0, sizeof(uint32_t)*(1 << max_partition_order)); object->capacity_by_order = max_partition_order; } diff --git a/src/libFLAC/include/private/bitmath.h b/src/libFLAC/include/private/bitmath.h index 9c75f85b..0d0a9c8a 100644 --- a/src/libFLAC/include/private/bitmath.h +++ b/src/libFLAC/include/private/bitmath.h @@ -43,9 +43,9 @@ #endif /* Will never be emitted for MSVC, GCC, Intel compilers */ -static inline unsigned int FLAC__clz_soft_uint32(FLAC__uint32 word) +static inline uint32_t FLAC__clz_soft_uint32(FLAC__uint32 word) { - static const unsigned char byte_to_unary_table[] = { + static const uint8_t byte_to_unary_table[] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -70,7 +70,7 @@ static inline unsigned int FLAC__clz_soft_uint32(FLAC__uint32 word) byte_to_unary_table[word] + 24; } -static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v) +static inline uint32_t FLAC__clz_uint32(FLAC__uint32 v) { /* Never used with input 0 */ FLAC__ASSERT(v > 0); @@ -82,7 +82,7 @@ static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v) return __builtin_clz(v); #elif defined(_MSC_VER) { - unsigned long idx; + uint32_t long idx; _BitScanReverse(&idx, v); return idx ^ 31U; } @@ -92,13 +92,13 @@ static inline unsigned int FLAC__clz_uint32(FLAC__uint32 v) } /* Used when 64-bit bsr/clz is unavailable; can use 32-bit bsr/clz when possible */ -static inline unsigned int FLAC__clz_soft_uint64(FLAC__uint64 word) +static inline uint32_t FLAC__clz_soft_uint64(FLAC__uint64 word) { return (FLAC__uint32)(word>>32) ? FLAC__clz_uint32((FLAC__uint32)(word>>32)) : FLAC__clz_uint32((FLAC__uint32)word) + 32; } -static inline unsigned int FLAC__clz_uint64(FLAC__uint64 v) +static inline uint32_t FLAC__clz_uint64(FLAC__uint64 v) { /* Never used with input 0 */ FLAC__ASSERT(v > 0); @@ -106,7 +106,7 @@ static inline unsigned int FLAC__clz_uint64(FLAC__uint64 v) return __builtin_clzll(v); #elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64)) { - unsigned long idx; + uint32_t long idx; _BitScanReverse64(&idx, v); return idx ^ 63U; } @@ -116,14 +116,14 @@ static inline unsigned int FLAC__clz_uint64(FLAC__uint64 v) } /* These two functions work with input 0 */ -static inline unsigned int FLAC__clz2_uint32(FLAC__uint32 v) +static inline uint32_t FLAC__clz2_uint32(FLAC__uint32 v) { if (!v) return 32; return FLAC__clz_uint32(v); } -static inline unsigned int FLAC__clz2_uint64(FLAC__uint64 v) +static inline uint32_t FLAC__clz2_uint64(FLAC__uint64 v) { if (!v) return 64; @@ -153,14 +153,14 @@ static inline unsigned int FLAC__clz2_uint64(FLAC__uint64 v) * ilog2(18) = 4 */ -static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v) +static inline uint32_t FLAC__bitmath_ilog2(FLAC__uint32 v) { FLAC__ASSERT(v > 0); #if defined(__INTEL_COMPILER) return _bit_scan_reverse(v); #elif defined(_MSC_VER) { - unsigned long idx; + uint32_t long idx; _BitScanReverse(&idx, v); return idx; } @@ -169,7 +169,7 @@ static inline unsigned FLAC__bitmath_ilog2(FLAC__uint32 v) #endif } -static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) +static inline uint32_t FLAC__bitmath_ilog2_wide(FLAC__uint64 v) { FLAC__ASSERT(v > 0); #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) @@ -177,7 +177,7 @@ static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) /* Sorry, only supported in x64/Itanium.. and both have fast FPU which makes integer-only encoder pointless */ #elif (defined(__INTEL_COMPILER) || defined(_MSC_VER)) && (defined(_M_IA64) || defined(_M_X64)) { - unsigned long idx; + uint32_t long idx; _BitScanReverse64(&idx, v); return idx; } @@ -187,7 +187,7 @@ static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) (C) Timothy B. Terriberry (tterribe@xiph.org) 2001-2009 CC0 (Public domain). */ { - static const unsigned char DEBRUIJN_IDX64[64]={ + static const uint8_t DEBRUIJN_IDX64[64]={ 0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40, 5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57, 63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56, @@ -205,6 +205,6 @@ static inline unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) #endif } -unsigned FLAC__bitmath_silog2(FLAC__int64 v); +uint32_t FLAC__bitmath_silog2(FLAC__int64 v); #endif diff --git a/src/libFLAC/include/private/bitreader.h b/src/libFLAC/include/private/bitreader.h index 7c731655..81e585af 100644 --- a/src/libFLAC/include/private/bitreader.h +++ b/src/libFLAC/include/private/bitreader.h @@ -65,27 +65,27 @@ FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br); * info functions */ FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br); -unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); -unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); +uint32_t FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br); +uint32_t FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br); /* * read functions */ -FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits); -FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits); -FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits); +FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, uint32_t bits); +FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, uint32_t bits); +FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, uint32_t bits); FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/ -FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */ -FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals); /* WATCHOUT: does not CRC the read data! */ -FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals); /* WATCHOUT: does not CRC the read data! */ -FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val); -FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter); -FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter); +FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, uint32_t bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */ +FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */ +FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, uint32_t nvals); /* WATCHOUT: does not CRC the read data! */ +FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, uint32_t *val); +FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, uint32_t parameter); +FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], uint32_t nvals, uint32_t parameter); #if 0 /* UNUSED */ -FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter); -FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter); +FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, uint32_t parameter); +FLAC__bool FLAC__bitreader_read_golomb_uint32_t(FLAC__BitReader *br, uint32_t *val, uint32_t parameter); #endif -FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen); -FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen); +FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, uint32_t *rawlen); +FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, uint32_t *rawlen); #endif diff --git a/src/libFLAC/include/private/bitwriter.h b/src/libFLAC/include/private/bitwriter.h index ef3ad1b6..d1aa0946 100644 --- a/src/libFLAC/include/private/bitwriter.h +++ b/src/libFLAC/include/private/bitwriter.h @@ -64,7 +64,7 @@ FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc); * info functions */ FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw); -unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */ +uint32_t FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */ /* * direct buffer access @@ -79,23 +79,23 @@ void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw); /* * write functions */ -FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits); -FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits); -FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits); -FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits); +FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t bits); +FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, uint32_t bits); FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); /*only for bits=32*/ -FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals); -FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val); -unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter); +FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], uint32_t nvals); +FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, uint32_t val); +uint32_t FLAC__bitwriter_rice_bits(FLAC__int32 val, uint32_t parameter); #if 0 /* UNUSED */ -unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter); -unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned val, unsigned parameter); +uint32_t FLAC__bitwriter_golomb_bits_signed(int val, uint32_t parameter); +uint32_t FLAC__bitwriter_golomb_bits_uint32_t(uint32_t val, uint32_t parameter); #endif -FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter); -FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter); +FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, uint32_t parameter); +FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, uint32_t nvals, uint32_t parameter); #if 0 /* UNUSED */ -FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter); -FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned val, unsigned parameter); +FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, uint32_t parameter); +FLAC__bool FLAC__bitwriter_write_golomb_uint32_t(FLAC__BitWriter *bw, uint32_t val, uint32_t parameter); #endif FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val); FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val); diff --git a/src/libFLAC/include/private/crc.h b/src/libFLAC/include/private/crc.h index 294f60ea..f783dcc2 100644 --- a/src/libFLAC/include/private/crc.h +++ b/src/libFLAC/include/private/crc.h @@ -42,14 +42,14 @@ extern FLAC__byte const FLAC__crc8_table[256]; #define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)]; void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc); -void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc); -FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len); +void FLAC__crc8_update_block(const FLAC__byte *data, uint32_t len, FLAC__uint8 *crc); +FLAC__uint8 FLAC__crc8(const FLAC__byte *data, uint32_t len); /* 16 bit CRC generator, MSB shifted first ** polynomial = x^16 + x^15 + x^2 + x^0 ** init = 0 */ -extern unsigned const FLAC__crc16_table[256]; +extern uint32_t const FLAC__crc16_table[256]; #define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) /* this alternate may be faster on some systems/compilers */ @@ -57,6 +57,6 @@ extern unsigned const FLAC__crc16_table[256]; #define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff) #endif -unsigned FLAC__crc16(const FLAC__byte *data, unsigned len); +uint32_t FLAC__crc16(const FLAC__byte *data, uint32_t len); #endif diff --git a/src/libFLAC/include/private/fixed.h b/src/libFLAC/include/private/fixed.h index 68cdfceb..9edf0abd 100644 --- a/src/libFLAC/include/private/fixed.h +++ b/src/libFLAC/include/private/fixed.h @@ -54,26 +54,26 @@ * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER] */ #ifndef FLAC__INTEGER_ONLY_LIBRARY -unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); # ifndef FLAC__NO_ASM # if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN # ifdef FLAC__SSE2_SUPPORTED -unsigned FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); -unsigned FLAC__fixed_compute_best_predictor_wide_intrin_sse2(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); +uint32_t FLAC__fixed_compute_best_predictor_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); +uint32_t FLAC__fixed_compute_best_predictor_wide_intrin_sse2(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); # endif # ifdef FLAC__SSSE3_SUPPORTED -unsigned FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -unsigned FLAC__fixed_compute_best_predictor_wide_intrin_ssse3(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER + 1]); +uint32_t FLAC__fixed_compute_best_predictor_intrin_ssse3(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +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 -unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +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 -unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); -unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); +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]); +uint32_t FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); #endif /* @@ -87,7 +87,7 @@ unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsig * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order * OUT residual[0,data_len-1] residual signal */ -void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]); +void FLAC__fixed_compute_residual(const FLAC__int32 data[], uint32_t data_len, uint32_t order, FLAC__int32 residual[]); /* * FLAC__fixed_restore_signal() @@ -102,6 +102,6 @@ void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, u * IN data[-order,-1] previously-reconstructed historical samples * OUT data[0,data_len-1] original signal */ -void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]); +void FLAC__fixed_restore_signal(const FLAC__int32 residual[], uint32_t data_len, uint32_t order, FLAC__int32 data[]); #endif diff --git a/src/libFLAC/include/private/float.h b/src/libFLAC/include/private/float.h index 12ece605..cb32da40 100644 --- a/src/libFLAC/include/private/float.h +++ b/src/libFLAC/include/private/float.h @@ -81,14 +81,14 @@ extern const FLAC__fixedpoint FLAC__FP_E; * be < 32 and evenly divisible by 4 (0 is OK but not very precise). * * 'precision' roughly limits the number of iterations that are done; - * use (unsigned)(-1) for maximum precision. + * use (uint32_t)(-1) for maximum precision. * * If 'x' is less than one -- that is, x < (1<<fracbits) -- then this * function will punt and return 0. * * The return value will also have 'fracbits' fractional bits. */ -FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision); +FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, uint32_t fracbits, uint32_t precision); #endif diff --git a/src/libFLAC/include/private/format.h b/src/libFLAC/include/private/format.h index 5b9cfbd0..8f28017c 100644 --- a/src/libFLAC/include/private/format.h +++ b/src/libFLAC/include/private/format.h @@ -35,11 +35,11 @@ #include "FLAC/format.h" -unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order); -unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize); -unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order); +uint32_t FLAC__format_get_max_rice_partition_order(uint32_t blocksize, uint32_t predictor_order); +uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize(uint32_t blocksize); +uint32_t FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(uint32_t limit, uint32_t blocksize, uint32_t predictor_order); void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object); -FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order); +FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, uint32_t max_partition_order); #endif diff --git a/src/libFLAC/include/private/lpc.h b/src/libFLAC/include/private/lpc.h index 6eb02be6..29c7ac38 100644 --- a/src/libFLAC/include/private/lpc.h +++ b/src/libFLAC/include/private/lpc.h @@ -54,7 +54,7 @@ * OUT out[0,lag-1] * IN data_len */ -void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len); +void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len); /* * FLAC__lpc_compute_autocorrelation() @@ -68,27 +68,27 @@ void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FL * IN 0 < lag <= data_len * OUT autoc[0,lag-1] */ -void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); #ifndef FLAC__NO_ASM # ifdef FLAC__CPU_IA32 # ifdef FLAC__HAS_NASM -void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_16_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_16_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); # endif # endif # if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN # ifdef FLAC__SSE_SUPPORTED -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); # endif # endif #endif @@ -114,7 +114,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real da * in lp_coeff[8][0,8], the LP coefficients for order 8 will be * in lp_coeff[7][0,7], etc. */ -void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]); +void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]); /* * FLAC__lpc_quantize_coefficients() @@ -136,7 +136,7 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_o * 2 => coefficients are all zero, which is bad. 'shift' is * unset. */ -int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift); +int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift); /* * FLAC__lpc_compute_residual_from_qlp_coefficients() @@ -151,29 +151,29 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, * IN lp_quantization quantization of LP coefficients in bits * OUT residual[0,data_len-1] residual signal */ -void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients(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(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); #ifndef FLAC__NO_ASM # ifdef FLAC__CPU_IA32 # ifdef FLAC__HAS_NASM -void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); +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, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); +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[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(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__SSE4_1_SUPPORTED -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(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_intrin_sse41(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__AVX2_SUPPORTED -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); +void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(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_intrin_avx2(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_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); # endif # endif #endif @@ -195,22 +195,22 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLA * IN data[-order,-1] previously-reconstructed historical samples * OUT data[0,data_len-1] original signal */ -void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); -void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); #ifndef FLAC__NO_ASM # ifdef FLAC__CPU_IA32 # ifdef FLAC__HAS_NASM -void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); -void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); -void FLAC__lpc_restore_signal_wide_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_wide_asm_ia32(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); # endif /* FLAC__HAS_NASM */ # endif /* FLAC__CPU_IA32 */ # if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN # ifdef FLAC__SSE2_SUPPORTED -void FLAC__lpc_restore_signal_16_intrin_sse2(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_16_intrin_sse2(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); # endif # ifdef FLAC__SSE4_1_SUPPORTED -void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); +void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); # endif # endif #endif /* FLAC__NO_ASM */ @@ -227,7 +227,7 @@ void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], un * IN total_samples > 0 # of samples in residual signal * RETURN expected bits per sample */ -double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, unsigned total_samples); +double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples); double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(double lpc_error, double error_scale); /* @@ -243,7 +243,7 @@ double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(doub * (includes warmup sample size and quantized LP coefficient) * RETURN [1,max_order] best order */ -unsigned FLAC__lpc_compute_best_order(const double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order); +uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order); #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ diff --git a/src/libFLAC/include/private/md5.h b/src/libFLAC/include/private/md5.h index c665ab31..f9d79c3e 100644 --- a/src/libFLAC/include/private/md5.h +++ b/src/libFLAC/include/private/md5.h @@ -45,6 +45,6 @@ typedef struct { void FLAC__MD5Init(FLAC__MD5Context *context); void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context); -FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample); +FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample); #endif diff --git a/src/libFLAC/include/private/memory.h b/src/libFLAC/include/private/memory.h index f103c531..a6d3faff 100644 --- a/src/libFLAC/include/private/memory.h +++ b/src/libFLAC/include/private/memory.h @@ -49,7 +49,7 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address); 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); +FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, uint32_t **unaligned_pointer, uint32_t **aligned_pointer); #ifndef FLAC__INTEGER_ONLY_LIBRARY FLAC__bool FLAC__memory_alloc_aligned_real_array(size_t elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer); #endif diff --git a/src/libFLAC/include/private/ogg_decoder_aspect.h b/src/libFLAC/include/private/ogg_decoder_aspect.h index 218f44ed..0a8534d4 100644 --- a/src/libFLAC/include/private/ogg_decoder_aspect.h +++ b/src/libFLAC/include/private/ogg_decoder_aspect.h @@ -46,7 +46,7 @@ typedef struct FLAC__OggDecoderAspect { /* these are for internal state related to Ogg decoding */ ogg_stream_state stream_state; ogg_sync_state sync_state; - unsigned version_major, version_minor; + uint32_t version_major, version_minor; FLAC__bool need_serial_number; FLAC__bool end_of_stream; FLAC__bool have_working_page; /* only if true will the following vars be valid */ diff --git a/src/libFLAC/include/private/ogg_encoder_aspect.h b/src/libFLAC/include/private/ogg_encoder_aspect.h index f55ef322..f3c95f96 100644 --- a/src/libFLAC/include/private/ogg_encoder_aspect.h +++ b/src/libFLAC/include/private/ogg_encoder_aspect.h @@ -41,7 +41,7 @@ typedef struct FLAC__OggEncoderAspect { /* these are storage for values that can be set through the API */ long serial_number; - unsigned num_metadata; + uint32_t num_metadata; /* these are for internal state related to Ogg encoding */ ogg_stream_state stream_state; @@ -52,12 +52,12 @@ typedef struct FLAC__OggEncoderAspect { } FLAC__OggEncoderAspect; void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, long value); -FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, unsigned value); +FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, uint32_t value); void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect); FLAC__bool FLAC__ogg_encoder_aspect_init(FLAC__OggEncoderAspect *aspect); void FLAC__ogg_encoder_aspect_finish(FLAC__OggEncoderAspect *aspect); -typedef FLAC__StreamEncoderWriteStatus (*FLAC__OggEncoderAspectWriteCallbackProxy)(const void *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data); +typedef FLAC__StreamEncoderWriteStatus (*FLAC__OggEncoderAspectWriteCallbackProxy)(const void *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); -FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data); +FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data); #endif diff --git a/src/libFLAC/include/private/ogg_mapping.h b/src/libFLAC/include/private/ogg_mapping.h index 1fa022d0..6eb609e0 100644 --- a/src/libFLAC/include/private/ogg_mapping.h +++ b/src/libFLAC/include/private/ogg_mapping.h @@ -38,7 +38,7 @@ /** The length of the packet type field in bytes. */ #define FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH (1u) -extern const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */ +extern const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */ extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */ @@ -47,8 +47,8 @@ extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */ extern const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC; /* = "FLAC" */ -extern const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */ -extern const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */ +extern const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */ +extern const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */ /** The length of the Ogg FLAC mapping major version number in bytes. */ #define FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH (1u) @@ -56,7 +56,7 @@ extern const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */ /** The length of the Ogg FLAC mapping minor version number in bytes. */ #define FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH (1u) -extern const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */ +extern const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */ /** The length of the #-of-header-packets number bytes. */ #define FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH (2u) diff --git a/src/libFLAC/include/private/stream_encoder.h b/src/libFLAC/include/private/stream_encoder.h index ab1721f6..ade648bf 100644 --- a/src/libFLAC/include/private/stream_encoder.h +++ b/src/libFLAC/include/private/stream_encoder.h @@ -49,17 +49,17 @@ #ifdef FLAC__SSE2_SUPPORTED extern void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps); + uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); #endif #ifdef FLAC__SSSE3_SUPPORTED extern void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps); + uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); #endif #ifdef FLAC__AVX2_SUPPORTED extern void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps); + uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); #endif #endif diff --git a/src/libFLAC/include/private/stream_encoder_framing.h b/src/libFLAC/include/private/stream_encoder_framing.h index f633a9d3..8df10494 100644 --- a/src/libFLAC/include/private/stream_encoder_framing.h +++ b/src/libFLAC/include/private/stream_encoder_framing.h @@ -38,9 +38,9 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw); FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw); -FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); +FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw); #endif diff --git a/src/libFLAC/include/protected/stream_decoder.h b/src/libFLAC/include/protected/stream_decoder.h index 5c31c161..c691edb3 100644 --- a/src/libFLAC/include/protected/stream_decoder.h +++ b/src/libFLAC/include/protected/stream_decoder.h @@ -41,11 +41,11 @@ typedef struct FLAC__StreamDecoderProtected { FLAC__StreamDecoderState state; FLAC__StreamDecoderInitStatus initstate; - unsigned channels; + uint32_t channels; FLAC__ChannelAssignment channel_assignment; - unsigned bits_per_sample; - unsigned sample_rate; /* in Hz */ - unsigned blocksize; /* in samples (per channel) */ + uint32_t bits_per_sample; + uint32_t sample_rate; /* in Hz */ + uint32_t blocksize; /* in samples (per channel) */ FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */ #if FLAC__HAS_OGG FLAC__OggDecoderAspect ogg_decoder_aspect; @@ -55,6 +55,6 @@ typedef struct FLAC__StreamDecoderProtected { /* * return the number of input bytes consumed */ -unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder); +uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder); #endif diff --git a/src/libFLAC/include/protected/stream_encoder.h b/src/libFLAC/include/protected/stream_encoder.h index 8850c6bc..c290904e 100644 --- a/src/libFLAC/include/protected/stream_encoder.h +++ b/src/libFLAC/include/protected/stream_encoder.h @@ -90,25 +90,25 @@ typedef struct FLAC__StreamEncoderProtected { FLAC__bool do_md5; FLAC__bool do_mid_side_stereo; FLAC__bool loose_mid_side_stereo; - unsigned channels; - unsigned bits_per_sample; - unsigned sample_rate; - unsigned blocksize; + uint32_t channels; + uint32_t bits_per_sample; + uint32_t sample_rate; + uint32_t blocksize; #ifndef FLAC__INTEGER_ONLY_LIBRARY - unsigned num_apodizations; + uint32_t num_apodizations; FLAC__ApodizationSpecification apodizations[FLAC__MAX_APODIZATION_FUNCTIONS]; #endif - unsigned max_lpc_order; - unsigned qlp_coeff_precision; + uint32_t max_lpc_order; + uint32_t qlp_coeff_precision; FLAC__bool do_qlp_coeff_prec_search; FLAC__bool do_exhaustive_model_search; FLAC__bool do_escape_coding; - unsigned min_residual_partition_order; - unsigned max_residual_partition_order; - unsigned rice_parameter_search_dist; + uint32_t min_residual_partition_order; + uint32_t max_residual_partition_order; + uint32_t rice_parameter_search_dist; FLAC__uint64 total_samples_estimate; FLAC__StreamMetadata **metadata; - unsigned num_metadata_blocks; + uint32_t num_metadata_blocks; FLAC__uint64 streaminfo_offset, seektable_offset, audio_offset; #if FLAC__HAS_OGG FLAC__OggEncoderAspect ogg_encoder_aspect; diff --git a/src/libFLAC/lpc.c b/src/libFLAC/lpc.c index 531247b5..53c3082e 100644 --- a/src/libFLAC/lpc.c +++ b/src/libFLAC/lpc.c @@ -63,19 +63,19 @@ static inline long int lround(double x) { /* If this fails, we are in the presence 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) +void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], uint32_t data_len) { - unsigned i; + uint32_t i; for(i = 0; i < data_len; i++) out[i] = in[i] * window[i]; } -void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { /* a readable, but slower, version */ #if 0 FLAC__real d; - unsigned i; + uint32_t i; FLAC__ASSERT(lag > 0); FLAC__ASSERT(lag <= data_len); @@ -99,8 +99,8 @@ void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_le * ('data_len' is usually much larger than 'lag') */ FLAC__real d; - unsigned sample, coeff; - const unsigned limit = data_len - lag; + uint32_t sample, coeff; + const uint32_t limit = data_len - lag; FLAC__ASSERT(lag > 0); FLAC__ASSERT(lag <= data_len); @@ -119,9 +119,9 @@ 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], double error[]) +void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], uint32_t *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], double error[]) { - unsigned i, j; + uint32_t i, j; double r, err, lpc[FLAC__MAX_LPC_ORDER]; FLAC__ASSERT(0 != max_order); @@ -163,9 +163,9 @@ void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_o } } -int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift) +int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], uint32_t order, uint32_t precision, FLAC__int32 qlp_coeff[], int *shift) { - unsigned i; + uint32_t i; double cmax; FLAC__int32 qmax, qmin; @@ -264,11 +264,11 @@ int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, #pragma warning ( disable : 4028 ) #endif -void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_restrict data, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict residual) +void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) { FLAC__int64 sumo; - unsigned i, j; + uint32_t i, j; FLAC__int32 sum; const FLAC__int32 *history; @@ -525,10 +525,10 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 * flac_r } #endif -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * flac_restrict data, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict residual) +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * flac_restrict data, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict residual) #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) { - unsigned i, j; + uint32_t i, j; FLAC__int64 sum; const FLAC__int32 *history; @@ -781,11 +781,11 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 * f #endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */ -void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict data) +void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data) #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) { FLAC__int64 sumo; - unsigned i, j; + uint32_t i, j; FLAC__int32 sum; const FLAC__int32 *r = residual, *history; @@ -1042,10 +1042,10 @@ void FLAC__lpc_restore_signal(const FLAC__int32 * flac_restrict residual, unsign } #endif -void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, unsigned data_len, const FLAC__int32 * flac_restrict qlp_coeff, unsigned order, int lp_quantization, FLAC__int32 * flac_restrict data) +void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, uint32_t data_len, const FLAC__int32 * flac_restrict qlp_coeff, uint32_t order, int lp_quantization, FLAC__int32 * flac_restrict data) #if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS) { - unsigned i, j; + uint32_t i, j; FLAC__int64 sum; const FLAC__int32 *r = residual, *history; @@ -1302,7 +1302,7 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 * flac_restrict residual, u #ifndef FLAC__INTEGER_ONLY_LIBRARY -double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, unsigned total_samples) +double FLAC__lpc_compute_expected_bits_per_residual_sample(double lpc_error, uint32_t total_samples) { double error_scale; @@ -1330,9 +1330,9 @@ double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(doub } } -unsigned FLAC__lpc_compute_best_order(const double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order) +uint32_t FLAC__lpc_compute_best_order(const double lpc_error[], uint32_t max_order, uint32_t total_samples, uint32_t overhead_bits_per_order) { - unsigned order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */ + uint32_t order, indx, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */ double bits, best_bits, error_scale; FLAC__ASSERT(max_order > 0); @@ -1341,7 +1341,7 @@ unsigned FLAC__lpc_compute_best_order(const double lpc_error[], unsigned max_ord error_scale = 0.5 / (double)total_samples; best_index = 0; - best_bits = (unsigned)(-1); + best_bits = (uint32_t)(-1); for(indx = 0, order = 1; indx < max_order; indx++, order++) { bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[indx], error_scale) * (double)(total_samples - order) + (double)(order * overhead_bits_per_order); diff --git a/src/libFLAC/lpc_intrin_avx2.c b/src/libFLAC/lpc_intrin_avx2.c index f9f5ccdb..01de4fb2 100644 --- a/src/libFLAC/lpc_intrin_avx2.c +++ b/src/libFLAC/lpc_intrin_avx2.c @@ -48,7 +48,7 @@ #include <immintrin.h> /* AVX2 */ FLAC__SSE_TARGET("avx2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { int i; FLAC__int32 sum; @@ -403,7 +403,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_avx2(const FLAC_ } FLAC__SSE_TARGET("avx2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { int i; FLAC__int32 sum; @@ -760,7 +760,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_avx2(const FLAC__in static FLAC__int32 pack_arr[8] = { 0, 2, 4, 6, 1, 3, 5, 7 }; FLAC__SSE_TARGET("avx2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_avx2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { int i; FLAC__int64 sum; diff --git a/src/libFLAC/lpc_intrin_sse.c b/src/libFLAC/lpc_intrin_sse.c index 430e73f0..d984418b 100644 --- a/src/libFLAC/lpc_intrin_sse.c +++ b/src/libFLAC/lpc_intrin_sse.c @@ -54,7 +54,7 @@ /* new routines: faster on current Intel (starting from Core i aka Nehalem) and all AMD CPUs */ FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { int i; int limit = data_len - 4; @@ -90,7 +90,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_new(const FLAC__real dat } FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { int i; int limit = data_len - 8; @@ -134,7 +134,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_new(const FLAC__real dat } FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { int i; int limit = data_len - 12; @@ -186,7 +186,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_new(const FLAC__real da } FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { int i; int limit = data_len - 16; @@ -248,7 +248,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_new(const FLAC__real da /* old routines: faster on older Intel CPUs (up to Core 2) */ FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { __m128 xmm0, xmm2, xmm5; @@ -285,7 +285,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_4_old(const FLAC__real dat } FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { __m128 xmm0, xmm1, xmm2, xmm3, xmm5, xmm6; @@ -331,7 +331,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_8_old(const FLAC__real dat } FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { __m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; @@ -385,7 +385,7 @@ void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_12_old(const FLAC__real da } FLAC__SSE_TARGET("sse") -void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_old(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]) +void FLAC__lpc_compute_autocorrelation_intrin_sse_lag_16_old(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]) { __m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9; diff --git a/src/libFLAC/lpc_intrin_sse2.c b/src/libFLAC/lpc_intrin_sse2.c index 13833948..f1176367 100644 --- a/src/libFLAC/lpc_intrin_sse2.c +++ b/src/libFLAC/lpc_intrin_sse2.c @@ -54,7 +54,7 @@ #define DATA32_RESULT(xmmN) data[i] = residual[i] + (_mm_cvtsi128_si32(xmmN) >> lp_quantization); FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +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[]) { int i; FLAC__int32 sum; @@ -408,7 +408,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_16_intrin_sse2(const FLAC_ } FLAC__SSE_TARGET("sse2") -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { int i; @@ -937,7 +937,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse2(const FLAC__in #if defined FLAC__CPU_IA32 && !defined FLAC__HAS_NASM /* unused for x64; not better than MMX asm */ FLAC__SSE_TARGET("sse2") -void FLAC__lpc_restore_signal_16_intrin_sse2(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]) +void FLAC__lpc_restore_signal_16_intrin_sse2(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]) { if (order < 8 || order > 12) { FLAC__lpc_restore_signal(residual, data_len, qlp_coeff, order, lp_quantization, data); diff --git a/src/libFLAC/lpc_intrin_sse41.c b/src/libFLAC/lpc_intrin_sse41.c index bef73f41..71b3771d 100644 --- a/src/libFLAC/lpc_intrin_sse41.c +++ b/src/libFLAC/lpc_intrin_sse41.c @@ -53,7 +53,7 @@ #define RESIDUAL64_RESULT1(xmmN) residual[i] = data[i] - _mm_cvtsi128_si32(_mm_srli_epi64(xmmN, lp_quantization)) FLAC__SSE_TARGET("sse4.1") -void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { int i; __m128i cnt = _mm_cvtsi32_si128(lp_quantization); @@ -589,7 +589,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide_intrin_sse41(const FL } FLAC__SSE_TARGET("sse4.1") -void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]) +void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]) { int i; __m128i cnt = _mm_cvtsi32_si128(lp_quantization); @@ -955,7 +955,7 @@ void FLAC__lpc_restore_signal_wide_intrin_sse41(const FLAC__int32 residual[], un #endif /* defined FLAC__CPU_IA32 */ FLAC__SSE_TARGET("sse4.1") -void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]) +void FLAC__lpc_compute_residual_from_qlp_coefficients_intrin_sse41(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]) { int i; FLAC__int32 sum; diff --git a/src/libFLAC/md5.c b/src/libFLAC/md5.c index e9013a9a..d395e09e 100644 --- a/src/libFLAC/md5.c +++ b/src/libFLAC/md5.c @@ -136,7 +136,7 @@ static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16]) #if WORDS_BIGENDIAN //@@@@@@ OPT: use bswap/intrinsics -static void byteSwap(FLAC__uint32 *buf, unsigned words) +static void byteSwap(FLAC__uint32 *buf, uint32_t words) { register FLAC__uint32 x; do { @@ -175,7 +175,7 @@ static void byteSwapX16(FLAC__uint32 *buf) * Update context to reflect the concatenation of another buffer full * of bytes. */ -static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, unsigned len) +static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, uint32_t len) { FLAC__uint32 t; @@ -271,13 +271,13 @@ void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx) /* * Convert the incoming audio signal to a byte stream */ -static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample) +static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample) { FLAC__byte *buf_ = mbuf->p8; FLAC__int16 *buf16 = mbuf->p16; FLAC__int32 *buf32 = mbuf->p32; FLAC__int32 a_word; - unsigned channel, sample; + uint32_t channel, sample; /* Storage in the output buffer, buf, is little endian. */ @@ -488,7 +488,7 @@ static void format_input_(FLAC__multibyte *mbuf, const FLAC__int32 * const signa /* * Convert the incoming audio signal to a byte stream and FLAC__MD5Update it. */ -FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample) +FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], uint32_t channels, uint32_t samples, uint32_t bytes_per_sample) { const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample; diff --git a/src/libFLAC/memory.c b/src/libFLAC/memory.c index a8ebd10f..3dae9d23 100644 --- a/src/libFLAC/memory.c +++ b/src/libFLAC/memory.c @@ -146,11 +146,11 @@ FLAC__bool FLAC__memory_alloc_aligned_uint64_array(size_t elements, FLAC__uint64 } } -FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, unsigned **unaligned_pointer, unsigned **aligned_pointer) +FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(size_t elements, uint32_t **unaligned_pointer, uint32_t **aligned_pointer) { - unsigned *pu; /* unaligned pointer */ + uint32_t *pu; /* unaligned pointer */ union { /* union needed to comply with C99 pointer aliasing rules */ - unsigned *pa; /* aligned pointer */ + uint32_t *pa; /* aligned pointer */ void *pv; /* aligned pointer alias */ } u; diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c index 0a84d03b..352a6c7a 100644 --- a/src/libFLAC/metadata_iterators.c +++ b/src/libFLAC/metadata_iterators.c @@ -62,50 +62,50 @@ * ***************************************************************************/ -static void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes); -static void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes); -static void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes); -static FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes); -static FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes); -static FLAC__uint64 unpack_uint64_(FLAC__byte *b, unsigned bytes); +static void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes); +static void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes); +static void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, uint32_t bytes); +static FLAC__uint32 unpack_uint32_(FLAC__byte *b, uint32_t bytes); +static FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, uint32_t bytes); +static FLAC__uint64 unpack_uint64_(FLAC__byte *b, uint32_t bytes); static FLAC__bool read_metadata_block_header_(FLAC__Metadata_SimpleIterator *iterator); static FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block); -static FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, unsigned *length); +static FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, uint32_t *length); static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata *block); static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_StreamInfo *block); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, unsigned block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, unsigned block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, unsigned block_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, unsigned max_length); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, unsigned block_length); +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, uint32_t block_length); +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, uint32_t block_length); +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, uint32_t block_length); +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, uint32_t max_length); +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, uint32_t block_length); static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track); static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block); static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Picture *block); -static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, unsigned block_length); +static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, uint32_t block_length); static FLAC__bool write_metadata_block_header_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block); static FLAC__bool write_metadata_block_data_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block); static FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block); static FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block); static FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block); -static FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, unsigned block_length); -static FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, unsigned block_length); +static FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, uint32_t block_length); +static FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, uint32_t block_length); static FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block); static FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block); static FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block); static FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block); -static FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, unsigned block_length); +static FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, uint32_t block_length); static FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block); -static FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, unsigned padding_length, FLAC__bool padding_is_last); +static FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, uint32_t padding_length, FLAC__bool padding_is_last); static FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool append); static void simple_iterator_push_(FLAC__Metadata_SimpleIterator *iterator); static FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator); -static unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb); -static unsigned seek_to_first_metadata_block_(FILE *f); +static uint32_t seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb); +static uint32_t seek_to_first_metadata_block_(FILE *f); static FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append); static FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, FLAC__off_t fixup_is_last_flag_offset, FLAC__bool backup); @@ -265,7 +265,7 @@ void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErro cd->got_error = true; } -FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors) +FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, uint32_t max_width, uint32_t max_height, uint32_t max_depth, uint32_t max_colors) { FLAC__Metadata_SimpleIterator *it; FLAC__uint64 max_area_seen = 0; @@ -334,11 +334,11 @@ struct FLAC__Metadata_SimpleIterator { FLAC__Metadata_SimpleIteratorStatus status; FLAC__off_t offset[SIMPLE_ITERATOR_MAX_PUSH_DEPTH]; FLAC__off_t first_offset; /* this is the offset to the STREAMINFO block */ - unsigned depth; + uint32_t depth; /* this is the metadata block header of the current block we are pointing to: */ FLAC__bool is_last; FLAC__MetadataType type; - unsigned length; + uint32_t length; }; FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[] = { @@ -417,7 +417,7 @@ FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_stat static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool read_only) { - unsigned ret; + uint32_t ret; FLAC__ASSERT(0 != iterator); @@ -588,7 +588,7 @@ FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const } /*@@@@add to tests*/ -FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator) +FLAC_API uint32_t FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator) { FLAC__ASSERT(0 != iterator); FLAC__ASSERT(0 != iterator->file); @@ -599,7 +599,7 @@ FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Me /*@@@@add to tests*/ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id) { - const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; + const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; FLAC__ASSERT(0 != iterator); FLAC__ASSERT(0 != iterator->file); @@ -693,7 +693,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp } } else /* iterator->length < block->length */ { - unsigned padding_leftover = 0; + uint32_t padding_leftover = 0; FLAC__bool padding_is_last = false; if(use_padding) { /* first see if we can even use padding */ @@ -701,7 +701,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp use_padding = false; } else { - const unsigned extra_padding_bytes_required = block->length - iterator->length; + const uint32_t extra_padding_bytes_required = block->length - iterator->length; simple_iterator_push_(iterator); if(!FLAC__metadata_simple_iterator_next(iterator)) { (void)simple_iterator_pop_(iterator); @@ -753,7 +753,7 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_Simp FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding) { - unsigned padding_leftover = 0; + uint32_t padding_leftover = 0; FLAC__bool padding_is_last = false; FLAC__ASSERT_DECLARATION(FLAC__off_t debug_target_offset = iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length;) @@ -892,7 +892,7 @@ struct FLAC__Metadata_Chain { FLAC__bool is_ogg; FLAC__Metadata_Node *head; FLAC__Metadata_Node *tail; - unsigned nodes; + uint32_t nodes; FLAC__Metadata_ChainStatus status; FLAC__off_t first_offset, last_offset; /* @@ -1089,7 +1089,7 @@ static void iterator_insert_node_after_(FLAC__Metadata_Iterator *iterator, FLAC_ static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node) { if(node->data->type == FLAC__METADATA_TYPE_PADDING && 0 != node->next && node->next->data->type == FLAC__METADATA_TYPE_PADDING) { - const unsigned growth = FLAC__STREAM_METADATA_HEADER_LENGTH + node->next->data->length; + const uint32_t growth = FLAC__STREAM_METADATA_HEADER_LENGTH + node->next->data->length; node->data->length += growth; /* new block size can be greater than max metadata block size, but it'll be fixed later in chain_prepare_for_write_() */ chain_delete_node_(chain, node->next); @@ -1213,7 +1213,7 @@ static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle han { FLAC__bool is_last; FLAC__MetadataType type; - unsigned length; + uint32_t length; do { node = node_new_(); @@ -1633,7 +1633,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata */ FLAC__off_t current_length; LastBlockState lbs_state = LBS_NONE; - unsigned lbs_size = 0; + uint32_t lbs_size = 0; FLAC__ASSERT(0 != chain); @@ -1674,7 +1674,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata { const FLAC__Metadata_Node *node; for(node = chain->head; node; node = node->next) { - unsigned block_len = node->data->length; + uint32_t block_len = node->data->length; if(node == chain->tail) { if(lbs_state == LBS_BLOCK_REMOVED) continue; @@ -1692,7 +1692,7 @@ FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata if(lbs_state == LBS_BLOCK_ADDED) { /* test added padding block */ - unsigned block_len = lbs_size; + uint32_t block_len = lbs_size; if(block_len >= (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) block_len = (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1; current_length += (FLAC__STREAM_METADATA_HEADER_LENGTH + block_len); @@ -1864,7 +1864,7 @@ FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain) FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain) { FLAC__Metadata_Node *node, *save; - unsigned i; + uint32_t i; FLAC__ASSERT(0 != chain); @@ -2041,9 +2041,9 @@ FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_It * ***************************************************************************/ -void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes) +void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes) { - unsigned i; + uint32_t i; b += bytes; @@ -2053,9 +2053,9 @@ void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes) } } -void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes) +void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, uint32_t bytes) { - unsigned i; + uint32_t i; for(i = 0; i < bytes; i++) { *(b++) = (FLAC__byte)(val & 0xff); @@ -2063,9 +2063,9 @@ void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes) } } -void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes) +void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, uint32_t bytes) { - unsigned i; + uint32_t i; b += bytes; @@ -2075,10 +2075,10 @@ void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes) } } -FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes) +FLAC__uint32 unpack_uint32_(FLAC__byte *b, uint32_t bytes) { FLAC__uint32 ret = 0; - unsigned i; + uint32_t i; for(i = 0; i < bytes; i++) ret = (ret << 8) | (FLAC__uint32)(*b++); @@ -2086,10 +2086,10 @@ FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes) return ret; } -FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes) +FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, uint32_t bytes) { FLAC__uint32 ret = 0; - unsigned i; + uint32_t i; b += bytes; @@ -2099,10 +2099,10 @@ FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes) return ret; } -FLAC__uint64 unpack_uint64_(FLAC__byte *b, unsigned bytes) +FLAC__uint64 unpack_uint64_(FLAC__byte *b, uint32_t bytes) { FLAC__uint64 ret = 0; - unsigned i; + uint32_t i; for(i = 0; i < bytes; i++) ret = (ret << 8) | (FLAC__uint64)(*b++); @@ -2133,7 +2133,7 @@ FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FL return (iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK); } -FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, unsigned *length) +FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, uint32_t *length) { FLAC__byte raw_header[FLAC__STREAM_METADATA_HEADER_LENGTH]; @@ -2191,16 +2191,16 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC block->max_blocksize = unpack_uint32_(b, 2); b += 2; block->min_framesize = unpack_uint32_(b, 3); b += 3; block->max_framesize = unpack_uint32_(b, 3); b += 3; - block->sample_rate = (unpack_uint32_(b, 2) << 4) | ((unsigned)(b[2] & 0xf0) >> 4); - block->channels = (unsigned)((b[2] & 0x0e) >> 1) + 1; - block->bits_per_sample = ((((unsigned)(b[2] & 0x01)) << 4) | (((unsigned)(b[3] & 0xf0)) >> 4)) + 1; + block->sample_rate = (unpack_uint32_(b, 2) << 4) | ((uint32_t)(b[2] & 0xf0) >> 4); + block->channels = (uint32_t)((b[2] & 0x0e) >> 1) + 1; + block->bits_per_sample = ((((uint32_t)(b[2] & 0x01)) << 4) | (((uint32_t)(b[3] & 0xf0)) >> 4)) + 1; block->total_samples = (((FLAC__uint64)(b[3] & 0x0f)) << 32) | unpack_uint64_(b+4, 4); memcpy(block->md5sum, b+8, 16); return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, unsigned block_length) +FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, uint32_t block_length) { (void)block; /* nothing to do; we don't care about reading the padding bytes */ @@ -2210,9 +2210,9 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__I return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, unsigned block_length) +FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, uint32_t block_length) { - const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; + const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; if(read_cb(block->id, 1, id_bytes, handle) != id_bytes) return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR; @@ -2236,9 +2236,9 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLA return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, unsigned block_length) +FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, uint32_t block_length) { - unsigned i; + uint32_t i; FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH]; FLAC__ASSERT(block_length % FLAC__STREAM_METADATA_SEEKPOINT_LENGTH == 0); @@ -2262,9 +2262,9 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC_ return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, unsigned max_length) +FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry, uint32_t max_length) { - const unsigned entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; + const uint32_t entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; FLAC__byte buffer[4]; /* magic number is asserted below */ FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8 == sizeof(buffer)); @@ -2300,11 +2300,11 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entr return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, unsigned block_length) +FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_VorbisComment *block, uint32_t block_length) { - unsigned i; + uint32_t i; FLAC__Metadata_SimpleIteratorStatus status; - const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; + const uint32_t num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; FLAC__byte buffer[4]; /* magic number is asserted below */ FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8 == sizeof(buffer)); @@ -2354,7 +2354,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_( FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track) { - unsigned i, len; + uint32_t i, len; FLAC__byte buffer[32]; /* asserted below that this is big enough */ FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64)); @@ -2423,7 +2423,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_( FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block) { - unsigned i, len; + uint32_t i, len; FLAC__Metadata_SimpleIteratorStatus status; FLAC__byte buffer[1024]; /* MSVC needs a constant expression so we put a magic number and assert */ @@ -2553,7 +2553,7 @@ FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__I return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK; } -FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, unsigned block_length) +FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, uint32_t block_length) { if(block_length == 0) { block->data = 0; @@ -2642,8 +2642,8 @@ FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block) { FLAC__byte buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH]; - const unsigned channels1 = block->channels - 1; - const unsigned bps1 = block->bits_per_sample - 1; + const uint32_t channels1 = block->channels - 1; + const uint32_t bps1 = block->bits_per_sample - 1; /* we are using hardcoded numbers for simplicity but we should * probably eventually write a bit-level packer and use the @@ -2666,9 +2666,9 @@ FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC_ return true; } -FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, unsigned block_length) +FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, uint32_t block_length) { - unsigned i, n = block_length; + uint32_t i, n = block_length; FLAC__byte buffer[1024]; (void)block; @@ -2687,9 +2687,9 @@ FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IO return true; } -FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, unsigned block_length) +FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, uint32_t block_length) { - const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; + const uint32_t id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8; if(write_cb(block->id, 1, id_bytes, handle) != id_bytes) return false; @@ -2704,7 +2704,7 @@ FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block) { - unsigned i; + uint32_t i; FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH]; for(i = 0; i < block->num_points; i++) { @@ -2721,9 +2721,9 @@ FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__ FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block) { - unsigned i; - const unsigned entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; - const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; + uint32_t i; + const uint32_t entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; + const uint32_t num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8; FLAC__byte buffer[4]; /* magic number is asserted below */ FLAC__ASSERT(flac_max(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN, FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8 == sizeof(buffer)); @@ -2751,7 +2751,7 @@ FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, F FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block) { - unsigned i, j, len; + uint32_t i, j, len; FLAC__byte buffer[1024]; /* asserted below that this is big enough */ FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64)); @@ -2845,7 +2845,7 @@ FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__I FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block) { - unsigned len; + uint32_t len; size_t slen; FLAC__byte buffer[4]; /* magic number is asserted below */ @@ -2917,7 +2917,7 @@ FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IO return true; } -FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, unsigned block_length) +FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, uint32_t block_length) { if(write_cb(block->data, 1, block_length, handle) != block_length) return false; @@ -2946,7 +2946,7 @@ FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *itera return read_metadata_block_header_(iterator); } -FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, unsigned padding_length, FLAC__bool padding_is_last) +FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, uint32_t padding_length, FLAC__bool padding_is_last) { FLAC__StreamMetadata *padding; @@ -3065,11 +3065,11 @@ FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator) * 2: seek error * 3: not a FLAC file */ -unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb) +uint32_t seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb) { FLAC__byte buffer[4]; size_t n; - unsigned i; + uint32_t i; FLAC__ASSERT(FLAC__STREAM_SYNC_LENGTH == sizeof(buffer)); @@ -3081,7 +3081,7 @@ unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallbac else if(n != 4) return 3; else if(0 == memcmp(buffer, "ID3", 3)) { - unsigned tag_length = 0; + uint32_t tag_length = 0; /* skip to the tag length */ if(seek_cb(handle, 2, SEEK_CUR) < 0) @@ -3115,7 +3115,7 @@ unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallbac return 3; } -unsigned seek_to_first_metadata_block_(FILE *f) +uint32_t seek_to_first_metadata_block_(FILE *f) { return seek_to_first_metadata_block_cb_((FLAC__IOHandle)f, (FLAC__IOCallback_Read)fread, fseek_wrapper_); } diff --git a/src/libFLAC/metadata_object.c b/src/libFLAC/metadata_object.c index 9cb95019..de8e5139 100644 --- a/src/libFLAC/metadata_object.c +++ b/src/libFLAC/metadata_object.c @@ -62,7 +62,7 @@ * else ASSERT * malloc error leaves 'to' unchanged */ -static FLAC__bool copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsigned bytes) +static FLAC__bool copy_bytes_(FLAC__byte **to, const FLAC__byte *from, uint32_t bytes) { FLAC__ASSERT(to != NULL); if (bytes > 0 && from != NULL) { @@ -80,7 +80,7 @@ static FLAC__bool copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsigned #if 0 /* UNUSED */ /* like copy_bytes_(), but free()s the original '*to' if the copy succeeds and the original '*to' is non-NULL */ -static FLAC__bool free_copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsigned bytes) +static FLAC__bool free_copy_bytes_(FLAC__byte **to, const FLAC__byte *from, uint32_t bytes) { FLAC__byte *copy; FLAC__ASSERT(to != NULL); @@ -96,7 +96,7 @@ static FLAC__bool free_copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsi /* reallocate entry to 1 byte larger and add a terminating NUL */ /* realloc() failure leaves entry unchanged */ -static FLAC__bool ensure_null_terminated_(FLAC__byte **entry, unsigned length) +static FLAC__bool ensure_null_terminated_(FLAC__byte **entry, uint32_t length) { FLAC__byte *x = safe_realloc_add_2op_(*entry, length, /*+*/1); if (x != NULL) { @@ -169,7 +169,7 @@ static void seektable_calculate_length_(FLAC__StreamMetadata *object) object->length = object->data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; } -static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(unsigned num_points) +static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(uint32_t num_points) { FLAC__StreamMetadata_SeekPoint *object_array; @@ -178,7 +178,7 @@ static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(unsigned num_points) object_array = safe_malloc_mul_2op_p(num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)); if (object_array != NULL) { - unsigned i; + uint32_t i; for (i = 0; i < num_points; i++) { object_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; object_array[i].stream_offset = 0; @@ -191,7 +191,7 @@ static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(unsigned num_points) static void vorbiscomment_calculate_length_(FLAC__StreamMetadata *object) { - unsigned i; + uint32_t i; FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); @@ -204,16 +204,16 @@ static void vorbiscomment_calculate_length_(FLAC__StreamMetadata *object) } } -static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_new_(unsigned num_comments) +static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_new_(uint32_t num_comments) { FLAC__ASSERT(num_comments > 0); return safe_calloc_(num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry)); } -static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment_Entry *object_array, unsigned num_comments) +static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment_Entry *object_array, uint32_t num_comments) { - unsigned i; + uint32_t i; FLAC__ASSERT(object_array != NULL && num_comments > 0); @@ -223,7 +223,7 @@ static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment free(object_array); } -static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_copy_(const FLAC__StreamMetadata_VorbisComment_Entry *object_array, unsigned num_comments) +static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_copy_(const FLAC__StreamMetadata_VorbisComment_Entry *object_array, uint32_t num_comments) { FLAC__StreamMetadata_VorbisComment_Entry *return_array; @@ -233,7 +233,7 @@ static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_copy_ return_array = vorbiscomment_entry_array_new_(num_comments); if (return_array != NULL) { - unsigned i; + uint32_t i; for (i = 0; i < num_comments; i++) { if (!copy_vcentry_(return_array+i, object_array+i)) { @@ -291,9 +291,9 @@ static FLAC__bool vorbiscomment_set_entry_(FLAC__StreamMetadata *object, FLAC__S return true; } -static int vorbiscomment_find_entry_from_(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name, unsigned field_name_length) +static int vorbiscomment_find_entry_from_(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name, uint32_t field_name_length) { - unsigned i; + uint32_t i; FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); @@ -309,7 +309,7 @@ static int vorbiscomment_find_entry_from_(const FLAC__StreamMetadata *object, un static void cuesheet_calculate_length_(FLAC__StreamMetadata *object) { - unsigned i; + uint32_t i; FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); @@ -340,23 +340,23 @@ static void cuesheet_calculate_length_(FLAC__StreamMetadata *object) } } -static FLAC__StreamMetadata_CueSheet_Index *cuesheet_track_index_array_new_(unsigned num_indices) +static FLAC__StreamMetadata_CueSheet_Index *cuesheet_track_index_array_new_(uint32_t num_indices) { FLAC__ASSERT(num_indices > 0); return safe_calloc_(num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)); } -static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_new_(unsigned num_tracks) +static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_new_(uint32_t num_tracks) { FLAC__ASSERT(num_tracks > 0); return safe_calloc_(num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)); } -static void cuesheet_track_array_delete_(FLAC__StreamMetadata_CueSheet_Track *object_array, unsigned num_tracks) +static void cuesheet_track_array_delete_(FLAC__StreamMetadata_CueSheet_Track *object_array, uint32_t num_tracks) { - unsigned i; + uint32_t i; FLAC__ASSERT(object_array != NULL && num_tracks > 0); @@ -370,7 +370,7 @@ static void cuesheet_track_array_delete_(FLAC__StreamMetadata_CueSheet_Track *ob free(object_array); } -static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_copy_(const FLAC__StreamMetadata_CueSheet_Track *object_array, unsigned num_tracks) +static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_copy_(const FLAC__StreamMetadata_CueSheet_Track *object_array, uint32_t num_tracks) { FLAC__StreamMetadata_CueSheet_Track *return_array; @@ -380,7 +380,7 @@ static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_copy_(const FLA return_array = cuesheet_track_array_new_(num_tracks); if (return_array != NULL) { - unsigned i; + uint32_t i; for (i = 0; i < num_tracks; i++) { if (!copy_track_(return_array+i, object_array+i)) { @@ -461,7 +461,7 @@ FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type */ break; case FLAC__METADATA_TYPE_VORBIS_COMMENT: - object->data.vorbis_comment.vendor_string.length = (unsigned)strlen(FLAC__VENDOR_STRING); + object->data.vorbis_comment.vendor_string.length = (uint32_t)strlen(FLAC__VENDOR_STRING); if (!copy_bytes_(&object->data.vorbis_comment.vendor_string.entry, (const FLAC__byte*)FLAC__VENDOR_STRING, object->data.vorbis_comment.vendor_string.length+1)) { free(object); return 0; @@ -715,7 +715,7 @@ static FLAC__bool compare_block_data_streaminfo_(const FLAC__StreamMetadata_Stre return true; } -static FLAC__bool compare_block_data_application_(const FLAC__StreamMetadata_Application *block1, const FLAC__StreamMetadata_Application *block2, unsigned block_length) +static FLAC__bool compare_block_data_application_(const FLAC__StreamMetadata_Application *block1, const FLAC__StreamMetadata_Application *block2, uint32_t block_length) { FLAC__ASSERT(block1 != NULL); FLAC__ASSERT(block2 != NULL); @@ -731,7 +731,7 @@ static FLAC__bool compare_block_data_application_(const FLAC__StreamMetadata_App static FLAC__bool compare_block_data_seektable_(const FLAC__StreamMetadata_SeekTable *block1, const FLAC__StreamMetadata_SeekTable *block2) { - unsigned i; + uint32_t i; FLAC__ASSERT(block1 != NULL); FLAC__ASSERT(block2 != NULL); @@ -756,7 +756,7 @@ static FLAC__bool compare_block_data_seektable_(const FLAC__StreamMetadata_SeekT static FLAC__bool compare_block_data_vorbiscomment_(const FLAC__StreamMetadata_VorbisComment *block1, const FLAC__StreamMetadata_VorbisComment *block2) { - unsigned i; + uint32_t i; if (block1->vendor_string.length != block2->vendor_string.length) return false; @@ -784,7 +784,7 @@ static FLAC__bool compare_block_data_vorbiscomment_(const FLAC__StreamMetadata_V static FLAC__bool compare_block_data_cuesheet_(const FLAC__StreamMetadata_CueSheet *block1, const FLAC__StreamMetadata_CueSheet *block2) { - unsigned i, j; + uint32_t i, j; if (strcmp(block1->media_catalog_number, block2->media_catalog_number) != 0) return false; @@ -854,7 +854,7 @@ static FLAC__bool compare_block_data_picture_(const FLAC__StreamMetadata_Picture return true; } -static FLAC__bool compare_block_data_unknown_(const FLAC__StreamMetadata_Unknown *block1, const FLAC__StreamMetadata_Unknown *block2, unsigned block_length) +static FLAC__bool compare_block_data_unknown_(const FLAC__StreamMetadata_Unknown *block1, const FLAC__StreamMetadata_Unknown *block2, uint32_t block_length) { FLAC__ASSERT(block1 != NULL); FLAC__ASSERT(block2 != NULL); @@ -899,7 +899,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *b } } -FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, unsigned length, FLAC__bool copy) +FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, uint32_t length, FLAC__bool copy) { FLAC__byte *save; @@ -924,7 +924,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetad return true; } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, unsigned new_num_points) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, uint32_t new_num_points) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -955,7 +955,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMe /* if growing, set new elements to placeholders */ if (new_size > old_size) { - unsigned i; + uint32_t i; for (i = object->data.seek_table.num_points; i < new_num_points; i++) { object->data.seek_table.points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER; object->data.seek_table.points[i].stream_offset = 0; @@ -970,7 +970,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMe return true; } -FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point) +FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -979,7 +979,7 @@ FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *ob object->data.seek_table.points[point_num] = point; } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, uint32_t point_num, FLAC__StreamMetadata_SeekPoint point) { int i; @@ -999,9 +999,9 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMet return true; } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, unsigned point_num) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, uint32_t point_num) { - unsigned i; + uint32_t i; FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -1022,7 +1022,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamM return FLAC__format_seektable_is_legal(&object->data.seek_table); } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, unsigned num) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, uint32_t num) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -1053,7 +1053,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__ return true; } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], unsigned num) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], uint32_t num) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -1061,7 +1061,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC_ if (num > 0) { FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table; - unsigned i, j; + uint32_t i, j; i = seek_table->num_points; @@ -1078,7 +1078,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC_ return true; } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, uint32_t num, FLAC__uint64 total_samples) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -1086,7 +1086,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point if (num > 0 && total_samples > 0) { FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table; - unsigned i, j; + uint32_t i, j; i = seek_table->num_points; @@ -1103,7 +1103,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point return true; } -FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, unsigned samples, FLAC__uint64 total_samples) +FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, uint32_t samples, FLAC__uint64 total_samples) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -1112,7 +1112,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point if (samples > 0 && total_samples > 0) { FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table; - unsigned i, j; + uint32_t i, j; FLAC__uint64 num, sample; num = 1 + total_samples / samples; /* 1+ for the first sample at 0 */ @@ -1129,7 +1129,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point i = seek_table->num_points; - if (!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + (unsigned)num)) + if (!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + (uint32_t)num)) return false; sample = 0; @@ -1145,7 +1145,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_point FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact) { - unsigned unique; + uint32_t unique; FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE); @@ -1162,7 +1162,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__ return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.vendor_string, &entry, copy); } -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments) +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, uint32_t new_num_comments) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); @@ -1186,7 +1186,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__St /* if shrinking, free the truncated entries */ if (new_num_comments < object->data.vorbis_comment.num_comments) { - unsigned i; + uint32_t i; for (i = new_num_comments; i < object->data.vorbis_comment.num_comments; i++) if (object->data.vorbis_comment.comments[i].entry != NULL) free(object->data.vorbis_comment.comments[i].entry); @@ -1216,7 +1216,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__St return true; } -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(comment_num < object->data.vorbis_comment.num_comments); @@ -1226,7 +1226,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__Stream return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.comments[comment_num], &entry, copy); } -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, uint32_t comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy) { FLAC__StreamMetadata_VorbisComment *vc; @@ -1276,7 +1276,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__St i = vorbiscomment_find_entry_from_(object, 0, (const char *)entry.entry, field_name_length); if (i >= 0) { - unsigned indx = (unsigned)i; + uint32_t indx = (uint32_t)i; if (!FLAC__metadata_object_vorbiscomment_set_comment(object, indx, entry, copy)) return false; entry = object->data.vorbis_comment.comments[indx]; @@ -1284,7 +1284,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__St if (all && indx < object->data.vorbis_comment.num_comments) { i = vorbiscomment_find_entry_from_(object, indx, (const char *)entry.entry, field_name_length); while (i >= 0) { - indx = (unsigned)i; + indx = (uint32_t)i; if (!FLAC__metadata_object_vorbiscomment_delete_comment(object, indx)) return false; if (indx < object->data.vorbis_comment.num_comments) @@ -1300,7 +1300,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__St } } -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num) +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, uint32_t comment_num) { FLAC__StreamMetadata_VorbisComment *vc; @@ -1329,7 +1329,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pa if (!FLAC__format_vorbiscomment_entry_name_is_legal(field_name)) return false; - if (!FLAC__format_vorbiscomment_entry_value_is_legal((const FLAC__byte *)field_value, (unsigned)(-1))) + if (!FLAC__format_vorbiscomment_entry_value_is_legal((const FLAC__byte *)field_value, (uint32_t)(-1))) return false; { @@ -1378,16 +1378,16 @@ FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair return true; } -FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, unsigned field_name_length) +FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, uint32_t field_name_length) { FLAC__ASSERT(entry.entry != NULL && entry.length > 0); { const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length); - return (eq != NULL && (unsigned)(eq-entry.entry) == field_name_length && FLAC__STRNCASECMP(field_name, (const char *)entry.entry, field_name_length) == 0); + return (eq != NULL && (uint32_t)(eq-entry.entry) == field_name_length && FLAC__STRNCASECMP(field_name, (const char *)entry.entry, field_name_length) == 0); } } -FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name) +FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, uint32_t offset, const char *field_name) { FLAC__ASSERT(field_name != NULL); @@ -1396,8 +1396,8 @@ FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__Str FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name) { - const unsigned field_name_length = strlen(field_name); - unsigned i; + const uint32_t field_name_length = strlen(field_name); + uint32_t i; FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); @@ -1417,8 +1417,8 @@ FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__Str FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name) { FLAC__bool ok = true; - unsigned matching = 0; - const unsigned field_name_length = strlen(field_name); + uint32_t matching = 0; + const uint32_t field_name_length = strlen(field_name); int i; FLAC__ASSERT(object != NULL); @@ -1428,7 +1428,7 @@ FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__S for (i = (int)object->data.vorbis_comment.num_comments - 1; ok && i >= 0; i--) { if (FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length)) { matching++; - ok &= FLAC__metadata_object_vorbiscomment_delete_comment(object, (unsigned)i); + ok &= FLAC__metadata_object_vorbiscomment_delete_comment(object, (uint32_t)i); } } @@ -1472,7 +1472,7 @@ FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_C free(object); } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, unsigned track_num, unsigned new_num_indices) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t new_num_indices) { FLAC__StreamMetadata_CueSheet_Track *track; FLAC__ASSERT(object != NULL); @@ -1516,7 +1516,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__St return true; } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num, FLAC__StreamMetadata_CueSheet_Index indx) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num, FLAC__StreamMetadata_CueSheet_Index indx) { FLAC__StreamMetadata_CueSheet_Track *track; @@ -1538,14 +1538,14 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__Stre return true; } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num) { FLAC__StreamMetadata_CueSheet_Index indx; memset(&indx, 0, sizeof(indx)); return FLAC__metadata_object_cuesheet_track_insert_index(object, track_num, index_num, indx); } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, uint32_t track_num, uint32_t index_num) { FLAC__StreamMetadata_CueSheet_Track *track; @@ -1564,7 +1564,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__Stre return true; } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, unsigned new_num_tracks) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, uint32_t new_num_tracks) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET); @@ -1588,7 +1588,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMet /* if shrinking, free the truncated entries */ if (new_num_tracks < object->data.cue_sheet.num_tracks) { - unsigned i; + uint32_t i; for (i = new_num_tracks; i < object->data.cue_sheet.num_tracks; i++) free(object->data.cue_sheet.tracks[i].indices); } @@ -1611,7 +1611,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMet return true; } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy) { FLAC__ASSERT(object != NULL); FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks); @@ -1619,7 +1619,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadat return cuesheet_set_track_(object, object->data.cue_sheet.tracks + track_num, track, copy); } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, uint32_t track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy) { FLAC__StreamMetadata_CueSheet *cs; @@ -1640,14 +1640,14 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMeta return FLAC__metadata_object_cuesheet_set_track(object, track_num, track, copy); } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, unsigned track_num) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, uint32_t track_num) { FLAC__StreamMetadata_CueSheet_Track track; memset(&track, 0, sizeof(track)); return FLAC__metadata_object_cuesheet_insert_track(object, track_num, &track, /*copy=*/false); } -FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, unsigned track_num) +FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, uint32_t track_num) { FLAC__StreamMetadata_CueSheet *cs; @@ -1676,7 +1676,7 @@ FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMe return FLAC__format_cuesheet_is_legal(&object->data.cue_sheet, check_cd_da_subset, violation); } -static FLAC__uint64 get_index_01_offset_(const FLAC__StreamMetadata_CueSheet *cs, unsigned track) +static FLAC__uint64 get_index_01_offset_(const FLAC__StreamMetadata_CueSheet *cs, uint32_t track) { if (track >= (cs->num_tracks-1) || cs->tracks[track].num_indices < 1) return 0; diff --git a/src/libFLAC/ogg_decoder_aspect.c b/src/libFLAC/ogg_decoder_aspect.c index 40cee19c..44f39219 100644 --- a/src/libFLAC/ogg_decoder_aspect.c +++ b/src/libFLAC/ogg_decoder_aspect.c @@ -161,7 +161,7 @@ FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper( /* if it is the first header packet, check for magic and a supported Ogg FLAC mapping version */ if (aspect->working_packet.bytes > 0 && aspect->working_packet.packet[0] == FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE) { const FLAC__byte *b = aspect->working_packet.packet; - const unsigned header_length = + const uint32_t header_length = FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH + FLAC__OGG_MAPPING_MAGIC_LENGTH + FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH + @@ -173,9 +173,9 @@ FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper( if (memcmp(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH)) return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC; b += FLAC__OGG_MAPPING_MAGIC_LENGTH; - aspect->version_major = (unsigned)(*b); + aspect->version_major = (uint32_t)(*b); b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH; - aspect->version_minor = (unsigned)(*b); + aspect->version_minor = (uint32_t)(*b); if (aspect->version_major != 1) return FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION; aspect->working_packet.packet += header_length; diff --git a/src/libFLAC/ogg_encoder_aspect.c b/src/libFLAC/ogg_encoder_aspect.c index ebd4614b..a655da93 100644 --- a/src/libFLAC/ogg_encoder_aspect.c +++ b/src/libFLAC/ogg_encoder_aspect.c @@ -72,7 +72,7 @@ void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, aspect->serial_number = value; } -FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, unsigned value) +FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, uint32_t value) { if(value < (1u << FLAC__OGG_MAPPING_NUM_HEADERS_LEN)) { aspect->num_metadata = value; @@ -109,7 +109,7 @@ void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect) * separate write callback for the fLaC magic, and then separate write * callbacks for each metadata block and audio frame. */ -FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data) +FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data) { /* WATCHOUT: * This depends on the behavior of FLAC__StreamEncoder that 'samples' @@ -170,14 +170,14 @@ FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(F /* add STREAMINFO */ memcpy(b, buffer, bytes); FLAC__ASSERT(b + bytes - synthetic_first_packet_body == sizeof(synthetic_first_packet_body)); - packet.packet = (unsigned char *)synthetic_first_packet_body; + packet.packet = (uint8_t *)synthetic_first_packet_body; packet.bytes = sizeof(synthetic_first_packet_body); packet.b_o_s = 1; aspect->is_first_packet = false; } else { - packet.packet = (unsigned char *)buffer; + packet.packet = (uint8_t *)buffer; packet.bytes = bytes; } diff --git a/src/libFLAC/ogg_helper.c b/src/libFLAC/ogg_helper.c index 7ca9160b..cbe5bc61 100644 --- a/src/libFLAC/ogg_helper.c +++ b/src/libFLAC/ogg_helper.c @@ -94,8 +94,8 @@ void simple_ogg_page__clear(ogg_page *page) FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data) { - static const unsigned OGG_HEADER_FIXED_PORTION_LEN = 27; - static const unsigned OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255; + static const uint32_t OGG_HEADER_FIXED_PORTION_LEN = 27; + static const uint32_t OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255; FLAC__byte crc[4]; FLAC__StreamEncoderSeekStatus seek_status; @@ -142,10 +142,10 @@ FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 po return false; { - unsigned i; + uint32_t i; /* check to see that it specifies a single packet */ - for(i = 0; i < (unsigned)page->header[26] - 1; i++) { + for(i = 0; i < (uint32_t)page->header[26] - 1; i++) { if(page->header[i + OGG_HEADER_FIXED_PORTION_LEN] != 255) { encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; return false; diff --git a/src/libFLAC/ogg_mapping.c b/src/libFLAC/ogg_mapping.c index 08fa5146..f6de6009 100644 --- a/src/libFLAC/ogg_mapping.c +++ b/src/libFLAC/ogg_mapping.c @@ -36,13 +36,13 @@ #include "private/ogg_mapping.h" -const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */ +const uint32_t FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */ const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE = 0x7f; const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC = (const FLAC__byte * const)"FLAC"; -const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */ -const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */ +const uint32_t FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */ +const uint32_t FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */ -const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */ +const uint32_t FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */ diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c index d364b0ce..2e1fdd5b 100644 --- a/src/libFLAC/stream_decoder.c +++ b/src/libFLAC/stream_decoder.c @@ -75,25 +75,25 @@ static const FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' }; static void set_defaults_(FLAC__StreamDecoder *decoder); static FILE *get_binary_stdin_(void); -static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels); +static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels); static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id); static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder); static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder); -static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length); -static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length); -static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, unsigned length); +static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length); +static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length); +static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length); static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj); static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj); static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder); static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder); static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode); static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder); -static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode); -static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode); -static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended); +static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode); +static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode); +static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended); static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder); static FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data); #if FLAC__HAS_OGG @@ -129,18 +129,18 @@ typedef struct FLAC__StreamDecoderPrivate { FLAC__StreamDecoderMetadataCallback metadata_callback; FLAC__StreamDecoderErrorCallback error_callback; /* generic 32-bit datapath: */ - void (*local_lpc_restore_signal)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + void (*local_lpc_restore_signal)(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); /* generic 64-bit datapath: */ - void (*local_lpc_restore_signal_64bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + void (*local_lpc_restore_signal_64bit)(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); /* for use when the signal is <= 16 bits-per-sample, or <= 15 bits-per-sample on a side channel (which requires 1 extra bit): */ - void (*local_lpc_restore_signal_16bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]); + void (*local_lpc_restore_signal_16bit)(const FLAC__int32 residual[], uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 data[]); void *client_data; FILE *file; /* only used if FLAC__stream_decoder_init_file()/FLAC__stream_decoder_init_file() called, else NULL */ FLAC__BitReader *input; FLAC__int32 *output[FLAC__MAX_CHANNELS]; FLAC__int32 *residual[FLAC__MAX_CHANNELS]; /* WATCHOUT: these are the aligned pointers; the real pointers that should be free()'d are residual_unaligned[] below */ FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents[FLAC__MAX_CHANNELS]; - unsigned output_capacity, output_channels; + uint32_t output_capacity, output_channels; FLAC__uint32 fixed_block_size, next_fixed_block_size; FLAC__uint64 samples_decoded; FLAC__bool has_stream_info, has_seek_table; @@ -165,7 +165,7 @@ typedef struct FLAC__StreamDecoderPrivate { FLAC__Frame last_frame; /* holds the info of the last frame we seeked to */ FLAC__uint64 first_frame_offset; /* hint to the seek routine of where in the stream the first audio frame starts */ FLAC__uint64 target_sample; - unsigned unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */ + uint32_t unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */ FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */ } FLAC__StreamDecoderPrivate; @@ -241,7 +241,7 @@ FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[] = { FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void) { FLAC__StreamDecoder *decoder; - unsigned i; + uint32_t i; FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */ @@ -303,7 +303,7 @@ FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void) FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder) { - unsigned i; + uint32_t i; if (decoder == NULL) return ; @@ -629,7 +629,7 @@ FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file( FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder) { FLAC__bool md5_failed = false; - unsigned i; + uint32_t i; FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->private_); @@ -723,9 +723,9 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecode FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->private_); FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT((unsigned)type <= FLAC__MAX_METADATA_TYPE_CODE); + FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE); /* double protection */ - if((unsigned)type > FLAC__MAX_METADATA_TYPE_CODE) + if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE) return false; if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) return false; @@ -765,7 +765,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder) { - unsigned i; + uint32_t i; FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->private_); FLAC__ASSERT(0 != decoder->protected_); @@ -782,9 +782,9 @@ FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->private_); FLAC__ASSERT(0 != decoder->protected_); - FLAC__ASSERT((unsigned)type <= FLAC__MAX_METADATA_TYPE_CODE); + FLAC__ASSERT((uint32_t)type <= FLAC__MAX_METADATA_TYPE_CODE); /* double protection */ - if((unsigned)type > FLAC__MAX_METADATA_TYPE_CODE) + if((uint32_t)type > FLAC__MAX_METADATA_TYPE_CODE) return false; if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED) return false; @@ -860,7 +860,7 @@ FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamD return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_samples : 0; } -FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) +FLAC_API uint32_t FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder) { FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->protected_); @@ -874,21 +874,21 @@ FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(con return decoder->protected_->channel_assignment; } -FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) +FLAC_API uint32_t FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder) { FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->protected_); return decoder->protected_->bits_per_sample; } -FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) +FLAC_API uint32_t FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder) { FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->protected_); return decoder->protected_->sample_rate; } -FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) +FLAC_API uint32_t FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder) { FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->protected_); @@ -1204,7 +1204,7 @@ FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *deco * ***********************************************************************/ -unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) +uint32_t FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder) { FLAC__ASSERT(0 != decoder); FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); @@ -1263,9 +1263,9 @@ FILE *get_binary_stdin_(void) return stdin; } -FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels) +FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, uint32_t size, uint32_t channels) { - unsigned i; + uint32_t i; FLAC__int32 *tmp; if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels) @@ -1328,7 +1328,7 @@ FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id) FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder) { FLAC__uint32 x; - unsigned i, id; + uint32_t i, id; FLAC__bool first = true; FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); @@ -1430,7 +1430,7 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) } else { FLAC__bool skip_it = !decoder->private_->metadata_filter[type]; - unsigned real_length = length; + uint32_t real_length = length; FLAC__StreamMetadata block; memset(&block, 0, sizeof(block)); @@ -1568,10 +1568,10 @@ FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder) return true; } -FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length) +FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length) { FLAC__uint32 x; - unsigned bits, used_bits = 0; + uint32_t bits, used_bits = 0; FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); @@ -1639,7 +1639,7 @@ FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is return true; } -FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length) +FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, uint32_t length) { FLAC__uint32 i, x; FLAC__uint64 xx; @@ -1681,7 +1681,7 @@ FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_ return true; } -FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, unsigned length) +FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj, uint32_t length) { FLAC__uint32 i; @@ -1938,7 +1938,7 @@ FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMeta FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder) { FLAC__uint32 x; - unsigned i, skip; + uint32_t i, skip; /* skip the version and flags bytes */ if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24)) @@ -2014,10 +2014,10 @@ FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder) FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode) { - unsigned channel; - unsigned i; + uint32_t channel; + uint32_t i; FLAC__int32 mid, side; - unsigned frame_crc; /* the one we calculate from the input stream */ + uint32_t frame_crc; /* the one we calculate from the input stream */ FLAC__uint32 x; *got_a_frame = false; @@ -2038,7 +2038,7 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL /* * first figure the correct bits-per-sample of the subframe */ - unsigned bps = decoder->private_->frame.header.bits_per_sample; + uint32_t bps = decoder->private_->frame.header.bits_per_sample; switch(decoder->private_->frame.header.channel_assignment) { case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT: /* no adjustment needed */ @@ -2163,9 +2163,9 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) { FLAC__uint32 x; FLAC__uint64 xx; - unsigned i, blocksize_hint = 0, sample_rate_hint = 0; + uint32_t i, blocksize_hint = 0, sample_rate_hint = 0; FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */ - unsigned raw_header_len; + uint32_t raw_header_len; FLAC__bool is_unparseable = false; FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)); @@ -2300,7 +2300,7 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) FLAC__ASSERT(0); } - x = (unsigned)(raw_header[3] >> 4); + x = (uint32_t)(raw_header[3] >> 4); if(x & 8) { decoder->private_->frame.header.channels = 2; switch(x & 7) { @@ -2319,11 +2319,11 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) } } else { - decoder->private_->frame.header.channels = (unsigned)x + 1; + decoder->private_->frame.header.channels = (uint32_t)x + 1; decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; } - switch(x = (unsigned)(raw_header[3] & 0x0e) >> 1) { + switch(x = (uint32_t)(raw_header[3] & 0x0e) >> 1) { case 0: if(decoder->private_->has_stream_info) decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.bits_per_sample; @@ -2468,11 +2468,11 @@ FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder) return true; } -FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode) +FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) { FLAC__uint32 x; FLAC__bool wasted_bits; - unsigned i; + uint32_t i; if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */ return false; /* read_callback_ sets the state for us */ @@ -2481,7 +2481,7 @@ FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsign x &= 0xfe; if(wasted_bits) { - unsigned u; + uint32_t u; if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u)) return false; /* read_callback_ sets the state for us */ decoder->private_->frame.subframes[channel].wasted_bits = u+1; @@ -2542,11 +2542,11 @@ FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsign return true; } -FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode) +FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) { FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant; FLAC__int32 x; - unsigned i; + uint32_t i; FLAC__int32 *output = decoder->private_->output[channel]; decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT; @@ -2565,12 +2565,12 @@ FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channe return true; } -FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode) +FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode) { FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed; FLAC__int32 i32; FLAC__uint32 u32; - unsigned u; + uint32_t u; decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED; @@ -2627,12 +2627,12 @@ FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, return true; } -FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode) +FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, const uint32_t order, FLAC__bool do_full_decode) { FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc; FLAC__int32 i32; FLAC__uint32 u32; - unsigned u; + uint32_t u; decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC; @@ -2722,11 +2722,11 @@ FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, un return true; } -FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode) +FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, uint32_t channel, uint32_t bps, FLAC__bool do_full_decode) { FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim; FLAC__int32 x, *residual = decoder->private_->residual[channel]; - unsigned i; + uint32_t i; decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM; @@ -2745,15 +2745,15 @@ FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channe return true; } -FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended) +FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, uint32_t predictor_order, uint32_t partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended) { FLAC__uint32 rice_parameter; int i; - unsigned partition, sample, u; - const unsigned partitions = 1u << partition_order; - const unsigned partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_order : decoder->private_->frame.header.blocksize - predictor_order; - const unsigned plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; - const unsigned pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; + uint32_t partition, sample, u; + const uint32_t partitions = 1u << partition_order; + const uint32_t partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_order : decoder->private_->frame.header.blocksize - predictor_order; + const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; + const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; /* invalid predictor and partition orders mush be handled in the callers */ FLAC__ASSERT(partition_order > 0? partition_samples >= predictor_order : decoder->private_->frame.header.blocksize >= predictor_order); @@ -2944,12 +2944,12 @@ FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder #endif decoder->private_->last_frame = *frame; /* save the frame */ if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */ - unsigned delta = (unsigned)(target_sample - this_frame_sample); + uint32_t delta = (uint32_t)(target_sample - this_frame_sample); /* kick out of seek mode */ decoder->private_->is_seeking = false; /* shift out the samples before target_sample */ if(delta > 0) { - unsigned channel; + uint32_t channel; const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS]; for(channel = 0; channel < frame->header.channels; channel++) newbuffer[channel] = buffer[channel] + delta; @@ -2995,16 +2995,16 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound, lower_bound_sample, upper_bound_sample, this_frame_sample; FLAC__int64 pos = -1; int i; - unsigned approx_bytes_per_frame; + uint32_t approx_bytes_per_frame; FLAC__bool first_seek = true; const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder); - const unsigned min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; - const unsigned max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; - const unsigned max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; - const unsigned min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; + const uint32_t min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize; + const uint32_t max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize; + const uint32_t max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize; + const uint32_t min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize; /* take these from the current frame in case they've changed mid-stream */ - unsigned channels = FLAC__stream_decoder_get_channels(decoder); - unsigned bps = FLAC__stream_decoder_get_bits_per_sample(decoder); + uint32_t channels = FLAC__stream_decoder_get_channels(decoder); + uint32_t bps = FLAC__stream_decoder_get_bits_per_sample(decoder); const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->private_->seek_table.data.seek_table : 0; /* use values from stream info if we didn't decode a frame */ @@ -3185,7 +3185,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; return false; } - approx_bytes_per_frame = (unsigned)(2 * (upper_bound - pos) / 3 + 16); + approx_bytes_per_frame = (uint32_t)(2 * (upper_bound - pos) / 3 + 16); } else { /* target_sample >= this_frame_sample + this frame's blocksize */ lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize; @@ -3193,7 +3193,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR; return false; } - approx_bytes_per_frame = (unsigned)(2 * (lower_bound - pos) / 3 + 16); + approx_bytes_per_frame = (uint32_t)(2 * (lower_bound - pos) / 3 + 16); } } @@ -3208,14 +3208,14 @@ FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint FLAC__uint64 this_frame_sample = (FLAC__uint64)0 - 1; FLAC__uint64 pos = 0; /* only initialized to avoid compiler warning */ FLAC__bool did_a_seek; - unsigned iteration = 0; + uint32_t iteration = 0; /* In the first iterations, we will calculate the target byte position * by the distance from the target sample to left_sample and * right_sample (let's call it "proportional search"). After that, we * will switch to binary search. */ - unsigned BINARY_SEARCH_AFTER_ITERATION = 2; + uint32_t BINARY_SEARCH_AFTER_ITERATION = 2; /* We will switch to a linear search once our current sample is less * than this number of samples ahead of the target sample diff --git a/src/libFLAC/stream_encoder.c b/src/libFLAC/stream_encoder.c index e1cba75e..9279c0a3 100644 --- a/src/libFLAC/stream_encoder.c +++ b/src/libFLAC/stream_encoder.c @@ -83,14 +83,14 @@ typedef struct { FLAC__int32 *data[FLAC__MAX_CHANNELS]; - unsigned size; /* of each data[] in samples */ - unsigned tail; + uint32_t size; /* of each data[] in samples */ + uint32_t tail; } verify_input_fifo; typedef struct { const FLAC__byte *data; - unsigned capacity; - unsigned bytes; + uint32_t capacity; + uint32_t bytes; } verify_output; typedef enum { @@ -102,14 +102,14 @@ typedef enum { static const struct CompressionLevels { FLAC__bool do_mid_side_stereo; FLAC__bool loose_mid_side_stereo; - unsigned max_lpc_order; - unsigned qlp_coeff_precision; + uint32_t max_lpc_order; + uint32_t qlp_coeff_precision; FLAC__bool do_qlp_coeff_prec_search; FLAC__bool do_escape_coding; FLAC__bool do_exhaustive_model_search; - unsigned min_residual_partition_order; - unsigned max_residual_partition_order; - unsigned rice_parameter_search_dist; + uint32_t min_residual_partition_order; + uint32_t max_residual_partition_order; + uint32_t rice_parameter_search_dist; const char *apodization; } compression_levels_[] = { { false, false, 0, 0, false, false, false, 0, 3, 0, "tukey(5e-1)" }, @@ -133,9 +133,9 @@ static const struct CompressionLevels { static void set_defaults_(FLAC__StreamEncoder *encoder); static void free_(FLAC__StreamEncoder *encoder); -static FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_blocksize); -static FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, unsigned samples, FLAC__bool is_last_block); -static FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, FLAC__bool is_last_block); +static FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, uint32_t new_blocksize); +static FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC__bool is_last_block); +static FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, FLAC__bool is_last_block); static void update_metadata_(const FLAC__StreamEncoder *encoder); #if FLAC__HAS_OGG static void update_ogg_metadata_(FLAC__StreamEncoder *encoder); @@ -145,118 +145,118 @@ static FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is static FLAC__bool process_subframe_( FLAC__StreamEncoder *encoder, - unsigned min_partition_order, - unsigned max_partition_order, + uint32_t min_partition_order, + uint32_t max_partition_order, const FLAC__FrameHeader *frame_header, - unsigned subframe_bps, + uint32_t subframe_bps, const FLAC__int32 integer_signal[], FLAC__Subframe *subframe[2], FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents[2], FLAC__int32 *residual[2], - unsigned *best_subframe, - unsigned *best_bits + uint32_t *best_subframe, + uint32_t *best_bits ); static FLAC__bool add_subframe_( FLAC__StreamEncoder *encoder, - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, const FLAC__Subframe *subframe, FLAC__BitWriter *frame ); -static unsigned evaluate_constant_subframe_( +static uint32_t evaluate_constant_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal, - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, FLAC__Subframe *subframe ); -static unsigned evaluate_fixed_subframe_( +static uint32_t evaluate_fixed_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned raw_bits_per_partition[], - unsigned blocksize, - unsigned subframe_bps, - unsigned order, - unsigned rice_parameter, - unsigned rice_parameter_limit, - unsigned min_partition_order, - unsigned max_partition_order, + uint32_t raw_bits_per_partition[], + uint32_t blocksize, + uint32_t subframe_bps, + uint32_t order, + uint32_t rice_parameter, + uint32_t rice_parameter_limit, + uint32_t min_partition_order, + uint32_t max_partition_order, FLAC__bool do_escape_coding, - unsigned rice_parameter_search_dist, + uint32_t rice_parameter_search_dist, FLAC__Subframe *subframe, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents ); #ifndef FLAC__INTEGER_ONLY_LIBRARY -static unsigned evaluate_lpc_subframe_( +static uint32_t evaluate_lpc_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned raw_bits_per_partition[], + uint32_t raw_bits_per_partition[], const FLAC__real lp_coeff[], - unsigned blocksize, - unsigned subframe_bps, - unsigned order, - unsigned qlp_coeff_precision, - unsigned rice_parameter, - unsigned rice_parameter_limit, - unsigned min_partition_order, - unsigned max_partition_order, + uint32_t blocksize, + uint32_t subframe_bps, + uint32_t order, + uint32_t qlp_coeff_precision, + uint32_t rice_parameter, + uint32_t rice_parameter_limit, + uint32_t min_partition_order, + uint32_t max_partition_order, FLAC__bool do_escape_coding, - unsigned rice_parameter_search_dist, + uint32_t rice_parameter_search_dist, FLAC__Subframe *subframe, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents ); #endif -static unsigned evaluate_verbatim_subframe_( +static uint32_t evaluate_verbatim_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, FLAC__Subframe *subframe ); -static unsigned find_best_partition_order_( +static uint32_t find_best_partition_order_( struct FLAC__StreamEncoderPrivate *private_, const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned raw_bits_per_partition[], - unsigned residual_samples, - unsigned predictor_order, - unsigned rice_parameter, - unsigned rice_parameter_limit, - unsigned min_partition_order, - unsigned max_partition_order, - unsigned bps, + uint32_t raw_bits_per_partition[], + uint32_t residual_samples, + uint32_t predictor_order, + uint32_t rice_parameter, + uint32_t rice_parameter_limit, + uint32_t min_partition_order, + uint32_t max_partition_order, + uint32_t bps, FLAC__bool do_escape_coding, - unsigned rice_parameter_search_dist, + uint32_t rice_parameter_search_dist, FLAC__EntropyCodingMethod *best_ecm ); static void precompute_partition_info_sums_( const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, - unsigned predictor_order, - unsigned min_partition_order, - unsigned max_partition_order, - unsigned bps + uint32_t residual_samples, + uint32_t predictor_order, + uint32_t min_partition_order, + uint32_t max_partition_order, + uint32_t bps ); static void precompute_partition_info_escapes_( const FLAC__int32 residual[], - unsigned raw_bits_per_partition[], - unsigned residual_samples, - unsigned predictor_order, - unsigned min_partition_order, - unsigned max_partition_order + uint32_t raw_bits_per_partition[], + uint32_t residual_samples, + uint32_t predictor_order, + uint32_t min_partition_order, + uint32_t max_partition_order ); static FLAC__bool set_partitioned_rice_( @@ -264,35 +264,35 @@ static FLAC__bool set_partitioned_rice_( const FLAC__int32 residual[], #endif const FLAC__uint64 abs_residual_partition_sums[], - const unsigned raw_bits_per_partition[], - const unsigned residual_samples, - const unsigned predictor_order, - const unsigned suggested_rice_parameter, - const unsigned rice_parameter_limit, - const unsigned rice_parameter_search_dist, - const unsigned partition_order, + const uint32_t raw_bits_per_partition[], + const uint32_t residual_samples, + const uint32_t predictor_order, + const uint32_t suggested_rice_parameter, + const uint32_t rice_parameter_limit, + const uint32_t rice_parameter_search_dist, + const uint32_t partition_order, const FLAC__bool search_for_escapes, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, - unsigned *bits + uint32_t *bits ); -static unsigned get_wasted_bits_(FLAC__int32 signal[], unsigned samples); +static uint32_t get_wasted_bits_(FLAC__int32 signal[], uint32_t samples); /* verify-related routines: */ static void append_to_verify_fifo_( verify_input_fifo *fifo, const FLAC__int32 * const input[], - unsigned input_offset, - unsigned channels, - unsigned wide_samples + uint32_t input_offset, + uint32_t channels, + uint32_t wide_samples ); static void append_to_verify_fifo_interleaved_( verify_input_fifo *fifo, const FLAC__int32 input[], - unsigned input_offset, - unsigned channels, - unsigned wide_samples + uint32_t input_offset, + uint32_t channels, + uint32_t wide_samples ); static FLAC__StreamDecoderReadStatus verify_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); @@ -303,7 +303,7 @@ static void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__Str static FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data); static FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data); static FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data); -static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data); +static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data); static FILE *get_binary_stdout_(void); @@ -314,7 +314,7 @@ static FILE *get_binary_stdout_(void); ***********************************************************************/ typedef struct FLAC__StreamEncoderPrivate { - unsigned input_capacity; /* current size (in samples) of the signal and residual buffers */ + uint32_t input_capacity; /* current size (in samples) of the signal and residual buffers */ FLAC__int32 *integer_signal[FLAC__MAX_CHANNELS]; /* the integer version of the input signal */ FLAC__int32 *integer_signal_mid_side[2]; /* the integer version of the mid-side input signal (stereo only) */ #ifndef FLAC__INTEGER_ONLY_LIBRARY @@ -323,8 +323,8 @@ typedef struct FLAC__StreamEncoderPrivate { FLAC__real *window[FLAC__MAX_APODIZATION_FUNCTIONS]; /* the pre-computed floating-point window for each apodization function */ FLAC__real *windowed_signal; /* the integer_signal[] * current window[] */ #endif - unsigned subframe_bps[FLAC__MAX_CHANNELS]; /* the effective bits per sample of the input signal (stream bps - wasted bits) */ - unsigned subframe_bps_mid_side[2]; /* the effective bits per sample of the mid-side input signal (stream bps - wasted bits + 0/1) */ + uint32_t subframe_bps[FLAC__MAX_CHANNELS]; /* the effective bits per sample of the input signal (stream bps - wasted bits) */ + uint32_t subframe_bps_mid_side[2]; /* the effective bits per sample of the mid-side input signal (stream bps - wasted bits + 0/1) */ FLAC__int32 *residual_workspace[FLAC__MAX_CHANNELS][2]; /* each channel has a candidate and best workspace where the subframe residual signals will be stored */ FLAC__int32 *residual_workspace_mid_side[2][2]; FLAC__Subframe subframe_workspace[FLAC__MAX_CHANNELS][2]; @@ -335,35 +335,35 @@ typedef struct FLAC__StreamEncoderPrivate { FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_workspace_mid_side[FLAC__MAX_CHANNELS][2]; FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents_workspace_ptr[FLAC__MAX_CHANNELS][2]; FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents_workspace_ptr_mid_side[FLAC__MAX_CHANNELS][2]; - unsigned best_subframe[FLAC__MAX_CHANNELS]; /* index (0 or 1) into 2nd dimension of the above workspaces */ - unsigned best_subframe_mid_side[2]; - unsigned best_subframe_bits[FLAC__MAX_CHANNELS]; /* size in bits of the best subframe for each channel */ - unsigned best_subframe_bits_mid_side[2]; + uint32_t best_subframe[FLAC__MAX_CHANNELS]; /* index (0 or 1) into 2nd dimension of the above workspaces */ + uint32_t best_subframe_mid_side[2]; + uint32_t best_subframe_bits[FLAC__MAX_CHANNELS]; /* size in bits of the best subframe for each channel */ + uint32_t best_subframe_bits_mid_side[2]; FLAC__uint64 *abs_residual_partition_sums; /* workspace where the sum of abs(candidate residual) for each partition is stored */ - unsigned *raw_bits_per_partition; /* workspace where the sum of silog2(candidate residual) for each partition is stored */ + uint32_t *raw_bits_per_partition; /* workspace where the sum of silog2(candidate residual) for each partition is stored */ FLAC__BitWriter *frame; /* the current frame being worked on */ - unsigned loose_mid_side_stereo_frames; /* rounded number of frames the encoder will use before trying both independent and mid/side frames again */ - unsigned loose_mid_side_stereo_frame_count; /* number of frames using the current channel assignment */ + uint32_t loose_mid_side_stereo_frames; /* rounded number of frames the encoder will use before trying both independent and mid/side frames again */ + uint32_t loose_mid_side_stereo_frame_count; /* number of frames using the current channel assignment */ FLAC__ChannelAssignment last_channel_assignment; FLAC__StreamMetadata streaminfo; /* scratchpad for STREAMINFO as it is built */ FLAC__StreamMetadata_SeekTable *seek_table; /* pointer into encoder->protected_->metadata_ where the seek table is */ - unsigned current_sample_number; - unsigned current_frame_number; + uint32_t current_sample_number; + uint32_t current_frame_number; FLAC__MD5Context md5context; FLAC__CPUInfo cpuinfo; - void (*local_precompute_partition_info_sums)(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps); + void (*local_precompute_partition_info_sums)(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps); #ifndef FLAC__INTEGER_ONLY_LIBRARY - unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - unsigned (*local_fixed_compute_best_predictor_wide)(const FLAC__int32 data[], unsigned data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); + uint32_t (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); + uint32_t (*local_fixed_compute_best_predictor_wide)(const FLAC__int32 data[], uint32_t data_len, float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); #else - unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); - unsigned (*local_fixed_compute_best_predictor_wide)(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); + uint32_t (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); + uint32_t (*local_fixed_compute_best_predictor_wide)(const FLAC__int32 data[], uint32_t data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]); #endif #ifndef FLAC__INTEGER_ONLY_LIBRARY - void (*local_lpc_compute_autocorrelation)(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]); - void (*local_lpc_compute_residual_from_qlp_coefficients)(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); - void (*local_lpc_compute_residual_from_qlp_coefficients_64bit)(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); - void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]); + void (*local_lpc_compute_autocorrelation)(const FLAC__real data[], uint32_t data_len, uint32_t lag, FLAC__real autoc[]); + void (*local_lpc_compute_residual_from_qlp_coefficients)(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); + void (*local_lpc_compute_residual_from_qlp_coefficients_64bit)(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); + void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const FLAC__int32 *data, uint32_t data_len, const FLAC__int32 qlp_coeff[], uint32_t order, int lp_quantization, FLAC__int32 residual[]); #endif FLAC__bool disable_constant_subframes; FLAC__bool disable_fixed_subframes; @@ -376,12 +376,12 @@ typedef struct FLAC__StreamEncoderPrivate { FLAC__StreamEncoderMetadataCallback metadata_callback; FLAC__StreamEncoderProgressCallback progress_callback; void *client_data; - unsigned first_seekpoint_to_check; + uint32_t first_seekpoint_to_check; FILE *file; /* only used when encoding to a file */ FLAC__uint64 bytes_written; FLAC__uint64 samples_written; - unsigned frames_written; - unsigned total_frames_estimate; + uint32_t frames_written; + uint32_t total_frames_estimate; /* unaligned (original) pointers to allocated data */ FLAC__int32 *integer_signal_unaligned[FLAC__MAX_CHANNELS]; FLAC__int32 *integer_signal_mid_side_unaligned[2]; @@ -394,7 +394,7 @@ typedef struct FLAC__StreamEncoderPrivate { FLAC__int32 *residual_workspace_unaligned[FLAC__MAX_CHANNELS][2]; FLAC__int32 *residual_workspace_mid_side_unaligned[2][2]; FLAC__uint64 *abs_residual_partition_sums_unaligned; - unsigned *raw_bits_per_partition_unaligned; + uint32_t *raw_bits_per_partition_unaligned; /* * These fields have been moved here from private function local * declarations merely to save stack space during encoding. @@ -414,9 +414,9 @@ typedef struct FLAC__StreamEncoderPrivate { verify_output output; struct { FLAC__uint64 absolute_sample; - unsigned frame_number; - unsigned channel; - unsigned sample; + uint32_t frame_number; + uint32_t channel; + uint32_t sample; FLAC__int32 expected; FLAC__int32 got; } error_stats; @@ -494,7 +494,7 @@ FLAC_API const char * const FLAC__StreamEncoderTellStatusString[] = { * WATCHOUT: some parts of the code assert that OVERREAD_ == 1 and there's * not really any reason to change it. */ -static const unsigned OVERREAD_ = 1; +static const uint32_t OVERREAD_ = 1; /*********************************************************************** * @@ -504,7 +504,7 @@ static const unsigned OVERREAD_ = 1; FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void) { FLAC__StreamEncoder *encoder; - unsigned i; + uint32_t i; FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */ @@ -575,7 +575,7 @@ FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void) FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder) { - unsigned i; + uint32_t i; if (encoder == NULL) return ; @@ -625,7 +625,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( FLAC__bool is_ogg ) { - unsigned i; + uint32_t i; FLAC__bool metadata_has_seektable, metadata_has_vorbis_comment, metadata_picture_has_type1, metadata_picture_has_type2; FLAC__ASSERT(0 != encoder); @@ -743,7 +743,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( #if FLAC__HAS_OGG /* reorder metadata if necessary to ensure that any VORBIS_COMMENT is the first, according to the mapping spec */ if(is_ogg && 0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 1) { - unsigned i1; + uint32_t i1; for(i1 = 1; i1 < encoder->protected_->num_metadata_blocks; i1++) { if(0 != encoder->protected_->metadata[i1] && encoder->protected_->metadata[i1]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { FLAC__StreamMetadata *vc = encoder->protected_->metadata[i1]; @@ -757,7 +757,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( #endif /* keep track of any SEEKTABLE block */ if(0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0) { - unsigned i2; + uint32_t i2; for(i2 = 0; i2 < encoder->protected_->num_metadata_blocks; i2++) { if(0 != encoder->protected_->metadata[i2] && encoder->protected_->metadata[i2]->type == FLAC__METADATA_TYPE_SEEKTABLE) { encoder->private_->seek_table = &encoder->protected_->metadata[i2]->data.seek_table; @@ -850,7 +850,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( encoder->private_->abs_residual_partition_sums_unaligned = encoder->private_->abs_residual_partition_sums = 0; encoder->private_->raw_bits_per_partition_unaligned = encoder->private_->raw_bits_per_partition = 0; #ifndef FLAC__INTEGER_ONLY_LIBRARY - encoder->private_->loose_mid_side_stereo_frames = (unsigned)((double)encoder->protected_->sample_rate * 0.4 / (double)encoder->protected_->blocksize + 0.5); + encoder->private_->loose_mid_side_stereo_frames = (uint32_t)((double)encoder->protected_->sample_rate * 0.4 / (double)encoder->protected_->blocksize + 0.5); #else /* 26214 is the approximate fixed-point equivalent to 0.4 (0.4 * 2^16) */ /* sample rate can be up to 655350 Hz, and thus use 20 bits, so we do the multiply÷ by hand */ @@ -858,7 +858,7 @@ static FLAC__StreamEncoderInitStatus init_stream_internal_( FLAC__ASSERT(FLAC__MAX_BLOCK_SIZE <= 65535); FLAC__ASSERT(encoder->protected_->sample_rate <= 655350); FLAC__ASSERT(encoder->protected_->blocksize <= 65535); - encoder->private_->loose_mid_side_stereo_frames = (unsigned)FLAC__fixedpoint_trunc((((FLAC__uint64)(encoder->protected_->sample_rate) * (FLAC__uint64)(26214)) << 16) / (encoder->protected_->blocksize<<16) + FLAC__FP_ONE_HALF); + encoder->private_->loose_mid_side_stereo_frames = (uint32_t)FLAC__fixedpoint_trunc((((FLAC__uint64)(encoder->protected_->sample_rate) * (FLAC__uint64)(26214)) << 16) / (encoder->protected_->blocksize<<16) + FLAC__FP_ONE_HALF); #endif if(encoder->private_->loose_mid_side_stereo_frames == 0) encoder->private_->loose_mid_side_stereo_frames = 1; @@ -1356,10 +1356,10 @@ static FLAC__StreamEncoderInitStatus init_FILE_internal_( } { - unsigned blocksize = FLAC__stream_encoder_get_blocksize(encoder); + uint32_t blocksize = FLAC__stream_encoder_get_blocksize(encoder); FLAC__ASSERT(blocksize != 0); - encoder->private_->total_frames_estimate = (unsigned)((FLAC__stream_encoder_get_total_samples_estimate(encoder) + blocksize - 1) / blocksize); + encoder->private_->total_frames_estimate = (uint32_t)((FLAC__stream_encoder_get_total_samples_estimate(encoder) + blocksize - 1) / blocksize); } return init_status; @@ -1555,7 +1555,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1566,7 +1566,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encod return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1577,7 +1577,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1588,7 +1588,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *en return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__bool ok = true; FLAC__ASSERT(0 != encoder); @@ -1621,7 +1621,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncod return ok; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1768,7 +1768,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *en return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1779,7 +1779,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder * return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1828,7 +1828,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__St return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1839,7 +1839,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__ return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1850,7 +1850,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__ return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value) +FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, uint32_t value) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1878,7 +1878,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__Stream return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks) +FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, uint32_t num_blocks) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -1977,7 +1977,7 @@ FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__ return FLAC__stream_decoder_get_resolved_state_string(encoder->private_->verify.decoder); } -FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got) +FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, uint32_t *frame_number, uint32_t *channel, uint32_t *sample, FLAC__int32 *expected, FLAC__int32 *got) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2020,7 +2020,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *e return encoder->protected_->do_md5; } -FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2028,7 +2028,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *e return encoder->protected_->channels; } -FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2036,7 +2036,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEnc return encoder->protected_->bits_per_sample; } -FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2044,7 +2044,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder return encoder->protected_->sample_rate; } -FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2068,7 +2068,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__S return encoder->protected_->loose_mid_side_stereo; } -FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2076,7 +2076,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncod return encoder->protected_->max_lpc_order; } -FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2108,7 +2108,7 @@ FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FL return encoder->protected_->do_exhaustive_model_search; } -FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2116,7 +2116,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FL return encoder->protected_->min_residual_partition_order; } -FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2124,7 +2124,7 @@ FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FL return encoder->protected_->max_residual_partition_order; } -FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder) +FLAC_API uint32_t FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder) { FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2140,10 +2140,10 @@ FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC return encoder->protected_->total_samples_estimate; } -FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples) +FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], uint32_t samples) { - unsigned i, j = 0, channel; - const unsigned channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; + uint32_t i, j = 0, channel; + const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2151,7 +2151,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 = flac_min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j); + const uint32_t 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); @@ -2196,11 +2196,11 @@ FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, c return true; } -FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples) +FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], uint32_t samples) { - unsigned i, j, k, channel; + uint32_t i, j, k, channel; FLAC__int32 x, mid, side; - const unsigned channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; + const uint32_t channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize; FLAC__ASSERT(0 != encoder); FLAC__ASSERT(0 != encoder->private_); @@ -2340,7 +2340,7 @@ void set_defaults_(FLAC__StreamEncoder *encoder) void free_(FLAC__StreamEncoder *encoder) { - unsigned i, channel; + uint32_t i, channel; FLAC__ASSERT(0 != encoder); if(encoder->protected_->metadata) { @@ -2419,10 +2419,10 @@ void free_(FLAC__StreamEncoder *encoder) FLAC__bitwriter_free(encoder->private_->frame); } -FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_blocksize) +FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, uint32_t new_blocksize) { FLAC__bool ok; - unsigned i, channel; + uint32_t i, channel; FLAC__ASSERT(new_blocksize > 0); FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK); @@ -2559,7 +2559,7 @@ FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_blocksize) return ok; } -FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, unsigned samples, FLAC__bool is_last_block) +FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, uint32_t samples, FLAC__bool is_last_block) { const FLAC__byte *buffer; size_t bytes; @@ -2606,7 +2606,7 @@ FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, unsigned samples, FLAC return true; } -FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, FLAC__bool is_last_block) +FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, FLAC__bool is_last_block) { FLAC__StreamEncoderWriteStatus status; FLAC__uint64 output_position = 0; @@ -2638,11 +2638,11 @@ FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const * frame yet) */ if(0 != encoder->private_->seek_table && encoder->protected_->audio_offset > 0 && encoder->private_->seek_table->num_points > 0) { - const unsigned blocksize = FLAC__stream_encoder_get_blocksize(encoder); + const uint32_t blocksize = FLAC__stream_encoder_get_blocksize(encoder); const FLAC__uint64 frame_first_sample = encoder->private_->samples_written; const FLAC__uint64 frame_last_sample = frame_first_sample + (FLAC__uint64)blocksize - 1; FLAC__uint64 test_sample; - unsigned i; + uint32_t i; for(i = encoder->private_->first_seekpoint_to_check; i < encoder->private_->seek_table->num_points; i++) { test_sample = encoder->private_->seek_table->points[i].sample_number; if(test_sample > frame_last_sample) { @@ -2705,9 +2705,9 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) 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; - const unsigned max_framesize = metadata->data.stream_info.max_framesize; - const unsigned bps = metadata->data.stream_info.bits_per_sample; + const uint32_t min_framesize = metadata->data.stream_info.min_framesize; + const uint32_t max_framesize = metadata->data.stream_info.max_framesize; + const uint32_t bps = metadata->data.stream_info.bits_per_sample; FLAC__StreamEncoderSeekStatus seek_status; FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO); @@ -2721,7 +2721,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) * Write MD5 signature */ { - const unsigned md5_offset = + const uint32_t md5_offset = FLAC__STREAM_METADATA_HEADER_LENGTH + ( FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + @@ -2749,7 +2749,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) * Write total samples */ { - const unsigned total_samples_byte_offset = + const uint32_t total_samples_byte_offset = FLAC__STREAM_METADATA_HEADER_LENGTH + ( FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + @@ -2782,7 +2782,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) * Write min/max framesize */ { - const unsigned min_framesize_offset = + const uint32_t min_framesize_offset = FLAC__STREAM_METADATA_HEADER_LENGTH + ( FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN + @@ -2810,7 +2810,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) * Write seektable */ if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) { - unsigned i; + uint32_t i; FLAC__format_seektable_sort(encoder->private_->seek_table); @@ -2824,7 +2824,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) for(i = 0; i < encoder->private_->seek_table->num_points; i++) { FLAC__uint64 xx; - unsigned x; + uint32_t x; xx = encoder->private_->seek_table->points[i].sample_number; b[7] = (FLAC__byte)xx; xx >>= 8; b[6] = (FLAC__byte)xx; xx >>= 8; @@ -2859,7 +2859,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder) void update_ogg_metadata_(FLAC__StreamEncoder *encoder) { /* the # of bytes in the 1st packet that precede the STREAMINFO */ - static const unsigned FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH = + static const uint32_t FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH = FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH + FLAC__OGG_MAPPING_MAGIC_LENGTH + FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH + @@ -2870,8 +2870,8 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) 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; - const unsigned max_framesize = metadata->data.stream_info.max_framesize; + const uint32_t min_framesize = metadata->data.stream_info.min_framesize; + const uint32_t max_framesize = metadata->data.stream_info.max_framesize; ogg_page page; FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO); @@ -2901,7 +2901,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) * Write MD5 signature */ { - const unsigned md5_offset = + const uint32_t md5_offset = FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + FLAC__STREAM_METADATA_HEADER_LENGTH + ( @@ -2915,7 +2915,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN ) / 8; - if(md5_offset + 16 > (unsigned)page.body_len) { + if(md5_offset + 16 > (uint32_t)page.body_len) { encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; simple_ogg_page__clear(&page); return; @@ -2927,7 +2927,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) * Write total samples */ { - const unsigned total_samples_byte_offset = + const uint32_t total_samples_byte_offset = FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + FLAC__STREAM_METADATA_HEADER_LENGTH + ( @@ -2941,7 +2941,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) - 4 ) / 8; - if(total_samples_byte_offset + 5 > (unsigned)page.body_len) { + if(total_samples_byte_offset + 5 > (uint32_t)page.body_len) { encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; simple_ogg_page__clear(&page); return; @@ -2959,7 +2959,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) * Write min/max framesize */ { - const unsigned min_framesize_offset = + const uint32_t min_framesize_offset = FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH + FLAC__STREAM_METADATA_HEADER_LENGTH + ( @@ -2967,7 +2967,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN ) / 8; - if(min_framesize_offset + 6 > (unsigned)page.body_len) { + if(min_framesize_offset + 6 > (uint32_t)page.body_len) { encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; simple_ogg_page__clear(&page); return; @@ -2990,7 +2990,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) * Write seektable */ if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) { - unsigned i; + uint32_t i; FLAC__byte *p; FLAC__format_seektable_sort(encoder->private_->seek_table); @@ -3003,7 +3003,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) return; /* state already set */ } - if((FLAC__STREAM_METADATA_HEADER_LENGTH + 18*encoder->private_->seek_table->num_points) != (unsigned)page.body_len) { + if((FLAC__STREAM_METADATA_HEADER_LENGTH + 18*encoder->private_->seek_table->num_points) != (uint32_t)page.body_len) { encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR; simple_ogg_page__clear(&page); return; @@ -3011,7 +3011,7 @@ void update_ogg_metadata_(FLAC__StreamEncoder *encoder) for(i = 0, p = page.body + FLAC__STREAM_METADATA_HEADER_LENGTH; i < encoder->private_->seek_table->num_points; i++, p += 18) { FLAC__uint64 xx; - unsigned x; + uint32_t x; xx = encoder->private_->seek_table->points[i].sample_number; b[7] = (FLAC__byte)xx; xx >>= 8; b[6] = (FLAC__byte)xx; xx >>= 8; @@ -3107,7 +3107,7 @@ FLAC__bool process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional_block) { FLAC__FrameHeader frame_header; - unsigned channel, min_partition_order = encoder->protected_->min_residual_partition_order, max_partition_order; + uint32_t channel, min_partition_order = encoder->protected_->min_residual_partition_order, max_partition_order; FLAC__bool do_independent, do_mid_side; /* @@ -3164,7 +3164,7 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fracti */ if(do_independent) { for(channel = 0; channel < encoder->protected_->channels; channel++) { - unsigned w = get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize); + uint32_t w = get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize); if (w > encoder->protected_->bits_per_sample) { w = encoder->protected_->bits_per_sample; } @@ -3175,7 +3175,7 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fracti if(do_mid_side) { FLAC__ASSERT(encoder->protected_->channels == 2); for(channel = 0; channel < 2; channel++) { - unsigned w = get_wasted_bits_(encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize); + uint32_t w = get_wasted_bits_(encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize); if (w > encoder->protected_->bits_per_sample) { w = encoder->protected_->bits_per_sample; } @@ -3238,7 +3238,7 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fracti * Compose the frame bitbuffer */ if(do_mid_side) { - unsigned left_bps = 0, right_bps = 0; /* initialized only to prevent superfluous compiler warning */ + uint32_t left_bps = 0, right_bps = 0; /* initialized only to prevent superfluous compiler warning */ FLAC__Subframe *left_subframe = 0, *right_subframe = 0; /* initialized only to prevent superfluous compiler warning */ FLAC__ChannelAssignment channel_assignment; @@ -3248,8 +3248,8 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fracti channel_assignment = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT? FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT : FLAC__CHANNEL_ASSIGNMENT_MID_SIDE); } else { - unsigned bits[4]; /* WATCHOUT - indexed by FLAC__ChannelAssignment */ - unsigned min_bits; + uint32_t bits[4]; /* WATCHOUT - indexed by FLAC__ChannelAssignment */ + uint32_t min_bits; int ca; FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT == 0); @@ -3356,16 +3356,16 @@ FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fracti FLAC__bool process_subframe_( FLAC__StreamEncoder *encoder, - unsigned min_partition_order, - unsigned max_partition_order, + uint32_t min_partition_order, + uint32_t max_partition_order, const FLAC__FrameHeader *frame_header, - unsigned subframe_bps, + uint32_t subframe_bps, const FLAC__int32 integer_signal[], FLAC__Subframe *subframe[2], FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents[2], FLAC__int32 *residual[2], - unsigned *best_subframe, - unsigned *best_bits + uint32_t *best_subframe, + uint32_t *best_bits ) { #ifndef FLAC__INTEGER_ONLY_LIBRARY @@ -3377,15 +3377,15 @@ FLAC__bool process_subframe_( double lpc_residual_bits_per_sample; FLAC__real autoc[FLAC__MAX_LPC_ORDER+1]; /* WATCHOUT: the size is important even though encoder->protected_->max_lpc_order might be less; some asm and x86 intrinsic routines need all the space */ double lpc_error[FLAC__MAX_LPC_ORDER]; - unsigned min_lpc_order, max_lpc_order, lpc_order; - unsigned min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision; + uint32_t min_lpc_order, max_lpc_order, lpc_order; + uint32_t min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision; #endif - unsigned min_fixed_order, max_fixed_order, guess_fixed_order, fixed_order; - unsigned rice_parameter; - unsigned _candidate_bits, _best_bits; - unsigned _best_subframe; + uint32_t min_fixed_order, max_fixed_order, guess_fixed_order, fixed_order; + uint32_t rice_parameter; + uint32_t _candidate_bits, _best_bits; + uint32_t _best_subframe; /* only use RICE2 partitions if stream bps > 16 */ - const unsigned rice_parameter_limit = FLAC__stream_encoder_get_bits_per_sample(encoder) > 16? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; + const uint32_t rice_parameter_limit = FLAC__stream_encoder_get_bits_per_sample(encoder) > 16? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; FLAC__ASSERT(frame_header->blocksize > 0); @@ -3397,7 +3397,7 @@ FLAC__bool process_subframe_( _best_bits = evaluate_verbatim_subframe_(encoder, integer_signal, frame_header->blocksize, subframe_bps, subframe[_best_subframe]); if(frame_header->blocksize >= FLAC__MAX_FIXED_ORDER) { - unsigned signal_is_constant = false; + uint32_t signal_is_constant = false; if(subframe_bps + 4 + FLAC__bitmath_ilog2((frame_header->blocksize-FLAC__MAX_FIXED_ORDER)|1) <= 32) guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor(integer_signal+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample); else @@ -3412,7 +3412,7 @@ FLAC__bool process_subframe_( #endif ) { /* the above means it's possible all samples are the same value; now double-check it: */ - unsigned i; + uint32_t i; signal_is_constant = true; for(i = 1; i < frame_header->blocksize; i++) { if(integer_signal[0] != integer_signal[i]) { @@ -3444,13 +3444,13 @@ FLAC__bool process_subframe_( #ifndef FLAC__INTEGER_ONLY_LIBRARY if(fixed_residual_bits_per_sample[fixed_order] >= (float)subframe_bps) continue; /* don't even try */ - rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > 0.0)? (unsigned)(fixed_residual_bits_per_sample[fixed_order]+0.5) : 0; /* 0.5 is for rounding */ + rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > 0.0)? (uint32_t)(fixed_residual_bits_per_sample[fixed_order]+0.5) : 0; /* 0.5 is for rounding */ #else if(FLAC__fixedpoint_trunc(fixed_residual_bits_per_sample[fixed_order]) >= (int)subframe_bps) continue; /* don't even try */ - rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > FLAC__FP_ZERO)? (unsigned)FLAC__fixedpoint_trunc(fixed_residual_bits_per_sample[fixed_order]+FLAC__FP_ONE_HALF) : 0; /* 0.5 is for rounding */ + rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > FLAC__FP_ZERO)? (uint32_t)FLAC__fixedpoint_trunc(fixed_residual_bits_per_sample[fixed_order]+FLAC__FP_ONE_HALF) : 0; /* 0.5 is for rounding */ #endif - rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */ + rice_parameter++; /* to account for the signed->uint32_t conversion during rice coding */ if(rice_parameter >= rice_parameter_limit) { #ifdef DEBUG_VERBOSE fprintf(stderr, "clipping rice_parameter (%u -> %u) @0\n", rice_parameter, rice_parameter_limit - 1); @@ -3491,7 +3491,7 @@ FLAC__bool process_subframe_( else max_lpc_order = encoder->protected_->max_lpc_order; if(max_lpc_order > 0) { - unsigned a; + uint32_t a; for (a = 0; a < encoder->protected_->num_apodizations; a++) { FLAC__lpc_window_data(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+1, autoc); @@ -3502,7 +3502,7 @@ FLAC__bool process_subframe_( min_lpc_order = 1; } else { - const unsigned guess_lpc_order = + const uint32_t guess_lpc_order = FLAC__lpc_compute_best_order( lpc_error, max_lpc_order, @@ -3521,8 +3521,8 @@ FLAC__bool process_subframe_( lpc_residual_bits_per_sample = FLAC__lpc_compute_expected_bits_per_residual_sample(lpc_error[lpc_order-1], frame_header->blocksize-lpc_order); if(lpc_residual_bits_per_sample >= (double)subframe_bps) continue; /* don't even try */ - rice_parameter = (lpc_residual_bits_per_sample > 0.0)? (unsigned)(lpc_residual_bits_per_sample+0.5) : 0; /* 0.5 is for rounding */ - rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */ + rice_parameter = (lpc_residual_bits_per_sample > 0.0)? (uint32_t)(lpc_residual_bits_per_sample+0.5) : 0; /* 0.5 is for rounding */ + rice_parameter++; /* to account for the signed->uint32_t conversion during rice coding */ if(rice_parameter >= rice_parameter_limit) { #ifdef DEBUG_VERBOSE fprintf(stderr, "clipping rice_parameter (%u -> %u) @1\n", rice_parameter, rice_parameter_limit - 1); @@ -3594,8 +3594,8 @@ FLAC__bool process_subframe_( FLAC__bool add_subframe_( FLAC__StreamEncoder *encoder, - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, const FLAC__Subframe *subframe, FLAC__BitWriter *frame ) @@ -3636,10 +3636,10 @@ FLAC__bool add_subframe_( #if SPOTCHECK_ESTIMATE static void spotcheck_subframe_estimate_( FLAC__StreamEncoder *encoder, - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, const FLAC__Subframe *subframe, - unsigned estimate + uint32_t estimate ) { FLAC__bool ret; @@ -3655,7 +3655,7 @@ static void spotcheck_subframe_estimate_( ret = add_subframe_(encoder, blocksize, subframe_bps, subframe, frame); FLAC__ASSERT(ret); { - const unsigned actual = FLAC__bitwriter_get_input_bits_unconsumed(frame); + const uint32_t actual = FLAC__bitwriter_get_input_bits_unconsumed(frame); if(estimate != actual) fprintf(stderr, "EST: bad, frame#%u sub#%%d type=%8s est=%u, actual=%u, delta=%d\n", encoder->private_->current_frame_number, FLAC__SubframeTypeString[subframe->type], estimate, actual, (int)actual-(int)estimate); } @@ -3663,15 +3663,15 @@ static void spotcheck_subframe_estimate_( } #endif -unsigned evaluate_constant_subframe_( +uint32_t evaluate_constant_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal, - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, FLAC__Subframe *subframe ) { - unsigned estimate; + uint32_t estimate; subframe->type = FLAC__SUBFRAME_TYPE_CONSTANT; subframe->data.constant.value = signal; @@ -3686,27 +3686,27 @@ unsigned evaluate_constant_subframe_( return estimate; } -unsigned evaluate_fixed_subframe_( +uint32_t evaluate_fixed_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned raw_bits_per_partition[], - unsigned blocksize, - unsigned subframe_bps, - unsigned order, - unsigned rice_parameter, - unsigned rice_parameter_limit, - unsigned min_partition_order, - unsigned max_partition_order, + uint32_t raw_bits_per_partition[], + uint32_t blocksize, + uint32_t subframe_bps, + uint32_t order, + uint32_t rice_parameter, + uint32_t rice_parameter_limit, + uint32_t min_partition_order, + uint32_t max_partition_order, FLAC__bool do_escape_coding, - unsigned rice_parameter_search_dist, + uint32_t rice_parameter_search_dist, FLAC__Subframe *subframe, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents ) { - unsigned i, residual_bits, estimate; - const unsigned residual_samples = blocksize - order; + uint32_t i, residual_bits, estimate; + const uint32_t residual_samples = blocksize - order; FLAC__fixed_compute_residual(signal+order, residual_samples, order, residual); @@ -3748,31 +3748,31 @@ unsigned evaluate_fixed_subframe_( } #ifndef FLAC__INTEGER_ONLY_LIBRARY -unsigned evaluate_lpc_subframe_( +uint32_t evaluate_lpc_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned raw_bits_per_partition[], + uint32_t raw_bits_per_partition[], const FLAC__real lp_coeff[], - unsigned blocksize, - unsigned subframe_bps, - unsigned order, - unsigned qlp_coeff_precision, - unsigned rice_parameter, - unsigned rice_parameter_limit, - unsigned min_partition_order, - unsigned max_partition_order, + uint32_t blocksize, + uint32_t subframe_bps, + uint32_t order, + uint32_t qlp_coeff_precision, + uint32_t rice_parameter, + uint32_t rice_parameter_limit, + uint32_t min_partition_order, + uint32_t max_partition_order, FLAC__bool do_escape_coding, - unsigned rice_parameter_search_dist, + uint32_t rice_parameter_search_dist, FLAC__Subframe *subframe, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents ) { FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER]; /* WATCHOUT: the size is important; some x86 intrinsic routines need more than lpc order elements */ - unsigned i, residual_bits, estimate; + uint32_t i, residual_bits, estimate; int quantization, ret; - const unsigned residual_samples = blocksize - order; + const uint32_t residual_samples = blocksize - order; /* try to keep qlp coeff precision such that only 32-bit math is required for decode of <=16bps(+1bps for side channel) streams */ if(subframe_bps <= 17) { @@ -3834,15 +3834,15 @@ unsigned evaluate_lpc_subframe_( } #endif -unsigned evaluate_verbatim_subframe_( +uint32_t evaluate_verbatim_subframe_( FLAC__StreamEncoder *encoder, const FLAC__int32 signal[], - unsigned blocksize, - unsigned subframe_bps, + uint32_t blocksize, + uint32_t subframe_bps, FLAC__Subframe *subframe ) { - unsigned estimate; + uint32_t estimate; subframe->type = FLAC__SUBFRAME_TYPE_VERBATIM; @@ -3859,27 +3859,27 @@ unsigned evaluate_verbatim_subframe_( return estimate; } -unsigned find_best_partition_order_( +uint32_t find_best_partition_order_( FLAC__StreamEncoderPrivate *private_, const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned raw_bits_per_partition[], - unsigned residual_samples, - unsigned predictor_order, - unsigned rice_parameter, - unsigned rice_parameter_limit, - unsigned min_partition_order, - unsigned max_partition_order, - unsigned bps, + uint32_t raw_bits_per_partition[], + uint32_t residual_samples, + uint32_t predictor_order, + uint32_t rice_parameter, + uint32_t rice_parameter_limit, + uint32_t min_partition_order, + uint32_t max_partition_order, + uint32_t bps, FLAC__bool do_escape_coding, - unsigned rice_parameter_search_dist, + uint32_t rice_parameter_search_dist, FLAC__EntropyCodingMethod *best_ecm ) { - unsigned residual_bits, best_residual_bits = 0; - unsigned best_parameters_index = 0; - unsigned best_partition_order = 0; - const unsigned blocksize = residual_samples + predictor_order; + uint32_t residual_bits, best_residual_bits = 0; + uint32_t best_parameters_index = 0; + uint32_t best_partition_order = 0; + const uint32_t 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 = flac_min(min_partition_order, max_partition_order); @@ -3891,7 +3891,7 @@ unsigned find_best_partition_order_( { int partition_order; - unsigned sum; + uint32_t sum; for(partition_order = (int)max_partition_order, sum = 0; partition_order >= (int)min_partition_order; partition_order--) { if(! @@ -3906,7 +3906,7 @@ unsigned find_best_partition_order_( rice_parameter, rice_parameter_limit, rice_parameter_search_dist, - (unsigned)partition_order, + (uint32_t)partition_order, do_escape_coding, &private_->partitioned_rice_contents_extra[!best_parameters_index], &residual_bits @@ -3933,13 +3933,13 @@ unsigned find_best_partition_order_( * knowledge; it is const to the outside world. */ FLAC__EntropyCodingMethod_PartitionedRiceContents* prc = (FLAC__EntropyCodingMethod_PartitionedRiceContents*)best_ecm->data.partitioned_rice.contents; - unsigned partition; + uint32_t partition; /* save best parameters and raw_bits */ 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))); + memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(uint32_t)*(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(uint32_t)*(1<<(best_partition_order))); /* * Now need to check if the type should be changed to * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the @@ -3959,22 +3959,22 @@ unsigned find_best_partition_order_( void precompute_partition_info_sums_( const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, - unsigned predictor_order, - unsigned min_partition_order, - unsigned max_partition_order, - unsigned bps + uint32_t residual_samples, + uint32_t predictor_order, + uint32_t min_partition_order, + uint32_t max_partition_order, + uint32_t bps ) { - const unsigned default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - unsigned partitions = 1u << max_partition_order; + const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; + uint32_t partitions = 1u << max_partition_order; FLAC__ASSERT(default_partition_samples > predictor_order); /* first do max_partition_order */ { - const unsigned threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - unsigned partition, residual_sample, end = (unsigned)(-(int)predictor_order); + const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); + uint32_t partition, residual_sample, end = (uint32_t)(-(int)predictor_order); /* WATCHOUT: "bps + FLAC__MAX_EXTRA_RESIDUAL_BPS" is the maximum assumed size of the average residual magnitude */ if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { for(partition = residual_sample = 0; partition < partitions; partition++) { @@ -3998,10 +3998,10 @@ void precompute_partition_info_sums_( /* now merge partitions for lower orders */ { - unsigned from_partition = 0, to_partition = partitions; + uint32_t from_partition = 0, to_partition = partitions; int partition_order; for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - unsigned i; + uint32_t i; partitions >>= 1; for(i = 0; i < partitions; i++) { abs_residual_partition_sums[to_partition++] = @@ -4015,24 +4015,24 @@ void precompute_partition_info_sums_( void precompute_partition_info_escapes_( const FLAC__int32 residual[], - unsigned raw_bits_per_partition[], - unsigned residual_samples, - unsigned predictor_order, - unsigned min_partition_order, - unsigned max_partition_order + uint32_t raw_bits_per_partition[], + uint32_t residual_samples, + uint32_t predictor_order, + uint32_t min_partition_order, + uint32_t max_partition_order ) { int partition_order; - unsigned from_partition, to_partition = 0; - const unsigned blocksize = residual_samples + predictor_order; + uint32_t from_partition, to_partition = 0; + const uint32_t blocksize = residual_samples + predictor_order; /* first do max_partition_order */ for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) { FLAC__int32 r; FLAC__uint32 rmax; - unsigned partition, partition_sample, partition_samples, residual_sample; - const unsigned partitions = 1u << partition_order; - const unsigned default_partition_samples = blocksize >> partition_order; + uint32_t partition, partition_sample, partition_samples, residual_sample; + const uint32_t partitions = 1u << partition_order; + const uint32_t default_partition_samples = blocksize >> partition_order; FLAC__ASSERT(default_partition_samples > predictor_order); @@ -4058,9 +4058,9 @@ void precompute_partition_info_escapes_( /* now merge partitions for lower orders */ for(from_partition = 0, --partition_order; partition_order >= (int)min_partition_order; partition_order--) { - unsigned m; - unsigned i; - const unsigned partitions = 1u << partition_order; + uint32_t m; + uint32_t i; + const uint32_t partitions = 1u << partition_order; for(i = 0; i < partitions; i++) { m = raw_bits_per_partition[from_partition]; from_partition++; @@ -4072,13 +4072,13 @@ void precompute_partition_info_escapes_( } #ifdef EXACT_RICE_BITS_CALCULATION -static inline unsigned count_rice_bits_in_partition_( - const unsigned rice_parameter, - const unsigned partition_samples, +static inline uint32_t count_rice_bits_in_partition_( + const uint32_t rice_parameter, + const uint32_t partition_samples, const FLAC__int32 *residual ) { - unsigned i, partition_bits = + uint32_t i, partition_bits = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */ (1+rice_parameter) * partition_samples /* 1 for unary stop bit + rice_parameter for the binary portion */ ; @@ -4087,9 +4087,9 @@ static inline unsigned count_rice_bits_in_partition_( return partition_bits; } #else -static inline unsigned count_rice_bits_in_partition_( - const unsigned rice_parameter, - const unsigned partition_samples, +static inline uint32_t count_rice_bits_in_partition_( + const uint32_t rice_parameter, + const uint32_t partition_samples, const FLAC__uint64 abs_residual_partition_sum ) { @@ -4098,8 +4098,8 @@ static inline unsigned count_rice_bits_in_partition_( (1+rice_parameter) * partition_samples + /* 1 for unary stop bit + rice_parameter for the binary portion */ ( rice_parameter? - (unsigned)(abs_residual_partition_sum >> (rice_parameter-1)) /* rice_parameter-1 because the real coder sign-folds instead of using a sign bit */ - : (unsigned)(abs_residual_partition_sum << 1) /* can't shift by negative number, so reverse */ + (uint32_t)(abs_residual_partition_sum >> (rice_parameter-1)) /* rice_parameter-1 because the real coder sign-folds instead of using a sign bit */ + : (uint32_t)(abs_residual_partition_sum << 1) /* can't shift by negative number, so reverse */ ) - (partition_samples >> 1) /* -(partition_samples>>1) to subtract out extra contributions to the abs_residual_partition_sum. @@ -4117,24 +4117,24 @@ FLAC__bool set_partitioned_rice_( const FLAC__int32 residual[], #endif const FLAC__uint64 abs_residual_partition_sums[], - const unsigned raw_bits_per_partition[], - const unsigned residual_samples, - const unsigned predictor_order, - const unsigned suggested_rice_parameter, - const unsigned rice_parameter_limit, - const unsigned rice_parameter_search_dist, - const unsigned partition_order, + const uint32_t raw_bits_per_partition[], + const uint32_t residual_samples, + const uint32_t predictor_order, + const uint32_t suggested_rice_parameter, + const uint32_t rice_parameter_limit, + const uint32_t rice_parameter_search_dist, + const uint32_t partition_order, const FLAC__bool search_for_escapes, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, - unsigned *bits + uint32_t *bits ) { - unsigned rice_parameter, partition_bits; - unsigned best_partition_bits, best_rice_parameter = 0; - unsigned bits_ = FLAC__ENTROPY_CODING_METHOD_TYPE_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; - unsigned *parameters, *raw_bits; + uint32_t rice_parameter, partition_bits; + uint32_t best_partition_bits, best_rice_parameter = 0; + uint32_t bits_ = FLAC__ENTROPY_CODING_METHOD_TYPE_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; + uint32_t *parameters, *raw_bits; #ifdef ENABLE_RICE_PARAMETER_SEARCH - unsigned min_rice_parameter, max_rice_parameter; + uint32_t min_rice_parameter, max_rice_parameter; #else (void)rice_parameter_search_dist; #endif @@ -4147,7 +4147,7 @@ FLAC__bool set_partitioned_rice_( raw_bits = partitioned_rice_contents->raw_bits; if(partition_order == 0) { - best_partition_bits = (unsigned)(-1); + best_partition_bits = (uint32_t)(-1); #ifdef ENABLE_RICE_PARAMETER_SEARCH if(rice_parameter_search_dist) { if(suggested_rice_parameter < rice_parameter_search_dist) @@ -4195,10 +4195,10 @@ FLAC__bool set_partitioned_rice_( bits_ += best_partition_bits; } else { - unsigned partition, residual_sample; - unsigned partition_samples; + uint32_t partition, residual_sample; + uint32_t partition_samples; FLAC__uint64 mean, k; - const unsigned partitions = 1u << partition_order; + const uint32_t partitions = 1u << partition_order; for(partition = residual_sample = 0; partition < partitions; partition++) { partition_samples = (residual_samples+predictor_order) >> partition_order; if(partition == 0) { @@ -4252,7 +4252,7 @@ FLAC__bool set_partitioned_rice_( rice_parameter = rice_parameter_limit - 1; } - best_partition_bits = (unsigned)(-1); + best_partition_bits = (uint32_t)(-1); #ifdef ENABLE_RICE_PARAMETER_SEARCH if(rice_parameter_search_dist) { if(rice_parameter < rice_parameter_search_dist) @@ -4304,9 +4304,9 @@ FLAC__bool set_partitioned_rice_( return true; } -unsigned get_wasted_bits_(FLAC__int32 signal[], unsigned samples) +uint32_t get_wasted_bits_(FLAC__int32 signal[], uint32_t samples) { - unsigned i, shift; + uint32_t i, shift; FLAC__int32 x = 0; for(i = 0; i < samples && !(x&1); i++) @@ -4328,9 +4328,9 @@ unsigned get_wasted_bits_(FLAC__int32 signal[], unsigned samples) return shift; } -void append_to_verify_fifo_(verify_input_fifo *fifo, const FLAC__int32 * const input[], unsigned input_offset, unsigned channels, unsigned wide_samples) +void append_to_verify_fifo_(verify_input_fifo *fifo, const FLAC__int32 * const input[], uint32_t input_offset, uint32_t channels, uint32_t wide_samples) { - unsigned channel; + uint32_t channel; for(channel = 0; channel < channels; channel++) memcpy(&fifo->data[channel][fifo->tail], &input[channel][input_offset], sizeof(FLAC__int32) * wide_samples); @@ -4340,11 +4340,11 @@ void append_to_verify_fifo_(verify_input_fifo *fifo, const FLAC__int32 * const i FLAC__ASSERT(fifo->tail <= fifo->size); } -void append_to_verify_fifo_interleaved_(verify_input_fifo *fifo, const FLAC__int32 input[], unsigned input_offset, unsigned channels, unsigned wide_samples) +void append_to_verify_fifo_interleaved_(verify_input_fifo *fifo, const FLAC__int32 input[], uint32_t input_offset, uint32_t channels, uint32_t wide_samples) { - unsigned channel; - unsigned sample, wide_sample; - unsigned tail = fifo->tail; + uint32_t channel; + uint32_t sample, wide_sample; + uint32_t tail = fifo->tail; sample = input_offset * channels; for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) { @@ -4391,16 +4391,16 @@ FLAC__StreamDecoderReadStatus verify_read_callback_(const FLAC__StreamDecoder *d FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) { FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder *)client_data; - unsigned channel; - const unsigned channels = frame->header.channels; - const unsigned blocksize = frame->header.blocksize; - const unsigned bytes_per_block = sizeof(FLAC__int32) * blocksize; + uint32_t channel; + const uint32_t channels = frame->header.channels; + const uint32_t blocksize = frame->header.blocksize; + const uint32_t bytes_per_block = sizeof(FLAC__int32) * blocksize; (void)decoder; for(channel = 0; channel < channels; channel++) { if(0 != memcmp(buffer[channel], encoder->private_->verify.input_fifo.data[channel], bytes_per_block)) { - unsigned i, sample = 0; + uint32_t i, sample = 0; FLAC__int32 expect = 0, got = 0; for(i = 0; i < blocksize; i++) { @@ -4414,7 +4414,7 @@ FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamDecoder FLAC__ASSERT(i < blocksize); FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); encoder->private_->verify.error_stats.absolute_sample = frame->header.number.sample_number + sample; - encoder->private_->verify.error_stats.frame_number = (unsigned)(frame->header.number.sample_number / blocksize); + encoder->private_->verify.error_stats.frame_number = (uint32_t)(frame->header.number.sample_number / blocksize); encoder->private_->verify.error_stats.channel = channel; encoder->private_->verify.error_stats.sample = sample; encoder->private_->verify.error_stats.expected = expect; @@ -4496,7 +4496,7 @@ static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *st #define local__fwrite fwrite #endif -FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) +FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) { (void)client_data, (void)current_frame; diff --git a/src/libFLAC/stream_encoder_framing.c b/src/libFLAC/stream_encoder_framing.c index 0929cd7b..2c78916d 100644 --- a/src/libFLAC/stream_encoder_framing.c +++ b/src/libFLAC/stream_encoder_framing.c @@ -42,12 +42,12 @@ #include "share/compat.h" 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); +static FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended); FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw) { - unsigned i, j; - const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING); + uint32_t i, j; + const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->is_last, FLAC__STREAM_METADATA_IS_LAST_LEN)) return false; @@ -219,7 +219,7 @@ FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__ FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw) { - unsigned u, blocksize_hint, sample_rate_hint; + uint32_t u, blocksize_hint, sample_rate_hint; FLAC__byte crc; FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw)); @@ -364,7 +364,7 @@ FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWrit return true; } -FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw) +FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) { FLAC__bool ok; @@ -377,9 +377,9 @@ FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, return ok; } -FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw) +FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) { - unsigned i; + uint32_t i; if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK | (subframe->order<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) return false; @@ -415,9 +415,9 @@ FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsign return true; } -FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw) +FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, uint32_t residual_samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) { - unsigned i; + uint32_t i; if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK | ((subframe->order-1)<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) return false; @@ -461,9 +461,9 @@ FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned r return true; } -FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw) +FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, uint32_t samples, uint32_t subframe_bps, uint32_t wasted_bits, FLAC__BitWriter *bw) { - unsigned i; + uint32_t i; const FLAC__int32 *signal = subframe->data; if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN)) @@ -495,13 +495,13 @@ FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCo return true; } -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) +FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const uint32_t residual_samples, const uint32_t predictor_order, const uint32_t rice_parameters[], const uint32_t raw_bits[], const uint32_t partition_order, const FLAC__bool is_extended) { - const unsigned plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; - const unsigned pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; + const uint32_t plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; + const uint32_t pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; if(partition_order == 0) { - unsigned i; + uint32_t i; if(raw_bits[0] == 0) { if(!FLAC__bitwriter_write_raw_uint32(bw, rice_parameters[0], plen)) @@ -523,9 +523,9 @@ FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 return true; } else { - unsigned i, j, k = 0, k_last = 0; - unsigned partition_samples; - const unsigned default_partition_samples = (residual_samples+predictor_order) >> partition_order; + uint32_t i, j, k = 0, k_last = 0; + uint32_t partition_samples; + const uint32_t default_partition_samples = (residual_samples+predictor_order) >> partition_order; for(i = 0; i < (1u<<partition_order); i++) { partition_samples = default_partition_samples; if(i == 0) diff --git a/src/libFLAC/stream_encoder_intrin_avx2.c b/src/libFLAC/stream_encoder_intrin_avx2.c index a94a02bf..12591f05 100644 --- a/src/libFLAC/stream_encoder_intrin_avx2.c +++ b/src/libFLAC/stream_encoder_intrin_avx2.c @@ -48,17 +48,17 @@ FLAC__SSE_TARGET("avx2") void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps) + uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps) { - const unsigned default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - unsigned partitions = 1u << max_partition_order; + const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; + uint32_t partitions = 1u << max_partition_order; FLAC__ASSERT(default_partition_samples > predictor_order); /* first do max_partition_order */ { - const unsigned threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - unsigned partition, residual_sample, end = (unsigned)(-(int)predictor_order); + const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); + uint32_t partition, residual_sample, end = (uint32_t)(-(int32_t)predictor_order); if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { for(partition = residual_sample = 0; partition < partitions; partition++) { @@ -125,10 +125,10 @@ void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual /* now merge partitions for lower orders */ { - unsigned from_partition = 0, to_partition = partitions; + uint32_t from_partition = 0, to_partition = partitions; int partition_order; for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - unsigned i; + uint32_t i; partitions >>= 1; for(i = 0; i < partitions; i++) { abs_residual_partition_sums[to_partition++] = diff --git a/src/libFLAC/stream_encoder_intrin_sse2.c b/src/libFLAC/stream_encoder_intrin_sse2.c index 0f1d7aaf..6c16d2e3 100644 --- a/src/libFLAC/stream_encoder_intrin_sse2.c +++ b/src/libFLAC/stream_encoder_intrin_sse2.c @@ -59,22 +59,22 @@ static inline __m128i local_abs_epi32(__m128i val) FLAC__SSE_TARGET("sse2") void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps) + uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps) { - const unsigned default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - unsigned partitions = 1u << max_partition_order; + const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; + uint32_t partitions = 1u << max_partition_order; FLAC__ASSERT(default_partition_samples > predictor_order); /* first do max_partition_order */ { - const unsigned threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - unsigned partition, residual_sample, end = (unsigned)(-(int)predictor_order); + const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); + uint32_t partition, residual_sample, end = (uint32_t)(-(int32_t)predictor_order); if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { for(partition = residual_sample = 0; partition < partitions; partition++) { __m128i mm_sum = _mm_setzero_si128(); - unsigned e1, e3; + uint32_t e1, e3; end += default_partition_samples; e1 = (residual_sample + 3) & ~3; e3 = end & ~3; @@ -109,7 +109,7 @@ void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual else { /* have to pessimistically use 64 bits for accumulator */ for(partition = residual_sample = 0; partition < partitions; partition++) { __m128i mm_sum = _mm_setzero_si128(); - unsigned e1, e3; + uint32_t e1, e3; end += default_partition_samples; e1 = (residual_sample + 1) & ~1; e3 = end & ~1; @@ -139,10 +139,10 @@ void FLAC__precompute_partition_info_sums_intrin_sse2(const FLAC__int32 residual /* now merge partitions for lower orders */ { - unsigned from_partition = 0, to_partition = partitions; + uint32_t from_partition = 0, to_partition = partitions; int partition_order; for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - unsigned i; + uint32_t i; partitions >>= 1; for(i = 0; i < partitions; i++) { abs_residual_partition_sums[to_partition++] = diff --git a/src/libFLAC/stream_encoder_intrin_ssse3.c b/src/libFLAC/stream_encoder_intrin_ssse3.c index 21a08fc2..1e87d83e 100644 --- a/src/libFLAC/stream_encoder_intrin_ssse3.c +++ b/src/libFLAC/stream_encoder_intrin_ssse3.c @@ -48,22 +48,22 @@ FLAC__SSE_TARGET("ssse3") void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residual[], FLAC__uint64 abs_residual_partition_sums[], - unsigned residual_samples, unsigned predictor_order, unsigned min_partition_order, unsigned max_partition_order, unsigned bps) + uint32_t residual_samples, uint32_t predictor_order, uint32_t min_partition_order, uint32_t max_partition_order, uint32_t bps) { - const unsigned default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; - unsigned partitions = 1u << max_partition_order; + const uint32_t default_partition_samples = (residual_samples + predictor_order) >> max_partition_order; + uint32_t partitions = 1u << max_partition_order; FLAC__ASSERT(default_partition_samples > predictor_order); /* first do max_partition_order */ { - const unsigned threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); - unsigned partition, residual_sample, end = (unsigned)(-(int)predictor_order); + const uint32_t threshold = 32 - FLAC__bitmath_ilog2(default_partition_samples); + uint32_t partition, residual_sample, end = (uint32_t)(-(int32_t)predictor_order); if(bps + FLAC__MAX_EXTRA_RESIDUAL_BPS < threshold) { for(partition = residual_sample = 0; partition < partitions; partition++) { __m128i mm_sum = _mm_setzero_si128(); - unsigned e1, e3; + uint32_t e1, e3; end += default_partition_samples; e1 = (residual_sample + 3) & ~3; e3 = end & ~3; @@ -98,7 +98,7 @@ void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residua else { /* have to pessimistically use 64 bits for accumulator */ for(partition = residual_sample = 0; partition < partitions; partition++) { __m128i mm_sum = _mm_setzero_si128(); - unsigned e1, e3; + uint32_t e1, e3; end += default_partition_samples; e1 = (residual_sample + 1) & ~1; e3 = end & ~1; @@ -128,10 +128,10 @@ void FLAC__precompute_partition_info_sums_intrin_ssse3(const FLAC__int32 residua /* now merge partitions for lower orders */ { - unsigned from_partition = 0, to_partition = partitions; + uint32_t from_partition = 0, to_partition = partitions; int partition_order; for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) { - unsigned i; + uint32_t i; partitions >>= 1; for(i = 0; i < partitions; i++) { abs_residual_partition_sums[to_partition++] = diff --git a/src/plugin_common/dither.c b/src/plugin_common/dither.c index b20ab514..b4c9b672 100644 --- a/src/plugin_common/dither.c +++ b/src/plugin_common/dither.c @@ -55,9 +55,9 @@ typedef struct { FLAC__int32 random; } dither_state; -static FLAC__int32 linear_dither(unsigned source_bps, unsigned target_bps, FLAC__int32 sample, dither_state *dither, const FLAC__int32 MIN, const FLAC__int32 MAX) +static FLAC__int32 linear_dither(uint32_t source_bps, uint32_t target_bps, FLAC__int32 sample, dither_state *dither, const FLAC__int32 MIN, const FLAC__int32 MAX) { - unsigned scalebits; + uint32_t scalebits; FLAC__int32 output, mask, random; FLAC__ASSERT(source_bps < 32); @@ -106,15 +106,15 @@ static FLAC__int32 linear_dither(unsigned source_bps, unsigned target_bps, FLAC_ return output >> scalebits; } -size_t FLAC__plugin_common__pack_pcm_signed_big_endian(FLAC__byte *data, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps) +size_t FLAC__plugin_common__pack_pcm_signed_big_endian(FLAC__byte *data, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, uint32_t source_bps, uint32_t target_bps) { static dither_state dither[FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS]; FLAC__byte * const start = data; FLAC__int32 sample; const FLAC__int32 *input_; - unsigned samples, channel; - const unsigned bytes_per_sample = target_bps / 8; - const unsigned incr = bytes_per_sample * channels; + uint32_t samples, channel; + const uint32_t bytes_per_sample = target_bps / 8; + const uint32_t incr = bytes_per_sample * channels; FLAC__ASSERT(channels > 0 && channels <= FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS); FLAC__ASSERT(source_bps < 32); @@ -187,15 +187,15 @@ size_t FLAC__plugin_common__pack_pcm_signed_big_endian(FLAC__byte *data, const F return wide_samples * channels * (target_bps/8); } -size_t FLAC__plugin_common__pack_pcm_signed_little_endian(FLAC__byte *data, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps) +size_t FLAC__plugin_common__pack_pcm_signed_little_endian(FLAC__byte *data, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, uint32_t source_bps, uint32_t target_bps) { static dither_state dither[FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS]; FLAC__byte * const start = data; FLAC__int32 sample; const FLAC__int32 *input_; - unsigned samples, channel; - const unsigned bytes_per_sample = target_bps / 8; - const unsigned incr = bytes_per_sample * channels; + uint32_t samples, channel; + const uint32_t bytes_per_sample = target_bps / 8; + const uint32_t incr = bytes_per_sample * channels; FLAC__ASSERT(channels > 0 && channels <= FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS); FLAC__ASSERT(source_bps < 32); diff --git a/src/plugin_common/dither.h b/src/plugin_common/dither.h index 32f5f1ca..e7c1301b 100644 --- a/src/plugin_common/dither.h +++ b/src/plugin_common/dither.h @@ -24,7 +24,7 @@ #include "defs.h" /* buy FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS for the caller */ #include "FLAC/ordinals.h" -size_t FLAC__plugin_common__pack_pcm_signed_big_endian(FLAC__byte *data, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps); -size_t FLAC__plugin_common__pack_pcm_signed_little_endian(FLAC__byte *data, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, unsigned source_bps, unsigned target_bps); +size_t FLAC__plugin_common__pack_pcm_signed_big_endian(FLAC__byte *data, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, uint32_t source_bps, uint32_t target_bps); +size_t FLAC__plugin_common__pack_pcm_signed_little_endian(FLAC__byte *data, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, uint32_t source_bps, uint32_t target_bps); #endif diff --git a/src/plugin_common/tags.c b/src/plugin_common/tags.c index 38df9581..a8e1181f 100644 --- a/src/plugin_common/tags.c +++ b/src/plugin_common/tags.c @@ -109,7 +109,7 @@ static size_t local__utf8_to_ucs2(const FLAC__byte *utf8, FLAC__uint16 *ucs2) return len; } -static FLAC__uint16 *local__convert_utf8_to_ucs2(const char *src, unsigned length) +static FLAC__uint16 *local__convert_utf8_to_ucs2(const char *src, uint32_t length) { FLAC__uint16 *out; size_t chars = 0; @@ -118,9 +118,9 @@ static FLAC__uint16 *local__convert_utf8_to_ucs2(const char *src, unsigned lengt /* calculate length */ { - const unsigned char *s, *end; - for (s=(const unsigned char *)src, end=s+length; s<end; chars++) { - const unsigned n = local__utf8len(s); + const uint32_t char *s, *end; + for (s=(const uint32_t char *)src, end=s+length; s<end; chars++) { + const uint32_t n = local__utf8len(s); if (n == 0) return 0; s += n; @@ -137,7 +137,7 @@ static FLAC__uint16 *local__convert_utf8_to_ucs2(const char *src, unsigned lengt /* convert */ { - const unsigned char *s = (const unsigned char *)src; + const uint32_t char *s = (const uint32_t char *)src; FLAC__uint16 *u = out; for ( ; chars; chars--) s += local__utf8_to_ucs2(s, u++); @@ -175,7 +175,7 @@ static size_t local__ucs2_to_utf8(FLAC__uint16 ucs2, FLAC__byte *utf8) } } -static char *local__convert_ucs2_to_utf8(const FLAC__uint16 *src, unsigned length) +static char *local__convert_ucs2_to_utf8(const FLAC__uint16 *src, uint32_t length) { char *out; size_t len = 0, n; @@ -184,7 +184,7 @@ static char *local__convert_ucs2_to_utf8(const FLAC__uint16 *src, unsigned lengt /* calculate length */ { - unsigned i; + uint32_t i; for (i = 0; i < length; i++) { n = local__ucs2len(src[i]); if(len + n < len) /* overflow check */ @@ -200,7 +200,7 @@ static char *local__convert_ucs2_to_utf8(const FLAC__uint16 *src, unsigned lengt /* convert */ { - unsigned char *u = (unsigned char *)out; + uint32_t char *u = (uint32_t char *)out; for ( ; *src; src++) u += local__ucs2_to_utf8(*src, u); local__ucs2_to_utf8(*src, u); diff --git a/src/plugin_xmms/fileinfo.c b/src/plugin_xmms/fileinfo.c index 54c0c562..8eb1e115 100644 --- a/src/plugin_xmms/fileinfo.c +++ b/src/plugin_xmms/fileinfo.c @@ -276,7 +276,7 @@ static void show_replaygain(void) void FLAC_XMMS__file_info_box(char *filename) { - unsigned i; + uint32_t i; gchar *title; if (!window) diff --git a/src/plugin_xmms/http.c b/src/plugin_xmms/http.c index 2f31576c..05f7300e 100644 --- a/src/plugin_xmms/http.c +++ b/src/plugin_xmms/http.c @@ -49,7 +49,7 @@ /* on FreeBSD we get socklen_t from <sys/socket.h> */ #if (!defined HAVE_SOCKLEN_T) && !defined(__FreeBSD__) -typedef unsigned int socklen_t; +typedef uint32_t socklen_t; #endif #define min(x,y) ((x)<(y)?(x):(y)) diff --git a/src/plugin_xmms/plugin.c b/src/plugin_xmms/plugin.c index d00b1ebe..d84d53cb 100644 --- a/src/plugin_xmms/plugin.c +++ b/src/plugin_xmms/plugin.c @@ -65,13 +65,13 @@ typedef struct { FLAC__bool eof; FLAC__bool play_thread_open; /* if true, is_playing must also be true */ FLAC__uint64 total_samples; - unsigned bits_per_sample; - unsigned channels; - unsigned sample_rate; + uint32_t bits_per_sample; + uint32_t channels; + uint32_t sample_rate; int length_in_msec; /* int (instead of FLAC__uint64) only because that's what XMMS uses; seeking won't work right if this maxes out */ gchar *title; AFormat sample_format; - unsigned sample_format_bytes_per_sample; + uint32_t sample_format_bytes_per_sample; int seek_to_in_sec; FLAC__bool has_replaygain; double replay_scale; @@ -130,7 +130,7 @@ InputPlugin flac_ip = #define SAMPLES_PER_WRITE 512 #define SAMPLE_BUFFER_SIZE ((FLAC__MAX_BLOCK_SIZE + SAMPLES_PER_WRITE) * FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS * (24/8)) static FLAC__byte sample_buffer_[SAMPLE_BUFFER_SIZE]; -static unsigned sample_buffer_first_, sample_buffer_last_; +static uint32_t sample_buffer_first_, sample_buffer_last_; static FLAC__StreamDecoder *decoder_ = 0; static stream_data_struct stream_data_; @@ -141,7 +141,7 @@ static FLAC__bool is_big_endian_host_; #define BITRATE_HIST_SEGMENT_MSEC 500 /* 500ms * 50 = 25s should be enough */ #define BITRATE_HIST_SIZE 50 -static unsigned bitrate_history_[BITRATE_HIST_SIZE]; +static uint32_t bitrate_history_[BITRATE_HIST_SIZE]; FLAC_API InputPlugin *get_iplugin_info(void) @@ -437,7 +437,7 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec) void *play_loop_(void *arg) { - unsigned written_time_last = 0, bh_index_last_w = 0, bh_index_last_o = BITRATE_HIST_SIZE, blocksize = 1; + uint32_t written_time_last = 0, bh_index_last_w = 0, bh_index_last_o = BITRATE_HIST_SIZE, blocksize = 1; FLAC__uint64 decode_position_last = 0, decode_position_frame_last = 0, decode_position_frame = 0; (void)arg; @@ -445,7 +445,7 @@ void *play_loop_(void *arg) while(stream_data_.is_playing) { if(!stream_data_.eof) { while(sample_buffer_last_ - sample_buffer_first_ < SAMPLES_PER_WRITE) { - unsigned s; + uint32_t s; s = sample_buffer_last_ - sample_buffer_first_; if(FLAC__stream_decoder_get_state(decoder_) == FLAC__STREAM_DECODER_END_OF_STREAM) { @@ -464,10 +464,10 @@ void *play_loop_(void *arg) decode_position_frame = 0; } if(sample_buffer_last_ - sample_buffer_first_ > 0) { - const unsigned n = min(sample_buffer_last_ - sample_buffer_first_, SAMPLES_PER_WRITE); + const uint32_t n = min(sample_buffer_last_ - sample_buffer_first_, SAMPLES_PER_WRITE); int bytes = n * stream_data_.channels * stream_data_.sample_format_bytes_per_sample; FLAC__byte *sample_buffer_start = sample_buffer_ + sample_buffer_first_ * stream_data_.channels * stream_data_.sample_format_bytes_per_sample; - unsigned written_time, bh_index_w; + uint32_t written_time, bh_index_w; FLAC__uint64 decode_position; sample_buffer_first_ += n; @@ -523,7 +523,7 @@ void *play_loop_(void *arg) } else { /* display the right bitrate from history */ - unsigned bh_index_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; + uint32_t bh_index_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; if(bh_index_o != bh_index_last_o && bh_index_o != bh_index_last_w && bh_index_o != (bh_index_last_w + 1) % BITRATE_HIST_SIZE) { bh_index_last_o = bh_index_o; flac_ip.set_info(stream_data_.title, stream_data_.length_in_msec, bitrate_history_[bh_index_o], stream_data_.sample_rate, stream_data_.channels); @@ -597,8 +597,8 @@ FLAC__StreamDecoderReadStatus http_read_callback_(const FLAC__StreamDecoder *dec FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) { stream_data_struct *stream_data = (stream_data_struct *)client_data; - const unsigned channels = stream_data->channels, wide_samples = frame->header.blocksize; - const unsigned bits_per_sample = stream_data->bits_per_sample; + const uint32_t channels = stream_data->channels, wide_samples = frame->header.blocksize; + const uint32_t bits_per_sample = stream_data->bits_per_sample; FLAC__byte *sample_buffer_start; (void)decoder; @@ -616,7 +616,7 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decode FLAC__replaygain_synthesis__apply_gain( sample_buffer_start, !is_big_endian_host_, - stream_data->sample_format_bytes_per_sample == 1, /* unsigned_data_out */ + stream_data->sample_format_bytes_per_sample == 1, /* uint32_t_data_out */ buffer, wide_samples, channels, diff --git a/src/share/getopt/getopt.c b/src/share/getopt/getopt.c index e8a13aa4..7928ad33 100644 --- a/src/share/getopt/getopt.c +++ b/src/share/getopt/getopt.c @@ -54,6 +54,7 @@ #endif #include <stdio.h> +#include <stdint.h> /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C @@ -663,8 +664,8 @@ share___getopt_internal (argc, argv, optstring, longopts, longind, long_only) for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) + if ((uint32_t) (nameend - nextchar) + == (uint32_t) strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -852,7 +853,7 @@ share___getopt_internal (argc, argv, optstring, longopts, longind, long_only) for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + if ((uint32_t) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c index 78473d8a..13784c28 100644 --- a/src/share/grabbag/cuesheet.c +++ b/src/share/grabbag/cuesheet.c @@ -29,12 +29,12 @@ #include "share/grabbag.h" #include "share/safe_str.h" -unsigned grabbag__cuesheet_msf_to_frame(unsigned minutes, unsigned seconds, unsigned frames) +uint32_t grabbag__cuesheet_msf_to_frame(uint32_t minutes, uint32_t seconds, uint32_t frames) { return ((minutes * 60) + seconds) * 75 + frames; } -void grabbag__cuesheet_frame_to_msf(unsigned frame, unsigned *minutes, unsigned *seconds, unsigned *frames) +void grabbag__cuesheet_frame_to_msf(uint32_t frame, uint32_t *minutes, uint32_t *seconds, uint32_t *frames) { *frames = frame % 75; frame /= 75; @@ -83,7 +83,7 @@ static FLAC__int64 local__parse_int64_(const char *s) * return sample number or <0 for error * WATCHOUT: if sample rate is not evenly divisible by 75, the resulting sample number will be approximate */ -static FLAC__int64 local__parse_msf_(const char *s, unsigned sample_rate) +static FLAC__int64 local__parse_msf_(const char *s, uint32_t sample_rate) { FLAC__int64 ret, field; char c; @@ -152,7 +152,7 @@ static FLAC__int64 local__parse_msf_(const char *s, unsigned sample_rate) * return sample number or <0 for error * WATCHOUT: depending on the sample rate, the resulting sample number may be approximate with fractional seconds */ -static FLAC__int64 local__parse_ms_(const char *s, unsigned sample_rate) +static FLAC__int64 local__parse_ms_(const char *s, uint32_t sample_rate) { FLAC__int64 ret, field; double x; @@ -240,10 +240,10 @@ static char *local__get_field_(char **s, FLAC__bool allow_quotes) return p; } -static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message, unsigned *last_line_read, FLAC__StreamMetadata *cuesheet, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) +static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message, uint32_t *last_line_read, FLAC__StreamMetadata *cuesheet, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) { char buffer[4096], *line, *field; - unsigned forced_leadout_track_num = 0; + uint32_t forced_leadout_track_num = 0; FLAC__uint64 forced_leadout_track_offset = 0; int in_track_num = -1, in_index_num = -1; FLAC__bool disc_has_catalog = false, track_has_flags = false, track_has_isrc = false, has_forced_leadout = false; @@ -523,7 +523,7 @@ static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message, *error_message = "illegal FLAC__lead-out track number"; return false; } - forced_leadout_track_num = (unsigned)track_num; + forced_leadout_track_num = (uint32_t)track_num; /*@@@ search for duplicate track number? */ if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) { *error_message = "FLAC__lead-out is missing offset"; @@ -587,7 +587,7 @@ static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message, return true; } -FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) +FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, uint32_t *last_line_read, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) { FLAC__StreamMetadata *cuesheet; @@ -614,7 +614,7 @@ FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_mes void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference) { const FLAC__StreamMetadata_CueSheet *cs; - unsigned track_num, index_num; + uint32_t track_num, index_num; FLAC__ASSERT(0 != file); FLAC__ASSERT(0 != cuesheet); @@ -629,7 +629,7 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co for(track_num = 0; track_num < cs->num_tracks-1; track_num++) { const FLAC__StreamMetadata_CueSheet_Track *track = cs->tracks + track_num; - fprintf(file, " TRACK %02u %s\n", (unsigned)track->number, track->type == 0? "AUDIO" : "DATA"); + fprintf(file, " TRACK %02u %s\n", (uint32_t)track->number, track->type == 0? "AUDIO" : "DATA"); if(track->pre_emphasis) fprintf(file, " FLAGS PRE\n"); @@ -639,10 +639,10 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co for(index_num = 0; index_num < track->num_indices; index_num++) { const FLAC__StreamMetadata_CueSheet_Index *indx = track->indices + index_num; - fprintf(file, " INDEX %02u ", (unsigned)indx->number); + fprintf(file, " INDEX %02u ", (uint32_t)indx->number); if(cs->is_cd) { - const unsigned logical_frame = (unsigned)((track->offset + indx->offset) / (44100 / 75)); - unsigned m, s, f; + const uint32_t logical_frame = (uint32_t)((track->offset + indx->offset) / (44100 / 75)); + uint32_t m, s, f; grabbag__cuesheet_frame_to_msf(logical_frame, &m, &s, &f); fprintf(file, "%02u:%02u:%02u\n", m, s, f); } @@ -652,5 +652,5 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co } fprintf(file, "REM FLAC__lead-in %" PRIu64 "\n", cs->lead_in); - fprintf(file, "REM FLAC__lead-out %u %" PRIu64 "\n", (unsigned)cs->tracks[track_num].number, cs->tracks[track_num].offset); + fprintf(file, "REM FLAC__lead-out %u %" PRIu64 "\n", (uint32_t)cs->tracks[track_num].number, cs->tracks[track_num].offset); } diff --git a/src/share/grabbag/picture.c b/src/share/grabbag/picture.c index f63b5a90..89d5cc92 100644 --- a/src/share/grabbag/picture.c +++ b/src/share/grabbag/picture.c @@ -143,7 +143,7 @@ static FLAC__bool local__extract_resolution_color_info_(FLAC__StreamMetadata_Pic while(len > 12) { /* every PNG chunk must be at least 12 bytes long */ const FLAC__uint32 clen = (FLAC__uint32)data[0] << 24 | (FLAC__uint32)data[1] << 16 | (FLAC__uint32)data[2] << 8 | (FLAC__uint32)data[3]; if(0 == memcmp(data+4, "IHDR", 4) && clen == 13) { - unsigned color_type = data[17]; + uint32_t color_type = data[17]; picture->width = (FLAC__uint32)data[8] << 24 | (FLAC__uint32)data[9] << 16 | (FLAC__uint32)data[10] << 8 | (FLAC__uint32)data[11]; picture->height = (FLAC__uint32)data[12] << 24 | (FLAC__uint32)data[13] << 16 | (FLAC__uint32)data[14] << 8 | (FLAC__uint32)data[15]; if(color_type == 3) { diff --git a/src/share/grabbag/replaygain.c b/src/share/grabbag/replaygain.c index ad3138f9..fb23a474 100644 --- a/src/share/grabbag/replaygain.c +++ b/src/share/grabbag/replaygain.c @@ -54,7 +54,7 @@ static const char *peak_format_ = "%s=%1.8f"; static double album_peak_, title_peak_; -const unsigned GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED = 190; +const uint32_t GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED = 190; /* FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 29 + 1 + 8 + FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN/8 + 21 + 1 + 10 + @@ -115,24 +115,24 @@ static FLAC__bool append_tag_(FLAC__StreamMetadata *block, const char *format, c return FLAC__metadata_object_vorbiscomment_append_comment(block, entry, /*copy=*/true); } -FLAC__bool grabbag__replaygain_is_valid_sample_frequency(unsigned sample_frequency) +FLAC__bool grabbag__replaygain_is_valid_sample_frequency(uint32_t sample_frequency) { return ValidGainFrequency( sample_frequency ); } -FLAC__bool grabbag__replaygain_init(unsigned sample_frequency) +FLAC__bool grabbag__replaygain_init(uint32_t sample_frequency) { title_peak_ = album_peak_ = 0.0; return InitGainAnalysis((long)sample_frequency) == INIT_GAIN_ANALYSIS_OK; } -FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, unsigned bps, unsigned samples) +FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, uint32_t bps, uint32_t samples) { /* using a small buffer improves data locality; we'd like it to fit easily in the dcache */ static flac_float_t lbuffer[2048], rbuffer[2048]; - static const unsigned nbuffer = sizeof(lbuffer) / sizeof(lbuffer[0]); + static const uint32_t nbuffer = sizeof(lbuffer) / sizeof(lbuffer[0]); FLAC__int32 block_peak = 0, s; - unsigned i, j; + uint32_t i, j; FLAC__ASSERT(bps >= 4 && bps <= FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE); FLAC__ASSERT(FLAC__MIN_BITS_PER_SAMPLE == 4); @@ -147,7 +147,7 @@ FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__ if(is_stereo) { j = 0; while(samples > 0) { - const unsigned n = local_min(samples, nbuffer); + const uint32_t n = local_min(samples, nbuffer); for(i = 0; i < n; i++, j++) { s = input[0][j]; lbuffer[i] = (flac_float_t)s; @@ -167,7 +167,7 @@ FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__ else { j = 0; while(samples > 0) { - const unsigned n = local_min(samples, nbuffer); + const uint32_t n = local_min(samples, nbuffer); for(i = 0; i < n; i++, j++) { s = input[0][j]; lbuffer[i] = (flac_float_t)s; @@ -190,7 +190,7 @@ FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__ if(is_stereo) { j = 0; while(samples > 0) { - const unsigned n = local_min(samples, nbuffer); + const uint32_t n = local_min(samples, nbuffer); for(i = 0; i < n; i++, j++) { s = input[0][j]; lbuffer[i] = (flac_float_t)(scale * (double)s); @@ -210,7 +210,7 @@ FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__ else { j = 0; while(samples > 0) { - const unsigned n = local_min(samples, nbuffer); + const uint32_t n = local_min(samples, nbuffer); for(i = 0; i < n; i++, j++) { s = input[0][j]; lbuffer[i] = (flac_float_t)(scale * (double)s); @@ -252,19 +252,19 @@ void grabbag__replaygain_get_title(float *gain, float *peak) typedef struct { - unsigned channels; - unsigned bits_per_sample; - unsigned sample_rate; + uint32_t channels; + uint32_t bits_per_sample; + uint32_t sample_rate; FLAC__bool error; } DecoderInstance; static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) { DecoderInstance *instance = (DecoderInstance*)client_data; - const unsigned bits_per_sample = frame->header.bits_per_sample; - const unsigned channels = frame->header.channels; - const unsigned sample_rate = frame->header.sample_rate; - const unsigned samples = frame->header.blocksize; + const uint32_t bits_per_sample = frame->header.bits_per_sample; + const uint32_t channels = frame->header.channels; + const uint32_t sample_rate = frame->header.sample_rate; + const uint32_t samples = frame->header.blocksize; (void)decoder; diff --git a/src/share/grabbag/seektable.c b/src/share/grabbag/seektable.c index 01118d51..2211e12e 100644 --- a/src/share/grabbag/seektable.c +++ b/src/share/grabbag/seektable.c @@ -27,9 +27,9 @@ #include <stdlib.h> /* for atoi() */ #include <string.h> -FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, unsigned sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points) +FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, uint32_t sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points) { - unsigned i; + uint32_t i; const char *pt; FLAC__ASSERT(0 != spec); @@ -53,9 +53,9 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec if(0 != spec_has_real_points) *spec_has_real_points = true; if(!only_explicit_placeholders) { - const int n = (unsigned)atoi(pt); + const int n = (uint32_t)atoi(pt); if(n > 0) - if(!FLAC__metadata_object_seektable_template_append_spaced_points(seektable_template, (unsigned)n, total_samples_to_encode)) + if(!FLAC__metadata_object_seektable_template_append_spaced_points(seektable_template, (uint32_t)n, total_samples_to_encode)) return false; } } @@ -68,7 +68,7 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec if(!only_explicit_placeholders) { const double sec = atof(pt); if(sec > 0.0) { - unsigned samples = (unsigned)(sec * (double)sample_rate); + uint32_t samples = (uint32_t)(sec * (double)sample_rate); /* Restrict seekpoints to two per second of audio. */ samples = samples < sample_rate / 2 ? sample_rate / 2 : samples; if(samples > 0) { diff --git a/src/share/replaygain_analysis/replaygain_analysis.c b/src/share/replaygain_analysis/replaygain_analysis.c index 20a5b28d..9d11e8cd 100644 --- a/src/share/replaygain_analysis/replaygain_analysis.c +++ b/src/share/replaygain_analysis/replaygain_analysis.c @@ -62,8 +62,8 @@ * flac_float_t l_samples [4096]; * flac_float_t r_samples [4096]; * size_t num_samples; - * unsigned int num_songs; - * unsigned int i; + * uint32_t int num_songs; + * uint32_t int i; * * InitGainAnalysis ( 44100 ); * for ( i = 1; i <= num_songs; i++ ) { @@ -125,8 +125,8 @@ static flac_float_t* rstepbuf; static flac_float_t* rstep; static flac_float_t* routbuf; static flac_float_t* rout; -static unsigned int sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */ -static unsigned long totsamp; +static uint32_t sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */ +static uint64_t totsamp; static double lsum; static double rsum; #if 0 @@ -144,7 +144,7 @@ static uint32_t B [120 * 100]; struct ReplayGainFilter { long rate; - unsigned downsample; + uint32_t downsample; flac_float_t BYule[YULE_ORDER+1]; flac_float_t AYule[YULE_ORDER+1]; flac_float_t BButter[BUTTER_ORDER+1]; @@ -269,7 +269,7 @@ static const struct ReplayGainFilter ReplayGainFilters[] = { /* When calling this procedure, make sure that ip[-order] and op[-order] point to real data! */ static void -filter ( const flac_float_t* input, flac_float_t* output, size_t nSamples, const flac_float_t* a, const flac_float_t* b, size_t order, unsigned downsample ) +filter ( const flac_float_t* input, flac_float_t* output, size_t nSamples, const flac_float_t* a, const flac_float_t* b, size_t order, uint32_t downsample ) { double y; size_t i; @@ -303,9 +303,9 @@ filter ( const flac_float_t* input, flac_float_t* output, size_t nSamples, const static struct ReplayGainFilter* CreateGainFilter ( long samplefreq ) { - unsigned i; + uint32_t i; long maxrate = 0; - unsigned downsample = 1; + uint32_t downsample = 1; struct ReplayGainFilter* gainfilter = malloc(sizeof(*gainfilter)); if ( !gainfilter ) @@ -338,7 +338,7 @@ CreateGainFilter ( long samplefreq ) } static void* -ReallocateWindowBuffer(unsigned window_size, flac_float_t **window_buffer) +ReallocateWindowBuffer(uint32_t window_size, flac_float_t **window_buffer) { *window_buffer = safe_realloc_(*window_buffer, sizeof(**window_buffer) * (window_size + MAX_ORDER)); return *window_buffer; @@ -413,7 +413,7 @@ InitGainAnalysis ( long samplefreq ) int AnalyzeSamples ( const flac_float_t* left_samples, const flac_float_t* right_samples, size_t num_samples, int num_channels ) { - unsigned downsample = replaygainfilter->downsample; + uint32_t downsample = replaygainfilter->downsample; const flac_float_t* curleft; const flac_float_t* curright; long prebufsamples; @@ -545,7 +545,7 @@ flac_float_t GetTitleGain ( void ) { flac_float_t retval; - unsigned int i; + uint32_t i; retval = analyzeResult ( A, sizeof(A)/sizeof(*A) ); diff --git a/src/share/replaygain_synthesis/replaygain_synthesis.c b/src/share/replaygain_synthesis/replaygain_synthesis.c index b7d227ea..c14ab1b9 100644 --- a/src/share/replaygain_synthesis/replaygain_synthesis.c +++ b/src/share/replaygain_synthesis/replaygain_synthesis.c @@ -79,9 +79,9 @@ * XORed values of both generators. */ -static unsigned int random_int_(void) +static uint32_t random_int_(void) { - static const unsigned char parity_[256] = { + static const uint8_t parity_[256] = { 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, @@ -91,10 +91,10 @@ static unsigned int random_int_(void) 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 }; - static unsigned int r1_ = 1; - static unsigned int r2_ = 1; + static uint32_t r1_ = 1; + static uint32_t r2_ = 1; - unsigned int t1, t2, t3, t4; + uint32_t t1, t2, t3, t4; /* Parity calculation is done via table lookup, this is also available * on CPUs without parity, can be implemented in C and avoid unpredictable @@ -201,7 +201,7 @@ static double scalar16_(const float* x, const float* y) void FLAC__replaygain_synthesis__init_dither_context(DitherContext *d, int bits, int shapingtype) { - static unsigned char default_dither [] = { 92, 92, 88, 84, 81, 78, 74, 67, 0, 0 }; + static uint8_t default_dither [] = { 92, 92, 88, 84, 81, 78, 74, 67, 0, 0 }; static const float* F [] = { F44_0, F44_1, F44_2, F44_3 }; int indx; @@ -292,7 +292,7 @@ static FLAC__int64 dither_output_(DitherContext *d, FLAC__bool do_dithering, int #endif -size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, const unsigned source_bps, const unsigned target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context) +size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool uint32_t_data_out, const FLAC__int32 * const input[], uint32_t wide_samples, uint32_t channels, const uint32_t source_bps, const uint32_t target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context) { static const FLAC__int64 hard_clip_factors_[33] = { 0, /* 0 bits-per-sample (not supported) */ @@ -340,11 +340,11 @@ size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool l const double multi_scale = scale / (double)(1u << (source_bps-1)); FLAC__byte * const start = data_out; - unsigned i, channel; + uint32_t i, channel; const FLAC__int32 *input_; double sample; - const unsigned bytes_per_sample = target_bps / 8; - const unsigned last_history_index = dither_context->LastHistoryIndex; + const uint32_t bytes_per_sample = target_bps / 8; + const uint32_t last_history_index = dither_context->LastHistoryIndex; NoiseShaping noise_shaping = dither_context->ShapingType; FLAC__int64 val64; FLAC__int32 val32; @@ -359,7 +359,7 @@ size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool l FLAC__ASSERT((target_bps & 7) == 0); for(channel = 0; channel < channels; channel++) { - const unsigned incr = bytes_per_sample * channels; + const uint32_t incr = bytes_per_sample * channels; data_out = start + bytes_per_sample * channel; input_ = input[channel]; for(i = 0; i < wide_samples; i++, data_out += incr) { @@ -383,7 +383,7 @@ size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool l val32 = (FLAC__int32)hard_clip_factor; uval32 = (FLAC__uint32)val32; - if (unsigned_data_out) + if (uint32_t_data_out) uval32 ^= twiggle; if (little_endian_data_out) { diff --git a/src/share/utf8/charmaps.h b/src/share/utf8/charmaps.h index 690d8906..16d049a2 100644 --- a/src/share/utf8/charmaps.h +++ b/src/share/utf8/charmaps.h @@ -4,7 +4,7 @@ * with a decent iconv. */ -static const unsigned short mapping_iso_8859_2[256] = { +static const uint16_t mapping_iso_8859_2[256] = { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, @@ -41,7 +41,7 @@ static const unsigned short mapping_iso_8859_2[256] = { static struct { const char *name; - const unsigned short *map; + const uint16_t *map; struct charset *charset; } maps[] = { { "ISO-8859-2", mapping_iso_8859_2, 0 }, diff --git a/src/share/utf8/charset.c b/src/share/utf8/charset.c index 5a2a6e49..432e32dd 100644 --- a/src/share/utf8/charset.c +++ b/src/share/utf8/charset.c @@ -69,7 +69,7 @@ static int ascii_strcasecmp(const char *s1, const char *s2) if (c1 != c2) break; } - return (unsigned char)*s1 - (unsigned char)*s2; + return (uint8_t)*s1 - (uint8_t)*s2; } /* @@ -78,7 +78,7 @@ static int ascii_strcasecmp(const char *s1, const char *s2) int utf8_mbtowc(int *pwc, const char *s, size_t n) { - unsigned char c; + uint8_t c; int wc, i, k; if (!n || !s) @@ -129,7 +129,7 @@ int utf8_mbtowc(int *pwc, const char *s, size_t n) int utf8_wctomb(char *s, int wc1) { - unsigned int wc = wc1; + uint32_t int wc = wc1; if (!s) return 0; @@ -231,7 +231,7 @@ static int mbtowc_ascii(void *map, int *pwc, const char *s, size_t n) (void)map; if (!n || !s) return 0; - wc = (unsigned char)*s; + wc = (uint8_t)*s; if (wc & ~0x7f) return -1; if (pwc) @@ -263,7 +263,7 @@ static int mbtowc_iso1(void *map, int *pwc, const char *s, size_t n) (void)map; if (!n || !s) return 0; - wc = (unsigned char)*s; + wc = (uint8_t)*s; if (wc & ~0xff) return -1; if (pwc) @@ -287,18 +287,18 @@ static int wctomb_iso1(void *map, char *s, int wc) */ struct map { - const unsigned short *from; + const uint16_t *from; struct inverse_map *to; }; static int mbtowc_8bit(void *map1, int *pwc, const char *s, size_t n) { struct map *map = map1; - unsigned short wc; + uint16_t wc; if (!n || !s) return 0; - wc = map->from[(unsigned char)*s]; + wc = map->from[(uint8_t)*s]; if (wc == 0xffff) return -1; if (pwc) @@ -316,8 +316,8 @@ static int mbtowc_8bit(void *map1, int *pwc, const char *s, size_t n) */ struct inverse_map { - unsigned char first[256]; - unsigned char next[256]; + uint8_t first[256]; + uint8_t next[256]; }; /* @@ -328,7 +328,7 @@ struct inverse_map { /* #define HASH(i) 0 */ /* #define HASH(i) 99 */ -static struct inverse_map *make_inverse_map(const unsigned short *from) +static struct inverse_map *make_inverse_map(const uint16_t *from) { struct inverse_map *to; char used[256]; @@ -362,7 +362,7 @@ static struct inverse_map *make_inverse_map(const unsigned short *from) static int wctomb_8bit(void *map1, char *s, int wc1) { struct map *map = map1; - unsigned short wc = wc1; + uint16_t wc = wc1; int i; if (!s) diff --git a/src/share/utf8/makemap.c b/src/share/utf8/makemap.c index 59af6083..790021c6 100644 --- a/src/share/utf8/makemap.c +++ b/src/share/utf8/makemap.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) const char *ib; char *ob; size_t ibl, obl, k; - unsigned char c, buf[4]; + uint8_t c, buf[4]; int i, wc; if (argc != 2) { diff --git a/src/test_grabbag/cuesheet/main.c b/src/test_grabbag/cuesheet/main.c index eb6f2712..433d11a6 100644 --- a/src/test_grabbag/cuesheet/main.c +++ b/src/test_grabbag/cuesheet/main.c @@ -29,12 +29,12 @@ #include "FLAC/metadata.h" #include "share/grabbag.h" -static int do_cuesheet(const char *infilename, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) +static int do_cuesheet(const char *infilename, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset) { FILE *fin, *fout; const char *error_message, *tmpfilenamebase; char tmpfilename[4096]; - unsigned last_line_read; + uint32_t last_line_read; FLAC__StreamMetadata *cuesheet; FLAC__ASSERT(strlen(infilename) + 2 < sizeof(tmpfilename)); @@ -116,7 +116,7 @@ static int do_cuesheet(const char *infilename, unsigned sample_rate, FLAC__bool int main(int argc, char *argv[]) { FLAC__uint64 lead_out_offset; - unsigned sample_rate = 48000; + uint32_t sample_rate = 48000; FLAC__bool is_cdda = false; const char *usage = "usage: test_cuesheet cuesheet_file lead_out_offset [ [ sample_rate ] cdda ]\n"; @@ -132,7 +132,7 @@ int main(int argc, char *argv[]) lead_out_offset = (FLAC__uint64)strtoul(argv[2], 0, 10); if(argc >= 4) { - sample_rate = (unsigned)atoi(argv[3]); + sample_rate = (uint32_t)atoi(argv[3]); if(argc >= 5) { if(0 == strcmp(argv[4], "cdda")) is_cdda = true; diff --git a/src/test_grabbag/picture/main.c b/src/test_grabbag/picture/main.c index 35cd45ea..df914098 100644 --- a/src/test_grabbag/picture/main.c +++ b/src/test_grabbag/picture/main.c @@ -73,9 +73,9 @@ static FLAC__bool test_one_picture(const char *prefix, const PictureFile *pf, co if(fn_only) flac_snprintf(s, sizeof(s), "pictures/%s", pf->path); else if (res == NULL) - flac_snprintf(s, sizeof(s), "%u|%s|%s||pictures/%s", (unsigned)pf->type, pf->mime_type, pf->description, pf->path); + flac_snprintf(s, sizeof(s), "%u|%s|%s||pictures/%s", (uint32_t)pf->type, pf->mime_type, pf->description, pf->path); else - flac_snprintf(s, sizeof(s), "%u|%s|%s|%dx%dx%d/%d|pictures/%s", (unsigned)pf->type, pf->mime_type, pf->description, res->width, res->height, res->depth, res->colors, pf->path); + flac_snprintf(s, sizeof(s), "%u|%s|%s|%dx%dx%d/%d|pictures/%s", (uint32_t)pf->type, pf->mime_type, pf->description, res->width, res->height, res->depth, res->colors, pf->path); printf("testing grabbag__picture_parse_specification(\"%s\")... ", s); diff --git a/src/test_libFLAC/bitwriter.c b/src/test_libFLAC/bitwriter.c index ae2f57ab..65959765 100644 --- a/src/test_libFLAC/bitwriter.c +++ b/src/test_libFLAC/bitwriter.c @@ -52,9 +52,9 @@ typedef FLAC__uint64 bwword; struct FLAC__BitWriter { bwword *buffer; bwword accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */ - unsigned capacity; /* capacity of buffer in words */ - unsigned words; /* # of complete words in buffer */ - unsigned bits; /* # of used bits in accum */ + uint32_t capacity; /* capacity of buffer in words */ + uint32_t words; /* # of complete words in buffer */ + uint32_t bits; /* # of used bits in accum */ }; #define WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD) @@ -65,7 +65,7 @@ FLAC__bool test_bitwriter(void) { FLAC__BitWriter *bw; FLAC__bool ok; - unsigned i, j; + uint32_t i, j; #if FLAC__BYTES_PER_WORD == 4 #if WORDS_BIGENDIAN static bwword test_pattern1[5] = { 0xaaf0aabe, 0xaaaaaaa8, 0x300aaaaa, 0xaaadeadb, 0x00eeface }; @@ -81,7 +81,7 @@ FLAC__bool test_bitwriter(void) #else #error FLAC__BYTES_PER_WORD is neither 4 nor 8 -- not implemented #endif - unsigned words, bits; /* what we think bw->words and bw->bits should be */ + uint32_t words, bits; /* what we think bw->words and bw->bits should be */ printf("\n+++ libFLAC unit test: bitwriter\n\n"); diff --git a/src/test_libFLAC/decoders.c b/src/test_libFLAC/decoders.c index 29d54e53..46114f1e 100644 --- a/src/test_libFLAC/decoders.c +++ b/src/test_libFLAC/decoders.c @@ -52,14 +52,14 @@ typedef struct { Layer layer; FILE *file; char filename[512]; - unsigned current_metadata_number; + uint32_t current_metadata_number; FLAC__bool ignore_errors; FLAC__bool error_occurred; } StreamDecoderClientData; static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_; static FLAC__StreamMetadata *expected_metadata_sequence_[9]; -static unsigned num_expected_; +static uint32_t num_expected_; static FLAC__off_t flacfilesize_; static const char *flacfilename(FLAC__bool is_ogg) @@ -82,7 +82,7 @@ static FLAC__bool die_s_(const char *msg, const FLAC__StreamDecoder *decoder) else printf("FAILED"); - printf(", state = %u (%s)\n", (unsigned)state, FLAC__StreamDecoderStateString[state]); + printf(", state = %u (%s)\n", (uint32_t)state, FLAC__StreamDecoderStateString[state]); return false; } @@ -315,7 +315,7 @@ static void stream_decoder_error_callback_(const FLAC__StreamDecoder *decoder, F } if(!dcd->ignore_errors) { - printf("ERROR: got error callback: err = %u (%s)\n", (unsigned)status, FLAC__StreamDecoderErrorStatusString[status]); + printf("ERROR: got error callback: err = %u (%s)\n", (uint32_t)status, FLAC__StreamDecoderErrorStatusString[status]); dcd->error_occurred = true; } } @@ -585,7 +585,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) printf("testing FLAC__stream_decoder_get_channels()... "); { - unsigned channels = FLAC__stream_decoder_get_channels(decoder); + uint32_t channels = FLAC__stream_decoder_get_channels(decoder); if(channels != streaminfo_.data.stream_info.channels) { printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels); return false; @@ -595,7 +595,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) printf("testing FLAC__stream_decoder_get_bits_per_sample()... "); { - unsigned bits_per_sample = FLAC__stream_decoder_get_bits_per_sample(decoder); + uint32_t bits_per_sample = FLAC__stream_decoder_get_bits_per_sample(decoder); if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) { printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample); return false; @@ -605,7 +605,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) printf("testing FLAC__stream_decoder_get_sample_rate()... "); { - unsigned sample_rate = FLAC__stream_decoder_get_sample_rate(decoder); + uint32_t sample_rate = FLAC__stream_decoder_get_sample_rate(decoder); if(sample_rate != streaminfo_.data.stream_info.sample_rate) { printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate); return false; @@ -615,7 +615,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) printf("testing FLAC__stream_decoder_get_blocksize()... "); { - unsigned blocksize = FLAC__stream_decoder_get_blocksize(decoder); + uint32_t blocksize = FLAC__stream_decoder_get_blocksize(decoder); /* value could be anything since we're at the last block, so accept any reasonable answer */ printf("returned %u... %s\n", blocksize, blocksize>0? "OK" : "FAILED"); if(blocksize == 0) @@ -625,7 +625,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) printf("testing FLAC__stream_decoder_get_channel_assignment()... "); { FLAC__ChannelAssignment ca = FLAC__stream_decoder_get_channel_assignment(decoder); - printf("returned %u (%s)... OK\n", (unsigned)ca, FLAC__ChannelAssignmentString[ca]); + printf("returned %u (%s)... OK\n", (uint32_t)ca, FLAC__ChannelAssignmentString[ca]); } if(layer < LAYER_FILE) { diff --git a/src/test_libFLAC/encoders.c b/src/test_libFLAC/encoders.c index 064879fb..510a9c2a 100644 --- a/src/test_libFLAC/encoders.c +++ b/src/test_libFLAC/encoders.c @@ -49,7 +49,7 @@ static const char * const LayerString[] = { static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, picture_, unknown_; static FLAC__StreamMetadata *metadata_sequence_[] = { &vorbiscomment_, &padding_, &seektable_, &application1_, &application2_, &cuesheet_, &picture_, &unknown_ }; -static const unsigned num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]); +static const uint32_t num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]); static const char *flacfilename(FLAC__bool is_ogg) { @@ -71,10 +71,10 @@ static FLAC__bool die_s_(const char *msg, const FLAC__StreamEncoder *encoder) else printf("FAILED"); - printf(", state = %u (%s)\n", (unsigned)state, FLAC__StreamEncoderStateString[state]); + printf(", state = %u (%s)\n", (uint32_t)state, FLAC__StreamEncoderStateString[state]); if(state == FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) { FLAC__StreamDecoderState dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder); - printf(" verify decoder state = %u (%s)\n", (unsigned)dstate, FLAC__StreamDecoderStateString[dstate]); + printf(" verify decoder state = %u (%s)\n", (uint32_t)dstate, FLAC__StreamDecoderStateString[dstate]); } return false; @@ -107,7 +107,7 @@ static FLAC__StreamEncoderReadStatus stream_encoder_read_callback_(const FLAC__S return FLAC__STREAM_ENCODER_READ_STATUS_ABORT; } -static FLAC__StreamEncoderWriteStatus stream_encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) +static FLAC__StreamEncoderWriteStatus stream_encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) { FILE *f = (FILE*)client_data; (void)encoder, (void)samples, (void)current_frame; @@ -145,7 +145,7 @@ static void stream_encoder_metadata_callback_(const FLAC__StreamEncoder *encoder (void)encoder, (void)metadata, (void)client_data; } -static void stream_encoder_progress_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data) +static void stream_encoder_progress_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate, void *client_data) { (void)encoder, (void)bytes_written, (void)samples_written, (void)frames_written, (void)total_frames_estimate, (void)client_data; } @@ -159,7 +159,7 @@ static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg) FILE *file = 0; FLAC__int32 samples[1024]; FLAC__int32 *samples_array[1]; - unsigned i; + uint32_t i; samples_array[0] = samples; @@ -206,7 +206,7 @@ static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg) printf("OK\n"); printf("testing FLAC__stream_encoder_set_compression_level()... "); - if(!FLAC__stream_encoder_set_compression_level(encoder, (unsigned)(-1))) + if(!FLAC__stream_encoder_set_compression_level(encoder, (uint32_t)(-1))) return die_s_("returned false", encoder); printf("OK\n"); @@ -320,17 +320,17 @@ static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg) printf("testing FLAC__stream_encoder_get_state()... "); state = FLAC__stream_encoder_get_state(encoder); - printf("returned state = %u (%s)... OK\n", (unsigned)state, FLAC__StreamEncoderStateString[state]); + printf("returned state = %u (%s)... OK\n", (uint32_t)state, FLAC__StreamEncoderStateString[state]); printf("testing FLAC__stream_encoder_get_verify_decoder_state()... "); dstate = FLAC__stream_encoder_get_verify_decoder_state(encoder); - printf("returned state = %u (%s)... OK\n", (unsigned)dstate, FLAC__StreamDecoderStateString[dstate]); + printf("returned state = %u (%s)... OK\n", (uint32_t)dstate, FLAC__StreamDecoderStateString[dstate]); { FLAC__uint64 absolute_sample; - unsigned frame_number; - unsigned channel; - unsigned sample; + uint32_t frame_number; + uint32_t channel; + uint32_t sample; FLAC__int32 expected; FLAC__int32 got; diff --git a/src/test_libFLAC/endswap.c b/src/test_libFLAC/endswap.c index 09eefda9..b10dc3eb 100644 --- a/src/test_libFLAC/endswap.c +++ b/src/test_libFLAC/endswap.c @@ -38,7 +38,7 @@ FLAC__bool test_endswap(void) uint32_t u32 = 0xabcdef01; union { - unsigned char bytes[4]; + uint8_t bytes[4]; uint16_t u16; uint32_t u32; } data; @@ -69,22 +69,22 @@ FLAC__bool test_endswap(void) printf("testing ENDSWAP_32 on int32_t ... "); if (((int32_t) ENDSWAP_32 (i32)) == i32) { - printf("\nFAILED, ENDSWAP_32(0x%08x) -> 0x%08x == 0x%08x\n", i32, (unsigned) ENDSWAP_32 (i32), i32); + printf("\nFAILED, ENDSWAP_32(0x%08x) -> 0x%08x == 0x%08x\n", i32, (uint32_t) ENDSWAP_32 (i32), i32); return false; } if (((int32_t) ENDSWAP_32 (ENDSWAP_32 (i32))) != i32) { - printf("\nFAILED, ENDSWAP_32(ENDSWAP_32(0x%08x)) -> 0x%08x != 0x%08x\n", i32, (unsigned) ENDSWAP_32(ENDSWAP_32 (i32)), i32); + printf("\nFAILED, ENDSWAP_32(ENDSWAP_32(0x%08x)) -> 0x%08x != 0x%08x\n", i32, (uint32_t) ENDSWAP_32(ENDSWAP_32 (i32)), i32); return false; } puts("OK"); printf("testing ENDSWAP_32 on uint32_t ... "); if (((uint32_t) ENDSWAP_32(u32)) == u32) { - printf("\nFAILED, ENDSWAP_32(0x%08x) -> 0x%08x == 0x%08x\n", u32, (unsigned) ENDSWAP_32(u32), u32); + printf("\nFAILED, ENDSWAP_32(0x%08x) -> 0x%08x == 0x%08x\n", u32, (uint32_t) ENDSWAP_32(u32), u32); return false; } if (((uint32_t) ENDSWAP_32 (ENDSWAP_32(u32))) != u32) { - printf("\nFAILED, ENDSWAP_32(ENDSWAP_32(0x%08x)) -> 0x%08x != 0%08x\n", u32, (unsigned) ENDSWAP_32(ENDSWAP_32(u32)), u32); + printf("\nFAILED, ENDSWAP_32(ENDSWAP_32(0x%08x)) -> 0x%08x != 0%08x\n", u32, (uint32_t) ENDSWAP_32(ENDSWAP_32(u32)), u32); return false; } puts("OK"); diff --git a/src/test_libFLAC/format.c b/src/test_libFLAC/format.c index 636bc5a2..d57c11df 100644 --- a/src/test_libFLAC/format.c +++ b/src/test_libFLAC/format.c @@ -29,7 +29,7 @@ static const char *true_false_string_[2] = { "false", "true" }; static struct { - unsigned rate; + uint32_t rate; FLAC__bool valid; FLAC__bool subset; } SAMPLE_RATES[] = { @@ -89,7 +89,7 @@ static struct { }; static struct { - unsigned length; + uint32_t length; const FLAC__byte *string; FLAC__bool valid; } VCENTRY_VALUES[] = { @@ -153,7 +153,7 @@ static struct { }; static struct { - unsigned length; + uint32_t length; const FLAC__byte *string; FLAC__bool valid; } VCENTRIES[] = { @@ -194,7 +194,7 @@ static struct { FLAC__bool test_format(void) { - unsigned i; + uint32_t i; printf("\n+++ libFLAC unit test: format\n\n"); @@ -236,7 +236,7 @@ FLAC__bool test_format(void) for(i = 0; i < sizeof(VCENTRY_VALUES_NT)/sizeof(VCENTRY_VALUES_NT[0]); i++) { printf("testing FLAC__format_vorbiscomment_entry_value_is_legal(\"%s\", -1)... ", VCENTRY_VALUES_NT[i].string); - if(FLAC__format_vorbiscomment_entry_value_is_legal(VCENTRY_VALUES_NT[i].string, (unsigned)(-1)) != VCENTRY_VALUES_NT[i].valid) { + if(FLAC__format_vorbiscomment_entry_value_is_legal(VCENTRY_VALUES_NT[i].string, (uint32_t)(-1)) != VCENTRY_VALUES_NT[i].valid) { printf("FAILED, expected %s, got %s\n", true_false_string_[VCENTRY_VALUES_NT[i].valid], true_false_string_[!VCENTRY_VALUES_NT[i].valid]); return false; } diff --git a/src/test_libFLAC/md5.c b/src/test_libFLAC/md5.c index 75bcb65e..4b6edfed 100644 --- a/src/test_libFLAC/md5.c +++ b/src/test_libFLAC/md5.c @@ -31,7 +31,7 @@ static FLAC__bool test_md5_clear_context(void); static FLAC__bool test_md5_codec(void); -static FLAC__bool test_md5_accumulate(const FLAC__int32 * const * signal,unsigned channels, unsigned samples, unsigned bytes_per_sample, const FLAC__byte target_digest [16]); +static FLAC__bool test_md5_accumulate(const FLAC__int32 * const * signal,uint32_t channels, uint32_t samples, uint32_t bytes_per_sample, const FLAC__byte target_digest [16]); FLAC__bool test_md5(void) { @@ -54,7 +54,7 @@ static FLAC__bool test_md5_clear_context(void) FLAC__MD5Context ctx; FLAC__byte digest[16]; FLAC__byte target[16] = { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e }; - unsigned k ; + uint32_t k ; char * cptr; printf("testing FLAC__MD5Init ... "); @@ -167,12 +167,12 @@ static FLAC__byte target_digests [8][4][16] = static FLAC__bool test_md5_codec(void) { FLAC__int32 arrays[MAX_CHANNEL_COUNT][MD5_SAMPLE_COUNT], *pointer[MAX_CHANNEL_COUNT], **signal; - unsigned chan, byte_size, seed = 0x12345679; + uint32_t chan, byte_size, seed = 0x12345679; /* Set up signal data using a trival Linear Congruent PRNG. */ signal = &pointer[0]; for (chan = 0 ; chan < MAX_CHANNEL_COUNT ; chan ++) { - unsigned k; + uint32_t k; pointer[chan] = arrays [chan]; for (k = 0 ; k < MD5_SAMPLE_COUNT ; k++) { seed = seed * 1103515245 + 12345; @@ -190,7 +190,7 @@ static FLAC__bool test_md5_codec(void) return true; } -static FLAC__bool test_md5_accumulate(const FLAC__int32 * const * signal, unsigned channels, unsigned samples, unsigned bytes_per_sample, const FLAC__byte target_digest [16]) +static FLAC__bool test_md5_accumulate(const FLAC__int32 * const * signal, uint32_t channels, uint32_t samples, uint32_t bytes_per_sample, const FLAC__byte target_digest [16]) { FLAC__MD5Context ctx; FLAC__byte digest[16]; diff --git a/src/test_libFLAC/metadata_manip.c b/src/test_libFLAC/metadata_manip.c index 667af84e..db9bd101 100644 --- a/src/test_libFLAC/metadata_manip.c +++ b/src/test_libFLAC/metadata_manip.c @@ -62,14 +62,14 @@ typedef struct { typedef struct { FLAC__StreamMetadata *blocks[64]; - unsigned num_blocks; + uint32_t num_blocks; } our_metadata_struct; /* our copy of the metadata in flacfilename() */ static our_metadata_struct our_metadata_; /* the current block number that corresponds to the position of the iterator we are testing */ -static unsigned mc_our_block_number_ = 0; +static uint32_t mc_our_block_number_ = 0; static const char *flacfilename(FLAC__bool is_ogg) { @@ -100,7 +100,7 @@ static void *malloc_or_die_(size_t size) { void *x = malloc(size); if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (unsigned)size); + fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)size); exit(1); } return x; @@ -118,9 +118,9 @@ static char *strdup_or_die_(const char *s) /* functions for working with our metadata copy */ -static FLAC__bool replace_in_our_metadata_(FLAC__StreamMetadata *block, unsigned position, FLAC__bool copy) +static FLAC__bool replace_in_our_metadata_(FLAC__StreamMetadata *block, uint32_t position, FLAC__bool copy) { - unsigned i; + uint32_t i; FLAC__StreamMetadata *obj = block; FLAC__ASSERT(position < our_metadata_.num_blocks); if(copy) { @@ -138,9 +138,9 @@ static FLAC__bool replace_in_our_metadata_(FLAC__StreamMetadata *block, unsigned return true; } -static FLAC__bool insert_to_our_metadata_(FLAC__StreamMetadata *block, unsigned position, FLAC__bool copy) +static FLAC__bool insert_to_our_metadata_(FLAC__StreamMetadata *block, uint32_t position, FLAC__bool copy) { - unsigned i; + uint32_t i; FLAC__StreamMetadata *obj = block; if(copy) { if(0 == (obj = FLAC__metadata_object_clone(block))) @@ -164,9 +164,9 @@ static FLAC__bool insert_to_our_metadata_(FLAC__StreamMetadata *block, unsigned return true; } -static void delete_from_our_metadata_(unsigned position) +static void delete_from_our_metadata_(uint32_t position) { - unsigned i; + uint32_t i; FLAC__ASSERT(position < our_metadata_.num_blocks); FLAC__metadata_object_delete(our_metadata_.blocks[position]); for(i = position; i < our_metadata_.num_blocks - 1; i++) @@ -386,9 +386,9 @@ static FLAC__bool read_chain_(FLAC__Metadata_Chain *chain, const char *filename, /* function for comparing our metadata to a FLAC__Metadata_Chain */ -static FLAC__bool compare_chain_(FLAC__Metadata_Chain *chain, unsigned current_position, FLAC__StreamMetadata *current_block) +static FLAC__bool compare_chain_(FLAC__Metadata_Chain *chain, uint32_t current_position, FLAC__StreamMetadata *current_block) { - unsigned i; + uint32_t i; FLAC__Metadata_Iterator *iterator; FLAC__StreamMetadata *block; FLAC__bool next_ok = true; @@ -504,14 +504,14 @@ static void decoder_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__St (void)decoder; dcd->error_occurred = true; - printf("ERROR: got error callback, status = %s (%u)\n", FLAC__StreamDecoderErrorStatusString[status], (unsigned)status); + printf("ERROR: got error callback, status = %s (%u)\n", FLAC__StreamDecoderErrorStatusString[status], (uint32_t)status); } static FLAC__bool generate_file_(FLAC__bool include_extras, FLAC__bool is_ogg) { FLAC__StreamMetadata streaminfo, vorbiscomment, *cuesheet, picture, padding; FLAC__StreamMetadata *metadata[4]; - unsigned i = 0, n = 0; + uint32_t i = 0, n = 0; printf("generating %sFLAC file for test\n", is_ogg? "Ogg " : ""); @@ -532,7 +532,7 @@ static FLAC__bool generate_file_(FLAC__bool include_extras, FLAC__bool is_ogg) memset(streaminfo.data.stream_info.md5sum, 0, 16); { - const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING); + const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); vorbiscomment.is_last = false; vorbiscomment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT; vorbiscomment.length = (4 + vendor_string_length) + 4; @@ -748,7 +748,7 @@ static FLAC__bool test_level_0_(void) printf("testing FLAC__metadata_get_picture()... "); - if(!FLAC__metadata_get_picture(flacfilename(/*is_ogg=*/false), &picture, /*type=*/(FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(unsigned)(-1), /*max_height=*/(unsigned)(-1), /*max_depth=*/(unsigned)(-1), /*max_colors=*/(unsigned)(-1))) + if(!FLAC__metadata_get_picture(flacfilename(/*is_ogg=*/false), &picture, /*type=*/(FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(uint32_t)(-1), /*max_height=*/(uint32_t)(-1), /*max_depth=*/(uint32_t)(-1), /*max_colors=*/(uint32_t)(-1))) return die_("during FLAC__metadata_get_picture()"); /* check to see if some basic data matches (c.f. generate_file_()) */ @@ -770,7 +770,7 @@ static FLAC__bool test_level_1_(void) FLAC__Metadata_SimpleIterator *iterator; FLAC__StreamMetadata *block, *app, *padding; FLAC__byte data[1000]; - unsigned our_current_position = 0; + uint32_t our_current_position = 0; /* initialize 'data' to avoid Valgrind errors */ memset(data, 0, sizeof(data)); @@ -796,7 +796,7 @@ static FLAC__bool test_level_1_(void) if(!FLAC__metadata_simple_iterator_init(iterator, flacfilename(/*is_ogg=*/false), /*read_only=*/false, /*preserve_file_stats=*/false)) return die_("FLAC__metadata_simple_iterator_init() returned false"); - printf("is writable = %u\n", (unsigned)FLAC__metadata_simple_iterator_is_writable(iterator)); + printf("is writable = %u\n", (uint32_t)FLAC__metadata_simple_iterator_is_writable(iterator)); if(FLAC__metadata_simple_iterator_is_writable(iterator)) return die_("iterator claims file is writable when tester thinks it should not be; are you running as root?\n"); @@ -892,7 +892,7 @@ static FLAC__bool test_level_1_(void) return die_("FLAC__metadata_simple_iterator_init() returned false"); our_current_position = 0; - printf("is writable = %u\n", (unsigned)FLAC__metadata_simple_iterator_is_writable(iterator)); + printf("is writable = %u\n", (uint32_t)FLAC__metadata_simple_iterator_is_writable(iterator)); printf("[S]VP\ttry to write over STREAMINFO block...\n"); if(!FLAC__metadata_simple_iterator_set_block(iterator, app, false)) @@ -1431,7 +1431,7 @@ static FLAC__bool test_level_2_(FLAC__bool filename_based, FLAC__bool is_ogg) FLAC__Metadata_Chain *chain; FLAC__StreamMetadata *block, *app, *padding; FLAC__byte data[2000]; - unsigned our_current_position; + uint32_t our_current_position; /* initialize 'data' to avoid Valgrind errors */ memset(data, 0, sizeof(data)); diff --git a/src/test_libFLAC/metadata_object.c b/src/test_libFLAC/metadata_object.c index 4ab4077e..b52b923d 100644 --- a/src/test_libFLAC/metadata_object.c +++ b/src/test_libFLAC/metadata_object.c @@ -30,7 +30,7 @@ #include <stdlib.h> /* for malloc() */ #include <string.h> /* for memcmp() */ -static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, unsigned len) +static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, uint32_t len) { FLAC__byte *ret; @@ -46,14 +46,14 @@ static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, unsigned len) static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from, const FLAC__StreamMetadata_CueSheet_Track *to) { - unsigned i; + uint32_t i; if(from->offset != to->offset) { printf("FAILED, track offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", to->offset, from->offset); return false; } if(from->number != to->number) { - printf("FAILED, track number mismatch, expected %u, got %u\n", (unsigned)to->number, (unsigned)from->number); + printf("FAILED, track number mismatch, expected %u, got %u\n", (uint32_t)to->number, (uint32_t)from->number); return false; } if(0 != strcmp(from->isrc, to->isrc)) { @@ -61,15 +61,15 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from return false; } if(from->type != to->type) { - printf("FAILED, track type mismatch, expected %u, got %u\n", (unsigned)to->type, (unsigned)from->type); + printf("FAILED, track type mismatch, expected %u, got %u\n", (uint32_t)to->type, (uint32_t)from->type); return false; } if(from->pre_emphasis != to->pre_emphasis) { - printf("FAILED, track pre_emphasis mismatch, expected %u, got %u\n", (unsigned)to->pre_emphasis, (unsigned)from->pre_emphasis); + printf("FAILED, track pre_emphasis mismatch, expected %u, got %u\n", (uint32_t)to->pre_emphasis, (uint32_t)from->pre_emphasis); return false; } if(from->num_indices != to->num_indices) { - printf("FAILED, track num_indices mismatch, expected %u, got %u\n", (unsigned)to->num_indices, (unsigned)from->num_indices); + printf("FAILED, track num_indices mismatch, expected %u, got %u\n", (uint32_t)to->num_indices, (uint32_t)from->num_indices); return false; } if(0 == to->indices || 0 == from->indices) { @@ -85,7 +85,7 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from return false; } if(from->indices[i].number != to->indices[i].number) { - printf("FAILED, track indices[%u].number mismatch, expected %u, got %u\n", i, (unsigned)to->indices[i].number, (unsigned)from->indices[i].number); + printf("FAILED, track indices[%u].number mismatch, expected %u, got %u\n", i, (uint32_t)to->indices[i].number, (uint32_t)from->indices[i].number); return false; } } @@ -94,9 +94,9 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from return true; } -static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint *from, const FLAC__StreamMetadata_SeekPoint *to, unsigned n) +static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint *from, const FLAC__StreamMetadata_SeekPoint *to, uint32_t n) { - unsigned i; + uint32_t i; FLAC__ASSERT(0 != from); FLAC__ASSERT(0 != to); @@ -119,9 +119,9 @@ static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint return true; } -static FLAC__bool check_seektable_(const FLAC__StreamMetadata *block, unsigned num_points, const FLAC__StreamMetadata_SeekPoint *array) +static FLAC__bool check_seektable_(const FLAC__StreamMetadata *block, uint32_t num_points, const FLAC__StreamMetadata_SeekPoint *array) { - const unsigned expected_length = num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; + const uint32_t expected_length = num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH; if(block->length != expected_length) { printf("FAILED, bad length, expected %u, got %u\n", expected_length, block->length); @@ -167,7 +167,7 @@ static void entry_clone_(FLAC__StreamMetadata_VorbisComment_Entry *entry) static void vc_calc_len_(FLAC__StreamMetadata *block) { const FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment; - unsigned i; + uint32_t i; block->length = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8; block->length += vc->vendor_string.length; @@ -178,14 +178,14 @@ static void vc_calc_len_(FLAC__StreamMetadata *block) } } -static void vc_resize_(FLAC__StreamMetadata *block, unsigned num) +static void vc_resize_(FLAC__StreamMetadata *block, uint32_t num) { FLAC__StreamMetadata_VorbisComment *vc = &block->data.vorbis_comment; if(vc->num_comments != 0) { FLAC__ASSERT(0 != vc->comments); if(num < vc->num_comments) { - unsigned i; + uint32_t i; for(i = num; i < vc->num_comments; i++) { if(0 != vc->comments[i].entry) free(vc->comments[i].entry); @@ -209,10 +209,10 @@ static void vc_resize_(FLAC__StreamMetadata *block, unsigned num) vc_calc_len_(block); } -static int vc_find_from_(FLAC__StreamMetadata *block, const char *name, unsigned start) +static int vc_find_from_(FLAC__StreamMetadata *block, const char *name, uint32_t start) { - const unsigned n = strlen(name); - unsigned i; + const uint32_t n = strlen(name); + uint32_t i; for(i = start; i < block->data.vorbis_comment.num_comments; i++) { const FLAC__StreamMetadata_VorbisComment_Entry *entry = &block->data.vorbis_comment.comments[i]; if(entry->length > n && 0 == strncmp((const char *)entry->entry, name, n) && entry->entry[n] == '=') @@ -230,7 +230,7 @@ static void vc_set_vs_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC vc_calc_len_(block); } -static void vc_set_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, unsigned pos, const char *field) +static void vc_set_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, uint32_t pos, const char *field) { if(0 != block->data.vorbis_comment.comments[pos].entry) free(block->data.vorbis_comment.comments[pos].entry); @@ -239,7 +239,7 @@ static void vc_set_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__S vc_calc_len_(block); } -static void vc_insert_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, unsigned pos, const char *field) +static void vc_insert_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC__StreamMetadata *block, uint32_t pos, const char *field) { vc_resize_(block, block->data.vorbis_comment.num_comments+1); memmove(&block->data.vorbis_comment.comments[pos+1], &block->data.vorbis_comment.comments[pos], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(block->data.vorbis_comment.num_comments-1-pos)); @@ -248,7 +248,7 @@ static void vc_insert_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLAC vc_calc_len_(block); } -static void vc_delete_(FLAC__StreamMetadata *block, unsigned pos) +static void vc_delete_(FLAC__StreamMetadata *block, uint32_t pos) { if(0 != block->data.vorbis_comment.comments[pos].entry) free(block->data.vorbis_comment.comments[pos].entry); @@ -264,7 +264,7 @@ static void vc_replace_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLA int indx; char field_name[256]; const char *eq = strchr(field, '='); - FLAC__ASSERT(eq>field && (unsigned)(eq-field) < sizeof(field_name)); + FLAC__ASSERT(eq>field && (uint32_t)(eq-field) < sizeof(field_name)); memcpy(field_name, field, eq-field); field_name[eq-field]='\0'; @@ -272,11 +272,11 @@ static void vc_replace_new_(FLAC__StreamMetadata_VorbisComment_Entry *entry, FLA if(indx < 0) vc_insert_new_(entry, block, block->data.vorbis_comment.num_comments, field); else { - vc_set_new_(entry, block, (unsigned)indx, field); + vc_set_new_(entry, block, (uint32_t)indx, field); if(all) { - for(indx = indx+1; indx >= 0 && (unsigned)indx < block->data.vorbis_comment.num_comments; ) - if((indx = vc_find_from_(block, field_name, (unsigned)indx)) >= 0) - vc_delete_(block, (unsigned)indx); + for(indx = indx+1; indx >= 0 && (uint32_t)indx < block->data.vorbis_comment.num_comments; ) + if((indx = vc_find_from_(block, field_name, (uint32_t)indx)) >= 0) + vc_delete_(block, (uint32_t)indx); } } @@ -308,7 +308,7 @@ static void track_clone_(FLAC__StreamMetadata_CueSheet_Track *track) static void cs_calc_len_(FLAC__StreamMetadata *block) { const FLAC__StreamMetadata_CueSheet *cs = &block->data.cue_sheet; - unsigned i; + uint32_t i; block->length = ( FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN + @@ -335,7 +335,7 @@ static void cs_calc_len_(FLAC__StreamMetadata *block) } } -static void tr_resize_(FLAC__StreamMetadata *block, unsigned track_num, unsigned num) +static void tr_resize_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t num) { FLAC__StreamMetadata_CueSheet_Track *tr; @@ -363,7 +363,7 @@ static void tr_resize_(FLAC__StreamMetadata *block, unsigned track_num, unsigned cs_calc_len_(block); } -static void tr_set_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index indx) +static void tr_set_new_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t pos, FLAC__StreamMetadata_CueSheet_Index indx) { FLAC__StreamMetadata_CueSheet_Track *tr; @@ -378,7 +378,7 @@ static void tr_set_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigne cs_calc_len_(block); } -static void tr_insert_new_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos, FLAC__StreamMetadata_CueSheet_Index indx) +static void tr_insert_new_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t pos, FLAC__StreamMetadata_CueSheet_Index indx) { FLAC__StreamMetadata_CueSheet_Track *tr; @@ -394,7 +394,7 @@ static void tr_insert_new_(FLAC__StreamMetadata *block, unsigned track_num, unsi cs_calc_len_(block); } -static void tr_delete_(FLAC__StreamMetadata *block, unsigned track_num, unsigned pos) +static void tr_delete_(FLAC__StreamMetadata *block, uint32_t track_num, uint32_t pos) { FLAC__StreamMetadata_CueSheet_Track *tr; @@ -409,14 +409,14 @@ static void tr_delete_(FLAC__StreamMetadata *block, unsigned track_num, unsigned cs_calc_len_(block); } -static void cs_resize_(FLAC__StreamMetadata *block, unsigned num) +static void cs_resize_(FLAC__StreamMetadata *block, uint32_t num) { FLAC__StreamMetadata_CueSheet *cs = &block->data.cue_sheet; if(cs->num_tracks != 0) { FLAC__ASSERT(0 != cs->tracks); if(num < cs->num_tracks) { - unsigned i; + uint32_t i; for(i = num; i < cs->num_tracks; i++) { if(0 != cs->tracks[i].indices) free(cs->tracks[i].indices); @@ -440,14 +440,14 @@ static void cs_resize_(FLAC__StreamMetadata *block, unsigned num) cs_calc_len_(block); } -static void cs_set_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, unsigned pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) +static void cs_set_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, uint32_t pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) { track_new_(track, offset, number, isrc, data, pre_em); block->data.cue_sheet.tracks[pos] = *track; cs_calc_len_(block); } -static void cs_insert_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, unsigned pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) +static void cs_insert_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__StreamMetadata *block, uint32_t pos, FLAC__uint64 offset, FLAC__byte number, const char *isrc, FLAC__bool data, FLAC__bool pre_em) { cs_resize_(block, block->data.cue_sheet.num_tracks+1); memmove(&block->data.cue_sheet.tracks[pos+1], &block->data.cue_sheet.tracks[pos], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(block->data.cue_sheet.num_tracks-1-pos)); @@ -455,7 +455,7 @@ static void cs_insert_new_(FLAC__StreamMetadata_CueSheet_Track *track, FLAC__Str cs_calc_len_(block); } -static void cs_delete_(FLAC__StreamMetadata *block, unsigned pos) +static void cs_delete_(FLAC__StreamMetadata *block, uint32_t pos) { if(0 != block->data.cue_sheet.tracks[pos].indices) free(block->data.cue_sheet.tracks[pos].indices); @@ -507,7 +507,7 @@ FLAC__bool test_metadata_object(void) FLAC__StreamMetadata_VorbisComment_Entry entry; FLAC__StreamMetadata_CueSheet_Index indx; FLAC__StreamMetadata_CueSheet_Track track; - unsigned i, expected_length, seekpoints; + uint32_t i, expected_length, seekpoints; int j; static FLAC__byte dummydata[4] = { 'a', 'b', 'c', 'd' }; diff --git a/src/test_libs_common/file_utils_flac.c b/src/test_libs_common/file_utils_flac.c index ed497cec..28ab08d5 100644 --- a/src/test_libs_common/file_utils_flac.c +++ b/src/test_libs_common/file_utils_flac.c @@ -52,7 +52,7 @@ typedef struct { FILE *file; } encoder_client_struct; -static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) +static FLAC__StreamEncoderWriteStatus encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, uint32_t samples, uint32_t current_frame, void *client_data) { encoder_client_struct *ecd = (encoder_client_struct*)client_data; @@ -69,13 +69,13 @@ static void encoder_metadata_callback_(const FLAC__StreamEncoder *encoder, const (void)encoder, (void)metadata, (void)client_data; } -FLAC__bool file_utils__generate_flacfile(FLAC__bool is_ogg, const char *output_filename, FLAC__off_t *output_filesize, unsigned length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, unsigned num_metadata) +FLAC__bool file_utils__generate_flacfile(FLAC__bool is_ogg, const char *output_filename, FLAC__off_t *output_filesize, uint32_t length, const FLAC__StreamMetadata *streaminfo, FLAC__StreamMetadata **metadata, uint32_t num_metadata) { FLAC__int32 samples[1024]; FLAC__StreamEncoder *encoder; FLAC__StreamEncoderInitStatus init_status; encoder_client_struct encoder_client_data; - unsigned i, n; + uint32_t i, n; FLAC__ASSERT(0 != output_filename); FLAC__ASSERT(0 != streaminfo); diff --git a/src/test_libs_common/metadata_utils.c b/src/test_libs_common/metadata_utils.c index d13f1015..a3f44991 100644 --- a/src/test_libs_common/metadata_utils.c +++ b/src/test_libs_common/metadata_utils.c @@ -68,52 +68,52 @@ FLAC__bool mutils__compare_block_data_streaminfo(const FLAC__StreamMetadata_Stre } if(0 != memcmp(blockcopy->md5sum, block->md5sum, sizeof(block->md5sum))) { printf("FAILED, md5sum mismatch, expected %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X, got %02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", - (unsigned)block->md5sum[0], - (unsigned)block->md5sum[1], - (unsigned)block->md5sum[2], - (unsigned)block->md5sum[3], - (unsigned)block->md5sum[4], - (unsigned)block->md5sum[5], - (unsigned)block->md5sum[6], - (unsigned)block->md5sum[7], - (unsigned)block->md5sum[8], - (unsigned)block->md5sum[9], - (unsigned)block->md5sum[10], - (unsigned)block->md5sum[11], - (unsigned)block->md5sum[12], - (unsigned)block->md5sum[13], - (unsigned)block->md5sum[14], - (unsigned)block->md5sum[15], - (unsigned)blockcopy->md5sum[0], - (unsigned)blockcopy->md5sum[1], - (unsigned)blockcopy->md5sum[2], - (unsigned)blockcopy->md5sum[3], - (unsigned)blockcopy->md5sum[4], - (unsigned)blockcopy->md5sum[5], - (unsigned)blockcopy->md5sum[6], - (unsigned)blockcopy->md5sum[7], - (unsigned)blockcopy->md5sum[8], - (unsigned)blockcopy->md5sum[9], - (unsigned)blockcopy->md5sum[10], - (unsigned)blockcopy->md5sum[11], - (unsigned)blockcopy->md5sum[12], - (unsigned)blockcopy->md5sum[13], - (unsigned)blockcopy->md5sum[14], - (unsigned)blockcopy->md5sum[15] + (uint32_t)block->md5sum[0], + (uint32_t)block->md5sum[1], + (uint32_t)block->md5sum[2], + (uint32_t)block->md5sum[3], + (uint32_t)block->md5sum[4], + (uint32_t)block->md5sum[5], + (uint32_t)block->md5sum[6], + (uint32_t)block->md5sum[7], + (uint32_t)block->md5sum[8], + (uint32_t)block->md5sum[9], + (uint32_t)block->md5sum[10], + (uint32_t)block->md5sum[11], + (uint32_t)block->md5sum[12], + (uint32_t)block->md5sum[13], + (uint32_t)block->md5sum[14], + (uint32_t)block->md5sum[15], + (uint32_t)blockcopy->md5sum[0], + (uint32_t)blockcopy->md5sum[1], + (uint32_t)blockcopy->md5sum[2], + (uint32_t)blockcopy->md5sum[3], + (uint32_t)blockcopy->md5sum[4], + (uint32_t)blockcopy->md5sum[5], + (uint32_t)blockcopy->md5sum[6], + (uint32_t)blockcopy->md5sum[7], + (uint32_t)blockcopy->md5sum[8], + (uint32_t)blockcopy->md5sum[9], + (uint32_t)blockcopy->md5sum[10], + (uint32_t)blockcopy->md5sum[11], + (uint32_t)blockcopy->md5sum[12], + (uint32_t)blockcopy->md5sum[13], + (uint32_t)blockcopy->md5sum[14], + (uint32_t)blockcopy->md5sum[15] ); return false; } return true; } -FLAC__bool mutils__compare_block_data_padding(const FLAC__StreamMetadata_Padding *block, const FLAC__StreamMetadata_Padding *blockcopy, unsigned block_length) +FLAC__bool mutils__compare_block_data_padding(const FLAC__StreamMetadata_Padding *block, const FLAC__StreamMetadata_Padding *blockcopy, uint32_t block_length) { /* we don't compare the padding guts */ (void)block, (void)blockcopy, (void)block_length; return true; } -FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_Application *block, const FLAC__StreamMetadata_Application *blockcopy, unsigned block_length) +FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_Application *block, const FLAC__StreamMetadata_Application *blockcopy, uint32_t block_length) { if(block_length < sizeof(block->id)) { printf("FAILED, bad block length = %u\n", block_length); @@ -121,14 +121,14 @@ FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_App } if(0 != memcmp(blockcopy->id, block->id, sizeof(block->id))) { printf("FAILED, id mismatch, expected %02X%02X%02X%02X, got %02X%02X%02X%02X\n", - (unsigned)block->id[0], - (unsigned)block->id[1], - (unsigned)block->id[2], - (unsigned)block->id[3], - (unsigned)blockcopy->id[0], - (unsigned)blockcopy->id[1], - (unsigned)blockcopy->id[2], - (unsigned)blockcopy->id[3] + (uint32_t)block->id[0], + (uint32_t)block->id[1], + (uint32_t)block->id[2], + (uint32_t)block->id[3], + (uint32_t)blockcopy->id[0], + (uint32_t)blockcopy->id[1], + (uint32_t)blockcopy->id[2], + (uint32_t)blockcopy->id[3] ); return false; } @@ -157,7 +157,7 @@ FLAC__bool mutils__compare_block_data_application(const FLAC__StreamMetadata_App FLAC__bool mutils__compare_block_data_seektable(const FLAC__StreamMetadata_SeekTable *block, const FLAC__StreamMetadata_SeekTable *blockcopy) { - unsigned i; + uint32_t i; if(blockcopy->num_points != block->num_points) { printf("FAILED, num_points mismatch, expected %u, got %u\n", block->num_points, blockcopy->num_points); return false; @@ -181,7 +181,7 @@ FLAC__bool mutils__compare_block_data_seektable(const FLAC__StreamMetadata_SeekT FLAC__bool mutils__compare_block_data_vorbiscomment(const FLAC__StreamMetadata_VorbisComment *block, const FLAC__StreamMetadata_VorbisComment *blockcopy) { - unsigned i; + uint32_t i; if(blockcopy->vendor_string.length != block->vendor_string.length) { printf("FAILED, vendor_string.length mismatch, expected %u, got %u\n", block->vendor_string.length, blockcopy->vendor_string.length); return false; @@ -223,7 +223,7 @@ FLAC__bool mutils__compare_block_data_vorbiscomment(const FLAC__StreamMetadata_V FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueSheet *block, const FLAC__StreamMetadata_CueSheet *blockcopy) { - unsigned i, j; + uint32_t i, j; if(0 != strcmp(blockcopy->media_catalog_number, block->media_catalog_number)) { printf("FAILED, media_catalog_number mismatch, expected %s, got %s\n", block->media_catalog_number, blockcopy->media_catalog_number); @@ -234,7 +234,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe return false; } if(blockcopy->is_cd != block->is_cd) { - printf("FAILED, is_cd mismatch, expected %u, got %u\n", (unsigned)block->is_cd, (unsigned)blockcopy->is_cd); + printf("FAILED, is_cd mismatch, expected %u, got %u\n", (uint32_t)block->is_cd, (uint32_t)blockcopy->is_cd); return false; } if(blockcopy->num_tracks != block->num_tracks) { @@ -247,11 +247,11 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe return false; } if(blockcopy->tracks[i].number != block->tracks[i].number) { - printf("FAILED, tracks[%u].number mismatch, expected %u, got %u\n", i, (unsigned)block->tracks[i].number, (unsigned)blockcopy->tracks[i].number); + printf("FAILED, tracks[%u].number mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].number, (uint32_t)blockcopy->tracks[i].number); return false; } if(blockcopy->tracks[i].num_indices != block->tracks[i].num_indices) { - printf("FAILED, tracks[%u].num_indices mismatch, expected %u, got %u\n", i, (unsigned)block->tracks[i].num_indices, (unsigned)blockcopy->tracks[i].num_indices); + printf("FAILED, tracks[%u].num_indices mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].num_indices, (uint32_t)blockcopy->tracks[i].num_indices); return false; } /* num_indices == 0 means lead-out track so only the track offset and number are valid */ @@ -261,11 +261,11 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe return false; } if(blockcopy->tracks[i].type != block->tracks[i].type) { - printf("FAILED, tracks[%u].type mismatch, expected %u, got %u\n", i, (unsigned)block->tracks[i].type, (unsigned)blockcopy->tracks[i].type); + printf("FAILED, tracks[%u].type mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].type, (uint32_t)blockcopy->tracks[i].type); return false; } if(blockcopy->tracks[i].pre_emphasis != block->tracks[i].pre_emphasis) { - printf("FAILED, tracks[%u].pre_emphasis mismatch, expected %u, got %u\n", i, (unsigned)block->tracks[i].pre_emphasis, (unsigned)blockcopy->tracks[i].pre_emphasis); + printf("FAILED, tracks[%u].pre_emphasis mismatch, expected %u, got %u\n", i, (uint32_t)block->tracks[i].pre_emphasis, (uint32_t)blockcopy->tracks[i].pre_emphasis); return false; } if(0 == block->tracks[i].indices || 0 == blockcopy->tracks[i].indices) { @@ -281,7 +281,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe return false; } if(blockcopy->tracks[i].indices[j].number != block->tracks[i].indices[j].number) { - printf("FAILED, tracks[%u].indices[%u].number mismatch, expected %u, got %u\n", i, j, (unsigned)block->tracks[i].indices[j].number, (unsigned)blockcopy->tracks[i].indices[j].number); + printf("FAILED, tracks[%u].indices[%u].number mismatch, expected %u, got %u\n", i, j, (uint32_t)block->tracks[i].indices[j].number, (uint32_t)blockcopy->tracks[i].indices[j].number); return false; } } @@ -295,13 +295,13 @@ FLAC__bool mutils__compare_block_data_picture(const FLAC__StreamMetadata_Picture { size_t len, lencopy; if(blockcopy->type != block->type) { - printf("FAILED, type mismatch, expected %u, got %u\n", (unsigned)block->type, (unsigned)blockcopy->type); + printf("FAILED, type mismatch, expected %u, got %u\n", (uint32_t)block->type, (uint32_t)blockcopy->type); return false; } len = strlen(block->mime_type); lencopy = strlen(blockcopy->mime_type); if(lencopy != len) { - printf("FAILED, mime_type length mismatch, expected %u, got %u\n", (unsigned)len, (unsigned)lencopy); + printf("FAILED, mime_type length mismatch, expected %u, got %u\n", (uint32_t)len, (uint32_t)lencopy); return false; } if(strcmp(blockcopy->mime_type, block->mime_type)) { @@ -311,7 +311,7 @@ FLAC__bool mutils__compare_block_data_picture(const FLAC__StreamMetadata_Picture len = strlen((const char *)block->description); lencopy = strlen((const char *)blockcopy->description); if(lencopy != len) { - printf("FAILED, description length mismatch, expected %u, got %u\n", (unsigned)len, (unsigned)lencopy); + printf("FAILED, description length mismatch, expected %u, got %u\n", (uint32_t)len, (uint32_t)lencopy); return false; } if(strcmp((const char *)blockcopy->description, (const char *)block->description)) { @@ -345,7 +345,7 @@ FLAC__bool mutils__compare_block_data_picture(const FLAC__StreamMetadata_Picture return true; } -FLAC__bool mutils__compare_block_data_unknown(const FLAC__StreamMetadata_Unknown *block, const FLAC__StreamMetadata_Unknown *blockcopy, unsigned block_length) +FLAC__bool mutils__compare_block_data_unknown(const FLAC__StreamMetadata_Unknown *block, const FLAC__StreamMetadata_Unknown *blockcopy, uint32_t block_length) { if(0 == block->data || 0 == blockcopy->data) { if(block->data != blockcopy->data) { @@ -377,7 +377,7 @@ FLAC__bool mutils__compare_block(const FLAC__StreamMetadata *block, const FLAC__ return false; } if(blockcopy->is_last != block->is_last) { - printf("FAILED, is_last mismatch, expected %u, got %u\n", (unsigned)block->is_last, (unsigned)blockcopy->is_last); + printf("FAILED, is_last mismatch, expected %u, got %u\n", (uint32_t)block->is_last, (uint32_t)blockcopy->is_last); return false; } if(blockcopy->length != block->length) { @@ -408,7 +408,7 @@ static void *malloc_or_die_(size_t size) { void *x = malloc(size); if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (unsigned)size); + fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)size); exit(1); } return x; @@ -418,7 +418,7 @@ static void *calloc_or_die_(size_t n, size_t size) { void *x = calloc(n, size); if(0 == x) { - fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (unsigned)n * (unsigned)size); + fprintf(stderr, "ERROR: out of memory allocating %u bytes\n", (uint32_t)n * (uint32_t)size); exit(1); } return x; @@ -498,7 +498,7 @@ void mutils__init_metadata_blocks( application2->data.application.data = 0; { - const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING); + const uint32_t vendor_string_length = (uint32_t)strlen(FLAC__VENDOR_STRING); vorbiscomment->is_last = false; vorbiscomment->type = FLAC__METADATA_TYPE_VORBIS_COMMENT; vorbiscomment->length = (4 + vendor_string_length) + 4 + (4 + 5) + (4 + 0); diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index ea4242a4..5a7e3999 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -40,8 +40,8 @@ typedef struct { FLAC__int32 **pcm; FLAC__bool got_data; FLAC__uint64 total_samples; - unsigned channels; - unsigned bits_per_sample; + uint32_t channels; + uint32_t bits_per_sample; FLAC__bool quiet; FLAC__bool ignore_errors; FLAC__bool error_occurred; @@ -72,12 +72,12 @@ static FLAC__bool die_s_(const char *msg, const FLAC__StreamDecoder *decoder) else printf("FAILED"); - printf(", state = %u (%s)\n", (unsigned)state, FLAC__StreamDecoderStateString[state]); + printf(", state = %u (%s)\n", (uint32_t)state, FLAC__StreamDecoderStateString[state]); return false; } -static unsigned local_rand_(void) +static uint32_t local_rand_(void) { #if !defined _MSC_VER && !defined __MINGW32__ #define RNDFUNC random @@ -105,7 +105,7 @@ static FLAC__off_t get_filesize_(const char *srcpath) static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const char *flacfilename) { FILE *f; - unsigned channels = 0, bps = 0, samples, i, j; + uint32_t channels = 0, bps = 0, samples, i, j; FLAC__off_t rawfilesize = get_filesize_(rawfilename); if (rawfilesize < 0) { @@ -174,7 +174,7 @@ static FLAC__bool read_pcm_(FLAC__int32 *pcm[], const char *rawfilename, const c } } else { /* bps == 16 */ - unsigned char c[2]; + uint8_t c[2]; uint16_t value; for(i = 0; i < samples; i++) { for(j = 0; j < channels; j++) { @@ -210,9 +210,9 @@ static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder /* check against PCM data if we have it */ if (dcd->pcm) { - unsigned c, i, j; + uint32_t c, i, j; for (c = 0; c < frame->header.channels; c++) - for (i = (unsigned)frame->header.number.sample_number, j = 0; j < frame->header.blocksize; i++, j++) + for (i = (uint32_t)frame->header.number.sample_number, j = 0; j < frame->header.blocksize; i++, j++) if (buffer[c][j] != dcd->pcm[c][i]) { printf("ERROR: sample mismatch at sample#%u(%u), channel=%u, expected %d, got %d\n", i, j, c, buffer[c][j], dcd->pcm[c][i]); return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; @@ -256,7 +256,7 @@ static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDeco } if(!dcd->ignore_errors) { - printf("ERROR: got error callback: err = %u (%s)\n", (unsigned)status, FLAC__StreamDecoderErrorStatusString[status]); + printf("ERROR: got error callback: err = %u (%s)\n", (uint32_t)status, FLAC__StreamDecoderErrorStatusString[status]); dcd->error_occurred = true; } } @@ -266,11 +266,11 @@ static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDeco * 1 - read 2 frames * 2 - read until end */ -static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, FLAC__off_t filesize, unsigned count, FLAC__int64 total_samples, unsigned read_mode, FLAC__int32 **pcm) +static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, FLAC__off_t filesize, uint32_t count, FLAC__int64 total_samples, uint32_t read_mode, FLAC__int32 **pcm) { FLAC__StreamDecoder *decoder; DecoderClientData decoder_client_data; - unsigned i; + uint32_t i; long int n; decoder_client_data.pcm = pcm; @@ -396,7 +396,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, FLAC__of int main(int argc, char *argv[]) { const char *flacfilename, *rawfilename = 0; - unsigned count = 0, read_mode; + uint32_t count = 0, read_mode; FLAC__int64 samples = -1; FLAC__off_t flacfilesize; FLAC__int32 *pcm[2] = { 0, 0 }; @@ -432,7 +432,7 @@ int main(int argc, char *argv[]) srandom(tv.tv_usec); } #else - srand((unsigned)time(0)); + srand((uint32_t)time(0)); #endif flacfilesize = get_filesize_(flacfilename); |