Commit 1c05c665 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media/gpu/test: Add parameter to support VD-based VDA using VdVDA.

This CL adds a parameter "--use_vd_vda" to the
video_decode_accelerator_tests and video_decode_accelerator_perf_tests
to support VD-based VDA using VdVDA.

Bug: b:136716838
Test: video_decode_accelerator_tests --use_vd_vda on Kevin and Eve
Test: video_decode_accelerator_perf_tests --use_vd_vda on Kevin and Eve

Change-Id: Ib515f97cef66412a3ff833686148d846148d6109
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928519Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749522}
parent 4781aef0
...@@ -128,6 +128,7 @@ static_library("video_player_test_environment") { ...@@ -128,6 +128,7 @@ static_library("video_player_test_environment") {
deps = [ deps = [
":frame_file_writer", ":frame_file_writer",
":helpers", ":helpers",
":video_player",
"//media/gpu", "//media/gpu",
] ]
} }
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
#include "media/gpu/chromeos/chromeos_video_decoder_factory.h"
#include "media/gpu/chromeos/platform_video_frame_utils.h" #include "media/gpu/chromeos/platform_video_frame_utils.h"
#include "media/gpu/chromeos/vd_video_decode_accelerator.h"
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
namespace media { namespace media {
...@@ -34,12 +36,14 @@ constexpr size_t kTimestampCacheSize = 128; ...@@ -34,12 +36,14 @@ constexpr size_t kTimestampCacheSize = 128;
TestVDAVideoDecoder::TestVDAVideoDecoder( TestVDAVideoDecoder::TestVDAVideoDecoder(
AllocationMode allocation_mode, AllocationMode allocation_mode,
bool use_vd_vda,
const gfx::ColorSpace& target_color_space, const gfx::ColorSpace& target_color_space,
FrameRenderer* const frame_renderer, FrameRenderer* const frame_renderer,
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
: output_mode_(allocation_mode == AllocationMode::kAllocate : output_mode_(allocation_mode == AllocationMode::kAllocate
? VideoDecodeAccelerator::Config::OutputMode::ALLOCATE ? VideoDecodeAccelerator::Config::OutputMode::ALLOCATE
: VideoDecodeAccelerator::Config::OutputMode::IMPORT), : VideoDecodeAccelerator::Config::OutputMode::IMPORT),
use_vd_vda_(use_vd_vda),
target_color_space_(target_color_space), target_color_space_(target_color_space),
frame_renderer_(frame_renderer), frame_renderer_(frame_renderer),
#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
...@@ -125,8 +129,19 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -125,8 +129,19 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config,
gpu::GpuDriverBugWorkarounds gpu_driver_bug_workarounds; gpu::GpuDriverBugWorkarounds gpu_driver_bug_workarounds;
gpu::GpuPreferences gpu_preferences; gpu::GpuPreferences gpu_preferences;
if (use_vd_vda_) {
#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
DVLOGF(2) << "Use VdVideoDecodeAccelerator";
vda_config.is_deferred_initialization_allowed = true;
decoder_ = media::VdVideoDecodeAccelerator::Create(
base::BindRepeating(&media::ChromeosVideoDecoderFactory::Create), this,
vda_config, base::SequencedTaskRunnerHandle::Get());
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
} else {
DVLOGF(2) << "Use original VDA";
decoder_ = decoder_factory->CreateVDA( decoder_ = decoder_factory->CreateVDA(
this, vda_config, gpu_driver_bug_workarounds, gpu_preferences); this, vda_config, gpu_driver_bug_workarounds, gpu_preferences);
}
if (!decoder_) { if (!decoder_) {
ASSERT_TRUE(decoder_) << "Failed to create VideoDecodeAccelerator factory"; ASSERT_TRUE(decoder_) << "Failed to create VideoDecodeAccelerator factory";
......
...@@ -37,6 +37,7 @@ class TestVDAVideoDecoder : public media::VideoDecoder, ...@@ -37,6 +37,7 @@ class TestVDAVideoDecoder : public media::VideoDecoder,
// whether allocating video frames will be done by the TestVDAVideoDecoder, or // whether allocating video frames will be done by the TestVDAVideoDecoder, or
// delegated to the underlying VDA. // delegated to the underlying VDA.
TestVDAVideoDecoder(AllocationMode allocation_mode, TestVDAVideoDecoder(AllocationMode allocation_mode,
bool use_vd_vda,
const gfx::ColorSpace& target_color_space, const gfx::ColorSpace& target_color_space,
FrameRenderer* const frame_renderer, FrameRenderer* const frame_renderer,
gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory);
...@@ -105,6 +106,9 @@ class TestVDAVideoDecoder : public media::VideoDecoder, ...@@ -105,6 +106,9 @@ class TestVDAVideoDecoder : public media::VideoDecoder,
// Video decode accelerator output mode. // Video decode accelerator output mode.
const VideoDecodeAccelerator::Config::OutputMode output_mode_; const VideoDecodeAccelerator::Config::OutputMode output_mode_;
// Whether VdVideoDecodeAccelerator is used.
bool use_vd_vda_;
// Output color space, used as hint to decoder to avoid conversions. // Output color space, used as hint to decoder to avoid conversions.
const gfx::ColorSpace target_color_space_; const gfx::ColorSpace target_color_space_;
......
...@@ -181,24 +181,32 @@ void VideoDecoderClient::CreateDecoderTask(bool* success, ...@@ -181,24 +181,32 @@ void VideoDecoderClient::CreateDecoderTask(bool* success,
DCHECK_EQ(decoder_client_state_, VideoDecoderClientState::kUninitialized); DCHECK_EQ(decoder_client_state_, VideoDecoderClientState::kUninitialized);
ASSERT_TRUE(!decoder_) << "Can't create decoder: already created"; ASSERT_TRUE(!decoder_) << "Can't create decoder: already created";
if (decoder_client_config_.use_vd) { switch (decoder_client_config_.implementation) {
case DecoderImplementation::kVD:
#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
if (decoder_client_config_.allocation_mode == AllocationMode::kImport) { if (decoder_client_config_.allocation_mode == AllocationMode::kImport) {
decoder_ = ChromeosVideoDecoderFactory::Create( decoder_ = ChromeosVideoDecoderFactory::Create(
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
std::make_unique<PlatformVideoFramePool>(gpu_memory_buffer_factory_), std::make_unique<PlatformVideoFramePool>(
std::make_unique<VideoFrameConverter>(), gpu_memory_buffer_factory_); gpu_memory_buffer_factory_),
std::make_unique<VideoFrameConverter>(),
gpu_memory_buffer_factory_);
} else { } else {
LOG(ERROR) << "VD-based video decoders only support import mode"; LOG(ERROR) << "VD-based video decoders only support import mode";
} }
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
} else { break;
case DecoderImplementation::kVDA:
case DecoderImplementation::kVDVDA:
// The video decoder client expects decoders to use the VD interface. We // The video decoder client expects decoders to use the VD interface. We
// can use the TestVDAVideoDecoder wrapper here to test VDA-based video // can use the TestVDAVideoDecoder wrapper here to test VDA-based video
// decoders. // decoders.
decoder_ = std::make_unique<TestVDAVideoDecoder>( decoder_ = std::make_unique<TestVDAVideoDecoder>(
decoder_client_config_.allocation_mode, gfx::ColorSpace(), decoder_client_config_.allocation_mode,
frame_renderer_.get(), gpu_memory_buffer_factory_); decoder_client_config_.implementation ==
DecoderImplementation::kVDVDA,
gfx::ColorSpace(), frame_renderer_.get(), gpu_memory_buffer_factory_);
break;
} }
*success = (decoder_ != nullptr); *success = (decoder_ != nullptr);
......
...@@ -38,6 +38,13 @@ enum class AllocationMode { ...@@ -38,6 +38,13 @@ enum class AllocationMode {
kAllocate, // Video decoder allocates video frame memory. kAllocate, // Video decoder allocates video frame memory.
}; };
// The supported video decoding implementation.
enum class DecoderImplementation {
kVDA, // VDA-based video decoder.
kVD, // VD-based video decoder.
kVDVDA, // VD-based video decoder with VdVDA.
};
// Video decoder client configuration. // Video decoder client configuration.
struct VideoDecoderClientConfig { struct VideoDecoderClientConfig {
// The maximum number of bitstream buffer decodes that can be requested // The maximum number of bitstream buffer decodes that can be requested
...@@ -45,8 +52,7 @@ struct VideoDecoderClientConfig { ...@@ -45,8 +52,7 @@ struct VideoDecoderClientConfig {
size_t max_outstanding_decode_requests = 1; size_t max_outstanding_decode_requests = 1;
// How the pictures buffers should be allocated. // How the pictures buffers should be allocated.
AllocationMode allocation_mode = AllocationMode::kImport; AllocationMode allocation_mode = AllocationMode::kImport;
// Use VD-based video decoders instead of VDA-based video decoders. DecoderImplementation implementation = DecoderImplementation::kVDA;
bool use_vd = false;
}; };
// The video decoder client is responsible for the communication between the // The video decoder client is responsible for the communication between the
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "media/base/video_types.h" #include "media/base/video_types.h"
#include "media/gpu/test/video.h" #include "media/gpu/test/video.h"
#include "media/gpu/test/video_player/video_decoder_client.h"
namespace media { namespace media {
namespace test { namespace test {
...@@ -22,7 +23,7 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create( ...@@ -22,7 +23,7 @@ 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,
bool use_vd, const DecoderImplementation implementation,
const base::FilePath& output_folder, const base::FilePath& output_folder,
const FrameOutputConfig& frame_output_config) { const FrameOutputConfig& frame_output_config) {
auto video = std::make_unique<media::test::Video>( auto video = std::make_unique<media::test::Video>(
...@@ -34,19 +35,19 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create( ...@@ -34,19 +35,19 @@ VideoPlayerTestEnvironment* VideoPlayerTestEnvironment::Create(
} }
return new VideoPlayerTestEnvironment(std::move(video), enable_validator, return new VideoPlayerTestEnvironment(std::move(video), enable_validator,
use_vd, output_folder, implementation, output_folder,
frame_output_config); frame_output_config);
} }
VideoPlayerTestEnvironment::VideoPlayerTestEnvironment( VideoPlayerTestEnvironment::VideoPlayerTestEnvironment(
std::unique_ptr<media::test::Video> video, std::unique_ptr<media::test::Video> video,
bool enable_validator, bool enable_validator,
bool use_vd, const DecoderImplementation implementation,
const base::FilePath& output_folder, const base::FilePath& output_folder,
const FrameOutputConfig& frame_output_config) const FrameOutputConfig& frame_output_config)
: video_(std::move(video)), : video_(std::move(video)),
enable_validator_(enable_validator), enable_validator_(enable_validator),
use_vd_(use_vd), implementation_(implementation),
frame_output_config_(frame_output_config), frame_output_config_(frame_output_config),
output_folder_(output_folder), output_folder_(output_folder),
gpu_memory_buffer_factory_( gpu_memory_buffer_factory_(
...@@ -74,7 +75,7 @@ void VideoPlayerTestEnvironment::SetUp() { ...@@ -74,7 +75,7 @@ void VideoPlayerTestEnvironment::SetUp() {
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// VideoDecoders always require import mode to be supported. // VideoDecoders always require import mode to be supported.
DCHECK(!use_vd_ || import_supported_); DCHECK(import_supported_ || implementation_ == DecoderImplementation::kVDA);
} }
const media::test::Video* VideoPlayerTestEnvironment::Video() const { const media::test::Video* VideoPlayerTestEnvironment::Video() const {
...@@ -90,8 +91,9 @@ bool VideoPlayerTestEnvironment::IsValidatorEnabled() const { ...@@ -90,8 +91,9 @@ bool VideoPlayerTestEnvironment::IsValidatorEnabled() const {
return enable_validator_; return enable_validator_;
} }
bool VideoPlayerTestEnvironment::UseVD() const { DecoderImplementation VideoPlayerTestEnvironment::GetDecoderImplementation()
return use_vd_; const {
return implementation_;
} }
FrameOutputMode VideoPlayerTestEnvironment::GetFrameOutputMode() const { FrameOutputMode VideoPlayerTestEnvironment::GetFrameOutputMode() const {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h" #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "media/gpu/test/video_frame_file_writer.h" #include "media/gpu/test/video_frame_file_writer.h"
#include "media/gpu/test/video_player/video_decoder_client.h"
#include "media/gpu/test/video_test_environment.h" #include "media/gpu/test/video_test_environment.h"
namespace media { namespace media {
...@@ -47,7 +48,7 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment { ...@@ -47,7 +48,7 @@ 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,
bool use_vd, const DecoderImplementation implementation,
const base::FilePath& output_folder = base::FilePath(), const base::FilePath& output_folder = base::FilePath(),
const FrameOutputConfig& frame_output_config = FrameOutputConfig()); const FrameOutputConfig& frame_output_config = FrameOutputConfig());
~VideoPlayerTestEnvironment() override; ~VideoPlayerTestEnvironment() override;
...@@ -59,8 +60,8 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment { ...@@ -59,8 +60,8 @@ 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. // Return which implementation is used.
bool UseVD() const; DecoderImplementation GetDecoderImplementation() const;
// Get the frame output mode. // Get the frame output mode.
FrameOutputMode GetFrameOutputMode() const; FrameOutputMode GetFrameOutputMode() const;
...@@ -83,13 +84,13 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment { ...@@ -83,13 +84,13 @@ class VideoPlayerTestEnvironment : public VideoTestEnvironment {
private: private:
VideoPlayerTestEnvironment(std::unique_ptr<media::test::Video> video, VideoPlayerTestEnvironment(std::unique_ptr<media::test::Video> video,
bool enable_validator, bool enable_validator,
bool use_vd, const DecoderImplementation implementation,
const base::FilePath& output_folder, const base::FilePath& output_folder,
const FrameOutputConfig& frame_output_config); const FrameOutputConfig& frame_output_config);
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 bool use_vd_; const DecoderImplementation implementation_;
const FrameOutputConfig frame_output_config_; const FrameOutputConfig frame_output_config_;
const base::FilePath output_folder_; const base::FilePath output_folder_;
......
...@@ -29,7 +29,7 @@ namespace { ...@@ -29,7 +29,7 @@ namespace {
constexpr const char* usage_msg = constexpr const char* usage_msg =
"usage: video_decode_accelerator_perf_tests\n" "usage: video_decode_accelerator_perf_tests\n"
" [-v=<level>] [--vmodule=<config>] [--output_folder]\n" " [-v=<level>] [--vmodule=<config>] [--output_folder]\n"
" [--use_vd] [--gtest_help] [--help]\n" " ([--use_vd]|[--use_vd_vda]) [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n"; " [<video path>] [<video metadata path>]\n";
// Video decoder perf tests help message. // Video decoder perf tests help message.
...@@ -49,6 +49,10 @@ constexpr const char* help_msg = ...@@ -49,6 +49,10 @@ constexpr const char* help_msg =
" will be stored in the current working directory.\n" " will be stored in the current working directory.\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"
" --use_vd_vda use the new VD-based video decoders with a wrapper"
" that translates to the VDA interface, used to test"
" interaction with older components expecting the VDA"
" interface.\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";
...@@ -316,7 +320,7 @@ class VideoDecoderTest : public ::testing::Test { ...@@ -316,7 +320,7 @@ class VideoDecoderTest : public ::testing::Test {
// Use the new VD-based video decoders if requested. // Use the new VD-based video decoders if requested.
VideoDecoderClientConfig config; VideoDecoderClientConfig config;
config.use_vd = g_env->UseVD(); config.implementation = g_env->GetDecoderImplementation();
// Force allocate mode if import mode is not supported. // Force allocate mode if import mode is not supported.
if (!g_env->ImportSupported()) if (!g_env->ImportSupported())
...@@ -399,6 +403,9 @@ int main(int argc, char** argv) { ...@@ -399,6 +403,9 @@ int main(int argc, char** argv) {
// Parse command line arguments. // Parse command line arguments.
base::FilePath::StringType output_folder = media::test::kDefaultOutputFolder; base::FilePath::StringType output_folder = media::test::kDefaultOutputFolder;
bool use_vd = false; bool use_vd = false;
bool use_vd_vda = false;
media::test::DecoderImplementation implementation =
media::test::DecoderImplementation::kVDA;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) { it != switches.end(); ++it) {
...@@ -411,6 +418,10 @@ int main(int argc, char** argv) { ...@@ -411,6 +418,10 @@ int main(int argc, char** argv) {
output_folder = it->second; output_folder = it->second;
} else if (it->first == "use_vd") { } else if (it->first == "use_vd") {
use_vd = true; use_vd = true;
implementation = media::test::DecoderImplementation::kVD;
} else if (it->first == "use_vd_vda") {
use_vd_vda = true;
implementation = media::test::DecoderImplementation::kVDVDA;
} else { } else {
std::cout << "unknown option: --" << it->first << "\n" std::cout << "unknown option: --" << it->first << "\n"
<< media::test::usage_msg; << media::test::usage_msg;
...@@ -418,12 +429,18 @@ int main(int argc, char** argv) { ...@@ -418,12 +429,18 @@ int main(int argc, char** argv) {
} }
} }
if (use_vd && use_vd_vda) {
std::cout << "--use_vd and --use_vd_vda cannot be enabled together.\n"
<< media::test::usage_msg;
return EXIT_FAILURE;
}
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, 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, use_vd, video_path, video_metadata_path, false, implementation,
base::FilePath(output_folder)); base::FilePath(output_folder));
if (!test_environment) if (!test_environment)
return EXIT_FAILURE; return EXIT_FAILURE;
......
...@@ -30,7 +30,7 @@ constexpr const char* usage_msg = ...@@ -30,7 +30,7 @@ constexpr const char* usage_msg =
" [-v=<level>] [--vmodule=<config>] [--disable_validator]\n" " [-v=<level>] [--vmodule=<config>] [--disable_validator]\n"
" [--output_frames=(all|corrupt)] [--output_format=(png|yuv)]\n" " [--output_frames=(all|corrupt)] [--output_format=(png|yuv)]\n"
" [--output_limit=<number>] [--output_folder=<folder>]\n" " [--output_limit=<number>] [--output_folder=<folder>]\n"
" [--use_vd] [--gtest_help] [--help]\n" " ([--use_vd]|[--use_vd_vda]) [--gtest_help] [--help]\n"
" [<video path>] [<video metadata path>]\n"; " [<video path>] [<video metadata path>]\n";
// Video decoder tests help message. // Video decoder tests help message.
...@@ -48,6 +48,10 @@ constexpr const char* help_msg = ...@@ -48,6 +48,10 @@ constexpr const char* help_msg =
" --disable_validator disable frame validation.\n" " --disable_validator disable frame validation.\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\n" " the default VDA-based video decoders.\n\n"
" --use_vd_vda use the new VD-based video decoders with a wrapper"
" that translates to the VDA interface, used to test"
" interaction with older components expecting the VDA"
" interface.\n"
" --output_frames write the selected video frames to disk, possible\n" " --output_frames write the selected video frames to disk, possible\n"
" values are \"all|corrupt\".\n" " values are \"all|corrupt\".\n"
" --output_format set the format of frames saved to disk, supported\n" " --output_format set the format of frames saved to disk, supported\n"
...@@ -104,8 +108,7 @@ class VideoDecoderTest : public ::testing::Test { ...@@ -104,8 +108,7 @@ class VideoDecoderTest : public ::testing::Test {
video->FrameChecksums(), PIXEL_FORMAT_I420, std::move(frame_writer))); video->FrameChecksums(), PIXEL_FORMAT_I420, std::move(frame_writer)));
} }
// Use the new VD-based video decoders if requested. config.implementation = g_env->GetDecoderImplementation();
config.use_vd = g_env->UseVD();
auto video_player = VideoPlayer::Create( auto video_player = VideoPlayer::Create(
config, g_env->GetGpuMemoryBufferFactory(), std::move(frame_renderer), config, g_env->GetGpuMemoryBufferFactory(), std::move(frame_renderer),
...@@ -324,8 +327,10 @@ TEST_F(VideoDecoderTest, FlushAtEndOfStream_RenderThumbnails) { ...@@ -324,8 +327,10 @@ TEST_F(VideoDecoderTest, FlushAtEndOfStream_RenderThumbnails) {
// specified as the new video decoders only support import mode. // specified as the new video decoders only support import mode.
// TODO(dstaessens): Deprecate after switching to new VD-based video decoders. // TODO(dstaessens): Deprecate after switching to new VD-based video decoders.
TEST_F(VideoDecoderTest, FlushAtEndOfStream_Allocate) { TEST_F(VideoDecoderTest, FlushAtEndOfStream_Allocate) {
if (!g_env->ImportSupported() || g_env->UseVD()) if (!g_env->ImportSupported() ||
g_env->GetDecoderImplementation() != DecoderImplementation::kVDA) {
GTEST_SKIP(); GTEST_SKIP();
}
VideoDecoderClientConfig config; VideoDecoderClientConfig config;
config.allocation_mode = AllocationMode::kAllocate; config.allocation_mode = AllocationMode::kAllocate;
...@@ -352,7 +357,7 @@ TEST_F(VideoDecoderTest, Initialize) { ...@@ -352,7 +357,7 @@ TEST_F(VideoDecoderTest, Initialize) {
// the media::VideoDecoder interface, so the test will be skipped if --use_vd // the media::VideoDecoder interface, so the test will be skipped if --use_vd
// is not specified. // is not specified.
TEST_F(VideoDecoderTest, Reinitialize) { TEST_F(VideoDecoderTest, Reinitialize) {
if (!g_env->UseVD()) if (g_env->GetDecoderImplementation() != DecoderImplementation::kVD)
GTEST_SKIP(); GTEST_SKIP();
// Create and initialize the video decoder. // Create and initialize the video decoder.
...@@ -381,7 +386,7 @@ TEST_F(VideoDecoderTest, Reinitialize) { ...@@ -381,7 +386,7 @@ TEST_F(VideoDecoderTest, Reinitialize) {
// are triggered upon destroying. // are triggered upon destroying.
TEST_F(VideoDecoderTest, DestroyBeforeInitialize) { TEST_F(VideoDecoderTest, DestroyBeforeInitialize) {
VideoDecoderClientConfig config = VideoDecoderClientConfig(); VideoDecoderClientConfig config = VideoDecoderClientConfig();
config.use_vd = g_env->UseVD(); config.implementation = g_env->GetDecoderImplementation();
auto tvp = VideoPlayer::Create(config, g_env->GetGpuMemoryBufferFactory(), auto tvp = VideoPlayer::Create(config, g_env->GetGpuMemoryBufferFactory(),
FrameRendererDummy::Create()); FrameRendererDummy::Create());
EXPECT_NE(tvp, nullptr); EXPECT_NE(tvp, nullptr);
...@@ -416,6 +421,9 @@ int main(int argc, char** argv) { ...@@ -416,6 +421,9 @@ int main(int argc, char** argv) {
media::test::FrameOutputConfig frame_output_config; media::test::FrameOutputConfig frame_output_config;
base::FilePath::StringType output_folder = base::FilePath::kCurrentDirectory; base::FilePath::StringType output_folder = base::FilePath::kCurrentDirectory;
bool use_vd = false; bool use_vd = false;
bool use_vd_vda = false;
media::test::DecoderImplementation implementation =
media::test::DecoderImplementation::kVDA;
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) { it != switches.end(); ++it) {
...@@ -459,6 +467,10 @@ int main(int argc, char** argv) { ...@@ -459,6 +467,10 @@ int main(int argc, char** argv) {
output_folder = it->second; output_folder = it->second;
} else if (it->first == "use_vd") { } else if (it->first == "use_vd") {
use_vd = true; use_vd = true;
implementation = media::test::DecoderImplementation::kVD;
} else if (it->first == "use_vd_vda") {
use_vd_vda = true;
implementation = media::test::DecoderImplementation::kVDVDA;
} else { } else {
std::cout << "unknown option: --" << it->first << "\n" std::cout << "unknown option: --" << it->first << "\n"
<< media::test::usage_msg; << media::test::usage_msg;
...@@ -466,12 +478,18 @@ int main(int argc, char** argv) { ...@@ -466,12 +478,18 @@ int main(int argc, char** argv) {
} }
} }
if (use_vd && use_vd_vda) {
std::cout << "--use_vd and --use_vd_vda cannot be enabled together.\n"
<< media::test::usage_msg;
return EXIT_FAILURE;
}
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, 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, use_vd, video_path, video_metadata_path, enable_validator, implementation,
base::FilePath(output_folder), frame_output_config); base::FilePath(output_folder), frame_output_config);
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