diff --git a/src/flac/analyze.c b/src/flac/analyze.c index 1073758..d4a4441 100644 --- a/src/flac/analyze.c +++ b/src/flac/analyze.c @@ -28,6 +28,20 @@ #include "FLAC/all.h" #include "analyze.h" +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + typedef struct { FLAC__int32 residual; unsigned count; @@ -66,11 +80,7 @@ void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__ unsigned i, channel, partitions; /* do the human-readable part first */ -#ifdef _MSC_VER - fprintf(fout, "frame=%u\toffset=%I64u\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]); -#else - fprintf(fout, "frame=%u\toffset=%llu\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, (unsigned long long)frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]); -#endif + fprintf(fout, "frame=%u\toffset=%"flactypei64"\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, (unsigned long long)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; diff --git a/src/metaflac/operations.c b/src/metaflac/operations.c index 639a1da..e43e073 100644 --- a/src/metaflac/operations.c +++ b/src/metaflac/operations.c @@ -32,6 +32,20 @@ #include #include "operations_shorthand.h" +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + static void show_version(void); static FLAC__bool do_major_operation(const CommandLineOptions *options); static FLAC__bool do_major_operation_on_file(const char *filename, const CommandLineOptions *options); @@ -565,11 +579,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); -#ifdef _MSC_VER - PPR; printf(" total samples: %I64u\n", block->data.stream_info.total_samples); -#else - PPR; printf(" total samples: %llu\n", (unsigned long long)block->data.stream_info.total_samples); -#endif + PPR; printf(" total samples: %"flactypeu64"\n", (unsigned long long)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]); @@ -596,11 +606,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) { -#ifdef _MSC_VER - PPR; printf(" point %u: sample_number=%I64u, stream_offset=%I64u, 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: sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, (unsigned long long)block->data.seek_table.points[i].sample_number, (unsigned long long)block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples); -#endif + PPR; printf(" point %u: sample_number=%"flactypeu64", stream_offset=%"flactypeu64", frame_samples=%u\n", i, (unsigned long long)block->data.seek_table.points[i].sample_number, (unsigned long long)block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples); } else { PPR; printf(" point %u: PLACEHOLDER\n", i); @@ -618,11 +624,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); -#ifdef _MSC_VER - PPR; printf(" lead-in: %I64u\n", block->data.cue_sheet.lead_in); -#else - PPR; printf(" lead-in: %llu\n", (unsigned long long)block->data.cue_sheet.lead_in); -#endif + PPR; printf(" lead-in: %"flactypeu64"\n", (unsigned long long)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++) { @@ -630,11 +632,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); -#ifdef _MSC_VER - PPR; printf(" offset: %I64u\n", track->offset); -#else - PPR; printf(" offset: %llu\n", (unsigned long long)track->offset); -#endif + PPR; printf(" offset: %"flactypeu64"\n", (unsigned long long)track->offset); if(is_last) { PPR; printf(" number: %u (%s)\n", (unsigned)track->number, is_leadout? "LEAD-OUT" : "INVALID"); } @@ -649,11 +647,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); -#ifdef _MSC_VER - PPR; printf(" offset: %I64u\n", index->offset); -#else - PPR; printf(" offset: %llu\n", (unsigned long long)index->offset); -#endif + PPR; printf(" offset: %"flactypeu64"\n", (unsigned long long)index->offset); PPR; printf(" number: %u\n", (unsigned)index->number); } } diff --git a/src/share/grabbag/cuesheet.c b/src/share/grabbag/cuesheet.c index 682ee3d..8dbb618 100644 --- a/src/share/grabbag/cuesheet.c +++ b/src/share/grabbag/cuesheet.c @@ -26,6 +26,20 @@ #include #include +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + unsigned grabbag__cuesheet_msf_to_frame(unsigned minutes, unsigned seconds, unsigned frames) { return ((minutes * 60) + seconds) * 75 + frames; @@ -649,19 +663,10 @@ void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, co fprintf(file, "%02u:%02u:%02u\n", m, s, f); } else -#ifdef _MSC_VER - fprintf(file, "%I64u\n", track->offset + index->offset); -#else - fprintf(file, "%llu\n", (unsigned long long)(track->offset + index->offset)); -#endif + fprintf(file, "%"flactypeu64"\n", (unsigned long long)(track->offset + index->offset)); } } -#ifdef _MSC_VER - fprintf(file, "REM FLAC__lead-in %I64u\n", cs->lead_in); - fprintf(file, "REM FLAC__lead-out %u %I64u\n", (unsigned)cs->tracks[track_num].number, cs->tracks[track_num].offset); -#else - fprintf(file, "REM FLAC__lead-in %llu\n", (unsigned long long)cs->lead_in); - fprintf(file, "REM FLAC__lead-out %u %llu\n", (unsigned)cs->tracks[track_num].number, (unsigned long long)cs->tracks[track_num].offset); -#endif + fprintf(file, "REM FLAC__lead-in %"flactypeu64"\n", (unsigned long long)cs->lead_in); + fprintf(file, "REM FLAC__lead-out %u %"flactypeu64"\n", (unsigned)cs->tracks[track_num].number, (unsigned long long)cs->tracks[track_num].offset); } diff --git a/src/test_libFLAC/encoders.c b/src/test_libFLAC/encoders.c index 1f40c62..6574b29 100644 --- a/src/test_libFLAC/encoders.c +++ b/src/test_libFLAC/encoders.c @@ -31,6 +31,20 @@ #include "test_libs_common/file_utils_flac.h" #include "test_libs_common/metadata_utils.h" +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + typedef enum { LAYER_STREAM = 0, /* FLAC__stream_encoder_init_[ogg_]stream() without seeking */ LAYER_SEEKABLE_STREAM, /* FLAC__stream_encoder_init_[ogg_]stream() with seeking */ @@ -449,11 +463,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) { -#ifdef _MSC_VER - printf("FAILED, expected %I64u, got %I64u\n", streaminfo_.data.stream_info.total_samples, FLAC__stream_encoder_get_total_samples_estimate(encoder)); -#else - printf("FAILED, expected %llu, got %llu\n", (unsigned long long)streaminfo_.data.stream_info.total_samples, (unsigned long long)FLAC__stream_encoder_get_total_samples_estimate(encoder)); -#endif + printf("FAILED, expected %"flactypeu64", got %"flactypeu64"\n", (unsigned long long)streaminfo_.data.stream_info.total_samples, (unsigned long long)FLAC__stream_encoder_get_total_samples_estimate(encoder)); return false; } printf("OK\n"); diff --git a/src/test_libFLAC/metadata_object.c b/src/test_libFLAC/metadata_object.c index c9a8479..52452bf 100644 --- a/src/test_libFLAC/metadata_object.c +++ b/src/test_libFLAC/metadata_object.c @@ -28,6 +28,20 @@ #include /* for malloc() */ #include /* for memcmp() */ +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + static FLAC__byte *make_dummydata_(FLAC__byte *dummydata, unsigned len) { FLAC__byte *ret; @@ -47,11 +61,7 @@ static FLAC__bool compare_track_(const FLAC__StreamMetadata_CueSheet_Track *from unsigned i; if(from->offset != to->offset) { -#ifdef _MSC_VER - printf("FAILED, track offset mismatch, expected %I64u, got %I64u\n", to->offset, from->offset); -#else - printf("FAILED, track offset mismatch, expected %llu, got %llu\n", (unsigned long long)to->offset, (unsigned long long)from->offset); -#endif + printf("FAILED, track offset mismatch, expected %"flactypeu64", got %"flactypeu64"\n", (unsigned long long)to->offset, (unsigned long long)from->offset); return false; } if(from->number != to->number) { @@ -83,11 +93,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) { -#ifdef _MSC_VER - printf("FAILED, track indices[%u].offset mismatch, expected %I64u, got %I64u\n", i, to->indices[i].offset, from->indices[i].offset); -#else - printf("FAILED, track indices[%u].offset mismatch, expected %llu, got %llu\n", i, (unsigned long long)to->indices[i].offset, (unsigned long long)from->indices[i].offset); -#endif + printf("FAILED, track indices[%u].offset mismatch, expected %"flactypeu64", got %"flactypeu64"\n", i, (unsigned long long)to->indices[i].offset, (unsigned long long)from->indices[i].offset); return false; } if(from->indices[i].number != to->indices[i].number) { @@ -109,19 +115,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) { -#ifdef _MSC_VER - printf("FAILED, point[%u].sample_number mismatch, expected %I64u, got %I64u\n", i, to[i].sample_number, from[i].sample_number); -#else - printf("FAILED, point[%u].sample_number mismatch, expected %llu, got %llu\n", i, (unsigned long long)to[i].sample_number, (unsigned long long)from[i].sample_number); -#endif + printf("FAILED, point[%u].sample_number mismatch, expected %"flactypeu64", got %"flactypeu64"\n", i, (unsigned long long)to[i].sample_number, (unsigned long long)from[i].sample_number); return false; } if(from[i].stream_offset != to[i].stream_offset) { -#ifdef _MSC_VER - printf("FAILED, point[%u].stream_offset mismatch, expected %I64u, got %I64u\n", i, to[i].stream_offset, from[i].stream_offset); -#else - printf("FAILED, point[%u].stream_offset mismatch, expected %llu, got %llu\n", i, (unsigned long long)to[i].stream_offset, (unsigned long long)from[i].stream_offset); -#endif + printf("FAILED, point[%u].stream_offset mismatch, expected %"flactypeu64", got %"flactypeu64"\n", i, (unsigned long long)to[i].stream_offset, (unsigned long long)from[i].stream_offset); return false; } if(from[i].frame_samples != to[i].frame_samples) { diff --git a/src/test_libs_common/metadata_utils.c b/src/test_libs_common/metadata_utils.c index d940180..0adf1ad 100644 --- a/src/test_libs_common/metadata_utils.c +++ b/src/test_libs_common/metadata_utils.c @@ -30,6 +30,20 @@ #include /* for malloc() */ #include /* for memcmp() */ +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + FLAC__bool mutils__compare_block_data_streaminfo(const FLAC__StreamMetadata_StreamInfo *block, const FLAC__StreamMetadata_StreamInfo *blockcopy) { if(blockcopy->min_blocksize != block->min_blocksize) { @@ -61,11 +75,8 @@ 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 %"flactypeu64", got %"flactypeu64"\n", (unsigned long long)block->total_samples, (unsigned long long)blockcopy->total_samples); return false; } if(0 != memcmp(blockcopy->md5sum, block->md5sum, sizeof(block->md5sum))) { @@ -166,19 +177,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 %"flactypeu64", got %"flactypeu64"\n", i, (unsigned long long)block->points[i].sample_number, (unsigned long long)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 %"flactypeu64", got %"flactypeu64"\n", i, (unsigned long long)block->points[i].stream_offset, (unsigned long long)blockcopy->points[i].stream_offset); return false; } if(blockcopy->points[i].frame_samples != block->points[i].frame_samples) { @@ -240,11 +243,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 %"flactypeu64", got %"flactypeu64"\n", (unsigned long long)block->lead_in, (unsigned long long)blockcopy->lead_in); return false; } if(blockcopy->is_cd != block->is_cd) { @@ -257,11 +256,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 %"flactypeu64", got %"flactypeu64"\n", i, (unsigned long long)block->tracks[i].offset, (unsigned long long)blockcopy->tracks[i].offset); return false; } if(blockcopy->tracks[i].number != block->tracks[i].number) { @@ -295,11 +290,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 %"flactypeu64", got %"flactypeu64"\n", i, j, (unsigned long long)block->tracks[i].indices[j].offset, (unsigned long long)blockcopy->tracks[i].indices[j].offset); return false; } if(blockcopy->tracks[i].indices[j].number != block->tracks[i].indices[j].number) { diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index 00dce64..234fac4 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -34,6 +34,20 @@ #include "FLAC/metadata.h" #include "FLAC/stream_decoder.h" +#ifdef HAVE_INTTYPES_H +#include +#define flactypei64 PRId64 +#define flactypeu64 PRIu64 +#else +#ifdef _MSC_VER +#define flactypei64 "I64d" +#define flactypeu64 "I64u" +#else +#define flactypei64 "lld" +#define flactypeu64 "llu" +#endif +#endif + typedef struct { FLAC__int32 **pcm; FLAC__bool got_data; @@ -200,11 +214,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) -#ifdef _MSC_VER - printf("frame@%I64u(%u)... ", frame->header.number.sample_number, frame->header.blocksize); -#else - printf("frame@%llu(%u)... ", (unsigned long long)frame->header.number.sample_number, frame->header.blocksize); -#endif + printf("frame@%"flactypeu64"(%u)... ", (unsigned long long)frame->header.number.sample_number, frame->header.blocksize); fflush(stdout); /* check against PCM data if we have it */ @@ -309,11 +319,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); } -#ifdef _MSC_VER - printf("file's total_samples is %I64u\n", decoder_client_data.total_samples); -#else - printf("file's total_samples is %llu\n", (unsigned long long)decoder_client_data.total_samples); -#endif + printf("file's total_samples is %"flactypeu64"\n", (unsigned long long)decoder_client_data.total_samples); n = (long int)decoder_client_data.total_samples; if(n == 0 && total_samples >= 0) @@ -347,11 +353,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, off_t fi pos = (FLAC__uint64)(local_rand_() % n); } -#ifdef _MSC_VER - printf("#%u:seek(%I64u)... ", i, pos); -#else - printf("#%u:seek(%llu)... ", i, (unsigned long long)pos); -#endif + printf("#%u:seek(%"flactypeu64")... ", i, (unsigned long long)pos); fflush(stdout); if(!FLAC__stream_decoder_seek_absolute(decoder, pos)) { if(pos >= (FLAC__uint64)n)