FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
audiodsp.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 /**
22  * @file
23  * miscellaneous audio operations
24  */
25 
26 #include "config.h"
27 #if HAVE_ALTIVEC_H
28 #include <altivec.h>
29 #endif
30 
31 #include "libavutil/attributes.h"
32 #include "libavutil/cpu.h"
33 #include "libavutil/ppc/cpu.h"
36 #include "libavcodec/audiodsp.h"
37 
38 #if HAVE_ALTIVEC
39 
40 static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
41  int order)
42 {
43  int i;
44  LOAD_ZERO;
45  register vec_s16 vec1;
46  register vec_s32 res = vec_splat_s32(0), t;
47  int32_t ires;
48 
49  for (i = 0; i < order; i += 8) {
50  vec1 = vec_unaligned_load(v1);
51  t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
52  res = vec_sums(t, res);
53  v1 += 8;
54  v2 += 8;
55  }
56  res = vec_splat(res, 3);
57  vec_ste(res, 0, &ires);
58 
59  return ires;
60 }
61 
62 #endif /* HAVE_ALTIVEC */
63 
64 #if HAVE_VSX
65 
66 static int32_t scalarproduct_int16_vsx(const int16_t *v1, const int16_t *v2, int order)
67 {
68  int i;
69  LOAD_ZERO;
70  register vec_s16 vec1;
71  register vec_s32 res = vec_splat_s32(0), t;
72  int32_t ires;
73 
74  for (i = 0; i < order; i += 8) {
75  vec1 = vec_vsx_ld(0, v1);
76  t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
77  res = vec_sums(t, res);
78  v1 += 8;
79  v2 += 8;
80  }
81  res = vec_splat(res, 3);
82  vec_ste(res, 0, &ires);
83 
84  return ires;
85 }
86 
87 #endif /* HAVE_VSX */
88 
90 {
91 #if HAVE_ALTIVEC
93  return;
94 
95  c->scalarproduct_int16 = scalarproduct_int16_altivec;
96 #endif /* HAVE_ALTIVEC */
97 
98 #if HAVE_VSX
99  if (!PPC_VSX(av_get_cpu_flags()))
100  return;
101 
102  c->scalarproduct_int16 = scalarproduct_int16_vsx;
103 #endif /* HAVE_VSX */
104 }
#define zero_s32v
Definition: types_altivec.h:45
#define PPC_VSX(flags)
Definition: cpu.h:27
int32_t(* scalarproduct_int16)(const int16_t *v1, const int16_t *v2, int len)
Calculate scalar product of two vectors.
Definition: audiodsp.h:29
#define vec_s32
Definition: types_altivec.h:32
Macro definitions for various function/variable attributes.
#define av_cold
Definition: attributes.h:82
#define vec_s16
Definition: types_altivec.h:30
av_cold void ff_audiodsp_init_ppc(AudioDSPContext *c)
Definition: audiodsp.c:89
#define PPC_ALTIVEC(flags)
Definition: cpu.h:26
#define LOAD_ZERO
Definition: types_altivec.h:38
int32_t
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:89
Contains misc utility macros and inline functions.
static double c[64]