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

Side by Side Diff: cc/resources/video_resource_updater_unittest.cc

Issue 2425423006: libyuv r1629 roll for AVX2 optimized HalfFloatPlane and ExtractAlpha. (Closed)
Patch Set: avoid reading off end of buffer VideoResourceUpdaterTest.MakeHalfFloatTest Created 4 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
« no previous file with comments | « DEPS ('k') | 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 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 "cc/resources/video_resource_updater.h" 5 #include "cc/resources/video_resource_updater.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 for (int bits = 9; bits <= 12; bits++) { 541 for (int bits = 9; bits <= 12; bits++) {
542 int num_values = 1 << bits; 542 int num_values = 1 << bits;
543 for (int i = 0; i < num_values; i++) 543 for (int i = 0; i < num_values; i++)
544 integers[i] = i; 544 integers[i] = i;
545 545
546 VideoResourceUpdater::MakeHalfFloats(integers, bits, num_values, 546 VideoResourceUpdater::MakeHalfFloats(integers, bits, num_values,
547 half_floats); 547 half_floats);
548 548
549 // Multiplier to converting integers to 0.0..1.0 range. 549 // Multiplier to converting integers to 0.0..1.0 range.
550 double multiplier = 1.0 / (num_values - 1); 550 double multiplier = 1.0 / (num_values - 1);
551 float expected_precision = 0.f;
551 552
552 for (int i = 0; i < num_values; i++) { 553 for (int i = 0; i < num_values; i++) {
553 // We expect the result to be within +/- one least-significant bit. 554 // We expect the result to be within +/- one least-significant bit.
554 // Within the range we care about, half-floats values and 555 // Within the range we care about, half-floats values and
555 // their representation both sort in the same order, so we 556 // their representation both sort in the same order, so we
556 // can just add one to get the next bigger half-float. 557 // can just add one to get the next bigger half-float.
557 float expected_precision = 558 if (i < num_values - 1) {
hubbe 2016/10/20 18:55:11 Why is this change needed? It seems it will just u
fbarchard1 2016/10/20 22:57:34 Done. unittest does not need a change.
559 expected_precision =
558 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); 560 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]);
561 }
559 EXPECT_NEAR(FromHalfFloat(half_floats[i]), integers[i] * multiplier, 562 EXPECT_NEAR(FromHalfFloat(half_floats[i]), integers[i] * multiplier,
560 expected_precision) 563 expected_precision)
561 << "i = " << i << " bits = " << bits; 564 << "i = " << i << " bits = " << bits;
562 } 565 }
563 } 566 }
564 } 567 }
565 568
566 } // namespace 569 } // namespace
567 } // namespace cc 570 } // namespace cc
OLDNEW
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698