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.

49 lines
1.6KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg 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.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "libavutil/libm.h"
  19. #include "libavcodec/celp_math.c"
  20. int main(void)
  21. {
  22. int i;
  23. const float f1[3] = {0.0, 1.1, 2.2};
  24. const float f2[3] = {3.3, 4.4, 5.5};
  25. const int16_t i1[3] = {6, 7, 8};
  26. const int16_t i2[3] = {9, 10, 11};
  27. float diff, largest, absa, absb;
  28. float r = ff_dot_productf(f1, f2, FF_ARRAY_ELEMS(f1));
  29. int64_t d = ff_dot_product(i1, i2, FF_ARRAY_ELEMS(i1));
  30. # define IsAlmostEqual(A, B, epsilon) \
  31. diff = fabsf(A - B); \
  32. absa = fabsf(A); \
  33. absb = fabsf(B); \
  34. largest = (absb > absa) ? absb : absa; \
  35. av_assert0(diff <= largest * epsilon);
  36. IsAlmostEqual(16.94f, r, 0.000001f);
  37. av_assert0(212 == d);
  38. for (i = 1024; i >= 1; i/=2)
  39. av_assert0(ff_log2_q15(i) == (1<<15)*((int)log2(i))+(1<<2));
  40. return 0;
  41. }