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

Unified Diff: ppapi/tests/test_video_encoder.cc

Issue 1132833002: pepper: add software vp9 encoder support to PPB_VideoEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Additional comments Created 5 years, 4 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 | « ppapi/tests/test_video_encoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_video_encoder.cc
diff --git a/ppapi/tests/test_video_encoder.cc b/ppapi/tests/test_video_encoder.cc
index b4907cc9773ec535b5a974e3f0ffd8142e6e908f..4b2abf2a7764915f3bfaddae6e8ebb5237e9cd5f 100644
--- a/ppapi/tests/test_video_encoder.cc
+++ b/ppapi/tests/test_video_encoder.cc
@@ -18,89 +18,98 @@ bool TestVideoEncoder::Init() {
}
void TestVideoEncoder::RunTests(const std::string& filter) {
- RUN_CALLBACK_TEST(TestVideoEncoder, Create, filter);
+ RUN_CALLBACK_TEST(TestVideoEncoder, AvailableCodecs, filter);
+ RUN_CALLBACK_TEST(TestVideoEncoder, IncorrectSizeFails, filter);
+ RUN_CALLBACK_TEST(TestVideoEncoder, InitializeVP8, filter);
+ RUN_CALLBACK_TEST(TestVideoEncoder, InitializeVP9, filter);
}
-std::string TestVideoEncoder::TestCreate() {
+std::string TestVideoEncoder::TestAvailableCodecs() {
// Test that we get results for supported formats. We should at
// least get the software supported formats.
- {
- pp::VideoEncoder video_encoder(instance_);
- ASSERT_FALSE(video_encoder.is_null());
-
- TestCompletionCallbackWithOutput<std::vector<PP_VideoProfileDescription> >
- callback(instance_->pp_instance(), false);
- callback.WaitForResult(
- video_encoder.GetSupportedProfiles(callback.GetCallback()));
-
- ASSERT_GE(callback.result(), 1U);
-
- const std::vector<PP_VideoProfileDescription> video_profiles =
- callback.output();
- ASSERT_GE(video_profiles.size(), 1U);
-
- bool found_vp8 = false;
- for (uint32_t i = 0; i < video_profiles.size(); ++i) {
- const PP_VideoProfileDescription& description = video_profiles[i];
- if (description.profile == PP_VIDEOPROFILE_VP8_ANY &&
- description.hardware_accelerated == PP_FALSE) {
- ASSERT_GE(description.max_framerate_numerator /
- description.max_framerate_denominator,
- 30U);
+ pp::VideoEncoder video_encoder(instance_);
+ ASSERT_FALSE(video_encoder.is_null());
+
+ TestCompletionCallbackWithOutput<std::vector<PP_VideoProfileDescription> >
+ callback(instance_->pp_instance(), false);
+ callback.WaitForResult(
+ video_encoder.GetSupportedProfiles(callback.GetCallback()));
+
+ ASSERT_GE(callback.result(), 1U);
+
+ const std::vector<PP_VideoProfileDescription> video_profiles =
+ callback.output();
+ ASSERT_GE(video_profiles.size(), 1U);
+
+ bool found_vp8 = false, found_vp9 = false;
+ for (uint32_t i = 0; i < video_profiles.size(); ++i) {
+ const PP_VideoProfileDescription& description = video_profiles[i];
+ if (description.hardware_accelerated == PP_FALSE) {
+ ASSERT_GE(description.max_framerate_numerator /
+ description.max_framerate_denominator,
+ 30U);
+ if (description.profile == PP_VIDEOPROFILE_VP8_ANY)
found_vp8 = true;
- }
+ else if (description.profile == PP_VIDEOPROFILE_VP9_ANY)
+ found_vp9 = true;
}
- ASSERT_TRUE(found_vp8);
}
+ ASSERT_TRUE(found_vp8);
+ ASSERT_TRUE(found_vp9);
+
+ PASS();
+}
+
+std::string TestVideoEncoder::TestIncorrectSizeFails() {
// Test that initializing the encoder with incorrect size fails.
- {
- pp::VideoEncoder video_encoder(instance_);
- ASSERT_FALSE(video_encoder.is_null());
- pp::Size video_size(0, 0);
-
- TestCompletionCallback callback(instance_->pp_instance(), false);
- callback.WaitForResult(
- video_encoder.Initialize(PP_VIDEOFRAME_FORMAT_I420,
- video_size,
- PP_VIDEOPROFILE_VP8_ANY,
- 1000000,
- PP_HARDWAREACCELERATION_WITHFALLBACK,
- callback.GetCallback()));
-
- ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
- }
- // Test that initializing the encoder with software VP8 succeeds.
- {
- pp::VideoEncoder video_encoder(instance_);
- ASSERT_FALSE(video_encoder.is_null());
- pp::Size video_size(640, 480);
-
- TestCompletionCallback callback(instance_->pp_instance(), false);
- callback.WaitForResult(
- video_encoder.Initialize(PP_VIDEOFRAME_FORMAT_I420,
- video_size,
- PP_VIDEOPROFILE_VP8_ANY,
- 1000000,
- PP_HARDWAREACCELERATION_WITHFALLBACK,
- callback.GetCallback()));
-
- ASSERT_EQ(PP_OK, callback.result());
-
- pp::Size coded_size;
- ASSERT_EQ(PP_OK, video_encoder.GetFrameCodedSize(&coded_size));
- ASSERT_GE(coded_size.GetArea(), video_size.GetArea());
- ASSERT_GE(video_encoder.GetFramesRequired(), 1);
-
- TestCompletionCallbackWithOutput<pp::VideoFrame> get_video_frame(
- instance_->pp_instance(), false);
- get_video_frame.WaitForResult(
- video_encoder.GetVideoFrame(get_video_frame.GetCallback()));
- ASSERT_EQ(PP_OK, get_video_frame.result());
-
- pp::Size video_frame_size;
- ASSERT_TRUE(get_video_frame.output().GetSize(&video_frame_size));
- ASSERT_EQ(coded_size.GetArea(), video_frame_size.GetArea());
- }
+ pp::VideoEncoder video_encoder(instance_);
+ ASSERT_FALSE(video_encoder.is_null());
+ pp::Size video_size(0, 0);
+
+ TestCompletionCallback callback(instance_->pp_instance(), false);
+ callback.WaitForResult(video_encoder.Initialize(
+ PP_VIDEOFRAME_FORMAT_I420, video_size, PP_VIDEOPROFILE_VP8_ANY, 1000000,
+ PP_HARDWAREACCELERATION_WITHFALLBACK, callback.GetCallback()));
+
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
+
+ PASS();
+}
+
+std::string TestVideoEncoder::TestInitializeVP8() {
+ return TestInitializeCodec(PP_VIDEOPROFILE_VP8_ANY);
+}
+
+std::string TestVideoEncoder::TestInitializeVP9() {
+ return TestInitializeCodec(PP_VIDEOPROFILE_VP9_ANY);
+}
+
+std::string TestVideoEncoder::TestInitializeCodec(PP_VideoProfile profile) {
+ pp::VideoEncoder video_encoder(instance_);
+ ASSERT_FALSE(video_encoder.is_null());
+ pp::Size video_size(640, 480);
+
+ TestCompletionCallback callback(instance_->pp_instance(), false);
+ callback.WaitForResult(video_encoder.Initialize(
+ PP_VIDEOFRAME_FORMAT_I420, video_size, profile, 1000000,
+ PP_HARDWAREACCELERATION_WITHFALLBACK, callback.GetCallback()));
+
+ ASSERT_EQ(PP_OK, callback.result());
+
+ pp::Size coded_size;
+ ASSERT_EQ(PP_OK, video_encoder.GetFrameCodedSize(&coded_size));
+ ASSERT_GE(coded_size.GetArea(), video_size.GetArea());
+ ASSERT_GE(video_encoder.GetFramesRequired(), 1);
+
+ TestCompletionCallbackWithOutput<pp::VideoFrame> get_video_frame(
+ instance_->pp_instance(), false);
+ get_video_frame.WaitForResult(
+ video_encoder.GetVideoFrame(get_video_frame.GetCallback()));
+ ASSERT_EQ(PP_OK, get_video_frame.result());
+
+ pp::Size video_frame_size;
+ ASSERT_TRUE(get_video_frame.output().GetSize(&video_frame_size));
+ ASSERT_EQ(coded_size.GetArea(), video_frame_size.GetArea());
PASS();
}
« no previous file with comments | « ppapi/tests/test_video_encoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698