13864
|
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
|
13147
|
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
|
|
11
|
|
12 #ifdef HAVE_BUILTIN_EXPECT
|
13864
|
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"
|
|
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;
|
13020
|
28 }
|
13864
|
29 -#endif /* ARCH_X86 */
|
|
30 +#endif /* ARCH_X86 || ARCH_X86_64 */
|
13020
|
31
|
|
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>
|
|
36
|
12937
|
37 @@ -195,6 +195,7 @@
|
|
38 #ifdef ARCH_ALPHA
|
|
39 static inline uint32_t arch_accel (void)
|
|
40 {
|
|
41 +#ifdef CAN_COMPILE_ALPHA_MVI
|
|
42 uint64_t no_mvi;
|
|
43
|
|
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
|
|
52 }
|
|
53 #endif /* ARCH_ALPHA */
|
|
54 #endif /* ACCEL_DETECT */
|
13864
|
55 @@ -212,7 +216,7 @@
|
|
56
|
|
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
|
|
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) {
|
12937
|
91 mpeg2_cpu_state_restore = state_restore_mmx;
|
|
92 }
|
|
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;
|
13864
|
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
|
12937
|
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;
|
|
112 + }
|
|
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]);
|
|
115 }
|
|
116
|
|
117 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
|
13864
|
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
|
12937
|
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);
|
13147
|
143 + decoder->quantizer_scales[i] = k;
|
12937
|
144 for (j = 0; j < 64; j++)
|
|
145 decoder->quantizer_prescale[index][i][j] =
|
|
146 k * mpeg2dec->quantizer_matrix[index][j];
|
13864
|
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
|
|
153
|
|
154 -static void inline idct_row (int16_t * const block)
|
|
155 +static inline void idct_row (int16_t * const block)
|
|
156 {
|
|
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;
|
|
161 }
|
|
162
|
|
163 -static void inline idct_col (int16_t * const block)
|
|
164 +static inline void idct_col (int16_t * const block)
|
|
165 {
|
|
166 int d0, d1, d2, d3;
|
|
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;
|
|
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;
|
|
191
|
|
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
|
12937
|
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 {
|
13864
|
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"
|
12937
|
236
|
13864
|
237 -#ifdef ARCH_X86
|
|
238 +#if defined(ARCH_X86) || defined(ARCH_X86_64)
|
|
239
|
|
240 #include <inttypes.h>
|
12937
|
241
|
13864
|
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)
|
12937
|
248 {
|
13864
|
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)
|
13020
|
254 @@ -43,20 +43,24 @@
|
12937
|
255 else
|
|
256 #endif
|
|
257 #ifdef ARCH_PPC
|
|
258 +#ifdef HAVE_ALTIVEC
|
|
259 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
|
|
260 mpeg2_mc = mpeg2_mc_altivec;
|
|
261 else
|
|
262 #endif
|
|
263 +#endif
|
|
264 #ifdef ARCH_ALPHA
|
|
265 if (accel & MPEG2_ACCEL_ALPHA)
|
|
266 mpeg2_mc = mpeg2_mc_alpha;
|
13020
|
267 else
|
|
268 #endif
|
|
269 #ifdef ARCH_SPARC
|
|
270 +#ifdef HAVE_VIS
|
|
271 if (accel & MPEG2_ACCEL_SPARC_VIS)
|
|
272 mpeg2_mc = mpeg2_mc_vis;
|
|
273 else
|
|
274 #endif
|
|
275 +#endif
|
|
276 mpeg2_mc = mpeg2_mc_c;
|
|
277 }
|
|
278
|
13864
|
279 diff -Naur libmpeg2.orig/motion_comp_mmx.c libmpeg2/motion_comp_mmx.c
|
|
280 --- libmpeg2.orig/motion_comp_mmx.c 2004-11-03 17:23:30.032865976 +0100
|
|
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
|
13147
|
294 @@ -82,6 +82,7 @@
|
|
295 #define PIC_FLAG_COMPOSITE_DISPLAY 32
|
|
296 #define PIC_FLAG_SKIP 64
|
|
297 #define PIC_FLAG_TAGS 128
|
|
298 +#define PIC_FLAG_REPEAT_FIRST_FIELD 256
|
|
299 #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
|
|
300
|
|
301 typedef struct mpeg2_picture_s {
|
13864
|
302 diff -Naur libmpeg2.orig/mpeg2_internal.h libmpeg2/mpeg2_internal.h
|
|
303 --- libmpeg2.orig/mpeg2_internal.h 2004-11-03 17:24:16.590788096 +0100
|
|
304 +++ libmpeg2/mpeg2_internal.h 2004-11-03 17:24:03.016851648 +0100
|
13147
|
305 @@ -144,6 +144,12 @@
|
12937
|
306 int second_field;
|
|
307
|
|
308 int mpeg1;
|
|
309 +
|
|
310 + /* for MPlayer: */
|
13147
|
311 + int quantizer_scales[32];
|
12937
|
312 + int quantizer_scale;
|
|
313 + char* quant_store;
|
|
314 + int quant_stride;
|
|
315 };
|
|
316
|
|
317 typedef struct {
|
13147
|
318 @@ -214,6 +220,10 @@
|
|
319 int8_t q_scale_type, scaled[4];
|
|
320 uint8_t quantizer_matrix[4][64];
|
|
321 uint8_t new_quantizer_matrix[4][64];
|
|
322 +
|
|
323 + /* for MPlayer: */
|
|
324 + unsigned char *pending_buffer;
|
|
325 + int pending_length;
|
|
326 };
|
|
327
|
|
328 typedef struct {
|
13864
|
329 diff -Naur libmpeg2.orig/slice.c libmpeg2/slice.c
|
|
330 --- libmpeg2.orig/slice.c 2004-11-03 17:24:16.591787944 +0100
|
|
331 +++ libmpeg2/slice.c 2004-11-03 17:24:03.016851648 +0100
|
13147
|
332 @@ -142,6 +142,7 @@
|
|
333
|
|
334 quantizer_scale_code = UBITS (bit_buf, 5);
|
|
335 DUMPBITS (bit_buf, bits, 5);
|
|
336 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
|
|
337
|
|
338 decoder->quantizer_matrix[0] =
|
|
339 decoder->quantizer_prescale[0][quantizer_scale_code];
|
|
340 @@ -1564,6 +1565,9 @@
|
12937
|
341
|
|
342 #define NEXT_MACROBLOCK \
|
|
343 do { \
|
|
344 + if(decoder->quant_store) \
|
|
345 + decoder->quant_store[decoder->quant_stride*(decoder->v_offset>>4) \
|
|
346 + +(decoder->offset>>4)] = decoder->quantizer_scale; \
|
|
347 decoder->offset += 16; \
|
|
348 if (decoder->offset == decoder->width) { \
|
|
349 do { /* just so we can use the break statement */ \
|