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.

85 lines
2.2KB

  1. /*
  2. * simple math operations
  3. * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef AVCODEC_ARM_MATHOPS_H
  22. #define AVCODEC_ARM_MATHOPS_H
  23. #include <stdint.h>
  24. #include "config.h"
  25. #include "libavutil/common.h"
  26. #if HAVE_INLINE_ASM
  27. #if HAVE_ARMV6
  28. #define MULH MULH
  29. static inline av_const int MULH(int a, int b)
  30. {
  31. int r;
  32. __asm__ ("smmul %0, %1, %2" : "=r"(r) : "r"(a), "r"(b));
  33. return r;
  34. }
  35. #endif
  36. #define MLS64(d, a, b) MAC64(d, -(a), b)
  37. #if HAVE_ARMV5TE
  38. /* signed 16x16 -> 32 multiply add accumulate */
  39. # define MAC16(rt, ra, rb) \
  40. __asm__ ("smlabb %0, %1, %2, %0" : "+r"(rt) : "r"(ra), "r"(rb));
  41. /* signed 16x16 -> 32 multiply */
  42. # define MUL16 MUL16
  43. static inline av_const int MUL16(int ra, int rb)
  44. {
  45. int rt;
  46. __asm__ ("smulbb %0, %1, %2" : "=r"(rt) : "r"(ra), "r"(rb));
  47. return rt;
  48. }
  49. #endif
  50. #define mid_pred mid_pred
  51. static inline av_const int mid_pred(int a, int b, int c)
  52. {
  53. int m;
  54. __asm__ (
  55. "mov %0, %2 \n\t"
  56. "cmp %1, %2 \n\t"
  57. "itt gt \n\t"
  58. "movgt %0, %1 \n\t"
  59. "movgt %1, %2 \n\t"
  60. "cmp %1, %3 \n\t"
  61. "it le \n\t"
  62. "movle %1, %3 \n\t"
  63. "cmp %0, %1 \n\t"
  64. "it gt \n\t"
  65. "movgt %0, %1 \n\t"
  66. : "=&r"(m), "+r"(a)
  67. : "r"(b), "r"(c)
  68. : "cc");
  69. return m;
  70. }
  71. #endif /* HAVE_INLINE_ASM */
  72. #endif /* AVCODEC_ARM_MATHOPS_H */