Index: trunk/source/Lib/TAppCommon/TAppComCamPara.cpp
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 296)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 608)
@@ -49,5 +49,5 @@
 #include <functional>
 #include <string>
-
+#if H_3D
 
 
@@ -58,6 +58,6 @@
   AOF( radShiftParams == NULL && raiShiftParams == NULL && radLUT == NULL && raiLUT == NULL );
 
-  uiNumberSourceViews = Max( 1, uiNumberSourceViews );
-  uiNumberTargetViews = Max( 1, uiNumberTargetViews );
+  uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews );
+  uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews );
 
   radShiftParams = new Double** [ uiNumberSourceViews ];
@@ -611,10 +611,13 @@
 }
 
-
 Void
 TAppComCamPara::xGetGeometryData( Int iView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated )
 {
   UInt uiFoundLine = -1;
+#if H_3D_FIX_REN_WARNING
+  if ( !xGetCameraDataRow( iView, uiFrame, uiFoundLine ) && xIsIn( m_aiSortedBaseViews, iView ))
+#else  
   if ( !xGetCameraDataRow( iView, uiFrame, uiFoundLine ) )
+#endif
   {
     AOT( m_aadCameraParameters[ uiFoundLine ].size() < 6 );
@@ -632,10 +635,18 @@
     Int  iDummy;
 
+#if H_3D_FIX_REN_WARNING
+    if( !xGetLeftRightView( iView, m_aiSortedBaseViews, iLeftView, iRightView, iDummy, iDummy ) ||
+#else
     if( !xGetLeftRightView( iView, m_aiViewsInCfgFile, iLeftView, iRightView, iDummy, iDummy ) ||
+#endif
          xGetCameraDataRow( iLeftView,  uiFrame, uiLeftViewLine  )                             ||
          xGetCameraDataRow( iRightView, uiFrame, uiRightViewLine )
       )
     {
+#if H_3D_FIX_REN_WARNING
+      std::cerr << "No left or no right base view next to view " << (Double)iView / m_dViewNumPrec << " for Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
+#else
       std::cerr << "No Left or no Right View next to View " << (Double)iView / m_dViewNumPrec << " for Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
+#endif
       AOT(true);
       exit( EXIT_FAILURE );
@@ -841,7 +852,9 @@
   Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
   Int     iLog2DivChroma = iLog2DivLuma + 1;
+
   Double  dMaxDispDev    = 0.0;
   Double  dMaxRndDispDvL = 0.0;
   Double  dMaxRndDispDvC = 0.0;
+
   for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
   {
@@ -892,7 +905,10 @@
 
         // maximum deviation
-        dMaxDispDev     = Max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
-        dMaxRndDispDvL  = Max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
-        dMaxRndDispDvC  = Max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
+#if H_3D_REN_MAX_DEV_OUT
+        m_dMaxShiftDeviation = std::max( m_dMaxShiftDeviation, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) / Double( 1 << m_iLog2Precision ) );        
+#endif
+        dMaxDispDev     = std::max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
+        dMaxRndDispDvL  = std::max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
+        dMaxRndDispDvC  = std::max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
       }
 
@@ -965,5 +981,4 @@
   //--- determine (virtual) camera parameter shift between view order index 1 and base view (view order index 0) ---
   Double        dCamPosShift, dPicPosShift;
-  Int           iMinVOI       = (1<<30);
   Int           iMinAbsVOI    = (1<<30);
   Int           iMinAbsVOIId  = 0;
@@ -973,5 +988,4 @@
     if( iAbsVOI < iMinAbsVOI )
     {
-      iMinVOI      = m_aiViewOrderIndex[ iBaseId ];
       iMinAbsVOI   = iAbsVOI;
       iMinAbsVOIId = iBaseId;
@@ -980,5 +994,4 @@
   AOF( iMinAbsVOIId != 0 && iMinAbsVOI != 0 );
   xGetCameraShifts( 0, iMinAbsVOIId, m_uiFirstFrameId, dCamPosShift, dPicPosShift );
-  Double  dCamPosShiftVOI01     = dCamPosShift / Double( iMinVOI );
 
   //--- determine maximum absolute camera position shift, precision, and base scale ---
@@ -991,38 +1004,4 @@
       dCamPosShift        = ( dCamPosShift < 0.0                ? -dCamPosShift : dCamPosShift       );
       dMaxAbsCamPosShift  = ( dCamPosShift > dMaxAbsCamPosShift ?  dCamPosShift : dMaxAbsCamPosShift );
-    }
-  }
-  Int     iPrecision  = 0;
-#if 0 // enabling this lines might be reasonable, but produces different results for the 2 view and 3 view test cases
-  Double  dEpsilon    = 1e-15;
-  Double  dAbsCamPosShiftVOI01  = ( dCamPosShiftVOI01 < 0.0 ? -dCamPosShiftVOI01 : dCamPosShiftVOI01 );
-  Double  dShiftRatio = dMaxAbsCamPosShift / dAbsCamPosShiftVOI01 - dEpsilon;
-  for( ; (Double)( 1 << iPrecision ) < dShiftRatio; iPrecision++ );
-#endif
-  Int     iPrecShift  = iPrecision + PDM_INTER_CALC_SHIFT + PDM_VIRT_DEPTH_PRECISION - 2;
-  AOF(    iPrecShift  < PDM_INTERNAL_CALC_BIT_DEPTH );
-  Int     iScaleVOI01 = 1 << iPrecShift;
-  m_iPdmPrecision     = iPrecision;
-
-  //--- loop over target views ---
-  for( Int iTargetId = 1; iTargetId < m_iNumberOfBaseViews; iTargetId++ )
-  {
-    // set scale and offset parameters for other views
-    for( Int iBaseId = 0; iBaseId < iTargetId; iBaseId++ )
-    {
-      xGetCameraShifts( (UInt)iBaseId, (UInt)iTargetId, m_uiFirstFrameId, dCamPosShift, dPicPosShift );
-      Double  dScale      = Double( iScaleVOI01 ) * dCamPosShiftVOI01 / dCamPosShift;
-      Int     iDiv        = m_aiViewOrderIndex[ iTargetId ] - m_aiViewOrderIndex[ iBaseId ];
-      Int     iAdd        = ( iDiv > 0 ? iDiv / 2 : -iDiv / 2 );
-      Int     iScalePred  = ( iScaleVOI01 + iAdd ) / iDiv;
-      Double  dFactor     = dScale / (Double)iScalePred * pow( 2.0, PDM_LOG4_SCALE_DENOMINATOR );
-      Int     iNominator  = (Int)floor( dFactor + .5 );
-      Int     iNomDelta   = iNominator - ( 1 << PDM_LOG4_SCALE_DENOMINATOR );
-      Int     iScale      = Int( ( (Int64)iNominator * (Int64)iScalePred + (Int64)( ( 1 << PDM_LOG4_SCALE_DENOMINATOR ) >> 1 ) ) >> PDM_LOG4_SCALE_DENOMINATOR );
-      Double  dOffset     = -dPicPosShift * Double( iScale ) * pow( 2.0, 2 - PDM_OFFSET_SHIFT );
-      Int     iOffset     = (Int)floor( dOffset + .5 );
-
-      m_aaiPdmScaleNomDelta [ iTargetId ][ iBaseId ]  = iNomDelta;
-      m_aaiPdmOffset        [ iTargetId ][ iBaseId ]  = iOffset;
     }
   }
@@ -1050,8 +1029,4 @@
   m_aaiScaleAndOffsetSet      = 0;
 
-  m_iPdmPrecision             = 0;
-  m_aaiPdmScaleNomDelta       = 0;
-  m_aaiPdmOffset              = 0;
-
   m_adBaseViewShiftParameter  = 0;
   m_aiBaseViewShiftParameter  = 0;
@@ -1067,4 +1042,7 @@
   m_bCamParsCodedPrecSet      = false;
 
+#if H_3D_REN_MAX_DEV_OUT
+  m_dMaxShiftDeviation        = -1; 
+#endif
 
 }
@@ -1078,8 +1056,8 @@
   xDeleteArray( m_aiBaseViewShiftLUT,        m_iNumberOfBaseViews, m_iNumberOfBaseViews,  2 );
 
-  xDeleteArray( m_adSynthViewShiftParameter, m_iNumberOfBaseViews, Max(1,m_iNumberOfSynthViews));
-  xDeleteArray( m_aiSynthViewShiftParameter, m_iNumberOfBaseViews, Max(1,m_iNumberOfSynthViews));
-  xDeleteArray( m_adSynthViewShiftLUT,       m_iNumberOfBaseViews, Max(1,m_iNumberOfSynthViews), 2 );
-  xDeleteArray( m_aiSynthViewShiftLUT,       m_iNumberOfBaseViews, Max(1,m_iNumberOfSynthViews), 2 );
+  xDeleteArray( m_adSynthViewShiftParameter, m_iNumberOfBaseViews, std::max((Int) 1 ,m_iNumberOfSynthViews));
+  xDeleteArray( m_aiSynthViewShiftParameter, m_iNumberOfBaseViews, std::max((Int) 1 ,m_iNumberOfSynthViews));
+  xDeleteArray( m_adSynthViewShiftLUT,       m_iNumberOfBaseViews, std::max((Int) 1 ,m_iNumberOfSynthViews), 2 );
+  xDeleteArray( m_aiSynthViewShiftLUT,       m_iNumberOfBaseViews, std::max( (Int)1 ,m_iNumberOfSynthViews), 2 );
 
   xDeleteArray( m_aaiCodedScale,             m_iNumberOfBaseViews );
@@ -1087,6 +1065,4 @@
   xDeleteArray( m_aaiScaleAndOffsetSet,      m_iNumberOfBaseViews );
 
-  xDeleteArray( m_aaiPdmScaleNomDelta,       m_iNumberOfBaseViews );
-  xDeleteArray( m_aaiPdmOffset,              m_iNumberOfBaseViews );
 }
 
@@ -1106,5 +1082,5 @@
 
     Int iViewOrderIdx  = (Int)( m_aadCameraParameters[ uiRow ][ 1 ] );
-    iMinViewOrderIdx   = Min( iViewOrderIdx, iMinViewOrderIdx );
+    iMinViewOrderIdx   = std::min( iViewOrderIdx, iMinViewOrderIdx );
 
     aiViewOrderIdx     .push_back( iViewOrderIdx );
@@ -1121,5 +1097,4 @@
     m_aiBaseId2SortedId.push_back( iCurBaseView );
     m_aiBaseSortedId2Id.push_back( iCurBaseView );
-
   }
 
@@ -1198,5 +1173,5 @@
     if( m_aiViewsInCfgFile.size() < 2 )
     {
-    std::cerr << "Failed reading config file" << std::endl;
+      std::cerr << "Failed reading config file" << std::endl;
       std::cerr << "At least two views must be given" << std::endl;
       exit( EXIT_FAILURE );
@@ -1332,10 +1307,4 @@
   xInit2dArray  ( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiScaleAndOffsetSet, 0 );
 
-  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiPdmScaleNomDelta     );
-  xCreate2dArray( (UInt)m_iNumberOfBaseViews, (UInt)m_iNumberOfBaseViews,  m_aaiPdmOffset            );
-
-  //===== init disparity to virtual depth conversion parameters =====
-  xSetPdmConversionParams();
-
   //===== init arrays for first frame =====
   xSetShiftParametersAndLUT( m_uiFirstFrameId );
@@ -1369,20 +1338,41 @@
       else
       {
-      for( UInt uiFrame = m_uiFirstFrameId; uiFrame <= m_uiLastFrameId; uiFrame++ )
-      {
-        Bool bInterpolatedCur;
-        xGetGeometryData( m_aiBaseViews[ uiBaseView ], uiFrame, dDummy, dDummy, dDummy, bInterpolatedCur );
-        xGetZNearZFar   ( m_aiBaseViews[ uiBaseView ], uiFrame, dDummy, dDummy );
-
-        if( bInterpolatedCur )
+        for( UInt uiFrame = m_uiFirstFrameId; uiFrame <= m_uiLastFrameId; uiFrame++ )
         {
-          std::cerr << "Error: CameraParameters for BaseView " << (Double)m_aiBaseViews[ uiBaseView ] / m_dViewNumPrec << " and Frame " << uiFrame << " not defined. "  << std::endl;
-          exit( EXIT_FAILURE );
+          Bool bInterpolatedCur;
+          xGetGeometryData( m_aiBaseViews[ uiBaseView ], uiFrame, dDummy, dDummy, dDummy, bInterpolatedCur );
+          xGetZNearZFar   ( m_aiBaseViews[ uiBaseView ], uiFrame, dDummy, dDummy );
+
+          if( bInterpolatedCur )
+          {
+            std::cerr << "Error: CameraParameters for BaseView " << (Double)m_aiBaseViews[ uiBaseView ] / m_dViewNumPrec << " and Frame " << uiFrame << " not defined. "  << std::endl;
+            exit( EXIT_FAILURE );
+          }
         }
       }
-
-      }
-    }
-
+    }
+#if H_3D_FIX_REN_WARNING
+    Bool bIgnoreFirst = true;     
+    for( UInt uiERView = 0; uiERView < m_aiSynthViews.size() && !m_bSetupFromCoded; uiERView++ )
+    {
+      if ( xIsIn(m_aiViewsInCfgFile, m_aiSynthViews[ uiERView ] ) )
+      {
+        if ( bIgnoreFirst )
+        {
+          std::cout << "Ignoring CameraParameterFile entries for virtual view(s): " ;
+          //GT: Integer precision virtual view camera parameters are always interpolated from coded views camera parameters.
+          bIgnoreFirst = false; 
+        }
+        std::cout << (Double)m_aiSynthViews[ uiERView ] / m_dViewNumPrec << " " ; 
+      }
+    }
+    if ( !bIgnoreFirst )
+    {
+      std::cout << std::endl; 
+    }
+#endif
+
+    Bool bInterpolateFirst = true; 
+    Bool bAnyInterpolated  = false; 
     for( UInt uiERView = 0; uiERView < m_aiSynthViews.size() && !m_bSetupFromCoded; uiERView++ )
     {
@@ -1394,9 +1384,22 @@
         bInterpolated |= bInterpolatedCur;
       }
+      
       if( bInterpolated )
       {
-        std::cout << "Interpolating Camera Parameters for View " << (Double)m_aiSynthViews[ uiERView ] / m_dViewNumPrec << std::endl;
-      }
-    }
+        bAnyInterpolated = true; 
+        if ( bInterpolateFirst ) 
+        {
+#if H_3D_FIX_REN_WARNING                        
+          std::cout << "Interpolating camera parameters      for virtual view(s): " ; 
+#else
+          std::cout << "Interpolating Camera Parameters for View(s) " ; 
+#endif
+            bInterpolateFirst = false; 
+        }          
+        std::cout << (Double)m_aiSynthViews[ uiERView ] / m_dViewNumPrec << " " ; 
+      }
+    }
+    if ( bAnyInterpolated )
+      std::cout << std::endl;
   }
 
@@ -1433,7 +1436,7 @@
 }
 
-#if SAIT_VSO_EST_A0033
-Void
-TAppComCamPara::xSetDispCoeff( UInt uiFrameId, Int iViewIdx )
+#if H_3D_VSO
+Void
+TAppComCamPara::setDispCoeff( UInt uiFrameId, Int iViewIdx )
 {
   UInt uiFrame = m_uiFirstFrameId + uiFrameId;
@@ -1453,5 +1456,5 @@
     xGetZNearZFar   ( iSourceViewNum, uiFrame, dZN1, dZF1 );
 
-    dBaseLine = ( Max( dPos[0], Max( dPos[1], dPos[2] ) ) - Min( dPos[0], Min( dPos[1], dPos[2] ) ) ) / 2.0;
+    dBaseLine = ( std::max( dPos[0], std::max( dPos[1], dPos[2] ) ) - std::min( dPos[0], std::min( dPos[1], dPos[2] ) ) ) / 2.0;
   }
   else if( m_iNumberOfBaseViews == 2 )
@@ -1465,5 +1468,4 @@
     dBaseLine = dPos[0] - dPos[1];
   }
-
 
   m_dDispCoeff = fabs( dFL1 * ( dBaseLine / 2.0 ) / 255.0 * ( 1.0/dZN1 - 1.0/dZF1 ) );
@@ -1495,4 +1497,17 @@
   return bExist;
 }
+
+#if H_3D_FIX_REN_WARNING
+Bool 
+  TAppComCamPara::xIsIn( std::vector<Int>& rVec, Int iElem) 
+{
+  Bool bFound = false; 
+  for (Int idx = 0; idx < rVec.size() && !bFound; idx++)
+  {
+    bFound = bFound || rVec[idx] == iElem; 
+  }
+  return bFound;
+}
+#endif
 
 Int TAppComCamPara::getRelDistLeft( Int iSynthViewIdx, Int iLeftViewIdx, Int iRightViewIdx )
@@ -1510,2 +1525,3 @@
   return xGetViewId(m_aiRelSynthViewsNum, iRelNum );
 }
+#endif
Index: trunk/source/Lib/TAppCommon/TAppComCamPara.h
===================================================================
--- trunk/source/Lib/TAppCommon/TAppComCamPara.h	(revision 296)
+++ trunk/source/Lib/TAppCommon/TAppComCamPara.h	(revision 608)
@@ -66,8 +66,10 @@
   Bool                m_bSetupFromCoded;                      ///< setup from coded parameter file
   Bool                m_bCamParsCodedPrecSet;                 ///< Coded Cam Para precision set for current frame;
-
-#if SAIT_VSO_EST_A0033
+  
+#if H_3D_REN_MAX_DEV_OUT
+  Double              m_dMaxShiftDeviation;                   ///< Maximum deviation of shifts with integer precision compare to double precision
+#endif
+  //SAIT_VSO_EST_A0033
   Double              m_dDispCoeff;
-#endif
 
   // view lists
@@ -90,9 +92,4 @@
   Int**               m_aaiScaleAndOffsetSet;                 ///< array indicating whether scale and offset have been set
 
-  // parameters for virtual depth map generation
-  Int                 m_iPdmPrecision;                        ///< additional precision for disparity - virtual depth conversion
-  Int**               m_aaiPdmScaleNomDelta;                  ///< [TargetView][RefView] delta for nominator of scale factor
-  Int**               m_aaiPdmOffset;                         ///< [TargetView][RefView] offset parameter
-
   // scale and offset parameters
   Double***           m_adBaseViewShiftParameter;             ///< ShiftParameters between BaseViews e.g. [2][1][0] shift scale from view 2 to view 1; [2][1][1] shift offset from view 2 to view 1
@@ -132,4 +129,8 @@
   Void  xSetupBaseViewsFromCoded  ();
   Void  xSetupBaseViews           ( Char* pchBaseViewNumbers, UInt uiNumBaseViews );
+#if H_3D_FIX_REN_WARNING
+  Bool  xIsIn                     ( std::vector<Int>& rVec, Int iNumber);
+#endif
+
 
   // functions for getting and setting scales and offsets
@@ -182,12 +183,16 @@
 
   Int                 synthRelNum2Idx           ( Int iRelNum );
-  Bool getLeftRightBaseView( Int iSynthViewIdx, Int &riLeftViewIdx, Int &riRightViewIdx, Int &riRelDistToLeft, Bool& rbIsBaseView );
+  Bool                getLeftRightBaseView      ( Int iSynthViewIdx, Int &riLeftViewIdx, Int &riRightViewIdx, Int &riRelDistToLeft, Bool& rbIsBaseView );
   Int                 getRelDistLeft            ( Int iSynthViewIdx, Int   iLeftViewIdx, Int iRightViewIdx );
   UInt                getCurFrameId             ()  { return m_iCurrentFrameId;   }
   static Void         convertNumberString       ( Char* pchViewNumberString, std::vector<Int>& raiViewNumbers, Double dViewNumPrec );
-
-#if SAIT_VSO_EST_A0033
-  Void xSetDispCoeff( UInt uiStartFrameId, Int iViewIdx );
-  Double getDispCoeff() { return m_dDispCoeff; }
+#if H_3D_REN_MAX_DEV_OUT
+  Double              getMaxShiftDeviation      () { return m_dMaxShiftDeviation; }; 
+#endif
+
+#if H_3D_VSO
+  // SAIT_VSO_EST_A033
+  Void                setDispCoeff              ( UInt uiStartFrameId, Int iViewIdx );
+  Double              getDispCoeff              () { return m_dDispCoeff; }
 #endif
 
@@ -215,12 +220,5 @@
   Int**               getCodedScale             ()  { return m_aaiCodedScale;           }
   Int**               getCodedOffset            ()  { return m_aaiCodedOffset;          }
-
-  // parameters for virtual depth map generation
-  Int                 getPdmPrecision           ()  { return m_iPdmPrecision;           }
-  Int**               getPdmScaleNomDelta       ()  { return m_aaiPdmScaleNomDelta;     }
-  Int**               getPdmOffset              ()  { return m_aaiPdmOffset;            }
-};
-
-
+};
 
 
Index: trunk/source/Lib/TAppCommon/program_options_lite.cpp
===================================================================
--- trunk/source/Lib/TAppCommon/program_options_lite.cpp	(revision 296)
+++ trunk/source/Lib/TAppCommon/program_options_lite.cpp	(revision 608)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -39,5 +39,5 @@
 #include <map>
 #include "program_options_lite.h"
-
+#include  "../TLibCommon/TypeDef.h"
 using namespace std;
 
@@ -146,4 +146,7 @@
       for(Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++)
       {
+#if H_MV
+        if  ( (*it)->opt->opt_duplicate ) continue; 
+#endif
         ostringstream line(ios_base::out);
         doHelpOpt(line, **it, pad_short);
@@ -161,4 +164,7 @@
       for(Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++)
       {
+#if H_MV
+        if  ( (*it)->opt->opt_duplicate ) continue; 
+#endif
         ostringstream line(ios_base::out);
         line << "  ";
@@ -192,5 +198,5 @@
             newline_pos++;
             line << opt_desc.substr(cur_pos, newline_pos - cur_pos);
-            cur_pos = newline_pos = newline_pos;
+            cur_pos = newline_pos;
             continue;
           }
Index: trunk/source/Lib/TAppCommon/program_options_lite.h
===================================================================
--- trunk/source/Lib/TAppCommon/program_options_lite.h	(revision 296)
+++ trunk/source/Lib/TAppCommon/program_options_lite.h	(revision 608)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -34,16 +34,17 @@
 #include <sstream>
 #include <string>
-#include <vector>
 #include <list>
 #include <map>
-#include <stdlib.h>
+#include  "../TLibCommon/TypeDef.h"
+
+#if H_MV
+#include <vector>
 #include <errno.h>
 #include <cstring>
-#include <math.h>
 
 #ifdef WIN32
 #define strdup _strdup
 #endif
-
+#endif
 //! \ingroup TAppCommon
 //! \{
@@ -56,4 +57,18 @@
     struct Options;
     
+    struct ParseFailure : public std::exception
+    {
+      ParseFailure(std::string arg0, std::string val0) throw()
+      : arg(arg0), val(val0)
+      {}
+
+      ~ParseFailure() throw() {};
+
+      std::string arg;
+      std::string val;
+
+      const char* what() const throw() { return "Option Parse Failure"; }
+    };
+
     void doHelp(std::ostream& out, Options& opts, unsigned columns = 80);
     unsigned parseGNU(Options& opts, unsigned argc, const char* argv[]);
@@ -71,6 +86,11 @@
     struct OptionBase
     {
+#if H_MV      
+      OptionBase(const std::string& name, const std::string& desc, bool duplicate = false)
+        : opt_string(name), opt_desc(desc), opt_duplicate(duplicate)
+#else
       OptionBase(const std::string& name, const std::string& desc)
       : opt_string(name), opt_desc(desc)
+#endif
       {};
       
@@ -84,4 +104,7 @@
       std::string opt_string;
       std::string opt_desc;
+#if H_MV
+      bool        opt_duplicate; 
+#endif
     };
     
@@ -90,6 +113,11 @@
     struct Option : public OptionBase
     {
+#if H_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)
+#else
       Option(const std::string& name, T& storage, T default_val, const std::string& desc)
       : OptionBase(name, desc), opt_storage(storage), opt_default_val(default_val)
+#endif
       {}
       
@@ -111,5 +139,13 @@
     {
       std::istringstream arg_ss (arg,std::istringstream::in);
-      arg_ss >> opt_storage;
+      arg_ss.exceptions(std::ios::failbit);
+      try
+      {
+        arg_ss >> opt_storage;
+      }
+      catch (...)
+      {
+        throw ParseFailure(opt_string, arg);
+      }
     }
     
@@ -122,5 +158,6 @@
       opt_storage = arg;
     }
-    
+
+#if H_MV    
     template<>
     inline void
@@ -258,5 +295,5 @@
       }
     }
-
+#endif
     /** Option class for argument handling using a user provided function */
     struct OptionFunc : public OptionBase
@@ -333,4 +370,5 @@
       }
       
+#if H_MV
       template<typename T>
       OptionSpecific&
@@ -338,22 +376,31 @@
       {
         std::string cNameBuffer;
-        std::string cDescriptionBuffer;
+        std::string cDescBuffer;
 
         cNameBuffer       .resize( name.size() + 10 );
-        cDescriptionBuffer.resize( desc.size() + 10 );
+        cDescBuffer.resize( desc.size() + 10 );
 
         storage.resize(uiMaxNum);
         for ( unsigned int uiK = 0; uiK < uiMaxNum; uiK++ )
         {
+          Bool duplicate = (uiK != 0); 
           // isn't there are sprintf function for string??
           sprintf((char*) cNameBuffer.c_str()       ,name.c_str(),uiK,uiK);
-          sprintf((char*) cDescriptionBuffer.c_str(),desc.c_str(),uiK,uiK);
-
-          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescriptionBuffer ));
+
+          if ( !duplicate )
+          {          
+            sprintf((char*) cDescBuffer.c_str(),desc.c_str(),uiK,uiK);
+          }
+
+          cNameBuffer.resize( std::strlen(cNameBuffer.c_str()) );  
+          cDescBuffer.resize( std::strlen(cDescBuffer.c_str()) ); 
+          
+
+          parent.addOption(new Option<T>( cNameBuffer, (storage[uiK]), default_val, cDescBuffer, duplicate ));
         }
 
         return *this;
       }
-
+#endif
       /**
        * Add option described by name to the parent Options list,
