OLD | NEW |
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 // The format of these tests are to enqueue a known amount of data and then | 5 // The format of these tests are to enqueue a known amount of data and then |
6 // request the exact amount we expect in order to dequeue the known amount of | 6 // request the exact amount we expect in order to dequeue the known amount of |
7 // data. This ensures that for any rate we are consuming input data at the | 7 // data. This ensures that for any rate we are consuming input data at the |
8 // correct rate. We always pass in a very large destination buffer with the | 8 // correct rate. We always pass in a very large destination buffer with the |
9 // expectation that FillBuffer() will fill as much as it can but no more. | 9 // expectation that FillBuffer() will fill as much as it can but no more. |
10 | 10 |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 // An interval which is of no effect. | 590 // An interval which is of no effect. |
591 exclude_interval = std::make_pair(-100, -10); | 591 exclude_interval = std::make_pair(-100, -10); |
592 EXPECT_EQ(4, internal::DecimatedSearch( | 592 EXPECT_EQ(4, internal::DecimatedSearch( |
593 4, exclude_interval, target.get(), search_region.get(), | 593 4, exclude_interval, target.get(), search_region.get(), |
594 energy_target.get(), energy_candid_blocks.get())); | 594 energy_target.get(), energy_candid_blocks.get())); |
595 | 595 |
596 EXPECT_EQ(5, internal::OptimalIndex(search_region.get(), target.get(), | 596 EXPECT_EQ(5, internal::OptimalIndex(search_region.get(), target.get(), |
597 exclude_interval)); | 597 exclude_interval)); |
598 } | 598 } |
599 | 599 |
600 TEST_F(AudioRendererAlgorithmTest, CubicInterpolation) { | 600 TEST_F(AudioRendererAlgorithmTest, QuadraticInterpolation) { |
601 // Arbitrary coefficients. | 601 // Arbitrary coefficients. |
602 const float kA = 0.7f; | 602 const float kA = 0.7f; |
603 const float kB = 1.2f; | 603 const float kB = 1.2f; |
604 const float kC = 0.8f; | 604 const float kC = 0.8f; |
605 | 605 |
606 float y_values[3]; | 606 float y_values[3]; |
607 y_values[0] = kA - kB + kC; | 607 y_values[0] = kA - kB + kC; |
608 y_values[1] = kC; | 608 y_values[1] = kC; |
609 y_values[2] = kA + kB + kC; | 609 y_values[2] = kA + kB + kC; |
610 | 610 |
611 float extremum; | 611 float extremum; |
612 float extremum_value; | 612 float extremum_value; |
613 | 613 |
614 internal::CubicInterpolation(y_values, &extremum, &extremum_value); | 614 internal::QuadraticInterpolation(y_values, &extremum, &extremum_value); |
615 | 615 |
616 float x_star = -kB / (2.f * kA); | 616 float x_star = -kB / (2.f * kA); |
617 float y_star = kA * x_star * x_star + kB * x_star + kC; | 617 float y_star = kA * x_star * x_star + kB * x_star + kC; |
618 | 618 |
619 EXPECT_FLOAT_EQ(x_star, extremum); | 619 EXPECT_FLOAT_EQ(x_star, extremum); |
620 EXPECT_FLOAT_EQ(y_star, extremum_value); | 620 EXPECT_FLOAT_EQ(y_star, extremum_value); |
621 } | 621 } |
622 | 622 |
| 623 TEST_F(AudioRendererAlgorithmTest, QuadraticInterpolation_Colinear) { |
| 624 float y_values[3]; |
| 625 y_values[0] = 1.0; |
| 626 y_values[1] = 1.0; |
| 627 y_values[2] = 1.0; |
| 628 |
| 629 float extremum; |
| 630 float extremum_value; |
| 631 |
| 632 internal::QuadraticInterpolation(y_values, &extremum, &extremum_value); |
| 633 |
| 634 EXPECT_FLOAT_EQ(extremum, 0.0); |
| 635 EXPECT_FLOAT_EQ(extremum_value, 1.0); |
| 636 } |
| 637 |
623 TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) { | 638 TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) { |
624 WsolaTest(0.6f); | 639 WsolaTest(0.6f); |
625 } | 640 } |
626 | 641 |
627 TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) { | 642 TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) { |
628 WsolaTest(1.6f); | 643 WsolaTest(1.6f); |
629 } | 644 } |
630 | 645 |
631 } // namespace media | 646 } // namespace media |
OLD | NEW |