Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1414)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1415)
@@ -1188,4 +1188,5 @@
   ("ConfWinTop",                                      m_confWinTop,                                         0, "Top offset for window conformance mode 3")
   ("ConfWinBottom",                                   m_confWinBottom,                                      0, "Bottom offset for window conformance mode 3")
+  ("AccessUnitDelimiter",                             m_AccessUnitDelimiter,                            false, "Enable Access Unit Delimiter NALUs")
   ("FrameRate,-fr",                                   m_iFrameRate,                                         0, "Frame rate")
 #if Q0074_COLOUR_REMAPPING_SEI
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1414)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1415)
@@ -119,5 +119,6 @@
 #if !SVC_EXTENSION
   Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
-#endif  
+#endif
+  Bool      m_AccessUnitDelimiter;                            ///< add Access Unit Delimiter NAL units
   InputColourSpaceConversion m_inputColourSpaceConvert;       ///< colour space conversion to apply to input video
   Bool      m_snrInternalColourSpace;                       ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied.
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1414)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1415)
@@ -543,4 +543,6 @@
 
   m_cTEncTop.setPad                                               ( m_aiPad );
+
+  m_cTEncTop.setAccessUnitDelimiter                               ( m_AccessUnitDelimiter );
 
 #if SVC_EXTENSION
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1414)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1415)
@@ -67,5 +67,15 @@
 #endif
 
-
+Void AUDWriter::codeAUD(TComBitIf& bs, const Int pictureType)
+{
+#if ENC_DEC_TRACE
+  xTraceAccessUnitDelimiter();
+#endif
+
+  assert (pictureType < 3);
+  setBitstream(&bs);
+  WRITE_CODE(pictureType, 3, "pic_type");
+  xWriteRbspTrailingBits();
+}
 
 // ====================================================================================================================
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1414)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1415)
@@ -64,4 +64,13 @@
 // Class definition
 // ====================================================================================================================
+
+class AUDWriter : public SyntaxElementWriter
+{
+public:
+  AUDWriter() {};
+  virtual ~AUDWriter() {};
+
+  Void  codeAUD(TComBitIf& bs, const Int pictureType);
+};
 
 /// CAVLC encoder class
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1414)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1415)
@@ -143,4 +143,5 @@
   Int       m_aiPad[2];
 
+  Bool      m_AccessUnitDelimiter;               ///< add Access Unit Delimiter NAL units
 
   Int       m_iMaxRefPicNum;                     ///< this is used to mimic the sliding mechanism used by the decoder
@@ -622,4 +623,7 @@
 
   Int       getPad                          ( Int i )      { assert (i < 2 );                      return  m_aiPad[i]; }
+
+  Bool      getAccessUnitDelimiter() const  { return m_AccessUnitDelimiter; }
+  Void      setAccessUnitDelimiter(Bool val){ m_AccessUnitDelimiter = val; }
 
   //======== Transform =============
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1414)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1415)
@@ -49,5 +49,7 @@
 #include <time.h>
 #include <math.h>
+
 #include <deque>
+using namespace std;
 
 #if SVC_EXTENSION
@@ -56,5 +58,4 @@
 #endif
 
-using namespace std;
 
 //! \ingroup TLibEncoder
@@ -293,4 +294,15 @@
 
   return actualTotalBits;
+}
+
+Void TEncGOP::xWriteAccessUnitDelimiter (AccessUnit &accessUnit, TComSlice *slice)
+{
+  AUDWriter audWriter;
+  OutputNALUnit nalu(NAL_UNIT_ACCESS_UNIT_DELIMITER);
+
+  Int picType = slice->isIntra() ? 0 : (slice->isInterP() ? 1 : 2);
+
+  audWriter.codeAUD(nalu.m_Bitstream, picType);
+  accessUnit.push_front(new NALUnitEBSP(nalu));
 }
 
@@ -2576,4 +2588,9 @@
 #endif
 
+    if (m_pcCfg->getAccessUnitDelimiter())
+    {
+      xWriteAccessUnitDelimiter(accessUnit, pcSlice);
+    }
+
     // reset presence of BP SEI indication
     m_bufferingPeriodSEIPresentInAU = false;
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h	(revision 1414)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h	(revision 1415)
@@ -55,11 +55,12 @@
 #include "SEIwrite.h"
 #include "SEIEncoder.h"
-#if CGS_3D_ASYMLUT
-#include "TEnc3DAsymLUT.h"
-#endif
 
 #include "TEncAnalyze.h"
 #include "TEncRateCtrl.h"
 #include <vector>
+
+#if CGS_3D_ASYMLUT
+#include "TEnc3DAsymLUT.h"
+#endif
 
 //! \ingroup TLibEncoder
@@ -235,4 +236,6 @@
   Double xCalculateRVM();
 
+  Void xWriteAccessUnitDelimiter (AccessUnit &accessUnit, TComSlice *slice);
+
   Void xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps);
   Void xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice);
