| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "mojo/public/cpp/environment/logging.h" |
| #include "mojo/services/media/common/cpp/linear_function.h" |
| int64_t LinearFunction::Apply(int64_t domain_basis, |
| const Ratio& slope, // range_delta / domain_delta |
| return slope.Scale(domain_input - domain_basis) + range_basis; |
| LinearFunction LinearFunction::Compose(const LinearFunction& bc, |
| const LinearFunction& ab, |
| return LinearFunction(ab.domain_basis(), bc.Apply(ab.range_basis()), |
| Ratio::Product(ab.slope(), bc.slope(), exact)); |