about summary refs log tree commit diff
path: root/other/pambayer.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-02-27 04:44:35 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-02-27 04:44:35 +0000
commit9f95511f291ecc492e283932064857717678bb19 (patch)
tree7907eb2c3a54851b9f0635d061a16466636896bf /other/pambayer.c
parent3f3a0bb41c579c667871ac322534c59323f1d801 (diff)
downloadnetpbm-mirror-9f95511f291ecc492e283932064857717678bb19.tar.gz
netpbm-mirror-9f95511f291ecc492e283932064857717678bb19.tar.xz
netpbm-mirror-9f95511f291ecc492e283932064857717678bb19.zip
Release 10.97.05
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4287 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'other/pambayer.c')
-rw-r--r--other/pambayer.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/other/pambayer.c b/other/pambayer.c
index 7fc1f809..9cffc8f0 100644
--- a/other/pambayer.c
+++ b/other/pambayer.c
@@ -78,6 +78,8 @@ parseCommandLine(int argc, const char ** argv,
     pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
+    free(option_def);
+
     if (argc-1 < 1)
         cmdlineP->inputFilespec = "-";
     else if (argc-1 > 1)
@@ -101,6 +103,41 @@ parseCommandLine(int argc, const char ** argv,
 
 
 static void
+clearTuples(const struct pam * const pamP,
+	    tuple **           const outtuples) {
+
+    unsigned int row;
+    unsigned int col;
+    unsigned int plane;
+
+    if(pamP->height <= 4 || pamP->width <= 4) {
+        for(row=0; row < pamP->height; ++row)
+          for(col=0; col < pamP->width; ++col)
+            for (plane=0; plane < pamP->depth; ++plane)
+              outtuples[row][col][plane] = 0;
+    }
+    else {
+        for(col = 0; col < pamP->width; ++col)
+            for (plane = 0; plane < pamP->depth; ++plane) {
+                outtuples[0][col][plane] = 0;
+                outtuples[1][col][plane] = 0;
+                outtuples[pamP->height-2][col][plane] = 0;
+                outtuples[pamP->height-1][col][plane] = 0;
+          }
+
+        for(row = 2; row < pamP->height - 2; ++row)
+            for (plane = 0; plane < pamP->depth; ++plane) {
+                outtuples[row][0][plane] = 0;
+                outtuples[row][1][plane] = 0;
+                outtuples[row][pamP->width-2][plane] = 0;
+                outtuples[row][pamP->width-1][plane] = 0;
+            }
+    }
+}
+
+
+
+static void
 calc_4(const struct pam * const pamP,
        tuple **           const intuples,
        tuple **           const outtuples,
@@ -319,6 +356,7 @@ main(int argc, const char **argv) {
     makeOutputPam(&inpam, &outpam);
 
     outtuples = pnm_allocpamarray(&outpam);
+    clearTuples(&outpam, outtuples);
 
     for (plane = 0; plane < 3; ++plane) {
         struct compAction const compAction = compActionTable[plane];