Commit 9c2290ad authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

Fix more printf formatting issues and remove un-necessary casts.

parent ce8a7513
......@@ -67,7 +67,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__
unsigned 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, (uint64_t)frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
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;
......
......@@ -284,13 +284,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, u
for(j = 0; j < order; j++) {
sum += qlp_coeff[j] * (*(--history));
sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
#if defined _MSC_VER
if(sumo > 2147483647I64 || sumo < -2147483648I64)
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%I64d\n",i,j,qlp_coeff[j],*history,sumo);
#else
if(sumo > 2147483647ll || sumo < -2147483648ll)
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,(long long)sumo);
#endif
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo);
}
*(residual++) = *(data++) - (sum >> lp_quantization);
}
......@@ -548,19 +542,11 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *da
for(j = 0; j < order; j++)
sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
#if defined _MSC_VER
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%I64d\n", i, sum >> lp_quantization);
#else
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%lld\n", i, (long long)(sum >> lp_quantization));
#endif
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%" PRId64 "\n", i, (sum >> lp_quantization));
break;
}
if(FLAC__bitmath_silog2_wide((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) {
#if defined _MSC_VER
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%I64d, residual=%I64d\n", i, *data, sum >> lp_quantization, (FLAC__int64)(*data) - (sum >> lp_quantization));
#else
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%lld, residual=%lld\n", i, *data, (long long)(sum >> lp_quantization), (long long)((FLAC__int64)(*data) - (sum >> lp_quantization)));
#endif
fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%" PRId64 ", residual=%" PRId64 "\n", i, *data, (long long)(sum >> lp_quantization), ((FLAC__int64)(*data) - (sum >> lp_quantization)));
break;
}
*(residual++) = *(data++) - (FLAC__int32)(sum >> lp_quantization);
......@@ -814,13 +800,8 @@ void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, c
for(j = 0; j < order; j++) {
sum += qlp_coeff[j] * (*(--history));
sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
#if defined _MSC_VER
if(sumo > 2147483647I64 || sumo < -2147483648I64)
fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%I64d\n",i,j,qlp_coeff[j],*history,sumo);
#else
if(sumo > 2147483647ll || sumo < -2147483648ll)
fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,(long long)sumo);
#endif
fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%" PRId64 "\n",i,j,qlp_coeff[j],*history,sumo);
}
*(data++) = *(r++) + (sum >> lp_quantization);
}
......@@ -1078,19 +1059,11 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_l
for(j = 0; j < order; j++)
sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
#ifdef _MSC_VER
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%I64d\n", i, sum >> lp_quantization);
#else
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%lld\n", i, (long long)(sum >> lp_quantization));
#endif
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%" PRId64 "\n", i, (sum >> lp_quantization));
break;
}
if(FLAC__bitmath_silog2_wide((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) {
#ifdef _MSC_VER
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%I64d, data=%I64d\n", i, *r, sum >> lp_quantization, (FLAC__int64)(*r) + (sum >> lp_quantization));
#else
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%lld, data=%lld\n", i, *r, (long long)(sum >> lp_quantization), (long long)((FLAC__int64)(*r) + (sum >> lp_quantization)));
#endif
fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%" PRId64 ", data=%" PRId64 "\n", i, *r, (sum >> lp_quantization), ((FLAC__int64)(*r) + (sum >> lp_quantization)));
break;
}
*(data++) = *(r++) + (FLAC__int32)(sum >> lp_quantization);
......
......@@ -565,7 +565,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
PPR; printf(" sample_rate: %u Hz\n", block->data.stream_info.sample_rate);
PPR; printf(" channels: %u\n", block->data.stream_info.channels);
PPR; printf(" bits-per-sample: %u\n", block->data.stream_info.bits_per_sample);
PPR; printf(" total samples: %" PRIu64 "\n", (uint64_t)block->data.stream_info.total_samples);
PPR; printf(" total samples: %" PRIu64 "\n", block->data.stream_info.total_samples);
PPR; printf(" MD5 signature: ");
for(i = 0; i < 16; i++) {
printf("%02x", (unsigned)block->data.stream_info.md5sum[i]);
......@@ -592,7 +592,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
PPR; printf(" seek points: %u\n", block->data.seek_table.num_points);
for(i = 0; i < block->data.seek_table.num_points; i++) {
if(block->data.seek_table.points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
PPR; printf(" point %u: sample_number=%" PRIu64 ", stream_offset=%" PRIu64 ", frame_samples=%u\n", i, (uint64_t)block->data.seek_table.points[i].sample_number, (uint64_t)block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
PPR; printf(" point %u: sample_number=%" PRIu64 ", stream_offset=%" PRIu64 ", frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
}
else {
PPR; printf(" point %u: PLACEHOLDER\n", i);
......@@ -610,7 +610,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
break;
case FLAC__METADATA_TYPE_CUESHEET:
PPR; printf(" media catalog number: %s\n", block->data.cue_sheet.media_catalog_number);
PPR; printf(" lead-in: %" PRIu64 "\n", (uint64_t)block->data.cue_sheet.lead_in);
PPR; printf(" lead-in: %" PRIu64 "\n", block->data.cue_sheet.lead_in);
PPR; printf(" is CD: %s\n", block->data.cue_sheet.is_cd? "true":"false");
PPR; printf(" number of tracks: %u\n", block->data.cue_sheet.num_tracks);
for(i = 0; i < block->data.cue_sheet.num_tracks; i++) {
......@@ -618,7 +618,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
const FLAC__bool is_last = (i == block->data.cue_sheet.num_tracks-1);
const FLAC__bool is_leadout = is_last && track->num_indices == 0;
PPR; printf(" track[%u]\n", i);
PPR; printf(" offset: %" PRIu64 "\n", (uint64_t)track->offset);
PPR; printf(" offset: %" PRIu64 "\n", track->offset);
if(is_last) {
PPR; printf(" number: %u (%s)\n", (unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID");
}
......@@ -633,7 +633,7 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
for(j = 0; j < track->num_indices; j++) {
const FLAC__StreamMetadata_CueSheet_Index *index = track->indices+j;
PPR; printf(" index[%u]\n", j);
PPR; printf(" offset: %" PRIu64 "\n", (uint64_t)index->offset);
PPR; printf(" offset: %" PRIu64 "\n", index->offset);
PPR; printf(" number: %u\n", (unsigned)index->number);
}
}
......
......@@ -162,7 +162,7 @@ FLAC__bool import_cs_from(const char *filename, FLAC__StreamMetadata **cuesheet,
for(track = 0; track < cs->num_tracks; track++) {
const FLAC__StreamMetadata_CueSheet_Track *tr = cs->tracks+track;
for(index = 0; index < tr->num_indices; index++) {
sprintf(spec, "%" PRIu64 "u;", (uint64_t)(tr->offset + tr->indices[index].offset));
sprintf(spec, "%" PRIu64 "u;", (tr->offset + tr->indices[index].offset));
local_strcat(seekpoint_specification, spec);
}
}
......
......@@ -75,7 +75,7 @@ FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool p
printf("%u\n", block->data.stream_info.bits_per_sample);
break;
case OP__SHOW_TOTAL_SAMPLES:
printf("%" PRIu64 "\n", (uint64_t)block->data.stream_info.total_samples);
printf("%" PRIu64 "\n", block->data.stream_info.total_samples);
break;
case OP__SET_MD5SUM:
memcpy(block->data.stream_info.md5sum, operation->argument.streaminfo_md5.value, 16);
......
......@@ -649,10 +649,10 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co
fprintf(file, "%02u:%02u:%02u\n", m, s, f);
}
else
fprintf(file, "%" PRIu64 "\n", (uint64_t)(track->offset + index->offset));
fprintf(file, "%" PRIu64 "\n", (track->offset + index->offset));
}
}
fprintf(file, "REM FLAC__lead-in %" PRIu64 "\n", (uint64_t)cs->lead_in);
fprintf(file, "REM FLAC__lead-out %u %" PRIu64 "\n", (unsigned)cs->tracks[track_num].number, (uint64_t)cs->tracks[track_num].offset);
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);
}
......@@ -449,7 +449,7 @@ static FLAC__bool test_stream_encoder(Layer layer, FLAC__bool is_ogg)
printf("testing FLAC__stream_encoder_get_total_samples_estimate()... ");
if(FLAC__stream_encoder_get_total_samples_estimate(encoder) != streaminfo_.data.stream_info.total_samples) {
printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", (uint64_t)streaminfo_.data.stream_info.total_samples, (uint64_t)FLAC__stream_encoder_get_total_samples_estimate(encoder));
printf("FAILED, expected %" PRIu64 ", got %" PRIu64 "\n", streaminfo_.data.stream_info.total_samples, FLAC__stream_encoder_get_total_samples_estimate(encoder));
return false;
}
printf("OK\n");
......
......@@ -47,7 +47,7 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from
unsigned i;
if(from->offset != to->offset) {
printf("FAILED, track offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", (uint64_t)to->offset, (uint64_t)from->offset);
printf("FAILED, track offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", to->offset, from->offset);
return false;
}
if(from->number != to->number) {
......@@ -79,7 +79,7 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from
else {
for(i = 0; i < to->num_indices; i++) {
if(from->indices[i].offset != to->indices[i].offset) {
printf("FAILED, track indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, (uint64_t)to->indices[i].offset, (uint64_t)from->indices[i].offset);
printf("FAILED, track indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to->indices[i].offset, from->indices[i].offset);
return false;
}
if(from->indices[i].number != to->indices[i].number) {
......@@ -101,11 +101,11 @@ static FLAC__bool compare_seekpoint_array_(const FLAC__StreamMetadata_SeekPoint
for(i = 0; i < n; i++) {
if(from[i].sample_number != to[i].sample_number) {
printf("FAILED, point[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, (uint64_t)to[i].sample_number, (uint64_t)from[i].sample_number);
printf("FAILED, point[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to[i].sample_number, from[i].sample_number);
return false;
}
if(from[i].stream_offset != to[i].stream_offset) {
printf("FAILED, point[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, (uint64_t)to[i].stream_offset, (uint64_t)from[i].stream_offset);
printf("FAILED, point[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, to[i].stream_offset, from[i].stream_offset);
return false;
}
if(from[i].frame_samples != to[i].frame_samples) {
......
......@@ -61,11 +61,7 @@ FLAC__bool mutils__compare_block_data_streaminfo(const FLAC__StreamMetadata_Stre
return false;
}
if(blockcopy->total_samples != block->total_samples) {
#ifdef _MSC_VER
printf("FAILED, total_samples mismatch, expected %I64u, got %I64u\n", block->total_samples, blockcopy->total_samples);
#else
printf("FAILED, total_samples mismatch, expected %llu, got %llu\n", (unsigned long long)block->total_samples, (unsigned long long)blockcopy->total_samples);
#endif
printf("FAILED, total_samples mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", block->total_samples, blockcopy->total_samples);
return false;
}
if(0 != memcmp(blockcopy->md5sum, block->md5sum, sizeof(block->md5sum))) {
......@@ -166,19 +162,11 @@ FLAC__bool mutils__compare_block_data_seektable(const FLAC__StreamMetadata_SeekT
}
for(i = 0; i < block->num_points; i++) {
if(blockcopy->points[i].sample_number != block->points[i].sample_number) {
#ifdef _MSC_VER
printf("FAILED, points[%u].sample_number mismatch, expected %I64u, got %I64u\n", i, block->points[i].sample_number, blockcopy->points[i].sample_number);
#else
printf("FAILED, points[%u].sample_number mismatch, expected %llu, got %llu\n", i, (unsigned long long)block->points[i].sample_number, (unsigned long long)blockcopy->points[i].sample_number);
#endif
printf("FAILED, points[%u].sample_number mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, block->points[i].sample_number, blockcopy->points[i].sample_number);
return false;
}
if(blockcopy->points[i].stream_offset != block->points[i].stream_offset) {
#ifdef _MSC_VER
printf("FAILED, points[%u].stream_offset mismatch, expected %I64u, got %I64u\n", i, block->points[i].stream_offset, blockcopy->points[i].stream_offset);
#else
printf("FAILED, points[%u].stream_offset mismatch, expected %llu, got %llu\n", i, (unsigned long long)block->points[i].stream_offset, (unsigned long long)blockcopy->points[i].stream_offset);
#endif
printf("FAILED, points[%u].stream_offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, block->points[i].stream_offset, blockcopy->points[i].stream_offset);
return false;
}
if(blockcopy->points[i].frame_samples != block->points[i].frame_samples) {
......@@ -240,11 +228,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe
return false;
}
if(blockcopy->lead_in != block->lead_in) {
#ifdef _MSC_VER
printf("FAILED, lead_in mismatch, expected %I64u, got %I64u\n", block->lead_in, blockcopy->lead_in);
#else
printf("FAILED, lead_in mismatch, expected %llu, got %llu\n", (unsigned long long)block->lead_in, (unsigned long long)blockcopy->lead_in);
#endif
printf("FAILED, lead_in mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", block->lead_in, blockcopy->lead_in);
return false;
}
if(blockcopy->is_cd != block->is_cd) {
......@@ -257,11 +241,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe
}
for(i = 0; i < block->num_tracks; i++) {
if(blockcopy->tracks[i].offset != block->tracks[i].offset) {
#ifdef _MSC_VER
printf("FAILED, tracks[%u].offset mismatch, expected %I64u, got %I64u\n", i, block->tracks[i].offset, blockcopy->tracks[i].offset);
#else
printf("FAILED, tracks[%u].offset mismatch, expected %llu, got %llu\n", i, (unsigned long long)block->tracks[i].offset, (unsigned long long)blockcopy->tracks[i].offset);
#endif
printf("FAILED, tracks[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, block->tracks[i].offset, blockcopy->tracks[i].offset);
return false;
}
if(blockcopy->tracks[i].number != block->tracks[i].number) {
......@@ -295,11 +275,7 @@ FLAC__bool mutils__compare_block_data_cuesheet(const FLAC__StreamMetadata_CueShe
else {
for(j = 0; j < block->tracks[i].num_indices; j++) {
if(blockcopy->tracks[i].indices[j].offset != block->tracks[i].indices[j].offset) {
#ifdef _MSC_VER
printf("FAILED, tracks[%u].indices[%u].offset mismatch, expected %I64u, got %I64u\n", i, j, block->tracks[i].indices[j].offset, blockcopy->tracks[i].indices[j].offset);
#else
printf("FAILED, tracks[%u].indices[%u].offset mismatch, expected %llu, got %llu\n", i, j, (unsigned long long)block->tracks[i].indices[j].offset, (unsigned long long)blockcopy->tracks[i].indices[j].offset);
#endif
printf("FAILED, tracks[%u].indices[%u].offset mismatch, expected %" PRIu64 ", got %" PRIu64 "\n", i, j, block->tracks[i].indices[j].offset, blockcopy->tracks[i].indices[j].offset);
return false;
}
if(blockcopy->tracks[i].indices[j].number != block->tracks[i].indices[j].number) {
......
......@@ -200,7 +200,7 @@ static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder
FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER); /* decoder guarantees this */
if (!dcd->quiet)
printf("frame@%" PRIu64 "(%u)... ", (uint64_t)frame->header.number.sample_number, frame->header.blocksize);
printf("frame@%" PRIu64 "(%u)... ", frame->header.number.sample_number, frame->header.blocksize);
fflush(stdout);
/* check against PCM data if we have it */
......@@ -305,7 +305,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, off_t fi
return die_s_("expected FLAC__STREAM_DECODER_END_OF_STREAM", decoder);
}
printf("file's total_samples is %" PRIu64 "\n", (uint64_t)decoder_client_data.total_samples);
printf("file's total_samples is %" PRIu64 "\n", decoder_client_data.total_samples);
n = (long int)decoder_client_data.total_samples;
if(n == 0 && total_samples >= 0)
......@@ -339,7 +339,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, off_t fi
pos = (FLAC__uint64)(local_rand_() % n);
}
printf("#%u:seek(%" PRIu64 ")... ", i, (uint64_t)pos);
printf("#%u:seek(%" PRIu64 ")... ", i, pos);
fflush(stdout);
if(!FLAC__stream_decoder_seek_absolute(decoder, pos)) {
if(pos >= (FLAC__uint64)n)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment