annotate ppc/mpegaudiodec_altivec.c @ 12220:0f635b1f7861 libavcodec

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