27 #define FIXP (1 << 16)
28 #define MY_PI 205887 // (M_PI * FIX)
48 if (a >=
MY_PI * 3 / 2)
57 #define ONE_HALF (1 << (SCALEBITS - 1))
58 #define FIX(x) ((int) ((x) * (1L << SCALEBITS) + 0.5))
61 unsigned char *cr,
unsigned char *src,
64 int wrap, wrap3, x, y;
65 int r,
g,
b, r1, g1, b1;
71 for (y = 0; y <
height; y += 2) {
72 for (x = 0; x <
width; x += 2) {
79 lum[0] = (
FIX(0.29900) * r +
FIX(0.58700) * g +
87 lum[1] = (
FIX(0.29900) * r +
FIX(0.58700) * g +
98 lum[0] = (
FIX(0.29900) * r +
FIX(0.58700) * g +
106 lum[1] = (
FIX(0.29900) * r +
FIX(0.58700) * g +
109 cb[0] = ((-
FIX(0.16874) * r1 -
FIX(0.33126) * g1 +
111 cr[0] = ((
FIX(0.50000) * r1 -
FIX(0.41869) * g1 -
125 #define DEFAULT_WIDTH 352
126 #define DEFAULT_HEIGHT 288
127 #define DEFAULT_NB_PICT 50
134 unsigned char *cb, *cr;
135 unsigned char *lum_tab, *cb_tab, *cr_tab;
138 cb_tab =
malloc(w * h / 4);
139 cr_tab =
malloc(w * h / 4);
143 f = fopen(filename,
"wb");
144 fprintf(f,
"P5\n%d %d\n%d\n", w, h * 3 / 2, 255);
145 fwrite(lum_tab, 1, w * h, f);
150 for (i = 0; i < h2; i++) {
151 fwrite(cb, 1, w2, f);
152 fwrite(cr, 1, w2, f);
170 if (x < 0 || x >=
width ||
187 static int ipol(uint8_t *src,
int x,
int y)
191 int frac_x = x & 0xFFFF;
192 int frac_y = y & 0xFFFF;
193 int s00 = src[( int_x & 255) + 256 * ( int_y & 255)];
194 int s01 = src[((int_x + 1) & 255) + 256 * ( int_y & 255)];
195 int s10 = src[( int_x & 255) + 256 * ((int_y + 1) & 255)];
196 int s11 = src[((int_x + 1) & 255) + 256 * ((int_y + 1) & 255)];
197 int s0 = (((1 << 16) - frac_x) * s00 + frac_x * s01) >> 8;
198 int s1 = (((1 << 16) - frac_x) * s10 + frac_x * s11) >> 8;
200 return (((1 << 16) - frac_y) * s0 + frac_y * s1) >> 24;
205 const int c =
h_cos[num % 360];
206 const int s =
h_sin[num % 360];
208 const int xi = -(w / 2) * c;
209 const int yi = (w / 2) * s;
211 const int xj = -(h / 2) * s;
212 const int yj = -(h / 2) * c;
219 for (j = 0; j < h; j++) {
220 x = xprime + xi +
FIXP * w / 2;
223 y = yprime + yi +
FIXP * h / 2;
226 for (i = 0; i < w; i++) {
249 input_file = fopen(filename,
"rb");
255 if (fread(line, 1, 15, input_file) != 15)
257 for (i = 0; i <
H; i++) {
258 if (fread(line, 1, 3 *
W, input_file) != 3 *
W)
260 for (j = 0; j <
W; j++) {
261 tab_r[W * i + j] = line[3 * j ];
262 tab_g[W * i + j] = line[3 * j + 1];
263 tab_b[W * i + j] = line[3 * j + 2];
269 for (i = 0; i < 360; i++) {
270 radian = 2 * i *
MY_PI / 360;
279 int main(
int argc,
char **argv)
285 printf(
"usage: %s directory/ image.pnm\n"
286 "generate a test video stream\n", argv[0]);
302 snprintf(buf,
sizeof(buf),
"%s%02d.pgm", argv[1], i);