Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Unified Diff: content/common/gpu/media/video_encode_accelerator_unittest.cc

Issue 760963003: Adds fake hardware video encoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed broken unittest Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/video_encode_accelerator_unittest.cc
diff --git a/content/common/gpu/media/video_encode_accelerator_unittest.cc b/content/common/gpu/media/video_encode_accelerator_unittest.cc
index e56b03b666b9ef84b73644185ab12e81e81e48e0..63f10c1f8436c77a0587b25ec76547b81dab94ac 100644
--- a/content/common/gpu/media/video_encode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_encode_accelerator_unittest.cc
@@ -20,6 +20,7 @@
#include "media/base/bitstream_buffer.h"
#include "media/base/test_data_util.h"
#include "media/filters/h264_parser.h"
+#include "media/video/fake_video_encode_accelerator.h"
#include "media/video/video_encode_accelerator.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -101,6 +102,11 @@ const unsigned int kMinFramesForBitrateTests = 300;
// Bitrate is only forced for tests that test bitrate.
const char* g_default_in_filename = "bear_320x192_40frames.yuv";
const char* g_default_in_parameters = ":320:192:1:out.h264:200000";
+
+// Enabled by including a --fake_encoder flag to the command line invoking the
+// test.
+bool g_fake_encoder = false;
+
// Environment to store test stream data for all test cases.
class VideoEncodeAcceleratorTestEnvironment;
VideoEncodeAcceleratorTestEnvironment* g_env;
@@ -488,7 +494,9 @@ scoped_ptr<StreamValidator> StreamValidator::Create(
const FrameFoundCallback& frame_cb) {
scoped_ptr<StreamValidator> validator;
- if (IsH264(profile)) {
+ if (g_fake_encoder) {
+ validator.reset(NULL);
+ } else if (IsH264(profile)) {
validator.reset(new H264Validator(frame_cb));
} else if (IsVP8(profile)) {
validator.reset(new VP8Validator(frame_cb));
@@ -529,6 +537,7 @@ class VEAClient : public VideoEncodeAccelerator::Client {
private:
bool has_encoder() { return encoder_.get(); }
+ scoped_ptr<media::VideoEncodeAccelerator> CreateFakeVEA();
scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA();
scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA();
@@ -716,7 +725,8 @@ VEAClient::VEAClient(TestStream* test_stream,
test_stream_->requested_profile,
base::Bind(&VEAClient::HandleEncodedFrame, base::Unretained(this)));
- CHECK(validator_.get());
+
+ CHECK(g_fake_encoder || validator_.get());
if (save_to_file_) {
CHECK(!test_stream_->out_filename.empty());
@@ -734,6 +744,17 @@ VEAClient::VEAClient(TestStream* test_stream,
VEAClient::~VEAClient() { CHECK(!has_encoder()); }
+scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateFakeVEA() {
+ scoped_ptr<media::VideoEncodeAccelerator> encoder;
+ if (g_fake_encoder) {
+ encoder.reset(
+ new media::FakeVideoEncodeAccelerator(
+ scoped_refptr<base::SingleThreadTaskRunner>(
+ base::MessageLoopProxy::current())));
+ }
+ return encoder.Pass();
+}
+
scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateV4L2VEA() {
scoped_ptr<media::VideoEncodeAccelerator> encoder;
#if defined(OS_CHROMEOS) && (defined(ARCH_CPU_ARMEL) || \
@@ -758,6 +779,7 @@ void VEAClient::CreateEncoder() {
CHECK(!has_encoder());
scoped_ptr<media::VideoEncodeAccelerator> encoders[] = {
+ CreateFakeVEA(),
CreateV4L2VEA(),
CreateVaapiVEA()
};
@@ -911,7 +933,11 @@ void VEAClient::BitstreamBufferReady(int32 bitstream_buffer_id,
const uint8* stream_ptr = static_cast<const uint8*>(shm->memory());
if (payload_size > 0) {
- validator_->ProcessStreamBuffer(stream_ptr, payload_size);
+ if (validator_) {
+ validator_->ProcessStreamBuffer(stream_ptr, payload_size);
+ } else {
+ HandleEncodedFrame(key_frame);
+ }
if (save_to_file_) {
if (IsVP8(test_stream_->requested_profile))
@@ -1352,6 +1378,9 @@ int main(int argc, char** argv) {
if (it->first == "num_frames_to_encode") {
std::string input(it->second.begin(), it->second.end());
CHECK(base::StringToInt(input, &content::g_num_frames_to_encode));
+ }
+ if (it->first == "fake_encoder") {
+ content::g_fake_encoder = true;
continue;
}
if (it->first == "run_at_fps") {
« no previous file with comments | « no previous file | media/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698