add explicit casts for some implicit conversions

This commit is contained in:
Josh Coalson
2001-07-03 04:38:59 +00:00
parent da2037d66d
commit 6d5be83970
4 changed files with 17 additions and 16 deletions

View File

@@ -365,12 +365,12 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder,
if(is_unsigned_samples) { if(is_unsigned_samples) {
for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++)
for(channel = 0; channel < channels; channel++, sample++) for(channel = 0; channel < channels; channel++, sample++)
u8buffer[sample] = buffer[channel][wide_sample] + 0x80; u8buffer[sample] = (FLAC__uint8)(buffer[channel][wide_sample] + 0x80);
} }
else { else {
for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++)
for(channel = 0; channel < channels; channel++, sample++) for(channel = 0; channel < channels; channel++, sample++)
s8buffer[sample] = buffer[channel][wide_sample]; s8buffer[sample] = (FLAC__int8)(buffer[channel][wide_sample]);
} }
if(fwrite(u8buffer, 1, sample, fout) != sample) if(fwrite(u8buffer, 1, sample, fout) != sample)
return FLAC__STREAM_DECODER_WRITE_ABORT; return FLAC__STREAM_DECODER_WRITE_ABORT;
@@ -379,12 +379,12 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__FileDecoder *decoder,
if(is_unsigned_samples) { if(is_unsigned_samples) {
for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++)
for(channel = 0; channel < channels; channel++, sample++) for(channel = 0; channel < channels; channel++, sample++)
u16buffer[sample] = buffer[channel][wide_sample] + 0x8000; u16buffer[sample] = (FLAC__uint16)(buffer[channel][wide_sample] + 0x8000);
} }
else { else {
for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(sample = wide_sample = 0; wide_sample < wide_samples; wide_sample++)
for(channel = 0; channel < channels; channel++, sample++) for(channel = 0; channel < channels; channel++, sample++)
s16buffer[sample] = buffer[channel][wide_sample]; s16buffer[sample] = (FLAC__int16)(buffer[channel][wide_sample]);
} }
if(is_big_endian != is_big_endian_host) { if(is_big_endian != is_big_endian_host) {
unsigned char tmp; unsigned char tmp;

View File

@@ -247,7 +247,7 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
} }
else { else {
unsigned left, need; unsigned left, need;
for(left = skip; left > 0; ) { for(left = (unsigned)skip; left > 0; ) { /*@@@ WATCHOUT: 4GB limit */
need = min(left, CHUNK_OF_SAMPLES); need = min(left, CHUNK_OF_SAMPLES);
if(fread(ucbuffer, 1, bytes_per_wide_sample * need, infile) < need) { if(fread(ucbuffer, 1, bytes_per_wide_sample * need, infile) < need) {
fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_wrapper.inbasefilename); fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_wrapper.inbasefilename);
@@ -258,10 +258,10 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
} }
} }
data_bytes -= skip * bytes_per_wide_sample; data_bytes -= (unsigned)skip * bytes_per_wide_sample; /*@@@ WATCHOUT: 4GB limit */
encoder_wrapper.total_samples_to_encode = data_bytes / bytes_per_wide_sample + *align_reservoir_samples; encoder_wrapper.total_samples_to_encode = data_bytes / bytes_per_wide_sample + *align_reservoir_samples;
if(sector_align) { if(sector_align) {
align_remainder = encoder_wrapper.total_samples_to_encode % 588; align_remainder = (unsigned)(encoder_wrapper.total_samples_to_encode % 588);
if(is_last_file) if(is_last_file)
encoder_wrapper.total_samples_to_encode += (588-align_remainder); /* will pad with zeroes */ encoder_wrapper.total_samples_to_encode += (588-align_remainder); /* will pad with zeroes */
else else
@@ -1058,7 +1058,7 @@ seektable_:
for(i = 0; i < encoder_wrapper->seek_table.num_points; i++) { for(i = 0; i < encoder_wrapper->seek_table.num_points; i++) {
if(!write_big_endian_uint64(f, encoder_wrapper->seek_table.points[i].sample_number)) goto end_; if(!write_big_endian_uint64(f, encoder_wrapper->seek_table.points[i].sample_number)) goto end_;
if(!write_big_endian_uint64(f, encoder_wrapper->seek_table.points[i].stream_offset)) goto end_; if(!write_big_endian_uint64(f, encoder_wrapper->seek_table.points[i].stream_offset)) goto end_;
if(!write_big_endian_uint16(f, encoder_wrapper->seek_table.points[i].frame_samples)) goto end_; if(!write_big_endian_uint16(f, (FLAC__uint16)encoder_wrapper->seek_table.points[i].frame_samples)) goto end_;
} }
} }

View File

@@ -290,17 +290,17 @@ FLAC__bool FLAC__bitbuffer_write_raw_uint32(FLAC__BitBuffer *bb, FLAC__uint32 va
n = 8 - bb->bits; n = 8 - bb->bits;
if(n == 8) { /* i.e. bb->bits == 0 */ if(n == 8) { /* i.e. bb->bits == 0 */
if(bits < 8) { if(bits < 8) {
bb->buffer[bb->bytes] = val; bb->buffer[bb->bytes] = (FLAC__byte)val;
bb->bits = bits; bb->bits = bits;
break; break;
} }
else if(bits == 8) { else if(bits == 8) {
bb->buffer[bb->bytes++] = val; bb->buffer[bb->bytes++] = (FLAC__byte)val;
break; break;
} }
else { else {
k = bits - 8; k = bits - 8;
bb->buffer[bb->bytes++] = val >> k; bb->buffer[bb->bytes++] = (FLAC__byte)(val >> k);
val &= (~(0xffffffff << k)); val &= (~(0xffffffff << k));
bits -= 8; bits -= 8;
} }
@@ -371,17 +371,17 @@ FLAC__bool FLAC__bitbuffer_write_raw_uint64(FLAC__BitBuffer *bb, FLAC__uint64 va
while(bits > 0) { while(bits > 0) {
if(bb->bits == 0) { if(bb->bits == 0) {
if(bits < 8) { if(bits < 8) {
bb->buffer[bb->bytes] = val; bb->buffer[bb->bytes] = (FLAC__byte)val;
bb->bits = bits; bb->bits = bits;
break; break;
} }
else if(bits == 8) { else if(bits == 8) {
bb->buffer[bb->bytes++] = val; bb->buffer[bb->bytes++] = (FLAC__byte)val;
break; break;
} }
else { else {
k = bits - 8; k = bits - 8;
bb->buffer[bb->bytes++] = val >> k; bb->buffer[bb->bytes++] = (FLAC__byte)(val >> k);
val &= (~(0xffffffffffffffff << k)); val &= (~(0xffffffffffffffff << k));
bits -= 8; bits -= 8;
} }

View File

@@ -506,6 +506,7 @@ void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErro
FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, FLAC__uint64 target_sample) FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, FLAC__uint64 target_sample)
{ {
/* @@@ we should really change long to off_t and start using lseek(); with fseek() we have the 2GB file limit. */
long first_frame_offset, lower_bound, upper_bound, pos = -1, last_pos = -1; long first_frame_offset, lower_bound, upper_bound, pos = -1, last_pos = -1;
int i, lower_seek_point = -1, upper_seek_point = -1; int i, lower_seek_point = -1, upper_seek_point = -1;
unsigned approx_bytes_per_frame; unsigned approx_bytes_per_frame;
@@ -563,7 +564,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, F
break; break;
} }
if(i >= 0) { /* i.e. we found a suitable seek point... */ if(i >= 0) { /* i.e. we found a suitable seek point... */
lower_bound = first_frame_offset + decoder->private->seek_table->points[i].stream_offset; lower_bound = first_frame_offset + (long)decoder->private->seek_table->points[i].stream_offset;
lower_seek_point = i; lower_seek_point = i;
} }
@@ -573,7 +574,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__FileDecoder *decoder, long filesize, F
break; break;
} }
if(i < (int)decoder->private->seek_table->num_points) { /* i.e. we found a suitable seek point... */ if(i < (int)decoder->private->seek_table->num_points) { /* i.e. we found a suitable seek point... */
upper_bound = first_frame_offset + decoder->private->seek_table->points[i].stream_offset; upper_bound = first_frame_offset + (long)decoder->private->seek_table->points[i].stream_offset;
upper_seek_point = i; upper_seek_point = i;
} }
} }