Mercurial > mplayer.hg
annotate libmpcodecs/vf_ilpack.c @ 13610:b79ee5bf2c9e
Sync with GomGom's patch-12 version.
updated copyright
bvhq options added (xvid 1.1+ api4.1)
psnr handling moved in separate functions
proper free() on uninit
printf -> mp_msg
capability to flush delayed frames
Changes by me (iive)
support for flushing delayed frames at the end
suppressed cosmetics and new aspect code changes
author | iive |
---|---|
date | Mon, 11 Oct 2004 15:48:18 +0000 |
parents | 57372aa1d655 |
children | 821f464b4d90 |
rev | line source |
---|---|
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
1 #include <stdio.h> |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
2 #include <stdlib.h> |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
3 #include <string.h> |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
4 #include <inttypes.h> |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
5 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
6 #include "../config.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
7 #include "../mp_msg.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
8 #include "../cpudetect.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
9 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
10 #include "img_format.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
11 #include "mp_image.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
12 #include "vf.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
13 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
14 #include "../libvo/fastmemcpy.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
15 #include "../postproc/rgb2rgb.h" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
16 |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
17 typedef void (pack_func_t)(unsigned char *dst, unsigned char *y, |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
18 unsigned char *u, unsigned char *v, int w, int us, int vs); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
19 |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
20 struct vf_priv_s { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
21 int mode; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
22 pack_func_t *pack[2]; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
23 }; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
24 |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
25 static void pack_nn_C(unsigned char *dst, unsigned char *y, |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
26 unsigned char *u, unsigned char *v, int w) |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
27 { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
28 int j; |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
29 for (j = w/2; j; j--) { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
30 *dst++ = *y++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
31 *dst++ = *u++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
32 *dst++ = *y++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
33 *dst++ = *v++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
34 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
35 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
36 |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
37 static void pack_li_0_C(unsigned char *dst, unsigned char *y, |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
38 unsigned char *u, unsigned char *v, int w, int us, int vs) |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
39 { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
40 int j; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
41 for (j = w/2; j; j--) { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
42 *dst++ = *y++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
43 *dst++ = (u[us+us] + 7*u[0])>>3; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
44 *dst++ = *y++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
45 *dst++ = (v[vs+vs] + 7*v[0])>>3; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
46 u++; v++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
47 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
48 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
49 |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
50 static void pack_li_1_C(unsigned char *dst, unsigned char *y, |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
51 unsigned char *u, unsigned char *v, int w, int us, int vs) |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
52 { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
53 int j; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
54 for (j = w/2; j; j--) { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
55 *dst++ = *y++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
56 *dst++ = (3*u[us+us] + 5*u[0])>>3; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
57 *dst++ = *y++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
58 *dst++ = (3*v[vs+vs] + 5*v[0])>>3; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
59 u++; v++; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
60 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
61 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
62 |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
63 #ifdef HAVE_MMX |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
64 static void pack_nn_MMX(unsigned char *dst, unsigned char *y, |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
65 unsigned char *u, unsigned char *v, int w) |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
66 { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
67 int j; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
68 asm volatile ("" |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
69 ".balign 16 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
70 "1: \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
71 "movq (%0), %%mm1 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
72 "movq (%0), %%mm2 \n\t" |
11648 | 73 "movq (%1), %%mm4 \n\t" |
74 "movq (%2), %%mm6 \n\t" | |
75 "punpcklbw %%mm6, %%mm4 \n\t" | |
76 "punpcklbw %%mm4, %%mm1 \n\t" | |
77 "punpckhbw %%mm4, %%mm2 \n\t" | |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
78 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
79 "addl $8, %0 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
80 "addl $4, %1 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
81 "addl $4, %2 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
82 "movq %%mm1, (%3) \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
83 "movq %%mm2, 8(%3) \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
84 "addl $16, %3 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
85 "decl %4 \n\t" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
86 "jnz 1b \n\t" |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
87 "emms \n\t" |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
88 : |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
89 : "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8) |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
90 : "memory" |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
91 ); |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
92 pack_nn_C(dst, y, u, v, (w&7)); |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
93 } |
11645 | 94 |
95 static void pack_li_0_MMX(unsigned char *dst, unsigned char *y, | |
96 unsigned char *u, unsigned char *v, int w, int us, int vs) | |
97 { | |
98 asm volatile ("" | |
99 "pushl %%ebp \n\t" | |
100 "movl 4(%%edx), %%ebp \n\t" | |
101 "movl (%%edx), %%edx \n\t" | |
102 "pxor %%mm0, %%mm0 \n\t" | |
103 | |
104 ".balign 16 \n\t" | |
105 ".Lli0: \n\t" | |
106 "movq (%%esi), %%mm1 \n\t" | |
107 "movq (%%esi), %%mm2 \n\t" | |
108 | |
109 "movq (%%eax,%%edx,2), %%mm4 \n\t" | |
110 "movq (%%ebx,%%ebp,2), %%mm6 \n\t" | |
111 "punpcklbw %%mm0, %%mm4 \n\t" | |
112 "punpcklbw %%mm0, %%mm6 \n\t" | |
113 "movq (%%eax), %%mm3 \n\t" | |
114 "movq (%%ebx), %%mm5 \n\t" | |
115 "punpcklbw %%mm0, %%mm3 \n\t" | |
116 "punpcklbw %%mm0, %%mm5 \n\t" | |
117 "paddw %%mm3, %%mm4 \n\t" | |
118 "paddw %%mm5, %%mm6 \n\t" | |
119 "paddw %%mm3, %%mm4 \n\t" | |
120 "paddw %%mm5, %%mm6 \n\t" | |
121 "paddw %%mm3, %%mm4 \n\t" | |
122 "paddw %%mm5, %%mm6 \n\t" | |
123 "paddw %%mm3, %%mm4 \n\t" | |
124 "paddw %%mm5, %%mm6 \n\t" | |
125 "paddw %%mm3, %%mm4 \n\t" | |
126 "paddw %%mm5, %%mm6 \n\t" | |
127 "paddw %%mm3, %%mm4 \n\t" | |
128 "paddw %%mm5, %%mm6 \n\t" | |
129 "paddw %%mm3, %%mm4 \n\t" | |
130 "paddw %%mm5, %%mm6 \n\t" | |
131 "psrlw $3, %%mm4 \n\t" | |
132 "psrlw $3, %%mm6 \n\t" | |
11648 | 133 "packuswb %%mm4, %%mm4 \n\t" |
134 "packuswb %%mm6, %%mm6 \n\t" | |
135 "punpcklbw %%mm6, %%mm4 \n\t" | |
136 "punpcklbw %%mm4, %%mm1 \n\t" | |
137 "punpckhbw %%mm4, %%mm2 \n\t" | |
11645 | 138 |
139 "movq %%mm1, (%%edi) \n\t" | |
140 "movq %%mm2, 8(%%edi) \n\t" | |
141 | |
142 "movq 8(%%esi), %%mm1 \n\t" | |
143 "movq 8(%%esi), %%mm2 \n\t" | |
144 | |
145 "movq (%%eax,%%edx,2), %%mm4 \n\t" | |
146 "movq (%%ebx,%%ebp,2), %%mm6 \n\t" | |
147 "punpckhbw %%mm0, %%mm4 \n\t" | |
148 "punpckhbw %%mm0, %%mm6 \n\t" | |
149 "movq (%%eax), %%mm3 \n\t" | |
150 "movq (%%ebx), %%mm5 \n\t" | |
151 "punpckhbw %%mm0, %%mm3 \n\t" | |
152 "punpckhbw %%mm0, %%mm5 \n\t" | |
153 "paddw %%mm3, %%mm4 \n\t" | |
154 "paddw %%mm5, %%mm6 \n\t" | |
155 "paddw %%mm3, %%mm4 \n\t" | |
156 "paddw %%mm5, %%mm6 \n\t" | |
157 "paddw %%mm3, %%mm4 \n\t" | |
158 "paddw %%mm5, %%mm6 \n\t" | |
159 "paddw %%mm3, %%mm4 \n\t" | |
160 "paddw %%mm5, %%mm6 \n\t" | |
161 "paddw %%mm3, %%mm4 \n\t" | |
162 "paddw %%mm5, %%mm6 \n\t" | |
163 "paddw %%mm3, %%mm4 \n\t" | |
164 "paddw %%mm5, %%mm6 \n\t" | |
165 "paddw %%mm3, %%mm4 \n\t" | |
166 "paddw %%mm5, %%mm6 \n\t" | |
167 "psrlw $3, %%mm4 \n\t" | |
168 "psrlw $3, %%mm6 \n\t" | |
11648 | 169 "packuswb %%mm4, %%mm4 \n\t" |
170 "packuswb %%mm6, %%mm6 \n\t" | |
171 "punpcklbw %%mm6, %%mm4 \n\t" | |
172 "punpcklbw %%mm4, %%mm1 \n\t" | |
173 "punpckhbw %%mm4, %%mm2 \n\t" | |
11645 | 174 |
175 "addl $16, %%esi \n\t" | |
176 "addl $8, %%eax \n\t" | |
177 "addl $8, %%ebx \n\t" | |
178 | |
179 "movq %%mm1, 16(%%edi) \n\t" | |
180 "movq %%mm2, 24(%%edi) \n\t" | |
181 "addl $32, %%edi \n\t" | |
182 | |
183 "decl %%ecx \n\t" | |
184 "jnz .Lli0 \n\t" | |
185 "emms \n\t" | |
186 "popl %%ebp \n\t" | |
187 : | |
188 : "S" (y), "D" (dst), "a" (u), "b" (v), "d" (&us), "c" (w/16) | |
189 : "memory" | |
190 ); | |
191 pack_li_0_C(dst, y, u, v, (w&15), us, vs); | |
192 } | |
193 | |
194 static void pack_li_1_MMX(unsigned char *dst, unsigned char *y, | |
195 unsigned char *u, unsigned char *v, int w, int us, int vs) | |
196 { | |
197 asm volatile ("" | |
198 "pushl %%ebp \n\t" | |
199 "movl 4(%%edx), %%ebp \n\t" | |
200 "movl (%%edx), %%edx \n\t" | |
201 "pxor %%mm0, %%mm0 \n\t" | |
202 | |
203 ".balign 16 \n\t" | |
204 ".Lli1: \n\t" | |
205 "movq (%%esi), %%mm1 \n\t" | |
206 "movq (%%esi), %%mm2 \n\t" | |
207 | |
208 "movq (%%eax,%%edx,2), %%mm4 \n\t" | |
209 "movq (%%ebx,%%ebp,2), %%mm6 \n\t" | |
210 "punpcklbw %%mm0, %%mm4 \n\t" | |
211 "punpcklbw %%mm0, %%mm6 \n\t" | |
212 "movq (%%eax), %%mm3 \n\t" | |
213 "movq (%%ebx), %%mm5 \n\t" | |
214 "punpcklbw %%mm0, %%mm3 \n\t" | |
215 "punpcklbw %%mm0, %%mm5 \n\t" | |
216 "movq %%mm4, %%mm7 \n\t" | |
217 "paddw %%mm4, %%mm4 \n\t" | |
218 "paddw %%mm7, %%mm4 \n\t" | |
219 "movq %%mm6, %%mm7 \n\t" | |
220 "paddw %%mm6, %%mm6 \n\t" | |
221 "paddw %%mm7, %%mm6 \n\t" | |
222 "paddw %%mm3, %%mm4 \n\t" | |
223 "paddw %%mm5, %%mm6 \n\t" | |
224 "paddw %%mm3, %%mm4 \n\t" | |
225 "paddw %%mm5, %%mm6 \n\t" | |
226 "paddw %%mm3, %%mm4 \n\t" | |
227 "paddw %%mm5, %%mm6 \n\t" | |
228 "paddw %%mm3, %%mm4 \n\t" | |
229 "paddw %%mm5, %%mm6 \n\t" | |
230 "paddw %%mm3, %%mm4 \n\t" | |
231 "paddw %%mm5, %%mm6 \n\t" | |
232 "psrlw $3, %%mm4 \n\t" | |
233 "psrlw $3, %%mm6 \n\t" | |
11648 | 234 "packuswb %%mm4, %%mm4 \n\t" |
235 "packuswb %%mm6, %%mm6 \n\t" | |
236 "punpcklbw %%mm6, %%mm4 \n\t" | |
237 "punpcklbw %%mm4, %%mm1 \n\t" | |
238 "punpckhbw %%mm4, %%mm2 \n\t" | |
11645 | 239 |
240 "movq %%mm1, (%%edi) \n\t" | |
241 "movq %%mm2, 8(%%edi) \n\t" | |
242 | |
243 "movq 8(%%esi), %%mm1 \n\t" | |
244 "movq 8(%%esi), %%mm2 \n\t" | |
245 | |
246 "movq (%%eax,%%edx,2), %%mm4 \n\t" | |
247 "movq (%%ebx,%%ebp,2), %%mm6 \n\t" | |
248 "punpckhbw %%mm0, %%mm4 \n\t" | |
249 "punpckhbw %%mm0, %%mm6 \n\t" | |
250 "movq (%%eax), %%mm3 \n\t" | |
251 "movq (%%ebx), %%mm5 \n\t" | |
252 "punpckhbw %%mm0, %%mm3 \n\t" | |
253 "punpckhbw %%mm0, %%mm5 \n\t" | |
254 "movq %%mm4, %%mm7 \n\t" | |
255 "paddw %%mm4, %%mm4 \n\t" | |
256 "paddw %%mm7, %%mm4 \n\t" | |
257 "movq %%mm6, %%mm7 \n\t" | |
258 "paddw %%mm6, %%mm6 \n\t" | |
259 "paddw %%mm7, %%mm6 \n\t" | |
260 "paddw %%mm3, %%mm4 \n\t" | |
261 "paddw %%mm5, %%mm6 \n\t" | |
262 "paddw %%mm3, %%mm4 \n\t" | |
263 "paddw %%mm5, %%mm6 \n\t" | |
264 "paddw %%mm3, %%mm4 \n\t" | |
265 "paddw %%mm5, %%mm6 \n\t" | |
266 "paddw %%mm3, %%mm4 \n\t" | |
267 "paddw %%mm5, %%mm6 \n\t" | |
268 "paddw %%mm3, %%mm4 \n\t" | |
269 "paddw %%mm5, %%mm6 \n\t" | |
270 "psrlw $3, %%mm4 \n\t" | |
271 "psrlw $3, %%mm6 \n\t" | |
11648 | 272 "packuswb %%mm4, %%mm4 \n\t" |
273 "packuswb %%mm6, %%mm6 \n\t" | |
274 "punpcklbw %%mm6, %%mm4 \n\t" | |
275 "punpcklbw %%mm4, %%mm1 \n\t" | |
276 "punpckhbw %%mm4, %%mm2 \n\t" | |
11645 | 277 |
278 "addl $16, %%esi \n\t" | |
279 "addl $8, %%eax \n\t" | |
280 "addl $8, %%ebx \n\t" | |
281 | |
282 "movq %%mm1, 16(%%edi) \n\t" | |
283 "movq %%mm2, 24(%%edi) \n\t" | |
284 "addl $32, %%edi \n\t" | |
285 | |
286 "decl %%ecx \n\t" | |
287 "jnz .Lli1 \n\t" | |
288 "emms \n\t" | |
289 "popl %%ebp \n\t" | |
290 : | |
291 : "S" (y), "D" (dst), "a" (u), "b" (v), "d" (&us), "c" (w/16) | |
292 : "memory" | |
293 ); | |
294 pack_li_1_C(dst, y, u, v, (w&15), us, vs); | |
295 } | |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
296 #endif |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
297 |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
298 static pack_func_t *pack_nn; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
299 static pack_func_t *pack_li_0; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
300 static pack_func_t *pack_li_1; |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
301 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
302 static void ilpack(unsigned char *dst, unsigned char *src[3], |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
303 int dststride, int srcstride[3], int w, int h, pack_func_t *pack[2]) |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
304 { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
305 int i; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
306 unsigned char *y, *u, *v; |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
307 int ys = srcstride[0], us = srcstride[1], vs = srcstride[2]; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
308 int a, b; |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
309 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
310 y = src[0]; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
311 u = src[1]; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
312 v = src[2]; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
313 |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
314 pack_nn(dst, y, u, v, w, 0, 0); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
315 y += ys; dst += dststride; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
316 pack_nn(dst, y, u+us, v+vs, w, 0, 0); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
317 y += ys; dst += dststride; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
318 for (i=2; i<h-2; i++) { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
319 a = (i&2) ? 1 : -1; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
320 b = (i&1) ^ ((i&2)>>1); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
321 pack[b](dst, y, u, v, w, us*a, vs*a); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
322 y += ys; |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
323 if ((i&3) == 1) { |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
324 u -= us; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
325 v -= vs; |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
326 } else { |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
327 u += us; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
328 v += vs; |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
329 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
330 dst += dststride; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
331 } |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
332 pack_nn(dst, y, u, v, w, 0, 0); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
333 y += ys; dst += dststride; u += us; v += vs; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
334 pack_nn(dst, y, u, v, w, 0, 0); |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
335 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
336 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
337 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
338 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi) |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
339 { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
340 mp_image_t *dmpi; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
341 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
342 // hope we'll get DR buffer: |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
343 dmpi=vf_get_image(vf->next, IMGFMT_YUY2, |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
344 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
345 mpi->w, mpi->h); |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
346 |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
347 ilpack(dmpi->planes[0], mpi->planes, dmpi->stride[0], mpi->stride, mpi->w, mpi->h, vf->priv->pack); |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
348 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
349 return vf_next_put_image(vf,dmpi); |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
350 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
351 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
352 static int config(struct vf_instance_s* vf, |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
353 int width, int height, int d_width, int d_height, |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
354 unsigned int flags, unsigned int outfmt) |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
355 { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
356 /* FIXME - also support UYVY output? */ |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
357 return vf_next_config(vf, width, height, d_width, d_height, flags, IMGFMT_YUY2); |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
358 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
359 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
360 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
361 static int query_format(struct vf_instance_s* vf, unsigned int fmt) |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
362 { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
363 /* FIXME - really any YUV 4:2:0 input format should work */ |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
364 switch (fmt) { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
365 case IMGFMT_YV12: |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
366 case IMGFMT_IYUV: |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
367 case IMGFMT_I420: |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
368 return vf_next_query_format(vf,IMGFMT_YUY2); |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
369 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
370 return 0; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
371 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
372 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
373 static int open(vf_instance_t *vf, char* args) |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
374 { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
375 vf->config=config; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
376 vf->query_format=query_format; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
377 vf->put_image=put_image; |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
378 vf->priv = calloc(1, sizeof(struct vf_priv_s)); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
379 vf->priv->mode = 1; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
380 if (args) sscanf(args, "%d", &vf->priv->mode); |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
381 |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
382 pack_nn = (pack_func_t *)pack_nn_C; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
383 pack_li_0 = pack_li_0_C; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
384 pack_li_1 = pack_li_1_C; |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
385 #ifdef HAVE_MMX |
11645 | 386 if(gCpuCaps.hasMMX) { |
387 pack_nn = (pack_func_t *)pack_nn_MMX; | |
388 pack_li_0 = pack_li_0_MMX; | |
389 pack_li_1 = pack_li_1_MMX; | |
390 } | |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
391 #endif |
11643
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
392 |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
393 switch(vf->priv->mode) { |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
394 case 0: |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
395 vf->priv->pack[0] = vf->priv->pack[1] = pack_nn; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
396 break; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
397 default: |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
398 mp_msg(MSGT_VFILTER, MSGL_WARN, |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
399 "ilpack: unknown mode %d (fallback to linear)\n", |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
400 vf->priv->mode); |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
401 case 1: |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
402 vf->priv->pack[0] = pack_li_0; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
403 vf->priv->pack[1] = pack_li_1; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
404 break; |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
405 } |
3ddfe9316ca9
big updates to ilpack: do proper interpolation rather than just
rfelker
parents:
9933
diff
changeset
|
406 |
9933
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
407 return 1; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
408 } |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
409 |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
410 vf_info_t vf_info_ilpack = { |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
411 "4:2:0 planar -> 4:2:2 packed reinterlacer", |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
412 "ilpack", |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
413 "Richard Felker", |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
414 "", |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
415 open, |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
416 NULL |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
417 }; |
3548701a13fe
1. new alternate approach to inverse telecine! much better!
rfelker
parents:
diff
changeset
|
418 |