]> git.sesse.net Git - nageru/commitdiff
Various fixes for 32-bit platforms.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 11 Mar 2019 22:39:43 +0000 (23:39 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 11 Mar 2019 22:39:43 +0000 (23:39 +0100)
futatabi/main.cpp
futatabi/player.cpp
futatabi/video_stream.cpp
nageru/audio_encoder.cpp
nageru/benchmark_audio_mixer.cpp
nageru/decklink_output.cpp
nageru/mixer.cpp
nageru/resampling_queue.cpp
nageru/x264_encoder.cpp

index a3a550e1afb6f1ce35562b3acfa921130baadae1..6dc50649c2c22d723f3e01b46686e95c694e844f 100644 (file)
@@ -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) {
index 586df48c470bf0ec4a8682df31da60334b2cdccc..687afd013f13033ddcfa3f1af161fa8bbf361286 100644 (file)
@@ -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<int64_t>(clip->pts_out, llrint(in_pts + clip->fade_time_seconds * clip->speed * TIMEBASE));
                        }
 
                        if (in_pts >= clip->pts_out) {
index da57ebb9d9f0cc882065fa1658bf55bc4d467194..290168ea834a63f9dfc304c551433dfabe65ad5d 100644 (file)
@@ -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.
index 7b72932f0b9ea1b4a6a4248001500f204326cf1d..a2ab14b60ddcc2dac567f8f0fc0b8e82931a09c5 100644 (file)
@@ -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);
        }
 
index edb4955335f30ec7b734a32a27a88ff19a94b1cc..98bc4e987d346d84bb3cba89fde5a682f1119998 100644 (file)
@@ -162,7 +162,7 @@ void do_benchmark()
 
        double elapsed = duration<double>(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);
 }
 
index ed66212a26bf0ddfa0ab0cfac4214f6b7430d7e8..e37002918cb4891f645827dcef74dc7115429031 100644 (file)
@@ -334,10 +334,10 @@ void DeckLinkOutput::send_audio(int64_t pts, const std::vector<float> &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:
index d1b52ef2dc54b4a9db8ad84e755bbadc4ac76411..bad1a5e166461737c3463684ccc427038f7c3269 100644 (file)
@@ -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) {
index ef7b73511ff596f7e93894fd703038ad370c8841..711c1c5239f44aad7df9000711556bc2ff39c2d6 100644 (file)
@@ -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;
index 52710088d1e722fce482a06b3f555c9afe3b6862..b98d6fdac4de8749ebc65c5b57b35ced79980856 100644 (file)
@@ -112,7 +112,7 @@ void X264Encoder::add_frame(int64_t pts, int64_t duration, YCbCrLumaCoefficients
        {
                lock_guard<mutex> 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;
                }