Add support for VDPAU video out, including hardware decoding.
[mplayer/glamo.git] / libmpeg2 / libmpeg2_changes.diff
blob64cfd3cee1ba368c8492d8999257a677f0205434
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
3 @@ -29,9 +33,13 @@
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. */
13 +#if 0
14 if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
15 accel |= MPEG2_ACCEL_X86_MMX;
17 @@ -124,6 +132,21 @@
18 #endif /* ACCEL_DETECT */
20 return accel;
22 +#else /* 0 */
23 + accel = 0;
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;
33 + return accel;
35 +#endif /* 0 */
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
41 @@ -345,6 +349,15 @@
42 fbuf->buf[1] = buf[1];
43 fbuf->buf[2] = buf[2];
44 fbuf->id = id;
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;
51 + }
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
59 @@ -100,6 +104,9 @@
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;
69 @@ -872,6 +879,7 @@
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)
79 @@ -235,34 +239,40 @@
81 void mpeg2_idct_init (uint32_t accel)
83 -#ifdef ARCH_X86
84 +#ifdef HAVE_SSE2
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) {
90 + } else
91 +#elif HAVE_MMX2
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) {
97 + } else
98 +#elif HAVE_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 ();
103 } else
104 #endif
105 -#ifdef ARCH_PPC
106 +#ifdef HAVE_ALTIVEC
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 ();
111 } else
112 #endif
113 -#ifdef ARCH_ALPHA
114 +#ifdef HAVE_MVI
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) {
120 + } else
121 +#elif ARCH_ALPHA
122 + if (accel & MPEG2_ACCEL_ALPHA) {
123 int i;
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
128 @@ -33,16 +37,22 @@
130 void mpeg2_mc_init (uint32_t accel)
132 -#ifdef ARCH_X86
133 +#ifdef HAVE_MMX2
134 if (accel & MPEG2_ACCEL_X86_MMXEXT)
135 mpeg2_mc = mpeg2_mc_mmxext;
136 - else if (accel & MPEG2_ACCEL_X86_3DNOW)
137 + else
138 +#endif
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)
143 + else
144 +#endif
145 +#ifdef HAVE_MMX
146 + if (accel & MPEG2_ACCEL_X86_MMX)
147 mpeg2_mc = mpeg2_mc_mmx;
148 else
149 #endif
150 -#ifdef ARCH_PPC
151 +#ifdef HAVE_ALTIVEC
152 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
153 mpeg2_mc = mpeg2_mc_altivec;
154 else
155 @@ -52,15 +62,15 @@
156 mpeg2_mc = mpeg2_mc_alpha;
157 else
158 #endif
159 -#ifdef ARCH_SPARC
160 +#ifdef HAVE_VIS
161 if (accel & MPEG2_ACCEL_SPARC_VIS)
162 mpeg2_mc = mpeg2_mc_vis;
163 else
164 #endif
165 #ifdef ARCH_ARM
166 - if (accel & MPEG2_ACCEL_ARM) {
167 + if (accel & MPEG2_ACCEL_ARM)
168 mpeg2_mc = mpeg2_mc_arm;
169 - } else
170 + else
171 #endif
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
176 @@ -152,6 +156,11 @@
178 /* XXX: stuff due to xine shit */
179 int8_t q_scale_type;
181 + int quantizer_scales[32];
182 + int quantizer_scale;
183 + char* quant_store;
184 + int quant_stride;
187 typedef struct {
188 @@ -223,6 +232,9 @@
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;
197 typedef struct {
198 --- libmpeg2/slice.c 2006-06-16 20:12:26.000000000 +0200
199 +++ libmpeg2/slice.c 2006-06-16 20:12:50.000000000 +0200
200 @@ -142,6 +146,7 @@
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 \
211 do { \
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; \
224 + else \
225 + decoder->quant_store[decoder->quant_stride \
226 + * (decoder->v_offset >> 4) \
227 + + (decoder->offset >> 4)] \
228 + = decoder->quantizer_scale; \
229 + } \
230 decoder->offset += 16; \
231 if (decoder->offset == decoder->width) { \
232 do { /* just so we can use the break statement */ \