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.

32 lines
888B

  1. #ifndef MATHEMATICS_H
  2. #define MATHEMATICS_H
  3. #include "rational.h"
  4. enum AVRounding {
  5. AV_ROUND_ZERO = 0, ///< round toward zero
  6. AV_ROUND_INF = 1, ///< round away from zero
  7. AV_ROUND_DOWN = 2, ///< round toward -infinity
  8. AV_ROUND_UP = 3, ///< round toward +infinity
  9. AV_ROUND_NEAR_INF = 5, ///< round to nearest and halfway cases away from zero
  10. };
  11. /**
  12. * rescale a 64bit integer with rounding to nearest.
  13. * a simple a*b/c isn't possible as it can overflow
  14. */
  15. int64_t av_rescale(int64_t a, int64_t b, int64_t c);
  16. /**
  17. * rescale a 64bit integer with specified rounding.
  18. * a simple a*b/c isn't possible as it can overflow
  19. */
  20. int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
  21. /**
  22. * rescale a 64bit integer by 2 rational numbers.
  23. */
  24. int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
  25. #endif /* MATHEMATICS_H */