comparison Meerwald/wm_bruyn_e.c @ 20:bd669312f068

suppress warnings, fix link errors
author Peter Meerwald-Stadler <pmeerw@pmeerw.net>
date Sat, 28 Jan 2023 23:54:58 +0100
parents 4987db85cfae
children
comparison
equal deleted inserted replaced
19:0fffb6f03ebf 20:bd669312f068
39 double *slope; 39 double *slope;
40 int rows, cols, format; 40 int rows, cols, format;
41 int c; 41 int c;
42 int i, j; 42 int i, j;
43 int n; 43 int n;
44 int col, row; 44 int row;
45 int n_block; 45 int n_block;
46 int skipping = 0; 46 int skipping = 0;
47 47
48 char signature_name[MAXPATHLEN]; 48 char signature_name[MAXPATHLEN];
49 char input_name[MAXPATHLEN] = "(stdin)"; 49 char input_name[MAXPATHLEN] = "(stdin)";
66 pgm_init(&argc, argv); wm_init(); 66 pgm_init(&argc, argv); wm_init();
67 67
68 // parse command line and set options 68 // parse command line and set options
69 while ((c = getopt(argc, argv, "b:h?n:o:p:P:q:s:t:T:v:k")) != EOF) { 69 while ((c = getopt(argc, argv, "b:h?n:o:p:P:q:s:t:T:v:k")) != EOF) {
70 switch (c) { 70 switch (c) {
71 case 'k': 71 case 'k':
72 skipping = 1; 72 skipping = 1;
73 break; 73 break;
74 case 'h': 74 case 'h':
75 case '?': 75 case '?':
76 usage(); 76 usage();
194 fscanf(sig, "%d\n", &blocksize); 194 fscanf(sig, "%d\n", &blocksize);
195 else 195 else
196 fscanf(sig, "%*d\n"); 196 fscanf(sig, "%*d\n");
197 fscanf(sig, "%d\n", &seed); 197 fscanf(sig, "%d\n", &seed);
198 srandom(seed); 198 srandom(seed);
199 n_signature = NBITSTOBYTES(nbit_signature); 199 fread(signature, sizeof(char), NBITSTOBYTES(nbit_signature), sig);
200 fread(signature, sizeof(char), n_signature, sig);
201 fscanf(sig, "\n"); 200 fscanf(sig, "\n");
202 } 201 }
203 else { 202 else {
204 fprintf(stderr, "%s: invalid signature file %s\n", progname, signature_name); 203 fprintf(stderr, "%s: invalid signature file %s\n", progname, signature_name);
205 exit(1); 204 exit(1);
240 pgm_readpgmrow(in, image[row], cols, maxval, format); 239 pgm_readpgmrow(in, image[row], cols, maxval, format);
241 240
242 fclose(in); 241 fclose(in);
243 242
244 row = 0; 243 row = 0;
245 col = 0;
246 244
247 // allocate memory for one block 245 // allocate memory for one block
248 block = alloc_grays(blocksize, blocksize); 246 block = alloc_grays(blocksize, blocksize);
249 247
250 // allocate memory for zone classification 248 // allocate memory for zone classification
252 250
253 // allocate memory for category classification 251 // allocate memory for category classification
254 category1 = alloc_grays(blocksize, blocksize); 252 category1 = alloc_grays(blocksize, blocksize);
255 category2 = alloc_grays(blocksize, blocksize); 253 category2 = alloc_grays(blocksize, blocksize);
256 254
257 // set up category classification array according to 255 // set up category classification array according to
258 // pattern type parameter 256 // pattern type parameter
259 for (i = 0; i < blocksize; i++) 257 for (i = 0; i < blocksize; i++)
260 for (j = 0; j < blocksize; j++) { 258 for (j = 0; j < blocksize; j++) {
261 category1[j][i] = lookup_pattern(pattern1, i, j); 259 category1[j][i] = lookup_pattern(pattern1, i, j);
262 category2[j][i] = lookup_pattern(pattern2, i, j); 260 category2[j][i] = lookup_pattern(pattern2, i, j);
284 xb = random() % (cols / blocksize); 282 xb = random() % (cols / blocksize);
285 yb = random() % (rows / blocksize); 283 yb = random() % (rows / blocksize);
286 } while (add_coord(coords, xb, yb) < 0); 284 } while (add_coord(coords, xb, yb) < 0);
287 285
288 // copy image block 286 // copy image block
289 copy_grays_to_block(block, image, xb * blocksize, yb * blocksize, blocksize, blocksize); 287 copy_grays_to_block(block, image, xb * blocksize, yb * blocksize, blocksize, blocksize);
290 288
291 if (verbose > 0) 289 if (verbose > 0)
292 fprintf(stderr, "embedding bit #%d (= %d) in block at (%d/%d)\n", n, get_signature_bit(n), xb * blocksize, yb * blocksize); 290 fprintf(stderr, "embedding bit #%d (= %d) in block at (%d/%d)\n", n, get_signature_bit(n), xb * blocksize, yb * blocksize);
293 if (verbose > 8) { 291 if (verbose > 8) {
294 print_grays(image, xb * blocksize, yb * blocksize, blocksize, blocksize); 292 print_grays(image, xb * blocksize, yb * blocksize, blocksize, blocksize);

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.