commit f6c21781d2e70000404fafa65a801ccd81347889
Author: David Sorber <dsorber@prometheus.fios-router.home>
Date:   Tue Feb 7 17:25:48 2017 -0500

    Well I fixed my bizzarre problem last night. It turns out that I was building the argv list for each forked process from the main input file list instead of from the sub list passed to each thread. Now PCA runs in a much more stable fashion. Next I'd like to add some sort of progress reporting and also decompress support. I had the idea of using inotify on the output files (since their names are known a priori) however inotify is Linux only and I haven't yet found a drop in replacement for Mac OS.

diff --git a/software/photo_compress_archiver/Makefile b/software/photo_compress_archiver/Makefile
index 9423c77..17be8f8 100644
--- a/software/photo_compress_archiver/Makefile
+++ b/software/photo_compress_archiver/Makefile
@@ -3,7 +3,7 @@ CXX=clang++
 CXXFLAGS=-std=c++11 -g
 OBJECTS = main.o PhotoCompressArchiver.o
 
-LDFLAGS=-L. -l packjpg -L/opt/local/lib -lboost_system-mt -lboost_regex-mt -lboost_filesystem-mt
+LDFLAGS=-L/opt/local/lib -lboost_system-mt -lboost_regex-mt -lboost_filesystem-mt
 
 all: main
 	
diff --git a/software/photo_compress_archiver/PhotoCompressArchiver.cc b/software/photo_compress_archiver/PhotoCompressArchiver.cc
index 4e330c6..d7e1cdc 100644
--- a/software/photo_compress_archiver/PhotoCompressArchiver.cc
+++ b/software/photo_compress_archiver/PhotoCompressArchiver.cc
@@ -1,13 +1,12 @@
 #include <chrono>
 #include <iostream>
+#include <iterator> // temporary for std::distance
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <unistd.h>
 
 #include "PhotoCompressArchiver.hh"
 
-#include "packjpglib.h"
-
 #define OUT(x) {\
     std::lock_guard<std::mutex> lock(m_output_mutex);\
     x\
@@ -95,8 +94,11 @@ int PhotoCompressArchiver::execute()
     }
     
     OUT(std::cout << "  Total compressed bytes: " << m_total_compressed_size 
-                  << "\n" << std::endl;)
-    
+                  << std::endl;)
+        
+    // Calculate and display ratio
+    double ratio = (double)m_total_compressed_size / m_total_uncompressed_size;
+    OUT(std::cout << "  Compression ratio: " << ratio << "\n" << std::endl;)
     
     OUT(std::cout << "execute terminating" << std::endl;)
     
@@ -148,6 +150,8 @@ void PhotoCompressArchiver::fork_worker(
                       << std::endl;)
     }
 #endif
+
+
         
     uint32_t argv_size = file_sublist->size() + 5;
     const char **exec_argv = new const char* [argv_size];
@@ -159,8 +163,8 @@ void PhotoCompressArchiver::fork_worker(
     exec_argv[3] = PROG_OPT3;
     
     // Add the sublist files to the argv array
-    uint32_t idx = 3;
-    for (auto& image_path : m_file_list)
+    uint32_t idx = 4;
+    for (auto& image_path : *file_sublist)
     {
         exec_argv[idx++] = image_path.string().c_str();
     }
@@ -222,7 +226,8 @@ void PhotoCompressArchiver::fork_worker(
         int rc = stat(new_file.c_str(), &statbuf);
         if (rc)
         {
-            OUT(std::cerr << "ERROR: unable to stat file " << new_file << std::endl;)
+            OUT(std::cerr << "T[" << tid << "] ERROR: unable to stat file " 
+                          << new_file << std::endl;)
         }     
         m_total_compressed_size += statbuf.st_size;
     }
diff --git a/software/photo_compress_archiver/main.cc b/software/photo_compress_archiver/main.cc
index dd346f3..d1b5849 100644
--- a/software/photo_compress_archiver/main.cc
+++ b/software/photo_compress_archiver/main.cc
@@ -4,8 +4,6 @@
 #include <boost/filesystem.hpp>
 #include <boost/regex.hpp>
 
-#include "packjpglib.h"
-
 #include "PhotoCompressArchiver.hh"
 
 // clang++ -std=c++11 -L. -l packjpg -I/opt/local/include -L/opt/local/lib 
