Mercurial > mplayer.hg
annotate libmpcodecs/vf_test.c @ 24816:ba929c5ee0bc
Fix input command parser for using only tab to separate the arguments.
author | ulion |
---|---|
date | Tue, 23 Oct 2007 00:44:22 +0000 |
parents | f8d4f8eff72b |
children | 00fff9a3b735 |
rev | line source |
---|---|
6278 | 1 /* |
2 Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at> | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; if not, write to the Free Software | |
17367
401b440a6d76
Update licensing information: The FSF changed postal address.
diego
parents:
17012
diff
changeset
|
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6278 | 17 */ |
18 | |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
21 #include <string.h> | |
22 #include <inttypes.h> | |
23 | |
17012 | 24 #include "config.h" |
25 #include "mp_msg.h" | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
26 #include "help_mp.h" |
6278 | 27 |
28 #include "img_format.h" | |
29 #include "mp_image.h" | |
30 #include "vf.h" | |
31 | |
32 //===========================================================================// | |
33 | |
34 #include <inttypes.h> | |
35 #include <math.h> | |
36 | |
37 #define MAX(a,b) ((a) > (b) ? (a) : (b)) | |
38 #define MIN(a,b) ((a) < (b) ? (a) : (b)) | |
39 #define ABS(a,b) ((a) > 0 ? (a) : -(a)) | |
40 | |
41 #define WIDTH 512 | |
42 #define HEIGHT 512 | |
43 | |
6413 | 44 struct vf_priv_s { |
45 int frame_num; | |
46 }; | |
47 | |
6278 | 48 static int config(struct vf_instance_s* vf, |
49 int width, int height, int d_width, int d_height, | |
50 unsigned int flags, unsigned int outfmt){ | |
51 | |
52 if(vf_next_query_format(vf,IMGFMT_YV12)<=0){ | |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
17906
diff
changeset
|
53 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YV12"); |
6278 | 54 return 0; |
55 } | |
56 | |
57 //hmm whats the meaning of these ... ;) | |
58 d_width= width= WIDTH; | |
59 d_height= height= HEIGHT; | |
60 | |
61 return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YV12); | |
62 } | |
63 | |
64 static double c[64]; | |
65 | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17367
diff
changeset
|
66 static void initIdct(void) |
6278 | 67 { |
68 int i; | |
69 | |
70 for (i=0; i<8; i++) | |
71 { | |
72 double s= i==0 ? sqrt(0.125) : 0.5; | |
73 int j; | |
74 | |
75 for(j=0; j<8; j++) | |
76 c[i*8+j]= s*cos((3.141592654/8.0)*i*(j+0.5)); | |
77 } | |
78 } | |
79 | |
80 | |
81 static void idct(uint8_t *dst, int dstStride, int src[64]) | |
82 { | |
83 int i, j, k; | |
84 double tmp[64]; | |
85 | |
86 for(i=0; i<8; i++) | |
87 { | |
88 for(j=0; j<8; j++) | |
89 { | |
90 double sum= 0.0; | |
91 | |
92 for(k=0; k<8; k++) | |
93 sum+= c[k*8+j]*src[8*i+k]; | |
94 | |
95 tmp[8*i+j]= sum; | |
96 } | |
97 } | |
98 | |
99 for(j=0; j<8; j++) | |
100 { | |
101 for(i=0; i<8; i++) | |
102 { | |
103 int v; | |
104 double sum= 0.0; | |
105 | |
106 for(k=0; k<8; k++) | |
107 sum+= c[k*8+i]*tmp[8*k+j]; | |
108 | |
6413 | 109 v= (int)floor(sum+0.5); |
6278 | 110 if(v<0) v=0; |
111 else if(v>255) v=255; | |
112 | |
113 dst[dstStride*i + j] = v; | |
114 } | |
115 } | |
116 } | |
117 | |
118 static void drawDc(uint8_t *dst, int stride, int color, int w, int h) | |
119 { | |
120 int y; | |
121 for(y=0; y<h; y++) | |
122 { | |
123 int x; | |
124 for(x=0; x<w; x++) | |
125 { | |
126 dst[x + y*stride]= color; | |
127 } | |
128 } | |
129 } | |
130 | |
131 static void drawBasis(uint8_t *dst, int stride, int amp, int freq, int dc) | |
132 { | |
133 int src[64]; | |
134 | |
135 memset(src, 0, 64*sizeof(int)); | |
136 src[0]= dc; | |
137 if(amp) src[freq]= amp; | |
138 idct(dst, stride, src); | |
139 } | |
140 | |
141 static void drawCbp(uint8_t *dst[3], int stride[3], int cbp, int amp, int dc) | |
142 { | |
143 if(cbp&1) drawBasis(dst[0] , stride[0], amp, 1, dc); | |
144 if(cbp&2) drawBasis(dst[0]+8 , stride[0], amp, 1, dc); | |
145 if(cbp&4) drawBasis(dst[0]+ 8*stride[0], stride[0], amp, 1, dc); | |
146 if(cbp&8) drawBasis(dst[0]+8+8*stride[0], stride[0], amp, 1, dc); | |
147 if(cbp&16)drawBasis(dst[1] , stride[1], amp, 1, dc); | |
148 if(cbp&32)drawBasis(dst[2] , stride[2], amp, 1, dc); | |
149 } | |
150 | |
151 static void dc1Test(uint8_t *dst, int stride, int w, int h, int off) | |
152 { | |
153 const int step= MAX(256/(w*h/256), 1); | |
154 int y; | |
155 int color=off; | |
156 for(y=0; y<h; y+=16) | |
157 { | |
158 int x; | |
159 for(x=0; x<w; x+=16) | |
160 { | |
161 drawDc(dst + x + y*stride, stride, color, 8, 8); | |
162 color+=step; | |
163 } | |
164 } | |
165 } | |
166 | |
167 static void freq1Test(uint8_t *dst, int stride, int off) | |
168 { | |
169 int y; | |
170 int freq=0; | |
171 for(y=0; y<8*16; y+=16) | |
172 { | |
173 int x; | |
174 for(x=0; x<8*16; x+=16) | |
175 { | |
6413 | 176 drawBasis(dst + x + y*stride, stride, 4*(96+off), freq, 128*8); |
6278 | 177 freq++; |
178 } | |
179 } | |
180 } | |
181 | |
182 static void amp1Test(uint8_t *dst, int stride, int off) | |
183 { | |
184 int y; | |
185 int amp=off; | |
186 for(y=0; y<16*16; y+=16) | |
187 { | |
188 int x; | |
189 for(x=0; x<16*16; x+=16) | |
190 { | |
191 drawBasis(dst + x + y*stride, stride, 4*(amp), 1, 128*8); | |
192 amp++; | |
193 } | |
194 } | |
195 } | |
196 | |
197 static void cbp1Test(uint8_t *dst[3], int stride[3], int off) | |
198 { | |
199 int y; | |
200 int cbp=0; | |
201 for(y=0; y<16*8; y+=16) | |
202 { | |
203 int x; | |
204 for(x=0; x<16*8; x+=16) | |
205 { | |
206 uint8_t *dst1[3]; | |
207 dst1[0]= dst[0] + x*2 + y*2*stride[0]; | |
208 dst1[1]= dst[1] + x + y*stride[1]; | |
209 dst1[2]= dst[2] + x + y*stride[2]; | |
210 | |
211 drawCbp(dst1, stride, cbp, (64+off)*4, 128*8); | |
212 cbp++; | |
213 } | |
214 } | |
215 } | |
216 | |
217 static void mv1Test(uint8_t *dst, int stride, int off) | |
218 { | |
219 int y; | |
220 for(y=0; y<16*16; y++) | |
221 { | |
222 int x; | |
223 if(y&16) continue; | |
224 for(x=0; x<16*16; x++) | |
225 { | |
226 dst[x + y*stride]= x + off*8/(y/32+1); | |
227 } | |
228 } | |
229 } | |
230 | |
6413 | 231 static void ring1Test(uint8_t *dst, int stride, int off) |
232 { | |
233 int y; | |
234 int color=0; | |
235 for(y=off; y<16*16; y+=16) | |
236 { | |
237 int x; | |
238 for(x=off; x<16*16; x+=16) | |
239 { | |
240 drawDc(dst + x + y*stride, stride, ((x+y)&16) ? color : -color, 16, 16); | |
241 // dst[x + y*stride]= 255 + (off&1); | |
242 color++; | |
243 } | |
244 } | |
245 } | |
246 | |
247 static void ring2Test(uint8_t *dst, int stride, int off) | |
248 { | |
249 int y; | |
250 for(y=0; y<16*16; y++) | |
251 { | |
252 int x; | |
253 for(x=0; x<16*16; x++) | |
254 { | |
255 double d= sqrt((x-8*16)*(x-8*16) + (y-8*16)*(y-8*16)); | |
256 double r= d/20 - (int)(d/20); | |
257 if(r<off/30.0) | |
258 { | |
259 dst[x + y*stride]= 255; | |
260 dst[x + y*stride+256]= 0; | |
261 } | |
262 else{ | |
263 dst[x + y*stride]= x; | |
264 dst[x + y*stride+256]= x; | |
265 } | |
266 } | |
267 } | |
268 } | |
269 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17566
diff
changeset
|
270 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
6278 | 271 mp_image_t *dmpi; |
6413 | 272 int frame= vf->priv->frame_num; |
6278 | 273 |
274 // hope we'll get DR buffer: | |
275 dmpi=vf_get_image(vf->next,IMGFMT_YV12, | |
276 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
277 WIDTH, HEIGHT); | |
278 | |
279 // clean | |
280 memset(dmpi->planes[0], 0, dmpi->stride[0]*dmpi->h); | |
6539
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6413
diff
changeset
|
281 memset(dmpi->planes[1], 128, dmpi->stride[1]*dmpi->h>>dmpi->chroma_y_shift); |
79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
alex
parents:
6413
diff
changeset
|
282 memset(dmpi->planes[2], 128, dmpi->stride[2]*dmpi->h>>dmpi->chroma_y_shift); |
6278 | 283 |
284 if(frame%30) | |
285 { | |
286 switch(frame/30) | |
287 { | |
288 case 0: dc1Test(dmpi->planes[0], dmpi->stride[0], 256, 256, frame%30); break; | |
289 case 1: dc1Test(dmpi->planes[1], dmpi->stride[1], 256, 256, frame%30); break; | |
290 case 2: freq1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break; | |
291 case 3: freq1Test(dmpi->planes[1], dmpi->stride[1], frame%30); break; | |
292 case 4: amp1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break; | |
293 case 5: amp1Test(dmpi->planes[1], dmpi->stride[1], frame%30); break; | |
294 case 6: cbp1Test(dmpi->planes , dmpi->stride , frame%30); break; | |
295 case 7: mv1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break; | |
6413 | 296 case 8: ring1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break; |
297 case 9: ring2Test(dmpi->planes[0], dmpi->stride[0], frame%30); break; | |
6278 | 298 } |
299 } | |
300 | |
301 frame++; | |
6413 | 302 vf->priv->frame_num= frame; |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17566
diff
changeset
|
303 return vf_next_put_image(vf,dmpi, pts); |
6278 | 304 } |
305 | |
306 //===========================================================================// | |
307 | |
308 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
309 return vf_next_query_format(vf,IMGFMT_YV12) & (~VFCAP_CSP_SUPPORTED_BY_HW); | |
310 } | |
311 | |
312 static int open(vf_instance_t *vf, char* args){ | |
313 vf->config=config; | |
314 vf->put_image=put_image; | |
315 vf->query_format=query_format; | |
6413 | 316 vf->priv=malloc(sizeof(struct vf_priv_s)); |
317 vf->priv->frame_num= args ? atoi(args) : 0; | |
6278 | 318 initIdct(); |
319 return 1; | |
320 } | |
321 | |
322 vf_info_t vf_info_test = { | |
323 "test pattern generator", | |
324 "test", | |
325 "Michael Niedermayer", | |
326 "", | |
9593
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
327 open, |
e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
albeu
parents:
7368
diff
changeset
|
328 NULL |
6278 | 329 }; |
330 | |
331 //===========================================================================// |