annotate libmpcodecs/vf_test.c @ 15883:b656bb4945cc

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