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_BIGENDIAN
33 #define GET_T(tt0,tt1,src,a,b){ \
34  a = vec_ld(16, src); \
35  tt0 = vec_perm(b, a, align); \
36  b = vec_ld(32, src); \
37  tt1 = vec_perm(a, b, align); \
38  }
39 #else
40 #define GET_T(tt0,tt1,src,a,b){ \
41  tt0 = vec_vsx_ld(0, src); \
42  tt1 = vec_vsx_ld(16, src); \
43  }
44 #endif
45 
46 #if HAVE_ALTIVEC
47 static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1,
48  const int16_t *v2,
49  const int16_t *v3,
50  int order, int mul)
51 {
52  LOAD_ZERO;
53  vec_s16 *pv1 = (vec_s16 *) v1;
54  register vec_s16 muls = { mul, mul, mul, mul, mul, mul, mul, mul };
55  register vec_s16 t0, t1, i0, i1, i4, i2, i3;
56  register vec_s32 res = zero_s32v;
57 #if HAVE_BIGENDIAN
58  register vec_u8 align = vec_lvsl(0, v2);
59  i2 = vec_ld(0, v2);
60  i3 = vec_ld(0, v3);
61 #endif
62  int32_t ires;
63 
64  order >>= 4;
65  do {
66  GET_T(t0,t1,v2,i1,i2);
67  i0 = pv1[0];
68  i1 = pv1[1];
69  res = vec_msum(t0, i0, res);
70  res = vec_msum(t1, i1, res);
71  GET_T(t0,t1,v3,i4,i3);
72  pv1[0] = vec_mladd(t0, muls, i0);
73  pv1[1] = vec_mladd(t1, muls, i1);
74  pv1 += 2;
75  v2 += 16;
76  v3 += 16;
77  } while (--order);
78  res = vec_splat(vec_sums(res, zero_s32v), 3);
79  vec_ste(res, 0, &ires);
80 
81  return ires;
82 }
83 #endif /* HAVE_ALTIVEC */
84 
86 {
87 #if HAVE_ALTIVEC
89  return;
90 
91  c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_altivec;
92 #endif /* HAVE_ALTIVEC */
93 }
#define zero_s32v
Definition: types_altivec.h:45
av_cold void ff_llauddsp_init_ppc(LLAudDSPContext *c)
#define vec_s32
Definition: types_altivec.h:32
Macro definitions for various function/variable attributes.
#define av_cold
Definition: attributes.h:82
#define t0
Definition: regdef.h:28
#define vec_s16
Definition: types_altivec.h:30
#define PPC_ALTIVEC(flags)
Definition: cpu.h:26
#define t1
Definition: regdef.h:29
#define LOAD_ZERO
Definition: types_altivec.h:38
int32_t
const AVS_VideoInfo int align
Definition: avisynth_c.h:658
#define vec_u8
Definition: types_altivec.h:27
int32_t(* scalarproduct_and_madd_int16)(int16_t *v1, const int16_t *v2, const int16_t *v3, int len, int mul)
Calculate scalar product of v1 and v2, and v1[i] += v3[i] * mul.
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:76
static double c[64]
#define GET_T(tt0, tt1, src, a, b)