annotate libmpeg2/idct.c @ 11823:98a40d938b91

10l
author diego
date Wed, 21 Jan 2004 19:59:33 +0000
parents ec04f41e2480
children d0a8810e155c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * idct.c
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
3 * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
7 * See http://libmpeg2.sourceforge.net/ for updates.
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * (at your option) any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
26 #include <stdlib.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
29 #include "mpeg2.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include "mpeg2_internal.h"
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
31 #include "attributes.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 #define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 #define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 #define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 #define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
40 /* idct main entry point */
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
41 void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
42 void (* mpeg2_idct_add) (int last, int16_t * block,
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
43 uint8_t * dest, int stride);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 static uint8_t clip_lut[1024];
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
46 #define CLIP(i) ((clip_lut+384)[(i)])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
48 #if 0
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
49 #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
50 do { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
51 t0 = W0*d0 + W1*d1; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
52 t1 = W0*d1 - W1*d0; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
53 } while (0)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
54 #else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
55 #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
56 do { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
57 int tmp = W0 * (d0 + d1); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
58 t0 = tmp + (W1 - W0) * d1; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
59 t1 = tmp - (W1 + W0) * d0; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
60 } while (0)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
61 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
10392
18ab5081d37d warning fixes
alex
parents: 10269
diff changeset
63 static inline void idct_row (int16_t * const block)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
65 int d0, d1, d2, d3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
66 int a0, a1, a2, a3, b0, b1, b2, b3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
67 int t0, t1, t2, t3;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 /* shortcut */
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
70 if (likely (!(block[1] | ((int32_t *)block)[1] | ((int32_t *)block)[2] |
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
71 ((int32_t *)block)[3]))) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
72 uint32_t tmp = (uint16_t) (block[0] << 3);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
73 tmp |= tmp << 16;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
74 ((int32_t *)block)[0] = tmp;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
75 ((int32_t *)block)[1] = tmp;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
76 ((int32_t *)block)[2] = tmp;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
77 ((int32_t *)block)[3] = tmp;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
81 d0 = (block[0] << 11) + 128;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
82 d1 = block[1];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
83 d2 = block[2] << 11;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
84 d3 = block[3];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
85 t0 = d0 + d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
86 t1 = d0 - d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
87 BUTTERFLY (t2, t3, W6, W2, d3, d1);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
88 a0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
89 a1 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
90 a2 = t1 - t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
91 a3 = t0 - t2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
93 d0 = block[4];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
94 d1 = block[5];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
95 d2 = block[6];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
96 d3 = block[7];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
97 BUTTERFLY (t0, t1, W7, W1, d3, d0);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
98 BUTTERFLY (t2, t3, W3, W5, d1, d2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
99 b0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
100 b3 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
101 t0 -= t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
102 t1 -= t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
103 b1 = ((t0 + t1) * 181) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
104 b2 = ((t0 - t1) * 181) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
105
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
106 block[0] = (a0 + b0) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
107 block[1] = (a1 + b1) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
108 block[2] = (a2 + b2) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
109 block[3] = (a3 + b3) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
110 block[4] = (a3 - b3) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
111 block[5] = (a2 - b2) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
112 block[6] = (a1 - b1) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
113 block[7] = (a0 - b0) >> 8;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115
10392
18ab5081d37d warning fixes
alex
parents: 10269
diff changeset
116 static inline void idct_col (int16_t * const block)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
118 int d0, d1, d2, d3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
119 int a0, a1, a2, a3, b0, b1, b2, b3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
120 int t0, t1, t2, t3;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
122 d0 = (block[8*0] << 11) + 65536;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
123 d1 = block[8*1];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
124 d2 = block[8*2] << 11;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
125 d3 = block[8*3];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
126 t0 = d0 + d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
127 t1 = d0 - d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
128 BUTTERFLY (t2, t3, W6, W2, d3, d1);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
129 a0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
130 a1 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
131 a2 = t1 - t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
132 a3 = t0 - t2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
134 d0 = block[8*4];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
135 d1 = block[8*5];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
136 d2 = block[8*6];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
137 d3 = block[8*7];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
138 BUTTERFLY (t0, t1, W7, W1, d3, d0);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
139 BUTTERFLY (t2, t3, W3, W5, d1, d2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
140 b0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
141 b3 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
142 t0 = (t0 - t2) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
143 t1 = (t1 - t3) >> 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
144 b1 = (t0 + t1) * 181;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
145 b2 = (t0 - t1) * 181;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
146
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
147 block[8*0] = (a0 + b0) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
148 block[8*1] = (a1 + b1) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
149 block[8*2] = (a2 + b2) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
150 block[8*3] = (a3 + b3) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
151 block[8*4] = (a3 - b3) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
152 block[8*5] = (a2 - b2) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
153 block[8*6] = (a1 - b1) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
154 block[8*7] = (a0 - b0) >> 17;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
157 static void mpeg2_idct_copy_c (int16_t * block, uint8_t * dest,
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
158 const int stride)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 for (i = 0; i < 8; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 idct_row (block + 8 * i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 for (i = 0; i < 8; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 idct_col (block + i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 do {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 dest[0] = CLIP (block[0]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 dest[1] = CLIP (block[1]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 dest[2] = CLIP (block[2]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 dest[3] = CLIP (block[3]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 dest[4] = CLIP (block[4]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 dest[5] = CLIP (block[5]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 dest[6] = CLIP (block[6]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 dest[7] = CLIP (block[7]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
176 block[0] = 0; block[1] = 0; block[2] = 0; block[3] = 0;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
177 block[4] = 0; block[5] = 0; block[6] = 0; block[7] = 0;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
178
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 dest += stride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 block += 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 } while (--i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
184 static void mpeg2_idct_add_c (const int last, int16_t * block,
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
185 uint8_t * dest, const int stride)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
189 if (last != 129 || (block[0] & 7) == 4) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
190 for (i = 0; i < 8; i++)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
191 idct_row (block + 8 * i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
192 for (i = 0; i < 8; i++)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
193 idct_col (block + i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
194 do {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
195 dest[0] = CLIP (block[0] + dest[0]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
196 dest[1] = CLIP (block[1] + dest[1]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
197 dest[2] = CLIP (block[2] + dest[2]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
198 dest[3] = CLIP (block[3] + dest[3]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
199 dest[4] = CLIP (block[4] + dest[4]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
200 dest[5] = CLIP (block[5] + dest[5]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
201 dest[6] = CLIP (block[6] + dest[6]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
202 dest[7] = CLIP (block[7] + dest[7]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
203
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
204 block[0] = 0; block[1] = 0; block[2] = 0; block[3] = 0;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
205 block[4] = 0; block[5] = 0; block[6] = 0; block[7] = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
207 dest += stride;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
208 block += 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
209 } while (--i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
210 } else {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
211 int DC;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
212
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
213 DC = (block[0] + 4) >> 3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
214 block[0] = block[63] = 0;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
215 i = 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
216 do {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
217 dest[0] = CLIP (DC + dest[0]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
218 dest[1] = CLIP (DC + dest[1]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
219 dest[2] = CLIP (DC + dest[2]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
220 dest[3] = CLIP (DC + dest[3]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
221 dest[4] = CLIP (DC + dest[4]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
222 dest[5] = CLIP (DC + dest[5]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
223 dest[6] = CLIP (DC + dest[6]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
224 dest[7] = CLIP (DC + dest[7]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
225 dest += stride;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
226 } while (--i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
227 }
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
228 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
230 void mpeg2_idct_init (uint32_t accel)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
231 {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
232 #ifdef ARCH_X86
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
233 if (accel & MPEG2_ACCEL_X86_MMXEXT) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
234 mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
235 mpeg2_idct_add = mpeg2_idct_add_mmxext;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
236 mpeg2_idct_mmx_init ();
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
237 } else if (accel & MPEG2_ACCEL_X86_MMX) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
238 mpeg2_idct_copy = mpeg2_idct_copy_mmx;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
239 mpeg2_idct_add = mpeg2_idct_add_mmx;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
240 mpeg2_idct_mmx_init ();
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
241 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
242 #endif
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
243 #ifdef ARCH_PPC
10269
217eb10b2f2d libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9852
diff changeset
244 #ifdef HAVE_ALTIVEC
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
245 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
246 mpeg2_idct_copy = mpeg2_idct_copy_altivec;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
247 mpeg2_idct_add = mpeg2_idct_add_altivec;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
248 mpeg2_idct_altivec_init ();
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
249 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
250 #endif
10269
217eb10b2f2d libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents: 9852
diff changeset
251 #endif
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
252 #ifdef ARCH_ALPHA
10488
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10392
diff changeset
253 #ifdef CAN_COMPILE_ALPHA_MVI
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
254 if (accel & MPEG2_ACCEL_ALPHA_MVI) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
255 mpeg2_idct_copy = mpeg2_idct_copy_mvi;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
256 mpeg2_idct_add = mpeg2_idct_add_mvi;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
257 mpeg2_idct_alpha_init (0);
10488
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10392
diff changeset
258 } else
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10392
diff changeset
259 #endif
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10392
diff changeset
260 if (accel & MPEG2_ACCEL_ALPHA) {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
261 mpeg2_idct_copy = mpeg2_idct_copy_alpha;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
262 mpeg2_idct_add = mpeg2_idct_add_alpha;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
263 mpeg2_idct_alpha_init (1);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
264 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
265 #endif
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
266 #ifdef LIBMPEG2_MLIB
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
267 if (accel & MPEG2_ACCEL_MLIB) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
268 mpeg2_idct_copy = mpeg2_idct_copy_mlib_non_ieee;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
269 mpeg2_idct_add = (getenv ("MLIB_NON_IEEE") ?
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
270 mpeg2_idct_add_mlib_non_ieee : mpeg2_idct_add_mlib);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
271 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
272 #endif
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
273 {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
274 extern uint8_t mpeg2_scan_norm[64];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
275 extern uint8_t mpeg2_scan_alt[64];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
276 int i, j;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
278 mpeg2_idct_copy = mpeg2_idct_copy_c;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
279 mpeg2_idct_add = mpeg2_idct_add_c;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
280 for (i = -384; i < 640; i++)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
281 clip_lut[i+384] = (i < 0) ? 0 : ((i > 255) ? 255 : i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
282 for (i = 0; i < 64; i++) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
283 j = mpeg2_scan_norm[i];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
284 mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
285 j = mpeg2_scan_alt[i];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
286 mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
287 }
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
288 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 }