You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7KB

  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. #ifndef MATHEMATICS_H
  19. #define MATHEMATICS_H
  20. #include "rational.h"
  21. enum AVRounding {
  22. AV_ROUND_ZERO = 0, ///< round toward zero
  23. AV_ROUND_INF = 1, ///< round away from zero
  24. AV_ROUND_DOWN = 2, ///< round toward -infinity
  25. AV_ROUND_UP = 3, ///< round toward +infinity
  26. AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
  27. };
  28. /**
  29. * rescale a 64bit integer with rounding to nearest.
  30. * a simple a*b/c isn't possible as it can overflow
  31. */
  32. int64_t av_rescale(int64_t a, int64_t b, int64_t c);
  33. /**
  34. * rescale a 64bit integer with specified rounding.
  35. * a simple a*b/c isn't possible as it can overflow
  36. */
  37. int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
  38. /**
  39. * rescale a 64bit integer by 2 rational numbers.
  40. */
  41. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
  42. #endif /* MATHEMATICS_H */