Mercurial > mplayer.hg
comparison libmpeg2/libmpeg-0.4.1.diff @ 21526:60a39d71e247
sync to libmpeg2-0.4.1
author | henry |
---|---|
date | Sat, 09 Dec 2006 10:34:27 +0000 |
parents | libmpeg2/libmpeg-0.4.0.diff@8c43ea1ea79a |
children | 6bee9fab79f6 |
comparison
equal
deleted
inserted
replaced
21525:329b03d67891 | 21526:60a39d71e247 |
---|---|
1 --- include/attributes.h 2006-06-16 20:12:26.000000000 +0200 | |
2 +++ libmpeg2/attributes.h 2006-06-16 20:12:50.000000000 +0200 | |
3 @@ -25,7 +29,7 @@ | |
4 #ifdef ATTRIBUTE_ALIGNED_MAX | |
5 #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) | |
6 #else | |
7 -#define ATTR_ALIGN(align) | |
8 +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((16 < align) ? 16 : align))) | |
9 #endif | |
10 | |
11 #ifdef HAVE_BUILTIN_EXPECT | |
12 --- libmpeg2/cpu_accel.c 2006-06-16 20:12:26.000000000 +0200 | |
13 +++ libmpeg2/cpu_accel.c 2006-06-16 20:12:50.000000000 +0200 | |
14 @@ -22,6 +26,7 @@ | |
15 */ | |
16 | |
17 #include "config.h" | |
18 +#include "cpudetect.h" | |
19 | |
20 #include <inttypes.h> | |
21 | |
22 @@ -30,9 +35,17 @@ | |
23 #include "mpeg2_internal.h" | |
24 | |
25 #ifdef ACCEL_DETECT | |
26 -#ifdef ARCH_X86 | |
27 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
28 + | |
29 +/* MPlayer imports libmpeg2 as decoder, which detects MMX / 3DNow! | |
30 + * instructions via assembly. However, it is regarded as duplicaed work | |
31 + * in MPlayer, so that we enforce to use MPlayer's implementation. | |
32 + */ | |
33 +#define USE_MPLAYER_CPUDETECT | |
34 + | |
35 static inline uint32_t arch_accel (void) | |
36 { | |
37 +#if !defined(USE_MPLAYER_CPUDETECT) | |
38 uint32_t eax, ebx, ecx, edx; | |
39 int AMD; | |
40 uint32_t caps; | |
41 @@ -105,10 +118,24 @@ | |
42 caps |= MPEG2_ACCEL_X86_MMXEXT; | |
43 | |
44 return caps; | |
45 +#else /* USE_MPLAYER_CPUDETECT: Use MPlayer's cpu capability property */ | |
46 + caps = 0; | |
47 + if (gCpuCaps.hasMMX) | |
48 + caps |= MPEG2_ACCEL_X86_MMX; | |
49 + if (gCpuCaps.hasSSE2) | |
50 + caps |= MPEG2_ACCEL_X86_SSE2; | |
51 + if (gCpuCaps.hasMMX2) | |
52 + caps |= MPEG2_ACCEL_X86_MMXEXT; | |
53 + if (gCpuCaps.has3DNow) | |
54 + caps |= MPEG2_ACCEL_X86_3DNOW; | |
55 + | |
56 + return caps; | |
57 + | |
58 +#endif /* USE_MPLAYER_CPUDETECT */ | |
59 } | |
60 -#endif /* ARCH_X86 */ | |
61 +#endif /* ARCH_X86 || ARCH_X86_64 */ | |
62 | |
63 -#if defined(ARCH_PPC) || defined(ARCH_SPARC) | |
64 +#if defined(ARCH_PPC) || (defined(ARCH_SPARC) && defined(HAVE_VIS)) | |
65 #include <signal.h> | |
66 #include <setjmp.h> | |
67 | |
68 @@ -166,10 +166,10 @@ | |
69 | |
70 canjump = 1; | |
71 | |
72 -#ifdef HAVE_ALTIVEC_H /* gnu */ | |
73 -#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t" | |
74 -#else /* apple */ | |
75 +#if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ ) /* apple */ | |
76 #define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t" | |
77 +#else /* gnu */ | |
78 +#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t" | |
79 #endif | |
80 asm volatile ("mtspr 256, %0\n\t" | |
81 VAND (0, 0, 0) | |
82 @@ -195,6 +222,7 @@ | |
83 #ifdef ARCH_ALPHA | |
84 static inline uint32_t arch_accel (void) | |
85 { | |
86 +#ifdef CAN_COMPILE_ALPHA_MVI | |
87 uint64_t no_mvi; | |
88 | |
89 asm volatile ("amask %1, %0" | |
90 @@ -202,6 +230,9 @@ | |
91 : "rI" (256)); /* AMASK_MVI */ | |
92 return no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA | | |
93 MPEG2_ACCEL_ALPHA_MVI); | |
94 +#else | |
95 + return MPEG2_ACCEL_ALPHA; | |
96 +#endif | |
97 } | |
98 #endif /* ARCH_ALPHA */ | |
99 #endif /* ACCEL_DETECT */ | |
100 @@ -212,7 +243,7 @@ | |
101 | |
102 accel = 0; | |
103 #ifdef ACCEL_DETECT | |
104 -#if defined (ARCH_X86) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC) | |
105 +#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC) | |
106 accel = arch_accel (); | |
107 #endif | |
108 #endif | |
109 --- libmpeg2/cpu_state.c 2006-06-16 20:12:26.000000000 +0200 | |
110 +++ libmpeg2/cpu_state.c 2006-06-16 20:12:50.000000000 +0200 | |
111 @@ -29,14 +33,14 @@ | |
112 #include "mpeg2.h" | |
113 #include "attributes.h" | |
114 #include "mpeg2_internal.h" | |
115 -#ifdef ARCH_X86 | |
116 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
117 #include "mmx.h" | |
118 #endif | |
119 | |
120 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL; | |
121 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL; | |
122 | |
123 -#ifdef ARCH_X86 | |
124 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
125 static void state_restore_mmx (cpu_state_t * state) | |
126 { | |
127 emms (); | |
128 @@ -115,12 +119,12 @@ | |
129 | |
130 void mpeg2_cpu_state_init (uint32_t accel) | |
131 { | |
132 -#ifdef ARCH_X86 | |
133 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
134 if (accel & MPEG2_ACCEL_X86_MMX) { | |
135 mpeg2_cpu_state_restore = state_restore_mmx; | |
136 } | |
137 #endif | |
138 -#ifdef ARCH_PPC | |
139 +#if defined(ARCH_PPC) && defined(HAVE_ALTIVEC) | |
140 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) { | |
141 mpeg2_cpu_state_save = state_save_altivec; | |
142 mpeg2_cpu_state_restore = state_restore_altivec; | |
143 --- libmpeg2/decode.c 2006-06-16 20:12:26.000000000 +0200 | |
144 +++ libmpeg2/decode.c 2006-06-16 20:12:50.000000000 +0200 | |
145 @@ -351,6 +355,15 @@ | |
146 fbuf->buf[1] = buf[1]; | |
147 fbuf->buf[2] = buf[2]; | |
148 fbuf->id = id; | |
149 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too! | |
150 + if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){ | |
151 + mpeg2dec->fbuf[1]->buf[0]=buf[0]; | |
152 + mpeg2dec->fbuf[1]->buf[1]=buf[1]; | |
153 + mpeg2dec->fbuf[1]->buf[2]=buf[2]; | |
154 + mpeg2dec->fbuf[1]->id=NULL; | |
155 + } | |
156 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n", | |
157 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]); | |
158 } | |
159 | |
160 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf) | |
161 --- libmpeg2/header.c 2006-06-16 20:12:26.000000000 +0200 | |
162 +++ libmpeg2/header.c 2006-06-16 20:12:50.000000000 +0200 | |
163 @@ -100,6 +104,9 @@ | |
164 mpeg2dec->decoder.convert = NULL; | |
165 mpeg2dec->decoder.convert_id = NULL; | |
166 mpeg2dec->picture = mpeg2dec->pictures; | |
167 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t)); | |
168 + memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t)); | |
169 + memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t)); | |
170 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf; | |
171 mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf; | |
172 mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf; | |
173 @@ -551,6 +558,7 @@ | |
174 if (!(mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)) { | |
175 picture->nb_fields = (buffer[3] & 2) ? 3 : 2; | |
176 flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0; | |
177 + flags |= (buffer[3] & 2) ? PIC_FLAG_REPEAT_FIRST_FIELD : 0; | |
178 } else | |
179 picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2; | |
180 break; | |
181 @@ -799,6 +807,7 @@ | |
182 mpeg2dec->scaled[index] = mpeg2dec->q_scale_type; | |
183 for (i = 0; i < 32; i++) { | |
184 k = mpeg2dec->q_scale_type ? non_linear_scale[i] : (i << 1); | |
185 + decoder->quantizer_scales[i] = k; | |
186 for (j = 0; j < 64; j++) | |
187 decoder->quantizer_prescale[index][i][j] = | |
188 k * mpeg2dec->quantizer_matrix[index][j]; | |
189 --- libmpeg2/idct.c 2006-06-16 20:12:26.000000000 +0200 | |
190 +++ libmpeg2/idct.c 2006-06-16 20:12:50.000000000 +0200 | |
191 @@ -239,12 +239,15 @@ | |
192 | |
193 void mpeg2_idct_init (uint32_t accel) | |
194 { | |
195 -#ifdef ARCH_X86 | |
196 +#ifdef HAVE_MMX2 | |
197 if (accel & MPEG2_ACCEL_X86_MMXEXT) { | |
198 mpeg2_idct_copy = mpeg2_idct_copy_mmxext; | |
199 mpeg2_idct_add = mpeg2_idct_add_mmxext; | |
200 mpeg2_idct_mmx_init (); | |
201 - } else if (accel & MPEG2_ACCEL_X86_MMX) { | |
202 + } else | |
203 +#endif | |
204 +#ifdef HAVE_MMX | |
205 + if (accel & MPEG2_ACCEL_X86_MMX) { | |
206 mpeg2_idct_copy = mpeg2_idct_copy_mmx; | |
207 mpeg2_idct_add = mpeg2_idct_add_mmx; | |
208 mpeg2_idct_mmx_init (); | |
209 @@ -254,11 +261,14 @@ | |
210 } else | |
211 #endif | |
212 #ifdef ARCH_ALPHA | |
213 +#ifdef CAN_COMPILE_ALPHA_MVI | |
214 if (accel & MPEG2_ACCEL_ALPHA_MVI) { | |
215 mpeg2_idct_copy = mpeg2_idct_copy_mvi; | |
216 mpeg2_idct_add = mpeg2_idct_add_mvi; | |
217 mpeg2_idct_alpha_init (); | |
218 - } else if (accel & MPEG2_ACCEL_ALPHA) { | |
219 + } else | |
220 +#endif | |
221 + if (accel & MPEG2_ACCEL_ALPHA) { | |
222 int i; | |
223 | |
224 mpeg2_idct_copy = mpeg2_idct_copy_alpha; | |
225 --- libmpeg2/idct_alpha.c 2006-06-16 20:12:26.000000000 +0200 | |
226 +++ libmpeg2/idct_alpha.c 2006-06-16 20:12:50.000000000 +0200 | |
227 @@ -157,6 +161,7 @@ | |
228 block[8*7] = (a0 - b0) >> 17; | |
229 } | |
230 | |
231 +#ifdef CAN_COMPILE_ALPHA_MVI | |
232 void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, const int stride) | |
233 { | |
234 uint64_t clampmask; | |
235 @@ -289,6 +294,7 @@ | |
236 stq (p7, dest + 7 * stride); | |
237 } | |
238 } | |
239 +#endif | |
240 | |
241 void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, const int stride) | |
242 { | |
243 --- libmpeg2/idct_mmx.c 2006-06-16 20:12:26.000000000 +0200 | |
244 +++ libmpeg2/idct_mmx.c 2006-06-16 20:12:50.000000000 +0200 | |
245 @@ -23,7 +27,7 @@ | |
246 | |
247 #include "config.h" | |
248 | |
249 -#ifdef ARCH_X86 | |
250 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
251 | |
252 #include <inttypes.h> | |
253 | |
254 --- libmpeg2/motion_comp.c 2006-06-16 20:12:26.000000000 +0200 | |
255 +++ libmpeg2/motion_comp.c 2006-06-16 20:12:50.000000000 +0200 | |
256 @@ -37,16 +37,22 @@ | |
257 | |
258 void mpeg2_mc_init (uint32_t accel) | |
259 { | |
260 -#ifdef ARCH_X86 | |
261 +#ifdef HAVE_MMX2 | |
262 if (accel & MPEG2_ACCEL_X86_MMXEXT) | |
263 mpeg2_mc = mpeg2_mc_mmxext; | |
264 - else if (accel & MPEG2_ACCEL_X86_3DNOW) | |
265 + else | |
266 +#endif | |
267 +#ifdef HAVE_3DNOW | |
268 + if (accel & MPEG2_ACCEL_X86_3DNOW) | |
269 mpeg2_mc = mpeg2_mc_3dnow; | |
270 - else if (accel & MPEG2_ACCEL_X86_MMX) | |
271 + else | |
272 +#endif | |
273 +#ifdef HAVE_MMX | |
274 + if (accel & MPEG2_ACCEL_X86_MMX) | |
275 mpeg2_mc = mpeg2_mc_mmx; | |
276 else | |
277 #endif | |
278 -#ifdef ARCH_PPC | |
279 +#if defined(ARCH_PPC) && defined(HAVE_ALTIVEC) | |
280 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) | |
281 mpeg2_mc = mpeg2_mc_altivec; | |
282 else | |
283 @@ -52,7 +62,7 @@ | |
284 mpeg2_mc = mpeg2_mc_alpha; | |
285 else | |
286 #endif | |
287 -#ifdef ARCH_SPARC | |
288 +#if defined(ARCH_SPARC) && defined(HAVE_VIS) | |
289 if (accel & MPEG2_ACCEL_SPARC_VIS) | |
290 mpeg2_mc = mpeg2_mc_vis; | |
291 else | |
292 --- libmpeg2/motion_comp_mmx.c 2006-06-16 20:12:26.000000000 +0200 | |
293 +++ libmpeg2/motion_comp_mmx.c 2006-06-16 20:12:50.000000000 +0200 | |
294 @@ -23,7 +27,7 @@ | |
295 | |
296 #include "config.h" | |
297 | |
298 -#ifdef ARCH_X86 | |
299 +#if defined(ARCH_X86) || defined(ARCH_X86_64) | |
300 | |
301 #include <inttypes.h> | |
302 | |
303 --- include/mpeg2.h 2006-06-16 20:12:26.000000000 +0200 | |
304 +++ libmpeg2/mpeg2.h 2006-06-16 20:12:50.000000000 +0200 | |
305 @@ -82,6 +86,7 @@ | |
306 #define PIC_FLAG_COMPOSITE_DISPLAY 32 | |
307 #define PIC_FLAG_SKIP 64 | |
308 #define PIC_FLAG_TAGS 128 | |
309 +#define PIC_FLAG_REPEAT_FIRST_FIELD 256 | |
310 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000 | |
311 | |
312 typedef struct mpeg2_picture_s { | |
313 @@ -154,6 +159,7 @@ | |
314 #define MPEG2_ACCEL_X86_MMX 1 | |
315 #define MPEG2_ACCEL_X86_3DNOW 2 | |
316 #define MPEG2_ACCEL_X86_MMXEXT 4 | |
317 +#define MPEG2_ACCEL_X86_SSE2 8 | |
318 #define MPEG2_ACCEL_PPC_ALTIVEC 1 | |
319 #define MPEG2_ACCEL_ALPHA 1 | |
320 #define MPEG2_ACCEL_ALPHA_MVI 2 | |
321 --- libmpeg2/mpeg2_internal.h 2006-06-16 20:12:26.000000000 +0200 | |
322 +++ libmpeg2/mpeg2_internal.h 2006-06-16 20:12:50.000000000 +0200 | |
323 @@ -144,6 +148,12 @@ | |
324 int second_field; | |
325 | |
326 int mpeg1; | |
327 + | |
328 + /* for MPlayer: */ | |
329 + int quantizer_scales[32]; | |
330 + int quantizer_scale; | |
331 + char* quant_store; | |
332 + int quant_stride; | |
333 }; | |
334 | |
335 typedef struct { | |
336 @@ -214,6 +224,10 @@ | |
337 int8_t q_scale_type, scaled[4]; | |
338 uint8_t quantizer_matrix[4][64]; | |
339 uint8_t new_quantizer_matrix[4][64]; | |
340 + | |
341 + /* for MPlayer: */ | |
342 + unsigned char *pending_buffer; | |
343 + int pending_length; | |
344 }; | |
345 | |
346 typedef struct { | |
347 --- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200 | |
348 +++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200 | |
349 @@ -142,6 +146,7 @@ | |
350 | |
351 quantizer_scale_code = UBITS (bit_buf, 5); | |
352 DUMPBITS (bit_buf, bits, 5); | |
353 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code]; | |
354 | |
355 decoder->quantizer_matrix[0] = | |
356 decoder->quantizer_prescale[0][quantizer_scale_code]; | |
357 @@ -1568,6 +1569,18 @@ | |
358 | |
359 #define NEXT_MACROBLOCK \ | |
360 do { \ | |
361 + if(decoder->quant_store) { \ | |
362 + if (decoder->picture_structure == TOP_FIELD) \ | |
363 + decoder->quant_store[2*decoder->quant_stride*(decoder->v_offset>>4) \ | |
364 + +(decoder->offset>>4)] = decoder->quantizer_scale; \ | |
365 + else if (decoder->picture_structure == BOTTOM_FIELD) \ | |
366 + decoder->quant_store[2*decoder->quant_stride*(decoder->v_offset>>4) \ | |
367 + + decoder->quant_stride \ | |
368 + +(decoder->offset>>4)] = decoder->quantizer_scale; \ | |
369 + else \ | |
370 + decoder->quant_store[decoder->quant_stride*(decoder->v_offset>>4) \ | |
371 + +(decoder->offset>>4)] = decoder->quantizer_scale; \ | |
372 + } \ | |
373 decoder->offset += 16; \ | |
374 if (decoder->offset == decoder->width) { \ | |
375 do { /* just so we can use the break statement */ \ |