From 3630741c0d8c1d73fb7d888e1eb772e53f117105 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 11 Mar 2019 23:39:43 +0100 Subject: [PATCH] Various fixes for 32-bit platforms. --- futatabi/main.cpp | 2 +- futatabi/player.cpp | 3 +-- futatabi/video_stream.cpp | 8 ++++---- nageru/audio_encoder.cpp | 2 +- nageru/benchmark_audio_mixer.cpp | 2 +- nageru/decklink_output.cpp | 10 +++++----- nageru/mixer.cpp | 2 +- nageru/resampling_queue.cpp | 4 ++-- nageru/x264_encoder.cpp | 2 +- 9 files changed, 17 insertions(+), 18 deletions(-) diff --git a/futatabi/main.cpp b/futatabi/main.cpp index a3a550e..6dc5064 100644 --- a/futatabi/main.cpp +++ b/futatabi/main.cpp @@ -79,7 +79,7 @@ FrameOnDisk write_frame(int stream_idx, int64_t pts, const uint8_t *data, size_t { if (open_frame_files.count(stream_idx) == 0) { char filename[256]; - snprintf(filename, sizeof(filename), "%s/frames/cam%d-pts%09ld.frames", + snprintf(filename, sizeof(filename), "%s/frames/cam%d-pts%09" PRId64 ".frames", global_flags.working_directory.c_str(), stream_idx, pts); FILE *fp = fopen(filename, "wb"); if (fp == nullptr) { diff --git a/futatabi/player.cpp b/futatabi/player.cpp index 586df48..687afd0 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -198,8 +198,7 @@ void Player::play_playlist_once() if (should_skip_to_next.exchange(false)) { // Test and clear. Clip *clip = &clip_list[clip_idx].clip; // Get a non-const pointer. - fprintf(stderr, "pts_out moving to first of %ld and %ld (currently at %f)\n", clip->pts_out, lrint(out_pts + clip->fade_time_seconds * TIMEBASE), out_pts); - clip->pts_out = std::min(clip->pts_out, lrint(in_pts + clip->fade_time_seconds * clip->speed * TIMEBASE)); + clip->pts_out = std::min(clip->pts_out, llrint(in_pts + clip->fade_time_seconds * clip->speed * TIMEBASE)); } if (in_pts >= clip->pts_out) { diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index da57ebb..290168e 100644 --- a/futatabi/video_stream.cpp +++ b/futatabi/video_stream.cpp @@ -333,7 +333,7 @@ void VideoStream::schedule_original_frame(steady_clock::time_point local_pts, QueueSpotHolder &&queue_spot_holder, FrameOnDisk frame, const string &subtitle) { - fprintf(stderr, "output_pts=%ld original input_pts=%ld\n", output_pts, frame.pts); + fprintf(stderr, "output_pts=%" PRId64 " original input_pts=%" PRId64 "\n", output_pts, frame.pts); QueuedFrame qf; qf.local_pts = local_pts; @@ -355,7 +355,7 @@ void VideoStream::schedule_faded_frame(steady_clock::time_point local_pts, int64 FrameOnDisk frame1_spec, FrameOnDisk frame2_spec, float fade_alpha, const string &subtitle) { - fprintf(stderr, "output_pts=%ld faded input_pts=%ld,%ld fade_alpha=%.2f\n", output_pts, frame1_spec.pts, frame2_spec.pts, fade_alpha); + fprintf(stderr, "output_pts=%" PRId64 " faded input_pts=%" PRId64 ",%" PRId64 " fade_alpha=%.2f\n", output_pts, frame1_spec.pts, frame2_spec.pts, fade_alpha); // Get the temporary OpenGL resources we need for doing the fade. // (We share these with interpolated frames, which is slightly @@ -425,9 +425,9 @@ void VideoStream::schedule_interpolated_frame(steady_clock::time_point local_pts float alpha, FrameOnDisk secondary_frame, float fade_alpha, const string &subtitle) { if (secondary_frame.pts != -1) { - fprintf(stderr, "output_pts=%ld interpolated input_pts1=%ld input_pts2=%ld alpha=%.3f secondary_pts=%ld fade_alpha=%.2f\n", output_pts, frame1.pts, frame2.pts, alpha, secondary_frame.pts, fade_alpha); + fprintf(stderr, "output_pts=%" PRId64 " interpolated input_pts1=%" PRId64 " input_pts2=%" PRId64 " alpha=%.3f secondary_pts=%" PRId64 " fade_alpha=%.2f\n", output_pts, frame1.pts, frame2.pts, alpha, secondary_frame.pts, fade_alpha); } else { - fprintf(stderr, "output_pts=%ld interpolated input_pts1=%ld input_pts2=%ld alpha=%.3f\n", output_pts, frame1.pts, frame2.pts, alpha); + fprintf(stderr, "output_pts=%" PRId64 " interpolated input_pts1=%" PRId64 " input_pts2=%" PRId64 " alpha=%.3f\n", output_pts, frame1.pts, frame2.pts, alpha); } // Get the temporary OpenGL resources we need for doing the interpolation. diff --git a/nageru/audio_encoder.cpp b/nageru/audio_encoder.cpp index 7b72932..a2ab14b 100644 --- a/nageru/audio_encoder.cpp +++ b/nageru/audio_encoder.cpp @@ -115,7 +115,7 @@ void AudioEncoder::encode_audio_one_frame(const float *audio, size_t num_samples audio_frame->sample_rate = OUTPUT_FREQUENCY; if (av_samples_alloc(audio_frame->data, nullptr, 2, num_samples, ctx->sample_fmt, 0) < 0) { - fprintf(stderr, "Could not allocate %ld samples.\n", num_samples); + fprintf(stderr, "Could not allocate %zu samples.\n", num_samples); exit(1); } diff --git a/nageru/benchmark_audio_mixer.cpp b/nageru/benchmark_audio_mixer.cpp index edb4955..98bc4e9 100644 --- a/nageru/benchmark_audio_mixer.cpp +++ b/nageru/benchmark_audio_mixer.cpp @@ -162,7 +162,7 @@ void do_benchmark() double elapsed = duration(end - start).count(); double simulated = double(out_samples) / (OUTPUT_FREQUENCY * 2); - printf("%ld samples produced in %.1f ms (%.1f%% CPU, %.1fx realtime).\n", + printf("%zu samples produced in %.1f ms (%.1f%% CPU, %.1fx realtime).\n", out_samples, elapsed * 1e3, 100.0 * elapsed / simulated, simulated / elapsed); } diff --git a/nageru/decklink_output.cpp b/nageru/decklink_output.cpp index ed66212..e370029 100644 --- a/nageru/decklink_output.cpp +++ b/nageru/decklink_output.cpp @@ -334,10 +334,10 @@ void DeckLinkOutput::send_audio(int64_t pts, const std::vector &samples) HRESULT result = output->ScheduleAudioSamples(int_samples.get(), samples.size() / 2, pts, TIMEBASE, &frames_written); if (result != S_OK) { - fprintf(stderr, "ScheduleAudioSamples(pts=%ld) failed (result=0x%08x)\n", pts, result); + fprintf(stderr, "ScheduleAudioSamples(pts=%" PRId64 ") failed (result=0x%08x)\n", pts, result); } else { if (frames_written != samples.size() / 2) { - fprintf(stderr, "ScheduleAudioSamples() returned short write (%u/%ld)\n", frames_written, samples.size() / 2); + fprintf(stderr, "ScheduleAudioSamples() returned short write (%u/%zu)\n", frames_written, samples.size() / 2); } } metric_decklink_output_scheduled_samples += samples.size() / 2; @@ -457,17 +457,17 @@ HRESULT DeckLinkOutput::ScheduledFrameCompleted(/* in */ IDeckLinkVideoFrame *co ++metric_decklink_output_completed_frames_completed; break; case bmdOutputFrameDisplayedLate: - fprintf(stderr, "Output frame displayed late (pts=%ld)\n", frame->pts); + fprintf(stderr, "Output frame displayed late (pts=%" PRId64 ")\n", frame->pts); fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n"); ++metric_decklink_output_completed_frames_late; break; case bmdOutputFrameDropped: - fprintf(stderr, "Output frame was dropped (pts=%ld)\n", frame->pts); + fprintf(stderr, "Output frame was dropped (pts=%" PRId64 "ld)\n", frame->pts); fprintf(stderr, "Consider increasing --output-buffer-frames if this persists.\n"); ++metric_decklink_output_completed_frames_dropped; break; case bmdOutputFrameFlushed: - fprintf(stderr, "Output frame was flushed (pts=%ld)\n", frame->pts); + fprintf(stderr, "Output frame was flushed (pts=%" PRId64 "ld)\n", frame->pts); ++metric_decklink_output_completed_frames_flushed; break; default: diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index d1b52ef..bad1a5e 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -824,7 +824,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, if (video_frame.len - video_offset == 0 || video_frame.len - video_offset != expected_length) { if (video_frame.len != 0) { - printf("%s: Dropping video frame with wrong length (%ld; expected %ld)\n", + printf("%s: Dropping video frame with wrong length (%zu; expected %zu)\n", spec_to_string(device).c_str(), video_frame.len - video_offset, expected_length); } if (video_frame.owner) { diff --git a/nageru/resampling_queue.cpp b/nageru/resampling_queue.cpp index ef7b735..711c1c5 100644 --- a/nageru/resampling_queue.cpp +++ b/nageru/resampling_queue.cpp @@ -115,7 +115,7 @@ bool ResamplingQueue::get_output_samples(steady_clock::time_point ts, float *sam // so that we don't need a long period to stabilize at the beginning. if (err < 0.0) { int delay_samples_to_add = lrintf(-err); - for (ssize_t i = 0; i < delay_samples_to_add * num_channels; ++i) { + for (ssize_t i = 0; i < delay_samples_to_add * int(num_channels); ++i) { buffer.push_front(0.0f); } total_consumed_samples -= delay_samples_to_add; // Equivalent to increasing input_samples_received on a0 and a1. @@ -143,7 +143,7 @@ bool ResamplingQueue::get_output_samples(steady_clock::time_point ts, float *sam // (we start ResamplingQueues also when we e.g. switch sound sources), // but in general, a little bit of increased timing jitter is acceptable // right after a setup change like this. - double loop_bandwidth_hz = (total_consumed_samples < 4 * freq_in) ? 0.2 : 0.02; + double loop_bandwidth_hz = (total_consumed_samples < 4 * int(freq_in)) ? 0.2 : 0.02; // Set filters. The first filter much wider than the first one (20x as wide). double w = (2.0 * M_PI) * loop_bandwidth_hz * num_samples / freq_out; diff --git a/nageru/x264_encoder.cpp b/nageru/x264_encoder.cpp index 5271008..b98d6fd 100644 --- a/nageru/x264_encoder.cpp +++ b/nageru/x264_encoder.cpp @@ -112,7 +112,7 @@ void X264Encoder::add_frame(int64_t pts, int64_t duration, YCbCrLumaCoefficients { lock_guard lock(mu); if (free_frames.empty()) { - fprintf(stderr, "WARNING: x264 queue full, dropping frame with pts %ld\n", pts); + fprintf(stderr, "WARNING: x264 queue full, dropping frame with pts %" PRId64 "\n", pts); ++metric_x264_dropped_frames; return; } -- 2.39.2