| Index: media/gpu/video_encode_accelerator_unittest.cc
|
| diff --git a/media/gpu/video_encode_accelerator_unittest.cc b/media/gpu/video_encode_accelerator_unittest.cc
|
| index 528b24f8d6834570c270de0dd2c7dc51e2af6e1a..ff6ddcdacbbc88a27e9d48b75c5226ac937db86c 100644
|
| --- a/media/gpu/video_encode_accelerator_unittest.cc
|
| +++ b/media/gpu/video_encode_accelerator_unittest.cc
|
| @@ -25,6 +25,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_split.h"
|
| #include "base/strings/stringprintf.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/thread.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "base/time/time.h"
|
| @@ -59,6 +60,8 @@
|
| #endif // defined(ARCH_CPU_X86_FAMILY)
|
| #elif defined(OS_MACOSX)
|
| #include "media/gpu/vt_video_encode_accelerator_mac.h"
|
| +#elif defined(OS_WIN)
|
| +#include "media/gpu/media_foundation_video_encode_accelerator_win.h"
|
| #else
|
| #error The VideoEncodeAcceleratorUnittest is not supported on this platform.
|
| #endif
|
| @@ -175,6 +178,7 @@ struct TestStream {
|
| std::vector<size_t> aligned_plane_size;
|
|
|
| std::string out_filename;
|
| +
|
| VideoCodecProfile requested_profile;
|
| unsigned int requested_bitrate;
|
| unsigned int requested_framerate;
|
| @@ -257,7 +261,11 @@ static void CreateAlignedInputStreamFile(const gfx::Size& coded_size,
|
| padding_sizes[i] = padding_rows * coded_bpl[i] + Align64Bytes(size) - size;
|
| }
|
|
|
| +#if defined(OS_POSIX)
|
| base::FilePath src_file(test_stream->in_filename);
|
| +#elif defined(OS_WIN)
|
| + base::FilePath src_file(base::UTF8ToWide(test_stream->in_filename));
|
| +#endif
|
| int64_t src_file_size = 0;
|
| LOG_ASSERT(base::GetFileSize(src_file, &src_file_size));
|
|
|
| @@ -323,7 +331,11 @@ static void ParseAndReadTestStreamData(const base::FilePath::StringType& data,
|
| LOG_ASSERT(fields.size() <= 9U) << data;
|
| TestStream* test_stream = new TestStream();
|
|
|
| - test_stream->in_filename = fields[0];
|
| +#if defined(OS_POSIX)
|
| + test_stream->in_filename = fields[0];
|
| +#elif defined(OS_WIN)
|
| + test_stream->in_filename = base::WideToUTF8(fields[0]);
|
| +#endif
|
| int width, height;
|
| bool result = base::StringToInt(fields[1], &width);
|
| LOG_ASSERT(result);
|
| @@ -338,8 +350,13 @@ static void ParseAndReadTestStreamData(const base::FilePath::StringType& data,
|
| LOG_ASSERT(profile <= VIDEO_CODEC_PROFILE_MAX);
|
| test_stream->requested_profile = static_cast<VideoCodecProfile>(profile);
|
|
|
| - if (fields.size() >= 5 && !fields[4].empty())
|
| + if (fields.size() >= 5 && !fields[4].empty()) {
|
| +#if defined(OS_POSIX)
|
| test_stream->out_filename = fields[4];
|
| +#elif defined(OS_WIN)
|
| + test_stream->out_filename = base::WideToUTF8(fields[4]);
|
| +#endif
|
| + }
|
|
|
| if (fields.size() >= 6 && !fields[5].empty())
|
| LOG_ASSERT(
|
| @@ -602,7 +619,7 @@ class VideoFrameQualityValidator {
|
| void VerifyOutputFrame(const scoped_refptr<VideoFrame>& output_frame);
|
| void Decode();
|
|
|
| - enum State { UNINITIALIZED, INITIALIZED, DECODING, ERROR };
|
| + enum State { UNINITIALIZED, INITIALIZED, DECODING, DECODER_ERROR };
|
|
|
| const VideoCodecProfile profile_;
|
| std::unique_ptr<FFmpegVideoDecoder> decoder_;
|
| @@ -665,7 +682,7 @@ void VideoFrameQualityValidator::InitializeCB(bool success) {
|
| decoder_state_ = INITIALIZED;
|
| Decode();
|
| } else {
|
| - decoder_state_ = ERROR;
|
| + decoder_state_ = DECODER_ERROR;
|
| if (IsH264(profile_))
|
| LOG(ERROR) << "Chromium does not support H264 decode. Try Chrome.";
|
| FAIL() << "Decoder initialization error";
|
| @@ -683,7 +700,7 @@ void VideoFrameQualityValidator::DecodeDone(DecodeStatus status) {
|
| decoder_state_ = INITIALIZED;
|
| Decode();
|
| } else {
|
| - decoder_state_ = ERROR;
|
| + decoder_state_ = DECODER_ERROR;
|
| FAIL() << "Unexpected decode status = " << status << ". Stop decoding.";
|
| decode_error_cb_.Run();
|
| }
|
| @@ -694,7 +711,7 @@ void VideoFrameQualityValidator::FlushDone(DecodeStatus status) {
|
| }
|
|
|
| void VideoFrameQualityValidator::Flush() {
|
| - if (decoder_state_ != ERROR) {
|
| + if (decoder_state_ != DECODER_ERROR) {
|
| decode_buffers_.push(DecoderBuffer::CreateEOSBuffer());
|
| Decode();
|
| }
|
| @@ -702,7 +719,7 @@ void VideoFrameQualityValidator::Flush() {
|
|
|
| void VideoFrameQualityValidator::AddDecodeBuffer(
|
| const scoped_refptr<DecoderBuffer>& buffer) {
|
| - if (decoder_state_ != ERROR) {
|
| + if (decoder_state_ != DECODER_ERROR) {
|
| decode_buffers_.push(buffer);
|
| Decode();
|
| }
|
| @@ -784,6 +801,7 @@ class VEAClient : public VideoEncodeAccelerator::Client {
|
| std::unique_ptr<VideoEncodeAccelerator> CreateV4L2VEA();
|
| std::unique_ptr<VideoEncodeAccelerator> CreateVaapiVEA();
|
| std::unique_ptr<VideoEncodeAccelerator> CreateVTVEA();
|
| + std::unique_ptr<VideoEncodeAccelerator> CreateMFVEA();
|
|
|
| void SetState(ClientState new_state);
|
|
|
| @@ -1002,7 +1020,12 @@ VEAClient::VEAClient(TestStream* test_stream,
|
|
|
| if (save_to_file_) {
|
| LOG_ASSERT(!test_stream_->out_filename.empty());
|
| +#if defined(OS_POSIX)
|
| base::FilePath out_filename(test_stream_->out_filename);
|
| +#elif defined(OS_WIN)
|
| + base::FilePath out_filename(
|
| + base::UTF8ToWide(test_stream_->out_filename));
|
| +#endif
|
| // This creates or truncates out_filename.
|
| // Without it, AppendToFile() will not work.
|
| EXPECT_EQ(0, base::WriteFile(out_filename, NULL, 0));
|
| @@ -1055,12 +1078,21 @@ std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateVTVEA() {
|
| return encoder;
|
| }
|
|
|
| +std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateMFVEA() {
|
| + std::unique_ptr<VideoEncodeAccelerator> encoder;
|
| +#if defined(OS_WIN)
|
| + encoder.reset(new MediaFoundationVideoEncodeAccelerator());
|
| +#endif
|
| + return encoder;
|
| +}
|
| +
|
| void VEAClient::CreateEncoder() {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| LOG_ASSERT(!has_encoder());
|
|
|
| std::unique_ptr<VideoEncodeAccelerator> encoders[] = {
|
| - CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA()};
|
| + CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(),
|
| + CreateMFVEA()};
|
|
|
| DVLOG(1) << "Profile: " << test_stream_->requested_profile
|
| << ", initial bitrate: " << requested_bitrate_;
|
| @@ -1705,14 +1737,16 @@ int main(int argc, char** argv) {
|
| base::ShadowingAtExitManager at_exit_manager;
|
| base::MessageLoop main_loop;
|
|
|
| + base::FilePath test_data_filepath =
|
| + media::GetTestDataFilePath(media::g_default_in_filename);
|
| + base::AppendToFile(test_data_filepath, media::g_default_in_parameters,
|
| + strlen(media::g_default_in_parameters));
|
| std::unique_ptr<base::FilePath::StringType> test_stream_data(
|
| - new base::FilePath::StringType(
|
| - media::GetTestDataFilePath(media::g_default_in_filename).value() +
|
| - media::g_default_in_parameters));
|
| + new base::FilePath::StringType(test_data_filepath.value()));
|
|
|
| // Needed to enable DVLOG through --vmodule.
|
| logging::LoggingSettings settings;
|
| - settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
| + settings.logging_dest = logging::LOG_DEFAULT;
|
| LOG_ASSERT(logging::InitLogging(settings));
|
|
|
| const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
|
|
|