Index: branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibCommon/SEI.cpp
===================================================================
--- branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibCommon/SEI.cpp	(revision 1336)
+++ branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibCommon/SEI.cpp	(revision 1337)
@@ -240,5 +240,7 @@
 #if NH_MV_SEI_TBD
   case SEI::FRAME_FIELD_INFO                      :               return new SEIFrameFieldInfo;
+#endif
   case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:            return new SEIThreeDimensionalReferenceDisplaysInfo;
+#if NH_MV_SEI_TBD
   case SEI::DEPTH_REPRESENTATION_INFO             :               return new SEIDepthRepresentationInfo;  
 #endif
@@ -976,33 +978,5 @@
 
 };
-
-Void SEIThreeDimensionalReferenceDisplaysInfo::setupFromSlice  ( const TComSlice* slice )
-{
-  sei.m_precRefDisplayWidth =  TBD ;
-  sei.m_refViewingDistanceFlag =  TBD ;
-  if( sei.m_refViewingDistanceFlag )
-  {
-    sei.m_precRefViewingDist =  TBD ;
-  }
-  sei.m_numRefDisplaysMinus1 =  TBD ;
-  for( Int i = 0; i  <=  NumRefDisplaysMinus1( ); i++ )
-  {
-    sei.m_leftViewId[i] =  TBD ;
-    sei.m_rightViewId[i] =  TBD ;
-    sei.m_exponentRefDisplayWidth[i] =  TBD ;
-    sei.m_mantissaRefDisplayWidth[i] =  TBD ;
-    if( sei.m_refViewingDistanceFlag )
-    {
-      sei.m_exponentRefViewingDistance[i] =  TBD ;
-      sei.m_mantissaRefViewingDistance[i] =  TBD ;
-    }
-    sei.m_additionalShiftPresentFlag[i] =  TBD ;
-    if( sei.m_additionalShiftPresentFlag( i ) )
-    {
-      sei.m_numSampleShiftPlus512[i] =  TBD ;
-    }
-  }
-  sei.m_threeDimensionalReferenceDisplaysExtensionFlag =  TBD ;
-};
+#endif
 
 Void SEIThreeDimensionalReferenceDisplaysInfo::setupFromCfgFile(const Char* cfgFile)
@@ -1011,13 +985,13 @@
   IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes; 
 
-  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send. 
-  defAppLayerIds    .push_back( TBD );
-  defAppPocs        .push_back( TBD );
-  defAppTids        .push_back( TBD );
-  defAppVclNaluTypes.push_back( TBD );
+  // Default values for which layers, POCS, Tids or Nalu types the SEI should be sent. 
+  defAppLayerIds      .push_back( 0 ); 
+  defAppPocs          .push_back( 0 );
+  defAppTids          .push_back( 0 );
+  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
 
   Int      defSeiNaluId                  = 0; 
   Int      defPositionInSeiNalu          = 0; 
-  Bool     defModifyByEncoder            = TBD; 
+  Bool     defModifyByEncoder            = 0; 
 
   // Setup config file options
@@ -1048,4 +1022,32 @@
 };
 
+
+UInt SEIThreeDimensionalReferenceDisplaysInfo::getMantissaReferenceDisplayWidthLen( Int i ) const
+{
+  return xGetSyntaxElementLen( m_exponentRefDisplayWidth[i], m_precRefDisplayWidth, m_mantissaRefDisplayWidth[ i ] );
+}
+
+UInt SEIThreeDimensionalReferenceDisplaysInfo::getMantissaReferenceViewingDistanceLen( Int i ) const
+{
+  return xGetSyntaxElementLen( m_exponentRefViewingDistance[i], m_precRefViewingDist, m_mantissaRefViewingDistance[ i ] );
+}
+
+UInt SEIThreeDimensionalReferenceDisplaysInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
+{
+  UInt len; 
+  if( expo == 0 )
+  {
+    len = std::max(0, prec - 30 );
+  }
+  else
+  {
+    len = std::max( 0, expo + prec - 31 );
+  }
+
+  assert( val >= 0 ); 
+  assert( val <= ( ( 1 << len )- 1) );
+  return len; 
+}
+
 Bool SEIThreeDimensionalReferenceDisplaysInfo::checkCfg( const TComSlice* slice )
 { 
@@ -1053,22 +1055,20 @@
   Bool wrongConfig = false; 
 
-  // TBD: Add constraints on presence of SEI here. 
-  xCheckCfg     ( wrongConfig, TBD , "TBD" );
-  xCheckCfg     ( wrongConfig, TBD , "TBD" );
-
-  // TBD: Modify constraints according to the SEI semantics.   
-  xCheckCfgRange( wrongConfig, m_precRefDisplayWidth            , MINVAL , MAXVAL, "prec_ref_display_width"           );
-  xCheckCfgRange( wrongConfig, m_refViewingDistanceFlag         , MINVAL , MAXVAL, "ref_viewing_distance_flag"        );
-  xCheckCfgRange( wrongConfig, m_precRefViewingDist             , MINVAL , MAXVAL, "prec_ref_viewing_dist"            );
-  xCheckCfgRange( wrongConfig, m_numRefDisplaysMinus1           , MINVAL , MAXVAL, "num_ref_displays_minus1"          );
-  xCheckCfgRange( wrongConfig, m_leftViewId[i]                  , MINVAL , MAXVAL, "left_view_id"                     );
-  xCheckCfgRange( wrongConfig, m_rightViewId[i]                 , MINVAL , MAXVAL, "right_view_id"                    );
-  xCheckCfgRange( wrongConfig, m_exponentRefDisplayWidth[i]     , MINVAL , MAXVAL, "exponent_ref_display_width"       );
-  xCheckCfgRange( wrongConfig, m_mantissaRefDisplayWidth[i]     , MINVAL , MAXVAL, "mantissa_ref_display_width"       );
-  xCheckCfgRange( wrongConfig, m_exponentRefViewingDistance[i]  , MINVAL , MAXVAL, "exponent_ref_viewing_distance"    );
-  xCheckCfgRange( wrongConfig, m_mantissaRefViewingDistance[i]  , MINVAL , MAXVAL, "mantissa_ref_viewing_distance"    );
-  xCheckCfgRange( wrongConfig, m_additionalShiftPresentFlag[i]  , MINVAL , MAXVAL, "additional_shift_present_flag"    );
-  xCheckCfgRange( wrongConfig, m_numSampleShiftPlus512[i]       , MINVAL , MAXVAL, "num_sample_shift_plus512"         );
-  xCheckCfgRange( wrongConfig, m_threeDimensionalReferenceDisplaysExtensionFlag, MINVAL , MAXVAL, "three_dimensional_reference_displays_extension_flag");
+  // The 3D reference display SEI should preferably be sent along with the multiview acquisition SEI. For now the multiview acquisition SEI is restricted to POC = 0, so 3D reference displays SEI is restricted to POC = 0 as well. 
+  xCheckCfg     ( wrongConfig, slice->isIRAP() && (slice->getPOC() == 0)  , "The 3D reference displays SEI message currently is associated with an access unit that contains an IRAP picture." );  
+
+  xCheckCfgRange( wrongConfig, m_precRefDisplayWidth            , 0 , 31, "prec_ref_display_width"  );
+  xCheckCfgRange( wrongConfig, m_refViewingDistanceFlag         , 0 , 1, "ref_viewing_distance_flag");
+  xCheckCfgRange( wrongConfig, m_precRefViewingDist             , 0 , 31, "prec_ref_viewing_dist"   );
+  xCheckCfgRange( wrongConfig, m_numRefDisplaysMinus1           , 0 , 31, "num_ref_displays_minus1" );
+
+  for (Int i = 0; i <= getNumRefDisplaysMinus1(); i++ )
+  {  
+    xCheckCfgRange( wrongConfig, m_exponentRefDisplayWidth[i]     , 0 , 62, "exponent_ref_display_width"   );
+    xCheckCfgRange( wrongConfig, m_exponentRefViewingDistance[i]  , 0 , 62, "exponent_ref_viewing_distance");
+    xCheckCfgRange( wrongConfig, m_additionalShiftPresentFlag[i]  , 0 , 1, "additional_shift_present_flag" );
+    xCheckCfgRange( wrongConfig, m_numSampleShiftPlus512[i]       , 0 , 1023, "num_sample_shift_plus512"   );
+  }
+  xCheckCfgRange( wrongConfig, m_threeDimensionalReferenceDisplaysExtensionFlag, 0 , 1, "three_dimensional_reference_displays_extension_flag");
 
   return wrongConfig; 
@@ -1076,4 +1076,5 @@
 };
 
+#if NH_MV_SEI_TBD
 Void SEIDepthRepresentationInfo::setupFromSlice  ( const TComSlice* slice )
 {
Index: branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibCommon/SEI.h
===================================================================
--- branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibCommon/SEI.h	(revision 1336)
+++ branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibCommon/SEI.h	(revision 1337)
@@ -873,4 +873,5 @@
   Bool      m_ffinfoDuplicateFlag;
 };
+#endif
 
 class SEIThreeDimensionalReferenceDisplaysInfo : public SEI
@@ -883,6 +884,10 @@
 
   Void setupFromCfgFile( const Char*      cfgFile );
-  Void setupFromSlice  ( const TComSlice* slice   );
-  Bool checkCfg        ( const TComSlice* slice   );
+  Bool checkCfg        ( const TComSlice* slice   );
+
+  Int getNumRefDisplaysMinus1( ) const
+  {
+    return m_numRefDisplaysMinus1; 
+  }
 
   Int       m_precRefDisplayWidth;
@@ -899,6 +904,26 @@
   IntAry1d  m_numSampleShiftPlus512;
   Bool      m_threeDimensionalReferenceDisplaysExtensionFlag;
-};
-
+
+  Void resizeArrays( )
+  {
+    Int numReferenceDiaplays = getNumRefDisplaysMinus1() + 1;
+  
+    m_leftViewId    .resize( numReferenceDiaplays );
+    m_rightViewId   .resize( numReferenceDiaplays );
+    m_exponentRefDisplayWidth      .resize( numReferenceDiaplays );
+    m_mantissaRefDisplayWidth      .resize( numReferenceDiaplays );
+    m_exponentRefViewingDistance   .resize( numReferenceDiaplays );
+    m_mantissaRefViewingDistance   .resize( numReferenceDiaplays );
+    m_additionalShiftPresentFlag   .resize( numReferenceDiaplays );
+    m_numSampleShiftPlus512        .resize( numReferenceDiaplays );
+  }
+
+  UInt getMantissaReferenceDisplayWidthLen  ( Int i ) const ;
+  UInt getMantissaReferenceViewingDistanceLen  ( Int i ) const ;
+private: 
+  UInt xGetSyntaxElementLen( Int expo, Int prec, Int val ) const; 
+};
+
+#if NH_MV_SEI_TBD
 class SEIDepthRepresentationInfo : public SEI
 {
Index: branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibDecoder/SEIread.cpp	(revision 1336)
+++ branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibDecoder/SEIread.cpp	(revision 1337)
@@ -355,8 +355,10 @@
       xParseSEIFrameFieldInfo((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
       break;
+#endif
     case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
       sei = new SEIThreeDimensionalReferenceDisplaysInfo;
       xParseSEIThreeDimensionalReferenceDisplaysInfo((SEIThreeDimensionalReferenceDisplaysInfo&) *sei, payloadSize, pDecodedMessageOutputStream );
       break;
+#if NH_MV_SEI_TBD
     case SEI::DEPTH_REPRESENTATION_INFO:
       sei = new SEIDepthRepresentationInfo;
@@ -1437,4 +1439,5 @@
   sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfoDuplicateFlag = (code == 1);
 };
+#endif
 
 Void SEIReader::xParseSEIThreeDimensionalReferenceDisplaysInfo(SEIThreeDimensionalReferenceDisplaysInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
@@ -1450,17 +1453,18 @@
   }
   sei_read_uvlc( pDecodedMessageOutputStream, code, "num_ref_displays_minus1" ); sei.m_numRefDisplaysMinus1 = code;
-  for( Int i = 0; i  <=  NumRefDisplaysMinus1( ); i++ )
+  sei.resizeArrays( );
+  for( Int i = 0; i  <=  sei.getNumRefDisplaysMinus1( ); i++ )
   {
     sei_read_uvlc( pDecodedMessageOutputStream, code, "left_view_id" ); sei.m_leftViewId[i] = code;
     sei_read_uvlc( pDecodedMessageOutputStream, code, "right_view_id" ); sei.m_rightViewId[i] = code;
     sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_ref_display_width" ); sei.m_exponentRefDisplayWidth[i] = code;
-    sei_read_code( pDecodedMessageOutputStream, getMantissaRefDisplayWidthLen ), code, "mantissa_ref_display_width" ); sei.m_mantissaRefDisplayWidth[i] = code;
+    sei_read_code( pDecodedMessageOutputStream, sei.getMantissaReferenceDisplayWidthLen(i), code, "mantissa_ref_display_width" ); sei.m_mantissaRefDisplayWidth[i] =  code      ;
     if( sei.m_refViewingDistanceFlag )
     {
       sei_read_code( pDecodedMessageOutputStream, 6, code, "exponent_ref_viewing_distance" ); sei.m_exponentRefViewingDistance[i] = code;
-      sei_read_code( pDecodedMessageOutputStream, getMantissaRefViewingDistanceLen ), code, "mantissa_ref_viewing_distance" ); sei.m_mantissaRefViewingDistance[i] = code;
+      sei_read_code( pDecodedMessageOutputStream, sei.getMantissaReferenceViewingDistanceLen(i), code, "mantissa_ref_viewing_distance" ); sei.m_mantissaRefViewingDistance[i] = code;
     }
     sei_read_flag( pDecodedMessageOutputStream, code, "additional_shift_present_flag" ); sei.m_additionalShiftPresentFlag[i] = (code == 1);
-    if( sei.m_additionalShiftPresentFlag( i ) )
+    if( sei.m_additionalShiftPresentFlag[i] )
     {
       sei_read_code( pDecodedMessageOutputStream, 10, code, "num_sample_shift_plus512" ); sei.m_numSampleShiftPlus512[i] = code;
@@ -1470,4 +1474,5 @@
 };
 
+#if NH_MV_SEI_TBD
 Void SEIReader::xParseSEIDepthRepresentationInfo(SEIDepthRepresentationInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream)
 {
Index: branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibDecoder/SEIread.h
===================================================================
--- branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibDecoder/SEIread.h	(revision 1336)
+++ branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibDecoder/SEIread.h	(revision 1337)
@@ -118,5 +118,7 @@
 #if NH_MV_SEI_TBD
   Void xParseSEIFrameFieldInfo                (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);
+#endif
   Void xParseSEIThreeDimensionalReferenceDisplaysInfo (SEIThreeDimensionalReferenceDisplaysInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);
+#if NH_MV_SEI_TBD
   Void xParseSEIDepthRepresentationInfo       (SEIDepthRepresentationInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream);
 
Index: branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibEncoder/SEIwrite.cpp
===================================================================
--- branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 1336)
+++ branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 1337)
@@ -163,7 +163,9 @@
      xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei));
      break; 
+#endif
    case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:
      xWriteSEIThreeDimensionalReferenceDisplaysInfo(*static_cast<const SEIThreeDimensionalReferenceDisplaysInfo*>(&sei));
      break; 
+ #if NH_MV_SEI_TBD
    case SEI::DEPTH_REPRESENTATION_INFO:
      xWriteSEIDepthRepresentationInfo(*static_cast<const SEIDepthRepresentationInfo*>(&sei));
@@ -1069,4 +1071,5 @@
   WRITE_FLAG( ( sei.m_ffinfoDuplicateFlag ? 1 : 0 ), "ffinfo_duplicate_flag" );
 };
+#endif
 
 Void SEIWriter::xWriteSEIThreeDimensionalReferenceDisplaysInfo( const SEIThreeDimensionalReferenceDisplaysInfo& sei)
@@ -1079,17 +1082,17 @@
   }
   WRITE_UVLC( sei.m_numRefDisplaysMinus1, "num_ref_displays_minus1" );
-  for( Int i = 0; i  <=  NumRefDisplaysMinus1( ); i++ )
+  for( Int i = 0; i  <=  sei.getNumRefDisplaysMinus1( ); i++ )
   {
     WRITE_UVLC( sei.m_leftViewId[i], "left_view_id" );
     WRITE_UVLC( sei.m_rightViewId[i], "right_view_id" );
     WRITE_CODE( sei.m_exponentRefDisplayWidth[i], 6, "exponent_ref_display_width" );
-    WRITE_CODE( sei.m_mantissaRefDisplayWidth[i], getMantissaRefDisplayWidthLen ), "mantissa_ref_display_width" );
+    WRITE_CODE( sei.m_mantissaRefDisplayWidth[i], sei.getMantissaReferenceDisplayWidthLen(i) , "mantissa_ref_display_width" );
     if( sei.m_refViewingDistanceFlag )
     {
       WRITE_CODE( sei.m_exponentRefViewingDistance[i], 6, "exponent_ref_viewing_distance" );
-      WRITE_CODE( sei.m_mantissaRefViewingDistance[i], getMantissaRefViewingDistanceLen ), "mantissa_ref_viewing_distance" );
+      WRITE_CODE( sei.m_mantissaRefViewingDistance[i], sei.getMantissaReferenceViewingDistanceLen(i), "mantissa_ref_viewing_distance" );
     }
     WRITE_FLAG( ( sei.m_additionalShiftPresentFlag[i] ? 1 : 0 ), "additional_shift_present_flag" );
-    if( sei.m_additionalShiftPresentFlag( i ) )
+    if( sei.m_additionalShiftPresentFlag[i] )
     {
       WRITE_CODE( sei.m_numSampleShiftPlus512[i], 10, "num_sample_shift_plus512" );
@@ -1099,4 +1102,5 @@
 };
 
+#if NH_MV_SEI_TBD
 Void SEIWriter::xWriteSEIDepthRepresentationInfo( const SEIDepthRepresentationInfo& sei)
 {
Index: branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibEncoder/SEIwrite.h
===================================================================
--- branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibEncoder/SEIwrite.h	(revision 1336)
+++ branches/HTM-15.1-dev0-Ericsson/source/Lib/TLibEncoder/SEIwrite.h	(revision 1337)
@@ -100,5 +100,7 @@
 #if NH_MV_SEI_TBD
   Void xWriteSEIFrameFieldInfo                ( const SEIFrameFieldInfo& sei);
+#endif
   Void xWriteSEIThreeDimensionalReferenceDisplaysInfo ( const SEIThreeDimensionalReferenceDisplaysInfo& sei);
+#if NH_MV_SEI_TBD
   Void xWriteSEIDepthRepresentationInfo       ( const SEIDepthRepresentationInfo& sei);
   Void xWriteSEIDepthRepInfoElement           ( const SEIDepthRepInfoElement& sei);
