typo fixes
[mplayer/greg.git] / libmpeg2 / libmpeg-0.4.0.diff
blob24d8595275cb62f6c867fc0144893e67fbfc0000
1 diff -Naur libmpeg2.orig/attributes.h libmpeg2/attributes.h
2 --- libmpeg2.orig/attributes.h 2004-11-03 17:24:16.587788552 +0100
3 +++ libmpeg2/attributes.h 2004-11-03 17:24:03.014851952 +0100
4 @@ -25,7 +25,7 @@
5 #ifdef ATTRIBUTE_ALIGNED_MAX
6 #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
7 #else
8 -#define ATTR_ALIGN(align)
9 +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((16 < align) ? 16 : align)))
10 #endif
12 #ifdef HAVE_BUILTIN_EXPECT
13 diff -Naur libmpeg2.orig/cpu_accel.c libmpeg2/cpu_accel.c
14 --- libmpeg2.orig/cpu_accel.c 2004-11-03 17:24:16.587788552 +0100
15 +++ libmpeg2/cpu_accel.c 2004-11-03 17:28:33.052799944 +0100
16 @@ -30,7 +30,7 @@
17 #include "mpeg2_internal.h"
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)
24 uint32_t eax, ebx, ecx, edx;
25 @@ -106,9 +106,9 @@
27 return caps;
29 -#endif /* ARCH_X86 */
30 +#endif /* ARCH_X86 || ARCH_X86_64 */
32 -#if defined(ARCH_PPC) || defined(ARCH_SPARC)
33 +#if defined(ARCH_PPC) || (defined(ARCH_SPARC) && defined(HAVE_VIS))
34 #include <signal.h>
35 #include <setjmp.h>
37 @@ -195,6 +195,7 @@
38 #ifdef ARCH_ALPHA
39 static inline uint32_t arch_accel (void)
41 +#ifdef CAN_COMPILE_ALPHA_MVI
42 uint64_t no_mvi;
44 asm volatile ("amask %1, %0"
45 @@ -202,6 +203,9 @@
46 : "rI" (256)); /* AMASK_MVI */
47 return no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
48 MPEG2_ACCEL_ALPHA_MVI);
49 +#else
50 + return MPEG2_ACCEL_ALPHA;
51 +#endif
53 #endif /* ARCH_ALPHA */
54 #endif /* ACCEL_DETECT */
55 @@ -212,7 +216,7 @@
57 accel = 0;
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
76 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
77 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
79 -#ifdef ARCH_X86
80 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
81 static void state_restore_mmx (cpu_state_t * state)
83 emms ();
84 @@ -115,12 +115,12 @@
86 void mpeg2_cpu_state_init (uint32_t accel)
88 -#ifdef ARCH_X86
89 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
90 if (accel & MPEG2_ACCEL_X86_MMX) {
91 mpeg2_cpu_state_restore = state_restore_mmx;
93 #endif
94 -#ifdef ARCH_PPC
95 +#if defined(ARCH_PPC) && defined(HAVE_ALTIVEC)
96 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
97 mpeg2_cpu_state_save = state_save_altivec;
98 mpeg2_cpu_state_restore = state_restore_altivec;
99 diff -Naur libmpeg2.orig/decode.c libmpeg2/decode.c
100 --- libmpeg2.orig/decode.c 2004-11-03 17:24:16.588788400 +0100
101 +++ libmpeg2/decode.c 2004-11-03 17:24:03.015851800 +0100
102 @@ -351,6 +351,15 @@
103 fbuf->buf[1] = buf[1];
104 fbuf->buf[2] = buf[2];
105 fbuf->id = id;
106 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
107 + if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
108 + mpeg2dec->fbuf[1]->buf[0]=buf[0];
109 + mpeg2dec->fbuf[1]->buf[1]=buf[1];
110 + mpeg2dec->fbuf[1]->buf[2]=buf[2];
111 + mpeg2dec->fbuf[1]->id=NULL;
113 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
114 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
117 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
118 diff -Naur libmpeg2.orig/header.c libmpeg2/header.c
119 --- libmpeg2.orig/header.c 2004-11-03 17:24:16.588788400 +0100
120 +++ libmpeg2/header.c 2004-11-03 17:24:03.015851800 +0100
121 @@ -100,6 +100,9 @@
122 mpeg2dec->decoder.convert = NULL;
123 mpeg2dec->decoder.convert_id = NULL;
124 mpeg2dec->picture = mpeg2dec->pictures;
125 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
126 + memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
127 + memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
128 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
129 mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
130 mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
131 @@ -551,6 +554,7 @@
132 if (!(mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)) {
133 picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
134 flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
135 + flags |= (buffer[3] & 2) ? PIC_FLAG_REPEAT_FIRST_FIELD : 0;
136 } else
137 picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2;
138 break;
139 @@ -799,6 +803,7 @@
140 mpeg2dec->scaled[index] = mpeg2dec->q_scale_type;
141 for (i = 0; i < 32; i++) {
142 k = mpeg2dec->q_scale_type ? non_linear_scale[i] : (i << 1);
143 + decoder->quantizer_scales[i] = k;
144 for (j = 0; j < 64; j++)
145 decoder->quantizer_prescale[index][i][j] =
146 k * mpeg2dec->quantizer_matrix[index][j];
147 diff -Naur libmpeg2.orig/idct.c libmpeg2/idct.c
148 --- libmpeg2.orig/idct.c 2004-11-03 17:24:16.588788400 +0100
149 +++ libmpeg2/idct.c 2004-11-03 17:28:33.052799944 +0100
150 @@ -66,7 +66,7 @@
151 } while (0)
152 #endif
154 -static void inline idct_row (int16_t * const block)
155 +static inline void idct_row (int16_t * const block)
157 int d0, d1, d2, d3;
158 int a0, a1, a2, a3, b0, b1, b2, b3;
159 @@ -119,7 +119,7 @@
160 block[7] = (a0 - b0) >> 12;
163 -static void inline idct_col (int16_t * const block)
164 +static inline void idct_col (int16_t * const block)
166 int d0, d1, d2, d3;
167 int a0, a1, a2, a3, b0, b1, b2, b3;
168 @@ -235,7 +235,7 @@
170 void mpeg2_idct_init (uint32_t accel)
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;
177 @@ -254,11 +254,14 @@
178 } else
179 #endif
180 #ifdef ARCH_ALPHA
181 +#ifdef CAN_COMPILE_ALPHA_MVI
182 if (accel & MPEG2_ACCEL_ALPHA_MVI) {
183 mpeg2_idct_copy = mpeg2_idct_copy_mvi;
184 mpeg2_idct_add = mpeg2_idct_add_mvi;
185 mpeg2_idct_alpha_init ();
186 - } else if (accel & MPEG2_ACCEL_ALPHA) {
187 + } else
188 +#endif
189 + if (accel & MPEG2_ACCEL_ALPHA) {
190 int i;
192 mpeg2_idct_copy = mpeg2_idct_copy_alpha;
193 diff -Naur libmpeg2.orig/idct_alpha.c libmpeg2/idct_alpha.c
194 --- libmpeg2.orig/idct_alpha.c 2004-11-03 17:24:16.588788400 +0100
195 +++ libmpeg2/idct_alpha.c 2004-11-03 17:24:03.015851800 +0100
196 @@ -59,7 +59,7 @@
197 } while (0)
198 #endif
200 -static void inline idct_row (int16_t * const block)
201 +static inline void idct_row (int16_t * const block)
203 uint64_t l, r;
204 int_fast32_t d0, d1, d2, d3;
205 @@ -116,7 +116,7 @@
206 block[7] = (a0 - b0) >> 12;
209 -static void inline idct_col (int16_t * const block)
210 +static inline void idct_col (int16_t * const block)
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;
218 +#ifdef CAN_COMPILE_ALPHA_MVI
219 void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, const int stride)
221 uint64_t clampmask;
222 @@ -289,6 +290,7 @@
223 stq (p7, dest + 7 * stride);
226 +#endif
228 void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, const int stride)
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 @@
235 #include "config.h"
237 -#ifdef ARCH_X86
238 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
240 #include <inttypes.h>
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 @@
247 void mpeg2_mc_init (uint32_t accel)
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)
254 @@ -42,7 +42,7 @@
255 mpeg2_mc = mpeg2_mc_mmx;
256 else
257 #endif
258 -#ifdef ARCH_PPC
259 +#if defined(ARCH_PPC) && defined(HAVE_ALTIVEC)
260 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
261 mpeg2_mc = mpeg2_mc_altivec;
262 else
263 @@ -52,7 +52,7 @@
264 mpeg2_mc = mpeg2_mc_alpha;
265 else
266 #endif
267 -#ifdef ARCH_SPARC
268 +#if defined(ARCH_SPARC) && defined(HAVE_VIS)
269 if (accel & MPEG2_ACCEL_SPARC_VIS)
270 mpeg2_mc = mpeg2_mc_vis;
271 else
272 diff -Naur libmpeg2.orig/motion_comp_mmx.c libmpeg2/motion_comp_mmx.c
273 --- libmpeg2.orig/motion_comp_mmx.c 2004-11-03 17:23:30.032865976 +0100
274 +++ libmpeg2/motion_comp_mmx.c 2004-11-03 17:28:33.053799792 +0100
275 @@ -23,7 +23,7 @@
277 #include "config.h"
279 -#ifdef ARCH_X86
280 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
282 #include <inttypes.h>
284 diff -Naur libmpeg2.orig/mpeg2.h libmpeg2/mpeg2.h
285 --- libmpeg2.orig/mpeg2.h 2004-11-03 17:24:16.589788248 +0100
286 +++ libmpeg2/mpeg2.h 2004-11-03 17:24:03.016851648 +0100
287 @@ -82,6 +82,7 @@
288 #define PIC_FLAG_COMPOSITE_DISPLAY 32
289 #define PIC_FLAG_SKIP 64
290 #define PIC_FLAG_TAGS 128
291 +#define PIC_FLAG_REPEAT_FIRST_FIELD 256
292 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
294 typedef struct mpeg2_picture_s {
295 diff -Naur libmpeg2.orig/mpeg2_internal.h libmpeg2/mpeg2_internal.h
296 --- libmpeg2.orig/mpeg2_internal.h 2004-11-03 17:24:16.590788096 +0100
297 +++ libmpeg2/mpeg2_internal.h 2004-11-03 17:24:03.016851648 +0100
298 @@ -144,6 +144,12 @@
299 int second_field;
301 int mpeg1;
303 + /* for MPlayer: */
304 + int quantizer_scales[32];
305 + int quantizer_scale;
306 + char* quant_store;
307 + int quant_stride;
310 typedef struct {
311 @@ -214,6 +220,10 @@
312 int8_t q_scale_type, scaled[4];
313 uint8_t quantizer_matrix[4][64];
314 uint8_t new_quantizer_matrix[4][64];
316 + /* for MPlayer: */
317 + unsigned char *pending_buffer;
318 + int pending_length;
321 typedef struct {
322 diff -Naur libmpeg2.orig/slice.c libmpeg2/slice.c
323 --- libmpeg2.orig/slice.c 2004-11-03 17:24:16.591787944 +0100
324 +++ libmpeg2/slice.c 2004-11-03 17:24:03.016851648 +0100
325 @@ -142,6 +142,7 @@
327 quantizer_scale_code = UBITS (bit_buf, 5);
328 DUMPBITS (bit_buf, bits, 5);
329 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
331 decoder->quantizer_matrix[0] =
332 decoder->quantizer_prescale[0][quantizer_scale_code];
333 @@ -1564,6 +1565,9 @@
335 #define NEXT_MACROBLOCK \
336 do { \
337 + if(decoder->quant_store) \
338 + decoder->quant_store[decoder->quant_stride*(decoder->v_offset>>4) \
339 + +(decoder->offset>>4)] = decoder->quantizer_scale; \
340 decoder->offset += 16; \
341 if (decoder->offset == decoder->width) { \
342 do { /* just so we can use the break statement */ \