Commit 458351fd authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Increase event timeout in video decoder (performance) tests.

This CL increases the timeout used when waiting for events in the
video_decode_accelerator_perf_tests. The MeasureCappedPerformance test decodes
the video in real-time, so we should make sure the timeout is at least as large
as the video's duration.

The timeout is also increased when writing video frames to disk in the
video_decode_accelerator_tests, as this can take a lot of time.

TEST=./video_decode_accelerator_tests on eve

BUG=None

Change-Id: Iaf92d32cae755e6d0afe50571a87bb44a87c561c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731641
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683933}
parent 81fcfc83
......@@ -103,6 +103,11 @@ gfx::Size Video::Resolution() const {
return resolution_;
}
base::TimeDelta Video::GetDuration() const {
return base::TimeDelta::FromSecondsD(static_cast<double>(num_frames_) /
static_cast<double>(frame_rate_));
}
const std::vector<std::string>& Video::FrameChecksums() const {
return frame_checksums_;
}
......
......@@ -10,6 +10,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "media/base/video_codecs.h"
#include "ui/gfx/geometry/size.h"
......@@ -48,6 +49,8 @@ class Video {
uint32_t NumFragments() const;
// Get the video resolution.
gfx::Size Resolution() const;
// Get the video duration.
base::TimeDelta GetDuration() const;
// Get the list of frame checksums.
const std::vector<std::string>& FrameChecksums() const;
......
......@@ -74,6 +74,13 @@ void VideoPlayer::Destroy() {
video_player_state_ = VideoPlayerState::kDestroyed;
}
void VideoPlayer::SetEventWaitTimeout(base::TimeDelta timeout) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(4);
event_timeout_ = timeout;
}
void VideoPlayer::Play() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOGF(4);
......@@ -129,9 +136,7 @@ FrameRenderer* VideoPlayer::GetFrameRenderer() const {
return decoder_client_->GetFrameRenderer();
}
bool VideoPlayer::WaitForEvent(VideoPlayerEvent event,
size_t times,
base::TimeDelta max_wait) {
bool VideoPlayer::WaitForEvent(VideoPlayerEvent event, size_t times) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_GE(times, 1u);
DVLOGF(4) << "Event ID: " << static_cast<size_t>(event);
......@@ -153,11 +158,11 @@ bool VideoPlayer::WaitForEvent(VideoPlayerEvent event,
}
// Check whether we've exceeded the maximum time we're allowed to wait.
if (time_waiting >= max_wait)
if (time_waiting >= event_timeout_)
return false;
const base::TimeTicks start_time = base::TimeTicks::Now();
event_cv_.TimedWait(max_wait - time_waiting);
event_cv_.TimedWait(event_timeout_ - time_waiting);
time_waiting += base::TimeTicks::Now() - start_time;
}
}
......
......@@ -27,7 +27,8 @@ class VideoDecoderClient;
struct VideoDecoderClientConfig;
// Default timeout used when waiting for events.
constexpr base::TimeDelta kDefaultTimeout = base::TimeDelta::FromSeconds(30);
constexpr base::TimeDelta kDefaultEventWaitTimeout =
base::TimeDelta::FromSeconds(30);
enum class VideoPlayerState : size_t {
kUninitialized = 0,
......@@ -71,6 +72,9 @@ class VideoPlayer {
// Wait until the renderer has finished rendering all queued frames.
void WaitForRenderer();
// Set the maximum time we will wait for an event to finish.
void SetEventWaitTimeout(base::TimeDelta timeout);
// Play the video asynchronously.
void Play();
// Play the video asynchronously. Automatically pause decoding when the
......@@ -94,9 +98,7 @@ class VideoPlayer {
// occurred since last calling this function will be taken into account. All
// events with different types will be consumed. Will return false if the
// specified timeout is exceeded while waiting for the events.
bool WaitForEvent(VideoPlayerEvent event,
size_t times = 1,
base::TimeDelta max_wait = kDefaultTimeout);
bool WaitForEvent(VideoPlayerEvent event, size_t times = 1);
// Helper function to wait for a FlushDone event.
bool WaitForFlushDone();
// Helper function to wait for a ResetDone event.
......@@ -131,6 +133,8 @@ class VideoPlayer {
VideoPlayerState video_player_state_;
std::unique_ptr<VideoDecoderClient> decoder_client_;
// The timeout used when waiting for events.
base::TimeDelta event_timeout_ = kDefaultEventWaitTimeout;
mutable base::Lock event_lock_;
base::ConditionVariable event_cv_;
......
......@@ -321,8 +321,13 @@ class VideoDecoderTest : public ::testing::Test {
if (!g_env->ImportSupported())
config.allocation_mode = AllocationMode::kAllocate;
return VideoPlayer::Create(video, std::move(frame_renderer),
std::move(frame_processors), config);
auto video_player = VideoPlayer::Create(
video, std::move(frame_renderer), std::move(frame_processors), config);
// Make sure the event timeout is at least as long as the video's duration.
video_player->SetEventWaitTimeout(
std::max(kDefaultEventWaitTimeout, g_env->Video()->GetDuration()));
return video_player;
}
PerformanceEvaluator* performance_evaluator_;
......
......@@ -86,8 +86,15 @@ class VideoDecoderTest : public ::testing::Test {
// Use the new VD-based video decoders if requested.
config.use_vd = g_env->UseVD();
return VideoPlayer::Create(video, std::move(frame_renderer),
std::move(frame_processors), config);
auto video_player = VideoPlayer::Create(
video, std::move(frame_renderer), std::move(frame_processors), config);
// Increase event timeout when outputting video frames.
if (g_env->IsFramesOutputEnabled()) {
video_player->SetEventWaitTimeout(std::max(
kDefaultEventWaitTimeout, g_env->Video()->GetDuration() * 10));
}
return video_player;
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment