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.

63 lines
1.8KB

  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 integer 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/ppc/types_altivec.h"
  30. #include "libavutil/ppc/util_altivec.h"
  31. #include "libavcodec/dsputil.h"
  32. #include "dsputil_altivec.h"
  33. static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
  34. int order)
  35. {
  36. int i;
  37. LOAD_ZERO;
  38. register vec_s16 vec1;
  39. register vec_s32 res = vec_splat_s32(0), t;
  40. int32_t ires;
  41. for (i = 0; i < order; i += 8) {
  42. vec1 = vec_unaligned_load(v1);
  43. t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
  44. res = vec_sums(t, res);
  45. v1 += 8;
  46. v2 += 8;
  47. }
  48. res = vec_splat(res, 3);
  49. vec_ste(res, 0, &ires);
  50. return ires;
  51. }
  52. av_cold void ff_int_init_altivec(DSPContext *c, AVCodecContext *avctx)
  53. {
  54. c->scalarproduct_int16 = scalarproduct_int16_altivec;
  55. }