diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2017-01-15 06:47:51 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2017-01-15 09:48:42 +1100 |
commit | 71b909b7a48bd112b7c05ae5dead92b3fc6e585a (patch) | |
tree | d9be7756c776a37e22292bb485228ba768fed38f /src/flac | |
parent | 588689b1385f9291602b88ea82e1c79d38b0080b (diff) | |
download | flac-71b909b7a48bd112b7c05ae5dead92b3fc6e585a.tar.gz |
Yet more purging of `unsigned` type
Diffstat (limited to 'src/flac')
-rw-r--r-- | src/flac/analyze.c | 28 | ||||
-rw-r--r-- | src/flac/decode.c | 70 | ||||
-rw-r--r-- | src/flac/encode.c | 242 | ||||
-rw-r--r-- | src/flac/foreign_metadata.c | 2 | ||||
-rw-r--r-- | src/flac/main.c | 60 | ||||
-rw-r--r-- | src/flac/utils.c | 14 | ||||
-rw-r--r-- | src/flac/vorbiscomment.c | 4 |
7 files changed, 210 insertions, 210 deletions
diff --git a/src/flac/analyze.c b/src/flac/analyze.c index e944493b..683b6446 100644 --- a/src/flac/analyze.c +++ b/src/flac/analyze.c @@ -34,14 +34,14 @@ typedef struct { FLAC__int32 residual; - unsigned count; + uint32_t count; } pair_t; typedef struct { pair_t buckets[FLAC__MAX_BLOCK_SIZE]; int peak_index; - unsigned nbuckets; - unsigned nsamples; + uint32_t nbuckets; + uint32_t nsamples; double sum, sos; double variance; double mean; @@ -51,7 +51,7 @@ typedef struct { static subframe_stats_t all_; static void init_stats(subframe_stats_t *stats); -static void update_stats(subframe_stats_t *stats, FLAC__int32 residual, unsigned incr); +static void update_stats(subframe_stats_t *stats, FLAC__int32 residual, uint32_t incr); static void compute_stats(subframe_stats_t *stats); static FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename); @@ -62,19 +62,19 @@ void flac__analyze_init(analysis_options aopts) } } -void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__uint64 frame_offset, unsigned frame_bytes, analysis_options aopts, FILE *fout) +void flac__analyze_frame(const FLAC__Frame *frame, uint32_t frame_number, FLAC__uint64 frame_offset, uint32_t frame_bytes, analysis_options aopts, FILE *fout) { - const unsigned channels = frame->header.channels; + const uint32_t channels = frame->header.channels; char outfilename[1024]; subframe_stats_t stats; - unsigned i, channel, partitions; + uint32_t i, channel, partitions; /* do the human-readable part first */ fprintf(fout, "frame=%u\toffset=%" PRIu64 "\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]); for(channel = 0; channel < channels; channel++) { const FLAC__Subframe *subframe = frame->subframes+channel; const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2; - const unsigned pesc = is_rice2? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; + const uint32_t pesc = is_rice2? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER; fprintf(fout, "\tsubframe=%u\twasted_bits=%u\ttype=%s", channel, subframe->wasted_bits, FLAC__SubframeTypeString[subframe->type]); switch(subframe->type) { case FLAC__SUBFRAME_TYPE_CONSTANT: @@ -87,7 +87,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__ fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.fixed.warmup[i]); partitions = (1u << subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order); for(i = 0; i < partitions; i++) { - unsigned parameter = subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->parameters[i]; + uint32_t parameter = subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->parameters[i]; if(parameter == pesc) fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]); else @@ -107,7 +107,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__ fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.lpc.warmup[i]); partitions = (1u << subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order); for(i = 0; i < partitions; i++) { - unsigned parameter = subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->parameters[i]; + uint32_t parameter = subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->parameters[i]; if(parameter == pesc) fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]); else @@ -128,7 +128,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__ if(aopts.do_residual_gnuplot) { for(channel = 0; channel < channels; channel++) { const FLAC__Subframe *subframe = frame->subframes+channel; - unsigned residual_samples; + uint32_t residual_samples; init_stats(&stats); @@ -178,9 +178,9 @@ void init_stats(subframe_stats_t *stats) stats->sos = 0.0; } -void update_stats(subframe_stats_t *stats, FLAC__int32 residual, unsigned incr) +void update_stats(subframe_stats_t *stats, FLAC__int32 residual, uint32_t incr) { - unsigned i; + uint32_t i; const double r = (double)residual, a = r*incr; stats->nsamples += incr; @@ -213,7 +213,7 @@ void compute_stats(subframe_stats_t *stats) FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename) { FILE *outfile; - unsigned i; + uint32_t i; const double m = stats->mean; const double s1 = stats->stddev, s2 = s1*2, s3 = s1*3, s4 = s1*4, s5 = s1*5, s6 = s1*6; const double p = stats->buckets[stats->peak_index].count; diff --git a/src/flac/decode.c b/src/flac/decode.c index 30fdbbbf..88bc2799 100644 --- a/src/flac/decode.c +++ b/src/flac/decode.c @@ -62,7 +62,7 @@ typedef struct { const char *outfilename; FLAC__uint64 samples_processed; - unsigned frame_counter; + uint32_t frame_counter; FLAC__bool abort_flag; FLAC__bool aborting_due_to_until; /* true if we intentionally abort decoding prematurely because we hit the --until point */ FLAC__bool aborting_due_to_unparseable; /* true if we abort decoding because we hit an unparseable frame */ @@ -75,9 +75,9 @@ typedef struct { FLAC__bool got_stream_info; FLAC__bool has_md5sum; FLAC__uint64 total_samples; - unsigned bps; - unsigned channels; - unsigned sample_rate; + uint32_t bps; + uint32_t channels; + uint32_t sample_rate; FLAC__uint32 channel_mask; /* these are used only in analyze mode */ @@ -104,16 +104,16 @@ static FLAC__bool DecoderSession_init_decoder(DecoderSession *d, const char *inf static FLAC__bool DecoderSession_process(DecoderSession *d); static int DecoderSession_finish_ok(DecoderSession *d); static int DecoderSession_finish_error(DecoderSession *d); -static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input); +static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input); static FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uint64 samples); -static FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatextensible, unsigned bps, unsigned channels, unsigned sample_rate, FLAC__uint32 channel_mask); -static FLAC__bool write_aiff_form_comm_chunk(FILE *f, FLAC__uint64 samples, unsigned bps, unsigned channels, unsigned sample_rate); +static FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatextensible, uint32_t bps, uint32_t channels, uint32_t sample_rate, FLAC__uint32 channel_mask); +static FLAC__bool write_aiff_form_comm_chunk(FILE *f, FLAC__uint64 samples, uint32_t bps, uint32_t channels, uint32_t sample_rate); static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val); static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val); static FLAC__bool write_little_endian_uint64(FILE *f, FLAC__uint64 val); static FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 val); static FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 val); -static FLAC__bool write_sane_extended(FILE *f, unsigned val); +static FLAC__bool write_sane_extended(FILE *f, uint32_t val); static FLAC__bool fixup_iff_headers(DecoderSession *d); static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); @@ -441,13 +441,13 @@ FLAC__bool DecoderSession_process(DecoderSession *d) /* write padding bytes for alignment if necessary */ if(!d->analysis_mode && !d->test_only && d->format != FORMAT_RAW) { const FLAC__uint64 data_size = d->total_samples * d->channels * ((d->bps+7)/8); - unsigned padding; + uint32_t padding; if(d->format != FORMAT_WAVE64) { - padding = (unsigned)(data_size & 1); + padding = (uint32_t)(data_size & 1); } else { /* 8-byte alignment for Wave64 */ - padding = (8 - (unsigned)(data_size & 7)) & 7; + padding = (8 - (uint32_t)(data_size & 7)) & 7; } for( ; padding > 0; --padding) { if(flac__utils_fwrite("\000", 1, 1, d->fout) != 1) { @@ -525,7 +525,7 @@ int DecoderSession_finish_error(DecoderSession *d) return 1; } -FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) +FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) { /* convert from mm:ss.sss to sample number if necessary */ flac__utils_canonicalize_skip_until_specification(spec, sample_rate); @@ -592,7 +592,7 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin (data_size+1) & (~(FLAC__uint64)1); FLAC__uint64 iff_size; - unsigned foreign_metadata_size = 0; /* size of all non-audio non-fmt/COMM foreign metadata chunks */ + uint32_t foreign_metadata_size = 0; /* size of all non-audio non-fmt/COMM foreign metadata chunks */ foreign_metadata_t *fm = decoder_session->foreign_metadata; size_t i; @@ -818,7 +818,7 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin return true; } -FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatextensible, unsigned bps, unsigned channels, unsigned sample_rate, FLAC__uint32 channel_mask) +FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatextensible, uint32_t bps, uint32_t channels, uint32_t sample_rate, FLAC__uint32 channel_mask) { if(!write_little_endian_uint16(f, (FLAC__uint16)(is_waveformatextensible? 65534 : 1))) /* compression code */ return false; @@ -856,7 +856,7 @@ FLAC__bool write_riff_wave_fmt_chunk_body(FILE *f, FLAC__bool is_waveformatexten return true; } -FLAC__bool write_aiff_form_comm_chunk(FILE *f, FLAC__uint64 samples, unsigned bps, unsigned channels, unsigned sample_rate) +FLAC__bool write_aiff_form_comm_chunk(FILE *f, FLAC__uint64 samples, uint32_t bps, uint32_t channels, uint32_t sample_rate) { FLAC__ASSERT(samples <= 0xffffffff); @@ -936,7 +936,7 @@ FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 val) return flac__utils_fwrite(b, 1, 4, f) == 4; } -FLAC__bool write_sane_extended(FILE *f, unsigned val) +FLAC__bool write_sane_extended(FILE *f, uint32_t val) /* Write to 'f' a SANE extended representation of 'val'. Return false if * the write succeeds; return true otherwise. * @@ -948,7 +948,7 @@ FLAC__bool write_sane_extended(FILE *f, unsigned val) * val!=0U */ { - unsigned int shift, exponent; + uint32_t shift, exponent; FLAC__ASSERT(val!=0U); /* handling 0 would require a special case */ @@ -994,8 +994,8 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder { DecoderSession *decoder_session = (DecoderSession*)client_data; FILE *fout = decoder_session->fout; - const unsigned bps = frame->header.bits_per_sample, channels = frame->header.channels; - const unsigned shift = (decoder_session->format != FORMAT_RAW && (bps%8))? 8-(bps%8): 0; + const uint32_t bps = frame->header.bits_per_sample, channels = frame->header.channels; + const uint32_t shift = (decoder_session->format != FORMAT_RAW && (bps%8))? 8-(bps%8): 0; FLAC__bool is_big_endian = ( decoder_session->format == FORMAT_AIFF || decoder_session->format == FORMAT_AIFF_C ? true : ( decoder_session->format == FORMAT_WAVE || decoder_session->format == FORMAT_WAVE64 || decoder_session->format == FORMAT_RF64 ? false : @@ -1006,8 +1006,8 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder decoder_session->format == FORMAT_WAVE || decoder_session->format == FORMAT_WAVE64 || decoder_session->format == FORMAT_RF64 ? bps<=8 : decoder_session->is_unsigned_samples )); - unsigned wide_samples = frame->header.blocksize, wide_sample, sample, channel; - unsigned frame_bytes = 0; + uint32_t wide_samples = frame->header.blocksize, wide_sample, sample, channel; + uint32_t frame_bytes = 0; static union { /* The arrays defined within this union are all the same size. */ @@ -1106,7 +1106,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder const FLAC__uint64 input_samples_passed = skip + decoder_session->samples_processed; FLAC__ASSERT(until >= input_samples_passed); if(input_samples_passed + wide_samples > until) - wide_samples = (unsigned)(until - input_samples_passed); + wide_samples = (uint32_t)(until - input_samples_passed); if (wide_samples == 0) { decoder_session->abort_flag = true; decoder_session->aborting_due_to_until = true; @@ -1117,7 +1117,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder if(decoder_session->analysis_mode) { FLAC__uint64 dpos; FLAC__stream_decoder_get_decode_position(decoder_session->decoder, &dpos); - frame_bytes = (unsigned)(dpos-decoder_session->decode_position); + frame_bytes = (uint32_t)(dpos-decoder_session->decode_position); decoder_session->decode_position = dpos; } @@ -1207,9 +1207,9 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder } } if(is_big_endian != is_big_endian_host_) { - unsigned char tmp; - const unsigned bytes = sample * 2; - unsigned b; + uint8_t tmp; + const uint32_t bytes = sample * 2; + uint32_t b; for(b = 0; b < bytes; b += 2) { tmp = ubuf.u8buffer[b]; ubuf.u8buffer[b] = ubuf.u8buffer[b+1]; @@ -1230,9 +1230,9 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder ubuf.s32buffer[sample] = buffer[channel][wide_sample]; } if(is_big_endian != is_big_endian_host_) { - unsigned char tmp; - const unsigned bytes = sample * 4; - unsigned b; + uint8_t tmp; + const uint32_t bytes = sample * 4; + uint32_t b; for(b = 0; b < bytes; b += 4) { tmp = ubuf.u8buffer[b]; ubuf.u8buffer[b] = ubuf.u8buffer[b+3]; @@ -1243,8 +1243,8 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder } } if(is_big_endian) { - unsigned b, lbyte; - const unsigned bytes = sample * 4; + uint32_t b, lbyte; + const uint32_t bytes = sample * 4; for(lbyte = b = 0; b < bytes; ) { b++; ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; @@ -1253,8 +1253,8 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder } } else { - unsigned b, lbyte; - const unsigned bytes = sample * 4; + uint32_t b, lbyte; + const uint32_t bytes = sample * 4; for(lbyte = b = 0; b < bytes; ) { ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; ubuf.u8buffer[lbyte++] = ubuf.u8buffer[b++]; @@ -1481,13 +1481,13 @@ void print_stats(const DecoderSession *decoder_session) const double progress = (double)decoder_session->samples_processed / (double)decoder_session->total_samples * 100.0; if(decoder_session->total_samples > 0) { - if ((unsigned)floor(progress + 0.5) == 100) + if ((uint32_t)floor(progress + 0.5) == 100) return; stats_print_name(2, decoder_session->inbasefilename); stats_print_info(2, "%s%u%% complete", decoder_session->test_only? "testing, " : decoder_session->analysis_mode? "analyzing, " : "", - (unsigned)floor(progress + 0.5) + (uint32_t)floor(progress + 0.5) ); } else { diff --git a/src/flac/encode.c b/src/flac/encode.c index 8b08beaa..73c15765 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -50,11 +50,11 @@ #define CHUNK_OF_SAMPLES 2048 typedef struct { - unsigned sample_rate; - unsigned channels; - unsigned bits_per_sample; /* width of sample point, including 'shift' bits, valid bps is bits_per_sample-shift */ - unsigned shift; /* # of LSBs samples have been shifted left by */ - unsigned bytes_per_wide_sample; /* for convenience, always == channels*((bps+7)/8), or 0 if N/A to input format (like FLAC) */ + uint32_t sample_rate; + uint32_t channels; + uint32_t bits_per_sample; /* width of sample point, including 'shift' bits, valid bps is bits_per_sample-shift */ + uint32_t shift; /* # of LSBs samples have been shifted left by */ + uint32_t bytes_per_wide_sample; /* for convenience, always == channels*((bps+7)/8), or 0 if N/A to input format (like FLAC) */ FLAC__bool is_unsigned_samples; FLAC__bool is_big_endian; FLAC__uint32 channel_mask; @@ -64,7 +64,7 @@ typedef struct { typedef struct { FLAC__off_t filesize; const FLAC__byte *lookahead; - unsigned lookahead_length; + uint32_t lookahead_length; size_t num_metadata_blocks; FLAC__StreamMetadata *metadata_blocks[1024]; /*@@@ BAD MAGIC number */ FLAC__uint64 samples_left_to_process; @@ -89,8 +89,8 @@ typedef struct { FLAC__uint64 unencoded_size; /* an estimate of the input size, only used in the progress indicator */ FLAC__uint64 bytes_written; FLAC__uint64 samples_written; - unsigned stats_frames_interval; - unsigned old_frames_written; + uint32_t stats_frames_interval; + uint32_t old_frames_written; SampleInfo info; @@ -133,18 +133,18 @@ static FLAC__int32 *input_[FLAC__MAX_CHANNELS]; /* * local routines */ -static FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length); +static FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length); static void EncoderSession_destroy(EncoderSession *e); static int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero, foreign_metadata_t *foreign_metadata, FLAC__bool error_on_compression_fail); static int EncoderSession_finish_error(EncoderSession *e); static FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options); -static FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], unsigned samples); +static FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], uint32_t samples); static FLAC__bool EncoderSession_format_is_iff(const EncoderSession *e); static FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int num_requested_seek_points, FLAC__StreamMetadata *cuesheet, EncoderSession *e); -static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input); -static FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metadata, unsigned num_metadata); -static FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned shift, size_t *channel_map); -static void 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 FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input); +static FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metadata, uint32_t num_metadata); +static FLAC__bool format_input(FLAC__int32 *dest[], uint32_t wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, uint32_t channels, uint32_t bps, uint32_t shift, size_t *channel_map); +static void 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); static FLAC__StreamDecoderReadStatus flac_decoder_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); static FLAC__StreamDecoderSeekStatus flac_decoder_seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data); static FLAC__StreamDecoderTellStatus flac_decoder_tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); @@ -153,7 +153,7 @@ static FLAC__bool flac_decoder_eof_callback(const FLAC__StreamDecoder *decoder, static FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); static void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); static void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); -static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors); +static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors); static void print_stats(const EncoderSession *encoder_session); static void print_error_with_init_status(const EncoderSession *e, const char *message, FLAC__StreamEncoderInitStatus init_status); static void print_error_with_state(const EncoderSession *e, const char *message); @@ -164,9 +164,9 @@ static FLAC__bool read_uint32(FILE *f, FLAC__bool big_endian, FLAC__uint32 *val, static FLAC__bool read_uint64(FILE *f, FLAC__bool big_endian, FLAC__uint64 *val, const char *fn); static FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn); static FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset); -static unsigned count_channel_mask_bits(FLAC__uint32 mask); +static uint32_t count_channel_mask_bits(FLAC__uint32 mask); #if 0 -static FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, unsigned channels); +static FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, uint32_t channels); #endif static FLAC__bool get_sample_info_raw(EncoderSession *e, encode_options_t options) @@ -186,7 +186,7 @@ static FLAC__bool get_sample_info_raw(EncoderSession *e, encode_options_t option static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t options) { FLAC__bool got_fmt_chunk = false, got_data_chunk = false, got_ds64_chunk = false; - unsigned sample_rate = 0, channels = 0, bps = 0, shift = 0; + uint32_t sample_rate = 0, channels = 0, bps = 0, shift = 0; FLAC__uint32 channel_mask = 0; FLAC__uint64 ds64_data_size = 0; @@ -233,7 +233,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio return false; data_bytes = xx; if(data_bytes < 28) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'ds64' chunk has length = %u\n", e->inbasefilename, (unsigned)data_bytes); + flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'ds64' chunk has length = %u\n", e->inbasefilename, (uint32_t)data_bytes); return false; } if(data_bytes & 1) /* should never happen, but enforce WAVE alignment rules */ @@ -300,7 +300,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio * If the channel mask has more set bits than # of channels, the extra MSBs are ignored. * If the channel mask has less set bits than # of channels, the extra channels are unassigned to any speaker. * - * Data is supposed to be unsigned for bps <= 8 else signed. + * Data is supposed to be uint32_t for bps <= 8 else signed. */ /* fmt chunk size */ @@ -312,18 +312,18 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) return false; if(xx) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly large Wave64 'fmt ' chunk has length = 0x%08X%08X\n", e->inbasefilename, (unsigned)xx, (unsigned)data_bytes); + flac__utils_printf(stderr, 1, "%s: ERROR: freakishly large Wave64 'fmt ' chunk has length = 0x%08X%08X\n", e->inbasefilename, (uint32_t)xx, (uint32_t)data_bytes); return false; } /* subtract size of header */ if (data_bytes < 16+8) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 'fmt ' chunk has length = 0x%08X%08X\n", e->inbasefilename, (unsigned)xx, (unsigned)data_bytes); + flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 'fmt ' chunk has length = 0x%08X%08X\n", e->inbasefilename, (uint32_t)xx, (uint32_t)data_bytes); return false; } data_bytes -= (16+8); } if(data_bytes < 16) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'fmt ' chunk has length = %u\n", e->inbasefilename, (unsigned)data_bytes); + flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'fmt ' chunk has length = %u\n", e->inbasefilename, (uint32_t)data_bytes); return false; } if(e->format != FORMAT_WAVE64) { @@ -338,14 +338,14 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio if(!read_uint16(e->fin, /*big_endian=*/false, &wFormatTag, e->inbasefilename)) return false; if(wFormatTag != 1 /*WAVE_FORMAT_PCM*/ && wFormatTag != 65534 /*WAVE_FORMAT_EXTENSIBLE*/) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported format type %u\n", e->inbasefilename, (unsigned)wFormatTag); + flac__utils_printf(stderr, 1, "%s: ERROR: unsupported format type %u\n", e->inbasefilename, (uint32_t)wFormatTag); return false; } /* number of channels */ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; - channels = (unsigned)x; + channels = (uint32_t)x; /* sample rate */ if(!read_uint32(e->fin, /*big_endian=*/false, &xx, e->inbasefilename)) @@ -362,7 +362,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio /* bits per sample */ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; - bps = (unsigned)x; + bps = (uint32_t)x; e->info.is_unsigned_samples = (bps <= 8); @@ -370,13 +370,13 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio if(bps != 8 && bps != 16) { if(bps == 24 || bps == 32) { /* let these slide with a warning since they're unambiguous */ - flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (unsigned)wFormatTag, bps); + flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (uint32_t)wFormatTag, bps); if(e->treat_warnings_as_errors) return false; } else { /* @@@ we could add an option to specify left- or right-justified blocks so we knew how to set 'shift' */ - flac__utils_printf(stderr, 1, "%s: ERROR: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (unsigned)wFormatTag, bps); + flac__utils_printf(stderr, 1, "%s: ERROR: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (uint32_t)wFormatTag, bps); return false; } } @@ -384,7 +384,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio if((bps+7)/8 * channels == block_align) { if(bps % 8) { /* assume legacy file is byte aligned with some LSBs zero; this is double-checked in format_input() */ - flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (unsigned)wFormatTag, block_align, bps, channels); + flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (uint32_t)wFormatTag, block_align, bps, channels); if(e->treat_warnings_as_errors) return false; shift = 8 - (bps % 8); @@ -394,7 +394,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio shift = 0; } else { - flac__utils_printf(stderr, 1, "%s: ERROR: illegal WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (unsigned)wFormatTag, block_align, bps, channels); + flac__utils_printf(stderr, 1, "%s: ERROR: illegal WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (uint32_t)wFormatTag, block_align, bps, channels); return false; } #else @@ -409,24 +409,24 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio } else { if(data_bytes < 40) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with size %u\n", e->inbasefilename, (unsigned)data_bytes); + flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with size %u\n", e->inbasefilename, (uint32_t)data_bytes); return false; } /* cbSize */ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; if(x < 22) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with cbSize %u\n", e->inbasefilename, (unsigned)x); + flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with cbSize %u\n", e->inbasefilename, (uint32_t)x); return false; } /* valid bps */ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; - if((unsigned)x > bps) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with wValidBitsPerSample (%u) > wBitsPerSample (%u)\n", e->inbasefilename, (unsigned)x, bps); + if((uint32_t)x > bps) { + flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with wValidBitsPerSample (%u) > wBitsPerSample (%u)\n", e->inbasefilename, (uint32_t)x, bps); return false; } - shift = bps - (unsigned)x; + shift = bps - (uint32_t)x; /* channel mask */ if(!read_uint32(e->fin, /*big_endian=*/false, &channel_mask, e->inbasefilename)) return false; @@ -495,12 +495,12 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio } #endif else { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk with unsupported channel mask=0x%04X\n\nUse --channel-map=none option to encode the input\n", e->inbasefilename, (unsigned)channel_mask); + flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk with unsupported channel mask=0x%04X\n\nUse --channel-map=none option to encode the input\n", e->inbasefilename, (uint32_t)channel_mask); return false; } if(!options.channel_map_none) { if(count_channel_mask_bits(channel_mask) < channels) { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has unassigned channels (#channels=%u)\n", e->inbasefilename, (unsigned)channel_mask, channels); + flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has unassigned channels (#channels=%u)\n", e->inbasefilename, (uint32_t)channel_mask, channels); return false; } #if 0 @@ -512,7 +512,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio channel_mask = limit_channel_mask(channel_mask, channels); #else else if(count_channel_mask_bits(channel_mask) > channels) { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has extra bits for non-existant channels (#channels=%u)\n", e->inbasefilename, (unsigned)channel_mask, channels); + flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has extra bits for non-existant channels (#channels=%u)\n", e->inbasefilename, (uint32_t)channel_mask, channels); return false; } #endif @@ -521,7 +521,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; if(x != 1) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported WAVEFORMATEXTENSIBLE chunk with non-PCM format %u\n", e->inbasefilename, (unsigned)x); + flac__utils_printf(stderr, 1, "%s: ERROR: unsupported WAVEFORMATEXTENSIBLE chunk with non-PCM format %u\n", e->inbasefilename, (uint32_t)x); return false; } data_bytes -= 26; @@ -560,7 +560,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio return false; /* subtract size of header */ if (data_bytes < 16+8) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 'data' chunk has length = 0x00000000%08X\n", e->inbasefilename, (unsigned)data_bytes); + flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 'data' chunk has length = 0x00000000%08X\n", e->inbasefilename, (uint32_t)data_bytes); return false; } data_bytes -= (16+8); @@ -601,22 +601,22 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio else flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X (use --keep-foreign-metadata to keep)\n", e->inbasefilename, - (unsigned)((const unsigned char *)chunk_id)[3], - (unsigned)((const unsigned char *)chunk_id)[2], - (unsigned)((const unsigned char *)chunk_id)[1], - (unsigned)((const unsigned char *)chunk_id)[0], - (unsigned)((const unsigned char *)chunk_id)[5], - (unsigned)((const unsigned char *)chunk_id)[4], - (unsigned)((const unsigned char *)chunk_id)[7], - (unsigned)((const unsigned char *)chunk_id)[6], - (unsigned)((const unsigned char *)chunk_id)[9], - (unsigned)((const unsigned char *)chunk_id)[8], - (unsigned)((const unsigned char *)chunk_id)[10], - (unsigned)((const unsigned char *)chunk_id)[11], - (unsigned)((const unsigned char *)chunk_id)[12], - (unsigned)((const unsigned char *)chunk_id)[13], - (unsigned)((const unsigned char *)chunk_id)[14], - (unsigned)((const unsigned char *)chunk_id)[15] + (uint32_t)((const uint8_t *)chunk_id)[3], + (uint32_t)((const uint8_t *)chunk_id)[2], + (uint32_t)((const uint8_t *)chunk_id)[1], + (uint32_t)((const uint8_t *)chunk_id)[0], + (uint32_t)((const uint8_t *)chunk_id)[5], + (uint32_t)((const uint8_t *)chunk_id)[4], + (uint32_t)((const uint8_t *)chunk_id)[7], + (uint32_t)((const uint8_t *)chunk_id)[6], + (uint32_t)((const uint8_t *)chunk_id)[9], + (uint32_t)((const uint8_t *)chunk_id)[8], + (uint32_t)((const uint8_t *)chunk_id)[10], + (uint32_t)((const uint8_t *)chunk_id)[11], + (uint32_t)((const uint8_t *)chunk_id)[12], + (uint32_t)((const uint8_t *)chunk_id)[13], + (uint32_t)((const uint8_t *)chunk_id)[14], + (uint32_t)((const uint8_t *)chunk_id)[15] ); if(e->treat_warnings_as_errors) return false; @@ -635,7 +635,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio skip = (skip+7) & (~(FLAC__uint64)7); /* subtract size of header */ if (skip < 16+8) { - flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 chunk has length = 0x00000000%08X\n", e->inbasefilename, (unsigned)skip); + flac__utils_printf(stderr, 1, "%s: ERROR: freakishly small Wave64 chunk has length = 0x00000000%08X\n", e->inbasefilename, (uint32_t)skip); return false; } skip -= (16+8); @@ -670,7 +670,7 @@ static FLAC__bool get_sample_info_wave(EncoderSession *e, encode_options_t optio static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t options) { FLAC__bool got_comm_chunk = false, got_ssnd_chunk = false; - unsigned sample_rate = 0, channels = 0, bps = 0, shift = 0; + uint32_t sample_rate = 0, channels = 0, bps = 0, shift = 0; FLAC__uint64 sample_frames = 0; FLAC__uint32 channel_mask = 0; @@ -692,7 +692,7 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio if(!memcmp(chunk_id, "COMM", 4)) { /* common chunk */ FLAC__uint16 x; FLAC__uint32 xx; - unsigned long skip; + uint64_t skip; const FLAC__bool is_aifc = e->format == FORMAT_AIFF_C; const FLAC__uint32 minimum_comm_size = (is_aifc? 22 : 18); @@ -705,11 +705,11 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) return false; else if(xx < minimum_comm_size) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard %s 'COMM' chunk has length = %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx); + flac__utils_printf(stderr, 1, "%s: ERROR: non-standard %s 'COMM' chunk has length = %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (uint32_t)xx); return false; } else if(!is_aifc && xx != minimum_comm_size) { - flac__utils_printf(stderr, 1, "%s: WARNING: non-standard %s 'COMM' chunk has length = %u, expected %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx, minimum_comm_size); + flac__utils_printf(stderr, 1, "%s: WARNING: non-standard %s 'COMM' chunk has length = %u, expected %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (uint32_t)xx, minimum_comm_size); if(e->treat_warnings_as_errors) return false; } @@ -718,7 +718,7 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio /* number of channels */ if(!read_uint16(e->fin, /*big_endian=*/true, &x, e->inbasefilename)) return false; - channels = (unsigned)x; + channels = (uint32_t)x; if(channels > 2 && !options.channel_map_none) { flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number of channels %u for AIFF\n", e->inbasefilename, channels); return false; @@ -732,7 +732,7 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio /* bits per sample */ if(!read_uint16(e->fin, /*big_endian=*/true, &x, e->inbasefilename)) return false; - bps = (unsigned)x; + bps = (uint32_t)x; shift = (bps%8)? 8-(bps%8) : 0; /* SSND data is always byte-aligned, left-justified but format_input() will double-check */ bps += shift; @@ -797,7 +797,7 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio else if(!memcmp(chunk_id, "SSND", 4) && !got_ssnd_chunk) { /* sound data chunk */ FLAC__uint32 xx; FLAC__uint64 data_bytes; - unsigned offset = 0; + uint32_t offset = 0; if(!got_comm_chunk) { flac__utils_printf(stderr, 1, "%s: ERROR: got 'SSND' chunk before 'COMM' chunk\n", e->inbasefilename); @@ -866,7 +866,7 @@ static FLAC__bool get_sample_info_aiff(EncoderSession *e, encode_options_t optio if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) return false; else { - unsigned long skip = xx + (xx & 1); + uint64_t skip = xx + (xx & 1); FLAC__ASSERT(skip <= LONG_MAX); if(!fskip_ahead(e->fin, skip)) { @@ -952,7 +952,7 @@ static FLAC__bool get_sample_info_flac(EncoderSession *e) /* * public routines */ -int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length, encode_options_t options) +int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length, encode_options_t options) { EncoderSession encoder_session; size_t channel_map[FLAC__MAX_CHANNELS]; @@ -1050,8 +1050,8 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena FLAC__uint64 total_samples_in_input; /* WATCHOUT: may be 0 to mean "unknown" */ FLAC__uint64 skip; FLAC__uint64 until; /* a value of 0 mean end-of-stream (i.e. --until=-0) */ - unsigned consecutive_eos_count = 0; - unsigned align_remainder = 0; + uint32_t consecutive_eos_count = 0; + uint32_t align_remainder = 0; switch(options.format) { case FORMAT_RAW: @@ -1139,7 +1139,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena } if(options.sector_align && (options.format != FORMAT_RAW || infilesize >=0)) { /* for RAW, need to know the filesize */ FLAC__ASSERT(skip == 0); /* asserted above too, but lest we forget */ - align_remainder = (unsigned)(encoder_session.total_samples_to_encode % 588); + align_remainder = (uint32_t)(encoder_session.total_samples_to_encode % 588); if(options.is_last_file) encoder_session.total_samples_to_encode += (588-align_remainder); /* will pad with zeroes */ else @@ -1202,7 +1202,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena switch(options.format) { case FORMAT_RAW: { - unsigned skip_bytes = encoder_session.info.bytes_per_wide_sample * (unsigned)skip; + uint32_t skip_bytes = encoder_session.info.bytes_per_wide_sample * (uint32_t)skip; if(skip_bytes > lookahead_length) { skip_bytes -= lookahead_length; lookahead_length = 0; @@ -1289,7 +1289,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena if(lookahead_length > 0) { FLAC__ASSERT(lookahead_length < CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample); memcpy(ubuffer.u8, lookahead, lookahead_length); - bytes_read = fread(ubuffer.u8+lookahead_length, sizeof(unsigned char), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample - lookahead_length, infile) + lookahead_length; + bytes_read = fread(ubuffer.u8+lookahead_length, sizeof(uint8_t), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample - lookahead_length, infile) + lookahead_length; if(ferror(infile)) { flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); @@ -1297,7 +1297,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena lookahead_length = 0; } else - bytes_read = fread(ubuffer.u8, sizeof(unsigned char), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample, infile); + bytes_read = fread(ubuffer.u8, sizeof(uint8_t), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample, infile); if(bytes_read == 0) { if(ferror(infile)) { @@ -1310,7 +1310,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena return EncoderSession_finish_error(&encoder_session); } else { - unsigned wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; + uint32_t wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; if(!format_input(input_, wide_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) return EncoderSession_finish_error(&encoder_session); @@ -1336,7 +1336,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena wanted -= lookahead_length; bytes_read = lookahead_length; if(wanted > 0) { - bytes_read += fread(ubuffer.u8+lookahead_length, sizeof(unsigned char), wanted, infile); + bytes_read += fread(ubuffer.u8+lookahead_length, sizeof(uint8_t), wanted, infile); if(ferror(infile)) { flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); @@ -1345,7 +1345,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena lookahead_length = 0; } else - bytes_read = fread(ubuffer.u8, sizeof(unsigned char), wanted, infile); + bytes_read = fread(ubuffer.u8, sizeof(uint8_t), wanted, infile); } if(bytes_read == 0) { @@ -1366,7 +1366,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena return EncoderSession_finish_error(&encoder_session); } else { - unsigned wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; + uint32_t wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; if(!format_input(input_, wide_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) return EncoderSession_finish_error(&encoder_session); @@ -1390,7 +1390,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena min (sizeof (ubuffer.u8), min ((size_t)encoder_session.fmt.iff.data_bytes, CHUNK_OF_SAMPLES * (size_t)encoder_session.info.bytes_per_wide_sample)); - size_t bytes_read = fread(ubuffer.u8, sizeof(unsigned char), bytes_to_read, infile); + size_t bytes_read = fread(ubuffer.u8, sizeof(uint8_t), bytes_to_read, infile); if(bytes_read == 0) { if(ferror(infile)) { flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); @@ -1414,7 +1414,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena return EncoderSession_finish_error(&encoder_session); } else { - unsigned wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; + uint32_t wide_samples = bytes_read / encoder_session.info.bytes_per_wide_sample; if(!format_input(input_, wide_samples, encoder_session.info.is_big_endian, encoder_session.info.is_unsigned_samples, encoder_session.info.channels, encoder_session.info.bits_per_sample, encoder_session.info.shift, channel_map)) return EncoderSession_finish_error(&encoder_session); @@ -1469,9 +1469,9 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena */ if(options.sector_align) { if(options.is_last_file) { - unsigned wide_samples = 588 - align_remainder; + uint32_t wide_samples = 588 - align_remainder; if(wide_samples < 588) { - unsigned channel; + uint32_t channel; info_align_zero = wide_samples; for(channel = 0; channel < encoder_session.info.channels; channel++) @@ -1487,7 +1487,7 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena if(*options.align_reservoir_samples > 0) { size_t bytes_read; FLAC__ASSERT(CHUNK_OF_SAMPLES >= 588); - bytes_read = fread(ubuffer.u8, sizeof(unsigned char), (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample, infile); + bytes_read = fread(ubuffer.u8, sizeof(uint8_t), (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample, infile); if(bytes_read == 0 && ferror(infile)) { flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); @@ -1516,9 +1516,9 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena ); } -FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, unsigned lookahead_length) +FLAC__bool EncoderSession_construct(EncoderSession *e, encode_options_t options, FLAC__off_t infilesize, FILE *infile, const char *infilename, const char *outfilename, const FLAC__byte *lookahead, uint32_t lookahead_length) { - unsigned i; + uint32_t i; FLAC__uint32 test = 1; /* @@ -1712,7 +1712,7 @@ int EncoderSession_finish_error(EncoderSession *e) } typedef struct { - unsigned num_metadata; + uint32_t num_metadata; FLAC__bool *needs_delete; FLAC__StreamMetadata **metadata; FLAC__StreamMetadata *cuesheet; /* always needs to be deleted */ @@ -1728,7 +1728,7 @@ static void static_metadata_init(static_metadata_t *m) static void static_metadata_clear(static_metadata_t *m) { - unsigned i; + uint32_t i; for(i = 0; i < m->num_metadata; i++) if(m->needs_delete[i]) FLAC__metadata_object_delete(m->metadata[i]); @@ -1758,14 +1758,14 @@ static FLAC__bool static_metadata_append(static_metadata_t *m, FLAC__StreamMetad FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options) { - const unsigned channels = e->info.channels; - const unsigned bps = e->info.bits_per_sample - e->info.shift; - const unsigned sample_rate = e->info.sample_rate; + const uint32_t channels = e->info.channels; + const uint32_t bps = e->info.bits_per_sample - e->info.shift; + const uint32_t sample_rate = e->info.sample_rate; FLACDecoderData *flac_decoder_data = (e->format == FORMAT_FLAC || e->format == FORMAT_OGGFLAC)? &e->fmt.flac.client_data : 0; FLAC__StreamMetadata padding; FLAC__StreamMetadata **metadata = 0; static_metadata_t static_metadata; - unsigned num_metadata = 0, ic; + uint32_t num_metadata = 0, ic; FLAC__StreamEncoderInitStatus init_status; const FLAC__bool is_cdda = (channels == 1 || channels == 2) && (bps == 16) && (sample_rate == 44100); char apodizations[2000]; @@ -1811,7 +1811,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio * metadata as the basis for the encoded file */ { - unsigned i; + uint32_t i; /* * first handle pictures: simple append any --pictures * specified. @@ -2036,7 +2036,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio * from scratch */ const foreign_metadata_t *foreign_metadata = EncoderSession_format_is_iff(e)? options.format_options.iff.foreign_metadata : 0; - unsigned i; + uint32_t i; if(e->seek_table_template->data.seek_table.num_points > 0) { e->seek_table_template->is_last = false; /* the encoder will set this for us */ @@ -2069,7 +2069,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio if(options.padding != 0) { padding.is_last = false; /* the encoder will set this for us */ padding.type = FLAC__METADATA_TYPE_PADDING; - padding.length = (unsigned)(options.padding>0? options.padding : (e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8)) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); + padding.length = (uint32_t)(options.padding>0? options.padding : (e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8)) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0); padding.length = min(padding.length, (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1); static_metadata_append(&static_metadata, &padding, /*needs_delete=*/false); } @@ -2193,7 +2193,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio return true; } -FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], unsigned samples) +FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], uint32_t samples) { if(e->replay_gain) { if(!grabbag__replaygain_analyze(buffer, e->info.channels==2, e->info.bits_per_sample, samples)) { @@ -2241,7 +2241,7 @@ FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int } if(0 != cuesheet) { - unsigned i, j; + uint32_t i, j; const FLAC__StreamMetadata_CueSheet *cs = &cuesheet->data.cue_sheet; for(i = 0; i < cs->num_tracks; i++) { const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+i; @@ -2267,7 +2267,7 @@ FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int return true; } -FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) +FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, uint32_t sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input) { /* convert from mm:ss.sss to sample number if necessary */ flac__utils_canonicalize_skip_until_specification(spec, sample_rate); @@ -2312,11 +2312,11 @@ FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, return true; } -FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metadata, unsigned num_metadata) +FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metadata, uint32_t num_metadata) { FLAC__bool metadata_picture_has_type1 = false; FLAC__bool metadata_picture_has_type2 = false; - unsigned i; + uint32_t i; FLAC__ASSERT(0 != metadata); for(i = 0; i < num_metadata; i++) { @@ -2359,9 +2359,9 @@ FLAC__bool verify_metadata(const EncoderSession *e, FLAC__StreamMetadata **metad return true; } -FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps, unsigned shift, size_t *channel_map) +FLAC__bool format_input(FLAC__int32 *dest[], uint32_t wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, uint32_t channels, uint32_t bps, uint32_t shift, size_t *channel_map) { - unsigned wide_sample, sample, channel; + uint32_t wide_sample, sample, channel; FLAC__int32 *out[FLAC__MAX_CHANNELS]; if(0 == channel_map) { @@ -2387,9 +2387,9 @@ FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool i } else if(bps == 16) { if(is_big_endian != is_big_endian_host_) { - unsigned char tmp; - const unsigned bytes = wide_samples * channels * (bps >> 3); - unsigned b; + uint8_t tmp; + const uint32_t bytes = wide_samples * channels * (bps >> 3); + uint32_t b; for(b = 0; b < bytes; b += 2) { tmp = ubuffer.u8[b]; ubuffer.u8[b] = ubuffer.u8[b+1]; @@ -2409,9 +2409,9 @@ FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool i } else if(bps == 24) { if(!is_big_endian) { - unsigned char tmp; - const unsigned bytes = wide_samples * channels * (bps >> 3); - unsigned b; + uint8_t tmp; + const uint32_t bytes = wide_samples * channels * (bps >> 3); + uint32_t b; for(b = 0; b < bytes; b += 3) { tmp = ubuffer.u8[b]; ubuffer.u8[b] = ubuffer.u8[b+2]; @@ -2419,7 +2419,7 @@ FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool i } } if(is_unsigned_samples) { - unsigned b; + uint32_t b; for(b = sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) { uint32_t t; @@ -2430,7 +2430,7 @@ FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool i } } else { - unsigned b; + uint32_t b; for(b = sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++, sample++) { uint32_t t; @@ -2458,7 +2458,7 @@ FLAC__bool format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool i return true; } -void 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) +void 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) { EncoderSession *e = (EncoderSession*)client_data; @@ -2566,7 +2566,7 @@ FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDec FLAC__uint64 n = min(data->samples_left_to_process, frame->header.blocksize); (void)decoder; - if(!EncoderSession_process(e, buffer, (unsigned)n)) { + if(!EncoderSession_process(e, buffer, (uint32_t)n)) { print_error_with_state(e, "ERROR during encoding"); data->fatal_error = true; return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; @@ -2606,10 +2606,10 @@ void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__Strea data->fatal_error = true; } -FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors) +FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, uint32_t sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors) { FILE *f; - unsigned last_line_read; + uint32_t last_line_read; const char *error_message; if(0 == cuesheet_filename) @@ -2672,7 +2672,7 @@ static void print_stats(const EncoderSession *encoder_session) } else { stats_print_name(2, encoder_session->inbasefilename); - stats_print_info(2, "%u%% complete, ratio=%s", (unsigned)floor(encoder_session->progress * 100.0 + 0.5), ratiostr); + stats_print_info(2, "%u%% complete, ratio=%s", (uint32_t)floor(encoder_session->progress * 100.0 + 0.5), ratiostr); } } } @@ -2741,9 +2741,9 @@ void print_error_with_state(const EncoderSession *e, const char *message) void print_verify_error(EncoderSession *e) { 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; @@ -2829,7 +2829,7 @@ FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn) * 'val'; return true otherwise. */ { - unsigned int i; + uint32_t i; FLAC__byte buf[10]; FLAC__uint64 p = 0; FLAC__int16 e; @@ -2853,7 +2853,7 @@ FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn) FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset) { - static unsigned char dump[8192]; + static uint8_t dump[8192]; struct flac_stat_s stb; if(flac_fstat(fileno(f), &stb) == 0 && (stb.st_mode & S_IFMT) == S_IFREG) @@ -2870,9 +2870,9 @@ FLAC__bool fskip_ahead(FILE *f, FLAC__uint64 offset) return true; } -unsigned count_channel_mask_bits(FLAC__uint32 mask) +uint32_t count_channel_mask_bits(FLAC__uint32 mask) { - unsigned count = 0; + uint32_t count = 0; while(mask) { if(mask & 1) count++; @@ -2882,10 +2882,10 @@ unsigned count_channel_mask_bits(FLAC__uint32 mask) } #if 0 -FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, unsigned channels) +FLAC__uint32 limit_channel_mask(FLAC__uint32 mask, uint32_t channels) { FLAC__uint32 x = 0x80000000; - unsigned count = count_channel_mask_bits(mask); + uint32_t count = count_channel_mask_bits(mask); while(x && count > channels) { if(mask & x) { mask &= ~x; diff --git a/src/flac/foreign_metadata.c b/src/flac/foreign_metadata.c index 64a34cf6..9ad9c185 100644 --- a/src/flac/foreign_metadata.c +++ b/src/flac/foreign_metadata.c @@ -417,7 +417,7 @@ static FLAC__bool read_from_wave64_(foreign_metadata_t *fm, FILE *f, const char static FLAC__bool write_to_flac_(foreign_metadata_t *fm, FILE *fin, FILE *fout, FLAC__Metadata_SimpleIterator *it, const char **error) { FLAC__byte buffer[4]; - const unsigned ID_LEN = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8; + const uint32_t ID_LEN = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8; size_t block_num = 0; FLAC__ASSERT(sizeof(buffer) >= ID_LEN); while(block_num < fm->num_blocks) { diff --git a/src/flac/main.c b/src/flac/main.c index 55b08216..4e7361b3 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -62,7 +62,7 @@ static int parse_option(int short_option, const char *long_option, const char *o static void free_options(void); static void add_compression_setting_bool(compression_setting_type_t type, FLAC__bool value); static void add_compression_setting_string(compression_setting_type_t type, const char *value); -static void add_compression_setting_unsigned(compression_setting_type_t type, unsigned value); +static void add_compression_setting_uint32_t(compression_setting_type_t type, uint32_t value); static int usage_error(const char *message, ...); static void short_usage(void); @@ -269,12 +269,12 @@ static struct { FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */ FLAC__bool error_on_compression_fail; - unsigned num_files; + uint32_t num_files; char **filenames; FLAC__StreamMetadata *vorbis_comment; FLAC__StreamMetadata *pictures[64]; - unsigned num_pictures; + uint32_t num_pictures; struct { FLAC__bool disable_constant_subframes; @@ -291,7 +291,7 @@ static struct { static FLAC__int32 align_reservoir_0[588], align_reservoir_1[588]; /* for carrying over samples from --sector-align */ /* DEPRECATED */ static FLAC__int32 *align_reservoir[2] = { align_reservoir_0, align_reservoir_1 }; -static unsigned align_reservoir_samples = 0; /* 0 .. 587 */ +static uint32_t align_reservoir_samples = 0; /* 0 .. 587 */ int main(int argc, char *argv[]) @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) } #endif - srand((unsigned)time(0)); + srand((uint32_t)time(0)); #ifdef _WIN32 { const char *var; @@ -385,7 +385,7 @@ int do_it(void) return usage_error("ERROR: --cue may not be combined with --skip or --until\n"); if(option_values.format_channels >= 0) { - if(option_values.format_channels == 0 || (unsigned)option_values.format_channels > FLAC__MAX_CHANNELS) + if(option_values.format_channels == 0 || (uint32_t)option_values.format_channels > FLAC__MAX_CHANNELS) return usage_error("ERROR: invalid number of channels '%u', must be > 0 and <= %u\n", option_values.format_channels, FLAC__MAX_CHANNELS); } if(option_values.format_bps >= 0) { @@ -491,7 +491,7 @@ int do_it(void) retval = decode_file("-"); } else { - unsigned i; + uint32_t i; if(option_values.num_files > 1) option_values.cmdline_forced_outfilename = 0; for(i = 0, retval = 0; i < option_values.num_files; i++) { @@ -512,7 +512,7 @@ int do_it(void) retval = encode_file("-", first, true); } else { - unsigned i; + uint32_t i; if(option_values.num_files > 1) option_values.cmdline_forced_outfilename = 0; for(i = 0, retval = 0; i < option_values.num_files; i++) { @@ -644,7 +644,7 @@ int parse_options(int argc, char *argv[]) option_values.num_files = argc - share__optind; if(option_values.num_files > 0) { - unsigned i = 0; + uint32_t i = 0; if(0 == (option_values.filenames = malloc(sizeof(char*) * option_values.num_files))) die("out of memory allocating space for file names list"); while(share__optind < argc) @@ -738,7 +738,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a option_values.cuesheet_filename = option_argument; } else if(0 == strcmp(long_option, "picture")) { - const unsigned max_pictures = sizeof(option_values.pictures)/sizeof(option_values.pictures[0]); + const uint32_t max_pictures = sizeof(option_values.pictures)/sizeof(option_values.pictures[0]); FLAC__ASSERT(0 != option_argument); if(option_values.num_pictures >= max_pictures) return usage_error("ERROR: too many --picture arguments, only %u allowed\n", max_pictures); @@ -817,7 +817,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a else if(0 == strncmp(option_argument, "unsigned", strlen(option_argument))) option_values.format_is_unsigned_samples = true; else - return usage_error("ERROR: argument to --sign must be \"signed\" or \"unsigned\"\n"); + return usage_error("ERROR: argument to --sign must be \"signed\" or \"uint32_t\"\n"); } else if(0 == strcmp(long_option, "residual-gnuplot")) { option_values.aopts.do_residual_gnuplot = true; @@ -970,7 +970,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a case '6': case '7': case '8': - add_compression_setting_unsigned(CST_COMPRESSION_LEVEL, short_option-'0'); + add_compression_setting_uint32_t(CST_COMPRESSION_LEVEL, short_option-'0'); break; case '9': return usage_error("ERROR: compression level '9' is reserved\n"); @@ -1007,12 +1007,12 @@ int parse_option(int short_option, const char *long_option, const char *option_a break; case 'b': { - unsigned i ; + uint32_t i ; FLAC__ASSERT(0 != option_argument); i = atoi(option_argument); if((i < (int)FLAC__MIN_BLOCK_SIZE || i > (int)FLAC__MAX_BLOCK_SIZE)) return usage_error("ERROR: invalid blocksize (-%c) '%d', must be >= %u and <= %u\n", short_option, i, FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE); - add_compression_setting_unsigned(CST_BLOCKSIZE, (unsigned)i); + add_compression_setting_uint32_t(CST_BLOCKSIZE, (uint32_t)i); } break; case 'e': @@ -1023,12 +1023,12 @@ int parse_option(int short_option, const char *long_option, const char *option_a break; case 'l': { - unsigned i ; + uint32_t i ; FLAC__ASSERT(0 != option_argument); i = atoi(option_argument); if(i > FLAC__MAX_LPC_ORDER) return usage_error("ERROR: invalid LPC order (-%c) '%d', must be >= %u and <= %u\n", short_option, i, 0, FLAC__MAX_LPC_ORDER); - add_compression_setting_unsigned(CST_MAX_LPC_ORDER, i); + add_compression_setting_uint32_t(CST_MAX_LPC_ORDER, i); } break; case 'A': @@ -1048,44 +1048,44 @@ int parse_option(int short_option, const char *long_option, const char *option_a break; case 'q': { - unsigned i ; + uint32_t i ; FLAC__ASSERT(0 != option_argument); i = atoi(option_argument); if((i > 0 && (i < FLAC__MIN_QLP_COEFF_PRECISION || i > FLAC__MAX_QLP_COEFF_PRECISION))) return usage_error("ERROR: invalid value '%d' for qlp coeff precision (-%c), must be 0 or between %u and %u, inclusive\n", i, short_option, FLAC__MIN_QLP_COEFF_PRECISION, FLAC__MAX_QLP_COEFF_PRECISION); - add_compression_setting_unsigned(CST_QLP_COEFF_PRECISION, i); + add_compression_setting_uint32_t(CST_QLP_COEFF_PRECISION, i); } break; case 'r': { - unsigned i; + uint32_t i; char * p; FLAC__ASSERT(0 != option_argument); p = strchr(option_argument, ','); if(0 == p) { - add_compression_setting_unsigned(CST_MIN_RESIDUAL_PARTITION_ORDER, 0); + add_compression_setting_uint32_t(CST_MIN_RESIDUAL_PARTITION_ORDER, 0); i = atoi(option_argument); if(i > FLAC__MAX_RICE_PARTITION_ORDER) return usage_error("ERROR: invalid value '%d' for residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER); - add_compression_setting_unsigned(CST_MAX_RESIDUAL_PARTITION_ORDER, i); + add_compression_setting_uint32_t(CST_MAX_RESIDUAL_PARTITION_ORDER, i); } else { i = atoi(option_argument); if(i > FLAC__MAX_RICE_PARTITION_ORDER) return usage_error("ERROR: invalid value '%d' for min residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER); - add_compression_setting_unsigned(CST_MIN_RESIDUAL_PARTITION_ORDER, i); + add_compression_setting_uint32_t(CST_MIN_RESIDUAL_PARTITION_ORDER, i); i = atoi(++p); if(i > FLAC__MAX_RICE_PARTITION_ORDER) return usage_error("ERROR: invalid value '%d' for max residual partition order (-%c), must be between 0 and %u, inclusive\n", i, short_option, FLAC__MAX_RICE_PARTITION_ORDER); - add_compression_setting_unsigned(CST_MAX_RESIDUAL_PARTITION_ORDER, i); + add_compression_setting_uint32_t(CST_MAX_RESIDUAL_PARTITION_ORDER, i); } } break; case 'R': { - unsigned i; + uint32_t i; i = atoi(option_argument); - add_compression_setting_unsigned(CST_RICE_PARAMETER_SEARCH_DIST, i); + add_compression_setting_uint32_t(CST_RICE_PARAMETER_SEARCH_DIST, i); } break; default: @@ -1098,7 +1098,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a void free_options(void) { - unsigned i; + uint32_t i; if(0 != option_values.filenames) { for(i = 0; i < option_values.num_files; i++) { if(0 != option_values.filenames[i]) @@ -1130,7 +1130,7 @@ void add_compression_setting_string(compression_setting_type_t type, const char option_values.num_compression_settings++; } -void add_compression_setting_unsigned(compression_setting_type_t type, unsigned value) +void add_compression_setting_uint32_t(compression_setting_type_t type, uint32_t value) { if(option_values.num_compression_settings >= sizeof(option_values.compression_settings)/sizeof(option_values.compression_settings[0])) die("too many compression settings"); @@ -1299,7 +1299,7 @@ void show_help(void) printf(" --channels=# Number of channels\n"); printf(" --bps=# Number of bits per sample\n"); printf(" --sample-rate=# Sample rate in Hz\n"); - printf(" --sign={signed|unsigned} Sign of samples\n"); + printf(" --sign={signed|uint32_t} Sign of samples\n"); printf(" --input-size=# Size of the raw input in bytes\n"); printf("negative options:\n"); printf(" --no-adaptive-mid-side\n"); @@ -1639,7 +1639,7 @@ void show_explain(void) printf(" --channels=# Number of channels\n"); printf(" --bps=# Number of bits per sample\n"); printf(" --sample-rate=# Sample rate in Hz\n"); - printf(" --sign={signed|unsigned} Sign of samples (the default is signed)\n"); + printf(" --sign={signed|uint32_t} Sign of samples (the default is signed)\n"); printf(" --input-size=# Size of the raw input in bytes. If you are\n"); printf(" encoding raw samples from stdin, you must set\n"); printf(" this option in order to be able to use --skip,\n"); @@ -1686,7 +1686,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ { FILE *encode_infile; FLAC__byte lookahead[12]; - unsigned lookahead_length = 0; + uint32_t lookahead_length = 0; FileFormat input_format = FORMAT_RAW; int retval; FLAC__off_t infilesize; diff --git a/src/flac/utils.c b/src/flac/utils.c index c2f5520f..b727feb0 100644 --- a/src/flac/utils.c +++ b/src/flac/utils.c @@ -65,7 +65,7 @@ static FLAC__bool local__parse_uint64_(const char *s, FLAC__uint64 *value) static FLAC__bool local__parse_timecode_(const char *s, double *value) { double ret; - unsigned i; + uint32_t i; char c, *endptr; /* parse [0-9][0-9]*: */ @@ -93,10 +93,10 @@ static FLAC__bool local__parse_timecode_(const char *s, double *value) return true; } -static FLAC__bool local__parse_cue_(const char *s, const char *end, unsigned *track, unsigned *indx) +static FLAC__bool local__parse_cue_(const char *s, const char *end, uint32_t *track, uint32_t *indx) { FLAC__bool got_track = false, got_index = false; - unsigned t = 0, i = 0; + uint32_t t = 0, i = 0; char c; while(end? s < end : *s != '\0') { @@ -129,7 +129,7 @@ static FLAC__bool local__parse_cue_(const char *s, const char *end, unsigned *tr * does not require sorted cuesheets). but if it's not sorted, picking a * nearest cue point has no significance. */ -static FLAC__uint64 local__find_closest_cue_(const FLAC__StreamMetadata_CueSheet *cuesheet, unsigned track, unsigned indx, FLAC__uint64 total_samples, FLAC__bool look_forward) +static FLAC__uint64 local__find_closest_cue_(const FLAC__StreamMetadata_CueSheet *cuesheet, uint32_t track, uint32_t indx, FLAC__uint64 total_samples, FLAC__bool look_forward) { int t, i; if(look_forward) { @@ -315,7 +315,7 @@ FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__Skip return true; } -void flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, unsigned sample_rate) +void flac__utils_canonicalize_skip_until_specification(utils__SkipUntilSpecification *spec, uint32_t sample_rate) { FLAC__ASSERT(0 != spec); if(!spec->value_is_samples) { @@ -391,7 +391,7 @@ FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__ FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); FLAC__ASSERT(strlen(CHANNEL_MASK_TAG)+1+2+16+1 <= sizeof(tag)); /* +1 for =, +2 for 0x, +16 for digits, +1 for NUL */ entry.entry = (FLAC__byte*)tag; - if((entry.length = flac_snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (unsigned)channel_mask)) >= sizeof(tag)) + if((entry.length = flac_snprintf(tag, sizeof(tag), "%s=0x%04X", CHANNEL_MASK_TAG, (uint32_t)channel_mask)) >= sizeof(tag)) return false; if(!FLAC__metadata_object_vorbiscomment_replace_comment(object, entry, /*all=*/true, /*copy=*/true)) return false; @@ -401,7 +401,7 @@ FLAC__bool flac__utils_set_channel_mask_tag(FLAC__StreamMetadata *object, FLAC__ FLAC__bool flac__utils_get_channel_mask_tag(const FLAC__StreamMetadata *object, FLAC__uint32 *channel_mask) { int offset; - unsigned val; + uint32_t val; char *p; FLAC__ASSERT(object); FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT); diff --git a/src/flac/vorbiscomment.c b/src/flac/vorbiscomment.c index 3feffeac..43de4cf9 100644 --- a/src/flac/vorbiscomment.c +++ b/src/flac/vorbiscomment.c @@ -42,7 +42,7 @@ typedef struct { char *field; /* the whole field as passed on the command line, i.e. "NAME=VALUE" */ char *field_name; /* according to the vorbis spec, field values can contain \0 so simple C strings are not enough here */ - unsigned field_value_length; + uint32_t field_value_length; char *field_value; FLAC__bool field_value_from_file; /* true if field_value holds a filename for the value, false for plain value */ } Argument_VcField; @@ -63,7 +63,7 @@ static char *local_strdup(const char *source) return ret; } -static FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, unsigned *length, const char **violation) +static FLAC__bool parse_vorbis_comment_field(const char *field_ref, char **field, char **name, char **value, uint32_t *length, const char **violation) { static const char * const violations[] = { "field name contains invalid character", |