patch-libavutil_internal_h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. $OpenBSD: patch-libavutil_internal_h,v 1.2 2017/06/15 11:33:18 ajacoutot Exp $
  2. lavu/internal: add ff_exp10
  3. lavc/aacenc_utils: replace powf(x,y) by expf(logf(x), y)
  4. Index: libavutil/internal.h
  5. --- libavutil/internal.h.orig
  6. +++ libavutil/internal.h
  7. @@ -270,6 +270,42 @@ void avpriv_request_sample(void *avc,
  8. #endif
  9. /**
  10. + * Compute 10^x for floating point values. Note: this function is by no means
  11. + * "correctly rounded", and is meant as a fast, reasonably accurate approximation.
  12. + * For instance, maximum relative error for the double precision variant is
  13. + * ~ 1e-13 for very small and very large values.
  14. + * This is ~2x faster than GNU libm's approach, which is still off by 2ulp on
  15. + * some inputs.
  16. + * @param x exponent
  17. + * @return 10^x
  18. + */
  19. +static av_always_inline double ff_exp10(double x)
  20. +{
  21. + return exp2(M_LOG2_10 * x);
  22. +}
  23. +
  24. +static av_always_inline float ff_exp10f(float x)
  25. +{
  26. + return exp2f(M_LOG2_10 * x);
  27. +}
  28. +
  29. +/**
  30. + * Compute x^y for floating point x, y. Note: this function is faster than the
  31. + * libm variant due to mainly 2 reasons:
  32. + * 1. It does not handle any edge cases. In particular, this is only guaranteed
  33. + * to work correctly for x > 0.
  34. + * 2. It is not as accurate as a standard nearly "correctly rounded" libm variant.
  35. + * @param x base
  36. + * @param y exponent
  37. + * @return x^y
  38. + */
  39. +static av_always_inline float ff_fast_powf(float x, float y)
  40. +{
  41. + return expf(logf(x) * y);
  42. +}
  43. +
  44. +
  45. +/**
  46. * A wrapper for open() setting O_CLOEXEC.
  47. */
  48. int avpriv_open(const char *filename, int flags, ...);