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
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. */
15 if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
16 accel |= MPEG2_ACCEL_X86_MMX;
19 #endif /* ACCEL_DETECT */
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;
38 #endif /* ARCH_X86 || ARCH_X86_64 */
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)
51 #endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */
55 static uint32_t arch_accel (uint32_t accel)
64 static uint32_t arch_accel (uint32_t accel)
66 if (accel & MPEG2_ACCEL_SPARC_VIS2)
69 #endif /* ARCH_SPARC */
73 static inline uint32_t arch_accel (uint32_t accel)
75 if (accel & MPEG2_ACCEL_ALPHA_MVI)
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);
85 Index: libmpeg2/cpu_state.c
86 ===================================================================
87 --- libmpeg2/cpu_state.c (revision 28324)
88 +++ libmpeg2/cpu_state.c (revision 28325)
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
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)
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;
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
132 fbuf->buf[1] = buf[1];
133 fbuf->buf[2] = buf[2];
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
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;
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)
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) {
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) {
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 ();
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 ();
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) {
212 + if (accel & MPEG2_ACCEL_ALPHA) {
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)
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)
240 #ifdef HAVE_ALTIVEC_H
242 Index: libmpeg2/idct_mmx.c
243 ===================================================================
244 --- libmpeg2/idct_mmx.c (revision 28324)
245 +++ libmpeg2/idct_mmx.c (revision 28325)
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
259 void mpeg2_mc_init (uint32_t accel)
263 if (accel & MPEG2_ACCEL_X86_MMXEXT)
264 mpeg2_mc = mpeg2_mc_mmxext;
265 - else if (accel & MPEG2_ACCEL_X86_3DNOW)
269 + if (accel & MPEG2_ACCEL_X86_3DNOW)
270 mpeg2_mc = mpeg2_mc_3dnow;
271 - else if (accel & MPEG2_ACCEL_X86_MMX)
275 + if (accel & MPEG2_ACCEL_X86_MMX)
276 mpeg2_mc = mpeg2_mc_mmx;
281 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
282 mpeg2_mc = mpeg2_mc_altivec;
287 if (accel & MPEG2_ACCEL_ALPHA)
288 mpeg2_mc = mpeg2_mc_alpha;
293 if (accel & MPEG2_ACCEL_SPARC_VIS)
294 mpeg2_mc = mpeg2_mc_vis;
299 - if (accel & MPEG2_ACCEL_ARM) {
300 + if (accel & MPEG2_ACCEL_ARM)
301 mpeg2_mc = mpeg2_mc_arm;
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)
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)
331 #ifdef HAVE_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)
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)
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)
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
376 /* XXX: stuff due to xine shit */
379 + int quantizer_scales[32];
380 + int quantizer_scale;
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;
405 --- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200
406 +++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200
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 \
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; \
432 + decoder->quant_store[decoder->quant_stride \
433 + * (decoder->v_offset >> 4) \
434 + + (decoder->offset >> 4)] \
435 + = decoder->quantizer_scale; \
437 decoder->offset += 16; \
438 if (decoder->offset == decoder->width) { \
439 do { /* just so we can use the break statement */ \