Index: branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1081)
@@ -72,6 +72,4 @@
 #endif
 , m_pchdQPFile()
-, m_pColumnWidth()
-, m_pRowHeight()
 , m_scalingListFile()
 {
@@ -139,6 +137,4 @@
 #endif
   free(m_pchdQPFile);
-  free(m_pColumnWidth);
-  free(m_pRowHeight);
   free(m_scalingListFile);
 #if H_MV
@@ -344,6 +340,6 @@
 #endif
   string cfg_dQPFile;
-  string cfg_ColumnWidth;
-  string cfg_RowHeight;
+  string cfgColumnWidth;
+  string cfgRowHeight;
   string cfg_ScalingListFile;
   string cfg_startOfCodedInterval;
@@ -420,11 +416,16 @@
   ("OutputBitDepthC",       m_outputBitDepthC,   0, "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
   ("InternalBitDepthC",     m_internalBitDepthC, 0, "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
-  ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
+  ("ConformanceMode",       m_conformanceWindowMode,  0, "Deprecated alias of ConformanceWindowMode")
+  ("ConformanceWindowMode", m_conformanceWindowMode,  0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
   ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
   ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
-  ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
-  ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
-  ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
-  ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
+  ("ConfLeft",              m_confWinLeft,            0, "Deprecated alias of ConfWinLeft")
+  ("ConfRight",             m_confWinRight,           0, "Deprecated alias of ConfWinRight")
+  ("ConfTop",               m_confWinTop,             0, "Deprecated alias of ConfWinTop")
+  ("ConfBottom",            m_confWinBottom,          0, "Deprecated alias of ConfWinBottom")
+  ("ConfWinLeft",           m_confWinLeft,            0, "Left offset for window conformance mode 3")
+  ("ConfWinRight",          m_confWinRight,           0, "Right offset for window conformance mode 3")
+  ("ConfWinTop",            m_confWinTop,             0, "Top offset for window conformance mode 3")
+  ("ConfWinBottom",         m_confWinBottom,          0, "Bottom offset for window conformance mode 3")
   ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
   ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
@@ -583,9 +584,15 @@
   ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
   ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
-  ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
-  ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
-  ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
-  ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
-  ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
+
+  //deprecated copies of renamed tile parameters
+  ("UniformSpacingIdc",           m_tileUniformSpacingFlag,        false,      "deprecated alias of TileUniformSpacing")
+  ("ColumnWidthArray",            cfgColumnWidth,                  string(""), "deprecated alias of TileColumnWidthArray")
+  ("RowHeightArray",              cfgRowHeight,                    string(""), "deprecated alias of TileRowHeightArray")
+
+  ("TileUniformSpacing",          m_tileUniformSpacingFlag,        false,      "Indicates that tile columns and rows are distributed uniformly")
+  ("NumTileColumnsMinus1",        m_numTileColumnsMinus1,          0,          "Number of tile columns in a picture minus 1")
+  ("NumTileRowsMinus1",           m_numTileRowsMinus1,             0,          "Number of rows in a picture minus 1")
+  ("TileColumnWidthArray",        cfgColumnWidth,                  string(""), "Array containing tile column width values in units of LCU")
+  ("TileRowHeightArray",          cfgRowHeight,                    string(""), "Array containing tile row height values in units of LCU")
   ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
   ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
@@ -669,5 +676,5 @@
   ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
   ("ColourPrimaries",                m_colourPrimaries,                        2, "Indicates chromaticity coordinates of the source primaries")
-  ("TransferCharateristics",         m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
+  ("TransferCharacteristics",        m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
   ("MatrixCoefficients",             m_matrixCoefficients,                     2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
   ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
@@ -889,24 +896,25 @@
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
   
-  Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
-  Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
-  if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
-  {
-    char *columnWidth;
+  Char* pColumnWidth = cfgColumnWidth.empty() ? NULL: strdup(cfgColumnWidth.c_str());
+  Char* pRowHeight = cfgRowHeight.empty() ? NULL : strdup(cfgRowHeight.c_str());
+
+  if( !m_tileUniformSpacingFlag && m_numTileColumnsMinus1 > 0 )
+  {
+    char *str;
     int  i=0;
-    m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
-    columnWidth = strtok(pColumnWidth, " ,-");
-    while(columnWidth!=NULL)
-    {
-      if( i>=m_iNumColumnsMinus1 )
+    m_tileColumnWidth.resize( m_numTileColumnsMinus1 );
+    str = strtok(pColumnWidth, " ,-");
+    while(str!=NULL)
+    {
+      if( i >= m_numTileColumnsMinus1 )
       {
         printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
         exit( EXIT_FAILURE );
       }
-      *( m_pColumnWidth + i ) = atoi( columnWidth );
-      columnWidth = strtok(NULL, " ,-");
+      m_tileColumnWidth[i] = atoi( str );
+      str = strtok(NULL, " ,-");
       i++;
     }
-    if( i<m_iNumColumnsMinus1 )
+    if( i < m_numTileColumnsMinus1 )
     {
       printf( "The width of some columns is not defined.\n" );
@@ -916,25 +924,25 @@
   else
   {
-    m_pColumnWidth = NULL;
-  }
-
-  if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
-  {
-    char *rowHeight;
+    m_tileColumnWidth.clear();
+  }
+
+  if( !m_tileUniformSpacingFlag && m_numTileRowsMinus1 > 0 )
+  {
+    char *str;
     int  i=0;
-    m_pRowHeight = new UInt[m_iNumRowsMinus1];
-    rowHeight = strtok(pRowHeight, " ,-");
-    while(rowHeight!=NULL)
-    {
-      if( i>=m_iNumRowsMinus1 )
+    m_tileRowHeight.resize(m_numTileRowsMinus1);
+    str = strtok(pRowHeight, " ,-");
+    while(str!=NULL)
+    {
+      if( i>=m_numTileRowsMinus1 )
       {
         printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
         exit( EXIT_FAILURE );
       }
-      *( m_pRowHeight + i ) = atoi( rowHeight );
-      rowHeight = strtok(NULL, " ,-");
+      m_tileRowHeight[i] = atoi( str );
+      str = strtok(NULL, " ,-");
       i++;
     }
-    if( i<m_iNumRowsMinus1 )
+    if( i < m_numTileRowsMinus1 )
     {
       printf( "The height of some rows is not defined.\n" );
@@ -944,5 +952,5 @@
   else
   {
-    m_pRowHeight = NULL;
+    m_tileRowHeight.clear();
   }
 #if H_MV
@@ -960,10 +968,10 @@
 
   // TODO:ChromaFmt assumes 4:2:0 below
-  switch (m_conformanceMode)
+  switch (m_conformanceWindowMode)
   {
   case 0:
     {
       // no conformance or padding
-      m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
+      m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
       m_aiPad[1] = m_aiPad[0] = 0;
       break;
@@ -975,15 +983,15 @@
       if (m_iSourceWidth % minCuSize)
       {
-        m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
-        m_iSourceWidth  += m_confRight;
+        m_aiPad[0] = m_confWinRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
+        m_iSourceWidth  += m_confWinRight;
       }
       if (m_iSourceHeight % minCuSize)
       {
-        m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
-        m_iSourceHeight += m_confBottom;
+        m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
+        m_iSourceHeight += m_confWinBottom;
         if ( m_isField )
         {
-          m_iSourceHeightOrg += m_confBottom << 1;
-          m_aiPad[1] = m_confBottom << 1;
+          m_iSourceHeightOrg += m_confWinBottom << 1;
+          m_aiPad[1] = m_confWinBottom << 1;
         }
       }
@@ -1005,6 +1013,6 @@
       m_iSourceWidth  += m_aiPad[0];
       m_iSourceHeight += m_aiPad[1];
-      m_confRight  = m_aiPad[0];
-      m_confBottom = m_aiPad[1];
+      m_confWinRight  = m_aiPad[0];
+      m_confWinBottom = m_aiPad[1];
       break;
     }
@@ -1012,5 +1020,5 @@
     {
       // conformance
-      if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
+      if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0))
       {
         fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
@@ -1680,5 +1688,5 @@
   }
   
-  Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
+  Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
   xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
 
@@ -1690,8 +1698,18 @@
   xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
 
-  xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
-  xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confWinLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confWinRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confWinTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
+  xConfirmPara( m_confWinBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
+
+  xConfirmPara( m_defaultDisplayWindowFlag && !m_vuiParametersPresentFlag, "VUI needs to be enabled for default display window");
+
+  if (m_defaultDisplayWindowFlag)
+  {
+    xConfirmPara( m_defDispWinLeftOffset   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left default display window offset must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara( m_defDispWinRightOffset  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right default display window offset must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara( m_defDispWinTopOffset    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top default display window offset must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara( m_defDispWinBottomOffset % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom default display window offset must be an integer multiple of the specified chroma subsampling");
+  }
 
 #if H_3D
@@ -2213,11 +2231,11 @@
       Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
       Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
-      if(m_iUniformSpacingIdr)
-      {
-        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
-        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
+      if(m_tileUniformSpacingFlag)
+      {
+        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_numTileColumnsMinus1)/(m_numTileColumnsMinus1+1));
+        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_numTileRowsMinus1)/(m_numTileRowsMinus1+1));
         // if only the last tile-row is one treeblock higher than the others 
         // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
-        if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
+        if(!((heightInCU-1)%(m_numTileRowsMinus1+1)))
         {
           maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
@@ -2225,5 +2243,5 @@
         // if only the last tile-column is one treeblock wider than the others 
         // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
-        if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
+        if(!((widthInCU-1)%(m_numTileColumnsMinus1+1)))
         {
           maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
@@ -2232,5 +2250,5 @@
       else // not uniform spacing
       {
-        if(m_iNumColumnsMinus1<1)
+        if(m_numTileColumnsMinus1<1)
         {
           maxTileWidth = m_iSourceWidth;
@@ -2239,12 +2257,12 @@
         {
           Int accColumnWidth = 0;
-          for(Int col=0; col<(m_iNumColumnsMinus1); col++)
+          for(Int col=0; col<(m_numTileColumnsMinus1); col++)
           {
-            maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
-            accColumnWidth += m_pColumnWidth[col];
+            maxTileWidth = m_tileColumnWidth[col]>maxTileWidth ? m_tileColumnWidth[col]:maxTileWidth;
+            accColumnWidth += m_tileColumnWidth[col];
           }
           maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
         }
-        if(m_iNumRowsMinus1<1)
+        if(m_numTileRowsMinus1<1)
         {
           maxTileHeight = m_iSourceHeight;
@@ -2253,8 +2271,8 @@
         {
           Int accRowHeight = 0;
-          for(Int row=0; row<(m_iNumRowsMinus1); row++)
+          for(Int row=0; row<(m_numTileRowsMinus1); row++)
           {
-            maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
-            accRowHeight += m_pRowHeight[row];
+            maxTileHeight = m_tileRowHeight[row]>maxTileHeight ? m_tileRowHeight[row]:maxTileHeight;
+            accRowHeight += m_tileRowHeight[row];
           }
           maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
@@ -2429,5 +2447,5 @@
   xPrintParaVector( "SAO"              , m_bUseSAO            ); 
 #endif
-  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
+  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
   printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
   if (m_isField)
Index: branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 1081)
@@ -43,4 +43,5 @@
 #include "TLibEncoder/TEncCfg.h"
 #include <sstream>
+#include <vector>
 #if H_3D
 #include "TAppCommon/TAppComCamPara.h"
@@ -172,9 +173,9 @@
   bool      m_isTopFieldFirst;
   
-  Int       m_conformanceMode;
-  Int       m_confLeft;
-  Int       m_confRight;
-  Int       m_confTop;
-  Int       m_confBottom;
+  Int       m_conformanceWindowMode;
+  Int       m_confWinLeft;
+  Int       m_confWinRight;
+  Int       m_confWinTop;
+  Int       m_confWinBottom;
   Int       m_framesToBeEncoded;                              ///< number of encoded frames
   Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
@@ -324,11 +325,9 @@
   Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
   Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
-  Int       m_iUniformSpacingIdr;
-  Int       m_iNumColumnsMinus1;
-  Char*     m_pchColumnWidth;
-  Int       m_iNumRowsMinus1;
-  Char*     m_pchRowHeight;
-  UInt*     m_pColumnWidth;
-  UInt*     m_pRowHeight;
+  Bool      m_tileUniformSpacingFlag;
+  Int       m_numTileColumnsMinus1;
+  Int       m_numTileRowsMinus1;
+  std::vector<Int> m_tileColumnWidth;
+  std::vector<Int> m_tileRowHeight;
   Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
Index: branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1081)
@@ -281,5 +281,5 @@
   m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
   m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
-  m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
+  m_cTEncTop.setConformanceWindow            ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
   m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
   
@@ -489,14 +489,14 @@
   }
 #endif
-  m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
-  m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
-  m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
-  if(m_iUniformSpacingIdr==0)
-  {
-    m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
-    m_cTEncTop.setRowHeight                ( m_pRowHeight );
+  m_cTEncTop.setTileUniformSpacingFlag     ( m_tileUniformSpacingFlag );
+  m_cTEncTop.setNumColumnsMinus1           ( m_numTileColumnsMinus1 );
+  m_cTEncTop.setNumRowsMinus1              ( m_numTileRowsMinus1 );
+  if(!m_tileUniformSpacingFlag)
+  {
+    m_cTEncTop.setColumnWidth              ( m_tileColumnWidth );
+    m_cTEncTop.setRowHeight                ( m_tileRowHeight );
   }
   m_cTEncTop.xCheckGSParameters();
-  Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
+  Int uiTilesCount          = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
   if(uiTilesCount == 1)
   {
@@ -603,4 +603,5 @@
   m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled ); 
   m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
+  m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag);
   m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
   m_cTEncTop.setSarWidth( m_sarWidth );
@@ -1087,5 +1088,9 @@
       if (m_pchReconFileList[layerId])
       {
+#if H_MV_ALIGN_HM_15
+        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst );
+#else
         m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
+#endif
       }
     }
@@ -1104,5 +1109,5 @@
       if (m_pchReconFile)
       {
-        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
+        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst );
       }
 
@@ -1140,5 +1145,9 @@
       if (m_pchReconFileList[layerId])
       {
+#if H_MV_ALIGN_HM_15
+        m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
+#else
         m_acTVideoIOYuvReconFileList[layerId]->write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
+#endif
       }    
     }
@@ -1156,5 +1165,5 @@
       if (m_pchReconFile)
       {
-        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
+        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
       }
 
@@ -1612,9 +1621,15 @@
 
   repFormat->setConformanceWindowVpsFlag( true );
+#if H_MV_ALIGN_HM_15
+  repFormat->setConfWinVpsLeftOffset    ( m_confWinLeft   / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) );
+  repFormat->setConfWinVpsRightOffset   ( m_confWinRight  / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() )  );
+  repFormat->setConfWinVpsTopOffset     ( m_confWinTop    / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() )  );
+  repFormat->setConfWinVpsBottomOffset  ( m_confWinBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); 
+#else
   repFormat->setConfWinVpsLeftOffset    ( m_confLeft   / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() ) );
   repFormat->setConfWinVpsRightOffset   ( m_confRight  / TComSPS::getWinUnitX( repFormat->getChromaFormatVpsIdc() )  );
   repFormat->setConfWinVpsTopOffset     ( m_confTop    / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() )  );
   repFormat->setConfWinVpsBottomOffset  ( m_confBottom / TComSPS::getWinUnitY( repFormat->getChromaFormatVpsIdc() ) ); 
-
+#endif
   assert( vps.getRepFormat( 0 ) == NULL ); 
   vps.setRepFormat( 0 , repFormat );
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 1081)
@@ -61,5 +61,5 @@
 #if H_MV
 #define NV_VERSION        "12.1"                ///< Current software version
-#define HM_VERSION        "14.0"                ///< 
+#define HM_VERSION        "15.0"                ///< 
 #else
 #define NV_VERSION        "14.0"                 ///< Current software version
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/SEI.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/SEI.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/SEI.h	(revision 1081)
@@ -161,6 +161,6 @@
   UInt m_bpSeqParameterSetId;
   Bool m_rapCpbParamsPresentFlag;
-  Bool m_cpbDelayOffset;
-  Bool m_dpbDelayOffset;
+  UInt m_cpbDelayOffset;
+  UInt m_dpbDelayOffset;
   UInt m_initialCpbRemovalDelay         [MAX_CPB_CNT][2];
   UInt m_initialCpbRemovalDelayOffset   [MAX_CPB_CNT][2];
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComPicSym.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComPicSym.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComPicSym.cpp	(revision 1081)
@@ -38,4 +38,5 @@
 #include "TComPicSym.h"
 #include "TComSampleAdaptiveOffset.h"
+#include "TComSlice.h"
 
 //! \ingroup TLibCommon
@@ -63,5 +64,4 @@
 ,m_iNumColumnsMinus1 (0)
 ,m_iNumRowsMinus1(0)
-,m_apcTComTile(NULL)
 ,m_puiCUOrderMap(0)
 ,m_puiTileIdxMap(NULL)
@@ -101,5 +101,5 @@
     delete [] m_apcTComSlice;
   }
-  m_apcTComSlice      = new TComSlice*[m_uiNumCUsInFrame*m_uiNumPartitions];  
+  m_apcTComSlice      = new TComSlice*[m_uiNumCUsInFrame];
   m_apcTComSlice[0]   = new TComSlice;
   m_uiNumAllocatedSlice = 1;
@@ -148,12 +148,4 @@
   m_apcTComDataCU = NULL;
 
-  for(Int i = 0; i < (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
-  {
-    delete m_apcTComTile[i];
-  }
-  delete [] m_apcTComTile;
-
-  m_apcTComTile = NULL;
-
   delete [] m_puiCUOrderMap;
   m_puiCUOrderMap = NULL;
@@ -173,4 +165,5 @@
 Void TComPicSym::allocateNewSlice()
 {
+  assert ((m_uiNumAllocatedSlice + 1) <= m_uiNumCUsInFrame);
   m_apcTComSlice[m_uiNumAllocatedSlice ++] = new TComSlice;
   if (m_uiNumAllocatedSlice>=2)
@@ -201,71 +194,132 @@
 }
 
-Void TComPicSym::xCreateTComTileArray()
-{
-  m_apcTComTile = new TComTile*[(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)];
-  for( UInt i=0; i<(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
-  {
-    m_apcTComTile[i] = new TComTile;
-  }
-}
-
-Void TComPicSym::xInitTiles()
-{
-  UInt  uiTileIdx;
-  UInt  uiColumnIdx = 0;
-  UInt  uiRowIdx = 0;
-  UInt  uiRightEdgePosInCU;
-  UInt  uiBottomEdgePosInCU;
-  Int   i, j;
+Void TComPicSym::initTiles(TComPPS *pps)
+{
+  //set NumColumnsMinus1 and NumRowsMinus1
+  setNumColumnsMinus1( pps->getNumTileColumnsMinus1() );
+  setNumRowsMinus1( pps->getTileNumRowsMinus1() );
+
+  const Int numCols = pps->getNumTileColumnsMinus1() + 1;
+  const Int numRows = pps->getTileNumRowsMinus1() + 1;
+  const Int numTiles = numRows * numCols;
+
+  // allocate memory for tile parameters
+  m_tileParameters.resize(numTiles);
+
+  if( pps->getTileUniformSpacingFlag() )
+  {
+    //set width and height for each (uniform) tile
+    for(Int row=0; row < numRows; row++)
+    {
+      for(Int col=0; col < numCols; col++)
+      {
+        const Int tileIdx = row * numCols + col;
+        m_tileParameters[tileIdx].setTileWidth( (col+1)*getFrameWidthInCU()/numCols
+                                              - (col*getFrameWidthInCU())/numCols );
+        m_tileParameters[tileIdx].setTileHeight( (row+1)*getFrameHeightInCU()/numRows
+                                               - (row*getFrameHeightInCU())/numRows );
+      }
+    }
+  }
+  else
+  {
+    //set the width for each tile
+    for(Int row=0; row < numRows; row++)
+    {
+      Int cumulativeTileWidth = 0;
+      for(Int col=0; col < getNumColumnsMinus1(); col++)
+  {
+  }
+      m_tileParameters[row * numCols + getNumColumnsMinus1()].setTileWidth( getFrameWidthInCU()-cumulativeTileWidth );
+}
+
+    //set the height for each tile
+    for(Int col=0; col < numCols; col++)
+{
+      Int cumulativeTileHeight = 0;
+      for(Int row=0; row < getNumRowsMinus1(); row++)
+      {
+        m_tileParameters[row * numCols + col].setTileHeight( pps->getTileRowHeight(row) );
+        cumulativeTileHeight += pps->getTileRowHeight(row);
+      }
+      m_tileParameters[getNumRowsMinus1() * numCols + col].setTileHeight( getFrameHeightInCU()-cumulativeTileHeight );
+    }
+  }
+
+#if TILE_SIZE_CHECK
+  Int minWidth  = 1;
+  Int minHeight = 1;
+  const Int profileIdc = pps->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc();
+  if (  profileIdc == Profile::MAIN || profileIdc == Profile::MAIN10)
+  {
+    if (pps->getTilesEnabledFlag())
+    {
+      minHeight = 64  / g_uiMaxCUHeight;
+      minWidth  = 256 / g_uiMaxCUWidth;
+    }
+  }
+  for(Int row=0; row < numRows; row++)
+  {
+    for(Int col=0; col < numCols; col++)
+    {
+      const Int tileIdx = row * numCols + col;
+      assert (m_tileParameters[tileIdx].getTileWidth() >= minWidth);
+      assert (m_tileParameters[tileIdx].getTileHeight() >= minHeight);
+    }
+  }
+#endif
 
   //initialize each tile of the current picture
-  for( uiRowIdx=0; uiRowIdx < m_iNumRowsMinus1+1; uiRowIdx++ )
-  {
-    for( uiColumnIdx=0; uiColumnIdx < m_iNumColumnsMinus1+1; uiColumnIdx++ )
-    {
-      uiTileIdx = uiRowIdx * (m_iNumColumnsMinus1+1) + uiColumnIdx;
+  for( Int row=0; row < numRows; row++ )
+  {
+    for( Int col=0; col < numCols; col++ )
+    {
+      const Int tileIdx = row * numCols + col;
 
       //initialize the RightEdgePosInCU for each tile
-      uiRightEdgePosInCU = 0;
-      for( i=0; i <= uiColumnIdx; i++ )
-      {
-        uiRightEdgePosInCU += this->getTComTile(uiRowIdx * (m_iNumColumnsMinus1+1) + i)->getTileWidth();
-      }
-      this->getTComTile(uiTileIdx)->setRightEdgePosInCU(uiRightEdgePosInCU-1);
+      Int rightEdgePosInCTU = 0;
+      for( Int i=0; i <= col; i++ )
+      {
+        rightEdgePosInCTU += m_tileParameters[row * numCols + i].getTileWidth();
+      }
+      m_tileParameters[tileIdx].setRightEdgePosInCU(rightEdgePosInCTU-1);
 
       //initialize the BottomEdgePosInCU for each tile
-      uiBottomEdgePosInCU = 0;
-      for( i=0; i <= uiRowIdx; i++ )
-      {
-        uiBottomEdgePosInCU += this->getTComTile(i * (m_iNumColumnsMinus1+1) + uiColumnIdx)->getTileHeight();
-      }
-      this->getTComTile(uiTileIdx)->setBottomEdgePosInCU(uiBottomEdgePosInCU-1);
+      Int bottomEdgePosInCTU = 0;
+      for( Int i=0; i <= row; i++ )
+      {
+        bottomEdgePosInCTU += m_tileParameters[i * numCols + col].getTileHeight();
+      }
+      m_tileParameters[tileIdx].setBottomEdgePosInCU(bottomEdgePosInCTU-1);
 
       //initialize the FirstCUAddr for each tile
-      this->getTComTile(uiTileIdx)->setFirstCUAddr( (this->getTComTile(uiTileIdx)->getBottomEdgePosInCU() - this->getTComTile(uiTileIdx)->getTileHeight() +1)*m_uiWidthInCU + 
-        this->getTComTile(uiTileIdx)->getRightEdgePosInCU() - this->getTComTile(uiTileIdx)->getTileWidth() + 1);
-    }
-  }
+      m_tileParameters[tileIdx].setFirstCUAddr( (m_tileParameters[tileIdx].getBottomEdgePosInCU() - m_tileParameters[tileIdx].getTileHeight() + 1) * getFrameWidthInCU() + 
+                                                 m_tileParameters[tileIdx].getRightEdgePosInCU() - m_tileParameters[tileIdx].getTileWidth() + 1);
+    }
+  }
+
+  Int  columnIdx = 0;
+  Int  rowIdx = 0;
 
   //initialize the TileIdxMap
-  for( i=0; i<m_uiNumCUsInFrame; i++)
-  {
-    for(j=0; j < m_iNumColumnsMinus1+1; j++)
-    {
-      if(i % m_uiWidthInCU <= this->getTComTile(j)->getRightEdgePosInCU())
-      {
-        uiColumnIdx = j;
-        j = m_iNumColumnsMinus1+1;
-      }
-    }
-    for(j=0; j < m_iNumRowsMinus1+1; j++)
-    {
-      if(i/m_uiWidthInCU <= this->getTComTile(j*(m_iNumColumnsMinus1 + 1))->getBottomEdgePosInCU())
-      {
-        uiRowIdx = j;
-        j = m_iNumRowsMinus1 + 1;
-      }
-    }
-    m_puiTileIdxMap[i] = uiRowIdx * (m_iNumColumnsMinus1 + 1) + uiColumnIdx;
+  for( Int i=0; i<m_uiNumCUsInFrame; i++)
+  {
+    for( Int col=0; col < numCols; col++)
+    {
+      if(i % getFrameWidthInCU() <= m_tileParameters[col].getRightEdgePosInCU())
+      {
+        columnIdx = col;
+        break;
+      }
+    }
+    for(Int row=0; row < numRows; row++)
+    {
+      if(i / getFrameWidthInCU() <= m_tileParameters[row*numCols].getBottomEdgePosInCU())
+      {
+        rowIdx = row;
+        break;
+      }
+    }
+    m_puiTileIdxMap[i] = rowIdx * numCols + columnIdx;
   }
 
@@ -417,4 +471,10 @@
 
 TComTile::TComTile()
+: m_uiTileWidth         (0)
+, m_uiTileHeight        (0)
+, m_uiRightEdgePosInCU  (0)
+, m_uiBottomEdgePosInCU (0)
+, m_uiFirstCUAddr       (0)
+
 {
 }
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComPicSym.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComPicSym.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComPicSym.h	(revision 1081)
@@ -45,4 +45,5 @@
 #include "TComDataCU.h"
 class TComSampleAdaptiveOffset;
+class TComPPS;
 
 //! \ingroup TLibCommon
@@ -102,5 +103,5 @@
   Int           m_iNumColumnsMinus1; 
   Int           m_iNumRowsMinus1;
-  TComTile**    m_apcTComTile;
+  std::vector<TComTile> m_tileParameters;
   UInt*         m_puiCUOrderMap;       //the map of LCU raster scan address relative to LCU encoding order 
   UInt*         m_puiTileIdxMap;       //the map of the tile index relative to LCU raster scan address 
@@ -133,5 +134,5 @@
   Int          getNumRowsMinus1()                                    { return m_iNumRowsMinus1; }
   Int          getNumTiles()                                         { return (m_iNumRowsMinus1+1)*(m_iNumColumnsMinus1+1); }
-  TComTile*    getTComTile  ( UInt tileIdx )                         { return *(m_apcTComTile + tileIdx); }
+  TComTile*    getTComTile  ( UInt tileIdx )                         { return &(m_tileParameters[tileIdx]); }
   Void         setCUOrderMap( Int encCUOrder, Int cuAddr )           { *(m_puiCUOrderMap + encCUOrder) = cuAddr; }
   UInt         getCUOrderMap( Int encCUOrder )                       { return *(m_puiCUOrderMap + (encCUOrder>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : encCUOrder)); }
@@ -141,6 +142,5 @@
   UInt         getPicSCUEncOrder( UInt SCUAddr );
   UInt         getPicSCUAddr( UInt SCUEncOrder );
-  Void         xCreateTComTileArray();
-  Void         xInitTiles();
+  Void         initTiles(TComPPS *pps);
   UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
   SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;}
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 1081)
@@ -2873,10 +2873,8 @@
 , m_entropyCodingSyncEnabledFlag   (false)
 , m_loopFilterAcrossTilesEnabledFlag  (true)
-, m_uniformSpacingFlag           (0)
-, m_iNumColumnsMinus1            (0)
-, m_puiColumnWidth               (NULL)
-, m_iNumRowsMinus1               (0)
-, m_puiRowHeight                 (NULL)
-, m_iNumSubstreams             (1)
+, m_uniformSpacingFlag           (false)
+, m_numTileColumnsMinus1         (0)
+, m_numTileRowsMinus1            (0)
+, m_numSubstreams               (1)
 , m_signHideFlag(0)
 , m_cabacInitPresentFlag        (false)
@@ -2911,14 +2909,4 @@
 TComPPS::~TComPPS()
 {
-  if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 )
-  {
-    if (m_puiColumnWidth) delete [] m_puiColumnWidth; 
-    m_puiColumnWidth = NULL;
-  }
-  if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 )
-  {
-    if (m_puiRowHeight) delete [] m_puiRowHeight;
-    m_puiRowHeight = NULL;
-  }
   delete m_scalingList;
 }
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 1081)
@@ -1970,11 +1970,11 @@
   
   Bool     m_loopFilterAcrossTilesEnabledFlag;
-  Int      m_uniformSpacingFlag;
-  Int      m_iNumColumnsMinus1;
-  UInt*    m_puiColumnWidth;
-  Int      m_iNumRowsMinus1;
-  UInt*    m_puiRowHeight;
-
-  Int      m_iNumSubstreams;
+  Bool             m_uniformSpacingFlag;
+  Int              m_numTileColumnsMinus1;
+  Int              m_numTileRowsMinus1;
+  std::vector<Int> m_tileColumnWidth;
+  std::vector<Int> m_tileRowHeight;
+
+  Int      m_numSubstreams;
 
   Int      m_signHideFlag;
@@ -2073,42 +2073,22 @@
   Bool    getDependentSliceSegmentsEnabledFlag() const     { return m_dependentSliceSegmentsEnabledFlag; }
   Void    setDependentSliceSegmentsEnabledFlag(Bool val)   { m_dependentSliceSegmentsEnabledFlag = val; }
-  Bool    getTilesEnabledFlag() const                      { return m_tilesEnabledFlag; }
-  Void    setTilesEnabledFlag(Bool val)                    { m_tilesEnabledFlag = val; }
   Bool    getEntropyCodingSyncEnabledFlag() const          { return m_entropyCodingSyncEnabledFlag; }
   Void    setEntropyCodingSyncEnabledFlag(Bool val)        { m_entropyCodingSyncEnabledFlag = val; }
-  Void     setUniformSpacingFlag            ( Bool b )          { m_uniformSpacingFlag = b; }
-  Bool     getUniformSpacingFlag            ()                  { return m_uniformSpacingFlag; }
-  Void     setNumColumnsMinus1              ( Int i )           { m_iNumColumnsMinus1 = i; }
-  Int      getNumColumnsMinus1              ()                  { return m_iNumColumnsMinus1; }
-  Void     setColumnWidth ( UInt* columnWidth )
-  {
-    if( m_uniformSpacingFlag == 0 && m_iNumColumnsMinus1 > 0 )
-    {
-      m_puiColumnWidth = new UInt[ m_iNumColumnsMinus1 ];
-
-      for(Int i=0; i<m_iNumColumnsMinus1; i++)
-      {
-        m_puiColumnWidth[i] = columnWidth[i];
-      }
-    }
-  }
-  UInt     getColumnWidth  (UInt columnIdx) { return *( m_puiColumnWidth + columnIdx ); }
-  Void     setNumRowsMinus1( Int i )        { m_iNumRowsMinus1 = i; }
-  Int      getNumRowsMinus1()               { return m_iNumRowsMinus1; }
-  Void     setRowHeight    ( UInt* rowHeight )
-  {
-    if( m_uniformSpacingFlag == 0 && m_iNumRowsMinus1 > 0 )
-    {
-      m_puiRowHeight = new UInt[ m_iNumRowsMinus1 ];
-
-      for(Int i=0; i<m_iNumRowsMinus1; i++)
-      {
-        m_puiRowHeight[i] = rowHeight[i];
-      }
-    }
-  }
-  UInt     getRowHeight           (UInt rowIdx)    { return *( m_puiRowHeight + rowIdx ); }
-  Void     setNumSubstreams(Int iNumSubstreams)               { m_iNumSubstreams = iNumSubstreams; }
-  Int      getNumSubstreams()                                 { return m_iNumSubstreams; }
+
+  Void     setTilesEnabledFlag       (Bool val)                             { m_tilesEnabledFlag = val; }
+  Bool     getTilesEnabledFlag       () const                               { return m_tilesEnabledFlag; }
+  Void     setTileUniformSpacingFlag (Bool b)                               { m_uniformSpacingFlag = b; }
+  Bool     getTileUniformSpacingFlag () const                               { return m_uniformSpacingFlag; }
+  Void     setNumTileColumnsMinus1   (Int i)                                { m_numTileColumnsMinus1 = i; }
+  Int      getNumTileColumnsMinus1   () const                               { return m_numTileColumnsMinus1; }
+  Void     setTileColumnWidth        (const std::vector<Int>& columnWidth ) { m_tileColumnWidth = columnWidth; }
+  UInt     getTileColumnWidth        (UInt columnIdx) const                 { return  m_tileColumnWidth[columnIdx]; }
+  Void     setNumTileRowsMinus1      (Int i)                                { m_numTileRowsMinus1 = i; }
+  Int      getTileNumRowsMinus1      () const                               { return m_numTileRowsMinus1; }
+  Void     setTileRowHeight          (const std::vector<Int>& rowHeight)    { m_tileRowHeight = rowHeight;  }
+  UInt     getTileRowHeight          (UInt rowIdx) const                    { return m_tileRowHeight[rowIdx]; }
+
+  Void     setNumSubstreams    (Int numSubstreams)                     { m_numSubstreams = numSubstreams; }
+  Int      getNumSubstreams    ()                                      { return m_numSubstreams; }
 
   Void      setSignHideFlag( Int signHideFlag ) { m_signHideFlag = signHideFlag; }
Index: branches/HTM-12.1-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 1081)
@@ -369,5 +369,5 @@
 #define H_MV_HLS_PTL_LIMITS                  0
 #define H_MV_HLS7_GEN                        0  // General changes (not tested)
-
+#define H_MV_ALIGN_HM_15                     1  
 
 // POC
@@ -418,4 +418,6 @@
 #define SAO_SGN_FUNC 1
 
+#define TILE_SIZE_CHECK 1
+
 #define FIX1172 1 ///< fix ticket #1172
 
@@ -433,5 +435,9 @@
 #define MAX_NESTING_NUM_LAYER       64
 
+#if H_MV
 #define MAX_VPS_NUM_HRD_PARAMETERS                1024
+#else
+#define MAX_VPS_NUM_HRD_PARAMETERS                1
+#endif
 #if H_MV
 #define MAX_NUM_SUB_LAYERS                        7
Index: branches/HTM-12.1-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1081)
@@ -292,30 +292,28 @@
   if( pcPPS->getTilesEnabledFlag() )
   {
-    READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumColumnsMinus1( uiCode );  
-    READ_UVLC ( uiCode, "num_tile_rows_minus1" );                   pcPPS->setNumRowsMinus1( uiCode );  
-    READ_FLAG ( uiCode, "uniform_spacing_flag" );                   pcPPS->setUniformSpacingFlag( uiCode );
-
-    if( !pcPPS->getUniformSpacingFlag())
-    {
-      UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt));
-      for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
+    READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumTileColumnsMinus1( uiCode );  
+    READ_UVLC ( uiCode, "num_tile_rows_minus1" );                   pcPPS->setNumTileRowsMinus1( uiCode );  
+    READ_FLAG ( uiCode, "uniform_spacing_flag" );                   pcPPS->setTileUniformSpacingFlag( uiCode == 1 );
+
+    if( !pcPPS->getTileUniformSpacingFlag())
+    {
+      std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1());
+      for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++)
       { 
         READ_UVLC( uiCode, "column_width_minus1" );  
         columnWidth[i] = uiCode+1;
       }
-      pcPPS->setColumnWidth(columnWidth);
-      free(columnWidth);
-
-      UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt));
-      for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
+      pcPPS->setTileColumnWidth(columnWidth);
+
+      std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1());
+      for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++)
       {
         READ_UVLC( uiCode, "row_height_minus1" );
         rowHeight[i] = uiCode + 1;
       }
-      pcPPS->setRowHeight(rowHeight);
-      free(rowHeight);  
-    }
-
-    if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0)
+      pcPPS->setTileRowHeight(rowHeight);
+    }
+
+    if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0)
     {
       READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" );   pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false );
@@ -1134,4 +1132,9 @@
         READ_FLAG( uiCode, "cprms_present_flag[i]" );              pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i );
       }
+      else
+      {
+        pcVPS->setCprmsPresentFlag( true, i );
+      }
+
       parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
     }
Index: branches/HTM-12.1-dev0/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1081)
@@ -727,5 +727,5 @@
 #endif
   pps->setSPS(sps);
-  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
+  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1);
   pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
 
@@ -1024,67 +1024,6 @@
   Bool bNextSlice     = pcSlice->isNextSlice();
 
-  UInt uiCummulativeTileWidth;
-  UInt uiCummulativeTileHeight;
-  UInt i, j, p;
-
-  //set NumColumnsMins1 and NumRowsMinus1
-  pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
-  pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
-
-  //create the TComTileArray
-  pcPic->getPicSym()->xCreateTComTileArray();
-
-  if( pcSlice->getPPS()->getUniformSpacingFlag() )
-  {
-    //set the width for each tile
-    for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
-    {
-      for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
-      {
-        pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
-          setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 
-          - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
-      }
-    }
-
-    //set the height for each tile
-    for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
-    {
-      for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
-      {
-        pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
-          setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 
-          - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
-      }
-    }
-  }
-  else
-  {
-    //set the width for each tile
-    for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++)
-    {
-      uiCummulativeTileWidth = 0;
-      for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++)
-      {
-        pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) );
-        uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i);
-      }
-      pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
-    }
-
-    //set the height for each tile
-    for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++)
-    {
-      uiCummulativeTileHeight = 0;
-      for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++)
-      { 
-        pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) );
-        uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i);
-      }
-      pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
-    }
-  }
-
-  pcPic->getPicSym()->xInitTiles();
+  UInt i;
+  pcPic->getPicSym()->initTiles(pcSlice->getPPS());
 
   //generate the Coding Order Map and Inverse Coding Order Map
Index: branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1081)
@@ -210,19 +210,19 @@
   if( pcPPS->getTilesEnabledFlag() )
   {
-    WRITE_UVLC( pcPPS->getNumColumnsMinus1(),                                    "num_tile_columns_minus1" );
-    WRITE_UVLC( pcPPS->getNumRowsMinus1(),                                       "num_tile_rows_minus1" );
-    WRITE_FLAG( pcPPS->getUniformSpacingFlag(),                                  "uniform_spacing_flag" );
-    if( pcPPS->getUniformSpacingFlag() == 0 )
-    {
-      for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
-      {
-        WRITE_UVLC( pcPPS->getColumnWidth(i)-1,                                  "column_width_minus1" );
-      }
-      for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
-      {
-        WRITE_UVLC( pcPPS->getRowHeight(i)-1,                                    "row_height_minus1" );
-      }
-    }
-    if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0)
+    WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(),                                    "num_tile_columns_minus1" );
+    WRITE_UVLC( pcPPS->getTileNumRowsMinus1(),                                       "num_tile_rows_minus1" );
+    WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(),                                  "uniform_spacing_flag" );
+    if( !pcPPS->getTileUniformSpacingFlag() )
+    {
+      for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++)
+      {
+        WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1,                                  "column_width_minus1" );
+      }
+      for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++)
+      {
+        WRITE_UVLC( pcPPS->getTileRowHeight(i)-1,                                    "row_height_minus1" );
+      }
+    }
+    if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0)
     {
       WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0,          "loop_filter_across_tiles_enabled_flag");
@@ -528,8 +528,8 @@
   if( defaultDisplayWindow.getWindowEnabledFlag() )
   {
-    WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset(),      "def_disp_win_left_offset");
-    WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset(),     "def_disp_win_right_offset");
-    WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset(),       "def_disp_win_top_offset");
-    WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset(),    "def_disp_win_bottom_offset");
+    WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset");
+    WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset");
+    WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset()   / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset");
+    WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset");
   }
   TimingInfo *timingInfo = pcVUI->getTimingInfo();
Index: branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncCfg.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncCfg.h	(revision 1081)
@@ -124,5 +124,4 @@
   Int       m_iSourceWidth;
   Int       m_iSourceHeight;
-  Int       m_conformanceMode;
   Window    m_conformanceWindow;
   Int       m_framesToBeEncoded;
@@ -229,9 +228,9 @@
   Bool      m_bPCMFilterDisableFlag;
   Bool      m_loopFilterAcrossTilesEnabledFlag;
-  Int       m_iUniformSpacingIdr;
+  Bool      m_tileUniformSpacingFlag;
   Int       m_iNumColumnsMinus1;
-  UInt*     m_puiColumnWidth;
   Int       m_iNumRowsMinus1;
-  UInt*     m_puiRowHeight;
+  std::vector<Int> m_tileColumnWidth;
+  std::vector<Int> m_tileRowHeight;
 
   Int       m_iWaveFrontSynchro;
@@ -430,6 +429,6 @@
 public:
   TEncCfg()
-  : m_puiColumnWidth()
-  , m_puiRowHeight()
+  : m_tileColumnWidth()
+  , m_tileRowHeight()
 #if H_MV
   , m_layerId(-1)
@@ -445,8 +444,5 @@
 
   virtual ~TEncCfg()
-  {
-    delete[] m_puiColumnWidth;
-    delete[] m_puiRowHeight;
-  }
+  {}
   
   Void setProfile(Profile::Name profile) { m_profile = profile; }
@@ -671,40 +667,14 @@
   Void  setLFCrossTileBoundaryFlag               ( Bool   val  )       { m_loopFilterAcrossTilesEnabledFlag = val; }
   Bool  getLFCrossTileBoundaryFlag               ()                    { return m_loopFilterAcrossTilesEnabledFlag;   }
-  Void  setUniformSpacingIdr           ( Int i )           { m_iUniformSpacingIdr = i; }
-  Int   getUniformSpacingIdr           ()                  { return m_iUniformSpacingIdr; }
+  Void  setTileUniformSpacingFlag      ( Bool b )          { m_tileUniformSpacingFlag = b; }
+  Bool  getTileUniformSpacingFlag      ()                  { return m_tileUniformSpacingFlag; }
   Void  setNumColumnsMinus1            ( Int i )           { m_iNumColumnsMinus1 = i; }
   Int   getNumColumnsMinus1            ()                  { return m_iNumColumnsMinus1; }
-  Void  setColumnWidth ( UInt* columnWidth )
-  {
-    if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
-    {
-      Int  m_iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth;
-      m_puiColumnWidth = new UInt[ m_iNumColumnsMinus1 ];
-
-      for(Int i=0; i<m_iNumColumnsMinus1; i++)
-      {
-        m_puiColumnWidth[i] = columnWidth[i];
-        printf("col: m_iWidthInCU= %4d i=%4d width= %4d\n",m_iWidthInCU,i,m_puiColumnWidth[i]); //AFU
-      }
-    }
-  }
-  UInt  getColumnWidth                 ( UInt columnidx )  { return *( m_puiColumnWidth + columnidx ); }
+  Void  setColumnWidth ( const std::vector<Int>& columnWidth ) { m_tileColumnWidth = columnWidth; }
+  UInt  getColumnWidth                 ( UInt columnIdx )      { return m_tileColumnWidth[columnIdx]; }
   Void  setNumRowsMinus1               ( Int i )           { m_iNumRowsMinus1 = i; }
   Int   getNumRowsMinus1               ()                  { return m_iNumRowsMinus1; }
-  Void  setRowHeight (UInt* rowHeight)
-  {
-    if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
-    {
-      Int  m_iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight;
-      m_puiRowHeight = new UInt[ m_iNumRowsMinus1 ];
-
-      for(Int i=0; i<m_iNumRowsMinus1; i++)
-      {
-        m_puiRowHeight[i] = rowHeight[i];
-        printf("row: m_iHeightInCU=%4d i=%4d height=%4d\n",m_iHeightInCU,i,m_puiRowHeight[i]); //AFU
-      }
-    }
-  }
-  UInt  getRowHeight                   ( UInt rowIdx )     { return *( m_puiRowHeight + rowIdx ); }
+  Void  setRowHeight ( const std::vector<Int>& rowHeight)      { m_tileRowHeight = rowHeight; }
+  UInt  getRowHeight                   ( UInt rowIdx )         { return m_tileRowHeight[rowIdx]; }
   Void  xCheckGSParameters();
   Void  setWaveFrontSynchro(Int iWaveFrontSynchro)       { m_iWaveFrontSynchro = iWaveFrontSynchro; }
Index: branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1081)
@@ -395,5 +395,9 @@
 Void TEncGOP::initGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP)
 {
+#if H_MV_ALIGN_HM_15
+  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, false );
+#else
   xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );
+#endif
   m_iNumPicCoded = 0;
 }
@@ -1228,68 +1232,8 @@
     UInt uiRealEndAddress = uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress;
 
-    UInt uiCummulativeTileWidth;
-    UInt uiCummulativeTileHeight;
     Int  p, j;
     UInt uiEncCUAddr;
 
-    //set NumColumnsMinus1 and NumRowsMinus1
-    pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
-    pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
-
-    //create the TComTileArray
-    pcPic->getPicSym()->xCreateTComTileArray();
-
-    if( pcSlice->getPPS()->getUniformSpacingFlag() == 1 )
-    {
-      //set the width for each tile
-      for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
-      {
-        for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
-        {
-          pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
-            setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 
-            - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
-        }
-      }
-
-      //set the height for each tile
-      for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
-      {
-        for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
-        {
-          pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
-            setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 
-            - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
-        }
-      }
-    }
-    else
-    {
-      //set the width for each tile
-      for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
-      {
-        uiCummulativeTileWidth = 0;
-        for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1(); p++)
-        {
-          pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->setTileWidth( pcSlice->getPPS()->getColumnWidth(p) );
-          uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(p);
-        }
-        pcPic->getPicSym()->getTComTile(j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
-      }
-
-      //set the height for each tile
-      for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
-      {
-        uiCummulativeTileHeight = 0;
-        for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1(); p++)
-        {
-          pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->setTileHeight( pcSlice->getPPS()->getRowHeight(p) );
-          uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(p);
-        }
-        pcPic->getPicSym()->getTComTile(p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
-      }
-    }
-    //intialize each tile of the current picture
-    pcPic->getPicSym()->xInitTiles();
+    pcPic->getPicSym()->initTiles(pcSlice->getPPS());
 
     // Allocate some coders, now we know how many tiles there are.
@@ -1814,4 +1758,5 @@
 
 #if SETTING_NO_OUT_PIC_PRIOR
+          pcSlice->setNoRaslOutputFlag(false);
           if (pcSlice->isIRAP())
           {
@@ -1821,4 +1766,5 @@
             }
             //the inference for NoOutputPriorPicsFlag
+            // KJS: This cannot happen at the encoder
             if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
             {
@@ -2492,20 +2438,4 @@
   assert (m_iGopSize > 0);
   
-  return;
-}
-
-Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut )
-{
-  assert( iNumPicRcvd > 0 );
-  //  Exception for the first frame
-  if ( iPOCLast == 0 )
-  {
-    m_iGopSize    = 1;
-  }
-  else
-    m_iGopSize    = m_pcCfg->getGOPSize();
-  
-  assert (m_iGopSize > 0); 
-
   return;
 }
Index: branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncGOP.h	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncGOP.h	(revision 1081)
@@ -200,5 +200,4 @@
 
   Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField );
-  Void  xInitGOP          ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut );
   Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, bool isField );
   
Index: branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1081)
@@ -6329,11 +6329,15 @@
     if( bCodeChroma )
     {
+      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
+      m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
       m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U );
-      uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsY;
+      uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits();
       
+      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
+      m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
       m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V );
-      uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - ( uiSingleBitsY + uiSingleBitsU );
+      uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits();
     }
     
@@ -6416,4 +6420,6 @@
         const Double singleCostY = m_pcRdCost->calcRdCost( uiSingleBitsY, uiNonzeroDistY );
 #endif
+        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
+
         m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA,     uiTrMode );
@@ -6449,4 +6455,5 @@
     else if( checkTransformSkipY )
     {
+      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
       m_pcEntropyCoder->resetBits();
       m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA, uiTrMode );
@@ -6505,4 +6512,5 @@
         {
           const Double dSingleCostU = m_pcRdCost->calcRdCost( uiSingleBitsU, uiNonzeroDistU );
+          m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
           m_pcEntropyCoder->resetBits();
           m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U,     uiTrMode );
@@ -6530,4 +6538,5 @@
       else if( checkTransformSkipUV )
       {
+        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
         m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode );
@@ -6574,4 +6583,5 @@
         {
           const Double dSingleCostV = m_pcRdCost->calcRdCost( uiSingleBitsV, uiNonzeroDistV );
+          m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
           m_pcEntropyCoder->resetBits();
           m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V,     uiTrMode );
@@ -6599,4 +6609,5 @@
       else if( checkTransformSkipUV )
       {
+        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
         m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode );
@@ -6795,5 +6806,4 @@
       pcCU->setCbfSubParts( uiAbsSumTransformSkipV ? uiSetCbf : 0, TEXT_CHROMA_V, uiAbsPartIdx, pcCU->getDepth(0)+uiTrModeC );
 
-      m_pcEntropyCoder->resetBits();
       uiSingleBitsU = 0;
       uiSingleBitsV = 0;
@@ -6801,4 +6811,5 @@
       if( uiAbsSumTransformSkipU )
       {
+        m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
         m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U );
@@ -6843,7 +6854,9 @@
       if( uiAbsSumTransformSkipV )
       {
+        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
+        m_pcEntropyCoder->resetBits();
         m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
         m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V );
-        uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsU;
+        uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits();
 
         curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
Index: branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1081)
@@ -854,5 +854,5 @@
   {
     TComVUI* pcVUI = m_cSPS.getVuiParameters();
-    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1);
+    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
     pcVUI->setAspectRatioIdc(getAspectRatioIdc());
     pcVUI->setSarWidth(getSarWidth());
@@ -1288,17 +1288,16 @@
 Void  TEncTop::xInitPPSforTiles()
 {
-  m_cPPS.setUniformSpacingFlag( m_iUniformSpacingIdr );
-  m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
-  m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
-  if( m_iUniformSpacingIdr == 0 )
-  {
-    m_cPPS.setColumnWidth( m_puiColumnWidth );
-    m_cPPS.setRowHeight( m_puiRowHeight );
+  m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag );
+  m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
+  m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 );
+  if( !m_tileUniformSpacingFlag )
+  {
+    m_cPPS.setTileColumnWidth( m_tileColumnWidth );
+    m_cPPS.setTileRowHeight( m_tileRowHeight );
   }
   m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
 
   // # substreams is "per tile" when tiles are independent.
-  if (m_iWaveFrontSynchro
-    )
+  if (m_iWaveFrontSynchro )
   {
     m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1));
@@ -1326,9 +1325,9 @@
   }
 
-  if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
+  if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag )
   {
     for(Int i=0; i<m_iNumColumnsMinus1; i++)
     {
-      uiCummulativeColumnWidth += m_puiColumnWidth[i];
+      uiCummulativeColumnWidth += m_tileColumnWidth[i];
     }
 
@@ -1353,8 +1352,8 @@
   }
 
-  if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 )
+  if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag )
   {
     for(Int i=0; i<m_iNumRowsMinus1; i++)
-      uiCummulativeRowHeight += m_puiRowHeight[i];
+      uiCummulativeRowHeight += m_tileRowHeight[i];
 
     if( uiCummulativeRowHeight >= iHeightInCU )
Index: branches/HTM-12.1-dev0/source/Lib/TLibVideoIO/TVideoIOYuv.cpp
===================================================================
--- branches/HTM-12.1-dev0/source/Lib/TLibVideoIO/TVideoIOYuv.cpp	(revision 1080)
+++ branches/HTM-12.1-dev0/source/Lib/TLibVideoIO/TVideoIOYuv.cpp	(revision 1081)
@@ -470,4 +470,9 @@
   Bool retval = true;
 
+  if ((width==0)||(height==0))
+  {
+    printf ("\nWarning: writing %d x %d luma sample output picture!", width, height);
+  }
+
   if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0)
   {
@@ -563,4 +568,9 @@
   
   Bool retval = true;
+  
+  if ((width==0)||(height==0))
+  {
+    printf ("\nWarning: writing %d x %d luma sample output picture!", width, height);
+  }
   
   if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0)
