FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lossless_audiodsp_altivec.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Luca Barbato <lu_zero@gentoo.org>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg 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  * FFmpeg 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 FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "config.h"
22 #if HAVE_ALTIVEC_H
23 #include <altivec.h>
24 #endif
25 
26 #include "libavutil/attributes.h"
27 #include "libavutil/cpu.h"
28 #include "libavutil/ppc/cpu.h"
31 
32 #if HAVE_ALTIVEC
33 static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1,
34  const int16_t *v2,
35  const int16_t *v3,
36  int order, int mul)
37 {
38  LOAD_ZERO;
39  vec_s16 *pv1 = (vec_s16 *) v1;
40  register vec_s16 muls = { mul, mul, mul, mul, mul, mul, mul, mul };
41  register vec_s16 t0, t1, i0, i1, i4;
42  register vec_s16 i2 = vec_ld(0, v2), i3 = vec_ld(0, v3);
43  register vec_s32 res = zero_s32v;
44  register vec_u8 align = vec_lvsl(0, v2);
45  int32_t ires;
46 
47  order >>= 4;
48  do {
49  i1 = vec_ld(16, v2);
50  t0 = vec_perm(i2, i1, align);
51  i2 = vec_ld(32, v2);
52  t1 = vec_perm(i1, i2, align);
53  i0 = pv1[0];
54  i1 = pv1[1];
55  res = vec_msum(t0, i0, res);
56  res = vec_msum(t1, i1, res);
57  i4 = vec_ld(16, v3);
58  t0 = vec_perm(i3, i4, align);
59  i3 = vec_ld(32, v3);
60  t1 = vec_perm(i4, i3, align);
61  pv1[0] = vec_mladd(t0, muls, i0);
62  pv1[1] = vec_mladd(t1, muls, i1);
63  pv1 += 2;
64  v2 += 16;
65  v3 += 16;
66  } while (--order);
67  res = vec_splat(vec_sums(res, zero_s32v), 3);
68  vec_ste(res, 0, &ires);
69 
70  return ires;
71 }
72 #endif /* HAVE_ALTIVEC */
73 
75 {
76 #if HAVE_ALTIVEC
78  return;
79 
80  c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_altivec;
81 #endif /* HAVE_ALTIVEC */
82 }