Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 630)
@@ -115,4 +115,13 @@
 , m_noRaslOutputFlag              ( false )
 , m_handleCraAsBlaFlag            ( false )
+#endif
+#if POC_RESET_IDC_SIGNALlING
+, m_pocResetIdc                   ( 0 )
+, m_pocResetPeriodId              ( 0 )
+, m_fullPocResetFlag              ( false )
+, m_pocLsbVal                     ( 0 )
+, m_pocMsbVal                     ( 0 )
+, m_pocMsbValRequiredFlag         ( false )
+, m_pocMsbValPresentFlag          ( false )
 #endif
 #endif //SVC_EXTENSION
Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 630)
@@ -2047,4 +2047,13 @@
   Bool        m_handleCraAsBlaFlag;
 #endif
+#if POC_RESET_IDC_SIGNALlING
+  Int         m_pocResetIdc;
+  Int         m_pocResetPeriodId;
+  Bool        m_fullPocResetFlag;
+  Int         m_pocLsbVal;
+  Int         m_pocMsbVal;
+  Bool        m_pocMsbValRequiredFlag;
+  Bool        m_pocMsbValPresentFlag;
+#endif
 #endif //SVC_EXTENSION
 
@@ -2374,4 +2383,20 @@
 
 #endif
+#if POC_RESET_IDC_SIGNALlING
+  Int       getPocResetIdc       ()                              { return m_pocResetIdc;       }
+  Void      setPocResetIdc       (Int b)                         { m_pocResetIdc = b;          }
+  Int       getPocResetPeriodId  ()                              { return m_pocResetPeriodId;       }
+  Void      setPocResetPeriodId  (Int b)                         { m_pocResetPeriodId = b;          }
+  Bool      getFullPocResetFlag  ()                              { return m_fullPocResetFlag;       }
+  Void      setFullPocResetFlag  (Bool b)                        { m_fullPocResetFlag = b;          }
+  Int       getPocLsbVal         ()                              { return m_pocLsbVal;       }
+  Void      setPocLsbVal       (Int b)                           { m_pocLsbVal = b;          }
+  Int       getPocMsbVal         ()                              { return m_pocMsbVal;       }
+  Void      setPocMsbVal       (Int b)                           { m_pocMsbVal = b;          }
+  Bool      getPocMsbValPresentFlag ()                           { return m_pocMsbValPresentFlag; }
+  Void      setPocMsbValPresentFlag (Bool x)                     { m_pocMsbValPresentFlag = x; }
+  Bool      getPocMsbValRequiredFlag ()                           { return m_pocMsbValRequiredFlag; }
+  Void      setPocMsbValRequiredFlag (Bool x)                     { m_pocMsbValRequiredFlag = x; }
+#endif
 
 #endif //SVC_EXTENSION
Index: /branches/SHM-5.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 630)
@@ -91,4 +91,7 @@
 #define POC_RESET_FLAG                   1      ///< JCTVC-N0244: POC reset flag for  layer pictures.
 #define POC_RESET_IDC                    1      ///< JCTVC-P0041: Include poc_reset_idc and related derivation - eventually will replace POC_RESET_FLAG
+#if POC_RESET_IDC
+#define POC_RESET_IDC_SIGNALLING         1      ///< JCTVC-P0041: Include signalling for poc_reset related syntax elements
+#endif
 #define NO_OUTPUT_OF_PRIOR_PICS          1      ///< Use no_output_of_prior_pics_flag
 #define ALIGN_TSA_STSA_PICS              1      ///< JCTVC-N0084: Alignment of TSA and STSA pictures across AU.
Index: /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 630)
@@ -2862,4 +2862,90 @@
   }
 
+#if POC_RESET_IDC_SIGNALlING
+  Int sliceHederExtensionLength = 0;
+  if(pps->getSliceHeaderExtensionPresentFlag())
+  {
+    READ_UVLC( uiCode, "slice_header_extension_length"); sliceHederExtensionLength = uiCode;
+  }
+  else
+  {
+    sliceHederExtensionLength = 0;
+  }
+  UInt startBits = m_pcBitstream->getNumBitsRead();     // Start counter of # SH Extn bits
+  if( sliceHederExtensionLength > 0 )
+  {
+    if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() )
+    {
+      READ_CODE( 2, uiCode,       "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode);
+    }
+    else
+    {
+      rpcSlice->setPocResetIdc( 0 );
+    }
+    if( rpcSlice->getPocResetIdc() > 0 )
+    {
+      READ_CODE(6, uiCode,      "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode);
+    }
+    else
+    {
+     
+      rpcSlice->setPocResetPeriodId( 0 );
+    }
+
+    if (rpcSlice->getPocResetIdc() == 3)
+    {
+      READ_FLAG( uiCode,        "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false);
+      READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode);
+    }
+
+    // Derive the value of PocMsbValRequiredFlag
+    rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()
+                                          /* || related to vps_poc_lsb_aligned_flag */
+                                          );
+
+    if( rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ )
+    {
+      READ_FLAG( uiCode,    "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false );
+    }
+    else
+    {
+      if( rpcSlice->getPocMsbValRequiredFlag() )
+      {
+        rpcSlice->setPocMsbValPresentFlag( true );
+      }
+      else
+      {
+        rpcSlice->setPocMsbValPresentFlag( false );
+      }
+    }
+
+    Int maxPocLsb  = 1 << rpcSlice->getSPS()->getBitsForPOC();
+    if( rpcSlice->getPocMsbValPresentFlag() )
+    {
+      READ_UVLC( uiCode,    "poc_msb_val");             rpcSlice->setPocMsbVal( uiCode );
+      // Update POC of the slice based on this MSB val
+      Int pocLsb     = rpcSlice->getPOC() % maxPocLsb;
+      rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb);
+    }
+    else
+    {
+      rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb );
+    }
+
+    // Read remaining bits in the slice header extension.
+    UInt endBits = m_pcBitstream->getNumBitsRead();
+    Int counter = (endBits - startBits) % 8;
+    if( counter )
+    {
+      counter = 8 - counter;
+    }
+
+    while( counter )
+    {
+      READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 );
+      counter--;
+    }
+  }
+#else
   if(pps->getSliceHeaderExtensionPresentFlag())
   {
@@ -2871,4 +2957,5 @@
     }
   }
+#endif
   m_pcBitstream->readByteAlignment();
 
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 630)
@@ -2056,8 +2056,11 @@
     }
   }
+
+#if !POC_RESET_IDC_SIGNALlING   // Wrong place to put slice header extension
   if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
   {
     WRITE_UVLC(0,"slice_header_extension_length");
   }
+#endif
 }
 
@@ -2195,4 +2198,86 @@
 }
 
+#if POC_RESET_IDC_SIGNALlING
+Void  TEncCavlc::codeSliceHeaderExtn( TComSlice* slice, Int shBitsWrittenTillNow )
+{
+  Int tmpBitsBeforeWriting = getNumberOfWrittenBits();
+  if(slice->getPPS()->getSliceHeaderExtensionPresentFlag())
+  {
+    // Derive the value of PocMsbValRequiredFlag
+    slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag()
+                                          /* || related to vps_poc_lsb_aligned_flag */
+                                          );
+
+    // Determine value of SH extension length.
+    Int shExtnLengthInBit = 0;
+    if (slice->getPPS()->getPocResetInfoPresentFlag())
+    {
+      shExtnLengthInBit += 2;
+      if (slice->getPocResetIdc() > 0)
+      {
+        shExtnLengthInBit += 6;
+        if (slice->getPocResetIdc() == 3)
+        {
+          shExtnLengthInBit += (slice->getSPS()->getBitsForPOC() + 1);
+        }
+      }
+    }
+
+
+    if ( slice->getPocMsbValRequiredFlag() )
+    {
+      Int iMaxPOClsb = 1<< slice->getSPS()->getBitsForPOC();
+
+      UInt lengthVal = 1;
+      UInt tempVal = slice->getPocMsbVal() + 1;
+      assert ( tempVal );
+      while( 1 != tempVal )
+      {
+        tempVal >>= 1;
+        lengthVal += 2;
+      }
+      shExtnLengthInBit += lengthVal;
+    }
+    Int shExtnAdditionalBits = 0;
+    if(shExtnLengthInBit % 8 != 0)
+    {
+      shExtnAdditionalBits = 8 - (shExtnLengthInBit % 8);
+    }
+    Int shExtnLength = (shExtnLengthInBit + shExtnAdditionalBits) / 8;
+    WRITE_UVLC( shExtnLength, "slice_header_extension_length" );
+
+    if(slice->getPPS()->getPocResetInfoPresentFlag())
+    {
+      WRITE_CODE( slice->getPocResetIdc(), 2,                                 "poc_reset_idc");
+    }
+    if(slice->getPocResetIdc() > 0)
+    {
+      WRITE_CODE( slice->getPocResetPeriodId(), 6,                            "poc_reset_period_id");
+    }
+    if(slice->getPocResetIdc() == 3) 
+    {
+      WRITE_FLAG( slice->getFullPocResetFlag() ? 1 : 0,                       "full_poc_reset_flag");
+      WRITE_CODE( slice->getPocLsbVal(), slice->getSPS()->getBitsForPOC(),  "poc_lsb_val");
+    }
+
+    if( slice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ )
+    {
+      WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_val_present_flag" );
+    }
+    if( slice->getPocMsbValPresentFlag() )
+    {
+      WRITE_UVLC( slice->getPocMsbVal(),                                      "poc_msb_val" );
+    }
+    for (Int i = 0; i < shExtnAdditionalBits; i++)
+    {
+      WRITE_FLAG( 1, "slice_segment_header_extension_reserved_bit");
+    }
+  }
+  shBitsWrittenTillNow += ( getNumberOfWrittenBits() - tmpBitsBeforeWriting );
+  
+  // Slice header byte_alignment() included in xAttachSliceDataToNalUnit
+}
+#endif
+
 Void TEncCavlc::codeTerminatingBit      ( UInt uilsLast )
 {
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.h	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncCavlc.h	(revision 630)
@@ -96,4 +96,7 @@
   Void  codeHrdParameters       ( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 );
   Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
+#if POC_RESET_IDC_SIGNALlING
+  Void  codeSliceHeaderExtn( TComSlice* slice, Int shBitsWrittenTillNow );
+#endif
   Void  codeTerminatingBit      ( UInt uilsLast );
   Void  codeSliceFinish         ();
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 630)
@@ -60,4 +60,11 @@
 }
 
+#if POC_RESET_IDC_SIGNALlING
+Void  TEncEntropy::encodeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow )
+{
+  m_pcEntropyCoderIf->codeSliceHeaderExtn( pSlice, shBitsWrittenTillNow );
+}
+#endif
+
 Void TEncEntropy::encodeTerminatingBit      ( UInt uiIsLast )
 {
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncEntropy.h	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncEntropy.h	(revision 630)
@@ -74,4 +74,7 @@
 
   virtual Void  codeTilesWPPEntryPoint  ( TComSlice* pSlice )     = 0;
+#if POC_RESET_IDC_SIGNALlING
+  virtual Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow )     = 0;
+#endif
   virtual Void  codeTerminatingBit      ( UInt uilsLast )                                       = 0;
   virtual Void  codeSliceFinish         ()                                                      = 0;
@@ -142,4 +145,7 @@
   Void    encodeSliceHeader         ( TComSlice* pcSlice );
   Void    encodeTilesWPPEntryPoint( TComSlice* pSlice );
+#if POC_RESET_IDC_SIGNALlING
+Void      encodeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow );
+#endif
   Void    encodeTerminatingBit      ( UInt uiIsLast );
   Void    encodeSliceFinish         ();
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 630)
@@ -2215,5 +2215,12 @@
             m_pcEntropyCoder->setEntropyCoder   ( m_pcCavlcCoder, pcSlice );
             m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
+#if !POC_RESET_IDC_SIGNALlING
             m_pcEntropyCoder->encodeTilesWPPEntryPoint( pcSlice );
+#else
+            tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits();
+            m_pcEntropyCoder->encodeTilesWPPEntryPoint( pcSlice );
+            actualHeadBits += ( m_pcEntropyCoder->getNumberOfWrittenBits() - tmpBitsBeforeWriting );
+            m_pcEntropyCoder->encodeSliceHeaderExtn( pcSlice, actualHeadBits );
+#endif
 
             // Substreams...
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 630)
@@ -266,4 +266,11 @@
 }
 
+#if POC_RESET_IDC_SIGNALlING
+Void  TEncSbac::codeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow )
+{
+  assert (0);
+  return;
+}
+#endif
 Void TEncSbac::codeTerminatingBit( UInt uilsLast )
 {
Index: /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncSbac.h	(revision 629)
+++ /branches/SHM-5.1-dev/source/Lib/TLibEncoder/TEncSbac.h	(revision 630)
@@ -95,4 +95,7 @@
   Void  codeSliceHeader         ( TComSlice* pcSlice );
   Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
+#if POC_RESET_IDC_SIGNALlING
+  Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
+#endif
   Void  codeTerminatingBit      ( UInt uilsLast      );
   Void  codeSliceFinish         ();
