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

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

Issue 1213323003: Supply empty frames until codec is done with top-off. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Loosen top-off frame count tests Created 5 years, 5 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_vpx.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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 277 }
278 278
279 // Pass some empty frames through the encoder. 279 // Pass some empty frames through the encoder.
280 for (int i = 0; i < 10; ++i) { 280 for (int i = 0; i < 10; ++i) {
281 TestEncodingRects(encoder, &tester, frame.get(), nullptr, 0); 281 TestEncodingRects(encoder, &tester, frame.get(), nullptr, 0);
282 } 282 }
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder, int topoff_frames) { 287 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder,
288 int max_topoff_frames) {
288 const DesktopSize kSize(640, 480); 289 const DesktopSize kSize(640, 480);
289 scoped_ptr<DesktopFrame> frame(PrepareFrame(kSize)); 290 scoped_ptr<DesktopFrame> frame(PrepareFrame(kSize));
290 291
291 frame->mutable_updated_region()->SetRect( 292 frame->mutable_updated_region()->SetRect(
292 webrtc::DesktopRect::MakeSize(kSize)); 293 webrtc::DesktopRect::MakeSize(kSize));
293 EXPECT_TRUE(encoder->Encode(*frame)); 294 EXPECT_TRUE(encoder->Encode(*frame));
294 295
296 int topoff_frames = 0;
295 frame->mutable_updated_region()->Clear(); 297 frame->mutable_updated_region()->Clear();
296 for (int i=0; i < topoff_frames; ++i) { 298 for (int i = 0; i < max_topoff_frames + 1; ++i) {
297 EXPECT_TRUE(encoder->Encode(*frame)); 299 if (!encoder->Encode(*frame))
300 break;
301 topoff_frames++;
298 } 302 }
299 303
300 EXPECT_FALSE(encoder->Encode(*frame)); 304 // If top-off is enabled then our random frame contents should always
305 // trigger it, so expect at least one top-off frame - strictly, though,
306 // an encoder may not always need to top-off.
307 EXPECT_GE(topoff_frames, max_topoff_frames ? 1 : 0);
308 EXPECT_LE(topoff_frames, max_topoff_frames);
301 } 309 }
302 310
303 static void TestEncodeDecodeRects(VideoEncoder* encoder, 311 static void TestEncodeDecodeRects(VideoEncoder* encoder,
304 VideoEncoderTester* encoder_tester, 312 VideoEncoderTester* encoder_tester,
305 VideoDecoderTester* decoder_tester, 313 VideoDecoderTester* decoder_tester,
306 DesktopFrame* frame, 314 DesktopFrame* frame,
307 const DesktopRect* rects, int count) { 315 const DesktopRect* rects, int count) {
308 frame->mutable_updated_region()->Clear(); 316 frame->mutable_updated_region()->Clear();
309 for (int i = 0; i < count; ++i) { 317 for (int i = 0; i < count; ++i) {
310 frame->mutable_updated_region()->AddRect(rects[i]); 318 frame->mutable_updated_region()->AddRect(rects[i]);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 450
443 if (frame_count >= kWarmUpFrameCount) { 451 if (frame_count >= kWarmUpFrameCount) {
444 elapsed = base::TimeTicks::Now() - start_time; 452 elapsed = base::TimeTicks::Now() - start_time;
445 } 453 }
446 } 454 }
447 455
448 return (frame_count * base::TimeDelta::FromSeconds(1)) / elapsed; 456 return (frame_count * base::TimeDelta::FromSeconds(1)) / elapsed;
449 } 457 }
450 458
451 } // namespace remoting 459 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/codec/codec_test.h ('k') | remoting/codec/video_encoder_vpx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698