Skip to content

Commit

Permalink
media/gpu/test: Allow overwriting output folder in new video decoder …
Browse files Browse the repository at this point in the history
…tests.

This CL adds the --output_folder parameter to the video_decode_accelerator_tests
and video_decode_accelerator_perf_tests binaries, so the default output folder
for video frames and metrics can be overwritten. This is required to run the
tests from Tast.

TEST=ran new VDA (perf) tests on eve

BUG=953114

Change-Id: Id536f0bc441dbf23ea3ab39434e340ec4503924e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605324
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665461}
  • Loading branch information
David Staessens authored and Commit Bot committed Jun 3, 2019
1 parent 40a8223 commit 4aeee03
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 16 deletions.
3 changes: 3 additions & 0 deletions docs/media/gpu/video_decoder_perf_test_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Multiple command line arguments can be given to the command:
-v enable verbose mode, e.g. -v=2.
--vmodule enable verbose mode for the specified module,
e.g. --vmodule=*media/gpu*=2.
--output_folder overwrite the output folder used to store
performance metrics, if not specified results
will be stored in the current working directory.
--use_vd use the new VD-based video decoders, instead of
the default VDA-based video decoders.
--gtest_help display the gtest help and exit.
Expand Down
2 changes: 2 additions & 0 deletions docs/media/gpu/video_decoder_test_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Multiple command line arguments can be given to the command:
platforms that don't support import mode.
--output_frames write all decoded video frames to the
"video_frames" folder.
--output_folder overwrite the default output folder used when
"--output_frames" is specified.
--use_vd use the new VD-based video decoders, instead of
the default VDA-based video decoders.
--gtest_help display the gtest help and exit.
Expand Down
7 changes: 1 addition & 6 deletions media/gpu/test/video_frame_file_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ class VideoFrameMapper;

namespace test {

// Default output folder used to store frames.
constexpr const base::FilePath::CharType* kDefaultOutputFolder =
FILE_PATH_LITERAL("video_frames");

// The video frame file writer class implements functionality to write video
// frames to file. The supported output formats are PNG and raw I420 YUV.
class VideoFrameFileWriter : public VideoFrameProcessor {
Expand All @@ -39,8 +35,7 @@ class VideoFrameFileWriter : public VideoFrameProcessor {

// Create an instance of the video frame file writer.
static std::unique_ptr<VideoFrameFileWriter> Create(
const base::FilePath& output_folder =
base::FilePath(kDefaultOutputFolder),
const base::FilePath& output_folder,
OutputFormat output_format = OutputFormat::kPNG);

// Interface VideoFrameProcessor
Expand Down
9 changes: 8 additions & 1 deletion media/gpu/test/video_player/video_player_test_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
const base::FilePath& video_metadata_path,
bool enable_validator,
bool output_frames,
const base::FilePath& output_folder,
bool use_vd) {
auto video = std::make_unique<media::test::Video>(
video_path.empty() ? base::FilePath(kDefaultTestVideoPath) : video_path,
Expand All @@ -31,17 +32,19 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
}

return new VideoPlayerTestEnvironment(std::move(video), enable_validator,
output_frames, use_vd);
output_frames, output_folder, use_vd);
}

VideoPlayerTestEnvironment::VideoPlayerTestEnvironment(
std::unique_ptr<media::test::Video> video,
bool enable_validator,
bool output_frames,
const base::FilePath& output_folder,
bool use_vd)
: video_(std::move(video)),
enable_validator_(enable_validator),
output_frames_(output_frames),
output_folder_(output_folder),
use_vd_(use_vd) {}

VideoPlayerTestEnvironment::~VideoPlayerTestEnvironment() = default;
Expand All @@ -58,6 +61,10 @@ bool VideoPlayerTestEnvironment::IsFramesOutputEnabled() const {
return output_frames_;
}

const base::FilePath& VideoPlayerTestEnvironment::OutputFolder() const {
return output_folder_;
}

bool VideoPlayerTestEnvironment::UseVD() const {
return use_vd_;
}
Expand Down
5 changes: 5 additions & 0 deletions media/gpu/test/video_player/video_player_test_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment {
const base::FilePath& video_metadata_path,
bool enable_validator,
bool output_frames,
const base::FilePath& output_folder,
bool use_vd);
~VideoPlayerTestEnvironment() override;

Expand All @@ -33,18 +34,22 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment {
bool IsValidatorEnabled() const;
// Check whether outputting frames is enabled.
bool IsFramesOutputEnabled() const;
// Get the output folder.
const base::FilePath& OutputFolder() const;
// Check whether we should use VD-based video decoders instead of VDA-based.
bool UseVD() const;

private:
VideoPlayerTestEnvironment(std::unique_ptr<media::test::Video> video,
bool enable_validator,
bool output_frames,
const base::FilePath& output_folder,
bool use_vd);

const std::unique_ptr<media::test::Video> video_;
const bool enable_validator_;
const bool output_frames_;
const base::FilePath output_folder_;
const bool use_vd_;
};
} // namespace test
Expand Down
19 changes: 14 additions & 5 deletions media/gpu/video_decode_accelerator_perf_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ namespace {
// making changes here.
constexpr const char* usage_msg =
"usage: video_decode_accelerator_perf_tests\n"
" [-v=<level>] [--vmodule=<config>] [--use_vd] [--gtest_help]\n"
" [--help] [<video path>] [<video metadata path>]\n";
" [-v=<level>] [--vmodule=<config>] [--output_folder]\n"
" [--use_vd] [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n";

// Video decoder perf tests help message.
constexpr const char* help_msg =
Expand All @@ -42,6 +43,9 @@ 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"
" --output_folder overwrite the output folder used to store\n"
" performance metrics, if not specified results\n"
" will be stored in the current working directory.\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"
Expand Down Expand Up @@ -175,9 +179,10 @@ void PerformanceEvaluator::StopMeasuring() {
}

void PerformanceEvaluator::WriteMetricsToFile() const {
base::FilePath output_folder_path = base::FilePath(kDefaultOutputFolder);
base::FilePath output_folder_path = base::FilePath(g_env->OutputFolder());
if (!DirectoryExists(output_folder_path))
base::CreateDirectory(output_folder_path);
output_folder_path = base::MakeAbsoluteFilePath(output_folder_path);

// Write performance metrics to json file.
base::Value metrics(base::Value::Type::DICTIONARY);
Expand Down Expand Up @@ -332,6 +337,7 @@ int main(int argc, char** argv) {
(args.size() >= 2) ? base::FilePath(args[1]) : base::FilePath();

// Parse command line arguments.
base::FilePath::StringType output_folder = media::test::kDefaultOutputFolder;
bool use_vd = false;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
Expand All @@ -341,7 +347,9 @@ int main(int argc, char** argv) {
continue;
}

if (it->first == "use_vd") {
if (it->first == "output_folder") {
output_folder = it->second;
} else if (it->first == "use_vd") {
use_vd = true;
} else {
std::cout << "unknown option: --" << it->first << "\n"
Expand All @@ -355,7 +363,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, false, false, use_vd);
video_path, video_metadata_path, false, false,
base::FilePath(output_folder), use_vd);
if (!test_environment)
return EXIT_FAILURE;

Expand Down
18 changes: 14 additions & 4 deletions media/gpu/video_decode_accelerator_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace {
constexpr const char* usage_msg =
"usage: video_decode_accelerator_tests\n"
" [-v=<level>] [--vmodule=<config>] [--disable_validator]\n"
" [--output_frames] [--use_vd] [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n";
" [--output_frames] [output_folder] [--use_vd] [--gtest_help]\n"
" [--help] [<video path>] [<video metadata path>]\n";

// Video decoder tests help message.
constexpr const char* help_msg =
Expand All @@ -43,13 +43,19 @@ 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"
" --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"
" the default VDA-based video decoders.\n"
" --gtest_help display the gtest help and exit.\n"
" --help display this help and exit.\n";

media::test::VideoPlayerTestEnvironment* g_env;

// Default output folder used to store video frames.
constexpr const base::FilePath::CharType* kDefaultOutputFolder =
FILE_PATH_LITERAL("video_frames");

// Video decode test class. Performs setup and teardown for each single test.
class VideoDecoderTest : public ::testing::Test {
public:
Expand All @@ -70,9 +76,10 @@ class VideoDecoderTest : public ::testing::Test {
// Write decoded video frames to the 'video_frames/<test_name/>' folder.
if (g_env->IsFramesOutputEnabled()) {
base::FilePath output_folder =
base::FilePath(FILE_PATH_LITERAL("video_frames"))
base::FilePath(g_env->OutputFolder())
.Append(base::FilePath(g_env->GetTestName()));
frame_processors.push_back(VideoFrameFileWriter::Create(output_folder));
VLOG(0) << "Writing video frames to: " << output_folder;
}

// Use the new VD-based video decoders if requested.
Expand Down Expand Up @@ -301,6 +308,7 @@ int main(int argc, char** argv) {
// Parse command line arguments.
bool enable_validator = true;
bool output_frames = false;
base::FilePath::StringType output_folder = media::test::kDefaultOutputFolder;
bool use_vd = false;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
Expand All @@ -314,6 +322,8 @@ int main(int argc, char** argv) {
enable_validator = false;
} else if (it->first == "output_frames") {
output_frames = true;
} else if (it->first == "output_folder") {
output_folder = it->second;
} else if (it->first == "use_vd") {
use_vd = true;
} else {
Expand All @@ -329,7 +339,7 @@ int main(int argc, char** argv) {
media::test::VideoPlayerTestEnvironment* test_environment =
media::test::VideoPlayerTestEnvironment::Create(
video_path, video_metadata_path, enable_validator, output_frames,
use_vd);
base::FilePath(output_folder), use_vd);
if (!test_environment)
return EXIT_FAILURE;

Expand Down

0 comments on commit 4aeee03

Please sign in to comment.