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.

73 lines
1.9KB

  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. /**
  21. * @file
  22. * miscellaneous audio operations
  23. */
  24. #include "config.h"
  25. #if HAVE_ALTIVEC_H
  26. #include <altivec.h>
  27. #endif
  28. #include "libavutil/attributes.h"
  29. #include "libavutil/cpu.h"
  30. #include "libavutil/ppc/cpu.h"
  31. #include "libavutil/ppc/types_altivec.h"
  32. #include "libavutil/ppc/util_altivec.h"
  33. #include "libavcodec/audiodsp.h"
  34. #if HAVE_ALTIVEC
  35. static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
  36. int order)
  37. {
  38. int i;
  39. LOAD_ZERO;
  40. register vec_s16 vec1;
  41. register vec_s32 res = vec_splat_s32(0), t;
  42. int32_t ires;
  43. for (i = 0; i < order; i += 8) {
  44. vec1 = vec_unaligned_load(v1);
  45. t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
  46. res = vec_sums(t, res);
  47. v1 += 8;
  48. v2 += 8;
  49. }
  50. res = vec_splat(res, 3);
  51. vec_ste(res, 0, &ires);
  52. return ires;
  53. }
  54. #endif /* HAVE_ALTIVEC */
  55. av_cold void ff_audiodsp_init_ppc(AudioDSPContext *c)
  56. {
  57. #if HAVE_ALTIVEC
  58. if (!PPC_ALTIVEC(av_get_cpu_flags()))
  59. return;
  60. c->scalarproduct_int16 = scalarproduct_int16_altivec;
  61. #endif /* HAVE_ALTIVEC */
  62. }