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

Unified Diff: remoting/codec/video_encoder_vpx_unittest.cc

Issue 349223007: Add manual tests to benchmark VP8 & VP9 encode performance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 6 years, 6 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
« remoting/codec/codec_test.cc ('K') | « remoting/codec/codec_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/codec/video_encoder_vpx_unittest.cc
diff --git a/remoting/codec/video_encoder_vpx_unittest.cc b/remoting/codec/video_encoder_vpx_unittest.cc
index ccef34c1ec2c238f4b8a94db08febd607223c029..bf1cfebc5a36add0cb2cee5384294895bff1d067 100644
--- a/remoting/codec/video_encoder_vpx_unittest.cc
+++ b/remoting/codec/video_encoder_vpx_unittest.cc
@@ -7,12 +7,19 @@
#include <limits>
#include <vector>
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/codec/codec_test.h"
#include "remoting/proto/video.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
+using webrtc::BasicDesktopFrame;
+using webrtc::DesktopFrame;
+using webrtc::DesktopRect;
+using webrtc::DesktopSize;
+using webrtc::DesktopVector;
+
namespace remoting {
// xRGB pixel colors for use by tests.
@@ -21,14 +28,14 @@ const uint32 kGreenColor = 0x00ff00;
// Creates a frame stippled between blue and red pixels, which is useful for
// lossy/lossless encode and color tests.
-static scoped_ptr<webrtc::DesktopFrame> CreateTestFrame(
- const webrtc::DesktopSize& frame_size) {
- scoped_ptr<webrtc::DesktopFrame> frame(
- new webrtc::BasicDesktopFrame(frame_size));
+static scoped_ptr<DesktopFrame> CreateTestFrame(
+ const DesktopSize& frame_size) {
+ scoped_ptr<DesktopFrame> frame(
+ new BasicDesktopFrame(frame_size));
for (int x = 0; x < frame_size.width(); ++x) {
for (int y = 0; y < frame_size.height(); ++y) {
uint8* pixel_u8 = frame->data() + (y * frame->stride()) +
- (x * webrtc::DesktopFrame::kBytesPerPixel);
+ (x * DesktopFrame::kBytesPerPixel);
*(reinterpret_cast<uint32*>(pixel_u8)) =
((x + y) & 1) ? kGreenColor : kBlueColor;
}
@@ -51,10 +58,9 @@ TEST(VideoEncoderVpxTest, TestVp9VideoEncoder) {
TEST(VideoEncoderVpxTest, TestVp9VideoEncoderLossyEncode) {
scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP9());
- webrtc::DesktopSize frame_size(1024, 768);
- scoped_ptr<webrtc::DesktopFrame> frame(CreateTestFrame(frame_size));
- frame->mutable_updated_region()->SetRect(
- webrtc::DesktopRect::MakeSize(frame_size));
+ DesktopSize frame_size(1024, 768);
+ scoped_ptr<DesktopFrame> frame(CreateTestFrame(frame_size));
+ frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(frame_size));
// Lossy encode the first frame.
encoder->SetLosslessEncode(false);
@@ -75,10 +81,9 @@ TEST(VideoEncoderVpxTest, TestVp9VideoEncoderLossyEncode) {
TEST(VideoEncoderVpxTest, TestVp9VideoEncoderLossyColor) {
scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP9());
- webrtc::DesktopSize frame_size(1024, 768);
- scoped_ptr<webrtc::DesktopFrame> frame(CreateTestFrame(frame_size));
- frame->mutable_updated_region()->SetRect(
- webrtc::DesktopRect::MakeSize(frame_size));
+ DesktopSize frame_size(1024, 768);
+ scoped_ptr<DesktopFrame> frame(CreateTestFrame(frame_size));
+ frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(frame_size));
// Lossy encode the first frame.
encoder->SetLosslessColor(false);
@@ -99,10 +104,9 @@ TEST(VideoEncoderVpxTest, TestVp9VideoEncoderLossyColor) {
TEST(VideoEncoderVpxTest, TestVp8VideoEncoderIgnoreLossy) {
scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
- webrtc::DesktopSize frame_size(1024, 768);
- scoped_ptr<webrtc::DesktopFrame> frame(CreateTestFrame(frame_size));
- frame->mutable_updated_region()->SetRect(
- webrtc::DesktopRect::MakeSize(frame_size));
+ DesktopSize frame_size(1024, 768);
+ scoped_ptr<DesktopFrame> frame(CreateTestFrame(frame_size));
+ frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(frame_size));
// Encode a frame, to give the encoder a chance to crash if misconfigured.
encoder->SetLosslessEncode(true);
@@ -114,22 +118,20 @@ TEST(VideoEncoderVpxTest, TestVp8VideoEncoderIgnoreLossy) {
// Test that calling Encode with a differently-sized media::ScreenCaptureData
// does not leak memory.
TEST(VideoEncoderVpxTest, TestSizeChangeNoLeak) {
- webrtc::DesktopSize frame_size(1000, 1000);
+ DesktopSize frame_size(1000, 1000);
scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
// Create first frame & encode it.
- scoped_ptr<webrtc::DesktopFrame> frame(CreateTestFrame(frame_size));
- frame->mutable_updated_region()->SetRect(
- webrtc::DesktopRect::MakeSize(frame_size));
+ scoped_ptr<DesktopFrame> frame(CreateTestFrame(frame_size));
+ frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(frame_size));
scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
EXPECT_TRUE(packet);
// Halve the size of the frame, and updated region, and encode again.
frame_size.set(frame_size.width(), frame_size.height() / 2);
frame = CreateTestFrame(frame_size);
- frame->mutable_updated_region()->SetRect(
- webrtc::DesktopRect::MakeSize(frame_size));
+ frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(frame_size));
packet = encoder->Encode(*frame);
EXPECT_TRUE(packet);
}
@@ -137,15 +139,56 @@ TEST(VideoEncoderVpxTest, TestSizeChangeNoLeak) {
// Test that the DPI information is correctly propagated from the
// media::ScreenCaptureData to the VideoPacket.
TEST(VideoEncoderVpxTest, TestDpiPropagation) {
- webrtc::DesktopSize frame_size(32, 32);
+ DesktopSize frame_size(32, 32);
scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
- scoped_ptr<webrtc::DesktopFrame> frame(CreateTestFrame(frame_size));
- frame->set_dpi(webrtc::DesktopVector(96, 97));
+ scoped_ptr<DesktopFrame> frame(CreateTestFrame(frame_size));
+ frame->set_dpi(DesktopVector(96, 97));
scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
EXPECT_EQ(packet->format().x_dpi(), 96);
EXPECT_EQ(packet->format().y_dpi(), 97);
}
+// Measure the performance of the VP8 encoder.
+TEST(VideoEncoderVpxTest, MANUAL_MeasureVp8Fps) {
+ scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8());
+
+ const DesktopSize kFrameSizes[] = {
+ DesktopSize(1280, 1024), DesktopSize(1920, 1200)
+ };
+
+ for (size_t i = 0; i < arraysize(kFrameSizes); ++i) {
+ float fps =
+ MeasureVideoEncoderFpsWithSize(encoder.get(), kFrameSizes[i]);
+ LOG(ERROR) << kFrameSizes[i].width() << "x" << kFrameSizes[i].height()
+ << ": " << fps << "fps";
+ }
+}
+
+// Measure the performance of the VP9 encoder.
+TEST(VideoEncoderVpxTest, MANUAL_MeasureVp9Fps) {
+ const DesktopSize kFrameSizes[] = {
+ DesktopSize(1280, 1024), DesktopSize(1920, 1200)
+ };
+
+ for (int lossless_mode = 0; lossless_mode < 4; ++lossless_mode) {
Sergey Ulanov 2014/06/24 02:00:51 nit: it might be more readable have list of tests
Wez 2014/06/24 02:14:13 I prefer to iterate over sizes and iterate over lo
+ bool lossless_color = lossless_mode & 1;
+ bool lossless_encode = lossless_mode & 2;
+
+ scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP9());
+ encoder->SetLosslessColor(lossless_color);
+ encoder->SetLosslessEncode(lossless_encode);
+
+ for (size_t i = 0; i < arraysize(kFrameSizes); ++i) {
+ float fps =
+ MeasureVideoEncoderFpsWithSize(encoder.get(), kFrameSizes[i]);
+ LOG(ERROR) << kFrameSizes[i].width() << "x" << kFrameSizes[i].height()
+ << "(" << (lossless_encode ? "lossless" : "lossy ") << ")"
+ << "(" << (lossless_color ? "I444" : "I420") << ")"
+ << ": " << fps << "fps";
+ }
+ }
+}
+
} // namespace remoting
« remoting/codec/codec_test.cc ('K') | « remoting/codec/codec_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698