dca.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_ARM_DCA_H
  21. #define AVCODEC_ARM_DCA_H
  22. #include <stdint.h>
  23. #include "config.h"
  24. #include "libavutil/intmath.h"
  25. #if HAVE_ARMV6 && HAVE_INLINE_ASM
  26. #define decode_blockcodes decode_blockcodes
  27. static inline int decode_blockcodes(int code1, int code2, int levels,
  28. int *values)
  29. {
  30. int v0, v1, v2, v3, v4, v5;
  31. __asm__ ("smmul %8, %14, %18 \n"
  32. "smmul %11, %15, %18 \n"
  33. "smlabb %14, %8, %17, %14 \n"
  34. "smlabb %15, %11, %17, %15 \n"
  35. "smmul %9, %8, %18 \n"
  36. "smmul %12, %11, %18 \n"
  37. "sub %14, %14, %16, lsr #1 \n"
  38. "sub %15, %15, %16, lsr #1 \n"
  39. "smlabb %8, %9, %17, %8 \n"
  40. "smlabb %11, %12, %17, %11 \n"
  41. "smmul %10, %9, %18 \n"
  42. "smmul %13, %12, %18 \n"
  43. "str %14, %0 \n"
  44. "str %15, %4 \n"
  45. "sub %8, %8, %16, lsr #1 \n"
  46. "sub %11, %11, %16, lsr #1 \n"
  47. "smlabb %9, %10, %17, %9 \n"
  48. "smlabb %12, %13, %17, %12 \n"
  49. "smmul %14, %10, %18 \n"
  50. "smmul %15, %13, %18 \n"
  51. "str %8, %1 \n"
  52. "str %11, %5 \n"
  53. "sub %9, %9, %16, lsr #1 \n"
  54. "sub %12, %12, %16, lsr #1 \n"
  55. "smlabb %10, %14, %17, %10 \n"
  56. "smlabb %13, %15, %17, %13 \n"
  57. "str %9, %2 \n"
  58. "str %12, %6 \n"
  59. "sub %10, %10, %16, lsr #1 \n"
  60. "sub %13, %13, %16, lsr #1 \n"
  61. "str %10, %3 \n"
  62. "str %13, %7 \n"
  63. : "=m"(values[0]), "=m"(values[1]),
  64. "=m"(values[2]), "=m"(values[3]),
  65. "=m"(values[4]), "=m"(values[5]),
  66. "=m"(values[6]), "=m"(values[7]),
  67. "=&r"(v0), "=&r"(v1), "=&r"(v2),
  68. "=&r"(v3), "=&r"(v4), "=&r"(v5),
  69. "+&r"(code1), "+&r"(code2)
  70. : "r"(levels - 1), "r"(-levels), "r"(ff_inverse[levels]));
  71. return code1 | code2;
  72. }
  73. #endif
  74. #if HAVE_NEON && HAVE_INLINE_ASM && HAVE_ASM_MOD_Y
  75. #define int8x8_fmul_int32 int8x8_fmul_int32
  76. static inline void int8x8_fmul_int32(float *dst, const int8_t *src, int scale)
  77. {
  78. __asm__ ("vcvt.f32.s32 %2, %2, #4 \n"
  79. "vld1.8 {d0}, [%1,:64] \n"
  80. "vmovl.s8 q0, d0 \n"
  81. "vmovl.s16 q1, d1 \n"
  82. "vmovl.s16 q0, d0 \n"
  83. "vcvt.f32.s32 q0, q0 \n"
  84. "vcvt.f32.s32 q1, q1 \n"
  85. "vmul.f32 q0, q0, %y2 \n"
  86. "vmul.f32 q1, q1, %y2 \n"
  87. "vst1.32 {q0-q1}, [%m0,:128] \n"
  88. : "=Um"(*(float (*)[8])dst)
  89. : "r"(src), "x"(scale)
  90. : "d0", "d1", "d2", "d3");
  91. }
  92. #endif
  93. #endif /* AVCODEC_ARM_DCA_H */