changeset 20:bd669312f068

suppress warnings, fix link errors
author Peter Meerwald-Stadler <pmeerw@pmeerw.net>
date Sat, 28 Jan 2023 23:54:58 +0100
parents 0fffb6f03ebf
children 1c4ccd635a68
files Meerwald/Makefile Meerwald/cmp_cox_sig.c Meerwald/cmp_dct8x8.c Meerwald/cmp_pgm.c Meerwald/cmp_ppm.c Meerwald/cmp_wang_sig.c Meerwald/dct.c Meerwald/frid2_common.c Meerwald/signature-utils.c Meerwald/signature-utils.h Meerwald/signature.c Meerwald/signature.h Meerwald/wang_common.c Meerwald/wang_common.h Meerwald/wavelet.c Meerwald/wm_bruyn_d.c Meerwald/wm_bruyn_e.c Meerwald/wm_kund2_d.c make/make.linux
diffstat 19 files changed, 225 insertions(+), 233 deletions(-) [+]
line wrap: on
line diff
--- a/Meerwald/Makefile	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/Makefile	Sat Jan 28 23:54:58 2023 +0100
@@ -27,13 +27,13 @@
 	$(CC) $(CFLAGS) $(INCLUDES) $(OPTIONS) -o $@ -c $<
 
 .1.ps:
-	$(GROFF) $< > $@ 
+	$(GROFF) $< > $@
 
 # library containing general stuff
 
-$(LIBPREFIX)wm$(LIB): dct$(O) coeff$(O) gray$(O) sort$(O) signature$(O) coord$(O) wm$(O)
+$(LIBPREFIX)wm$(LIB): dct$(O) coeff$(O) gray$(O) sort$(O) signature-utils$(O) coord$(O) wm$(O)
 	$(RM) $@
-	ar -rc $@ dct$(O) coeff$(O) gray$(O) sort$(O) signature$(O) coord$(O) wm$(O)
+	ar -rc $@ dct$(O) coeff$(O) gray$(O) sort$(O) signature-utils$(O) coord$(O) wm$(O)
 
 libraryclean:
 	$(RM) $(LIBPREFIX)wm$(LIB)
@@ -162,8 +162,8 @@
 wm_bruyn_d$(EXE): wm_bruyn_d$(O)  bruyn_common$(O) $(LIBPREFIX)wm$(LIB)
 	$(CC) $(LDFLAGS) -o $@  wm_bruyn_d$(O) bruyn_common$(O) $(WMLIB) $(LIBS) $(PGMLIBS)
 
-gen_bruyn_sig$(EXE): gen_bruyn_sig$(O) wm$(O)
-	$(CC) $(LDFLAGS) -o $@ gen_bruyn_sig$(O) wm$(O) $(LIBS)
+gen_bruyn_sig$(EXE): gen_bruyn_sig$(O) wm$(O) $(LIBPREFIX)wm$(LIB)
+	$(CC) $(LDFLAGS) -o $@ gen_bruyn_sig$(O) wm$(O) $(WMLIB)
 
 cmp_bruyn_sig$(EXE): cmp_bruyn_sig$(O) $(LIBPREFIX)wm$(LIB)
 	$(CC) $(LDFLAGS) -o $@ cmp_bruyn_sig$(O) $(WMLIB) $(LIBS)
@@ -176,7 +176,7 @@
 coxtest: cox
 	gen_cox_sig$(EXE) > ../sigs/cox.sig
 	wm_cox_e$(EXE) -s ../sigs/cox.sig -o ../watermarked/cox_lena.pgm ../images/lena.pgm
-	wm_cox_d$(EXE) -s ../sigs/cox.sig -o ../wms/cox.wm -i ../images/lena.pgm ../watermarked/cox_lena.pgm 
+	wm_cox_d$(EXE) -s ../sigs/cox.sig -o ../wms/cox.wm -i ../images/lena.pgm ../watermarked/cox_lena.pgm
 	cmp_cox_sig$(EXE) -s ../sigs/cox.sig ../wms/cox.wm
 
 coxinstall: cox
@@ -207,7 +207,7 @@
 corvitest: corvi
 	gen_corvi_sig$(EXE) > ../sigs/corvi.sig
 	wm_corvi_e$(EXE) -s ../sigs/corvi.sig -o ../watermarked/corvi_lena.pgm ../images/lena.pgm
-	wm_corvi_d$(EXE) -s ../sigs/corvi.sig -o ../wms/corvi.wm -i ../images/lena.pgm ../watermarked/corvi_lena.pgm 
+	wm_corvi_d$(EXE) -s ../sigs/corvi.sig -o ../wms/corvi.wm -i ../images/lena.pgm ../watermarked/corvi_lena.pgm
 	cmp_corvi_sig$(EXE) -s ../sigs/corvi.sig ../wms/corvi.wm
 
 corviinstall: corvi
@@ -238,7 +238,7 @@
 xiatest: xia
 	gen_xia_sig$(EXE) > ../sigs/xia.sig
 	wm_xia_e$(EXE) -s ../sigs/xia.sig -o ../watermarked/xia_lena.pgm ../images/lena.pgm
-	wm_xia_d$(EXE) -s ../sigs/xia.sig -o ../wms/xia.wm -i ../images/lena.pgm ../watermarked/xia_lena.pgm 
+	wm_xia_d$(EXE) -s ../sigs/xia.sig -o ../wms/xia.wm -i ../images/lena.pgm ../watermarked/xia_lena.pgm
 	cmp_xia_sig$(EXE) -s ../sigs/xia.sig ../wms/xia.wm
 
 xiainstall: xia
@@ -268,7 +268,7 @@
 wangtest: wang
 	gen_wang_sig$(EXE) -n 1000 > ../sigs/wang.sig
 	wm_wang_e$(EXE) -s ../sigs/wang.sig -o ../watermarked/wang_lena.pgm ../images/lena.pgm
-	wm_wang_d$(EXE) -s ../sigs/wang.sig -o ../wms/wang.wm -i ../images/lena.pgm ../watermarked/wang_lena.pgm 
+	wm_wang_d$(EXE) -s ../sigs/wang.sig -o ../wms/wang.wm -i ../images/lena.pgm ../watermarked/wang_lena.pgm
 	cmp_wang_sig$(EXE) -s ../sigs/wang.sig ../wms/wang.wm
 
 wanginstall: wang
@@ -298,7 +298,7 @@
 kimtest: kim
 	gen_kim_sig$(EXE) -n 1000 > ../sigs/kim.sig
 	wm_kim_e$(EXE) -s ../sigs/kim.sig -o ../watermarked/kim_lena.pgm ../images/lena.pgm
-	wm_kim_d$(EXE) -s ../sigs/kim.sig -o ../wms/kim.wm -i ../images/lena.pgm ../watermarked/kim_lena.pgm 
+	wm_kim_d$(EXE) -s ../sigs/kim.sig -o ../wms/kim.wm -i ../images/lena.pgm ../watermarked/kim_lena.pgm
 	cmp_kim_sig$(EXE) -s ../sigs/kim.sig ../wms/kim.wm
 
 kiminstall: kim
@@ -328,7 +328,7 @@
 zhutest: zhu
 	gen_zhu_sig$(EXE) > ../sigs/zhu.sig
 	wm_zhu_e$(EXE) -s ../sigs/zhu.sig -o ../watermarked/zhu_lena.pgm ../images/lena.pgm
-	wm_zhu_d$(EXE) -s ../sigs/zhu.sig -o ../wms/zhu.wm -i ../images/lena.pgm ../watermarked/zhu_lena.pgm 
+	wm_zhu_d$(EXE) -s ../sigs/zhu.sig -o ../wms/zhu.wm -i ../images/lena.pgm ../watermarked/zhu_lena.pgm
 	cmp_zhu_sig$(EXE) -s ../sigs/zhu.sig ../wms/zhu.wm
 
 zhuinstall: zhu
@@ -432,8 +432,8 @@
 wm_kund2_d$(EXE): wm_kund2_d$(O) $(LIBPREFIX)wm$(LIB) $(LIBPREFIX)wavelet$(LIB)
 	$(CC) $(LDFLAGS) -o $@  wm_kund2_d$(O) $(WMLIB) $(WAVELIB) $(LIBS) $(PGMLIBS)
 
-gen_kund2_sig$(EXE): gen_kund2_sig$(O) wm$(O) signature$(O)
-	$(CC) $(LDFLAGS) -o $@ gen_kund2_sig$(O) wm$(O) signature$(O) $(LIBS)
+gen_kund2_sig$(EXE): gen_kund2_sig$(O) wm$(O) signature-utils$(O)
+	$(CC) $(LDFLAGS) -o $@ gen_kund2_sig$(O) wm$(O) signature-utils$(O) $(LIBS)
 
 cmp_kund2_sig$(EXE): cmp_kund2_sig$(O) $(LIBPREFIX)wm$(LIB)
 	$(CC) $(LDFLAGS) -o $@ cmp_kund2_sig$(O) $(WMLIB) $(LIBS)
@@ -448,7 +448,7 @@
 kund3test: kund3
 	gen_kund3_sig$(EXE) -n 1000 -l 2 -q 2 gen_kund3_sig.c > ../sigs/kund3.sig
 	wm_kund3_e$(EXE) -s ../sigs/kund3.sig -o ../watermarked/kund3_lena.pgm ../images/lena.pgm
-	wm_kund3_d$(EXE) -s ../sigs/kund3.sig -o ../wms/kund3.wm ../watermarked/kund3_lena.pgm 
+	wm_kund3_d$(EXE) -s ../sigs/kund3.sig -o ../wms/kund3.wm ../watermarked/kund3_lena.pgm
 	cmp_kund3_sig$(EXE) -s ../sigs/kund3.sig ../wms/kund3.wm
 
 kund3install: kund3
@@ -462,8 +462,8 @@
 wm_kund3_d$(EXE): wm_kund3_d$(O) $(LIBPREFIX)wm$(LIB) $(LIBPREFIX)wavelet$(LIB)
 	$(CC) $(LDFLAGS) -o $@  wm_kund3_d$(O) $(WMLIB) $(WAVELIB) $(LIBS) $(PGMLIBS)
 
-gen_kund3_sig$(EXE): gen_kund3_sig$(O) wm$(O) signature$(O)
-	$(CC) $(LDFLAGS) -o $@ gen_kund3_sig$(O) wm$(O) signature$(O) $(LIBS)
+gen_kund3_sig$(EXE): gen_kund3_sig$(O) wm$(O) signature-utils$(O)
+	$(CC) $(LDFLAGS) -o $@ gen_kund3_sig$(O) wm$(O) signature-utils$(O) $(LIBS)
 
 cmp_kund3_sig$(EXE): cmp_kund3_sig$(O) $(LIBPREFIX)wm$(LIB)
 	$(CC) $(LDFLAGS) -o $@ cmp_kund3_sig$(O) $(WMLIB) $(LIBS)
@@ -505,8 +505,7 @@
 
 clean:	coxclean bruynclean kochclean corviclean xiaclean zhuclean xieclean kund3clean kund2clean \
 	dugadclean kimclean wangclean frid2clean toolsclean libraryclean waveletclean xie2clean
-	$(RM) *$(O) *.ps ../sigs/* ../wms/* ../watermarked/* 
-	
+	$(RM) *$(O) *.ps ../sigs/* ../wms/* ../watermarked/*
 
 man:	coxman bruynman kochman corviman xiaman xieman toolsman
 
--- a/Meerwald/cmp_cox_sig.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/cmp_cox_sig.c	Sat Jan 28 23:54:58 2023 +0100
@@ -3,8 +3,7 @@
 char *progname;
 
 void usage(void) {
-  fprintf(stderr, "usage: %s [-h] [-C] [-o file] [-v n] -s file file\n\n", progname);
-  fprintf(stderr, "\t-C\t\toutput correlation only\n");
+  fprintf(stderr, "usage: %s [-h] [-o file] [-v n] -s file file\n\n", progname);
   fprintf(stderr, "\t-h\t\tprint usage\n");
   fprintf(stderr, "\t-o file\t\toutput file\n");
   fprintf(stderr, "\t-s file\t\toriginal signature file\n");
@@ -28,21 +27,17 @@
   double sig_mean, sig_variance;
   double s1, s2, s3;
   char line[32];
- 
+
   int verbose = 0;
-  int correlation_only = 0;
 
   progname = argv[0];
 
-  while ((c = getopt(argc, argv, "h?Co:s:v:")) != EOF) {
+  while ((c = getopt(argc, argv, "h?o:s:v:")) != EOF) {
     switch (c) {
       case 'h':
       case '?':
         usage();
         break;
-      case 'C':
-        correlation_only = 1;
-        break;
       case 'o':
         if ((out = fopen(optarg, "w")) == NULL) {
           fprintf(stderr, "%s: unable to open output file %s\n", progname, optarg);
@@ -134,7 +129,7 @@
     fscanf(in, "%lf\n", &in_x);
 
     if (verbose >= 1) {
-      fprintf(stderr, "orig %f input %f\n", sig_x, in_x);  
+      fprintf(stderr, "orig %f input %f\n", sig_x, in_x);
     }
 
     s1 += sig_x * in_x;
--- a/Meerwald/cmp_dct8x8.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/cmp_dct8x8.c	Sat Jan 28 23:54:58 2023 +0100
@@ -157,10 +157,12 @@
       fdct_block_8x8(input_image, col, 0, input_dcts);
       fdct_block_8x8(orig_image, col, 0, orig_dcts);
 
-      for (i = 0; i < NJPEG; i++)
-        for (j = 0; j < NJPEG; j++)
+      for (i = 0; i < NJPEG; i++) {
+        for (j = 0; j < NJPEG; j++) {
           error += sqr(input_dcts[j][i + cols] - orig_dcts[j][i + cols]);
           output[j][i + col] = PIXELRANGE(fabs(input_dcts[j][i + cols] - orig_dcts[j][i + cols]) * m);
+        }
+      }
     }
 
     if (!print_psnr_only) {
--- a/Meerwald/cmp_pgm.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/cmp_pgm.c	Sat Jan 28 23:54:58 2023 +0100
@@ -32,7 +32,7 @@
   gray in_maxval;
   int orig_cols, orig_rows, orig_format;
   gray orig_maxval;
-  int cols, rows, format;
+  int cols, rows;
   gray maxval;
   int col, row;
 
@@ -123,7 +123,6 @@
 
   cols = in_cols;
   rows = in_rows;
-  format = in_format;
   maxval = in_maxval;
 
   input_image = pgm_allocarray(cols, rows);
--- a/Meerwald/cmp_ppm.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/cmp_ppm.c	Sat Jan 28 23:54:58 2023 +0100
@@ -39,7 +39,7 @@
   pixval in_maxval;
   int orig_cols, orig_rows, orig_format;
   pixval orig_maxval;
-  int cols, rows, format;
+  int cols, rows;
   pixval maxval;
   int col, row;
 
@@ -163,7 +163,6 @@
 
   cols = in_cols;
   rows = in_rows;
-  format = in_format;
   maxval = in_maxval;
 
   input_image = ppm_allocarray(cols, rows);
--- a/Meerwald/cmp_wang_sig.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/cmp_wang_sig.c	Sat Jan 28 23:54:58 2023 +0100
@@ -3,8 +3,7 @@
 char *progname;
 
 void usage(void) {
-  fprintf(stderr, "usage: %s [-h] [-C] [-o file] [-v n] -s file file\n\n", progname);
-  fprintf(stderr, "\t-C\t\toutput correlation only\n");
+  fprintf(stderr, "usage: %s [-h] [-o file] [-v n] -s file file\n\n", progname);
   fprintf(stderr, "\t-h\t\tprint usage\n");
   fprintf(stderr, "\t-o file\t\toutput file\n");
   fprintf(stderr, "\t-v n\t\tverbosity level\n");
@@ -30,19 +29,15 @@
   char line[32];
 
   int verbose = 0;
-  int correlation_only = 0;
 
   progname = argv[0];
 
-  while ((c = getopt(argc, argv, "h?Co:s:v:")) != EOF) {
+  while ((c = getopt(argc, argv, "h?o:s:v:")) != EOF) {
     switch (c) {
       case 'h':
       case '?':
         usage();
         break;
-      case 'C':
-        correlation_only = 1;
-        break;
       case 'o':
         if ((out = fopen(optarg, "w")) == NULL) {
           fprintf(stderr, "%s: unable to open output file %s\n", progname, optarg);
@@ -83,7 +78,7 @@
     else
       strcpy(input_name, argv[0]);
   }
-    
+
   if (!sig) {
     fprintf(stderr, "%s: original signature file not specified, use -s file option\n", progname);
     exit(1);
--- a/Meerwald/dct.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/dct.c	Sat Jan 28 23:54:58 2023 +0100
@@ -21,16 +21,6 @@
     {49,  64,  78,  87, 103, 121, 120, 101},
     {72,  92,  95,  98, 112, 100, 103,  99}};
 
-static const unsigned int JPEG_chromin_quant_table[NJPEG][NJPEG] = {
-      {17,  18,  24,  47,  99,  99,  99,  99},
-      {18,  21,  26,  66,  99,  99,  99,  99},
-      {24,  26,  56,  99,  99,  99,  99,  99},
-      {47,  66,  99,  99,  99,  99,  99,  99},
-      {99,  99,  99,  99,  99,  99,  99,  99},
-      {99,  99,  99,  99,  99,  99,  99,  99},
-      {99,  99,  99,  99,  99,  99,  99,  99},
-      {99,  99,  99,  99,  99,  99,  99,  99}};
-
 static void initcosarray()
 {
   int i,group,base,item,nitems,halfN;
--- a/Meerwald/frid2_common.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/frid2_common.c	Sat Jan 28 23:54:58 2023 +0100
@@ -1,5 +1,5 @@
 #include "frid2_common.h"
-#include "signature.h"
+#include "signature-utils.h"
 #include "wm.h"
 
 extern char *progname;
@@ -43,7 +43,7 @@
       if (fabs(d - x) < fabs(d - x * BACKWARD_STEP(alpha)))
         x *= FORWARD_STEP(alpha);
       else
-        x *= BACKWARD_STEP(alpha);        
+        x *= BACKWARD_STEP(alpha);
     }
 
     d =  (x + x * BACKWARD_STEP(alpha)) / 2.0;
@@ -54,8 +54,8 @@
     dcts[row][col] = d;
 
     n++;
-  }  
-}        
+  }
+}
 
 void embed_med_freq(double **dcts, int cols, int rows, double gamma, int seed, int verbose) {
   // select mid-frequency (30%) coefficients
@@ -64,12 +64,12 @@
 
   double *vector;
   int x = 0, y = 0, dir = 1;
-  int i, j;    
+  int i, j;
 
   vector = malloc((end - start) * sizeof(double));
   for (i = 0; i < (end - start); i++)
     vector[i] = 0.0;
-        
+
   // create pseudo-random vector
   srandom(seed);
   for (i = 0; i < nbit_signature; i++) {
@@ -98,7 +98,7 @@
 //      fprintf(stderr, "%d/%d: %f -> %f\n", x, y, dcts[y][x], dcts[y][x] + gamma * vector[i - start]);
       dcts[y][x] += gamma * vector[i - start];
     }
-  }        
+  }
 
   free(vector);
 }
@@ -148,7 +148,7 @@
     sum2 += pow(fabs(d), beta);
 
     n++;
-  }  
+  }
 
   return sum1 / sum2;
 }
@@ -165,7 +165,7 @@
   double corr[2];
   double correlation;
 
-  // locate start positions 
+  // locate start positions
   for (i = 0; i < start; i++) {
     x -= dir;
     y += dir;
@@ -173,10 +173,10 @@
     if (x >= cols) { dir = 1; x = cols - 1; y += 2; }
     if (y < 0) { dir = 1; y = 0; }
     if (y >= rows) { dir = -1; y = rows - 1; x += 2; }
-  }		
+  }
 
   // save start positions
-  startx = x;		
+  startx = x;
   starty = y;
   startdir = dir;
   srandom(seed);
@@ -187,14 +187,14 @@
 
     for (j = 0; j <= (end - start); j++)
       vector[j] = (double) (random() & RAND_MAX) / (double) RAND_MAX - 0.5;
-				
+
     for (j = 0; j <= 1; j++) {
       x = startx;
       y = starty;
       dir = startdir;
       corr[j] = 0;
 
-      for (k = 0; start + k < end; k++) {   
+      for (k = 0; start + k < end; k++) {
         x -= dir;
         y += dir;
         if (x < 0) { dir = -1; x = 0; }
@@ -203,7 +203,7 @@
         if (y >= rows) { dir = -1; y = rows - 1; x += 2; }
         corr[j] += dcts[y][x] * vector[k + j];
       }
-    }	
+    }
 
     set_signature2_bit(i,  (corr[0] >= corr[1]) ? 0 : 1);
   }
@@ -216,5 +216,5 @@
   }
   correlation = (double) sum / (sqrt(sum1) * sqrt(sum2));
 
-  return correlation;		
+  return correlation;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Meerwald/signature-utils.c	Sat Jan 28 23:54:58 2023 +0100
@@ -0,0 +1,120 @@
+#include <string.h>
+#include <strings.h>
+#include "signature-utils.h"
+
+void init_signature_bits() {
+  bzero(signature, sizeof(signature));
+}
+
+void init_signature1_bits() {
+  bzero(signature1, sizeof(signature1));
+}
+
+void init_signature2_bits() {
+  bzero(signature2, sizeof(signature2));
+}
+
+int _get_signature_bit(char *s, int lim, int n) {
+  int byte = n >> 3;
+  int bit = n & 7;
+
+#ifdef DEBUG
+  if (byte < 0 || byte >= lim)
+    fprintf(stderr, "get_signature_bit?(): index out of range\n");
+#endif
+
+  return (s[byte] & (1 << bit)) >> bit;
+}
+
+int get_signature_bit(int n) {
+  return _get_signature_bit(signature, NSIGNATURE, n);
+}
+
+int get_signature1_bit(int n) {
+  return _get_signature_bit(signature1, NSIGNATURE, n);
+}
+
+int get_signature2_bit(int n) {
+  return _get_signature_bit(signature2, NSIGNATURE, n);
+}
+
+void _set_signature_bit(char *s, int limit, int n, int v) {
+  int byte = n >> 3;
+  int bit = n & 7;
+
+#ifdef DEBUG
+  if (byte < 0 || byte >= limit / 8)
+    fprintf(stderr, "get_signature_bit?(): index out of range\n");
+#endif
+
+  if (v)
+    s[byte] |= (1 << bit);
+  else
+    s[byte] &= ~(1 << bit);
+}
+
+void set_signature_bit(int n, int v) {
+  _set_signature_bit(signature, NSIGNATURE, n, v);
+}
+
+void set_signature1_bit(int n, int v) {
+  _set_signature_bit(signature1, NSIGNATURE, n, v);
+}
+
+void set_signature2_bit(int n, int v) {
+  _set_signature_bit(signature2, NSIGNATURE, n, v);
+}
+
+int _binstr_to_sig(const char *binstr, char *sig, int *bytes, int *bits) {
+  int n = strlen(binstr);
+  int i;
+
+  for (i = 0; i < n; i++) {
+    if (binstr[i] == '0')
+      _set_signature_bit(sig, NSIGNATURE, i, 0);
+    else if (binstr[i] == '1')
+      _set_signature_bit(sig, NSIGNATURE, i, 1);
+    else
+      return 0;
+  }
+
+  *bytes = (n % 8 > 0) ? n / 8 + 1 : n / 8;
+  *bits = n;
+
+  return 1;  
+}
+
+int binstr_to_sig(const char *binstr) {
+  return _binstr_to_sig(binstr, signature, &n_signature, &nbit_signature);
+}
+
+int binstr_to_sig1(const char *binstr) {
+  return _binstr_to_sig(binstr, signature1, &n_signature1, &nbit_signature1);
+}
+
+int binstr_to_sig2(const char *binstr) {
+  return _binstr_to_sig(binstr, signature2, &n_signature2, &nbit_signature2);
+}
+
+int _sig_to_binstr(char *binstr, char *sig, int bits) {
+  int i;
+
+  for (i = 0; i < bits; i++)
+    binstr[i] = _get_signature_bit(sig, NSIGNATURE, i) ? '1' : '0';
+
+  binstr[bits] = '\0';
+
+  return 1;
+}
+
+int sig_to_binstr(char *binstr) {
+  return _sig_to_binstr(binstr, signature, nbit_signature);
+}
+
+int sig1_to_binstr(char *binstr) {
+  return _sig_to_binstr(binstr, signature1, nbit_signature1);
+}
+
+int sig2_to_binstr(char *binstr) {
+  return _sig_to_binstr(binstr, signature2, nbit_signature2);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Meerwald/signature-utils.h	Sat Jan 28 23:54:58 2023 +0100
@@ -0,0 +1,37 @@
+#ifndef SIGNATURE_UTILS_H
+#define SIGNATURE_UTILS_H
+
+#define NSIGNATURE 4096
+#define NBITSIGNATURE (NSIGNATURE * 8)
+
+extern int n_signature;
+extern int nbit_signature;
+extern int n_signature1;
+extern int nbit_signature1;
+extern int n_signature2;
+extern int nbit_signature2;
+
+extern char signature[NSIGNATURE];
+extern char signature1[NSIGNATURE];
+extern char signature2[NSIGNATURE];
+
+void init_signature_bits();
+int get_signature_bit(int n);
+void set_signature_bit(int n, int v);
+
+void init_signature1_bits();
+int get_signature1_bit(int n);
+void set_signature1_bit(int n, int v);
+
+void init_signature2_bits();
+int get_signature2_bit(int n);
+void set_signature2_bit(int n, int v);
+
+int binstr_to_sig(const char *binstr);
+int binstr_to_sig1(const char *binstr);
+int binstr_to_sig2(const char *binstr);
+int sig_to_binstr(char *binstr);
+int sig1_to_binstr(char *binstr);
+int sig2_to_binstr(char *binstr);
+
+#endif
--- a/Meerwald/signature.c	Tue Sep 21 13:40:51 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-#include "signature.h"
-
-void init_signature_bits() {
-  bzero(signature, sizeof(signature));
-}
-
-void init_signature1_bits() {
-  bzero(signature1, sizeof(signature1));
-}
-
-void init_signature2_bits() {
-  bzero(signature2, sizeof(signature2));
-}
-
-int _get_signature_bit(char *s, int lim, int n) {
-  int byte = n >> 3;
-  int bit = n & 7;
-
-#ifdef DEBUG
-  if (byte < 0 || byte >= lim)
-    fprintf(stderr, "get_signature_bit?(): index out of range\n");
-#endif
-
-  return (s[byte] & (1 << bit)) >> bit;
-}
-
-int get_signature_bit(int n) {
-  return _get_signature_bit(signature, NSIGNATURE, n);
-}
-
-int get_signature1_bit(int n) {
-  return _get_signature_bit(signature1, NSIGNATURE, n);
-}
-
-int get_signature2_bit(int n) {
-  return _get_signature_bit(signature2, NSIGNATURE, n);
-}
-
-void _set_signature_bit(char *s, int limit, int n, int v) {
-  int byte = n >> 3;
-  int bit = n & 7;
-
-#ifdef DEBUG
-  if (byte < 0 || byte >= limit / 8)
-    fprintf(stderr, "get_signature_bit?(): index out of range\n");
-#endif
-
-  if (v)
-    s[byte] |= (1 << bit);
-  else
-    s[byte] &= ~(1 << bit);
-}
-
-void set_signature_bit(int n, int v) {
-  _set_signature_bit(signature, NSIGNATURE, n, v);
-}
-
-void set_signature1_bit(int n, int v) {
-  _set_signature_bit(signature1, NSIGNATURE, n, v);
-}
-
-void set_signature2_bit(int n, int v) {
-  _set_signature_bit(signature2, NSIGNATURE, n, v);
-}
-
-int _binstr_to_sig(const char *binstr, char *sig, int *bytes, int *bits) {
-  int n = strlen(binstr);
-  int i;
-
-  for (i = 0; i < n; i++) {
-    if (binstr[i] == '0')
-      _set_signature_bit(sig, NSIGNATURE, i, 0);
-    else if (binstr[i] == '1')
-      _set_signature_bit(sig, NSIGNATURE, i, 1);
-    else
-      return 0;
-  }
-
-  *bytes = (n % 8 > 0) ? n / 8 + 1 : n / 8;
-  *bits = n;
-
-  return 1;  
-}
-
-int binstr_to_sig(const char *binstr) {
-  return _binstr_to_sig(binstr, signature, &n_signature, &nbit_signature);
-}
-
-int binstr_to_sig1(const char *binstr) {
-  return _binstr_to_sig(binstr, signature1, &n_signature1, &nbit_signature1);
-}
-
-int binstr_to_sig2(const char *binstr) {
-  return _binstr_to_sig(binstr, signature2, &n_signature2, &nbit_signature2);
-}
-
-int _sig_to_binstr(char *binstr, char *sig, int bits) {
-  int i;
-
-  for (i = 0; i < bits; i++)
-    binstr[i] = _get_signature_bit(sig, NSIGNATURE, i) ? '1' : '0';
-
-  binstr[bits] = '\0';
-
-  return 1;
-}
-
-int sig_to_binstr(char *binstr) {
-  return _sig_to_binstr(binstr, signature, nbit_signature);
-}
-
-int sig1_to_binstr(char *binstr) {
-  return _sig_to_binstr(binstr, signature1, nbit_signature1);
-}
-
-int sig2_to_binstr(char *binstr) {
-  return _sig_to_binstr(binstr, signature2, nbit_signature2);
-}
--- a/Meerwald/signature.h	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/signature.h	Sat Jan 28 23:54:58 2023 +0100
@@ -2,9 +2,7 @@
 #define SIGNATURE_H
 
 #include "wm.h"
-
-#define NSIGNATURE 4096
-#define NBITSIGNATURE (NSIGNATURE * 8)
+#include "signature-utils.h"
 
 int n_signature;
 int nbit_signature;
@@ -17,23 +15,4 @@
 char signature1[NSIGNATURE];
 char signature2[NSIGNATURE];
 
-void init_signature_bits();
-int get_signature_bit(int n);
-void set_signature_bit(int n, int v);
-
-void init_signature1_bits();
-int get_signature1_bit(int n);
-void set_signature1_bit(int n, int v);
-
-void init_signature2_bits();
-int get_signature2_bit(int n);
-void set_signature2_bit(int n, int v);
-
-int binstr_to_sig(const char *binstr);
-int binstr_to_sig1(const char *binstr);
-int binstr_to_sig2(const char *binstr);
-int sig_to_binstr(char *binstr);
-int sig1_to_binstr(char *binstr);
-int sig2_to_binstr(char *binstr);
-
 #endif
--- a/Meerwald/wang_common.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/wang_common.c	Sat Jan 28 23:54:58 2023 +0100
@@ -1,6 +1,9 @@
 #include "dwt_util.h"
 #include "wang_common.h"
 
+Subband_data *subbands;
+int n_subbands;
+
 void init_subbands(Image_tree tree) {
   int levels = 0;
   int i;
@@ -24,7 +27,7 @@
     subbands[i++] = alloc_subband(HORIZONTAL, p->horizontal);
     subbands[i++] = alloc_subband(VERTICAL, p->vertical);
     subbands[i++] = alloc_subband(DIAGONAL, p->diagonal);
-    
+
     p = p->coarse;
   }
 
@@ -44,11 +47,11 @@
   p->size = p->height * p->width;
   p->image = tree->image;
   p->type = type;
-  
+ 
   p->selected = malloc(p->height * sizeof(char *));
   p->selected[0] = calloc(p->size, sizeof(char));
   for (i = 1; i < p->height; i++)
-    p->selected[i] = &(p->selected[0][i * p->width]); 
+    p->selected[i] = &(p->selected[0][i * p->width]);
 
   return p;
 }
--- a/Meerwald/wang_common.h	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/wang_common.h	Sat Jan 28 23:54:58 2023 +0100
@@ -17,9 +17,6 @@
   char** selected;
 } *Subband_data;
 
-Subband_data *subbands;
-int n_subbands;
-
 void init_subbands(Image_tree tree);
 Subband_data alloc_subband(int type, Image_tree tree);
 void free_subband(Subband_data subband);
--- a/Meerwald/wavelet.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/wavelet.c	Sat Jan 28 23:54:58 2023 +0100
@@ -90,7 +90,7 @@
 	IntImage	img;
 	FILE		*fp;
 	IntPixel	*data;
-	int		width, height, i, max, ch1, ch2;
+	int		width, height, i, ch1, ch2;
 		
 	fp=fopen(file,"rb");
 	if (fp==NULL) goto error;
@@ -102,7 +102,7 @@
 	width=read_int(fp);
 	height=read_int(fp);
 	if ((width==0) || (height==0) ) goto error1;
-	max=read_int(fp);
+	read_int(fp);
 
 	img=new_intimage(width,height);
 
@@ -1555,7 +1555,7 @@
 
 {       Image_tree tree;
 	Image img;
-	int min,max_level,e;
+	int min,max_level;
 
 	tree=new_image_tree();
 	if(!tree) goto error;
@@ -1572,7 +1572,7 @@
 	max_level=log10((float) min/best_basis_min)/log10(2);
 	if (max_level>level) max_level=level;
 	
-	e=compute_best(tree,0,max_level,flt,method,cost,epsilon);
+	compute_best(tree,0,max_level,flt,method,cost,epsilon);
 
 	if (!tree->image) free(img);
 
--- a/Meerwald/wm_bruyn_d.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/wm_bruyn_d.c	Sat Jan 28 23:54:58 2023 +0100
@@ -41,7 +41,7 @@
   int c;
   int i, j;
   int n;
-  int col, row;
+  int row;
   int n_block;
 
   char signature_name[MAXPATHLEN];
@@ -72,7 +72,7 @@
       case '?':
         usage();
         break;
-      case 'k':  
+      case 'k':
         skipping = 1;
         break;
       case 'n':
@@ -243,7 +243,6 @@
   fclose(in);
 
   row = 0;
-  col = 0;
 
   // allocate memory for one block
   block = alloc_grays(blocksize, blocksize);
@@ -255,7 +254,7 @@
   category1 = alloc_grays(blocksize, blocksize);
   category2 = alloc_grays(blocksize, blocksize);
 
-  // set up category classification array according to 
+  // set up category classification array according to
   // pattern type parameter
   for (i = 0; i < blocksize; i++)
     for (j = 0; j < blocksize; j++) {
@@ -290,9 +289,9 @@
 
     // copy image block
     fprintf(stderr, "XXX1 %d %d %d\n", xb*blocksize, yb*blocksize, blocksize);
-    copy_grays_to_block(block, image, xb * blocksize, yb * blocksize, blocksize, blocksize);    
+    copy_grays_to_block(block, image, xb * blocksize, yb * blocksize, blocksize, blocksize);
     fprintf(stderr, "XXX2\n");
-    
+
     if (verbose > 0)
       fprintf(stderr, "detecting bit #%d in block at (%d/%d)\n", n, xb * blocksize, yb * blocksize);
 
--- a/Meerwald/wm_bruyn_e.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/wm_bruyn_e.c	Sat Jan 28 23:54:58 2023 +0100
@@ -41,7 +41,7 @@
   int c;
   int i, j;
   int n;
-  int col, row;
+  int row;
   int n_block;
   int skipping = 0;
 
@@ -68,7 +68,7 @@
   // parse command line and set options
   while ((c = getopt(argc, argv, "b:h?n:o:p:P:q:s:t:T:v:k")) != EOF) {
     switch (c) {
-      case 'k':  
+      case 'k':
         skipping = 1;
         break;
       case 'h':
@@ -196,8 +196,7 @@
         fscanf(sig, "%*d\n");
       fscanf(sig, "%d\n", &seed);
       srandom(seed);
-      n_signature = NBITSTOBYTES(nbit_signature);
-      fread(signature, sizeof(char), n_signature, sig);
+      fread(signature, sizeof(char), NBITSTOBYTES(nbit_signature), sig);
       fscanf(sig, "\n");
     }
     else {
@@ -242,7 +241,6 @@
   fclose(in);
 
   row = 0;
-  col = 0;
 
   // allocate memory for one block
   block = alloc_grays(blocksize, blocksize);
@@ -254,7 +252,7 @@
   category1 = alloc_grays(blocksize, blocksize);
   category2 = alloc_grays(blocksize, blocksize);
 
-  // set up category classification array according to 
+  // set up category classification array according to
   // pattern type parameter
   for (i = 0; i < blocksize; i++)
     for (j = 0; j < blocksize; j++) {
@@ -286,7 +284,7 @@
     } while (add_coord(coords, xb, yb) < 0);
 
     // copy image block
-    copy_grays_to_block(block, image, xb * blocksize, yb * blocksize, blocksize, blocksize);    
+    copy_grays_to_block(block, image, xb * blocksize, yb * blocksize, blocksize, blocksize);
 
     if (verbose > 0)
       fprintf(stderr, "embedding bit #%d (= %d) in block at (%d/%d)\n", n, get_signature_bit(n), xb * blocksize, yb * blocksize);
--- a/Meerwald/wm_kund2_d.c	Tue Sep 21 13:40:51 2010 +0200
+++ b/Meerwald/wm_kund2_d.c	Sat Jan 28 23:54:58 2023 +0100
@@ -228,9 +228,7 @@
     int lwidth = p->vertical->image->width;
     int lheight =  p->vertical->image->height;
     int bx, by;
-    int nblock;
 
-    nblock = 0;
     for (bx = 0; bx < lwidth; bx += blocksize) {
       for (by = 0; by < lheight; by += blocksize) {
         int bw = MIN(bx + blocksize, lwidth);
@@ -239,7 +237,7 @@
 
     // start to extracting watermark from beginning at each level
     // get width and height of detail images at current level
-  
+
     if (verbose > 1)
       fprintf(stderr, "%s: extracting at level %d now, size %d x %d\n",
         progname, p->coarse->level, lwidth, lheight);
--- a/make/make.linux	Tue Sep 21 13:40:51 2010 +0200
+++ b/make/make.linux	Sat Jan 28 23:54:58 2023 +0100
@@ -1,5 +1,5 @@
 CC = gcc
-CFLAGS = -O2 -g -DLINUX -Wall
+CFLAGS = -O2 -g -DLINUX -Wall -Wno-unused-result
 LDFLAGS = -g
 LIBS = -lm
 PGMLIBS = -lnetpbm

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