comparison libmpeg2/libmpeg-0.4.0.diff @ 13864:96259a2f2142

enable mmx support on x86_64 in libmpeg2
author aurel
date Wed, 03 Nov 2004 17:12:01 +0000
parents 456a348bd973
children 4d64117768b1
comparison
equal deleted inserted replaced
13863:2233c999dce1 13864:96259a2f2142
1 diff -ur libmpeg2/attributes.h libmpeg2/attributes.h 1 diff -Naur libmpeg2.orig/attributes.h libmpeg2/attributes.h
2 --- libmpeg2/attributes.h 2003-01-09 08:48:40.000000000 +0100 2 --- libmpeg2.orig/attributes.h 2004-11-03 17:24:16.587788552 +0100
3 +++ libmpeg2/attributes.h 2004-08-25 20:59:47.000000000 +0200 3 +++ libmpeg2/attributes.h 2004-11-03 17:24:03.014851952 +0100
4 @@ -25,7 +25,7 @@ 4 @@ -25,7 +25,7 @@
5 #ifdef ATTRIBUTE_ALIGNED_MAX 5 #ifdef ATTRIBUTE_ALIGNED_MAX
6 #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) 6 #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
7 #else 7 #else
8 -#define ATTR_ALIGN(align) 8 -#define ATTR_ALIGN(align)
9 +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((16 < align) ? 16 : align))) 9 +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((16 < align) ? 16 : align)))
10 #endif 10 #endif
11 11
12 #ifdef HAVE_BUILTIN_EXPECT 12 #ifdef HAVE_BUILTIN_EXPECT
13 diff -ur libmpeg2/cpu_accel.c libmpeg2/cpu_accel.c 13 diff -Naur libmpeg2.orig/cpu_accel.c libmpeg2/cpu_accel.c
14 --- libmpeg2/cpu_accel.c 2003-10-06 04:31:52.000000000 +0200 14 --- libmpeg2.orig/cpu_accel.c 2004-11-03 17:24:16.587788552 +0100
15 +++ libmpeg2/cpu_accel.c 2004-08-15 15:37:41.000000000 +0200 15 +++ libmpeg2/cpu_accel.c 2004-11-03 17:28:33.052799944 +0100
16 @@ -108,7 +108,7 @@ 16 @@ -30,7 +30,7 @@
17 } 17 #include "mpeg2_internal.h"
18 #endif /* ARCH_X86 */ 18
19 #ifdef ACCEL_DETECT
20 -#ifdef ARCH_X86
21 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
22 static inline uint32_t arch_accel (void)
23 {
24 uint32_t eax, ebx, ecx, edx;
25 @@ -106,9 +106,9 @@
26
27 return caps;
28 }
29 -#endif /* ARCH_X86 */
30 +#endif /* ARCH_X86 || ARCH_X86_64 */
19 31
20 -#if defined(ARCH_PPC) || defined(ARCH_SPARC) 32 -#if defined(ARCH_PPC) || defined(ARCH_SPARC)
21 +#if defined(ARCH_PPC) || (defined(ARCH_SPARC) && defined(HAVE_VIS)) 33 +#if defined(ARCH_PPC) || (defined(ARCH_SPARC) && defined(HAVE_VIS))
22 #include <signal.h> 34 #include <signal.h>
23 #include <setjmp.h> 35 #include <setjmp.h>
38 + return MPEG2_ACCEL_ALPHA; 50 + return MPEG2_ACCEL_ALPHA;
39 +#endif 51 +#endif
40 } 52 }
41 #endif /* ARCH_ALPHA */ 53 #endif /* ARCH_ALPHA */
42 #endif /* ACCEL_DETECT */ 54 #endif /* ACCEL_DETECT */
43 diff -ur libmpeg2/cpu_state.c libmpeg2/cpu_state.c 55 @@ -212,7 +216,7 @@
44 --- libmpeg2/cpu_state.c 2003-08-21 10:00:49.000000000 +0200 56
45 +++ libmpeg2/cpu_state.c 2004-08-02 13:27:37.000000000 +0200 57 accel = 0;
46 @@ -120,7 +120,7 @@ 58 #ifdef ACCEL_DETECT
59 -#if defined (ARCH_X86) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
60 +#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
61 accel = arch_accel ();
62 #endif
63 #endif
64 diff -Naur libmpeg2.orig/cpu_state.c libmpeg2/cpu_state.c
65 --- libmpeg2.orig/cpu_state.c 2004-11-03 17:24:16.587788552 +0100
66 +++ libmpeg2/cpu_state.c 2004-11-03 17:28:33.052799944 +0100
67 @@ -29,14 +29,14 @@
68 #include "mpeg2.h"
69 #include "attributes.h"
70 #include "mpeg2_internal.h"
71 -#ifdef ARCH_X86
72 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
73 #include "mmx.h"
74 #endif
75
76 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
77 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
78
79 -#ifdef ARCH_X86
80 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
81 static void state_restore_mmx (cpu_state_t * state)
82 {
83 emms ();
84 @@ -115,12 +115,12 @@
85
86 void mpeg2_cpu_state_init (uint32_t accel)
87 {
88 -#ifdef ARCH_X86
89 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
90 if (accel & MPEG2_ACCEL_X86_MMX) {
47 mpeg2_cpu_state_restore = state_restore_mmx; 91 mpeg2_cpu_state_restore = state_restore_mmx;
48 } 92 }
49 #endif 93 #endif
50 -#ifdef ARCH_PPC 94 -#ifdef ARCH_PPC
51 +#if defined(ARCH_PPC) && defined(HAVE_ALTIVEC) 95 +#if defined(ARCH_PPC) && defined(HAVE_ALTIVEC)
52 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) { 96 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
53 mpeg2_cpu_state_save = state_save_altivec; 97 mpeg2_cpu_state_save = state_save_altivec;
54 mpeg2_cpu_state_restore = state_restore_altivec; 98 mpeg2_cpu_state_restore = state_restore_altivec;
55 diff -ur libmpeg2/decode.c libmpeg2/decode.c 99 diff -Naur libmpeg2.orig/decode.c libmpeg2/decode.c
56 --- libmpeg2/decode.c 2003-12-22 12:59:34.000000000 +0100 100 --- libmpeg2.orig/decode.c 2004-11-03 17:24:16.588788400 +0100
57 +++ libmpeg2/decode.c 2004-08-02 13:27:37.000000000 +0200 101 +++ libmpeg2/decode.c 2004-11-03 17:24:03.015851800 +0100
58 @@ -351,6 +351,15 @@ 102 @@ -351,6 +351,15 @@
59 fbuf->buf[1] = buf[1]; 103 fbuf->buf[1] = buf[1];
60 fbuf->buf[2] = buf[2]; 104 fbuf->buf[2] = buf[2];
61 fbuf->id = id; 105 fbuf->id = id;
62 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too! 106 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
69 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n", 113 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
70 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]); 114 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
71 } 115 }
72 116
73 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf) 117 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
74 diff -ur libmpeg2/header.c libmpeg2/header.c 118 diff -Naur libmpeg2.orig/header.c libmpeg2/header.c
75 --- libmpeg2/header.c 2003-12-22 12:24:02.000000000 +0100 119 --- libmpeg2.orig/header.c 2004-11-03 17:24:16.588788400 +0100
76 +++ libmpeg2/header.c 2004-08-24 22:25:07.000000000 +0200 120 +++ libmpeg2/header.c 2004-11-03 17:24:03.015851800 +0100
77 @@ -100,6 +100,9 @@ 121 @@ -100,6 +100,9 @@
78 mpeg2dec->decoder.convert = NULL; 122 mpeg2dec->decoder.convert = NULL;
79 mpeg2dec->decoder.convert_id = NULL; 123 mpeg2dec->decoder.convert_id = NULL;
80 mpeg2dec->picture = mpeg2dec->pictures; 124 mpeg2dec->picture = mpeg2dec->pictures;
81 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t)); 125 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
98 k = mpeg2dec->q_scale_type ? non_linear_scale[i] : (i << 1); 142 k = mpeg2dec->q_scale_type ? non_linear_scale[i] : (i << 1);
99 + decoder->quantizer_scales[i] = k; 143 + decoder->quantizer_scales[i] = k;
100 for (j = 0; j < 64; j++) 144 for (j = 0; j < 64; j++)
101 decoder->quantizer_prescale[index][i][j] = 145 decoder->quantizer_prescale[index][i][j] =
102 k * mpeg2dec->quantizer_matrix[index][j]; 146 k * mpeg2dec->quantizer_matrix[index][j];
103 diff -ur libmpeg2/idct_alpha.c libmpeg2/idct_alpha.c 147 diff -Naur libmpeg2.orig/idct.c libmpeg2/idct.c
104 --- libmpeg2/idct_alpha.c 2003-09-19 11:26:42.000000000 +0200 148 --- libmpeg2.orig/idct.c 2004-11-03 17:24:16.588788400 +0100
105 +++ libmpeg2/idct_alpha.c 2004-08-02 13:27:37.000000000 +0200 149 +++ libmpeg2/idct.c 2004-11-03 17:28:33.052799944 +0100
106 @@ -59,7 +59,7 @@
107 } while (0)
108 #endif
109
110 -static void inline idct_row (int16_t * const block)
111 +static inline void idct_row (int16_t * const block)
112 {
113 uint64_t l, r;
114 int_fast32_t d0, d1, d2, d3;
115 @@ -116,7 +116,7 @@
116 block[7] = (a0 - b0) >> 12;
117 }
118
119 -static void inline idct_col (int16_t * const block)
120 +static inline void idct_col (int16_t * const block)
121 {
122 int_fast32_t d0, d1, d2, d3;
123 int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
124 @@ -157,6 +157,7 @@
125 block[8*7] = (a0 - b0) >> 17;
126 }
127
128 +#ifdef CAN_COMPILE_ALPHA_MVI
129 void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, const int stride)
130 {
131 uint64_t clampmask;
132 @@ -289,6 +290,7 @@
133 stq (p7, dest + 7 * stride);
134 }
135 }
136 +#endif
137
138 void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, const int stride)
139 {
140 diff -ur libmpeg2/idct.c libmpeg2/idct.c
141 --- libmpeg2/idct.c 2003-09-19 11:26:42.000000000 +0200
142 +++ libmpeg2/idct.c 2004-08-02 13:27:37.000000000 +0200
143 @@ -66,7 +66,7 @@ 150 @@ -66,7 +66,7 @@
144 } while (0) 151 } while (0)
145 #endif 152 #endif
146 153
147 -static void inline idct_row (int16_t * const block) 154 -static void inline idct_row (int16_t * const block)
156 -static void inline idct_col (int16_t * const block) 163 -static void inline idct_col (int16_t * const block)
157 +static inline void idct_col (int16_t * const block) 164 +static inline void idct_col (int16_t * const block)
158 { 165 {
159 int d0, d1, d2, d3; 166 int d0, d1, d2, d3;
160 int a0, a1, a2, a3, b0, b1, b2, b3; 167 int a0, a1, a2, a3, b0, b1, b2, b3;
168 @@ -235,7 +235,7 @@
169
170 void mpeg2_idct_init (uint32_t accel)
171 {
172 -#ifdef ARCH_X86
173 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
174 if (accel & MPEG2_ACCEL_X86_MMXEXT) {
175 mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
176 mpeg2_idct_add = mpeg2_idct_add_mmxext;
161 @@ -254,11 +254,14 @@ 177 @@ -254,11 +254,14 @@
162 } else 178 } else
163 #endif 179 #endif
164 #ifdef ARCH_ALPHA 180 #ifdef ARCH_ALPHA
165 +#ifdef CAN_COMPILE_ALPHA_MVI 181 +#ifdef CAN_COMPILE_ALPHA_MVI
172 +#endif 188 +#endif
173 + if (accel & MPEG2_ACCEL_ALPHA) { 189 + if (accel & MPEG2_ACCEL_ALPHA) {
174 int i; 190 int i;
175 191
176 mpeg2_idct_copy = mpeg2_idct_copy_alpha; 192 mpeg2_idct_copy = mpeg2_idct_copy_alpha;
177 diff -ur libmpeg2/motion_comp.c libmpeg2/motion_comp.c 193 diff -Naur libmpeg2.orig/idct_alpha.c libmpeg2/idct_alpha.c
178 --- libmpeg2/motion_comp.c 2003-10-06 04:31:52.000000000 +0200 194 --- libmpeg2.orig/idct_alpha.c 2004-11-03 17:24:16.588788400 +0100
179 +++ libmpeg2/motion_comp.c 2004-08-15 15:37:41.000000000 +0200 195 +++ libmpeg2/idct_alpha.c 2004-11-03 17:24:03.015851800 +0100
196 @@ -59,7 +59,7 @@
197 } while (0)
198 #endif
199
200 -static void inline idct_row (int16_t * const block)
201 +static inline void idct_row (int16_t * const block)
202 {
203 uint64_t l, r;
204 int_fast32_t d0, d1, d2, d3;
205 @@ -116,7 +116,7 @@
206 block[7] = (a0 - b0) >> 12;
207 }
208
209 -static void inline idct_col (int16_t * const block)
210 +static inline void idct_col (int16_t * const block)
211 {
212 int_fast32_t d0, d1, d2, d3;
213 int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
214 @@ -157,6 +157,7 @@
215 block[8*7] = (a0 - b0) >> 17;
216 }
217
218 +#ifdef CAN_COMPILE_ALPHA_MVI
219 void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, const int stride)
220 {
221 uint64_t clampmask;
222 @@ -289,6 +290,7 @@
223 stq (p7, dest + 7 * stride);
224 }
225 }
226 +#endif
227
228 void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, const int stride)
229 {
230 diff -Naur libmpeg2.orig/idct_mmx.c libmpeg2/idct_mmx.c
231 --- libmpeg2.orig/idct_mmx.c 2004-11-03 17:23:30.029866432 +0100
232 +++ libmpeg2/idct_mmx.c 2004-11-03 17:28:33.052799944 +0100
233 @@ -23,7 +23,7 @@
234
235 #include "config.h"
236
237 -#ifdef ARCH_X86
238 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
239
240 #include <inttypes.h>
241
242 diff -Naur libmpeg2.orig/motion_comp.c libmpeg2/motion_comp.c
243 --- libmpeg2.orig/motion_comp.c 2004-11-03 17:26:19.828053184 +0100
244 +++ libmpeg2/motion_comp.c 2004-11-03 17:28:33.053799792 +0100
245 @@ -33,7 +33,7 @@
246
247 void mpeg2_mc_init (uint32_t accel)
248 {
249 -#ifdef ARCH_X86
250 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
251 if (accel & MPEG2_ACCEL_X86_MMXEXT)
252 mpeg2_mc = mpeg2_mc_mmxext;
253 else if (accel & MPEG2_ACCEL_X86_3DNOW)
180 @@ -43,20 +43,24 @@ 254 @@ -43,20 +43,24 @@
181 else 255 else
182 #endif 256 #endif
183 #ifdef ARCH_PPC 257 #ifdef ARCH_PPC
184 +#ifdef HAVE_ALTIVEC 258 +#ifdef HAVE_ALTIVEC
200 #endif 274 #endif
201 +#endif 275 +#endif
202 mpeg2_mc = mpeg2_mc_c; 276 mpeg2_mc = mpeg2_mc_c;
203 } 277 }
204 278
205 diff -ur libmpeg2/mpeg2.h libmpeg2/mpeg2.h 279 diff -Naur libmpeg2.orig/motion_comp_mmx.c libmpeg2/motion_comp_mmx.c
206 --- libmpeg2/mpeg2.h 2003-12-22 13:13:35.000000000 +0100 280 --- libmpeg2.orig/motion_comp_mmx.c 2004-11-03 17:23:30.032865976 +0100
207 +++ libmpeg2/mpeg2.h 2004-08-02 13:27:37.000000000 +0200 281 +++ libmpeg2/motion_comp_mmx.c 2004-11-03 17:28:33.053799792 +0100
282 @@ -23,7 +23,7 @@
283
284 #include "config.h"
285
286 -#ifdef ARCH_X86
287 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
288
289 #include <inttypes.h>
290
291 diff -Naur libmpeg2.orig/mpeg2.h libmpeg2/mpeg2.h
292 --- libmpeg2.orig/mpeg2.h 2004-11-03 17:24:16.589788248 +0100
293 +++ libmpeg2/mpeg2.h 2004-11-03 17:24:03.016851648 +0100
208 @@ -82,6 +82,7 @@ 294 @@ -82,6 +82,7 @@
209 #define PIC_FLAG_COMPOSITE_DISPLAY 32 295 #define PIC_FLAG_COMPOSITE_DISPLAY 32
210 #define PIC_FLAG_SKIP 64 296 #define PIC_FLAG_SKIP 64
211 #define PIC_FLAG_TAGS 128 297 #define PIC_FLAG_TAGS 128
212 +#define PIC_FLAG_REPEAT_FIRST_FIELD 256 298 +#define PIC_FLAG_REPEAT_FIRST_FIELD 256
213 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000 299 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
214 300
215 typedef struct mpeg2_picture_s { 301 typedef struct mpeg2_picture_s {
216 diff -ur libmpeg2/mpeg2_internal.h libmpeg2/mpeg2_internal.h 302 diff -Naur libmpeg2.orig/mpeg2_internal.h libmpeg2/mpeg2_internal.h
217 --- libmpeg2/mpeg2_internal.h 2003-12-22 12:24:02.000000000 +0100 303 --- libmpeg2.orig/mpeg2_internal.h 2004-11-03 17:24:16.590788096 +0100
218 +++ libmpeg2/mpeg2_internal.h 2004-08-24 22:25:07.000000000 +0200 304 +++ libmpeg2/mpeg2_internal.h 2004-11-03 17:24:03.016851648 +0100
219 @@ -144,6 +144,12 @@ 305 @@ -144,6 +144,12 @@
220 int second_field; 306 int second_field;
221 307
222 int mpeg1; 308 int mpeg1;
223 + 309 +
238 + unsigned char *pending_buffer; 324 + unsigned char *pending_buffer;
239 + int pending_length; 325 + int pending_length;
240 }; 326 };
241 327
242 typedef struct { 328 typedef struct {
243 diff -ur libmpeg2/slice.c libmpeg2/slice.c 329 diff -Naur libmpeg2.orig/slice.c libmpeg2/slice.c
244 --- libmpeg2/slice.c 2003-12-22 12:24:02.000000000 +0100 330 --- libmpeg2.orig/slice.c 2004-11-03 17:24:16.591787944 +0100
245 +++ libmpeg2/slice.c 2004-08-24 22:25:07.000000000 +0200 331 +++ libmpeg2/slice.c 2004-11-03 17:24:03.016851648 +0100
246 @@ -142,6 +142,7 @@ 332 @@ -142,6 +142,7 @@
247 333
248 quantizer_scale_code = UBITS (bit_buf, 5); 334 quantizer_scale_code = UBITS (bit_buf, 5);
249 DUMPBITS (bit_buf, bits, 5); 335 DUMPBITS (bit_buf, bits, 5);
250 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code]; 336 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];