1 /*
2 * Altivec optimized MP3 decoding functions
3 * Copyright (c) 2010 Vitor Sessak
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "config.h"
28
29 #if HAVE_ALTIVEC
30
31 #define MACS(rt, ra, rb) rt+=(ra)*(rb)
32 #define MLSS(rt, ra, rb) rt-=(ra)*(rb)
33
34 #define SUM8(op, sum, w, p) \
35 { \
36 op(sum, (w)[0 * 64], (p)[0 * 64]); \
37 op(sum, (w)[1 * 64], (p)[1 * 64]); \
38 op(sum, (w)[2 * 64], (p)[2 * 64]); \
39 op(sum, (w)[3 * 64], (p)[3 * 64]); \
40 op(sum, (w)[4 * 64], (p)[4 * 64]); \
41 op(sum, (w)[5 * 64], (p)[5 * 64]); \
42 op(sum, (w)[6 * 64], (p)[6 * 64]); \
43 op(sum, (w)[7 * 64], (p)[7 * 64]); \
44 }
45
47 const float *win2,
float *sum1,
float *sum2,
int len)
48 {
49 const vector float *win1a = (const vector float *) win1;
50 const vector float *win2a = (const vector float *) win2;
51 const vector float *bufa = (const vector float *) buf;
52 vector float *sum1a = (vector float *) sum1;
53 vector float *sum2a = (vector float *) sum2;
55 vector float v1, v2, v3;
56
57 len = len >> 2;
58
59 #define MULT(a, b) \
60 { \
61 v1 = vec_ld(a, win1a); \
62 v2 = vec_ld(b, win2a); \
63 v3 = vec_ld(a, bufa); \
64 v0 = vec_madd(v3, v1, v0); \
65 v4 = vec_madd(v2, v3, v4); \
66 }
67
68 while (len--) {
70 v4 = vec_xor(v4, v4);
71
72 MULT( 0, 0);
73 MULT( 256, 64);
74 MULT( 512, 128);
75 MULT( 768, 192);
76 MULT(1024, 256);
77 MULT(1280, 320);
78 MULT(1536, 384);
79 MULT(1792, 448);
80
82 vec_st(v4, 0, sum2a);
83 sum1a++;
84 sum2a++;
85 win1a++;
86 win2a++;
87 bufa++;
88 }
89 }
90
91 static void apply_window_mp3(
float *
in,
float *win,
int *unused,
float *
out,
92 int incr)
93 {
98
99 float sum;
100 int j;
101 float *out2 = out + 32 * incr;
102
103 /* copy to avoid wrap */
104 memcpy(in + 512, in, 32 * sizeof(*in));
105
107 apply_window(in + 32, win + 48, win + 640, sumb, sumd, 16);
108
109 SUM8(
MLSS, suma[0], win + 32, in + 48);
110
111 sumc[ 0] = 0;
112 sumb[16] = 0;
113 sumd[16] = 0;
114
115 out[0 ] = suma[ 0];
116 out += incr;
117 out2 -= incr;
118 for(j=1;j<16;j++) {
119 *out = suma[ j] - sumd[16-j];
120 *out2 = -sumb[16-j] - sumc[ j];
121 out += incr;
122 out2 -= incr;
123 }
124
125 sum = 0;
126 SUM8(
MLSS, sum, win + 16 + 32, in + 32);
127 *out = sum;
128 }
129
130 #endif /* HAVE_ALTIVEC */
131
133 {
134 #if HAVE_ALTIVEC
136 #endif /* HAVE_ALTIVEC */
137 }