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 static inline uint32_t arch_accel (uint32_t accel)
12 +/* Use MPlayer CPU detection instead of libmpeg2 variant. */
14 if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
15 accel |= MPEG2_ACCEL_X86_MMX;
18 #endif /* ACCEL_DETECT */
24 + if (gCpuCaps.hasMMX)
25 + accel |= MPEG2_ACCEL_X86_MMX;
26 + if (gCpuCaps.hasSSE2)
27 + accel |= MPEG2_ACCEL_X86_SSE2;
28 + if (gCpuCaps.hasMMX2)
29 + accel |= MPEG2_ACCEL_X86_MMXEXT;
30 + if (gCpuCaps.has3DNow)
31 + accel |= MPEG2_ACCEL_X86_3DNOW;
37 #endif /* ARCH_X86 || ARCH_X86_64 */
39 --- libmpeg2/decode.c 2006-06-16 20:12:26.000000000 +0200
40 +++ libmpeg2/decode.c 2006-06-16 20:12:50.000000000 +0200
42 fbuf->buf[1] = buf[1];
43 fbuf->buf[2] = buf[2];
45 + // HACK! FIXME! At first I frame, copy pointers to prediction frame too!
46 + if (mpeg2dec->custom_fbuf && !mpeg2dec->fbuf[1]->buf[0]){
47 + mpeg2dec->fbuf[1]->buf[0]=buf[0];
48 + mpeg2dec->fbuf[1]->buf[1]=buf[1];
49 + mpeg2dec->fbuf[1]->buf[2]=buf[2];
50 + mpeg2dec->fbuf[1]->id=NULL;
52 +// printf("libmpeg2: FBUF 0:%p 1:%p 2:%p\n",
53 +// mpeg2dec->fbuf[0]->buf[0],mpeg2dec->fbuf[1]->buf[0],mpeg2dec->fbuf[2]->buf[0]);
56 void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf)
57 --- libmpeg2/header.c 2006-06-16 20:12:26.000000000 +0200
58 +++ libmpeg2/header.c 2006-06-16 20:12:50.000000000 +0200
60 mpeg2dec->decoder.convert = NULL;
61 mpeg2dec->decoder.convert_id = NULL;
62 mpeg2dec->picture = mpeg2dec->pictures;
63 + memset(&mpeg2dec->fbuf_alloc[0].fbuf, 0, sizeof(mpeg2_fbuf_t));
64 + memset(&mpeg2dec->fbuf_alloc[1].fbuf, 0, sizeof(mpeg2_fbuf_t));
65 + memset(&mpeg2dec->fbuf_alloc[2].fbuf, 0, sizeof(mpeg2_fbuf_t));
66 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf;
67 mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf;
68 mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf;
70 mpeg2dec->scaled[idx] = decoder->q_scale_type;
71 for (i = 0; i < 32; i++) {
72 k = decoder->q_scale_type ? non_linear_scale[i] : (i << 1);
73 + decoder->quantizer_scales[i] = k;
74 for (j = 0; j < 64; j++)
75 decoder->quantizer_prescale[idx][i][j] =
76 k * mpeg2dec->quantizer_matrix[idx][j];
77 --- libmpeg2/idct.c (revision 26652)
78 +++ libmpeg2/idct.c (working copy)
81 void mpeg2_idct_init (uint32_t accel)
85 if (accel & MPEG2_ACCEL_X86_SSE2) {
86 mpeg2_idct_copy = mpeg2_idct_copy_sse2;
87 mpeg2_idct_add = mpeg2_idct_add_sse2;
88 mpeg2_idct_mmx_init ();
89 - } else if (accel & MPEG2_ACCEL_X86_MMXEXT) {
92 + if (accel & MPEG2_ACCEL_X86_MMXEXT) {
93 mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
94 mpeg2_idct_add = mpeg2_idct_add_mmxext;
95 mpeg2_idct_mmx_init ();
96 - } else if (accel & MPEG2_ACCEL_X86_MMX) {
99 + if (accel & MPEG2_ACCEL_X86_MMX) {
100 mpeg2_idct_copy = mpeg2_idct_copy_mmx;
101 mpeg2_idct_add = mpeg2_idct_add_mmx;
102 mpeg2_idct_mmx_init ();
107 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
108 mpeg2_idct_copy = mpeg2_idct_copy_altivec;
109 mpeg2_idct_add = mpeg2_idct_add_altivec;
110 mpeg2_idct_altivec_init ();
115 if (accel & MPEG2_ACCEL_ALPHA_MVI) {
116 mpeg2_idct_copy = mpeg2_idct_copy_mvi;
117 mpeg2_idct_add = mpeg2_idct_add_mvi;
118 mpeg2_idct_alpha_init ();
119 - } else if (accel & MPEG2_ACCEL_ALPHA) {
122 + if (accel & MPEG2_ACCEL_ALPHA) {
125 mpeg2_idct_copy = mpeg2_idct_copy_alpha;
126 --- libmpeg2/motion_comp.c 2006-06-16 20:12:26.000000000 +0200
127 +++ libmpeg2/motion_comp.c 2006-06-16 20:12:50.000000000 +0200
130 void mpeg2_mc_init (uint32_t accel)
134 if (accel & MPEG2_ACCEL_X86_MMXEXT)
135 mpeg2_mc = mpeg2_mc_mmxext;
136 - else if (accel & MPEG2_ACCEL_X86_3DNOW)
139 +#ifdef HAVE_AMD3DNOW
140 + if (accel & MPEG2_ACCEL_X86_3DNOW)
141 mpeg2_mc = mpeg2_mc_3dnow;
142 - else if (accel & MPEG2_ACCEL_X86_MMX)
146 + if (accel & MPEG2_ACCEL_X86_MMX)
147 mpeg2_mc = mpeg2_mc_mmx;
152 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
153 mpeg2_mc = mpeg2_mc_altivec;
156 mpeg2_mc = mpeg2_mc_alpha;
161 if (accel & MPEG2_ACCEL_SPARC_VIS)
162 mpeg2_mc = mpeg2_mc_vis;
166 - if (accel & MPEG2_ACCEL_ARM) {
167 + if (accel & MPEG2_ACCEL_ARM)
168 mpeg2_mc = mpeg2_mc_arm;
172 mpeg2_mc = mpeg2_mc_c;
174 --- libmpeg2/mpeg2_internal.h 2006-06-16 20:12:26.000000000 +0200
175 +++ libmpeg2/mpeg2_internal.h 2006-06-16 20:12:50.000000000 +0200
178 /* XXX: stuff due to xine shit */
181 + int quantizer_scales[32];
182 + int quantizer_scale;
189 //int8_t q_scale_type, scaled[4];
190 uint8_t quantizer_matrix[4][64];
191 uint8_t new_quantizer_matrix[4][64];
193 + unsigned char *pending_buffer;
194 + int pending_length;
198 --- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200
199 +++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200
202 quantizer_scale_code = UBITS (bit_buf, 5);
203 DUMPBITS (bit_buf, bits, 5);
204 + decoder->quantizer_scale = decoder->quantizer_scales[quantizer_scale_code];
206 decoder->quantizer_matrix[0] =
207 decoder->quantizer_prescale[0][quantizer_scale_code];
208 @@ -1564,6 +1569,24 @@
210 #define NEXT_MACROBLOCK \
212 + if(decoder->quant_store) { \
213 + if (decoder->picture_structure == TOP_FIELD) \
214 + decoder->quant_store[2 * decoder->quant_stride \
215 + * (decoder->v_offset >> 4) \
216 + + (decoder->offset >> 4)] \
217 + = decoder->quantizer_scale; \
218 + else if (decoder->picture_structure == BOTTOM_FIELD) \
219 + decoder->quant_store[2 * decoder->quant_stride \
220 + * (decoder->v_offset >> 4) \
221 + + decoder->quant_stride \
222 + + (decoder->offset >> 4)] \
223 + = decoder->quantizer_scale; \
225 + decoder->quant_store[decoder->quant_stride \
226 + * (decoder->v_offset >> 4) \
227 + + (decoder->offset >> 4)] \
228 + = decoder->quantizer_scale; \
230 decoder->offset += 16; \
231 if (decoder->offset == decoder->width) { \
232 do { /* just so we can use the break statement */ \