Index: branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1003)
+++ branches/SHM-upgrade/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 1006)
@@ -265,4 +265,5 @@
       }
       fclose (targetDecLayerIdSetFile);
+#if !R0235_SMALLEST_LAYER_ID  // LayerId=0 is not required anymore in some cases
       if ( m_targetDecLayerIdSet.size() > 0 && !isLayerIdZeroIncluded )
       {
@@ -270,4 +271,5 @@
         return false;
       }
+#endif
     }
     else
Index: branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1003)
+++ branches/SHM-upgrade/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1006)
@@ -1212,4 +1212,10 @@
     return true;
   }
+#if R0235_SMALLEST_LAYER_ID
+  if (nalu->m_layerId == 0 && (nalu->m_nalUnitType == NAL_UNIT_VPS || nalu->m_nalUnitType == NAL_UNIT_SPS || nalu->m_nalUnitType == NAL_UNIT_PPS || nalu->m_nalUnitType == NAL_UNIT_EOS))
+  {
+    return true;
+  }
+#endif
   for (std::vector<Int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++)
   {
Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1003)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1006)
@@ -2681,5 +2681,17 @@
 #if MULTIPLE_PTL_SUPPORT
     Int olsToLsIndex = (olsCtr >= (m_numLayerSets + m_numAddLayerSets)) ? m_outputLayerSetIdx[olsCtr - (m_numLayerSets + m_numAddLayerSets)] : olsCtr;
+#if R0235_SMALLEST_LAYER_ID
+    // This is a fix to allow setting of PTL for additional layer sets
+    if (olsCtr >= m_numLayerSets && olsCtr < (m_numLayerSets + m_numAddLayerSets))
+    {
+      scanStringToArrayNumEntries(cfg_listOfLayerPTLOfOlss[olsCtr], m_numLayerInIdList[olsToLsIndex], "List of PTL for each layers in OLS", m_listOfLayerPTLofOlss[olsCtr]);
+    }
+    else
+    {
+      scanStringToArray(cfg_listOfLayerPTLOfOlss[olsCtr], m_numLayerInIdList[olsToLsIndex], "List of PTL for each layers in OLS", m_listOfLayerPTLofOlss[olsCtr]);
+    }
+#else
     scanStringToArray( cfg_listOfLayerPTLOfOlss[olsCtr], m_numLayerInIdList[olsToLsIndex], "List of PTL for each layers in OLS", m_listOfLayerPTLofOlss[olsCtr] );
+#endif
     //For conformance checking
     //Conformance of a layer in an output operation point associated with an OLS in a bitstream to the Scalable Main profile is indicated as follows:
@@ -2688,4 +2700,8 @@
     //If OpTid of the output operation point is equal to vps_max_sub_layer_minus1, the conformance is indicated by general_profile_idc being equal to 7 or general_profile_compatibility_flag[ 7 ] being equal to 1
     //The following assert may be updated / upgraded to take care of general_profile_compatibility_flag.
+#if R0235_SMALLEST_LAYER_ID
+    if (m_numAddLayerSets == 0)
+    {
+#endif
     for ( Int ii = 1; ii < m_numLayerInIdList[olsToLsIndex]; ii++)
     {
@@ -2696,5 +2712,8 @@
                 (m_profileCompatibility[m_listOfLayerPTLofOlss[olsCtr][ii]] == m_profileList[m_listOfLayerPTLofOlss[olsCtr][ii - 1]]) );
       }
-    }   
+    }
+#if R0235_SMALLEST_LAYER_ID
+    }
+#endif
 #endif
   }
@@ -5084,4 +5103,76 @@
 }
 #endif
+
+#if R0235_SMALLEST_LAYER_ID
+#if OUTPUT_LAYER_SETS_CONFIG
+Void TAppEncCfg::cfgStringToArrayNumEntries(Int **arr, string const cfgString, Int &numEntries, const char* logString)
+{
+  Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
+  if (numEntries > 0)
+  {
+    Char *arrayEntry;
+    Int i = 0;
+    *arr = new Int[numEntries];
+
+    if (tempChar == NULL)
+    {
+      arrayEntry = NULL;
+    }
+    else
+    {
+      arrayEntry = strtok(tempChar, " ,");
+    }
+    while (arrayEntry != NULL)
+    {
+      if (i >= numEntries)
+      {
+        printf("%s: The number of entries specified is larger than the allowed number.\n", logString);
+        exit(EXIT_FAILURE);
+      }
+      *(*arr + i) = atoi(arrayEntry);
+      arrayEntry = strtok(NULL, " ,");
+      i++;
+    }
+    numEntries = i;
+    /*
+    if (i < numEntries)
+    {
+      printf("%s: Some entries are not specified.\n", logString);
+      exit(EXIT_FAILURE);
+    }
+    */
+  }
+  else
+  {
+    *arr = NULL;
+  }
+
+  if (tempChar)
+  {
+    free(tempChar);
+    tempChar = NULL;
+  }
+}
+
+Bool TAppEncCfg::scanStringToArrayNumEntries(string const cfgString, Int &numEntries, const char* logString, std::vector<Int> & returnVector)
+{
+  Int *tempArray = NULL;
+  numEntries = MAX_LAYERS;
+  // For all layer sets
+  cfgStringToArrayNumEntries(&tempArray, cfgString, numEntries, logString);
+  if (tempArray)
+  {
+    returnVector.empty();
+    for (Int i = 0; i < numEntries; i++)
+    {
+      returnVector.push_back(tempArray[i]);
+    }
+    delete[] tempArray; tempArray = NULL;
+    return true;
+  }
+  return false;
+}
+#endif
+#endif // R0235
 #endif //SVC_EXTENSION
 //! \}
Index: branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.h	(revision 1003)
+++ branches/SHM-upgrade/source/App/TAppEncoder/TAppEncCfg.h	(revision 1006)
@@ -587,4 +587,9 @@
   Bool scanStringToArray(string const cfgString, Int const numEntries, const char* logString, std::vector<Int> &  returnVector);
   Void cfgStringToArray(Int **arr, string const cfgString, Int const numEntries, const char* logString);
+#if R0235_SMALLEST_LAYER_ID
+  Bool scanStringToArrayNumEntries(string const cfgString, Int &numEntries, const char* logString, Int * const returnArray);
+  Bool scanStringToArrayNumEntries(string const cfgString, Int &numEntries, const char* logString, std::vector<Int> &  returnVector);
+  Void cfgStringToArrayNumEntries(Int **arr, string const cfgString, Int &numEntries, const char* logString);
+#endif
 #else
   Void cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString);
Index: branches/SHM-upgrade/source/App/utils/ExtractAddLS/ExtractAddLS.c
===================================================================
--- branches/SHM-upgrade/source/App/utils/ExtractAddLS/ExtractAddLS.c	(revision 1006)
+++ branches/SHM-upgrade/source/App/utils/ExtractAddLS/ExtractAddLS.c	(revision 1006)
@@ -0,0 +1,439 @@
+/* The copyright in this software is being made available under the BSD
+* License, included below. This software may be subject to other third party
+* and contributor rights, including patent rights, and no such rights are
+* granted under this license.
+*
+* Copyright (c) 2010-2014, ITU/ISO/IEC
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+*
+*  * Redistributions of source code must retain the above copyright notice,
+*    this list of conditions and the following disclaimer.
+*  * Redistributions in binary form must reproduce the above copyright notice,
+*    this list of conditions and the following disclaimer in the documentation
+*    and/or other materials provided with the distribution.
+*  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+*    be used to endorse or promote products derived from this software without
+*    specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+enum NalUnitType
+{
+  NAL_UNIT_CODED_SLICE_TRAIL_N = 0,
+  NAL_UNIT_CODED_SLICE_TRAIL_R,
+
+  NAL_UNIT_CODED_SLICE_TSA_N,
+  NAL_UNIT_CODED_SLICE_TSA_R,
+
+  NAL_UNIT_CODED_SLICE_STSA_N,
+  NAL_UNIT_CODED_SLICE_STSA_R,
+
+  NAL_UNIT_CODED_SLICE_RADL_N,
+  NAL_UNIT_CODED_SLICE_RADL_R,
+
+  NAL_UNIT_CODED_SLICE_RASL_N,
+  NAL_UNIT_CODED_SLICE_RASL_R,
+
+  NAL_UNIT_RESERVED_VCL_N10,
+  NAL_UNIT_RESERVED_VCL_R11,
+  NAL_UNIT_RESERVED_VCL_N12,
+  NAL_UNIT_RESERVED_VCL_R13,
+  NAL_UNIT_RESERVED_VCL_N14,
+  NAL_UNIT_RESERVED_VCL_R15,
+
+  NAL_UNIT_CODED_SLICE_BLA_W_LP,
+  NAL_UNIT_CODED_SLICE_BLA_W_RADL,
+  NAL_UNIT_CODED_SLICE_BLA_N_LP,
+  NAL_UNIT_CODED_SLICE_IDR_W_RADL,
+  NAL_UNIT_CODED_SLICE_IDR_N_LP,
+  NAL_UNIT_CODED_SLICE_CRA,
+  NAL_UNIT_RESERVED_IRAP_VCL22,
+  NAL_UNIT_RESERVED_IRAP_VCL23,
+
+  NAL_UNIT_RESERVED_VCL24,
+  NAL_UNIT_RESERVED_VCL25,
+  NAL_UNIT_RESERVED_VCL26,
+  NAL_UNIT_RESERVED_VCL27,
+  NAL_UNIT_RESERVED_VCL28,
+  NAL_UNIT_RESERVED_VCL29,
+  NAL_UNIT_RESERVED_VCL30,
+  NAL_UNIT_RESERVED_VCL31,
+
+  NAL_UNIT_VPS,
+  NAL_UNIT_SPS,
+  NAL_UNIT_PPS,
+  NAL_UNIT_ACCESS_UNIT_DELIMITER,
+  NAL_UNIT_EOS,
+  NAL_UNIT_EOB,
+  NAL_UNIT_FILLER_DATA,
+  NAL_UNIT_PREFIX_SEI,
+  NAL_UNIT_SUFFIX_SEI,
+  NAL_UNIT_RESERVED_NVCL41,
+  NAL_UNIT_RESERVED_NVCL42,
+  NAL_UNIT_RESERVED_NVCL43,
+  NAL_UNIT_RESERVED_NVCL44,
+  NAL_UNIT_RESERVED_NVCL45,
+  NAL_UNIT_RESERVED_NVCL46,
+  NAL_UNIT_RESERVED_NVCL47,
+  NAL_UNIT_UNSPECIFIED_48,
+  NAL_UNIT_UNSPECIFIED_49,
+  NAL_UNIT_UNSPECIFIED_50,
+  NAL_UNIT_UNSPECIFIED_51,
+  NAL_UNIT_UNSPECIFIED_52,
+  NAL_UNIT_UNSPECIFIED_53,
+  NAL_UNIT_UNSPECIFIED_54,
+  NAL_UNIT_UNSPECIFIED_55,
+  NAL_UNIT_UNSPECIFIED_56,
+  NAL_UNIT_UNSPECIFIED_57,
+  NAL_UNIT_UNSPECIFIED_58,
+  NAL_UNIT_UNSPECIFIED_59,
+  NAL_UNIT_UNSPECIFIED_60,
+  NAL_UNIT_UNSPECIFIED_61,
+  NAL_UNIT_UNSPECIFIED_62,
+  NAL_UNIT_UNSPECIFIED_63,
+  NAL_UNIT_INVALID,
+};
+
+char *nalUnitNames[] =
+{
+  "NAL_UNIT_CODED_SLICE_TRAIL_N",
+  "NAL_UNIT_CODED_SLICE_TRAIL_R",
+
+  "NAL_UNIT_CODED_SLICE_TSA_N",
+  "NAL_UNIT_CODED_SLICE_TSA_R",
+
+  "NAL_UNIT_CODED_SLICE_STSA_N",
+  "NAL_UNIT_CODED_SLICE_STSA_R",
+
+  "NAL_UNIT_CODED_SLICE_RADL_N",
+  "NAL_UNIT_CODED_SLICE_RADL_R",
+
+  "NAL_UNIT_CODED_SLICE_RASL_N",
+  "NAL_UNIT_CODED_SLICE_RASL_R",
+
+  "NAL_UNIT_RESERVED_VCL_N10",
+  "NAL_UNIT_RESERVED_VCL_R11",
+  "NAL_UNIT_RESERVED_VCL_N12",
+  "NAL_UNIT_RESERVED_VCL_R13",
+  "NAL_UNIT_RESERVED_VCL_N14",
+  "NAL_UNIT_RESERVED_VCL_R15",
+
+  "NAL_UNIT_CODED_SLICE_BLA_W_LP",
+  "NAL_UNIT_CODED_SLICE_BLA_W_RADL",
+  "NAL_UNIT_CODED_SLICE_BLA_N_LP",
+  "NAL_UNIT_CODED_SLICE_IDR_W_RADL",
+  "NAL_UNIT_CODED_SLICE_IDR_N_LP",
+  "NAL_UNIT_CODED_SLICE_CRA",
+  "NAL_UNIT_RESERVED_IRAP_VCL22",
+  "NAL_UNIT_RESERVED_IRAP_VCL23",
+
+  "NAL_UNIT_RESERVED_VCL24",
+  "NAL_UNIT_RESERVED_VCL25",
+  "NAL_UNIT_RESERVED_VCL26",
+  "NAL_UNIT_RESERVED_VCL27",
+  "NAL_UNIT_RESERVED_VCL28",
+  "NAL_UNIT_RESERVED_VCL29",
+  "NAL_UNIT_RESERVED_VCL30",
+  "NAL_UNIT_RESERVED_VCL31",
+
+  "NAL_UNIT_VPS",
+  "NAL_UNIT_SPS",
+  "NAL_UNIT_PPS",
+  "NAL_UNIT_ACCESS_UNIT_DELIMITER",
+  "NAL_UNIT_EOS",
+  "NAL_UNIT_EOB",
+  "NAL_UNIT_FILLER_DATA",
+  "NAL_UNIT_PREFIX_SEI",
+  "NAL_UNIT_SUFFIX_SEI",
+  "NAL_UNIT_RESERVED_NVCL41",
+  "NAL_UNIT_RESERVED_NVCL42",
+  "NAL_UNIT_RESERVED_NVCL43",
+  "NAL_UNIT_RESERVED_NVCL44",
+  "NAL_UNIT_RESERVED_NVCL45",
+  "NAL_UNIT_RESERVED_NVCL46",
+  "NAL_UNIT_RESERVED_NVCL47",
+  "NAL_UNIT_UNSPECIFIED_48",
+  "NAL_UNIT_UNSPECIFIED_49",
+  "NAL_UNIT_UNSPECIFIED_50",
+  "NAL_UNIT_UNSPECIFIED_51",
+  "NAL_UNIT_UNSPECIFIED_52",
+  "NAL_UNIT_UNSPECIFIED_53",
+  "NAL_UNIT_UNSPECIFIED_54",
+  "NAL_UNIT_UNSPECIFIED_55",
+  "NAL_UNIT_UNSPECIFIED_56",
+  "NAL_UNIT_UNSPECIFIED_57",
+  "NAL_UNIT_UNSPECIFIED_58",
+  "NAL_UNIT_UNSPECIFIED_59",
+  "NAL_UNIT_UNSPECIFIED_60",
+  "NAL_UNIT_UNSPECIFIED_61",
+  "NAL_UNIT_UNSPECIFIED_62",
+  "NAL_UNIT_UNSPECIFIED_63"
+};
+
+typedef struct NalUnitHeader_s
+{
+  int nalUnitType;
+  int nuhLayerId;
+  int nuhTemporalIdPlus1;
+} NalUnitHeader;
+
+
+int findStartCodePrefix(FILE *inFile, int *numStartCodeZeros)
+{
+  int numZeros = 0;
+  int currByte;
+  
+  for (;;)
+  {
+    currByte = fgetc(inFile);
+    if (currByte == EOF)
+    {
+      return 0;
+    }
+
+    if (currByte == 0x01 && numZeros > 1)
+    {
+      *numStartCodeZeros = numZeros;
+      return 1;
+    }
+    else if (currByte == 0)
+    {
+      numZeros++;
+    }
+    else
+    {
+      numZeros = 0;
+    }
+  }
+}
+
+int parseNalUnitHeader(FILE *inFile, NalUnitHeader *nalu)
+{
+  int byte0, byte1;
+
+  byte0 = fgetc(inFile);
+  byte1 = fgetc(inFile);
+
+  if (byte0 == EOF || byte1 == EOF)
+  {
+    return 0;
+  }
+
+  nalu->nalUnitType = (byte0 >> 1) & 0x3f;
+  nalu->nuhLayerId  = (((byte0 << 8) | byte1) >> 3) & 0x3f;
+  nalu->nuhTemporalIdPlus1 = byte1 & 0x07;
+
+  return 1;
+}
+
+void writeStartCodePrefixAndNUH(FILE *outFile, int numStartCodeZeros, NalUnitHeader *nalu)
+{
+  int byte0, byte1;
+  int i;
+
+  /* Start code prefix */
+  if (numStartCodeZeros > 3)
+  {
+    numStartCodeZeros = 3;
+  }
+  for (i = 0; i < numStartCodeZeros; i++)
+  {
+    fputc(0, outFile);
+  }
+  fputc(0x01, outFile);
+
+  /* NAL unit header */
+  byte0 = ((nalu->nalUnitType << 6) | nalu->nuhLayerId) >> 5;
+  byte1 = ((nalu->nuhLayerId << 3) | nalu->nuhTemporalIdPlus1) & 0xff;
+  fputc(byte0, outFile);
+  fputc(byte1, outFile);
+}
+
+int main(int argc, char **argv)
+{
+  FILE *inFile;
+  FILE *outFile;
+  int assignedBaseLayerId;
+  int tIdTarget = 6;
+  NalUnitHeader nalu;
+  int numStartCodeZeros;
+  int nalIsSpsPpsEob;
+  int nalIsVpsSpsPpsEos;
+  int removeNal;
+  int layerIdListTarget[8];
+  int i;
+  int layerIdx;
+  int numLayerIds;
+  char nalName[32];
+
+  if (argc < 5 || argc > 10)
+  {
+    fprintf(stderr, "\n  Usage: ExtractAddLS <infile> <outfile> <max temporal ID> <list of layer IDs> \n\n");
+    fprintf(stderr, "  If only one layer ID is given, independent non-base layer rewriting process\n");
+    fprintf(stderr, "  is performed\n");
+    fprintf(stderr, "  If more than one layer ID is given, sub-bitstream extraction process for\n");
+    fprintf(stderr, "  additional layer sets is performed (Layer ID list should exactly match\n");
+    fprintf(stderr, "  an additional layer set defined in VPS)\n");
+    exit(1);
+  }
+
+  inFile = fopen(argv[1], "rb");
+  if (inFile == NULL)
+  {
+    fprintf(stderr, "Cannot open input file %s\n", argv[1]);
+    exit(1);
+  }
+
+  outFile = fopen(argv[2], "wb");
+  if (outFile == NULL)
+  {
+    fprintf(stderr, "Cannot open output file %s\n", argv[2]);
+    exit(1);
+  }
+
+  tIdTarget = atoi(argv[3]);
+  if (tIdTarget < 0 || tIdTarget > 6)
+  {
+    fprintf(stderr, "Invalid maximum temporal ID (must be in range 0-6)\n");
+    exit(1);
+  }
+
+  for (i = 4, layerIdx = 0; i < argc; i++, layerIdx++)
+  {
+    layerIdListTarget[layerIdx] = atoi(argv[i]);
+    if (layerIdListTarget[layerIdx] < 1 || layerIdListTarget[layerIdx] > 7)
+    {
+      fprintf(stderr, "Invalid layer ID (must be in range 1-7)\n");
+      exit(1);
+    }
+  }
+
+  numLayerIds = layerIdx;
+  assignedBaseLayerId = layerIdListTarget[0];
+
+  /* Iterate through all NAL units */
+  for (;;)
+  {
+    if (!findStartCodePrefix(inFile, &numStartCodeZeros))
+    {
+      break;
+    }
+    if (!parseNalUnitHeader(inFile, &nalu))
+    {
+      break;
+    }
+
+    if (numLayerIds == 1)
+    {
+      /* independent non-base layer rewriting process */
+
+      nalIsSpsPpsEob = (nalu.nalUnitType == NAL_UNIT_SPS || nalu.nalUnitType == NAL_UNIT_PPS || nalu.nalUnitType == NAL_UNIT_EOB);
+
+      removeNal = (!nalIsSpsPpsEob && (nalu.nuhLayerId != assignedBaseLayerId))
+                || (nalIsSpsPpsEob && (nalu.nuhLayerId != 0) && (nalu.nuhLayerId != assignedBaseLayerId))
+                || (nalu.nalUnitType == NAL_UNIT_VPS)
+                || ((nalu.nuhTemporalIdPlus1 - 1) > tIdTarget);
+
+      nalu.nuhLayerId = 0;
+    }
+    else /* numLayerIds > 1 */
+    {
+      /* sub-bitstream extraction process for additional layer sets */
+
+      int isTargetLayer = 0;
+
+      for (i = 0; i < numLayerIds; i++)
+      {
+        if (layerIdListTarget[i] == nalu.nuhLayerId)
+        {
+          isTargetLayer = 1;
+        }
+      }
+    
+      nalIsVpsSpsPpsEos = (nalu.nalUnitType == NAL_UNIT_VPS || nalu.nalUnitType == NAL_UNIT_SPS || nalu.nalUnitType == NAL_UNIT_PPS || nalu.nalUnitType == NAL_UNIT_EOS);
+
+      removeNal = (!(nalIsVpsSpsPpsEos || nalu.nalUnitType == NAL_UNIT_EOB) && !isTargetLayer)
+                || (nalIsVpsSpsPpsEos && (nalu.nuhLayerId != 0) && !isTargetLayer)
+                || ((nalu.nuhTemporalIdPlus1 - 1) > tIdTarget);
+    }
+
+    if (!removeNal)
+    {
+      /* Write current NAL unit to output bitstream */
+
+      long naluBytesStartPos;
+      long numNaluBytes;
+      long i;
+
+      printf("Keep  ");
+
+      writeStartCodePrefixAndNUH(outFile, numStartCodeZeros, &nalu);
+
+      naluBytesStartPos = ftell(inFile);
+      /* Find beginning of the next NAL unit to calculate length of the current unit */
+      if (findStartCodePrefix(inFile, &numStartCodeZeros))
+      {
+        numNaluBytes = ftell(inFile) - naluBytesStartPos - numStartCodeZeros - 1;
+      }
+      else
+      {
+        numNaluBytes = ftell(inFile) - naluBytesStartPos;
+      }
+      fseek(inFile, naluBytesStartPos, SEEK_SET);
+
+      i = 0;
+
+      if (numLayerIds > 1 && nalu.nalUnitType == NAL_UNIT_VPS)
+      {
+        /* sub-bitstream extraction process for additional layer sets */
+        int nalByte = fgetc(inFile);
+        nalByte = nalByte & ~(0x04);  /* vps_base_layer_available_flag in each VPS is set equal to 0 */
+        fputc(nalByte, outFile);
+        i++;
+      }
+
+      for (; i < numNaluBytes; i++)
+      {
+        fputc(fgetc(inFile), outFile);
+      }
+    }
+    else
+    {
+      printf("-     ");
+    }
+
+    strcpy(nalName, nalUnitNames[nalu.nalUnitType]);
+    for (i = strlen(nalName); i < 31; i++)
+    {
+      nalName[i] = ' ';
+    }
+    nalName[31] = '\0';
+
+    printf("%s  layer ID: %i  temporal ID: %i\n", nalName, nalu.nuhLayerId, nalu.nuhTemporalIdPlus1 - 1);
+  }
+
+  fclose(inFile);
+  fclose(outFile);
+
+
+  return 0;
+}
Index: branches/SHM-upgrade/source/App/utils/ExtractAddLS/ReadMe.txt
===================================================================
--- branches/SHM-upgrade/source/App/utils/ExtractAddLS/ReadMe.txt	(revision 1006)
+++ branches/SHM-upgrade/source/App/utils/ExtractAddLS/ReadMe.txt	(revision 1006)
@@ -0,0 +1,21 @@
+
+This a tool that either:
+
+  1. Extracts an independent non-base layer from a multi-layer bitstream, converts it to a base-layer bistream and writes it to a file. The extraction processs is defined in chapter F.10.2 of the HEVC version 2 specification.
+
+or
+
+  2. Extracts an additional layer set sub-bitstream from multi-layer bitstream and writes it to a file. The extraction processs is defined in chapter F.10.3 of the HEVC version 2 specification.
+
+
+The tool is invoked as follows:
+
+  ExtractAddLS <infile> <outfile> <Max temporal ID> <layer IDs of the extracted layers>
+
+The process that is invoked is decided based on the number of IDs that are given in the layer ID list.  If only one layer ID is given, independent non-base layer rewriting process is invoked. If more than one layer ID is given, sub-bitstream extraction for additional layer sets is invoked.
+
+The result of independent non-base layer rewriting process can be decoded with an HEVC/H.265 v1 compliant decoder as long as the extracted independent layer conform with v1 specification text. The tool removes VPS from the output bitstream during rewriting so an HEVC/H.265 decoder should not expect it to be present.
+
+
+
+
Index: branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.cpp	(revision 1003)
+++ branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.cpp	(revision 1006)
@@ -901,5 +901,9 @@
  */
 #if NO_CLRAS_OUTPUT_FLAG
+#if R0235_SMALLEST_LAYER_ID
+Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag, UInt smallestLayerId )
+#else
 Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag )
+#endif
 {
   if( !isIRAP() )
@@ -913,5 +917,9 @@
   // When the current picture is an IRAP picture with nuh_layer_id equal to 0 and NoClrasOutputFlag is equal to 1, 
   // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked as "unused for reference".
+#if R0235_SMALLEST_LAYER_ID
+  if (m_layerId == smallestLayerId && noClrasOutputFlag)
+#else
   if( m_layerId == 0 && noClrasOutputFlag )
+#endif
   {
     // mark all pictures for all layers as not used for reference
Index: branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.h	(revision 1003)
+++ branches/SHM-upgrade/source/Lib/TLibCommon/TComSlice.h	(revision 1006)
@@ -2536,5 +2536,9 @@
   Void      checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic);
 #if NO_CLRAS_OUTPUT_FLAG
+#if R0235_SMALLEST_LAYER_ID
+  Void      decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag, UInt smallestLayerId = 0 );
+#else
   Void      decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag );
+#endif
   Void      decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag);
 #else
Index: branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h	(revision 1003)
+++ branches/SHM-upgrade/source/Lib/TLibCommon/TypeDef.h	(revision 1006)
@@ -81,4 +81,5 @@
 #define R0227_BR_PR_ADD_LAYER_SET        1      ///< JCTVC-R0227, Signalling of bit-rate and picture rate for additional layer set
 #define R0042_PROFILE_INDICATION         1      ///< JCTVC-R0042, Profile indication for additional layer sets
+#define R0235_SMALLEST_LAYER_ID          1      ///< JCTVC-R0235, SmallestLayerId semantics 
 
 #define Q0108_TSA_STSA                   1      ///< JCTVC-Q0108, Remove cross-layer alignment constraints of TSA and STSA pictures, enable to have different prediction structures in different layers
Index: branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1003)
+++ branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1006)
@@ -1525,5 +1525,9 @@
           for(Int kk = 0; kk < pcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++)
           {
+#if R0235_SMALLEST_LAYER_ID
+            if( pcSlice->getVPS()->getNecessaryLayerFlag(ii, kk) && pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk) )
+#else
             if(pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk))
+#endif
             {
               chkAssert=1;
@@ -3218,5 +3222,5 @@
 #endif
       {
-        READ_CODE( numBitsForPtlIdx, uiCode, "profile_level_tier_idx[i]" ); 
+        READ_CODE( numBitsForPtlIdx, uiCode, "profile_tier_level_idx[i]" ); 
         vps->setProfileLevelTierIdx(i, j, uiCode );
 
@@ -3228,4 +3232,9 @@
         //If OpTid of the output operation point is equal to vps_max_sub_layer_minus1, the conformance is indicated by general_profile_idc being equal to 7 or general_profile_compatibility_flag[ 7 ] being equal to 1
         //The following assert may be updated / upgraded to take care of general_profile_compatibility_flag.
+#if R0235_SMALLEST_LAYER_ID
+        // The assertion below is not valid for independent non-base layers 
+        if (vps->getNumAddLayerSets() == 0)
+        {
+#endif
         if (j > 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) != 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j - 1) != 0)
         {
@@ -3234,4 +3243,7 @@
                  vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc())  );
         }
+#if R0235_SMALLEST_LAYER_ID
+        }
+#endif
 #endif
       }
@@ -3243,5 +3255,5 @@
       numBits++;
     }
-    READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
+    READ_CODE( numBits, uiCode, "profile_tier_level_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
 #endif
 #if P0300_ALT_OUTPUT_LAYER_FLAG
Index: branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1003)
+++ branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1006)
@@ -91,4 +91,7 @@
 #if SVC_EXTENSION 
   m_layerId = 0;
+#if R0235_SMALLEST_LAYER_ID
+  m_smallestLayerId = 0;
+#endif
 #if AVC_BASE
   m_pBLReconFile = NULL;
@@ -838,5 +841,22 @@
 #if OUTPUT_LAYER_SET_INDEX
   // Following check should go wherever the VPS is activated
+#if R0235_SMALLEST_LAYER_ID
+  if (!m_apcSlicePilot->getVPS()->getBaseLayerAvailableFlag())
+  {
+    assert(nalu.m_layerId != 0);
+    assert(m_apcSlicePilot->getVPS()->getNumAddLayerSets() > 0);
+    if (getCommonDecoderParams()->getTargetOutputLayerSetIdx() >= 0)
+    {
+      UInt layerIdx = m_apcSlicePilot->getVPS()->getOutputLayerSetIdx(getCommonDecoderParams()->getTargetOutputLayerSetIdx());
+      assert(layerIdx > m_apcSlicePilot->getVPS()->getVpsNumLayerSetsMinus1());
+    }
+  }
+  if (m_apcSlicePilot->getVPS()->getNumAddLayerSets() == 0)
+  {
+    checkValueOfTargetOutputLayerSetIdx(m_apcSlicePilot->getVPS());
+  }
+#else
   checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS());
+#endif
 #endif
 #if RESOLUTION_BASED_DPB
@@ -969,5 +989,9 @@
 #if NO_OUTPUT_OF_PRIOR_PICS
 #if NO_CLRAS_OUTPUT_FLAG
+#if R0235_SMALLEST_LAYER_ID
+  if (m_layerId == m_smallestLayerId && m_apcSlicePilot->getRapPicFlag())
+#else
   if (m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() )
+#endif
   {
     if (m_bFirstSliceInSequence)
@@ -1001,5 +1025,9 @@
   }
 
+#if R0235_SMALLEST_LAYER_ID
+  m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag, m_smallestLayerId );
+#else
   m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag );
+#endif
 #endif
 
@@ -2470,4 +2498,7 @@
         cListPic->clear();
       }
+#endif
+#if R0235_SMALLEST_LAYER_ID
+      xDeriveSmallestLayerId(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
 #endif
       return false;
@@ -3116,5 +3147,9 @@
 Void TDecTop::xCheckLayerReset()
 {
+#if R0235_SMALLEST_LAYER_ID
+  if (m_apcSlicePilot->isIRAP() && m_layerId > m_smallestLayerId)
+#else
   if (m_apcSlicePilot->isIRAP() && m_layerId > 0)
+#endif
   {
     Bool layerResetFlag;
@@ -3200,4 +3235,41 @@
 #endif
 
+#if R0235_SMALLEST_LAYER_ID
+Void TDecTop::xDeriveSmallestLayerId(TComVPS* vps)
+{
+  UInt smallestLayerId;
+  UInt targetOlsIdx = getCommonDecoderParams()->getTargetOutputLayerSetIdx();
+  UInt targetDecLayerSetIdx = vps->getOutputLayerSetIdx(targetOlsIdx);
+  UInt lsIdx = targetDecLayerSetIdx;
+  UInt targetDecLayerIdList[MAX_LAYERS] = {0};
+
+  for (UInt i = 0, j = 0; i < vps->getNumLayersInIdList(lsIdx); i++)
+  {
+    if (vps->getNecessaryLayerFlag(targetOlsIdx, i))
+    {
+      targetDecLayerIdList[j++] = vps->getLayerSetLayerIdList(lsIdx, i);
+    }
+  }
+
+  if (targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1())
+  {
+    smallestLayerId = 0;
+  }
+  else if (vps->getNumLayersInIdList(targetDecLayerSetIdx) == 1)
+  {
+    smallestLayerId = 0;
+  }
+  else
+  {
+    smallestLayerId = targetDecLayerIdList[0];
+  }
+
+  for (UInt layer = 0; layer <= MAX_VPS_LAYER_ID_PLUS1 - 1; layer++)
+  {
+    m_ppcTDecTop[layer]->m_smallestLayerId = smallestLayerId;
+  }
+}
+#endif
+
 #endif //SVC_EXTENSION
 
Index: branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h	(revision 1003)
+++ branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h	(revision 1006)
@@ -133,4 +133,7 @@
   UInt                    m_numLayer;
   TDecTop**               m_ppcTDecTop;
+#if R0235_SMALLEST_LAYER_ID
+  UInt                    m_smallestLayerId;
+#endif
 #if P0297_VPS_POC_LSB_ALIGNED_FLAG
   Bool                    m_pocResettingFlag;
@@ -256,4 +259,7 @@
   Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
   TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
+#if R0235_SMALLEST_LAYER_ID
+  Void      xDeriveSmallestLayerId(TComVPS* vps);
+#endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
   TDecTop*  getRefLayerDec(UInt refLayerIdc);
