From ba3ea588faa8e7908bce832820c08e43a09863fe Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 13 Apr 2023 17:02:14 +0200 Subject: [PATCH] Rename MAX_FPS to TYPICAL_FPS. --- nageru/defs.h | 2 +- nageru/ffmpeg_capture.cpp | 4 ++-- nageru/mixer.cpp | 2 +- nageru/quicksync_encoder.cpp | 6 +++--- nageru/quicksync_encoder_impl.h | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nageru/defs.h b/nageru/defs.h index 41ee96a..c34c2ac 100644 --- a/nageru/defs.h +++ b/nageru/defs.h @@ -3,7 +3,7 @@ #include -#define MAX_FPS 60 +#define TYPICAL_FPS 60 #define FAKE_FPS 25 // Must be an integer. // #define MAX_VIDEO_CARDS 16 // defined in shared_defs.h. #define MAX_ALSA_CARDS 16 diff --git a/nageru/ffmpeg_capture.cpp b/nageru/ffmpeg_capture.cpp index a9ad73d..504eff2 100644 --- a/nageru/ffmpeg_capture.cpp +++ b/nageru/ffmpeg_capture.cpp @@ -715,7 +715,7 @@ bool FFmpegCapture::play_video(const string &pathname) 1e3 * duration(now - next_frame_start).count()); pts_origin = frame->pts; start = next_frame_start = now; - timecode += MAX_FPS * 2 + 1; + timecode += TYPICAL_FPS * 2 + 1; } } bool finished_wakeup; @@ -733,7 +733,7 @@ bool FFmpegCapture::play_video(const string &pathname) // Make sure to get the audio resampler reset. (This is a hack; // ideally, the frame callback should just accept a way to signal // audio discontinuity.) - timecode += MAX_FPS * 2 + 1; + timecode += TYPICAL_FPS * 2 + 1; } last_neutral_color = get_neutral_color(frame->metadata); if (frame_callback != nullptr) { diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index 9d3b12c..9978906 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -981,7 +981,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode, // (Could be nonintegral, but resampling will save us then.) const int silence_samples = OUTPUT_FREQUENCY * video_format.frame_rate_den / video_format.frame_rate_nom; - if (dropped_frames > MAX_FPS * 2) { + if (dropped_frames > TYPICAL_FPS * 2) { fprintf(stderr, "%s lost more than two seconds (or time code jumping around; from 0x%04x to 0x%04x), resetting resampler\n", description_for_card(card_index).c_str(), card->last_timecode, timecode); audio_mixer->reset_resampler(device); diff --git a/nageru/quicksync_encoder.cpp b/nageru/quicksync_encoder.cpp index 32b82bb..328c2c6 100644 --- a/nageru/quicksync_encoder.cpp +++ b/nageru/quicksync_encoder.cpp @@ -699,9 +699,9 @@ public: void push_pts(int64_t pts) { if (buf.empty() && num_b_frames > 0) { // First frame. - int64_t base_dts = pts - num_b_frames * (TIMEBASE / MAX_FPS); + int64_t base_dts = pts - num_b_frames * (TIMEBASE / TYPICAL_FPS); for (int i = 0; i < num_b_frames; ++i) { - buf.push(base_dts + i * (TIMEBASE / MAX_FPS)); + buf.push(base_dts + i * (TIMEBASE / TYPICAL_FPS)); } } buf.push(pts); @@ -1855,7 +1855,7 @@ void QuickSyncEncoderImpl::encode_remaining_frames_as_p(int encoding_frame_num, int display_frame_num = pending_frame.first; assert(display_frame_num > 0); PendingFrame frame = move(pending_frame.second); - int64_t dts = last_dts + (TIMEBASE / MAX_FPS); + int64_t dts = last_dts + (TIMEBASE / TYPICAL_FPS); printf("Finalizing encode: Encoding leftover frame %d as P-frame instead of B-frame.\n", display_frame_num); encode_frame(frame, encoding_frame_num++, display_frame_num, gop_start_display_frame_num, FRAME_P, frame.pts, dts, frame.duration, frame.ycbcr_coefficients); last_dts = dts; diff --git a/nageru/quicksync_encoder_impl.h b/nageru/quicksync_encoder_impl.h index 421ff95..c40567c 100644 --- a/nageru/quicksync_encoder_impl.h +++ b/nageru/quicksync_encoder_impl.h @@ -59,7 +59,7 @@ public: // So we never get negative dts. int64_t global_delay() const { - return int64_t(ip_period - 1) * (TIMEBASE / MAX_FPS); + return int64_t(ip_period - 1) * (TIMEBASE / TYPICAL_FPS); } private: @@ -209,7 +209,7 @@ private: static constexpr int initial_qp = 15; static constexpr int minimal_qp = 0; static constexpr int intra_period = 30; - static constexpr int intra_idr_period = MAX_FPS; // About a second; more at lower frame rates. Not ideal. + static constexpr int intra_idr_period = TYPICAL_FPS; // About a second; more at lower frame rates. Not ideal. // Quality settings that are meant to be static, but might be overridden // by the profile. -- 2.39.2