annotate libmpeg2/idct_altivec.c @ 10853:1e04ac498440

force a new line if a message is very long
author pl
date Fri, 12 Sep 2003 15:46:16 +0000
parents aeea70a0e72c
children d0a8810e155c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
1 /*
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
2 * idct_altivec.c
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
5 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
7 * See http://libmpeg2.sourceforge.net/ for updates.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
8 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
9 * mpeg2dec is free software; you can redistribute it and/or modify
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
12 * (at your option) any later version.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
13 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
14 * mpeg2dec is distributed in the hope that it will be useful,
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
17 * GNU General Public License for more details.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
18 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
22 */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
23
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
24 #include "config.h"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
25
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
26 #ifdef ARCH_PPC
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
27
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
28 #ifdef HAVE_ALTIVEC_H
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
29 #include <altivec.h>
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
30 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
31 #include <inttypes.h>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
32
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
33 #include "mpeg2.h"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
34 #include "mpeg2_internal.h"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
35 #include "attributes.h"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
36
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
37 typedef vector signed char vector_s8_t;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
38 typedef vector unsigned char vector_u8_t;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
39 typedef vector signed short vector_s16_t;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
40 typedef vector unsigned short vector_u16_t;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
41 typedef vector signed int vector_s32_t;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
42 typedef vector unsigned int vector_u32_t;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
43
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
44 #if defined(HAVE_ALTIVEC_H) && (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
45 /* work around gcc <3.3 vec_mergel bug */
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
46 static inline vector_s16_t my_vec_mergel (vector_s16_t const A,
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
47 vector_s16_t const B)
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
48 {
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
49 static const vector_u8_t mergel = {
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
50 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
51 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
52 };
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
53 return vec_perm (A, B, mergel);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
54 }
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
55 #undef vec_mergel
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
56 #define vec_mergel my_vec_mergel
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
57 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
58
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
59 #ifdef HAVE_ALTIVEC_H /* gnu */
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
60 #define VEC_S16(a,b,c,d,e,f,g,h) {a, b, c, d, e, f, g, h}
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
61 #else /* apple */
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
62 #define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) (a, b, c, d, e, f, g, h)
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
63 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
64
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
65 static const vector_s16_t constants ATTR_ALIGN(16) =
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
66 VEC_S16 (23170, 13573, 6518, 21895, -23170, -21895, 32, 31);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
67 static const vector_s16_t constants_1 ATTR_ALIGN(16) =
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
68 VEC_S16 (16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
69 static const vector_s16_t constants_2 ATTR_ALIGN(16) =
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
70 VEC_S16 (22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
71 static const vector_s16_t constants_3 ATTR_ALIGN(16) =
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
72 VEC_S16 (21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
73 static const vector_s16_t constants_4 ATTR_ALIGN(16) =
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
74 VEC_S16 (19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722);
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
75
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
76 #define IDCT_HALF \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
77 /* 1st stage */ \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
78 t1 = vec_mradds (a1, vx7, vx1 ); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
79 t8 = vec_mradds (a1, vx1, vec_subs (zero, vx7)); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
80 t7 = vec_mradds (a2, vx5, vx3); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
81 t3 = vec_mradds (ma2, vx3, vx5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
82 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
83 /* 2nd stage */ \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
84 t5 = vec_adds (vx0, vx4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
85 t0 = vec_subs (vx0, vx4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
86 t2 = vec_mradds (a0, vx6, vx2); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
87 t4 = vec_mradds (a0, vx2, vec_subs (zero, vx6)); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
88 t6 = vec_adds (t8, t3); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
89 t3 = vec_subs (t8, t3); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
90 t8 = vec_subs (t1, t7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
91 t1 = vec_adds (t1, t7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
92 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
93 /* 3rd stage */ \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
94 t7 = vec_adds (t5, t2); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
95 t2 = vec_subs (t5, t2); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
96 t5 = vec_adds (t0, t4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
97 t0 = vec_subs (t0, t4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
98 t4 = vec_subs (t8, t3); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
99 t3 = vec_adds (t8, t3); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
100 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
101 /* 4th stage */ \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
102 vy0 = vec_adds (t7, t1); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
103 vy7 = vec_subs (t7, t1); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
104 vy1 = vec_mradds (c4, t3, t5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
105 vy6 = vec_mradds (mc4, t3, t5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
106 vy2 = vec_mradds (c4, t4, t0); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
107 vy5 = vec_mradds (mc4, t4, t0); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
108 vy3 = vec_adds (t2, t6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
109 vy4 = vec_subs (t2, t6);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
110
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
111 #define IDCT \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
112 vector_s16_t vx0, vx1, vx2, vx3, vx4, vx5, vx6, vx7; \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
113 vector_s16_t vy0, vy1, vy2, vy3, vy4, vy5, vy6, vy7; \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
114 vector_s16_t a0, a1, a2, ma2, c4, mc4, zero, bias; \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
115 vector_s16_t t0, t1, t2, t3, t4, t5, t6, t7, t8; \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
116 vector_u16_t shift; \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
117 \
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
118 c4 = vec_splat (constants, 0); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
119 a0 = vec_splat (constants, 1); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
120 a1 = vec_splat (constants, 2); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
121 a2 = vec_splat (constants, 3); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
122 mc4 = vec_splat (constants, 4); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
123 ma2 = vec_splat (constants, 5); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
124 bias = (vector_s16_t)vec_splat ((vector_s32_t)constants, 3); \
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
125 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
126 zero = vec_splat_s16 (0); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
127 shift = vec_splat_u16 (4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
128 \
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
129 vx0 = vec_mradds (vec_sl (block[0], shift), constants_1, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
130 vx1 = vec_mradds (vec_sl (block[1], shift), constants_2, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
131 vx2 = vec_mradds (vec_sl (block[2], shift), constants_3, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
132 vx3 = vec_mradds (vec_sl (block[3], shift), constants_4, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
133 vx4 = vec_mradds (vec_sl (block[4], shift), constants_1, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
134 vx5 = vec_mradds (vec_sl (block[5], shift), constants_4, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
135 vx6 = vec_mradds (vec_sl (block[6], shift), constants_3, zero); \
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
136 vx7 = vec_mradds (vec_sl (block[7], shift), constants_2, zero); \
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
137 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
138 IDCT_HALF \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
139 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
140 vx0 = vec_mergeh (vy0, vy4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
141 vx1 = vec_mergel (vy0, vy4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
142 vx2 = vec_mergeh (vy1, vy5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
143 vx3 = vec_mergel (vy1, vy5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
144 vx4 = vec_mergeh (vy2, vy6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
145 vx5 = vec_mergel (vy2, vy6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
146 vx6 = vec_mergeh (vy3, vy7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
147 vx7 = vec_mergel (vy3, vy7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
148 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
149 vy0 = vec_mergeh (vx0, vx4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
150 vy1 = vec_mergel (vx0, vx4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
151 vy2 = vec_mergeh (vx1, vx5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
152 vy3 = vec_mergel (vx1, vx5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
153 vy4 = vec_mergeh (vx2, vx6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
154 vy5 = vec_mergel (vx2, vx6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
155 vy6 = vec_mergeh (vx3, vx7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
156 vy7 = vec_mergel (vx3, vx7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
157 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
158 vx0 = vec_adds (vec_mergeh (vy0, vy4), bias); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
159 vx1 = vec_mergel (vy0, vy4); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
160 vx2 = vec_mergeh (vy1, vy5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
161 vx3 = vec_mergel (vy1, vy5); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
162 vx4 = vec_mergeh (vy2, vy6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
163 vx5 = vec_mergel (vy2, vy6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
164 vx6 = vec_mergeh (vy3, vy7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
165 vx7 = vec_mergel (vy3, vy7); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
166 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
167 IDCT_HALF \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
168 \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
169 shift = vec_splat_u16 (6); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
170 vx0 = vec_sra (vy0, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
171 vx1 = vec_sra (vy1, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
172 vx2 = vec_sra (vy2, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
173 vx3 = vec_sra (vy3, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
174 vx4 = vec_sra (vy4, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
175 vx5 = vec_sra (vy5, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
176 vx6 = vec_sra (vy6, shift); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
177 vx7 = vec_sra (vy7, shift);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
178
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
179 void mpeg2_idct_copy_altivec (int16_t * const _block, uint8_t * dest,
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
180 const int stride)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
181 {
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
182 vector_s16_t * const block = (vector_s16_t *)_block;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
183 vector_u8_t tmp;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
184
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
185 IDCT
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
186
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
187 #define COPY(dest,src) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
188 tmp = vec_packsu (src, src); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
189 vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
190 vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
191
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
192 COPY (dest, vx0) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
193 COPY (dest, vx1) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
194 COPY (dest, vx2) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
195 COPY (dest, vx3) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
196 COPY (dest, vx4) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
197 COPY (dest, vx5) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
198 COPY (dest, vx6) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
199 COPY (dest, vx7)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
200
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
201 block[0] = block[1] = block[2] = block[3] = zero;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
202 block[4] = block[5] = block[6] = block[7] = zero;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
203 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
204
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
205 void mpeg2_idct_add_altivec (const int last, int16_t * const _block,
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
206 uint8_t * dest, const int stride)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
207 {
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
208 vector_s16_t * const block = (vector_s16_t *)_block;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
209 vector_u8_t tmp;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
210 vector_s16_t tmp2, tmp3;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
211 vector_u8_t perm0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
212 vector_u8_t perm1;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
213 vector_u8_t p0, p1, p;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
214
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
215 IDCT
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
216
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
217 p0 = vec_lvsl (0, dest);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
218 p1 = vec_lvsl (stride, dest);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
219 p = vec_splat_u8 (-1);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
220 perm0 = vec_mergeh (p, p0);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
221 perm1 = vec_mergeh (p, p1);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
222
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
223 #define ADD(dest,src,perm) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
224 /* *(uint64_t *)&tmp = *(uint64_t *)dest; */ \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
225 tmp = vec_ld (0, dest); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
226 tmp2 = (vector_s16_t)vec_perm (tmp, (vector_u8_t)zero, perm); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
227 tmp3 = vec_adds (tmp2, src); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
228 tmp = vec_packsu (tmp3, tmp3); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
229 vec_ste ((vector_u32_t)tmp, 0, (unsigned int *)dest); \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
230 vec_ste ((vector_u32_t)tmp, 4, (unsigned int *)dest);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
231
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
232 ADD (dest, vx0, perm0) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
233 ADD (dest, vx1, perm1) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
234 ADD (dest, vx2, perm0) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
235 ADD (dest, vx3, perm1) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
236 ADD (dest, vx4, perm0) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
237 ADD (dest, vx5, perm1) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
238 ADD (dest, vx6, perm0) dest += stride;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
239 ADD (dest, vx7, perm1)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
240
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
241 block[0] = block[1] = block[2] = block[3] = zero;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
242 block[4] = block[5] = block[6] = block[7] = zero;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
243 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
244
10270
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
245 void mpeg2_idct_altivec_init (void)
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
246 {
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
247 extern uint8_t mpeg2_scan_norm[64];
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
248 extern uint8_t mpeg2_scan_alt[64];
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
249 int i, j;
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
250
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
251 /* the altivec idct uses a transposed input, so we patch scan tables */
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
252 for (i = 0; i < 64; i++) {
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
253 j = mpeg2_scan_norm[i];
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
254 mpeg2_scan_norm[i] = (j >> 3) | ((j & 7) << 3);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
255 j = mpeg2_scan_alt[i];
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
256 mpeg2_scan_alt[i] = (j >> 3) | ((j & 7) << 3);
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
257 }
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
258 }
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
259
aeea70a0e72c libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9857
diff changeset
260 #endif