Index: trunk/source/Lib/TAppCommon/TAppComCamPara.cpp
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 1196)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 1313)
@@ -49,5 +49,5 @@
 #include <functional>
 #include <string>
-#if H_3D
+#if NH_3D
 
 
@@ -1366,5 +1366,5 @@
 }
 
-#if H_3D_VSO
+#if NH_3D_VSO
 Void
 TAppComCamPara::setDispCoeff( UInt uiFrameId, Int iViewIdx )
@@ -1373,7 +1373,7 @@
   Int  iSourceViewNum = m_aiBaseViews[ iViewIdx ];
   Double dBaseLine = 0.0;
-  Double dFL1, dCS1, dCP1, dZN1, dZF1; 
-  Bool bInterpolated;
-  double dPos[3];
+  Double dFL1 = 1.0, dCS1 = 1.0, dCP1 = 1.0, dZN1 = 1.0, dZF1 = 1.0;
+  Bool bInterpolated = false;
+  double dPos[3] = {0.0, 0.0, 0.0};
 
   if( m_iNumberOfBaseViews == 3 )
Index: trunk/source/Lib/TAppCommon/TAppComCamPara.h
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.h	(revision 1196)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.h	(revision 1313)
@@ -188,5 +188,5 @@
 #endif
 
-#if H_3D_VSO
+#if NH_3D_VSO
   // SAIT_VSO_EST_A033
   Void                setDispCoeff              ( UInt uiStartFrameId, Int iViewIdx );
Index: trunk/source/Lib/TAppCommon/program_options_lite.cpp
===================================================================
--- trunk/source/Lib/TAppCommon/program_options_lite.cpp	(revision 1196)
+++ trunk/source/Lib/TAppCommon/program_options_lite.cpp	(revision 1313)
@@ -2,7 +2,7 @@
  * License, included below. This software may be subject to other third party
  * and contributor rights, including patent rights, and no such rights are
- * granted under this license.  
+ * granted under this license.
  *
-* Copyright (c) 2010-2015, ITU/ISO/IEC
+ * Copyright (c) 2010-2015, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -40,5 +40,5 @@
 #include <algorithm>
 #include "program_options_lite.h"
-#include  "../TLibCommon/TypeDef.h"
+#include  "../TLibCommon/CommonDef.h"
 using namespace std;
 
@@ -50,5 +50,19 @@
   namespace program_options_lite
   {
-    
+    ErrorReporter default_error_reporter;
+
+    ostream& ErrorReporter::error(const string& where)
+    {
+      is_errored = 1;
+      cerr << where << " error: ";
+      return cerr;
+    }
+
+    ostream& ErrorReporter::warn(const string& where)
+    {
+      cerr << where << " warning: ";
+      return cerr;
+    }
+
     Options::~Options()
     {
@@ -58,5 +72,5 @@
       }
     }
-    
+
     void Options::addOption(OptionBase *opt)
     {
@@ -64,5 +78,5 @@
       names->opt = opt;
       string& opt_string = opt->opt_string;
-      
+
       size_t opt_start = 0;
       for (size_t opt_end = 0; opt_end != string::npos;)
@@ -96,6 +110,6 @@
       return OptionSpecific(*this);
     }
-    
-    static void setOptions(Options::NamesPtrList& opt_list, const string& value)
+
+    static void setOptions(Options::NamesPtrList& opt_list, const string& value, ErrorReporter& error_reporter)
     {
       /* multiple options may be registered for the same name:
@@ -103,10 +117,10 @@
       for (Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it)
       {
-        (*it)->opt->parse(value);
+        (*it)->opt->parse(value, error_reporter);
       }
     }
 
     static const char spaces[41] = "                                        ";
-    
+
     /* format help text for a single option:
      * using the formatting: "-x, --long",
@@ -138,5 +152,5 @@
       }
     }
-    
+
     /* format the help text */
     void doHelp(ostream& out, Options& opts, unsigned columns)
@@ -147,5 +161,5 @@
       for(Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++)
       {
-#if H_MV
+#if NH_MV
         if  ( (*it)->opt->opt_duplicate ) continue; 
 #endif
@@ -157,5 +171,5 @@
       unsigned opt_width = min(max_width+2, 28u + pad_short) + 2;
       unsigned desc_width = columns - opt_width;
-      
+
       /* second pass: write out formatted option and help text.
        *  - align start of help text to start at opt_width
@@ -165,5 +179,5 @@
       for(Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++)
       {
-#if H_MV
+#if NH_MV
         if  ( (*it)->opt->opt_duplicate ) continue; 
 #endif
@@ -215,5 +229,5 @@
             split_pos = opt_desc.find_last_not_of(' ', split_pos) + 1;
           }
-          
+
           /* bad split if no suitable space to split at.  fall back to width */
           bool bad_split = split_pos == string::npos || split_pos <= cur_pos;
@@ -223,5 +237,5 @@
           }
           line << opt_desc.substr(cur_pos, split_pos - cur_pos);
-          
+
           /* eat up any space for the start of the next line */
           if (!bad_split)
@@ -230,5 +244,5 @@
           }
           cur_pos = newline_pos = split_pos;
-          
+
           if (cur_pos >= opt_desc.size())
           {
@@ -241,6 +255,25 @@
       }
     }
-    
-    bool storePair(Options& opts, bool allow_long, bool allow_short, const string& name, const string& value)
+
+    struct OptionWriter
+    {
+      OptionWriter(Options& rOpts, ErrorReporter& err)
+      : opts(rOpts), error_reporter(err)
+      {}
+      virtual ~OptionWriter() {}
+
+      virtual const string where() = 0;
+
+      bool storePair(bool allow_long, bool allow_short, const string& name, const string& value);
+      bool storePair(const string& name, const string& value)
+      {
+        return storePair(true, true, name, value);
+      }
+
+      Options& opts;
+      ErrorReporter& error_reporter;
+    };
+
+    bool OptionWriter::storePair(bool allow_long, bool allow_short, const string& name, const string& value)
     {
       bool found = false;
@@ -254,5 +287,5 @@
         }
       }
-      
+
       /* check for the short list */
       if (allow_short && !(found && allow_long))
@@ -267,22 +300,29 @@
       if (!found)
       {
-        /* not found */
-        cerr << "Unknown option: `" << name << "' (value:`" << value << "')" << endl;
+        error_reporter.error(where())
+          << "Unknown option `" << name << "' (value:`" << value << "')\n";
         return false;
       }
 
-      setOptions((*opt_it).second, value);
+      setOptions((*opt_it).second, value, error_reporter);
       return true;
     }
-    
-    bool storePair(Options& opts, const string& name, const string& value)
-    {
-      return storePair(opts, true, true, name, value);
-    }
-    
+
+    struct ArgvParser : public OptionWriter
+    {
+      ArgvParser(Options& rOpts, ErrorReporter& rError_reporter)
+      : OptionWriter(rOpts, rError_reporter)
+      {}
+
+      const string where() { return "command line"; }
+
+      unsigned parseGNU(unsigned argc, const char* argv[]);
+      unsigned parseSHORT(unsigned argc, const char* argv[]);
+    };
+
     /**
      * returns number of extra arguments consumed
      */
-    unsigned parseGNU(Options& opts, unsigned argc, const char* argv[])
+    unsigned ArgvParser::parseGNU(unsigned argc, const char* argv[])
     {
       /* gnu style long options can take the forms:
@@ -294,5 +334,5 @@
       size_t arg_opt_sep = arg.find_first_of('=');
       string option = arg.substr(arg_opt_start, arg_opt_sep - arg_opt_start);
-      
+
       unsigned extra_argc_consumed = 0;
       if (arg_opt_sep == string::npos)
@@ -305,8 +345,10 @@
         * booleans */
         if (argc == 1)
+        {
           return 0; /* run out of argv for argument */
+        }
         extra_argc_consumed = 1;
 #endif
-        if(!storePair(opts, true, false, option, "1"))
+        if(!storePair(true, false, option, "1"))
         {
           return 0;
@@ -317,5 +359,5 @@
         /* argument occurs after option_sep */
         string val = arg.substr(arg_opt_sep + 1);
-        storePair(opts, true, false, option, val);
+        storePair(true, false, option, val);
       }
 
@@ -323,5 +365,5 @@
     }
 
-    unsigned parseSHORT(Options& opts, unsigned argc, const char* argv[])
+    unsigned ArgvParser::parseSHORT(unsigned argc, const char* argv[])
     {
       /* short options can take the forms:
@@ -338,15 +380,18 @@
       if (argc == 1)
       {
-        cerr << "Not processing option without argument `" << option << "'" << endl;
+        error_reporter.error(where())
+          << "Not processing option `" << option << "' without argument\n";
         return 0; /* run out of argv for argument */
       }
-      storePair(opts, false, true, option, string(argv[1]));
+      storePair(false, true, option, string(argv[1]));
 
       return 1;
     }
-    
+
     list<const char*>
-    scanArgv(Options& opts, unsigned argc, const char* argv[])
-    {
+    scanArgv(Options& opts, unsigned argc, const char* argv[], ErrorReporter& error_reporter)
+    {
+      ArgvParser avp(opts, error_reporter);
+
       /* a list for anything that didn't get handled as an option */
       list<const char*> non_option_arguments;
@@ -370,9 +415,5 @@
         {
           /* handle short (single dash) options */
-#if 0
-          i += parsePOSIX(opts, argc - i, &argv[i]);
-#else
-          i += parseSHORT(opts, argc - i, &argv[i]);
-#endif
+          i += avp.parseSHORT(argc - i, &argv[i]);
           continue;
         }
@@ -382,16 +423,39 @@
           /* a lone double dash ends option processing */
           while (++i < argc)
+          {
             non_option_arguments.push_back(argv[i]);
+          }
           break;
         }
 
         /* handle long (double dash) options */
-        i += parseGNU(opts, argc - i, &argv[i]);
+        i += avp.parseGNU(argc - i, &argv[i]);
       }
 
       return non_option_arguments;
     }
-    
-    void scanLine(Options& opts, string& line)
+
+    struct CfgStreamParser : public OptionWriter
+    {
+      CfgStreamParser(const string& rName, Options& rOpts, ErrorReporter& rError_reporter)
+      : OptionWriter(rOpts, rError_reporter)
+      , name(rName)
+      , linenum(0)
+      {}
+
+      const string name;
+      int linenum;
+      const string where()
+      {
+        ostringstream os;
+        os << name << ":" << linenum;
+        return os.str();
+      }
+
+      void scanLine(string& line);
+      void scanStream(istream& in);
+    };
+
+    void CfgStreamParser::scanLine(string& line)
     {
       /* strip any leading whitespace */
@@ -416,4 +480,5 @@
       {
         /* error: badly formatted line */
+        error_reporter.warn(where()) << "line formatting error\n";
         return;
       }
@@ -421,4 +486,5 @@
       {
         /* error: badly formatted line */
+        error_reporter.warn(where()) << "line formatting error\n";
         return;
       }
@@ -429,4 +495,9 @@
       {
         /* error: badly formatted line */
+#if !NH_MV
+        error_reporter.warn(where()) << "line formatting error\n";
+#else
+        // HTM also allows empty parameters.
+#endif
         return;
       }
@@ -447,6 +518,5 @@
          * any trailing whitespace will be removed shortly */
         value_end = line.find_first_not_of(" \t\n\r", value_end);
-      }
-      while (value_end != string::npos);
+      } while (value_end != string::npos);
       /* strip any trailing space from value*/
       value_end = line.find_last_not_of(" \t\n\r", value_end);
@@ -460,20 +530,25 @@
       {
         /* error: no value */
+#if !NH_MV
+        error_reporter.warn(where()) << "no value found\n";
+#else
+        // This is ok for HTM.
+#endif
         return;
       }
 
       /* store the value in option */
-      storePair(opts, true, false, option, value);
-    }
-
-    void scanFile(Options& opts, istream& in)
+      storePair(true, false, option, value);
+    }
+
+    void CfgStreamParser::scanStream(istream& in)
     {
       do
       {
+        linenum++;
         string line;
         getline(in, line);
-        scanLine(opts, line);
-      }
-      while(!!in);
+        scanLine(line);
+      } while(!!in);
     }
 
@@ -488,17 +563,18 @@
     }
 
-    void parseConfigFile(Options& opts, const string& filename)
+    void parseConfigFile(Options& opts, const string& filename, ErrorReporter& error_reporter)
     {
       ifstream cfgstream(filename.c_str(), ifstream::in);
       if (!cfgstream)
       {
-        cerr << "Failed to open config file: `" << filename << "'" << endl;
-        exit(EXIT_FAILURE);
-      }
-      scanFile(opts, cfgstream);
-    }
-
-  };
-};
+        error_reporter.error(filename) << "Failed to open config file\n";
+        return;
+      }
+      CfgStreamParser csp(filename, opts, error_reporter);
+      csp.scanStream(cfgstream);
+    }
+
+  }
+}
 
 //! \}
Index: trunk/source/Lib/TAppCommon/program_options_lite.h
===================================================================
--- trunk/source/Lib/TAppCommon/program_options_lite.h	(revision 1196)
+++ trunk/source/Lib/TAppCommon/program_options_lite.h	(revision 1313)
@@ -2,7 +2,7 @@
  * License, included below. This software may be subject to other third party
  * and contributor rights, including patent rights, and no such rights are
- * granted under this license.  
+ * granted under this license.
  *
-* Copyright (c) 2010-2015, ITU/ISO/IEC
+ * Copyright (c) 2010-2015, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -36,7 +36,7 @@
 #include <list>
 #include <map>
-#include  "../TLibCommon/TypeDef.h"
-
-#if H_MV
+#include  "../TLibCommon/CommonDef.h" 
+
+#if NH_MV
 #include <vector>
 #include <errno.h>
@@ -47,4 +47,9 @@
 #endif
 #endif
+
+
+#ifndef __PROGRAM_OPTIONS_LITE__
+#define __PROGRAM_OPTIONS_LITE__
+
 //! \ingroup TAppCommon
 //! \{
@@ -56,5 +61,5 @@
   {
     struct Options;
-    
+
     struct ParseFailure : public std::exception
     {
@@ -71,14 +76,20 @@
     };
 
+    struct ErrorReporter
+    {
+      ErrorReporter() : is_errored(0) {}
+      virtual ~ErrorReporter() {}
+      virtual std::ostream& error(const std::string& where);
+      virtual std::ostream& warn(const std::string& where);
+      bool is_errored;
+    };
+
+    extern ErrorReporter default_error_reporter;
+
     void doHelp(std::ostream& out, Options& opts, unsigned columns = 80);
-    unsigned parseGNU(Options& opts, unsigned argc, const char* argv[]);
-    unsigned parseSHORT(Options& opts, unsigned argc, const char* argv[]);
-    std::list<const char*> scanArgv(Options& opts, unsigned argc, const char* argv[]);
-    void scanLine(Options& opts, std::string& line);
-    void scanFile(Options& opts, std::istream& in);
+    std::list<const char*> scanArgv(Options& opts, unsigned argc, const char* argv[], ErrorReporter& error_reporter = default_error_reporter);
     void setDefaults(Options& opts);
-    void parseConfigFile(Options& opts, const std::string& filename);
-    bool storePair(Options& opts, const std::string& name, const std::string& value);
-    
+    void parseConfigFile(Options& opts, const std::string& filename, ErrorReporter& error_reporter = default_error_reporter);
+
     /** OptionBase: Virtual base class for storing information relating to a
      * specific option This base class describes common elements.  Type specific
@@ -86,5 +97,5 @@
     struct OptionBase
     {
-#if H_MV      
+#if NH_MV      
       OptionBase(const std::string& name, const std::string& desc, bool duplicate = false)
         : opt_string(name), opt_desc(desc), opt_duplicate(duplicate)
@@ -94,24 +105,24 @@
 #endif
       {};
-      
+
       virtual ~OptionBase() {}
-      
+
       /* parse argument arg, to obtain a value for the option */
-      virtual void parse(const std::string& arg) = 0;
+      virtual void parse(const std::string& arg, ErrorReporter&) = 0;
       /* set the argument to the default value */
       virtual void setDefault() = 0;
-      
+
       std::string opt_string;
       std::string opt_desc;
-#if H_MV
+#if NH_MV
       bool        opt_duplicate; 
 #endif
     };
-    
+
     /** Type specific option storage */
     template<typename T>
     struct Option : public OptionBase
     {
-#if H_MV
+#if NH_MV
       Option(const std::string& name, T& storage, T default_val, const std::string& desc, bool duplicate = false)
         : OptionBase(name, desc, duplicate), opt_storage(storage), opt_default_val(default_val)
@@ -121,20 +132,20 @@
 #endif
       {}
-      
-      void parse(const std::string& arg);
-      
+
+      void parse(const std::string& arg, ErrorReporter&);
+
       void setDefault()
       {
         opt_storage = opt_default_val;
       }
-      
+
       T& opt_storage;
       T opt_default_val;
     };
-    
+
     /* Generic parsing */
     template<typename T>
     inline void
-    Option<T>::parse(const std::string& arg)
+    Option<T>::parse(const std::string& arg, ErrorReporter&)
     {
       std::istringstream arg_ss (arg,std::istringstream::in);
@@ -149,18 +160,18 @@
       }
     }
-    
+
     /* string parsing is specialized -- copy the whole string, not just the
      * first word */
     template<>
     inline void
-    Option<std::string>::parse(const std::string& arg)
+    Option<std::string>::parse(const std::string& arg, ErrorReporter&)
     {
       opt_storage = arg;
     }
 
-#if H_MV    
+#if NH_MV    
     template<>
     inline void
-      Option<char*>::parse(const std::string& arg)
+      Option<char*>::parse(const std::string& arg, ErrorReporter&)
     {
       opt_storage = arg.empty() ? NULL : strdup(arg.c_str()) ;
@@ -169,5 +180,5 @@
     template<>
     inline void
-      Option< std::vector<char*> >::parse(const std::string& arg)
+      Option< std::vector<char*> >::parse(const std::string& arg, ErrorReporter&)
     {
       opt_storage.clear(); 
@@ -191,5 +202,5 @@
     template<>    
     inline void
-      Option< std::vector<double> >::parse(const std::string& arg)
+      Option< std::vector<double> >::parse(const std::string& arg, ErrorReporter&)
     {
       char* pcNextStart = (char*) arg.data();
@@ -227,5 +238,5 @@
     template<>
     inline void
-      Option< std::vector<int> >::parse(const std::string& arg)
+      Option< std::vector<int> >::parse(const std::string& arg, ErrorReporter&)
     {
       opt_storage.clear();
@@ -265,5 +276,5 @@
     template<>
     inline void
-      Option< std::vector<bool> >::parse(const std::string& arg)
+      Option< std::vector<bool> >::parse(const std::string& arg, ErrorReporter&)
     {
       char* pcNextStart = (char*) arg.data();
@@ -299,32 +310,32 @@
     struct OptionFunc : public OptionBase
     {
-      typedef void (Func)(Options&, const std::string&);
-      
+      typedef void (Func)(Options&, const std::string&, ErrorReporter&);
+
       OptionFunc(const std::string& name, Options& parent_, Func *func_, const std::string& desc)
       : OptionBase(name, desc), parent(parent_), func(func_)
       {}
-      
-      void parse(const std::string& arg)
-      {
-        func(parent, arg);
-      }
-      
+
+      void parse(const std::string& arg, ErrorReporter& error_reporter)
+      {
+        func(parent, arg, error_reporter);
+      }
+
       void setDefault()
       {
         return;
       }
-      
+
     private:
       Options& parent;
-      void (*func)(Options&, const std::string&);
-    };
-    
+      Func* func;
+    };
+
     class OptionSpecific;
     struct Options
     {
       ~Options();
-      
+
       OptionSpecific addOptions();
-      
+
       struct Names
       {
@@ -333,5 +344,7 @@
         {
           if (opt)
+          {
             delete opt;
+          }
         }
         std::list<std::string> opt_long;
@@ -341,13 +354,13 @@
 
       void addOption(OptionBase *opt);
-      
+
       typedef std::list<Names*> NamesPtrList;
       NamesPtrList opt_list;
-      
+
       typedef std::map<std::string, NamesPtrList> NamesMap;
       NamesMap opt_long_map;
       NamesMap opt_short_map;
     };
-    
+
     /* Class with templated overloaded operator(), for use by Options::addOptions() */
     class OptionSpecific
@@ -355,5 +368,5 @@
     public:
       OptionSpecific(Options& parent_) : parent(parent_) {}
-      
+
       /**
        * Add option described by name to the parent Options list,
@@ -369,6 +382,6 @@
         return *this;
       }
-      
-#if H_MV
+
+#if NH_MV
       template<typename T>
       OptionSpecific&
@@ -419,7 +432,9 @@
       Options& parent;
     };
-    
-  }; /* namespace: program_options_lite */
-}; /* namespace: df */
+
+  } /* namespace: program_options_lite */
+} /* namespace: df */
 
 //! \}
+
+#endif
