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

Side by Side Diff: remoting/codec/codec_test.cc

Issue 1150163002: Update VideoFramePump to pass un-changed frames to encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work-around Visual Studio issue w/ undefined references Created 5 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 unified diff | Download patch
« no previous file with comments | « remoting/codec/codec_test.h ('k') | remoting/codec/video_encoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <deque> 5 #include <deque>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 int memory_size = size.width() * size.height() * kBytesPerPixel; 240 int memory_size = size.width() * size.height() * kBytesPerPixel;
241 for (int i = 0; i < memory_size; ++i) { 241 for (int i = 0; i < memory_size; ++i) {
242 frame->data()[i] = rand() % 256; 242 frame->data()[i] = rand() % 256;
243 } 243 }
244 244
245 return frame.Pass(); 245 return frame.Pass();
246 } 246 }
247 247
248 static void TestEncodingRects(VideoEncoder* encoder, 248 static void TestEncodingRects(VideoEncoder* encoder,
249 VideoEncoderTester* tester, 249 VideoEncoderTester* tester,
250 webrtc::DesktopFrame* frame, 250 DesktopFrame* frame,
251 const DesktopRect* rects, 251 const DesktopRect* rects,
252 int count) { 252 int count) {
253 frame->mutable_updated_region()->Clear(); 253 frame->mutable_updated_region()->Clear();
254 for (int i = 0; i < count; ++i) { 254 for (int i = 0; i < count; ++i) {
255 frame->mutable_updated_region()->AddRect(rects[i]); 255 frame->mutable_updated_region()->AddRect(rects[i]);
256 } 256 }
257 257
258 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame); 258 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
259 tester->DataAvailable(packet.Pass()); 259 tester->DataAvailable(packet.Pass());
260 } 260 }
261 261
262 void TestVideoEncoder(VideoEncoder* encoder, bool strict) { 262 void TestVideoEncoder(VideoEncoder* encoder, bool strict) {
263 const int kSizes[] = {320, 319, 317, 150}; 263 const int kSizes[] = {320, 319, 317, 150};
264 264
265 VideoEncoderTester tester; 265 VideoEncoderTester tester;
266 266
267 for (size_t xi = 0; xi < arraysize(kSizes); ++xi) { 267 for (size_t xi = 0; xi < arraysize(kSizes); ++xi) {
268 for (size_t yi = 0; yi < arraysize(kSizes); ++yi) { 268 for (size_t yi = 0; yi < arraysize(kSizes); ++yi) {
269 DesktopSize size = DesktopSize(kSizes[xi], kSizes[yi]); 269 DesktopSize size = DesktopSize(kSizes[xi], kSizes[yi]);
270 scoped_ptr<webrtc::DesktopFrame> frame = PrepareFrame(size); 270 scoped_ptr<DesktopFrame> frame = PrepareFrame(size);
271 std::vector<std::vector<DesktopRect> > test_rect_lists = 271 std::vector<std::vector<DesktopRect> > test_rect_lists =
272 MakeTestRectLists(size); 272 MakeTestRectLists(size);
273 for (size_t i = 0; i < test_rect_lists.size(); ++i) { 273 for (size_t i = 0; i < test_rect_lists.size(); ++i) {
274 const std::vector<DesktopRect>& test_rects = test_rect_lists[i]; 274 const std::vector<DesktopRect>& test_rects = test_rect_lists[i];
275 TestEncodingRects(encoder, &tester, frame.get(), 275 TestEncodingRects(encoder, &tester, frame.get(),
276 &test_rects[0], test_rects.size()); 276 &test_rects[0], test_rects.size());
277 } 277 }
278
279 // Pass some empty frames through the encoder.
280 for (int i = 0; i < 10; ++i) {
281 TestEncodingRects(encoder, &tester, frame.get(), nullptr, 0);
282 }
278 } 283 }
279 } 284 }
280 } 285 }
281 286
287 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder, int topoff_frames) {
288 const DesktopSize kSize(640, 480);
289 scoped_ptr<DesktopFrame> frame(PrepareFrame(kSize));
290
291 frame->mutable_updated_region()->SetRect(
292 webrtc::DesktopRect::MakeSize(kSize));
293 EXPECT_TRUE(encoder->Encode(*frame));
294
295 frame->mutable_updated_region()->Clear();
296 for (int i=0; i < topoff_frames; ++i) {
297 EXPECT_TRUE(encoder->Encode(*frame));
298 }
299
300 EXPECT_FALSE(encoder->Encode(*frame));
301 }
302
282 static void TestEncodeDecodeRects(VideoEncoder* encoder, 303 static void TestEncodeDecodeRects(VideoEncoder* encoder,
283 VideoEncoderTester* encoder_tester, 304 VideoEncoderTester* encoder_tester,
284 VideoDecoderTester* decoder_tester, 305 VideoDecoderTester* decoder_tester,
285 DesktopFrame* frame, 306 DesktopFrame* frame,
286 const DesktopRect* rects, int count) { 307 const DesktopRect* rects, int count) {
287 frame->mutable_updated_region()->Clear(); 308 frame->mutable_updated_region()->Clear();
288 for (int i = 0; i < count; ++i) { 309 for (int i = 0; i < count; ++i) {
289 frame->mutable_updated_region()->AddRect(rects[i]); 310 frame->mutable_updated_region()->AddRect(rects[i]);
290 } 311 }
291 decoder_tester->AddRects(rects, count); 312 decoder_tester->AddRects(rects, count);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 442
422 if (frame_count >= kWarmUpFrameCount) { 443 if (frame_count >= kWarmUpFrameCount) {
423 elapsed = base::TimeTicks::Now() - start_time; 444 elapsed = base::TimeTicks::Now() - start_time;
424 } 445 }
425 } 446 }
426 447
427 return (frame_count * base::TimeDelta::FromSeconds(1)) / elapsed; 448 return (frame_count * base::TimeDelta::FromSeconds(1)) / elapsed;
428 } 449 }
429 450
430 } // namespace remoting 451 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/codec/codec_test.h ('k') | remoting/codec/video_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698