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.

81 lines
2.6KB

  1. /*
  2. * Copyright (c) 2007 Luca Barbato <lu_zero@gentoo.org>
  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. #include "config.h"
  21. #include "libavutil/attributes.h"
  22. #include "libavutil/cpu.h"
  23. #include "libavutil/ppc/cpu.h"
  24. #include "libavutil/ppc/util_altivec.h"
  25. #include "libavcodec/apedsp.h"
  26. #if HAVE_ALTIVEC && HAVE_BIGENDIAN
  27. static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1,
  28. const int16_t *v2,
  29. const int16_t *v3,
  30. int order, int mul)
  31. {
  32. LOAD_ZERO;
  33. vec_s16 *pv1 = (vec_s16 *) v1;
  34. register vec_s16 muls = { mul, mul, mul, mul, mul, mul, mul, mul };
  35. register vec_s16 t0, t1, i0, i1, i4;
  36. register vec_s16 i2 = vec_ld(0, v2), i3 = vec_ld(0, v3);
  37. register vec_s32 res = zero_s32v;
  38. register vec_u8 align = vec_lvsl(0, v2);
  39. int32_t ires;
  40. order >>= 4;
  41. do {
  42. i1 = vec_ld(16, v2);
  43. t0 = vec_perm(i2, i1, align);
  44. i2 = vec_ld(32, v2);
  45. t1 = vec_perm(i1, i2, align);
  46. i0 = pv1[0];
  47. i1 = pv1[1];
  48. res = vec_msum(t0, i0, res);
  49. res = vec_msum(t1, i1, res);
  50. i4 = vec_ld(16, v3);
  51. t0 = vec_perm(i3, i4, align);
  52. i3 = vec_ld(32, v3);
  53. t1 = vec_perm(i4, i3, align);
  54. pv1[0] = vec_mladd(t0, muls, i0);
  55. pv1[1] = vec_mladd(t1, muls, i1);
  56. pv1 += 2;
  57. v2 += 16;
  58. v3 += 16;
  59. } while (--order);
  60. res = vec_splat(vec_sums(res, zero_s32v), 3);
  61. vec_ste(res, 0, &ires);
  62. return ires;
  63. }
  64. #endif /* HAVE_ALTIVEC && HAVE_BIGENDIAN */
  65. av_cold void ff_apedsp_init_ppc(APEDSPContext *c)
  66. {
  67. #if HAVE_ALTIVEC && HAVE_BIGENDIAN
  68. if (!PPC_ALTIVEC(av_get_cpu_flags()))
  69. return;
  70. c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_altivec;
  71. #endif /* HAVE_ALTIVEC && HAVE_BIGENDIAN */
  72. }