| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/codec/video_encoder_vpx.h" | 5 #include "remoting/codec/video_encoder_vpx.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <limits> | 9 #include <limits> |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "remoting/codec/codec_test.h" | 13 #include "remoting/codec/codec_test.h" |
| 12 #include "remoting/proto/video.pb.h" | 14 #include "remoting/proto/video.pb.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 16 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 15 | 17 |
| 16 namespace remoting { | 18 namespace remoting { |
| 17 | 19 |
| 18 // xRGB pixel colors for use by tests. | 20 // xRGB pixel colors for use by tests. |
| 19 const uint32 kBlueColor = 0x0000ff; | 21 const uint32_t kBlueColor = 0x0000ff; |
| 20 const uint32 kGreenColor = 0x00ff00; | 22 const uint32_t kGreenColor = 0x00ff00; |
| 21 | 23 |
| 22 // Creates a frame stippled between blue and red pixels, which is useful for | 24 // Creates a frame stippled between blue and red pixels, which is useful for |
| 23 // lossy/lossless encode and color tests. By default all pixels in the frame | 25 // lossy/lossless encode and color tests. By default all pixels in the frame |
| 24 // are included in the updated_region(). | 26 // are included in the updated_region(). |
| 25 static scoped_ptr<webrtc::DesktopFrame> CreateTestFrame( | 27 static scoped_ptr<webrtc::DesktopFrame> CreateTestFrame( |
| 26 const webrtc::DesktopSize& frame_size) { | 28 const webrtc::DesktopSize& frame_size) { |
| 27 scoped_ptr<webrtc::DesktopFrame> frame( | 29 scoped_ptr<webrtc::DesktopFrame> frame( |
| 28 new webrtc::BasicDesktopFrame(frame_size)); | 30 new webrtc::BasicDesktopFrame(frame_size)); |
| 29 for (int x = 0; x < frame_size.width(); ++x) { | 31 for (int x = 0; x < frame_size.width(); ++x) { |
| 30 for (int y = 0; y < frame_size.height(); ++y) { | 32 for (int y = 0; y < frame_size.height(); ++y) { |
| 31 uint8* pixel_u8 = frame->data() + (y * frame->stride()) + | 33 uint8_t* pixel_u8 = frame->data() + (y * frame->stride()) + |
| 32 (x * webrtc::DesktopFrame::kBytesPerPixel); | 34 (x * webrtc::DesktopFrame::kBytesPerPixel); |
| 33 *(reinterpret_cast<uint32*>(pixel_u8)) = | 35 *(reinterpret_cast<uint32_t*>(pixel_u8)) = |
| 34 ((x + y) & 1) ? kGreenColor : kBlueColor; | 36 ((x + y) & 1) ? kGreenColor : kBlueColor; |
| 35 } | 37 } |
| 36 } | 38 } |
| 37 frame->mutable_updated_region()->SetRect( | 39 frame->mutable_updated_region()->SetRect( |
| 38 webrtc::DesktopRect::MakeSize(frame_size)); | 40 webrtc::DesktopRect::MakeSize(frame_size)); |
| 39 return frame.Pass(); | 41 return frame.Pass(); |
| 40 } | 42 } |
| 41 | 43 |
| 42 TEST(VideoEncoderVpxTest, Vp8) { | 44 TEST(VideoEncoderVpxTest, Vp8) { |
| 43 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8()); | 45 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP8()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 177 |
| 176 TEST(VideoEncoderVpxTest, Vp9LossyUnchangedFrame) { | 178 TEST(VideoEncoderVpxTest, Vp9LossyUnchangedFrame) { |
| 177 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP9()); | 179 scoped_ptr<VideoEncoderVpx> encoder(VideoEncoderVpx::CreateForVP9()); |
| 178 encoder->SetLosslessEncode(false); | 180 encoder->SetLosslessEncode(false); |
| 179 // Expect that VP9+CR should generate no more than 10 top-off frames | 181 // Expect that VP9+CR should generate no more than 10 top-off frames |
| 180 // per cycle, and take no more than 2 cycles to top-off. | 182 // per cycle, and take no more than 2 cycles to top-off. |
| 181 TestVideoEncoderEmptyFrames(encoder.get(), 20); | 183 TestVideoEncoderEmptyFrames(encoder.get(), 20); |
| 182 } | 184 } |
| 183 | 185 |
| 184 } // namespace remoting | 186 } // namespace remoting |
| OLD | NEW |