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

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

Issue 23477059: Simplify VideoEncoder interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 VideoEncoderTester* tester, 351 VideoEncoderTester* tester,
352 webrtc::DesktopFrame* frame, 352 webrtc::DesktopFrame* frame,
353 const DesktopRect* rects, 353 const DesktopRect* rects,
354 int count) { 354 int count) {
355 frame->mutable_updated_region()->Clear(); 355 frame->mutable_updated_region()->Clear();
356 for (int i = 0; i < count; ++i) { 356 for (int i = 0; i < count; ++i) {
357 frame->mutable_updated_region()->AddRect(rects[i]); 357 frame->mutable_updated_region()->AddRect(rects[i]);
358 } 358 }
359 tester->AddRects(rects, count); 359 tester->AddRects(rects, count);
360 360
361 encoder->Encode(frame, base::Bind( 361 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
362 &VideoEncoderTester::DataAvailable, base::Unretained(tester))); 362 tester->DataAvailable(packet.Pass());
363 } 363 }
364 364
365 void TestVideoEncoder(VideoEncoder* encoder, bool strict) { 365 void TestVideoEncoder(VideoEncoder* encoder, bool strict) {
366 const int kSizes[] = {320, 319, 317, 150}; 366 const int kSizes[] = {320, 319, 317, 150};
367 367
368 VideoEncoderMessageTester message_tester; 368 VideoEncoderMessageTester message_tester;
369 message_tester.set_strict(strict); 369 message_tester.set_strict(strict);
370 370
371 VideoEncoderTester tester(&message_tester); 371 VideoEncoderTester tester(&message_tester);
372 372
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 uint8* memory = frame->data() + 405 uint8* memory = frame->data() +
406 frame->stride() * rects[i].top() + 406 frame->stride() * rects[i].top() +
407 webrtc::DesktopFrame::kBytesPerPixel * rects[i].left(); 407 webrtc::DesktopFrame::kBytesPerPixel * rects[i].left();
408 for (int y = 0; y < rects[i].height(); ++y) { 408 for (int y = 0; y < rects[i].height(); ++y) {
409 for (int x = 0; x < row_size; ++x) 409 for (int x = 0; x < row_size; ++x)
410 memory[x] = rand() % 256; 410 memory[x] = rand() % 256;
411 memory += frame->stride(); 411 memory += frame->stride();
412 } 412 }
413 } 413 }
414 414
415 encoder->Encode(frame, base::Bind(&VideoEncoderTester::DataAvailable, 415 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
416 base::Unretained(encoder_tester))); 416 encoder_tester->DataAvailable(packet.Pass());
417 decoder_tester->VerifyResults(); 417 decoder_tester->VerifyResults();
418 decoder_tester->Reset(); 418 decoder_tester->Reset();
419 } 419 }
420 420
421 void TestVideoEncoderDecoder( 421 void TestVideoEncoderDecoder(
422 VideoEncoder* encoder, VideoDecoder* decoder, bool strict) { 422 VideoEncoder* encoder, VideoDecoder* decoder, bool strict) {
423 DesktopSize kSize = DesktopSize(320, 240); 423 DesktopSize kSize = DesktopSize(320, 240);
424 424
425 VideoEncoderMessageTester message_tester; 425 VideoEncoderMessageTester message_tester;
426 message_tester.set_strict(strict); 426 message_tester.set_strict(strict);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(screen_size)); 468 frame->mutable_updated_region()->SetRect(DesktopRect::MakeSize(screen_size));
469 469
470 scoped_ptr<webrtc::BasicDesktopFrame> expected_result( 470 scoped_ptr<webrtc::BasicDesktopFrame> expected_result(
471 new webrtc::BasicDesktopFrame(view_size)); 471 new webrtc::BasicDesktopFrame(view_size));
472 FillWithGradient(expected_result.get()); 472 FillWithGradient(expected_result.get());
473 473
474 VideoDecoderTester decoder_tester(decoder, screen_size, view_size); 474 VideoDecoderTester decoder_tester(decoder, screen_size, view_size);
475 decoder_tester.set_frame(frame.get()); 475 decoder_tester.set_frame(frame.get());
476 decoder_tester.AddRegion(frame->updated_region()); 476 decoder_tester.AddRegion(frame->updated_region());
477 477
478 encoder->Encode(frame.get(), 478 scoped_ptr<VideoPacket> packet = encoder->Encode(*frame);
479 base::Bind(&VideoDecoderTester::ReceivedScopedPacket, 479 decoder_tester.ReceivedScopedPacket(packet.Pass());
480 base::Unretained(&decoder_tester)));
481 480
482 decoder_tester.VerifyResultsApprox(expected_result->data(), 481 decoder_tester.VerifyResultsApprox(expected_result->data(),
483 max_error_limit, mean_error_limit); 482 max_error_limit, mean_error_limit);
484 483
485 // Check that the decoder correctly re-renders the frame if its client 484 // Check that the decoder correctly re-renders the frame if its client
486 // invalidates the frame. 485 // invalidates the frame.
487 decoder_tester.ResetRenderedData(); 486 decoder_tester.ResetRenderedData();
488 decoder->Invalidate( 487 decoder->Invalidate(
489 SkISize::Make(view_size.width(), view_size.height()), 488 SkISize::Make(view_size.width(), view_size.height()),
490 SkRegion(SkIRect::MakeWH(view_size.width(), view_size.height()))); 489 SkRegion(SkIRect::MakeWH(view_size.width(), view_size.height())));
491 decoder_tester.RenderFrame(); 490 decoder_tester.RenderFrame();
492 decoder_tester.VerifyResultsApprox(expected_result->data(), 491 decoder_tester.VerifyResultsApprox(expected_result->data(),
493 max_error_limit, mean_error_limit); 492 max_error_limit, mean_error_limit);
494 } 493 }
495 494
496 } // namespace remoting 495 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698