media/gpu/test: Add test option to disable bitstream validation.
This cl adds a command line option to the new video_encode_accelerator_tests to disable bitstream validation. Bug: 1045825 Test: ./video_encode_accelerator_tests --disable_validator on hana Change-Id: I11667a65a574d9ec518b0469dd9614c7e530efe4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2227934 Commit-Queue: David Staessens <dstaessens@chromium.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Cr-Commit-Position: refs/heads/master@{#777198}
This commit is contained in:

committed by
Commit Bot

parent
b5d684c347
commit
b0a9528044
@ -55,12 +55,18 @@ Multiple command line arguments can be given to the command:
|
||||
|
||||
--codec codec profile to encode, "h264 (baseline)",
|
||||
"h264main, "h264high", "vp8" and "vp9"
|
||||
|
||||
-v enable verbose mode, e.g. -v=2.
|
||||
--vmodule enable verbose mode for the specified module,
|
||||
e.g. --vmodule=*media/gpu*=2.
|
||||
|
||||
--gtest_help display the gtest help and exit.
|
||||
--help display this help and exit.
|
||||
|
||||
Non-performance tests only:
|
||||
|
||||
--disable_validator disable validation of encoded bitstream.
|
||||
|
||||
## Source code
|
||||
See the video encoder tests [source code](https://cs.chromium.org/chromium/src/media/gpu/video_encode_accelerator_tests.cc).
|
||||
See the video encoder performance tests [source code](https://cs.chromium.org/chromium/src/media/gpu/video_encode_accelerator_perf_tests.cc).
|
||||
|
@ -50,6 +50,7 @@ const std::vector<base::Feature> kDisabledFeaturesForVideoEncoderTest = {
|
||||
VideoEncoderTestEnvironment* VideoEncoderTestEnvironment::Create(
|
||||
const base::FilePath& video_path,
|
||||
const base::FilePath& video_metadata_path,
|
||||
bool enable_bitstream_validator,
|
||||
const base::FilePath& output_folder,
|
||||
const std::string& codec) {
|
||||
if (video_path.empty()) {
|
||||
@ -89,17 +90,19 @@ VideoEncoderTestEnvironment* VideoEncoderTestEnvironment::Create(
|
||||
return nullptr;
|
||||
}
|
||||
VideoCodecProfile profile = it->profile;
|
||||
return new VideoEncoderTestEnvironment(std::move(video), output_folder,
|
||||
profile);
|
||||
return new VideoEncoderTestEnvironment(
|
||||
std::move(video), enable_bitstream_validator, output_folder, profile);
|
||||
}
|
||||
|
||||
VideoEncoderTestEnvironment::VideoEncoderTestEnvironment(
|
||||
std::unique_ptr<media::test::Video> video,
|
||||
bool enable_bitstream_validator,
|
||||
const base::FilePath& output_folder,
|
||||
VideoCodecProfile profile)
|
||||
: VideoTestEnvironment(kEnabledFeaturesForVideoEncoderTest,
|
||||
kDisabledFeaturesForVideoEncoderTest),
|
||||
video_(std::move(video)),
|
||||
enable_bitstream_validator_(enable_bitstream_validator),
|
||||
output_folder_(output_folder),
|
||||
profile_(profile),
|
||||
gpu_memory_buffer_factory_(
|
||||
@ -111,6 +114,10 @@ media::test::Video* VideoEncoderTestEnvironment::Video() const {
|
||||
return video_.get();
|
||||
}
|
||||
|
||||
bool VideoEncoderTestEnvironment::IsBitstreamValidatorEnabled() const {
|
||||
return enable_bitstream_validator_;
|
||||
}
|
||||
|
||||
const base::FilePath& VideoEncoderTestEnvironment::OutputFolder() const {
|
||||
return output_folder_;
|
||||
}
|
||||
|
@ -29,12 +29,15 @@ class VideoEncoderTestEnvironment : public VideoTestEnvironment {
|
||||
static VideoEncoderTestEnvironment* Create(
|
||||
const base::FilePath& video_path,
|
||||
const base::FilePath& video_metadata_path,
|
||||
bool enable_bitstream_validator,
|
||||
const base::FilePath& output_folder,
|
||||
const std::string& codec);
|
||||
~VideoEncoderTestEnvironment() override;
|
||||
|
||||
// Get the video the tests will be ran on.
|
||||
media::test::Video* Video() const;
|
||||
// Whether bitstream validation is enabled.
|
||||
bool IsBitstreamValidatorEnabled() const;
|
||||
// Get the output folder.
|
||||
const base::FilePath& OutputFolder() const;
|
||||
// Get the output codec profile.
|
||||
@ -48,11 +51,14 @@ class VideoEncoderTestEnvironment : public VideoTestEnvironment {
|
||||
|
||||
private:
|
||||
VideoEncoderTestEnvironment(std::unique_ptr<media::test::Video> video,
|
||||
bool enable_bitstream_validator,
|
||||
const base::FilePath& output_folder,
|
||||
VideoCodecProfile profile);
|
||||
|
||||
// Video file to be used for testing.
|
||||
const std::unique_ptr<media::test::Video> video_;
|
||||
// Whether bitstream validation should be enabled while testing.
|
||||
const bool enable_bitstream_validator_;
|
||||
// Output folder to be used to store test artifacts (e.g. perf metrics).
|
||||
const base::FilePath output_folder_;
|
||||
// VideoCodecProfile to be produced by VideoEncoder.
|
||||
|
@ -366,7 +366,7 @@ int main(int argc, char** argv) {
|
||||
// Set up our test environment.
|
||||
media::test::VideoEncoderTestEnvironment* test_environment =
|
||||
media::test::VideoEncoderTestEnvironment::Create(
|
||||
video_path, video_metadata_path, base::FilePath(output_folder),
|
||||
video_path, video_metadata_path, false, base::FilePath(output_folder),
|
||||
codec);
|
||||
if (!test_environment)
|
||||
return EXIT_FAILURE;
|
||||
|
@ -30,7 +30,7 @@ namespace {
|
||||
// TODO(dstaessens): Add video_encoder_test_usage.md
|
||||
constexpr const char* usage_msg =
|
||||
"usage: video_encode_accelerator_tests\n"
|
||||
" [--codec=<codec>]\n"
|
||||
" [--codec=<codec>] [--disable_validator]\n"
|
||||
" [-v=<level>] [--vmodule=<config>] [--gtest_help] [--help]\n"
|
||||
" [<video path>] [<video metadata path>]\n";
|
||||
|
||||
@ -45,6 +45,7 @@ constexpr const char* help_msg =
|
||||
"\nThe following arguments are supported:\n"
|
||||
" --codec codec profile to encode, \"h264 (baseline)\",\n"
|
||||
" \"h264main, \"h264high\", \"vp8\" and \"vp9\"\n"
|
||||
" --disable_validator disable validation of encoded bitstream.\n\n"
|
||||
" -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\n"
|
||||
@ -65,7 +66,23 @@ class VideoEncoderTest : public ::testing::Test {
|
||||
VideoEncoderClientConfig config = VideoEncoderClientConfig()) {
|
||||
LOG_ASSERT(video);
|
||||
|
||||
auto video_encoder =
|
||||
VideoEncoder::Create(config, CreateBitstreamProcessors(video, config));
|
||||
LOG_ASSERT(video_encoder);
|
||||
LOG_ASSERT(video_encoder->Initialize(video));
|
||||
|
||||
return video_encoder;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<BitstreamProcessor>> CreateBitstreamProcessors(
|
||||
Video* video,
|
||||
VideoEncoderClientConfig config) {
|
||||
std::vector<std::unique_ptr<BitstreamProcessor>> bitstream_processors;
|
||||
if (!g_env->IsBitstreamValidatorEnabled()) {
|
||||
return bitstream_processors;
|
||||
}
|
||||
|
||||
const gfx::Rect visible_rect(video->Resolution());
|
||||
VideoCodec codec = VideoCodecProfileToVideoCodec(config.output_profile);
|
||||
switch (codec) {
|
||||
@ -87,14 +104,21 @@ class VideoEncoderTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
// Attach a bitstream validator to validate all encoded video frames. The
|
||||
// bitstream validator uses a software video decoder to validate the encoded
|
||||
// buffers by decoding them. Metrics such as the image's SSIM can be
|
||||
// calculated for additional quality checks.
|
||||
// bitstream validator uses a software video decoder to validate the
|
||||
// encoded buffers by decoding them. Metrics such as the image's SSIM can
|
||||
// be calculated for additional quality checks.
|
||||
VideoDecoderConfig decoder_config(
|
||||
codec, config.output_profile, VideoDecoderConfig::AlphaMode::kIsOpaque,
|
||||
VideoColorSpace(), kNoTransformation, visible_rect.size(), visible_rect,
|
||||
visible_rect.size(), EmptyExtraData(), EncryptionScheme::kUnencrypted);
|
||||
std::vector<std::unique_ptr<VideoFrameProcessor>> video_frame_processors;
|
||||
|
||||
raw_data_helper_ = RawDataHelper::Create(video);
|
||||
if (!raw_data_helper_) {
|
||||
LOG(ERROR) << "Failed to create raw data helper";
|
||||
return bitstream_processors;
|
||||
}
|
||||
|
||||
// TODO(hiroh): Add corrupt frame processors.
|
||||
VideoFrameValidator::GetModelFrameCB get_model_frame_cb =
|
||||
base::BindRepeating(&VideoEncoderTest::GetModelFrame,
|
||||
@ -109,20 +133,9 @@ class VideoEncoderTest : public ::testing::Test {
|
||||
LOG_ASSERT(bitstream_validator);
|
||||
bitstream_processors.emplace_back(std::move(bitstream_validator));
|
||||
|
||||
auto video_encoder =
|
||||
VideoEncoder::Create(config, std::move(bitstream_processors));
|
||||
LOG_ASSERT(video_encoder);
|
||||
LOG_ASSERT(video_encoder->Initialize(video));
|
||||
|
||||
raw_data_helper_ = RawDataHelper::Create(video);
|
||||
if (!raw_data_helper_) {
|
||||
LOG(ERROR) << "Failed to create ";
|
||||
return nullptr;
|
||||
}
|
||||
return video_encoder;
|
||||
return bitstream_processors;
|
||||
}
|
||||
|
||||
private:
|
||||
scoped_refptr<const VideoFrame> GetModelFrame(size_t frame_index) {
|
||||
LOG_ASSERT(raw_data_helper_);
|
||||
return raw_data_helper_->GetFrame(frame_index);
|
||||
@ -182,6 +195,7 @@ int main(int argc, char** argv) {
|
||||
std::string codec = "h264";
|
||||
|
||||
// Parse command line arguments.
|
||||
bool enable_bitstream_validator = true;
|
||||
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
|
||||
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
|
||||
it != switches.end(); ++it) {
|
||||
@ -192,6 +206,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (it->first == "codec") {
|
||||
codec = it->second;
|
||||
} else if (it->first == "disable_validator") {
|
||||
enable_bitstream_validator = false;
|
||||
} else {
|
||||
std::cout << "unknown option: --" << it->first << "\n"
|
||||
<< media::test::usage_msg;
|
||||
@ -204,7 +220,8 @@ int main(int argc, char** argv) {
|
||||
// Set up our test environment.
|
||||
media::test::VideoEncoderTestEnvironment* test_environment =
|
||||
media::test::VideoEncoderTestEnvironment::Create(
|
||||
video_path, video_metadata_path, base::FilePath(), codec);
|
||||
video_path, video_metadata_path, enable_bitstream_validator,
|
||||
base::FilePath(), codec);
|
||||
if (!test_environment)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
|
Reference in New Issue
Block a user