| Index: media/gpu/video_encode_accelerator_unittest.cc
|
| diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/media/gpu/video_encode_accelerator_unittest.cc
|
| similarity index 95%
|
| rename from content/common/gpu/media/video_encode_accelerator_unittest.cc
|
| rename to media/gpu/video_encode_accelerator_unittest.cc
|
| index 3f3f9ef66d0a709804ed0c7a54fb885cf1dccd96..0cfbfaaee3f657974a7ecbb8ea9dbcd367ee821b 100644
|
| --- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
|
| +++ b/media/gpu/video_encode_accelerator_unittest.cc
|
| @@ -30,7 +30,6 @@
|
| #include "base/time/time.h"
|
| #include "base/timer/timer.h"
|
| #include "build/build_config.h"
|
| -#include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
|
| #include "media/base/bind_to_current_loop.h"
|
| #include "media/base/bitstream_buffer.h"
|
| #include "media/base/cdm_context.h"
|
| @@ -43,29 +42,30 @@
|
| #include "media/filters/ffmpeg_video_decoder.h"
|
| #include "media/filters/h264_parser.h"
|
| #include "media/filters/ivf_parser.h"
|
| +#include "media/gpu/video_accelerator_unittest_helpers.h"
|
| #include "media/video/fake_video_encode_accelerator.h"
|
| #include "media/video/video_encode_accelerator.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| #if defined(ARCH_CPU_ARMEL) || (defined(USE_OZONE) && defined(USE_V4L2_CODEC))
|
| -#include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
|
| +#include "media/gpu/v4l2_video_encode_accelerator.h"
|
| #endif
|
| #if defined(ARCH_CPU_X86_FAMILY)
|
| -#include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
|
| -#include "content/common/gpu/media/vaapi_wrapper.h"
|
| +#include "media/gpu/vaapi_video_encode_accelerator.h"
|
| +#include "media/gpu/vaapi_wrapper.h"
|
| // Status has been defined as int in Xlib.h.
|
| #undef Status
|
| #endif // defined(ARCH_CPU_X86_FAMILY)
|
| #elif defined(OS_MACOSX)
|
| -#include "content/common/gpu/media/vt_video_encode_accelerator_mac.h"
|
| +#include "media/gpu/vt_video_encode_accelerator_mac.h"
|
| #else
|
| #error The VideoEncodeAcceleratorUnittest is not supported on this platform.
|
| #endif
|
|
|
| using media::VideoEncodeAccelerator;
|
|
|
| -namespace content {
|
| +namespace media {
|
| namespace {
|
|
|
| const media::VideoPixelFormat kInputFormat = media::PIXEL_FORMAT_I420;
|
| @@ -329,7 +329,8 @@ static void CreateAlignedInputStreamFile(const gfx::Size& coded_size,
|
| << "File should be mapped at a 64 byte boundary";
|
|
|
| LOG_ASSERT(test_stream->mapped_aligned_in_file.length() %
|
| - test_stream->aligned_buffer_size == 0U)
|
| + test_stream->aligned_buffer_size ==
|
| + 0U)
|
| << "Stream byte size is not a product of calculated frame byte size";
|
| LOG_ASSERT(test_stream->num_frames > 0UL);
|
| }
|
| @@ -339,9 +340,9 @@ static void CreateAlignedInputStreamFile(const gfx::Size& coded_size,
|
| static void ParseAndReadTestStreamData(const base::FilePath::StringType& data,
|
| ScopedVector<TestStream>* test_streams) {
|
| // Split the string to individual test stream data.
|
| - std::vector<base::FilePath::StringType> test_streams_data = base::SplitString(
|
| - data, base::FilePath::StringType(1, ';'),
|
| - base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| + std::vector<base::FilePath::StringType> test_streams_data =
|
| + base::SplitString(data, base::FilePath::StringType(1, ';'),
|
| + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
| LOG_ASSERT(test_streams_data.size() >= 1U) << data;
|
|
|
| // Parse each test stream data and read the input file.
|
| @@ -373,21 +374,21 @@ static void ParseAndReadTestStreamData(const base::FilePath::StringType& data,
|
| test_stream->out_filename = fields[4];
|
|
|
| if (fields.size() >= 6 && !fields[5].empty())
|
| - LOG_ASSERT(base::StringToUint(fields[5],
|
| - &test_stream->requested_bitrate));
|
| + LOG_ASSERT(
|
| + base::StringToUint(fields[5], &test_stream->requested_bitrate));
|
|
|
| if (fields.size() >= 7 && !fields[6].empty())
|
| - LOG_ASSERT(base::StringToUint(fields[6],
|
| - &test_stream->requested_framerate));
|
| + LOG_ASSERT(
|
| + base::StringToUint(fields[6], &test_stream->requested_framerate));
|
|
|
| if (fields.size() >= 8 && !fields[7].empty()) {
|
| - LOG_ASSERT(base::StringToUint(fields[7],
|
| - &test_stream->requested_subsequent_bitrate));
|
| + LOG_ASSERT(base::StringToUint(
|
| + fields[7], &test_stream->requested_subsequent_bitrate));
|
| }
|
|
|
| if (fields.size() >= 9 && !fields[8].empty()) {
|
| - LOG_ASSERT(base::StringToUint(fields[8],
|
| - &test_stream->requested_subsequent_framerate));
|
| + LOG_ASSERT(base::StringToUint(
|
| + fields[8], &test_stream->requested_subsequent_framerate));
|
| }
|
| test_streams->push_back(test_stream);
|
| }
|
| @@ -546,7 +547,7 @@ void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) {
|
| ASSERT_TRUE(seen_pps_);
|
| seen_idr_ = true;
|
| keyframe = true;
|
| - // fallthrough
|
| + // fallthrough
|
| case media::H264NALU::kNonIDRSlice: {
|
| ASSERT_TRUE(seen_idr_);
|
| if (!frame_cb_.Run(keyframe))
|
| @@ -578,8 +579,7 @@ void H264Validator::ProcessStreamBuffer(const uint8_t* stream, size_t size) {
|
| class VP8Validator : public StreamValidator {
|
| public:
|
| explicit VP8Validator(const FrameFoundCallback& frame_cb)
|
| - : StreamValidator(frame_cb),
|
| - seen_keyframe_(false) {}
|
| + : StreamValidator(frame_cb), seen_keyframe_(false) {}
|
|
|
| void ProcessStreamBuffer(const uint8_t* stream, size_t size) override;
|
|
|
| @@ -1051,7 +1051,9 @@ VEAClient::VEAClient(TestStream* test_stream,
|
| thread_checker_.DetachFromThread();
|
| }
|
|
|
| -VEAClient::~VEAClient() { LOG_ASSERT(!has_encoder()); }
|
| +VEAClient::~VEAClient() {
|
| + LOG_ASSERT(!has_encoder());
|
| +}
|
|
|
| std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateFakeVEA() {
|
| std::unique_ptr<media::VideoEncodeAccelerator> encoder;
|
| @@ -1066,7 +1068,7 @@ std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateFakeVEA() {
|
| std::unique_ptr<media::VideoEncodeAccelerator> VEAClient::CreateV4L2VEA() {
|
| std::unique_ptr<media::VideoEncodeAccelerator> encoder;
|
| #if defined(OS_CHROMEOS) && (defined(ARCH_CPU_ARMEL) || \
|
| - (defined(USE_OZONE) && defined(USE_V4L2_CODEC)))
|
| + (defined(USE_OZONE) && defined(USE_V4L2_CODEC)))
|
| scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
|
| if (device)
|
| encoder.reset(new V4L2VideoEncodeAccelerator(device));
|
| @@ -1105,11 +1107,9 @@ void VEAClient::CreateEncoder() {
|
| continue;
|
| encoder_ = std::move(encoders[i]);
|
| SetState(CS_ENCODER_SET);
|
| - if (encoder_->Initialize(kInputFormat,
|
| - test_stream_->visible_size,
|
| + if (encoder_->Initialize(kInputFormat, test_stream_->visible_size,
|
| test_stream_->requested_profile,
|
| - requested_bitrate_,
|
| - this)) {
|
| + requested_bitrate_, this)) {
|
| SetStreamParameters(requested_bitrate_, requested_framerate_);
|
| SetState(CS_INITIALIZED);
|
|
|
| @@ -1359,11 +1359,9 @@ scoped_refptr<media::VideoFrame> VEAClient::PrepareInputFrame(
|
|
|
| scoped_refptr<media::VideoFrame> frame = CreateFrame(position);
|
| EXPECT_TRUE(frame);
|
| - frame->AddDestructionObserver(
|
| - media::BindToCurrentLoop(
|
| - base::Bind(&VEAClient::InputNoLongerNeededCallback,
|
| - base::Unretained(this),
|
| - next_input_id_)));
|
| + frame->AddDestructionObserver(media::BindToCurrentLoop(
|
| + base::Bind(&VEAClient::InputNoLongerNeededCallback,
|
| + base::Unretained(this), next_input_id_)));
|
|
|
| LOG_ASSERT(inputs_at_client_.insert(next_input_id_).second);
|
|
|
| @@ -1431,10 +1429,11 @@ void VEAClient::FeedEncoderWithOutput(base::SharedMemory* shm) {
|
| base::SharedMemoryHandle dup_handle;
|
| LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle));
|
|
|
| - media::BitstreamBuffer bitstream_buffer(
|
| - next_output_buffer_id_++, dup_handle, output_buffer_size_);
|
| - LOG_ASSERT(output_buffers_at_client_.insert(
|
| - std::make_pair(bitstream_buffer.id(), shm)).second);
|
| + media::BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle,
|
| + output_buffer_size_);
|
| + LOG_ASSERT(output_buffers_at_client_
|
| + .insert(std::make_pair(bitstream_buffer.id(), shm))
|
| + .second);
|
| encoder_->UseOutputBitstreamBuffer(bitstream_buffer);
|
| }
|
|
|
| @@ -1528,23 +1527,22 @@ void VEAClient::VerifyStreamProperties() {
|
| unsigned int bitrate = encoded_stream_size_since_last_check_ * 8 *
|
| current_framerate_ / num_frames_since_last_check_;
|
| DVLOG(1) << "Current chunk's bitrate: " << bitrate
|
| - << " (expected: " << current_requested_bitrate_
|
| - << " @ " << current_framerate_ << " FPS,"
|
| + << " (expected: " << current_requested_bitrate_ << " @ "
|
| + << current_framerate_ << " FPS,"
|
| << " num frames in chunk: " << num_frames_since_last_check_;
|
|
|
| num_frames_since_last_check_ = 0;
|
| encoded_stream_size_since_last_check_ = 0;
|
|
|
| if (force_bitrate_) {
|
| - EXPECT_NEAR(bitrate,
|
| - current_requested_bitrate_,
|
| + EXPECT_NEAR(bitrate, current_requested_bitrate_,
|
| kBitrateTolerance * current_requested_bitrate_);
|
| }
|
|
|
| // All requested keyframes should've been provided. Allow the last requested
|
| // frame to remain undelivered if we haven't reached the maximum frame number
|
| // by which it should have arrived.
|
| - if (num_encoded_frames_ < next_keyframe_at_ + kMaxKeyframeDelay)
|
| + if (num_encoded_frames_ < next_keyframe_at_ + kMaxKeyframeDelay)
|
| EXPECT_LE(num_keyframes_requested_, 1UL);
|
| else
|
| EXPECT_EQ(num_keyframes_requested_, 0UL);
|
| @@ -1610,7 +1608,7 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
|
| const bool verify_output =
|
| base::get<7>(GetParam()) || g_env->verify_all_output();
|
|
|
| - ScopedVector<ClientStateNotification<ClientState> > notes;
|
| + ScopedVector<ClientStateNotification<ClientState>> notes;
|
| ScopedVector<VEAClient> clients;
|
| base::Thread encoder_thread("EncoderThread");
|
| ASSERT_TRUE(encoder_thread.Start());
|
| @@ -1633,9 +1631,8 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
|
| mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output));
|
|
|
| encoder_thread.message_loop()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&VEAClient::CreateEncoder,
|
| - base::Unretained(clients.back())));
|
| + FROM_HERE, base::Bind(&VEAClient::CreateEncoder,
|
| + base::Unretained(clients.back())));
|
| }
|
|
|
| // All encoders must pass through states in this order.
|
| @@ -1738,7 +1735,7 @@ INSTANTIATE_TEST_CASE_P(
|
| // - mid-stream encoder_->Destroy()
|
|
|
| } // namespace
|
| -} // namespace content
|
| +} // namespace media
|
|
|
| int main(int argc, char** argv) {
|
| testing::InitGoogleTest(&argc, argv); // Removes gtest-specific args.
|
| @@ -1749,8 +1746,8 @@ int main(int argc, char** argv) {
|
|
|
| std::unique_ptr<base::FilePath::StringType> test_stream_data(
|
| new base::FilePath::StringType(
|
| - media::GetTestDataFilePath(content::g_default_in_filename).value() +
|
| - content::g_default_in_parameters));
|
| + media::GetTestDataFilePath(media::g_default_in_filename).value() +
|
| + media::g_default_in_parameters));
|
|
|
| // Needed to enable DVLOG through --vmodule.
|
| logging::LoggingSettings settings;
|
| @@ -1767,8 +1764,7 @@ int main(int argc, char** argv) {
|
|
|
| base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
|
| for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
|
| - it != switches.end();
|
| - ++it) {
|
| + it != switches.end(); ++it) {
|
| if (it->first == "test_stream_data") {
|
| test_stream_data->assign(it->second.c_str());
|
| continue;
|
| @@ -1781,7 +1777,7 @@ int main(int argc, char** argv) {
|
| }
|
| if (it->first == "num_frames_to_encode") {
|
| std::string input(it->second.begin(), it->second.end());
|
| - LOG_ASSERT(base::StringToInt(input, &content::g_num_frames_to_encode));
|
| + LOG_ASSERT(base::StringToInt(input, &media::g_num_frames_to_encode));
|
| continue;
|
| }
|
| if (it->first == "measure_latency") {
|
| @@ -1789,7 +1785,7 @@ int main(int argc, char** argv) {
|
| continue;
|
| }
|
| if (it->first == "fake_encoder") {
|
| - content::g_fake_encoder = true;
|
| + media::g_fake_encoder = true;
|
| continue;
|
| }
|
| if (it->first == "run_at_fps") {
|
| @@ -1815,13 +1811,13 @@ int main(int argc, char** argv) {
|
| }
|
|
|
| #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
|
| - content::VaapiWrapper::PreSandboxInitialization();
|
| + media::VaapiWrapper::PreSandboxInitialization();
|
| #endif
|
|
|
| - content::g_env =
|
| - reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>(
|
| + media::g_env =
|
| + reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>(
|
| testing::AddGlobalTestEnvironment(
|
| - new content::VideoEncodeAcceleratorTestEnvironment(
|
| + new media::VideoEncodeAcceleratorTestEnvironment(
|
| std::move(test_stream_data), log_path, run_at_fps,
|
| needs_encode_latency, verify_all_output)));
|
|
|
|
|