Configure needs AS to be set for the Makefiles.
[mplayer/glamo.git] / libmpeg2 / libmpeg2_changes.diff
blob5e55453ab147866c942382712f1cb92e8537c7f9
1 --- libmpeg2/cpu_accel.c 2006-06-16 20:12:26.000000000 +0200
2 +++ libmpeg2/cpu_accel.c 2006-06-16 20:12:50.000000000 +0200
3 @@ -29,9 +33,13 @@
4 #include "attributes.h"
5 #include "mpeg2_internal.h"
7 +#include "cpudetect.h"
9 -#if defined(ARCH_X86) || defined(ARCH_X86_64)
10 +#if ARCH_X86 || ARCH_X86_64
11 static inline uint32_t arch_accel (uint32_t accel)
13 +/* Use MPlayer CPU detection instead of libmpeg2 variant. */
14 +#if 0
15 if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
16 accel |= MPEG2_ACCEL_X86_MMX;
18 @@ -124,6 +132,21 @@
19 #endif /* ACCEL_DETECT */
21 return accel;
23 +#else /* 0 */
24 + accel = 0;
25 + if (gCpuCaps.hasMMX)
26 + accel |= MPEG2_ACCEL_X86_MMX;
27 + if (gCpuCaps.hasSSE2)
28 + accel |= MPEG2_ACCEL_X86_SSE2;
29 + if (gCpuCaps.hasMMX2)
30 + accel |= MPEG2_ACCEL_X86_MMXEXT;
31 + if (gCpuCaps.has3DNow)
32 + accel |= MPEG2_ACCEL_X86_3DNOW;
34 + return accel;
36 +#endif /* 0 */
38 #endif /* ARCH_X86 || ARCH_X86_64 */
40 @@ -127,7 +150,7 @@
42 #endif /* ARCH_X86 || ARCH_X86_64 */
44 -#if defined(ACCEL_DETECT) && (defined(ARCH_PPC) || defined(ARCH_SPARC))
45 +#if defined(ACCEL_DETECT) && (ARCH_PPC || ARCH_SPARC)
46 #include <signal.h>
47 #include <setjmp.h>
49 @@ -146,7 +169,7 @@
51 #endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */
53 -#ifdef ARCH_PPC
54 +#if ARCH_PPC
55 static uint32_t arch_accel (uint32_t accel)
57 #ifdef ACCEL_DETECT
58 @@ -183,7 +206,7 @@
60 #endif /* ARCH_PPC */
62 -#ifdef ARCH_SPARC
63 +#if ARCH_SPARC
64 static uint32_t arch_accel (uint32_t accel)
66 if (accel & MPEG2_ACCEL_SPARC_VIS2)
67 @@ -229,7 +252,7 @@
69 #endif /* ARCH_SPARC */
71 -#ifdef ARCH_ALPHA
72 +#if ARCH_ALPHA
73 static inline uint32_t arch_accel (uint32_t accel)
75 if (accel & MPEG2_ACCEL_ALPHA_MVI)
76 @@ -253,7 +276,7 @@
78 uint32_t mpeg2_detect_accel (uint32_t accel)
80 -#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
81 +#if ARCH_X86 || ARCH_X86_64 || ARCH_PPC || ARCH_ALPHA || ARCH_SPARC
82 accel = arch_accel (accel);
83 #endif
84 return accel;
85 Index: libmpeg2/cpu_state.c
86 ===================================================================
87 --- libmpeg2/cpu_state.c (revision 28324)
88 +++ libmpeg2/cpu_state.c (revision 28325)
89 @@ -29,21 +29,21 @@
90 #include "mpeg2.h"
91 #include "attributes.h"
92 #include "mpeg2_internal.h"
93 -#if defined(ARCH_X86) || defined(ARCH_X86_64)
94 +#if ARCH_X86 || ARCH_X86_64
95 #include "mmx.h"
96 #endif
98 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
99 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
101 -#if defined(ARCH_X86) || defined(ARCH_X86_64)
102 +#if ARCH_X86 || ARCH_X86_64
103 static void state_restore_mmx (cpu_state_t * state)
105 emms ();
107 #endif
109 -#ifdef ARCH_PPC
110 +#if ARCH_PPC
111 #if defined(__APPLE_CC__) /* apple */
112 #define LI(a,b) "li r" #a "," #b "\n\t"
113 #define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
114 @@ -115,12 +115,12 @@
116 void mpeg2_cpu_state_init (uint32_t accel)
118 -#if defined(ARCH_X86) || defined(ARCH_X86_64)
119 +#if ARCH_X86 || ARCH_X86_64
120 if (accel & MPEG2_ACCEL_X86_MMX) {
121 mpeg2_cpu_state_restore = state_restore_mmx;
123 #endif
124 -#ifdef ARCH_PPC
125 +#if ARCH_PPC
126 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
127 mpeg2_cpu_state_save = state_save_altivec;
128 mpeg2_cpu_state_restore = state_restore_altivec;
129 --- libmpeg2/decode.c 2006-06-16 20:12:26.000000000 +0200
130 +++ libmpeg2/decode.c 2006-06-16 20:12:50.000000000 +0200
131 @@ -345,6 +349,15 @@
132 fbuf->buf[1] = buf[1];
133 fbuf->buf[2] = buf[2];
134 fbuf->id = id;
135 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
136 + if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
137 + mpeg2dec->fbuf[1]->buf[0]=buf[0];
138 + mpeg2dec->fbuf[1]->buf[1]=buf[1];
139 + mpeg2dec->fbuf[1]->buf[2]=buf[2];
140 + mpeg2dec->fbuf[1]->id=NULL;
142 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
143 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
146 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
147 --- libmpeg2/header.c 2006-06-16 20:12:26.000000000 +0200
148 +++ libmpeg2/header.c 2006-06-16 20:12:50.000000000 +0200
149 @@ -100,6 +104,9 @@
150 mpeg2dec->decoder.convert = NULL;
151 mpeg2dec->decoder.convert_id = NULL;
152 mpeg2dec->picture = mpeg2dec->pictures;
153 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
154 + memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
155 + memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
156 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
157 mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
158 mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
159 @@ -872,6 +879,7 @@
160 mpeg2dec->scaled[idx] = decoder->q_scale_type;
161 for (i = 0; i < 32; i++) {
162 k = decoder->q_scale_type ? non_linear_scale[i] : (i << 1);
163 + decoder->quantizer_scales[i] = k;
164 for (j = 0; j < 64; j++)
165 decoder->quantizer_prescale[idx][i][j] =
166 k * mpeg2dec->quantizer_matrix[idx][j];
167 --- libmpeg2/idct.c (revision 26652)
168 +++ libmpeg2/idct.c (working copy)
169 @@ -235,34 +239,40 @@
171 void mpeg2_idct_init (uint32_t accel)
173 -#ifdef ARCH_X86
174 +#if HAVE_SSE2
175 if (accel & MPEG2_ACCEL_X86_SSE2) {
176 mpeg2_idct_copy = mpeg2_idct_copy_sse2;
177 mpeg2_idct_add = mpeg2_idct_add_sse2;
178 mpeg2_idct_mmx_init ();
179 - } else if (accel & MPEG2_ACCEL_X86_MMXEXT) {
180 + } else
181 +#elif HAVE_MMX2
182 + if (accel & MPEG2_ACCEL_X86_MMXEXT) {
183 mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
184 mpeg2_idct_add = mpeg2_idct_add_mmxext;
185 mpeg2_idct_mmx_init ();
186 - } else if (accel & MPEG2_ACCEL_X86_MMX) {
187 + } else
188 +#elif HAVE_MMX
189 + if (accel & MPEG2_ACCEL_X86_MMX) {
190 mpeg2_idct_copy = mpeg2_idct_copy_mmx;
191 mpeg2_idct_add = mpeg2_idct_add_mmx;
192 mpeg2_idct_mmx_init ();
193 } else
194 #endif
195 -#ifdef ARCH_PPC
196 +#if HAVE_ALTIVEC
197 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
198 mpeg2_idct_copy = mpeg2_idct_copy_altivec;
199 mpeg2_idct_add = mpeg2_idct_add_altivec;
200 mpeg2_idct_altivec_init ();
201 } else
202 #endif
203 -#ifdef ARCH_ALPHA
204 +#if HAVE_MVI
205 if (accel & MPEG2_ACCEL_ALPHA_MVI) {
206 mpeg2_idct_copy = mpeg2_idct_copy_mvi;
207 mpeg2_idct_add = mpeg2_idct_add_mvi;
208 mpeg2_idct_alpha_init ();
209 - } else if (accel & MPEG2_ACCEL_ALPHA) {
210 + } else
211 +#elif ARCH_ALPHA
212 + if (accel & MPEG2_ACCEL_ALPHA) {
213 int i;
215 mpeg2_idct_copy = mpeg2_idct_copy_alpha;
216 Index: libmpeg2/idct_alpha.c
217 ===================================================================
218 --- libmpeg2/idct_alpha.c (revision 28324)
219 +++ libmpeg2/idct_alpha.c (revision 28325)
220 @@ -24,7 +24,7 @@
222 #include "config.h"
224 -#ifdef ARCH_ALPHA
225 +#if ARCH_ALPHA
227 #include <stdlib.h>
228 #include <inttypes.h>
229 Index: libmpeg2/idct_altivec.c
230 ===================================================================
231 --- libmpeg2/idct_altivec.c (revision 28324)
232 +++ libmpeg2/idct_altivec.c (revision 28325)
233 @@ -23,7 +23,7 @@
235 #include "config.h"
237 -#ifdef ARCH_PPC
238 +#if ARCH_PPC
240 #ifdef HAVE_ALTIVEC_H
241 #include <altivec.h>
242 Index: libmpeg2/idct_mmx.c
243 ===================================================================
244 --- libmpeg2/idct_mmx.c (revision 28324)
245 +++ libmpeg2/idct_mmx.c (revision 28325)
246 @@ -23,7 +23,7 @@
248 #include "config.h"
250 -#if defined(ARCH_X86) || defined(ARCH_X86_64)
251 +#if ARCH_X86 || ARCH_X86_64
253 #include <inttypes.h>
255 --- libmpeg2/motion_comp.c 2006-06-16 20:12:26.000000000 +0200
256 +++ libmpeg2/motion_comp.c 2006-06-16 20:12:50.000000000 +0200
257 @@ -33,34 +37,40 @@
259 void mpeg2_mc_init (uint32_t accel)
261 -#ifdef ARCH_X86
262 +#if HAVE_MMX2
263 if (accel & MPEG2_ACCEL_X86_MMXEXT)
264 mpeg2_mc = mpeg2_mc_mmxext;
265 - else if (accel & MPEG2_ACCEL_X86_3DNOW)
266 + else
267 +#endif
268 +#if HAVE_AMD3DNOW
269 + if (accel & MPEG2_ACCEL_X86_3DNOW)
270 mpeg2_mc = mpeg2_mc_3dnow;
271 - else if (accel & MPEG2_ACCEL_X86_MMX)
272 + else
273 +#endif
274 +#if HAVE_MMX
275 + if (accel & MPEG2_ACCEL_X86_MMX)
276 mpeg2_mc = mpeg2_mc_mmx;
277 else
278 #endif
279 -#ifdef ARCH_PPC
280 +#if HAVE_ALTIVEC
281 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
282 mpeg2_mc = mpeg2_mc_altivec;
283 else
284 #endif
285 -#ifdef ARCH_ALPHA
286 +#if ARCH_ALPHA
287 if (accel & MPEG2_ACCEL_ALPHA)
288 mpeg2_mc = mpeg2_mc_alpha;
289 else
290 #endif
291 -#ifdef ARCH_SPARC
292 +#if HAVE_VIS
293 if (accel & MPEG2_ACCEL_SPARC_VIS)
294 mpeg2_mc = mpeg2_mc_vis;
295 else
296 #endif
297 -#ifdef ARCH_ARM
298 +#if ARCH_ARM
299 - if (accel & MPEG2_ACCEL_ARM) {
300 + if (accel & MPEG2_ACCEL_ARM)
301 mpeg2_mc = mpeg2_mc_arm;
302 - } else
303 + else
304 #endif
305 mpeg2_mc = mpeg2_mc_c;
307 Index: libmpeg2/motion_comp_alpha.c
308 ===================================================================
309 --- libmpeg2/motion_comp_alpha.c (revision 28324)
310 +++ libmpeg2/motion_comp_alpha.c (revision 28325)
311 @@ -22,7 +22,7 @@
313 #include "config.h"
315 -#ifdef ARCH_ALPHA
316 +#if ARCH_ALPHA
318 #include <inttypes.h>
320 Index: libmpeg2/motion_comp_altivec.c
321 ===================================================================
322 --- libmpeg2/motion_comp_altivec.c (revision 28324)
323 +++ libmpeg2/motion_comp_altivec.c (revision 28325)
324 @@ -23,7 +23,7 @@
326 #include "config.h"
328 -#ifdef ARCH_PPC
329 +#if ARCH_PPC
331 #ifdef HAVE_ALTIVEC_H
332 #include <altivec.h>
333 Index: libmpeg2/motion_comp_arm.c
334 ===================================================================
335 --- libmpeg2/motion_comp_arm.c (revision 28324)
336 +++ libmpeg2/motion_comp_arm.c (revision 28325)
337 @@ -22,7 +22,7 @@
339 #include "config.h"
341 -#ifdef ARCH_ARM
342 +#if ARCH_ARM
344 #include <inttypes.h>
346 Index: libmpeg2/motion_comp_mmx.c
347 ===================================================================
348 --- libmpeg2/motion_comp_mmx.c (revision 28324)
349 +++ libmpeg2/motion_comp_mmx.c (revision 28325)
350 @@ -23,7 +23,7 @@
352 #include "config.h"
354 -#if defined(ARCH_X86) || defined(ARCH_X86_64)
355 +#if ARCH_X86 || ARCH_X86_64
357 #include <inttypes.h>
359 Index: libmpeg2/motion_comp_vis.c
360 ===================================================================
361 --- libmpeg2/motion_comp_vis.c (revision 28324)
362 +++ libmpeg2/motion_comp_vis.c (revision 28325)
363 @@ -22,7 +22,7 @@
365 #include "config.h"
367 -#ifdef ARCH_SPARC
368 +#if ARCH_SPARC
370 #include <inttypes.h>
372 --- libmpeg2/mpeg2_internal.h 2006-06-16 20:12:26.000000000 +0200
373 +++ libmpeg2/mpeg2_internal.h 2006-06-16 20:12:50.000000000 +0200
374 @@ -152,6 +156,11 @@
376 /* XXX: stuff due to xine shit */
377 int8_t q_scale_type;
379 + int quantizer_scales[32];
380 + int quantizer_scale;
381 + char* quant_store;
382 + int quant_stride;
385 typedef struct {
386 @@ -223,6 +232,9 @@
387 //int8_t q_scale_type, scaled[4];
388 uint8_t quantizer_matrix[4][64];
389 uint8_t new_quantizer_matrix[4][64];
391 + unsigned char *pending_buffer;
392 + int pending_length;
395 typedef struct {
396 @@ -226,7 +238,7 @@
399 typedef struct {
400 -#ifdef ARCH_PPC
401 +#if ARCH_PPC
402 uint8_t regv[12*16];
403 #endif
404 int dummy;
405 --- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200
406 +++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200
407 @@ -142,6 +146,7 @@
409 quantizer_scale_code = UBITS (bit_buf, 5);
410 DUMPBITS (bit_buf, bits, 5);
411 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
413 decoder->quantizer_matrix[0] =
414 decoder->quantizer_prescale[0][quantizer_scale_code];
415 @@ -1564,6 +1569,24 @@
417 #define NEXT_MACROBLOCK \
418 do { \
419 + if(decoder->quant_store) { \
420 + if (decoder->picture_structure == TOP_FIELD) \
421 + decoder->quant_store[2 * decoder->quant_stride \
422 + * (decoder->v_offset >> 4) \
423 + + (decoder->offset >> 4)] \
424 + = decoder->quantizer_scale; \
425 + else if (decoder->picture_structure == BOTTOM_FIELD) \
426 + decoder->quant_store[2 * decoder->quant_stride \
427 + * (decoder->v_offset >> 4) \
428 + + decoder->quant_stride \
429 + + (decoder->offset >> 4)] \
430 + = decoder->quantizer_scale; \
431 + else \
432 + decoder->quant_store[decoder->quant_stride \
433 + * (decoder->v_offset >> 4) \
434 + + (decoder->offset >> 4)] \
435 + = decoder->quantizer_scale; \
436 + } \
437 decoder->offset += 16; \
438 if (decoder->offset == decoder->width) { \
439 do { /* just so we can use the break statement */ \