Commit | Line | Data |
---|---|---|

04d7f601 DB |
1 | /* |

2 | * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> | |

3 | * | |

4 | * This library is free software; you can redistribute it and/or | |

5 | * modify it under the terms of the GNU Lesser General Public | |

6 | * License as published by the Free Software Foundation; either | |

7 | * version 2 of the License, or (at your option) any later version. | |

8 | * | |

9 | * This library is distributed in the hope that it will be useful, | |

10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |

11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |

12 | * Lesser General Public License for more details. | |

13 | * | |

14 | * You should have received a copy of the GNU Lesser General Public | |

15 | * License along with this library; if not, write to the Free Software | |

16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |

17 | */ | |

18 | ||

c11c2bc2 AS |
19 | #ifndef MATHEMATICS_H |

20 | #define MATHEMATICS_H | |

21 | ||

22 | #include "rational.h" | |

23 | ||

24 | enum AVRounding { | |

25 | AV_ROUND_ZERO = 0, ///< round toward zero | |

26 | AV_ROUND_INF = 1, ///< round away from zero | |

27 | AV_ROUND_DOWN = 2, ///< round toward -infinity | |

28 | AV_ROUND_UP = 3, ///< round toward +infinity | |

29 | AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero | |

30 | }; | |

31 | ||

32 | /** | |

33 | * rescale a 64bit integer with rounding to nearest. | |

34 | * a simple a*b/c isn't possible as it can overflow | |

35 | */ | |

36 | int64_t av_rescale(int64_t a, int64_t b, int64_t c); | |

37 | ||

38 | /** | |

39 | * rescale a 64bit integer with specified rounding. | |

40 | * a simple a*b/c isn't possible as it can overflow | |

41 | */ | |

42 | int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding); | |

43 | ||

44 | /** | |

45 | * rescale a 64bit integer by 2 rational numbers. | |

46 | */ | |

47 | int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq); | |

48 | ||

49 | #endif /* MATHEMATICS_H */ |