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

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

Issue 11195062: Improve codec tests to test a broader variety of dimensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reduce number of test cases, fix indentation. Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 << "Row " << y << " is different"; 215 << "Row " << y << " is different";
216 original += stride; 216 original += stride;
217 decoded += stride; 217 decoded += stride;
218 } 218 }
219 } 219 }
220 } 220 }
221 221
222 // The error at each pixel is the root mean square of the errors in 222 // The error at each pixel is the root mean square of the errors in
223 // the R, G, and B components, each normalized to [0, 1]. This routine 223 // the R, G, and B components, each normalized to [0, 1]. This routine
224 // checks that the maximum and mean pixel errors do not exceed given limits. 224 // checks that the maximum and mean pixel errors do not exceed given limits.
225 void VerifyResultsApprox(const uint8* expected_view_data, 225 void VerifyResultsApprox(const uint8* expected_view_data,
226 double max_error_limit, double mean_error_limit) { 226 double max_error_limit, double mean_error_limit) {
227 double max_error = 0.0; 227 double max_error = 0.0;
228 double sum_error = 0.0; 228 double sum_error = 0.0;
229 int error_num = 0; 229 int error_num = 0;
230 for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) { 230 for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) {
231 const int stride = view_size_.width() * kBytesPerPixel; 231 const int stride = view_size_.width() * kBytesPerPixel;
232 const int offset = stride * i.rect().top() + 232 const int offset = stride * i.rect().top() +
233 kBytesPerPixel * i.rect().left(); 233 kBytesPerPixel * i.rect().left();
234 const uint8* expected = expected_view_data + offset; 234 const uint8* expected = expected_view_data + offset;
235 const uint8* actual = image_data_.get() + offset; 235 const uint8* actual = image_data_.get() + offset;
236 for (int y = 0; y < i.rect().height(); ++y) { 236 for (int y = 0; y < i.rect().height(); ++y) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 for (int i = 0; i < count; ++i) { 350 for (int i = 0; i < count; ++i) {
351 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op); 351 data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op);
352 } 352 }
353 tester->AddRects(rects, count); 353 tester->AddRects(rects, count);
354 354
355 encoder->Encode(data, true, base::Bind( 355 encoder->Encode(data, true, base::Bind(
356 &VideoEncoderTester::DataAvailable, base::Unretained(tester))); 356 &VideoEncoderTester::DataAvailable, base::Unretained(tester)));
357 } 357 }
358 358
359 void TestVideoEncoder(VideoEncoder* encoder, bool strict) { 359 void TestVideoEncoder(VideoEncoder* encoder, bool strict) {
360 SkISize kSize = SkISize::Make(320, 240); 360 const int kSizes[] = {320, 319, 317, 150};
361 361
362 VideoEncoderMessageTester message_tester; 362 VideoEncoderMessageTester message_tester;
363 message_tester.set_strict(strict); 363 message_tester.set_strict(strict);
364 364
365 VideoEncoderTester tester(&message_tester); 365 VideoEncoderTester tester(&message_tester);
366 366
367 scoped_array<uint8> memory; 367 scoped_array<uint8> memory;
368 scoped_refptr<CaptureData> data =
369 PrepareEncodeData(kSize, media::VideoFrame::RGB32, &memory);
370 368
371 std::vector<std::vector<SkIRect> > test_rect_lists = MakeTestRectLists(kSize); 369 for (size_t xi = 0; xi < arraysize(kSizes); ++xi) {
372 for (size_t i = 0; i < test_rect_lists.size(); ++i) { 370 for (size_t yi = 0; yi < arraysize(kSizes); ++yi) {
373 const std::vector<SkIRect>& test_rects = test_rect_lists[i]; 371 SkISize size = SkISize::Make(kSizes[xi], kSizes[yi]);
374 TestEncodingRects(encoder, &tester, data, 372 scoped_refptr<CaptureData> data =
375 &test_rects[0], test_rects.size()); 373 PrepareEncodeData(size, media::VideoFrame::RGB32, &memory);
374 std::vector<std::vector<SkIRect> > test_rect_lists =
375 MakeTestRectLists(size);
376 for (size_t i = 0; i < test_rect_lists.size(); ++i) {
377 const std::vector<SkIRect>& test_rects = test_rect_lists[i];
378 TestEncodingRects(encoder, &tester, data,
379 &test_rects[0], test_rects.size());
380 }
381 }
376 } 382 }
377 } 383 }
378 384
379 static void TestEncodeDecodeRects(VideoEncoder* encoder, 385 static void TestEncodeDecodeRects(VideoEncoder* encoder,
380 VideoEncoderTester* encoder_tester, 386 VideoEncoderTester* encoder_tester,
381 VideoDecoderTester* decoder_tester, 387 VideoDecoderTester* decoder_tester,
382 scoped_refptr<CaptureData> data, 388 scoped_refptr<CaptureData> data,
383 const SkIRect* rects, int count) { 389 const SkIRect* rects, int count) {
384 data->mutable_dirty_region().setRects(rects, count); 390 data->mutable_dirty_region().setRects(rects, count);
385 encoder_tester->AddRects(rects, count); 391 encoder_tester->AddRects(rects, count);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // Check that the decoder correctly re-renders the frame if its client 493 // Check that the decoder correctly re-renders the frame if its client
488 // invalidates the frame. 494 // invalidates the frame.
489 decoder_tester.ResetRenderedData(); 495 decoder_tester.ResetRenderedData();
490 decoder->Invalidate(view_size, SkRegion(view_rect)); 496 decoder->Invalidate(view_size, SkRegion(view_rect));
491 decoder_tester.RenderFrame(); 497 decoder_tester.RenderFrame();
492 decoder_tester.VerifyResultsApprox(expected_view_data.get(), 498 decoder_tester.VerifyResultsApprox(expected_view_data.get(),
493 max_error_limit, mean_error_limit); 499 max_error_limit, mean_error_limit);
494 } 500 }
495 501
496 } // namespace remoting 502 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698