annotate libmpeg2/idct.c @ 30342:01ae3b5e504f

Disable all hwaccel glue code from FFmpeg.
author diego
date Thu, 21 Jan 2010 11:16:03 +0000
parents 25337a2147e7
children
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
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
9852
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
26625
5b89b42f6d50 Only compile and use libmpeg2 AltiVec code when AltiVec is available. The
diego
parents: 26619
diff changeset
22 *
27571
fd18fa10de53 libmpeg-0.4.1.diff was renamed to libmpeg2_changes.diff.
diego
parents: 27522
diff changeset
23 * Modified for use with MPlayer, see libmpeg2_changes.diff for the exact changes.
26625
5b89b42f6d50 Only compile and use libmpeg2 AltiVec code when AltiVec is available. The
diego
parents: 26619
diff changeset
24 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
5b89b42f6d50 Only compile and use libmpeg2 AltiVec code when AltiVec is available. The
diego
parents: 26619
diff changeset
25 * $Id$
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
30 #include <stdlib.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #include <inttypes.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
33 #include "mpeg2.h"
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
34 #include "attributes.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 #include "mpeg2_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
37 #define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
38 #define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
39 #define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
40 #define W5 1609 /* 2048 * sqrt (2) * cos (5 * pi / 16) */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
41 #define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
42 #define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
36
846535ace7a2 libmpeg2-0.2.0 merge
arpi_esp
parents: 1
diff changeset
44 /* idct main entry point */
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
45 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
46 void (* mpeg2_idct_add) (int last, int16_t * block,
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
47 uint8_t * dest, int stride);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
49 /*
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
50 * In legal streams, the IDCT output should be between -384 and +384.
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
51 * In corrupted streams, it is possible to force the IDCT output to go
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
52 * to +-3826 - this is the worst case for a column IDCT where the
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
53 * column inputs are 16-bit values.
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
54 */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
55 uint8_t mpeg2_clip[3840 * 2 + 256];
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
56 #define CLIP(i) ((mpeg2_clip + 3840)[i])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
58 #if 0
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
59 #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
60 do { \
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
61 t0 = W0 * d0 + W1 * d1; \
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
62 t1 = W0 * d1 - W1 * d0; \
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
63 } while (0)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
64 #else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
65 #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
66 do { \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
67 int tmp = W0 * (d0 + d1); \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
68 t0 = tmp + (W1 - W0) * d1; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
69 t1 = tmp - (W1 + W0) * d0; \
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
70 } while (0)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
71 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
10392
18ab5081d37d warning fixes
alex
parents: 10269
diff changeset
73 static inline void idct_row (int16_t * const block)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
75 int d0, d1, d2, d3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
76 int a0, a1, a2, a3, b0, b1, b2, b3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
77 int t0, t1, t2, t3;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 /* shortcut */
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
80 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
81 ((int32_t *)block)[3]))) {
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
82 uint32_t tmp = (uint16_t) (block[0] >> 1);
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
83 tmp |= tmp << 16;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
84 ((int32_t *)block)[0] = tmp;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
85 ((int32_t *)block)[1] = tmp;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
86 ((int32_t *)block)[2] = tmp;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
87 ((int32_t *)block)[3] = tmp;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
91 d0 = (block[0] << 11) + 2048;
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
92 d1 = block[1];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
93 d2 = block[2] << 11;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
94 d3 = block[3];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
95 t0 = d0 + d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
96 t1 = d0 - d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
97 BUTTERFLY (t2, t3, W6, W2, d3, d1);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
98 a0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
99 a1 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
100 a2 = t1 - t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
101 a3 = t0 - t2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
103 d0 = block[4];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
104 d1 = block[5];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
105 d2 = block[6];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
106 d3 = block[7];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
107 BUTTERFLY (t0, t1, W7, W1, d3, d0);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
108 BUTTERFLY (t2, t3, W3, W5, d1, d2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
109 b0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
110 b3 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
111 t0 -= t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
112 t1 -= t3;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
113 b1 = ((t0 + t1) >> 8) * 181;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
114 b2 = ((t0 - t1) >> 8) * 181;
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
115
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
116 block[0] = (a0 + b0) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
117 block[1] = (a1 + b1) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
118 block[2] = (a2 + b2) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
119 block[3] = (a3 + b3) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
120 block[4] = (a3 - b3) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
121 block[5] = (a2 - b2) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
122 block[6] = (a1 - b1) >> 12;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
123 block[7] = (a0 - b0) >> 12;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125
10392
18ab5081d37d warning fixes
alex
parents: 10269
diff changeset
126 static inline void idct_col (int16_t * const block)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
128 int d0, d1, d2, d3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
129 int a0, a1, a2, a3, b0, b1, b2, b3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
130 int t0, t1, t2, t3;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
132 d0 = (block[8*0] << 11) + 65536;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
133 d1 = block[8*1];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
134 d2 = block[8*2] << 11;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
135 d3 = block[8*3];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
136 t0 = d0 + d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
137 t1 = d0 - d2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
138 BUTTERFLY (t2, t3, W6, W2, d3, d1);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
139 a0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
140 a1 = t1 + t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
141 a2 = t1 - t3;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
142 a3 = t0 - t2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
144 d0 = block[8*4];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
145 d1 = block[8*5];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
146 d2 = block[8*6];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
147 d3 = block[8*7];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
148 BUTTERFLY (t0, t1, W7, W1, d3, d0);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
149 BUTTERFLY (t2, t3, W3, W5, d1, d2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
150 b0 = t0 + t2;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
151 b3 = t1 + t3;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
152 t0 -= t2;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
153 t1 -= t3;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
154 b1 = ((t0 + t1) >> 8) * 181;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
155 b2 = ((t0 - t1) >> 8) * 181;
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
156
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
157 block[8*0] = (a0 + b0) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
158 block[8*1] = (a1 + b1) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
159 block[8*2] = (a2 + b2) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
160 block[8*3] = (a3 + b3) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
161 block[8*4] = (a3 - b3) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
162 block[8*5] = (a2 - b2) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
163 block[8*6] = (a1 - b1) >> 17;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
164 block[8*7] = (a0 - b0) >> 17;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
167 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
168 const int stride)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 for (i = 0; i < 8; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 idct_row (block + 8 * i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 for (i = 0; i < 8; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 idct_col (block + i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 do {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 dest[0] = CLIP (block[0]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 dest[1] = CLIP (block[1]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 dest[2] = CLIP (block[2]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 dest[3] = CLIP (block[3]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 dest[4] = CLIP (block[4]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 dest[5] = CLIP (block[5]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 dest[6] = CLIP (block[6]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 dest[7] = CLIP (block[7]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
186 ((int32_t *)block)[0] = 0; ((int32_t *)block)[1] = 0;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
187 ((int32_t *)block)[2] = 0; ((int32_t *)block)[3] = 0;
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
188
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 dest += stride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 block += 8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 } while (--i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
194 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
195 uint8_t * dest, const int stride)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
199 if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
200 for (i = 0; i < 8; i++)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
201 idct_row (block + 8 * i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
202 for (i = 0; i < 8; i++)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
203 idct_col (block + i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
204 do {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
205 dest[0] = CLIP (block[0] + dest[0]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
206 dest[1] = CLIP (block[1] + dest[1]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
207 dest[2] = CLIP (block[2] + dest[2]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
208 dest[3] = CLIP (block[3] + dest[3]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
209 dest[4] = CLIP (block[4] + dest[4]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
210 dest[5] = CLIP (block[5] + dest[5]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
211 dest[6] = CLIP (block[6] + dest[6]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
212 dest[7] = CLIP (block[7] + dest[7]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
213
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
214 ((int32_t *)block)[0] = 0; ((int32_t *)block)[1] = 0;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
215 ((int32_t *)block)[2] = 0; ((int32_t *)block)[3] = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
217 dest += stride;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
218 block += 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
219 } while (--i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
220 } else {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
221 int DC;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
222
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
223 DC = (block[0] + 64) >> 7;
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
224 block[0] = block[63] = 0;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
225 i = 8;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
226 do {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
227 dest[0] = CLIP (DC + dest[0]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
228 dest[1] = CLIP (DC + dest[1]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
229 dest[2] = CLIP (DC + dest[2]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
230 dest[3] = CLIP (DC + dest[3]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
231 dest[4] = CLIP (DC + dest[4]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
232 dest[5] = CLIP (DC + dest[5]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
233 dest[6] = CLIP (DC + dest[6]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
234 dest[7] = CLIP (DC + dest[7]);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
235 dest += stride;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
236 } while (--i);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
237 }
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
238 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
240 void mpeg2_idct_init (uint32_t accel)
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
241 {
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27979
diff changeset
242 #if HAVE_SSE2
26393
2506f1b0bdbe Backport SSE2-optimized IDCT routines from upstream libmpeg2.
diego
parents: 26282
diff changeset
243 if (accel & MPEG2_ACCEL_X86_SSE2) {
2506f1b0bdbe Backport SSE2-optimized IDCT routines from upstream libmpeg2.
diego
parents: 26282
diff changeset
244 mpeg2_idct_copy = mpeg2_idct_copy_sse2;
2506f1b0bdbe Backport SSE2-optimized IDCT routines from upstream libmpeg2.
diego
parents: 26282
diff changeset
245 mpeg2_idct_add = mpeg2_idct_add_sse2;
2506f1b0bdbe Backport SSE2-optimized IDCT routines from upstream libmpeg2.
diego
parents: 26282
diff changeset
246 mpeg2_idct_mmx_init ();
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
247 } else
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
248 #elif HAVE_MMX2
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
249 if (accel & MPEG2_ACCEL_X86_MMXEXT) {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
250 mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
251 mpeg2_idct_add = mpeg2_idct_add_mmxext;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
252 mpeg2_idct_mmx_init ();
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
253 } else
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
254 #elif HAVE_MMX
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
255 if (accel & MPEG2_ACCEL_X86_MMX) {
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
256 mpeg2_idct_copy = mpeg2_idct_copy_mmx;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
257 mpeg2_idct_add = mpeg2_idct_add_mmx;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
258 mpeg2_idct_mmx_init ();
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
259 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
260 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27979
diff changeset
261 #if HAVE_ALTIVEC
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
262 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
263 mpeg2_idct_copy = mpeg2_idct_copy_altivec;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
264 mpeg2_idct_add = mpeg2_idct_add_altivec;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
265 mpeg2_idct_altivec_init ();
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
266 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
267 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27979
diff changeset
268 #if HAVE_MVI
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
269 if (accel & MPEG2_ACCEL_ALPHA_MVI) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
270 mpeg2_idct_copy = mpeg2_idct_copy_mvi;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
271 mpeg2_idct_add = mpeg2_idct_add_mvi;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
272 mpeg2_idct_alpha_init ();
27522
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
273 } else
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
274 #elif ARCH_ALPHA
1462a44ea6b9 Use preprocessor conditionals to disable CPU-extension-specific code. We cannot
diego
parents: 26625
diff changeset
275 if (accel & MPEG2_ACCEL_ALPHA) {
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
276 int i;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
277
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
278 mpeg2_idct_copy = mpeg2_idct_copy_alpha;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
279 mpeg2_idct_add = mpeg2_idct_add_alpha;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
280 mpeg2_idct_alpha_init ();
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
281 for (i = -3840; i < 3840 + 256; i++)
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
282 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
283 } else
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
284 #endif
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
285 {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
286 int i, j;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
288 mpeg2_idct_copy = mpeg2_idct_copy_c;
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
289 mpeg2_idct_add = mpeg2_idct_add_c;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
290 for (i = -3840; i < 3840 + 256; i++)
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
291 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
9852
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
292 for (i = 0; i < 64; i++) {
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
293 j = mpeg2_scan_norm[i];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
294 mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
295 j = mpeg2_scan_alt[i];
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
296 mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
297 }
47984e3f54ce Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents: 3731
diff changeset
298 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 }