From: Steinar H. Gunderson Date: Mon, 9 Jan 2017 22:51:16 +0000 (+0100) Subject: Move find_received_timestamp() into print_latency.h, so that multiple consumers can... X-Git-Tag: 1.5.0~76 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=8c5fb6a77a16f30a32121971db749a211f8050ad Move find_received_timestamp() into print_latency.h, so that multiple consumers can use it. --- diff --git a/print_latency.cpp b/print_latency.cpp index 0b0a1ae..ee9470c 100644 --- a/print_latency.cpp +++ b/print_latency.cpp @@ -1,4 +1,5 @@ #include "print_latency.h" + #include "flags.h" #include @@ -8,6 +9,19 @@ using namespace std; using namespace std::chrono; +ReceivedTimestamps find_received_timestamp(const vector &input_frames) +{ + // Find min and max timestamp of all input frames that have a timestamp. + steady_clock::time_point min_ts = steady_clock::time_point::max(), max_ts = steady_clock::time_point::min(); + for (const RefCountedFrame &input_frame : input_frames) { + if (input_frame && input_frame->received_timestamp > steady_clock::time_point::min()) { + min_ts = min(min_ts, input_frame->received_timestamp); + max_ts = max(max_ts, input_frame->received_timestamp); + } + } + return { min_ts, max_ts }; +} + void print_latency(const string &header, const ReceivedTimestamps &received_ts, bool is_b_frame, int *frameno) { if (received_ts.max_ts == steady_clock::time_point::min()) diff --git a/print_latency.h b/print_latency.h index 9d8a93b..0e880ca 100644 --- a/print_latency.h +++ b/print_latency.h @@ -7,6 +7,9 @@ #include #include +#include + +#include "ref_counted_frame.h" // Since every output frame is based on multiple input frames, we need // more than one start timestamp. For now, we keep just the smallest @@ -16,6 +19,8 @@ struct ReceivedTimestamps { std::chrono::steady_clock::time_point min_ts, max_ts; }; +ReceivedTimestamps find_received_timestamp(const std::vector &input_frames); + void print_latency(const std::string &header, const ReceivedTimestamps &received_ts, bool is_b_frame, int *frameno); #endif // !defined(_PRINT_LATENCY_H) diff --git a/quicksync_encoder.cpp b/quicksync_encoder.cpp index 284b67a..749eb63 100644 --- a/quicksync_encoder.cpp +++ b/quicksync_encoder.cpp @@ -1829,19 +1829,6 @@ void memcpy_with_pitch(uint8_t *dst, const uint8_t *src, size_t src_width, size_ } } -ReceivedTimestamps find_received_timestamp(const vector &input_frames) -{ - // Find min and max timestamp of all input frames that have a timestamp. - steady_clock::time_point min_ts = steady_clock::time_point::max(), max_ts = steady_clock::time_point::min(); - for (const RefCountedFrame &input_frame : input_frames) { - if (input_frame && input_frame->received_timestamp > steady_clock::time_point::min()) { - min_ts = min(min_ts, input_frame->received_timestamp); - max_ts = max(max_ts, input_frame->received_timestamp); - } - } - return { min_ts, max_ts }; -} - } // namespace void QuickSyncEncoderImpl::pass_frame(QuickSyncEncoderImpl::PendingFrame frame, int display_frame_num, int64_t pts, int64_t duration)