Chromium Code Reviews| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 // An interval which is of no effect. | 583 // An interval which is of no effect. |
| 584 exclude_interval = std::make_pair(-100, -10); | 584 exclude_interval = std::make_pair(-100, -10); |
| 585 EXPECT_EQ(4, internal::DecimatedSearch( | 585 EXPECT_EQ(4, internal::DecimatedSearch( |
| 586 4, exclude_interval, target.get(), search_region.get(), | 586 4, exclude_interval, target.get(), search_region.get(), |
| 587 energy_target.get(), energy_candid_blocks.get())); | 587 energy_target.get(), energy_candid_blocks.get())); |
| 588 | 588 |
| 589 EXPECT_EQ(5, internal::OptimalIndex(search_region.get(), target.get(), | 589 EXPECT_EQ(5, internal::OptimalIndex(search_region.get(), target.get(), |
| 590 exclude_interval)); | 590 exclude_interval)); |
| 591 } | 591 } |
| 592 | 592 |
| 593 TEST_F(AudioRendererAlgorithmTest, CubicInterpolation) { | 593 TEST_F(AudioRendererAlgorithmTest, QuadraticInterpolation) { |
| 594 // Arbitrary coefficients. | 594 // Arbitrary coefficients. |
| 595 const float kA = 0.7f; | 595 const float kA = 0.7f; |
| 596 const float kB = 1.2f; | 596 const float kB = 1.2f; |
| 597 const float kC = 0.8f; | 597 const float kC = 0.8f; |
| 598 | 598 |
| 599 float y_values[3]; | 599 float y_values[3]; |
| 600 y_values[0] = kA - kB + kC; | 600 y_values[0] = kA - kB + kC; |
| 601 y_values[1] = kC; | 601 y_values[1] = kC; |
| 602 y_values[2] = kA + kB + kC; | 602 y_values[2] = kA + kB + kC; |
| 603 | 603 |
| 604 float extremum; | 604 float extremum; |
| 605 float extremum_value; | 605 float extremum_value; |
| 606 | 606 |
| 607 internal::CubicInterpolation(y_values, &extremum, &extremum_value); | 607 internal::QuadraticInterpolation(y_values, &extremum, &extremum_value); |
| 608 | 608 |
| 609 float x_star = -kB / (2.f * kA); | 609 float x_star = -kB / (2.f * kA); |
| 610 float y_star = kA * x_star * x_star + kB * x_star + kC; | 610 float y_star = kA * x_star * x_star + kB * x_star + kC; |
| 611 | 611 |
| 612 EXPECT_FLOAT_EQ(x_star, extremum); | 612 EXPECT_FLOAT_EQ(x_star, extremum); |
| 613 EXPECT_FLOAT_EQ(y_star, extremum_value); | 613 EXPECT_FLOAT_EQ(y_star, extremum_value); |
| 614 } | 614 } |
| 615 | 615 |
| 616 TEST_F(AudioRendererAlgorithmTest, QuadraticInterpolation_Colinear) { | |
| 617 float y_values[3]; | |
| 618 y_values[0] = 1.0; | |
| 619 y_values[1] = 1.0; | |
| 620 y_values[2] = 1.0; | |
| 621 | |
| 622 float extremum; | |
| 623 float extremum_value; | |
| 624 | |
| 625 internal::QuadraticInterpolation(y_values, &extremum, &extremum_value); | |
| 626 | |
| 627 EXPECT_NEAR(extremum, 0.0, 1.0); | |
|
DaleCurtis
2014/03/29 01:10:01
within 1 seems pretty large?
sandersd (OOO until July 31)
2014/03/29 01:19:37
Since the choice of x = 0 was arbitrary, I'm only
| |
| 628 EXPECT_FLOAT_EQ(extremum_value, 1.0); | |
| 629 } | |
| 630 | |
| 616 TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) { | 631 TEST_F(AudioRendererAlgorithmTest, WsolaSlowdown) { |
| 617 WsolaTest(0.6f); | 632 WsolaTest(0.6f); |
| 618 } | 633 } |
| 619 | 634 |
| 620 TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) { | 635 TEST_F(AudioRendererAlgorithmTest, WsolaSpeedup) { |
| 621 WsolaTest(1.6f); | 636 WsolaTest(1.6f); |
| 622 } | 637 } |
| 623 | 638 |
| 624 } // namespace media | 639 } // namespace media |
| OLD | NEW |