FFmpeg
4.0
libavcodec
ppc
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
23
#include "
libavutil/attributes.h
"
24
#include "
libavutil/cpu.h
"
25
#include "
libavutil/ppc/cpu.h
"
26
#include "
libavutil/ppc/util_altivec.h
"
27
28
#include "
libavcodec/lossless_audiodsp.h
"
29
30
#if HAVE_BIGENDIAN
31
#define GET_T(tt0,tt1,src,a,b){ \
32
a = vec_ld(16, src); \
33
tt0 = vec_perm(b, a, align); \
34
b = vec_ld(32, src); \
35
tt1 = vec_perm(a, b, align); \
36
}
37
#else
38
#define GET_T(tt0,tt1,src,a,b){ \
39
tt0 = vec_vsx_ld(0, src); \
40
tt1 = vec_vsx_ld(16, src); \
41
}
42
#endif
43
44
#if HAVE_ALTIVEC
45
static
int32_t
scalarproduct_and_madd_int16_altivec(int16_t *v1,
46
const
int16_t *v2,
47
const
int16_t *v3,
48
int
order,
int
mul)
49
{
50
LOAD_ZERO
;
51
vec_s16
*pv1 = (
vec_s16
*) v1;
52
register
vec_s16
muls = { mul, mul, mul, mul, mul, mul, mul, mul };
53
register
vec_s16
t0
,
t1
, i0, i1, i4, i2, i3;
54
register
vec_s32
res =
zero_s32v
;
55
#if HAVE_BIGENDIAN
56
register
vec_u8
align
= vec_lvsl(0, v2);
57
i2 = vec_ld(0, v2);
58
i3 = vec_ld(0, v3);
59
#endif
60
int32_t
ires;
61
62
order >>= 4;
63
do
{
64
GET_T
(t0,t1,v2,i1,i2);
65
i0 = pv1[0];
66
i1 = pv1[1];
67
res = vec_msum(t0, i0, res);
68
res = vec_msum(t1, i1, res);
69
GET_T
(t0,t1,v3,i4,i3);
70
pv1[0] = vec_mladd(t0, muls, i0);
71
pv1[1] = vec_mladd(t1, muls, i1);
72
pv1 += 2;
73
v2 += 16;
74
v3 += 16;
75
}
while
(--order);
76
res = vec_splat(vec_sums(res,
zero_s32v
), 3);
77
vec_ste(res, 0, &ires);
78
79
return
ires;
80
}
81
#endif
/* HAVE_ALTIVEC */
82
83
av_cold
void
ff_llauddsp_init_ppc
(
LLAudDSPContext
*
c
)
84
{
85
#if HAVE_ALTIVEC
86
if
(!
PPC_ALTIVEC
(
av_get_cpu_flags
()))
87
return
;
88
89
c->
scalarproduct_and_madd_int16
= scalarproduct_and_madd_int16_altivec;
90
#endif
/* HAVE_ALTIVEC */
91
}
cpu.h
ff_llauddsp_init_ppc
av_cold void ff_llauddsp_init_ppc(LLAudDSPContext *c)
Definition:
lossless_audiodsp_altivec.c:83
vec_s32
#define vec_s32
Definition:
util_altivec.h:39
LOAD_ZERO
#define LOAD_ZERO
Definition:
util_altivec.h:45
zero_s32v
#define zero_s32v
Definition:
util_altivec.h:52
attributes.h
Macro definitions for various function/variable attributes.
av_cold
#define av_cold
Definition:
attributes.h:82
t0
#define t0
Definition:
regdef.h:28
vec_s16
#define vec_s16
Definition:
util_altivec.h:37
LLAudDSPContext
Definition:
lossless_audiodsp.h:28
PPC_ALTIVEC
#define PPC_ALTIVEC(flags)
Definition:
cpu.h:25
t1
#define t1
Definition:
regdef.h:29
lossless_audiodsp.h
int32_t
int32_t
Definition:
audio_convert.c:194
LLAudDSPContext::scalarproduct_and_madd_int16
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.
Definition:
lossless_audiodsp.h:35
vec_u8
#define vec_u8
Definition:
util_altivec.h:34
align
const AVS_VideoInfo int align
Definition:
avisynth_c.h:795
cpu.h
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition:
cpu.c:93
util_altivec.h
Contains misc utility macros and inline functions.
c
static double c[64]
Definition:
vsrc_mptestsrc.c:87
GET_T
#define GET_T(tt0, tt1, src, a, b)
Definition:
lossless_audiodsp_altivec.c:38
Generated on Tue May 22 2018 07:06:39 for FFmpeg by
1.8.13