From d0725671d6266c7466303ba6a1984ccdd068780e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 28 Dec 2018 11:29:00 +0100 Subject: [PATCH] Simplify Player::thread_func() a little further. --- futatabi/player.cpp | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/futatabi/player.cpp b/futatabi/player.cpp index f4fae1c..f13a4a5 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -233,7 +233,9 @@ void Player::play_playlist_once() } } - if (frame_lower.pts == frame_upper.pts || global_flags.interpolation_quality == 0) { + // If there's nothing to interpolate between, or if interpolation is turned off, + // or we're a preview, then just display the frame. + if (frame_lower.pts == frame_upper.pts || global_flags.interpolation_quality == 0 || video_stream == nullptr) { display_single_frame(primary_stream_idx, frame_lower, secondary_stream_idx, secondary_frame, fade_alpha, next_frame_start, /*snapped=*/false); continue; @@ -290,31 +292,21 @@ void Player::play_playlist_once() } double alpha = double(in_pts - frame_lower.pts) / (frame_upper.pts - frame_lower.pts); - - if (video_stream == nullptr) { - // Previews don't do any interpolation. - assert(secondary_stream_idx == -1); + auto display_func = [this](shared_ptr frame) { if (destination != nullptr) { - destination->setFrame(primary_stream_idx, frame_lower); + destination->setFrame(frame); } - last_pts_played = frame_lower.pts; + }; + if (secondary_stream_idx == -1) { + ++metric_interpolated_frame; } else { - auto display_func = [this](shared_ptr frame) { - if (destination != nullptr) { - destination->setFrame(frame); - } - }; - if (secondary_stream_idx == -1) { - ++metric_interpolated_frame; - } else { - ++metric_interpolated_faded_frame; - } - video_stream->schedule_interpolated_frame( - next_frame_start, pts, display_func, QueueSpotHolder(this), - frame_lower, frame_upper, alpha, - secondary_frame, fade_alpha); - last_pts_played = in_pts; // Not really needed; only previews use last_pts_played. + ++metric_interpolated_faded_frame; } + video_stream->schedule_interpolated_frame( + next_frame_start, pts, display_func, QueueSpotHolder(this), + frame_lower, frame_upper, alpha, + secondary_frame, fade_alpha); + last_pts_played = in_pts; // Not really needed; only previews use last_pts_played. } // The clip ended. @@ -348,6 +340,7 @@ void Player::display_single_frame(int primary_stream_idx, const FrameOnDisk &pri display_func(); } else { if (secondary_stream_idx == -1) { + // NOTE: We could be increasing unused metrics for previews, but that's harmless. if (snapped) { ++metric_original_snapped_frame; } else { @@ -358,6 +351,7 @@ void Player::display_single_frame(int primary_stream_idx, const FrameOnDisk &pri primary_frame); } else { assert(secondary_frame.pts != -1); + // NOTE: We could be increasing unused metrics for previews, but that's harmless. if (snapped) { ++metric_faded_snapped_frame; } else { -- 2.39.2