Commit d59cd9cc authored by David Staessens's avatar David Staessens Committed by Commit Bot

media/gpu/test: Add extra command line options to video decoder tests.

This CL adds extra command line options to the video_decode_accelerator_tests to
control the format and amount of video frames saved to disk when --output_frames
is specified:
--output_format: allows switching the file format between png and yuv.
--output_limit: allows putting a limit on the number of frames saved to disk.

TEST=ran new VDA tests on caroline

BUG=962354

Change-Id: Ifc0556986b28309b79ac7df9597154b85f08cc29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831728
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702728}
parent 1a2e6374
...@@ -66,14 +66,19 @@ Multiple command line arguments can be given to the command: ...@@ -66,14 +66,19 @@ Multiple command line arguments can be given to the command:
-v enable verbose mode, e.g. -v=2. -v enable verbose mode, e.g. -v=2.
--vmodule enable verbose mode for the specified module, --vmodule enable verbose mode for the specified module,
e.g. --vmodule=*media/gpu*=2. e.g. --vmodule=*media/gpu*=2.
--disable_validator disable frame validation. --disable_validator disable frame validation.
--output_frames write the selected video frames to disk, possible
values are "all|corrupt", the default output folder
is "<testname>".
--output_folder overwrite the default output folder used when
"--output_frames" is specified.
--use_vd use the new VD-based video decoders, instead of --use_vd use the new VD-based video decoders, instead of
the default VDA-based video decoders. the default VDA-based video decoders.
--output_frames write the selected video frames to disk, possible
values are "all|corrupt".
--output_format set the format of frames saved to disk, supported
formats are "png" (default) and "yuv".
--output_limit limit the number of frames saved to disk.
--output_folder set the folder used to store frames, defaults to
"<testname>"
--gtest_help display the gtest help and exit. --gtest_help display the gtest help and exit.
--help display this help and exit. --help display this help and exit.
......
...@@ -150,6 +150,7 @@ static_library("video_player_test_environment") { ...@@ -150,6 +150,7 @@ static_library("video_player_test_environment") {
"//media/test/data/", "//media/test/data/",
] ]
deps = [ deps = [
":frame_file_writer",
":helpers", ":helpers",
":video_player", ":video_player",
"//media/gpu", "//media/gpu",
......
...@@ -22,9 +22,9 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create( ...@@ -22,9 +22,9 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
const base::FilePath& video_path, const base::FilePath& video_path,
const base::FilePath& video_metadata_path, const base::FilePath& video_metadata_path,
bool enable_validator, bool enable_validator,
FrameOutputMode frame_output_mode, bool use_vd,
const base::FilePath& output_folder, const FrameOutputConfig& frame_output_config,
bool use_vd) { const base::FilePath& output_folder) {
auto video = std::make_unique<media::test::Video>( auto video = std::make_unique<media::test::Video>(
video_path.empty() ? base::FilePath(kDefaultTestVideoPath) : video_path, video_path.empty() ? base::FilePath(kDefaultTestVideoPath) : video_path,
video_metadata_path); video_metadata_path);
...@@ -34,21 +34,21 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create( ...@@ -34,21 +34,21 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
} }
return new VideoPlayerTestEnvironment(std::move(video), enable_validator, return new VideoPlayerTestEnvironment(std::move(video), enable_validator,
frame_output_mode, output_folder, use_vd, frame_output_config,
use_vd); output_folder);
} }
VideoPlayerTestEnvironment::VideoPlayerTestEnvironment( VideoPlayerTestEnvironment::VideoPlayerTestEnvironment(
std::unique_ptr<media::test::Video> video, std::unique_ptr<media::test::Video> video,
bool enable_validator, bool enable_validator,
FrameOutputMode frame_output_mode, bool use_vd,
const base::FilePath& output_folder, const FrameOutputConfig& frame_output_config,
bool use_vd) const base::FilePath& output_folder)
: video_(std::move(video)), : video_(std::move(video)),
enable_validator_(enable_validator), enable_validator_(enable_validator),
frame_output_mode_(frame_output_mode), use_vd_(use_vd),
output_folder_(output_folder), frame_output_config_(frame_output_config),
use_vd_(use_vd) {} output_folder_(output_folder) {}
VideoPlayerTestEnvironment::~VideoPlayerTestEnvironment() = default; VideoPlayerTestEnvironment::~VideoPlayerTestEnvironment() = default;
...@@ -82,16 +82,25 @@ bool VideoPlayerTestEnvironment::IsValidatorEnabled() const { ...@@ -82,16 +82,25 @@ bool VideoPlayerTestEnvironment::IsValidatorEnabled() const {
return enable_validator_; return enable_validator_;
} }
bool VideoPlayerTestEnvironment::UseVD() const {
return use_vd_;
}
FrameOutputMode VideoPlayerTestEnvironment::GetFrameOutputMode() const { FrameOutputMode VideoPlayerTestEnvironment::GetFrameOutputMode() const {
return frame_output_mode_; return frame_output_config_.output_mode;
} }
const base::FilePath& VideoPlayerTestEnvironment::OutputFolder() const { VideoFrameFileWriter::OutputFormat
return output_folder_; VideoPlayerTestEnvironment::GetFrameOutputFormat() const {
return frame_output_config_.output_format;
} }
bool VideoPlayerTestEnvironment::UseVD() const { uint64_t VideoPlayerTestEnvironment::GetFrameOutputLimit() const {
return use_vd_; return frame_output_config_.output_limit;
}
const base::FilePath& VideoPlayerTestEnvironment::OutputFolder() const {
return output_folder_;
} }
bool VideoPlayerTestEnvironment::ImportSupported() const { bool VideoPlayerTestEnvironment::ImportSupported() const {
......
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
#ifndef MEDIA_GPU_TEST_VIDEO_PLAYER_VIDEO_PLAYER_TEST_ENVIRONMENT_H_ #ifndef MEDIA_GPU_TEST_VIDEO_PLAYER_VIDEO_PLAYER_TEST_ENVIRONMENT_H_
#define MEDIA_GPU_TEST_VIDEO_PLAYER_VIDEO_PLAYER_TEST_ENVIRONMENT_H_ #define MEDIA_GPU_TEST_VIDEO_PLAYER_VIDEO_PLAYER_TEST_ENVIRONMENT_H_
#include <limits>
#include <memory> #include <memory>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "media/gpu/test/video_frame_file_writer.h"
#include "media/gpu/test/video_test_environment.h" #include "media/gpu/test/video_test_environment.h"
namespace media { namespace media {
...@@ -25,6 +27,17 @@ enum class FrameOutputMode { ...@@ -25,6 +27,17 @@ enum class FrameOutputMode {
kAll // Output all frames. kAll // Output all frames.
}; };
// Frame output configuration.
struct FrameOutputConfig {
// The frame output mode controls which frames will be output.
FrameOutputMode output_mode = FrameOutputMode::kNone;
// The maximum number of frames that will be output.
uint64_t output_limit = std::numeric_limits<uint64_t>::max();
// The format of frames that are output.
VideoFrameFileWriter::OutputFormat output_format =
VideoFrameFileWriter::OutputFormat::kPNG;
};
// Test environment for video decode tests. Performs setup and teardown once for // Test environment for video decode tests. Performs setup and teardown once for
// the entire test run. // the entire test run.
class VideoPlayerTestEnvironment : public VideoTestEnvironment { class VideoPlayerTestEnvironment : public VideoTestEnvironment {
...@@ -33,9 +46,9 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment { ...@@ -33,9 +46,9 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment {
const base::FilePath& video_path, const base::FilePath& video_path,
const base::FilePath& video_metadata_path, const base::FilePath& video_metadata_path,
bool enable_validator, bool enable_validator,
FrameOutputMode frame_output_mode, bool use_vd,
const base::FilePath& output_folder, const FrameOutputConfig& frame_output_config = FrameOutputConfig(),
bool use_vd); const base::FilePath& output_folder = base::FilePath());
~VideoPlayerTestEnvironment() override; ~VideoPlayerTestEnvironment() override;
// Set up video test environment, called once for entire test run. // Set up video test environment, called once for entire test run.
...@@ -45,27 +58,35 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment { ...@@ -45,27 +58,35 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment {
const media::test::Video* Video() const; const media::test::Video* Video() const;
// Check whether frame validation is enabled. // Check whether frame validation is enabled.
bool IsValidatorEnabled() const; bool IsValidatorEnabled() const;
// Check whether we should use VD-based video decoders instead of VDA-based.
bool UseVD() const;
// Get the frame output mode. // Get the frame output mode.
FrameOutputMode GetFrameOutputMode() const; FrameOutputMode GetFrameOutputMode() const;
// Get the file format used when outputting frames.
VideoFrameFileWriter::OutputFormat GetFrameOutputFormat() const;
// Get the maximum number of frames that will be output.
uint64_t GetFrameOutputLimit() const;
// Get the output folder. // Get the output folder.
const base::FilePath& OutputFolder() const; const base::FilePath& OutputFolder() const;
// Check whether we should use VD-based video decoders instead of VDA-based.
bool UseVD() const;
// Whether import mode is supported, valid after SetUp() has been called. // Whether import mode is supported, valid after SetUp() has been called.
bool ImportSupported() const; bool ImportSupported() const;
private: private:
VideoPlayerTestEnvironment(std::unique_ptr<media::test::Video> video, VideoPlayerTestEnvironment(std::unique_ptr<media::test::Video> video,
bool enable_validator, bool enable_validator,
FrameOutputMode frame_output_mode, bool use_vd,
const base::FilePath& output_folder, const FrameOutputConfig& frame_output_config,
bool use_vd); const base::FilePath& output_folder);
const std::unique_ptr<media::test::Video> video_; const std::unique_ptr<media::test::Video> video_;
const bool enable_validator_; const bool enable_validator_;
const FrameOutputMode frame_output_mode_;
const base::FilePath output_folder_;
const bool use_vd_; const bool use_vd_;
const FrameOutputConfig frame_output_config_;
const base::FilePath output_folder_;
// TODO(dstaessens): Remove this once all allocate-only platforms reached EOL. // TODO(dstaessens): Remove this once all allocate-only platforms reached EOL.
bool import_supported_ = false; bool import_supported_ = false;
}; };
......
...@@ -422,9 +422,7 @@ int main(int argc, char** argv) { ...@@ -422,9 +422,7 @@ int main(int argc, char** argv) {
// Set up our test environment. // Set up our test environment.
media::test::VideoPlayerTestEnvironment* test_environment = media::test::VideoPlayerTestEnvironment* test_environment =
media::test::VideoPlayerTestEnvironment::Create( media::test::VideoPlayerTestEnvironment::Create(
video_path, video_metadata_path, false, video_path, video_metadata_path, false, use_vd);
media::test::FrameOutputMode::kAll, base::FilePath(output_folder),
use_vd);
if (!test_environment) if (!test_environment)
return EXIT_FAILURE; return EXIT_FAILURE;
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <limits>
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/strings/string_number_conversions.h"
#include "media/base/test_data_util.h" #include "media/base/test_data_util.h"
#include "media/gpu/test/video_frame_file_writer.h" #include "media/gpu/test/video_frame_file_writer.h"
#include "media/gpu/test/video_frame_validator.h" #include "media/gpu/test/video_frame_validator.h"
...@@ -25,7 +28,8 @@ namespace { ...@@ -25,7 +28,8 @@ namespace {
constexpr const char* usage_msg = constexpr const char* usage_msg =
"usage: video_decode_accelerator_tests\n" "usage: video_decode_accelerator_tests\n"
" [-v=<level>] [--vmodule=<config>] [--disable_validator]\n" " [-v=<level>] [--vmodule=<config>] [--disable_validator]\n"
" [--output_frames=(all|corrupt)] [--output_folder=<folder>]\n" " [--output_frames=(all|corrupt)] [--output_format=(png|yuv)]\n"
" [--output_limit=<number>] [--output_folder=<folder>]\n"
" [--use_vd] [--gtest_help] [--help]\n" " [--use_vd] [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n"; " [<video path>] [<video metadata path>]\n";
...@@ -40,24 +44,20 @@ constexpr const char* help_msg = ...@@ -40,24 +44,20 @@ constexpr const char* help_msg =
"\nThe following arguments are supported:\n" "\nThe following arguments are supported:\n"
" -v enable verbose mode, e.g. -v=2.\n" " -v enable verbose mode, e.g. -v=2.\n"
" --vmodule enable verbose mode for the specified module,\n" " --vmodule enable verbose mode for the specified module,\n"
" e.g. --vmodule=*media/gpu*=2.\n" " e.g. --vmodule=*media/gpu*=2.\n\n"
" --disable_validator disable frame validation.\n" " --disable_validator disable frame validation.\n"
" --output_frames write the selected video frames to disk, possible\n"
" values are \"all|corrupt\", the default output\n"
" folder is \"<testname>\".\n"
" --output_folder overwrite the default output folder used when\n"
" \"--output_frames\" is specified.\n"
" --use_vd use the new VD-based video decoders, instead of\n" " --use_vd use the new VD-based video decoders, instead of\n"
" the default VDA-based video decoders.\n" " the default VDA-based video decoders.\n\n"
" --output_frames write the selected video frames to disk, possible\n"
" values are \"all|corrupt\".\n"
" --output_format set the format of frames saved to disk, supported\n"
" formats are \"png\" (default) and \"yuv\".\n"
" --output_limit limit the number of frames saved to disk.\n"
" --output_folder set the folder used to store frames, defaults to\n"
" \"<testname>\".\n\n"
" --gtest_help display the gtest help and exit.\n" " --gtest_help display the gtest help and exit.\n"
" --help display this help and exit.\n"; " --help display this help and exit.\n";
// The output format used when writing frames to disk.
constexpr VideoFrameFileWriter::OutputFormat kOutputFormat =
VideoFrameFileWriter::OutputFormat::kPNG;
// The max number of corrupt frames to write to disk.
constexpr size_t kCorruptFrameWriteLimit = 3;
media::test::VideoPlayerTestEnvironment* g_env; media::test::VideoPlayerTestEnvironment* g_env;
// Video decode test class. Performs setup and teardown for each single test. // Video decode test class. Performs setup and teardown for each single test.
...@@ -82,22 +82,23 @@ class VideoDecoderTest : public ::testing::Test { ...@@ -82,22 +82,23 @@ class VideoDecoderTest : public ::testing::Test {
// mode is 'all'. Only supported if import mode is supported and enabled. // mode is 'all'. Only supported if import mode is supported and enabled.
if (g_env->GetFrameOutputMode() == FrameOutputMode::kAll && if (g_env->GetFrameOutputMode() == FrameOutputMode::kAll &&
config.allocation_mode == AllocationMode::kImport) { config.allocation_mode == AllocationMode::kImport) {
frame_processors.push_back( frame_processors.push_back(VideoFrameFileWriter::Create(
VideoFrameFileWriter::Create(output_folder, kOutputFormat)); output_folder, g_env->GetFrameOutputFormat(),
g_env->GetFrameOutputLimit()));
VLOG(0) << "Writing video frames to: " << output_folder; VLOG(0) << "Writing video frames to: " << output_folder;
} }
// Use the video frame validator to validate decoded video frames if // Use the video frame validator to validate decoded video frames if
// enabled. If the frame output mode is 'corrupt', a frame writer will be // enabled. If the frame output mode is 'corrupt', a frame writer will be
// attached to forward corrupted frames to. The maximum number of corrupt // attached to forward corrupted frames to. Only supported if import mode
// frames written to disk will be limited, to reduce the size of generated // is supported and enabled.
// test artifacts. Only supported if import mode is supported and enabled.
if (g_env->IsValidatorEnabled() && if (g_env->IsValidatorEnabled() &&
config.allocation_mode == AllocationMode::kImport) { config.allocation_mode == AllocationMode::kImport) {
std::unique_ptr<VideoFrameFileWriter> frame_writer; std::unique_ptr<VideoFrameFileWriter> frame_writer;
if (g_env->GetFrameOutputMode() == FrameOutputMode::kCorrupt) { if (g_env->GetFrameOutputMode() == FrameOutputMode::kCorrupt) {
frame_writer = VideoFrameFileWriter::Create( frame_writer = VideoFrameFileWriter::Create(
output_folder, kOutputFormat, kCorruptFrameWriteLimit); output_folder, g_env->GetFrameOutputFormat(),
g_env->GetFrameOutputLimit());
} }
frame_processors.push_back(media::test::VideoFrameValidator::Create( frame_processors.push_back(media::test::VideoFrameValidator::Create(
video->FrameChecksums(), PIXEL_FORMAT_I420, std::move(frame_writer))); video->FrameChecksums(), PIXEL_FORMAT_I420, std::move(frame_writer)));
...@@ -410,8 +411,7 @@ int main(int argc, char** argv) { ...@@ -410,8 +411,7 @@ int main(int argc, char** argv) {
// Parse command line arguments. // Parse command line arguments.
bool enable_validator = true; bool enable_validator = true;
media::test::FrameOutputMode frame_output_mode = media::test::FrameOutputConfig frame_output_config;
media::test::FrameOutputMode::kNone;
base::FilePath::StringType output_folder = base::FilePath::kCurrentDirectory; base::FilePath::StringType output_folder = base::FilePath::kCurrentDirectory;
bool use_vd = false; bool use_vd = false;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
...@@ -426,14 +426,33 @@ int main(int argc, char** argv) { ...@@ -426,14 +426,33 @@ int main(int argc, char** argv) {
enable_validator = false; enable_validator = false;
} else if (it->first == "output_frames") { } else if (it->first == "output_frames") {
if (it->second == "all") { if (it->second == "all") {
frame_output_mode = media::test::FrameOutputMode::kAll; frame_output_config.output_mode = media::test::FrameOutputMode::kAll;
} else if (it->second == "corrupt") { } else if (it->second == "corrupt") {
frame_output_mode = media::test::FrameOutputMode::kCorrupt; frame_output_config.output_mode =
media::test::FrameOutputMode::kCorrupt;
} else { } else {
std::cout << "unknown frame output mode \"" << it->second std::cout << "unknown frame output mode \"" << it->second
<< "\", possible values are \"all|corrupt\"\n"; << "\", possible values are \"all|corrupt\"\n";
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else if (it->first == "output_format") {
if (it->second == "png") {
frame_output_config.output_format =
media::test::VideoFrameFileWriter::OutputFormat::kPNG;
} else if (it->second == "yuv") {
frame_output_config.output_format =
media::test::VideoFrameFileWriter::OutputFormat::kYUV;
} else {
std::cout << "unknown frame output format \"" << it->second
<< "\", possible values are \"png|yuv\"\n";
return EXIT_FAILURE;
}
} else if (it->first == "output_limit") {
if (!base::StringToUint64(it->second,
&frame_output_config.output_limit)) {
std::cout << "invalid number \"" << it->second << "\n";
return EXIT_FAILURE;
}
} else if (it->first == "output_folder") { } else if (it->first == "output_folder") {
output_folder = it->second; output_folder = it->second;
} else if (it->first == "use_vd") { } else if (it->first == "use_vd") {
...@@ -450,8 +469,8 @@ int main(int argc, char** argv) { ...@@ -450,8 +469,8 @@ int main(int argc, char** argv) {
// Set up our test environment. // Set up our test environment.
media::test::VideoPlayerTestEnvironment* test_environment = media::test::VideoPlayerTestEnvironment* test_environment =
media::test::VideoPlayerTestEnvironment::Create( media::test::VideoPlayerTestEnvironment::Create(
video_path, video_metadata_path, enable_validator, frame_output_mode, video_path, video_metadata_path, enable_validator, use_vd,
base::FilePath(output_folder), use_vd); frame_output_config, base::FilePath(output_folder));
if (!test_environment) if (!test_environment)
return EXIT_FAILURE; 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