• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef OBOE_INTEGER_RATIO_H
18 #define OBOE_INTEGER_RATIO_H
19 
20 #include <sys/types.h>
21 
22 namespace resampler {
23 
24 /**
25  * Represent the ratio of two integers.
26  */
27 class IntegerRatio {
28 public:
IntegerRatio(int32_t numerator,int32_t denominator)29     IntegerRatio(int32_t numerator, int32_t denominator)
30             : mNumerator(numerator), mDenominator(denominator) {}
31 
32     /**
33      * Reduce by removing common prime factors.
34      */
35     void reduce();
36 
getNumerator()37     int32_t getNumerator() {
38         return mNumerator;
39     }
40 
getDenominator()41     int32_t getDenominator() {
42         return mDenominator;
43     }
44 
45 private:
46     int32_t mNumerator;
47     int32_t mDenominator;
48 };
49 
50 }
51 
52 #endif //OBOE_INTEGER_RATIO_H
53