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.

102 lines
2.5KB

  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. #include "libavutil/attributes.h"
  26. #include "libavutil/cpu.h"
  27. #include "libavutil/ppc/cpu.h"
  28. #include "libavutil/ppc/util_altivec.h"
  29. #include "libavcodec/audiodsp.h"
  30. #if HAVE_ALTIVEC && HAVE_BIGENDIAN
  31. static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
  32. int order)
  33. {
  34. int i;
  35. LOAD_ZERO;
  36. register vec_s16 vec1;
  37. register vec_s32 res = vec_splat_s32(0), t;
  38. int32_t ires;
  39. for (i = 0; i < order; i += 8) {
  40. vec1 = vec_unaligned_load(v1);
  41. t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
  42. res = vec_sums(t, res);
  43. v1 += 8;
  44. v2 += 8;
  45. }
  46. res = vec_splat(res, 3);
  47. vec_ste(res, 0, &ires);
  48. return ires;
  49. }
  50. #endif /* HAVE_ALTIVEC && HAVE_BIGENDIAN */
  51. #if HAVE_VSX
  52. static int32_t scalarproduct_int16_vsx(const int16_t *v1, const int16_t *v2, int order)
  53. {
  54. int i;
  55. LOAD_ZERO;
  56. register vec_s16 vec1;
  57. register vec_s32 res = vec_splat_s32(0), t;
  58. int32_t ires;
  59. for (i = 0; i < order; i += 8) {
  60. vec1 = vec_vsx_ld(0, v1);
  61. t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
  62. res = vec_sums(t, res);
  63. v1 += 8;
  64. v2 += 8;
  65. }
  66. res = vec_splat(res, 3);
  67. vec_ste(res, 0, &ires);
  68. return ires;
  69. }
  70. #endif /* HAVE_VSX */
  71. av_cold void ff_audiodsp_init_ppc(AudioDSPContext *c)
  72. {
  73. #if HAVE_ALTIVEC && HAVE_BIGENDIAN
  74. if (!PPC_ALTIVEC(av_get_cpu_flags()))
  75. return;
  76. c->scalarproduct_int16 = scalarproduct_int16_altivec;
  77. #endif /* HAVE_ALTIVEC */
  78. #if HAVE_VSX
  79. if (!PPC_VSX(av_get_cpu_flags()))
  80. return;
  81. c->scalarproduct_int16 = scalarproduct_int16_vsx;
  82. #endif /* HAVE_VSX */
  83. }