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 RESAMPLER_INTEGER_RATIO_H 18 #define RESAMPLER_INTEGER_RATIO_H 19 20 #include <sys/types.h> 21 22 #include "ResamplerDefinitions.h" 23 24 namespace RESAMPLER_OUTER_NAMESPACE::resampler { 25 26 /** 27 * Represent the ratio of two integers. 28 */ 29 class IntegerRatio { 30 public: IntegerRatio(int32_t numerator,int32_t denominator)31 IntegerRatio(int32_t numerator, int32_t denominator) 32 : mNumerator(numerator), mDenominator(denominator) {} 33 34 /** 35 * Reduce by removing common prime factors. 36 */ 37 void reduce(); 38 getNumerator()39 int32_t getNumerator() { 40 return mNumerator; 41 } 42 getDenominator()43 int32_t getDenominator() { 44 return mDenominator; 45 } 46 47 private: 48 int32_t mNumerator; 49 int32_t mDenominator; 50 }; 51 52 } /* namespace RESAMPLER_OUTER_NAMESPACE::resampler */ 53 54 #endif //RESAMPLER_INTEGER_RATIO_H 55