OLD | NEW |
---|---|
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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
533 return pow(2.0, -24.0) * fraction; | 533 return pow(2.0, -24.0) * fraction; |
534 } else if (exponent == 0x1F) { | 534 } else if (exponent == 0x1F) { |
535 return sign * 1000000000000.0; | 535 return sign * 1000000000000.0; |
536 } else { | 536 } else { |
537 return pow(2.0, exponent - 25) * (0x400 + fraction); | 537 return pow(2.0, exponent - 25) * (0x400 + fraction); |
538 } | 538 } |
539 } | 539 } |
540 | 540 |
541 } // namespace | 541 } // namespace |
542 | 542 |
543 TEST_F(VideoResourceUpdaterTest, MakeHalfFloatTest) { | 543 TEST_F(VideoResourceUpdaterTest, MakeHalfFloatTest) { |
hubbe
2017/03/23 17:46:11
Move this test to media::
Uzair
2017/03/24 05:39:08
Done.
| |
544 unsigned short integers[1 << 16]; | 544 unsigned short integers[1 << 16]; |
545 unsigned short half_floats[1 << 16]; | 545 unsigned short half_floats[1 << 16]; |
546 for (int bits = 9; bits <= 16; bits++) { | 546 for (int bits = 9; bits <= 16; bits++) { |
547 std::unique_ptr<VideoResourceUpdater::HalfFloatMaker> half_float_maker; | 547 std::unique_ptr<media::HalfFloatMaker> half_float_maker; |
548 half_float_maker = VideoResourceUpdater::NewHalfFloatMaker(bits); | 548 half_float_maker = media::HalfFloatMaker::NewHalfFloatMaker(bits); |
549 int num_values = 1 << bits; | 549 int num_values = 1 << bits; |
550 for (int i = 0; i < num_values; i++) | 550 for (int i = 0; i < num_values; i++) |
551 integers[i] = i; | 551 integers[i] = i; |
552 | 552 |
553 half_float_maker->MakeHalfFloats(integers, num_values, half_floats); | 553 half_float_maker->MakeHalfFloats(integers, num_values, half_floats); |
554 // Multiplier to converting integers to 0.0..1.0 range. | 554 // Multiplier to converting integers to 0.0..1.0 range. |
555 double multiplier = 1.0 / (num_values - 1); | 555 double multiplier = 1.0 / (num_values - 1); |
556 | 556 |
557 for (int i = 0; i < num_values; i++) { | 557 for (int i = 0; i < num_values; i++) { |
558 // This value is in range 0..1 | 558 // This value is in range 0..1 |
(...skipping 12 matching lines...) Expand all Loading... | |
571 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); | 571 FromHalfFloat(half_floats[i] + 1) - FromHalfFloat(half_floats[i]); |
572 EXPECT_NEAR(FromHalfFloat(half_floats[i]), expected_value, | 572 EXPECT_NEAR(FromHalfFloat(half_floats[i]), expected_value, |
573 expected_precision) | 573 expected_precision) |
574 << "i = " << i << " bits = " << bits; | 574 << "i = " << i << " bits = " << bits; |
575 } | 575 } |
576 } | 576 } |
577 } | 577 } |
578 | 578 |
579 } // namespace | 579 } // namespace |
580 } // namespace cc | 580 } // namespace cc |
OLD | NEW |