Commit 30322cec authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Add parameter to switch between VD and VDA-based video decoders.

This CL adds a parameter to the video_decode_accelerator_tests and the
video_decode_accelerator_perf_tests to switch between the current VDA-based
video decoders and the new VD-based video decoder implementations.

Currently as no VD-based video decoders are present yet, using this parameter
will always cause the tests to fail.

TEST=ran new VDA tests on nocturne

BUG=925712

Change-Id: I0f5e7df0507b6d7c6d6d75aed54a982cec7b4004
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1559091
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649751}
parent 2633e436
......@@ -153,12 +153,19 @@ void VideoDecoderClient::CreateDecoderTask(base::WaitableEvent* done) {
WaitingCB waiting_cb =
base::BindRepeating([](WaitingReason) { NOTIMPLEMENTED(); });
// TODO(dstaessens@) Currently we always create a VDA-based video decoder,
// change to use a factory that can create different types of decoders.
decoder_ = base::WrapUnique(
new TestVDAVideoDecoder(decoder_client_config_.allocation_mode,
gfx::ColorSpace(), frame_renderer_.get()));
decoder_->Initialize(config, false, nullptr, init_cb, output_cb, waiting_cb);
if (decoder_client_config_.use_vd) {
// TODO(dstaessens@) Create VD-based video decoder.
NOTIMPLEMENTED();
} else {
// The video decoder client expects decoders to use the VD interface. We can
// use the TestVDAVideoDecoder wrapper here to test VDA-based video
// decoders.
decoder_ = base::WrapUnique(
new TestVDAVideoDecoder(decoder_client_config_.allocation_mode,
gfx::ColorSpace(), frame_renderer_.get()));
decoder_->Initialize(config, false, nullptr, init_cb, output_cb,
waiting_cb);
}
DCHECK_LE(decoder_client_config_.max_outstanding_decode_requests,
static_cast<size_t>(decoder_->GetMaxDecodeRequests()));
......
......@@ -43,6 +43,8 @@ struct VideoDecoderClientConfig {
size_t max_outstanding_decode_requests = 1;
// How the pictures buffers should be allocated.
AllocationMode allocation_mode = AllocationMode::kImport;
// Use VD-based video decoders instead of VDA-based video decoders.
bool use_vd = false;
};
// The video decoder client is responsible for the communication between the
......
......@@ -35,7 +35,8 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
const base::FilePath& video_path,
const base::FilePath& video_metadata_path,
bool enable_validator,
bool output_frames) {
bool output_frames,
bool use_vd) {
auto video = std::make_unique<media::test::Video>(
video_path.empty() ? base::FilePath(kDefaultTestVideoPath) : video_path,
video_metadata_path);
......@@ -45,16 +46,18 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
}
return new VideoPlayerTestEnvironment(std::move(video), enable_validator,
output_frames);
output_frames, use_vd);
}
VideoPlayerTestEnvironment::VideoPlayerTestEnvironment(
std::unique_ptr<media::test::Video> video,
bool enable_validator,
bool output_frames)
bool output_frames,
bool use_vd)
: video_(std::move(video)),
enable_validator_(enable_validator),
output_frames_(output_frames) {}
output_frames_(output_frames),
use_vd_(use_vd) {}
VideoPlayerTestEnvironment::~VideoPlayerTestEnvironment() = default;
......@@ -115,6 +118,10 @@ bool VideoPlayerTestEnvironment::IsFramesOutputEnabled() const {
return output_frames_;
}
bool VideoPlayerTestEnvironment::UseVD() const {
return use_vd_;
}
base::FilePath::StringType VideoPlayerTestEnvironment::GetTestName() const {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
......
......@@ -30,7 +30,8 @@ class VideoPlayerTestEnvironment : public ::testing::Environment {
const base::FilePath& video_path,
const base::FilePath& video_metadata_path,
bool enable_validator,
bool output_frames);
bool output_frames,
bool use_vd);
~VideoPlayerTestEnvironment() override;
// Set up the video decode test environment, only called once.
......@@ -44,6 +45,8 @@ class VideoPlayerTestEnvironment : public ::testing::Environment {
bool IsValidatorEnabled() const;
// Check whether outputting frames is enabled.
bool IsFramesOutputEnabled() const;
// Check whether we should use VD-based video decoders instead of VDA-based.
bool UseVD() const;
// Get the name of the current test.
base::FilePath::StringType GetTestName() const;
......@@ -51,12 +54,14 @@ class VideoPlayerTestEnvironment : public ::testing::Environment {
private:
VideoPlayerTestEnvironment(std::unique_ptr<media::test::Video> video,
bool enable_validator,
bool output_frames);
bool output_frames,
bool use_vd);
std::unique_ptr<base::test::ScopedTaskEnvironment> task_environment_;
const std::unique_ptr<media::test::Video> video_;
const bool enable_validator_;
const bool output_frames_;
const bool use_vd_;
// An exit manager is required to run callbacks on shutdown.
base::AtExitManager at_exit_manager;
......
......@@ -23,8 +23,8 @@ namespace {
// Video decoder perf tests usage message.
constexpr const char* usage_msg =
"usage: video_decode_accelerator_perf_tests\n"
" [-v=<level>] [--vmodule=<config>] [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n";
" [-v=<level>] [--vmodule=<config>] [--use_vd] [--gtest_help]\n"
" [--help] [<video path>] [<video metadata path>]\n";
// Video decoder perf tests help message.
constexpr const char* help_msg =
......@@ -38,6 +38,8 @@ constexpr const char* help_msg =
" -v enable verbose mode, e.g. -v=2.\n"
" --vmodule enable verbose mode for the specified module,\n"
" e.g. --vmodule=*media/gpu*=2.\n"
" --use_vd use the new VD-based video decoders, instead of\n"
" the default VDA-based video decoders.\n"
" --gtest_help display the gtest help and exit.\n"
" --help display this help and exit.\n";
......@@ -168,9 +170,13 @@ class VideoDecoderTest : public ::testing::Test {
auto performance_evaluator = std::make_unique<PerformanceEvaluator>();
performance_evaluator_ = performance_evaluator.get();
frame_processors.push_back(std::move(performance_evaluator));
// Use the new VD-based video decoders if requested.
VideoDecoderClientConfig config;
config.use_vd = g_env->UseVD();
return VideoPlayer::Create(video, FrameRendererDummy::Create(),
std::move(frame_processors),
VideoDecoderClientConfig());
std::move(frame_processors), config);
}
PerformanceEvaluator* performance_evaluator_;
......@@ -219,12 +225,17 @@ int main(int argc, char** argv) {
(args.size() >= 2) ? base::FilePath(args[1]) : base::FilePath();
// Parse command line arguments.
bool use_vd = false;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) {
if (it->first.find("gtest_") == 0 || // Handled by GoogleTest
it->first == "v" || it->first == "vmodule") { // Handled by Chrome
continue;
}
if (it->first == "use_vd") {
use_vd = true;
} else {
std::cout << "unknown option: --" << it->first << "\n"
<< media::test::usage_msg;
......@@ -237,7 +248,7 @@ int main(int argc, char** argv) {
// Set up our test environment.
media::test::VideoPlayerTestEnvironment* test_environment =
media::test::VideoPlayerTestEnvironment::Create(
video_path, video_metadata_path, false, false);
video_path, video_metadata_path, false, false, use_vd);
if (!test_environment)
return EXIT_FAILURE;
......
......@@ -23,7 +23,7 @@ namespace {
constexpr const char* usage_msg =
"usage: video_decode_accelerator_tests\n"
" [-v=<level>] [--vmodule=<config>] [--disable_validator]\n"
" [--output_frames] [--gtest_help] [--help]\n"
" [--output_frames] [--use_vd] [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n";
// Video decoder tests help message.
......@@ -42,6 +42,8 @@ constexpr const char* help_msg =
" platforms that don't support import mode.\n"
" --output_frames write all decoded video frames to the\n"
" \"video_frames\" folder.\n"
" --use_vd use the new VD-based video decoders, instead of\n"
" the default VDA-based video decoders.\n"
" --gtest_help display the gtest help and exit.\n"
" --help display this help and exit.\n";
......@@ -52,7 +54,7 @@ class VideoDecoderTest : public ::testing::Test {
public:
std::unique_ptr<VideoPlayer> CreateVideoPlayer(
const Video* video,
const VideoDecoderClientConfig& config = VideoDecoderClientConfig(),
VideoDecoderClientConfig config = VideoDecoderClientConfig(),
std::unique_ptr<FrameRenderer> frame_renderer =
FrameRendererDummy::Create()) {
LOG_ASSERT(video);
......@@ -72,6 +74,9 @@ class VideoDecoderTest : public ::testing::Test {
frame_processors.push_back(VideoFrameFileWriter::Create(output_folder));
}
// 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);
}
......@@ -295,6 +300,7 @@ int main(int argc, char** argv) {
// Parse command line arguments.
bool enable_validator = true;
bool output_frames = false;
bool use_vd = false;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) {
......@@ -307,6 +313,8 @@ int main(int argc, char** argv) {
enable_validator = false;
} else if (it->first == "output_frames") {
output_frames = true;
} else if (it->first == "use_vd") {
use_vd = true;
} else {
std::cout << "unknown option: --" << it->first << "\n"
<< media::test::usage_msg;
......@@ -319,7 +327,8 @@ int main(int argc, char** argv) {
// Set up our test environment.
media::test::VideoPlayerTestEnvironment* test_environment =
media::test::VideoPlayerTestEnvironment::Create(
video_path, video_metadata_path, enable_validator, output_frames);
video_path, video_metadata_path, enable_validator, output_frames,
use_vd);
if (!test_environment)
return EXIT_FAILURE;
......
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