Index: trunk/source/App/TAppDownConvert/TAppDownConvert.cpp
===================================================================
--- trunk/source/App/TAppDownConvert/TAppDownConvert.cpp	(revision 345)
+++ trunk/source/App/TAppDownConvert/TAppDownConvert.cpp	(revision 345)
@@ -0,0 +1,472 @@
+/* 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-2013, 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.
+ */
+
+/** \file     TAppDownConvert.cpp
+    \brief    Down convert application main
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+//! \ingroup TAppDecoder
+//! \{
+
+#define pi 3.1415926
+
+int get_mem2DPelWithPad(unsigned char ***array2D, int dim0, int dim1, int iPadY, int iPadX)
+{
+  int i;
+  unsigned char *curr = NULL;
+  int iHeight, iWidth;
+
+  iHeight = dim0+2*iPadY;
+  iWidth = dim1+2*iPadX;
+  (*array2D) = (unsigned char**)malloc(iHeight*sizeof(unsigned char*));
+  *(*array2D) = (unsigned char* )calloc(iHeight * iWidth, sizeof(unsigned char ));
+
+  (*array2D)[0] += iPadX;
+  curr = (*array2D)[0];
+  for(i = 1 ; i < iHeight; i++)
+  {
+    curr += iWidth;
+    (*array2D)[i] = curr;
+  }
+  (*array2D) = &((*array2D)[iPadY]);
+
+  return 0;
+}
+
+int get_mem2DintWithPad(int ***array2D, int dim0, int dim1, int iPadY, int iPadX)
+{
+  int i;
+  int *curr = NULL;
+  int iHeight, iWidth;
+
+  iHeight = dim0+2*iPadY;
+  iWidth = dim1+2*iPadX;
+  (*array2D) = (int**)malloc(iHeight*sizeof(int*));
+  *(*array2D) = (int* )calloc(iHeight * iWidth, sizeof(int ));
+
+  (*array2D)[0] += iPadX;
+  curr = (*array2D)[0];
+  for(i = 1 ; i < iHeight; i++)
+  {
+    curr += iWidth;
+    (*array2D)[i] = curr;
+  }
+  (*array2D) = &((*array2D)[iPadY]);
+
+  return 0;
+}
+
+void free_mem2DPelWithPad(unsigned char **array2D, int iPadY, int iPadX)
+{
+  if (array2D)
+  {
+    if (*array2D)
+    {
+      free (array2D[-iPadY]-iPadX);
+    }
+    else 
+    {
+      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
+    }
+
+    free (&array2D[-iPadY]);
+  } 
+  else
+  {
+    printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
+  }
+}
+
+void free_mem2DintWithPad(int **array2D, int iPadY, int iPadX)
+{
+  if (array2D)
+  {
+    if (*array2D)
+    {
+      free (array2D[-iPadY]-iPadX);
+    }
+    else 
+    {
+      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
+    }
+
+    free (&array2D[-iPadY]);
+  } 
+  else
+  {
+    printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
+  }
+}
+
+void PadImgHorizontal(unsigned char **src, unsigned char **dst, int height, int width, int pad_h)
+{
+  int i, j;
+  unsigned char *BufSrc, *BufDst;
+
+  for (j=0;j<height;j++)
+  {    
+    BufDst = &(dst[j][-pad_h] );
+    BufSrc = src[j];
+    for (i=0;i<pad_h;i++)
+    {
+      *(BufDst++) = BufSrc[0];
+    }
+    memcpy(BufDst, BufSrc, width*sizeof(unsigned char));
+    BufDst += width;
+    for (i=0;i<pad_h;i++)
+    {
+      *(BufDst++) = BufSrc[width-1];
+    }
+  }
+}
+
+void FilterImg( unsigned char **src,
+                int           **temp,
+                unsigned char **dst,
+                int           height1,  
+                int           width1,  
+                int           M, 
+                int           N, 
+                int           **phase_filter,
+                int           length,
+                int           shift,
+                int           plane)
+{
+  int height2,width2;
+  int k,iSum;
+  int i0, div_i0, i1;
+  int j0, div_j0, j1;
+  int *p_filter;
+  unsigned char *p_src, *p_dst;
+  int **p_temp, *p_tmp;
+  int shift2 = (2*shift);
+  int shift_round = (1 << (2 * shift - 1));
+
+  height2 = (height1 * M) / N;
+  width2  = (width1  * M) / N;
+
+  // horizontal filtering
+  for(j1 = 0; j1 < height1; j1++)
+  {
+    i0=-N;
+    p_tmp = temp[j1];
+    for(i1 = 0; i1 < width2; i1++)
+    {
+      i0      += N;
+      div_i0   = (i0 / M);
+      p_src    = &src[j1][ div_i0 - (length >> 1)];
+      p_filter = phase_filter[i0 - div_i0 * M];
+      iSum     = 0;
+      for(k = 0; k < length; k++)
+      {
+        iSum += (*p_src++) * (*p_filter++);
+      }
+      *p_tmp++ = iSum;
+    }
+  }
+
+  // pad temp (vertical)
+  for (k=-(length>>1);k<0;k++)
+    memcpy(temp[k], temp[0], width2*sizeof(int));
+  for (k=height1;k<(height1+(length>>1));k++)
+    memcpy(temp[k], temp[k-1], (width2)* sizeof(int));
+
+  // vertical filtering
+  j0 = (plane == 0) ? -N : -(N-1);
+  
+  for(j1 = 0; j1 < height2; j1++)
+  {
+    j0      += N;
+    div_j0   = (j0 / M);
+    p_dst    = dst[j1];
+    p_temp   = &temp[div_j0 - (length>>1)];
+    p_filter = phase_filter[j0 - div_j0 * M];
+    for(i1 = 0; i1 < width2;i1++)
+    {
+      iSum=0;
+      for(k = 0; k < length; k++)
+      {
+        iSum += p_temp[k][i1] * p_filter[k];
+      }
+      iSum=((iSum + shift_round) >> shift2);
+      *p_dst++ = (unsigned char)(iSum > 255 ? 255 : iSum < 0 ? 0 : iSum);
+    }
+  }
+}
+
+// ====================================================================================================================
+// Main function
+// ====================================================================================================================
+
+int main(int argc, char *argv[])
+{
+  const int phase_filter_0[4][13]={
+    {0,  2,  -3,  -9,   6,  39,  58,  39,   6,  -9,  -3,  2,  0},  
+    {0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  
+    {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1},  
+    {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1}  
+  };
+
+  const int phase_filter_1[8][13]={
+    {0,   0,  5,  -6,  -10,  37,  76,  37,-10,   -6, 5,  0,   0},    
+    {0,  -1,  5,  -3,  -12,  29,  75,  45,  -7,   -8, 5,  0,   0},    
+    {0,  -1,  4,  -1,  -13,  22,  73,  52,  -3,  -10, 4,  1,   0},    
+    {0,  -1,  4,   1,  -13,  14,  70,  59,   2,  -12, 3,  2,  -1},  
+    {0,  -1,  3,   2,  -13,   8,  65,  65,   8,  -13, 2,  3,  -1},    
+    {0,  -1,  2,   3,  -12,   2,  59,  70,  14,  -13, 1,  4,  -1},    
+    {0,   0,  1,   4,  -10,  -3,  52,  73,  22,  -13,-1,  4,  -1},    
+    {0,   0,  0,   5,   -8,  -7,  45,  75,  29,  -12,-3,  5,  -1}    
+  };
+
+  int i,j;
+
+  int width_org,  width_org_c,  width_sampled,  width_sampled_c;
+  int height_org, height_org_c, height_sampled, height_sampled_c;
+  int size_org,   size_org_c,   size_sampled,   size_sampled_c;
+
+  unsigned char **Y1,    **U1,    **V1;
+  unsigned char **Y2,    **U2,    **V2;
+  unsigned char **temp_luma,    **temp_chroma;
+  int           **tempY, **tempU, **tempV;
+
+  int **phase_filter;
+  int log2_scaling_factor=7;
+
+  FILE * infile;
+  FILE * outfile;
+
+  int M,N;
+  int ratio;
+  int Frames=0;
+  int totalFrames=0;
+  int StartFrame=0;
+  int Tap=13;
+
+  if (argc < 6)
+  {
+    printf("\nIncorrect number of arguments!!!\n\n");
+    printf("Syntax: \n");
+    printf("%s <input width> <input height> <input file> <output file> <downsampling method> [frames_to_process] [start_frame]\n\n", argv[0]);
+    printf("<downsampling method> 0: 2x downsampling, 1: 1.5x downsampling. \n");
+    printf("Examples: \n");
+    printf("%s 1920 1080 input_1920x1080_24p.yuv output_960x540_24p.yuv 0 \n", argv[0]);
+    printf("%s 1920 1080 input_1920x1080_24p.yuv output_1280x720_24p.yuv 1 \n", argv[0]);
+    return -1;
+  }
+
+  width_org  = atoi  (argv[1]);
+  height_org = atoi  (argv[2]);
+  infile     = fopen (argv[3], "rb");
+  outfile    = fopen (argv[4], "wb");
+  ratio      = atoi  (argv[5]); 
+
+  for(i=7; i<= argc; i++)
+  {
+    switch(i)
+    {
+    case 7:
+      Frames = atoi(argv[6]);
+      break;
+    case 8:
+      StartFrame = atoi(argv[7]);
+      break;
+    default:
+      printf("Too many input arguments");
+      break;
+    }
+  }
+
+  if( width_org < 4 || height_org < 4 )
+  {
+    printf("\ninput resolution is too small, exit\n");
+    return -1;
+  }
+  if ( infile == NULL || outfile == NULL )
+  {
+    printf("\ninput or output file is invalid, exit\n");
+    return -1;
+  }
+  if ((argc > 6) && (Frames < 1 || StartFrame < 0))
+  {
+    printf("input frame parameter error\n");
+    return -1;
+  }
+  if ( ratio > 1 || ratio < 0)
+  {
+    printf("\ndown sampling parameter %d is not supported (0: 2x downsampling, 1: 1.5x downsampling)\n", ratio);
+    return -1;
+  }
+
+  if (ratio==0)
+  {
+    M=4;
+    N=8;
+  }
+  else if (ratio==1)
+  {
+    M=8;
+    N=12;
+  }
+
+  width_org_c      = width_org  >> 1;
+  height_org_c     = height_org >> 1;
+  width_sampled    = (width_org  * M) / N;
+  height_sampled   = (height_org * M) / N;
+  width_sampled_c  = width_sampled  >> 1;
+  height_sampled_c = height_sampled >> 1;
+  size_org         = height_org * width_org;
+  size_org_c       = height_org_c * width_org_c;
+  size_sampled     = height_sampled * width_sampled;
+  size_sampled_c   = height_sampled_c * width_sampled_c;
+
+  printf("\n=============================================================\n");
+  printf("\n Input  = %s", argv[3]);
+  printf("\n Output = %s", argv[4]);
+  printf("\n Rescaling input from (%d,%d) to (%d,%d) resolution\n", width_org, height_org, width_sampled, height_sampled);
+  printf("\n=============================================================\n\n");  
+
+  // construct phase filters
+  get_mem2DintWithPad (&phase_filter, M, Tap, 0, 0);
+
+  for (j=0;j<M;j++)
+    for (i=0;i<Tap;i++)
+      phase_filter[j][i]= ratio==0 ? phase_filter_0[j][i] :  phase_filter_1[j][i];
+
+  get_mem2DPelWithPad (&Y1, height_org,   width_org,   0, Tap>>1);
+  get_mem2DPelWithPad (&U1, height_org_c, width_org_c, 0, Tap>>1);
+  get_mem2DPelWithPad (&V1, height_org_c, width_org_c, 0, Tap>>1);
+
+  get_mem2DintWithPad (&tempY, height_org,   width_sampled,   Tap>>1, 0);
+  get_mem2DintWithPad (&tempU, height_org_c, width_sampled_c, Tap>>1, 0);
+  get_mem2DintWithPad (&tempV, height_org_c, width_sampled_c, Tap>>1, 0);
+
+  get_mem2DPelWithPad (&Y2, height_sampled,   width_sampled,  0,0);
+  get_mem2DPelWithPad (&U2, height_sampled_c, width_sampled_c,0,0);
+  get_mem2DPelWithPad (&V2, height_sampled_c, width_sampled_c,0,0);
+
+  get_mem2DPelWithPad (&temp_luma,   height_org,   width_org,  0,0);
+  get_mem2DPelWithPad (&temp_chroma, height_org_c, width_org_c,0,0);
+
+  if(StartFrame!=0)
+  {
+    for (i = 0; i < StartFrame; i ++)
+    {
+      fread(temp_luma[0], sizeof(unsigned char), size_org,     infile);
+      fread(temp_chroma[0], sizeof(unsigned char), size_org_c, infile);
+      fread(temp_chroma[0], sizeof(unsigned char), size_org_c, infile);
+      if (feof(infile))
+      {
+        printf("\nThe start frame number exceeds the file size\n");
+        return -1;
+      }
+    }
+    //fseek64(infile, (size_org * StartFrame * 3) >> 1,SEEK_SET);
+  }
+
+  if (Frames)
+  {
+    totalFrames = Frames;
+  }
+  else
+  {
+    totalFrames = 0x7FFF;
+  }
+
+  i = 0;
+  while(totalFrames)
+  {
+    
+    // read and pad Y
+    fread(temp_luma[0], sizeof(unsigned char), size_org,     infile);
+    PadImgHorizontal(temp_luma, Y1, height_org, width_org, Tap>>1);
+
+    // read and pad U
+    fread(temp_chroma[0], sizeof(unsigned char), size_org_c, infile);
+    PadImgHorizontal(temp_chroma, U1, height_org_c, width_org_c, Tap>>1);
+
+    // read and pad V
+    fread(temp_chroma[0], sizeof(unsigned char), size_org_c, infile);
+    PadImgHorizontal(temp_chroma, V1, height_org_c, width_org_c, Tap>>1);
+
+    if (feof(infile))
+    {
+      break;
+    }
+
+    fprintf(stdout,"Rescaling %dth frame\r", i);
+    fflush(stdout);
+
+    i ++;
+    totalFrames --;
+
+    FilterImg(Y1,tempY,Y2,height_org,  width_org,  M, N, phase_filter,Tap,log2_scaling_factor,0);
+    FilterImg(U1,tempU,U2,height_org_c,width_org_c,M, N, phase_filter,Tap,log2_scaling_factor,1);
+    FilterImg(V1,tempV,V2,height_org_c,width_org_c,M, N, phase_filter,Tap,log2_scaling_factor,2);
+
+    // write a sampled frame
+    fwrite(Y2[0], sizeof(unsigned char), size_sampled,     outfile);
+    fwrite(U2[0], sizeof(unsigned char), size_sampled_c, outfile);
+    fwrite(V2[0], sizeof(unsigned char), size_sampled_c, outfile);
+
+  }
+
+  printf("\nEnd of rescaling process.\n");
+
+  free_mem2DintWithPad (phase_filter, 0, 0);
+
+  free_mem2DPelWithPad (Y1, 0, Tap>>1);
+  free_mem2DPelWithPad (U1, 0, Tap>>1);
+  free_mem2DPelWithPad (V1, 0, Tap>>1);
+
+  free_mem2DintWithPad (tempY, Tap>>1, 0);
+  free_mem2DintWithPad (tempU, Tap>>1, 0);
+  free_mem2DintWithPad (tempV, Tap>>1, 0);
+
+  free_mem2DPelWithPad (Y2,0,0);
+  free_mem2DPelWithPad (U2,0,0);
+  free_mem2DPelWithPad (V2,0,0);
+
+  free_mem2DPelWithPad (temp_luma,  0,0);
+  free_mem2DPelWithPad (temp_chroma,0,0);
+
+  fclose(infile);
+  fclose(outfile);
+
+  return 0;
+}
+
+//! \}
Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 314)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 345)
@@ -817,4 +817,11 @@
     opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry());
   }
+#if FINAL_RPL_CHANGE_N0082
+  for(Int i=1; i<MAX_GOP+1; i++) {
+    std::ostringstream cOSS;
+    cOSS<<"FrameEL"<<i;
+    opts.addOptions()(cOSS.str(), m_acLayerCfg[1].m_GOPListLayer[i-1], GOPEntry());
+  }
+#endif
   po::setDefaults(opts);
   const list<const Char*>& argv_unhandled = po::scanArgv(opts, argc, (const Char**) argv);
@@ -1460,8 +1467,12 @@
 #endif
   
+#if !FINAL_RPL_CHANGE_N0082
   Bool verifiedGOP=false;
+#endif
   Bool errorGOP=false;
+#if !FINAL_RPL_CHANGE_N0082
   Int checkGOP=1;
   Int numRefs = 1;
+#endif
   Int refList[MAX_NUM_REF_PICS+1];
   refList[0]=0;
@@ -1471,5 +1482,7 @@
     isOK[i]=false;
   }
+#if !FINAL_RPL_CHANGE_N0082
   Int numOK=0;
+#endif
 #if !SVC_EXTENSION
   xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
@@ -1514,5 +1527,23 @@
   }
 #endif
-
+#if FINAL_RPL_CHANGE_N0082
+  for(UInt layer=0; layer<m_numLayers; layer++)
+  {
+    if (m_acLayerCfg[layer].m_GOPListLayer[0].m_POC<0){
+      memcpy( m_acLayerCfg[layer].m_GOPListLayer, m_GOPList, sizeof(GOPEntry)*MAX_GOP );
+    }
+    errorGOP = xconfirmExtraGOP( m_acLayerCfg[layer].m_GOPListLayer );
+    xConfirmPara(errorGOP,"Invalid GOP structure given");
+  }
+  //tentative for encoder
+  if( m_acLayerCfg[1].m_GOPListLayer[5].m_POC == 6  && m_acLayerCfg[1].m_GOPListLayer[7].m_POC == 7 ){
+    //RA, POC5
+    m_acLayerCfg[1].m_GOPListLayer[5].m_usedByCurrPic[2] = 0;
+    m_acLayerCfg[1].m_GOPListLayer[5].m_refIdc[2] = 0;
+    //RA, POC7
+    m_acLayerCfg[1].m_GOPListLayer[7].m_usedByCurrPic[2] = 0;
+    m_acLayerCfg[1].m_GOPListLayer[7].m_refIdc[2] = 0;
+  }
+#else
   m_extraRPSs=0;
   //start looping through frames in coding order until we can verify that the GOP structure is correct.
@@ -1710,4 +1741,5 @@
   }
   xConfirmPara(errorGOP,"Invalid GOP structure given");
+#endif
   m_maxTempLayer = 1;
   for(Int i=0; i<m_iGOPSize; i++) 
@@ -1730,8 +1762,4 @@
       m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics + 1;
     }
-
-#if SVC_EXTENSION
-    m_maxDecPicBuffering[m_GOPList[i].m_temporalId] += 1; // it should be updated if more than 1 resampling picture is used
-#endif
 
     Int highestDecodingNumberWithLowerPOC = 0; 
@@ -2187,10 +2215,4 @@
   printf("ENCODER_FAST_MODE: %d ", ENCODER_FAST_MODE);
   printf("REF_IDX_MFM: %d ", REF_IDX_MFM);
-#elif INTRA_BL
-  printf("INTRA_BL:%d ", INTRA_BL);
-#if !AVC_BASE
-  printf("SVC_MVP:%d ", SVC_MVP );
-  printf("SVC_BL_CAND_INTRA:%d", SVC_BL_CAND_INTRA );
-#endif
 #endif
 #else
@@ -2245,3 +2267,218 @@
 }
 #endif
+
+#if FINAL_RPL_CHANGE_N0082
+Bool  TAppEncCfg::xconfirmExtraGOP (GOPEntry * ge)
+{
+  Bool verifiedGOP=false;
+  Bool errorGOP=false;
+  Int checkGOP=1;
+  Int numRefs = 1;
+  Int refList[MAX_NUM_REF_PICS+1];
+  refList[0]=0;
+  Bool isOK[MAX_GOP];
+  for(Int i=0; i<MAX_GOP; i++) 
+  {
+    isOK[i]=false;
+  }
+  Int numOK=0;
+
+  m_extraRPSs=0;
+  //start looping through frames in coding order until we can verify that the GOP structure is correct.
+  while(!verifiedGOP&&!errorGOP) 
+  {
+    Int curGOP = (checkGOP-1)%m_iGOPSize;
+    Int curPOC = ((checkGOP-1)/m_iGOPSize)*m_iGOPSize + ge[curGOP].m_POC;    
+    if(ge[curGOP].m_POC<0) 
+    {
+      printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
+      errorGOP=true;
+    }
+    else 
+    {
+      //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
+      Bool beforeI = false;
+      for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) 
+      {
+        Int absPOC = curPOC+ge[curGOP].m_referencePics[i];
+        if(absPOC < 0)
+        {
+          beforeI=true;
+        }
+        else 
+        {
+          Bool found=false;
+          for(Int j=0; j<numRefs; j++) 
+          {
+            if(refList[j]==absPOC) 
+            {
+              found=true;
+              for(Int k=0; k<m_iGOPSize; k++)
+              {
+                if(absPOC%m_iGOPSize == ge[k].m_POC%m_iGOPSize)
+                {
+                  if(ge[k].m_temporalId==ge[curGOP].m_temporalId)
+                  {
+                    ge[k].m_refPic = true;
+                  }
+                  ge[curGOP].m_usedByCurrPic[i]=ge[k].m_temporalId<=ge[curGOP].m_temporalId;
+                }
+              }
+            }
+          }
+          if(!found)
+          {
+            printf("\nError: ref pic %d is not available for GOP frame %d\n",ge[curGOP].m_referencePics[i],curGOP+1);
+            errorGOP=true;
+          }
+        }
+      }
+      if(!beforeI&&!errorGOP)
+      {
+        //all ref frames were present
+        if(!isOK[curGOP]) 
+        {
+          numOK++;
+          isOK[curGOP]=true;
+          if(numOK==m_iGOPSize)
+          {
+            verifiedGOP=true;
+          }
+        }
+      }
+      else 
+      {
+        //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
+        ge[m_iGOPSize+m_extraRPSs]=ge[curGOP];
+        Int newRefs=0;
+        for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) 
+        {
+          Int absPOC = curPOC+ge[curGOP].m_referencePics[i];
+          if(absPOC>=0)
+          {
+            ge[m_iGOPSize+m_extraRPSs].m_referencePics[newRefs]=ge[curGOP].m_referencePics[i];
+            ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[newRefs]=ge[curGOP].m_usedByCurrPic[i];
+            newRefs++;
+          }
+        }
+        Int numPrefRefs = ge[curGOP].m_numRefPicsActive;
+        
+        for(Int offset = -1; offset>-checkGOP; offset--)
+        {
+          //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
+          Int offGOP = (checkGOP-1+offset)%m_iGOPSize;
+          Int offPOC = ((checkGOP-1+offset)/m_iGOPSize)*m_iGOPSize + ge[offGOP].m_POC;
+          if(offPOC>=0&&ge[offGOP].m_temporalId<=ge[curGOP].m_temporalId)
+          {
+            Bool newRef=false;
+            for(Int i=0; i<numRefs; i++)
+            {
+              if(refList[i]==offPOC)
+              {
+                newRef=true;
+              }
+            }
+            for(Int i=0; i<newRefs; i++) 
+            {
+              if(ge[m_iGOPSize+m_extraRPSs].m_referencePics[i]==offPOC-curPOC)
+              {
+                newRef=false;
+              }
+            }
+            if(newRef) 
+            {
+              Int insertPoint=newRefs;
+              //this picture can be added, find appropriate place in list and insert it.
+              if(ge[offGOP].m_temporalId==ge[curGOP].m_temporalId)
+              {
+                ge[offGOP].m_refPic = true;
+              }
+              for(Int j=0; j<newRefs; j++)
+              {
+                if(ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]<offPOC-curPOC||ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]>0)
+                {
+                  insertPoint = j;
+                  break;
+                }
+              }
+              Int prev = offPOC-curPOC;
+              Int prevUsed = ge[offGOP].m_temporalId<=ge[curGOP].m_temporalId;
+              for(Int j=insertPoint; j<newRefs+1; j++)
+              {
+                Int newPrev = ge[m_iGOPSize+m_extraRPSs].m_referencePics[j];
+                Int newUsed = ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j];
+                ge[m_iGOPSize+m_extraRPSs].m_referencePics[j]=prev;
+                ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j]=prevUsed;
+                prevUsed=newUsed;
+                prev=newPrev;
+              }
+              newRefs++;
+            }
+          }
+          if(newRefs>=numPrefRefs)
+          {
+            break;
+          }
+        }
+        ge[m_iGOPSize+m_extraRPSs].m_numRefPics=newRefs;
+        ge[m_iGOPSize+m_extraRPSs].m_POC = curPOC;
+        if (m_extraRPSs == 0)
+        {
+          ge[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 0;
+          ge[m_iGOPSize+m_extraRPSs].m_numRefIdc = 0;
+        }
+        else
+        {
+          Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
+          Int refPOC = ge[rIdx].m_POC;
+          Int refPics = ge[rIdx].m_numRefPics;
+          Int newIdc=0;
+          for(Int i = 0; i<= refPics; i++) 
+          {
+            Int deltaPOC = ((i != refPics)? ge[rIdx].m_referencePics[i] : 0);  // check if the reference abs POC is >= 0
+            Int absPOCref = refPOC+deltaPOC;
+            Int refIdc = 0;
+            for (Int j = 0; j < ge[m_iGOPSize+m_extraRPSs].m_numRefPics; j++)
+            {
+              if ( (absPOCref - curPOC) == ge[m_iGOPSize+m_extraRPSs].m_referencePics[j])
+              {
+                if (ge[m_iGOPSize+m_extraRPSs].m_usedByCurrPic[j])
+                {
+                  refIdc = 1;
+                }
+                else
+                {
+                  refIdc = 2;
+                }
+              }
+            }
+            ge[m_iGOPSize+m_extraRPSs].m_refIdc[newIdc]=refIdc;
+            newIdc++;
+          }
+          ge[m_iGOPSize+m_extraRPSs].m_interRPSPrediction = 1;  
+          ge[m_iGOPSize+m_extraRPSs].m_numRefIdc = newIdc;
+          ge[m_iGOPSize+m_extraRPSs].m_deltaRPS = refPOC - ge[m_iGOPSize+m_extraRPSs].m_POC; 
+        }
+        curGOP=m_iGOPSize+m_extraRPSs;
+        m_extraRPSs++;
+      }
+      numRefs=0;
+      for(Int i = 0; i< ge[curGOP].m_numRefPics; i++) 
+      {
+        Int absPOC = curPOC+ge[curGOP].m_referencePics[i];
+        if(absPOC >= 0) 
+        {
+          refList[numRefs]=absPOC;
+          numRefs++;
+        }
+      }
+      refList[numRefs]=curPOC;
+      numRefs++;
+    }
+    checkGOP++;
+  }
+
+  return errorGOP; //update
+}
+#endif
 //! \}
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 314)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 345)
@@ -348,4 +348,7 @@
   Void  xPrintParameter ();                                   ///< print configuration values
   Void  xPrintUsage     ();                                   ///< print usage
+#if FINAL_RPL_CHANGE_N0082
+  Bool  xconfirmExtraGOP (GOPEntry * ge);
+#endif
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Int       m_adaptiveResolutionChange;                       ///< Indicate adaptive resolution change frame
Index: trunk/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 314)
+++ trunk/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 345)
@@ -81,4 +81,7 @@
   Int       m_scaledRefLayerBottomOffset[MAX_LAYERS];
 #endif  
+#if FINAL_RPL_CHANGE_N0082
+  GOPEntry  m_GOPListLayer[MAX_GOP];                            ///< for layer
+#endif
 public:
   TAppEncLayerCfg();
@@ -141,4 +144,7 @@
   Bool    getRCForceIntraQP()         {return m_RCForceIntraQP;        }
 #endif
+#if FINAL_RPL_CHANGE_N0082
+  GOPEntry getGOPEntry(Int i )        {return m_GOPListLayer[i];  }
+#endif
 }; // END CLASS DEFINITION TAppEncLayerCfg
 
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 314)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 345)
@@ -136,5 +136,9 @@
     m_acTEncTop[layer].setDecodingRefreshType          ( m_iDecodingRefreshType );
     m_acTEncTop[layer].setGOPSize                      ( m_iGOPSize );
+#if FINAL_RPL_CHANGE_N0082
+    m_acTEncTop[layer].setGopList                      ( m_acLayerCfg[layer].m_GOPListLayer );
+#else
     m_acTEncTop[layer].setGopList                      ( m_GOPList );
+#endif
     m_acTEncTop[layer].setExtraRPSs                    ( m_extraRPSs );
     for(Int i = 0; i < MAX_TLAYER; i++)
@@ -884,4 +888,24 @@
   }
 #endif
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  vps->setMaxTidIlRefPicsPlus1PresentFlag(true);
+  if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
+  {
+    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
+    {
+      vps->setMaxSublayerForIlpPlus1(i, vps->getMaxTLayers()+1);
+    }
+  }
+  else
+  {
+    for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
+    {
+      vps->setMaxSublayerForIlpPlus1(i, 7);
+    }
+  }
+#endif 
+#if ILP_SSH_SIG
+    vps->setIlpSshSignalingEnabledFlag(true);
+#endif
 #if VPS_EXTN_PROFILE_INFO
   vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
Index: trunk/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/CommonDef.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/CommonDef.h	(revision 345)
@@ -57,5 +57,5 @@
 
 #if SVC_EXTENSION
-#define NV_VERSION        "trunk"                 ///< Current software version
+#define NV_VERSION        "3.0"                 ///< Current software version
 #else
 #define NV_VERSION        "11.0"                ///< Current software version
Index: trunk/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- trunk/source/Lib/TLibCommon/ContextTables.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/ContextTables.h	(revision 345)
@@ -92,7 +92,4 @@
 #define NUM_SAO_MERGE_FLAG_CTX        1       ///< number of context models for SAO merge flags
 #define NUM_SAO_TYPE_IDX_CTX          1       ///< number of context models for SAO type index
-#if INTRA_BL
-#define NUM_INTRA_BL_PRED_CTX         3
-#endif
 
 #define NUM_TRANSFORMSKIP_FLAG_CTX    1       ///< number of context models for transform skipping 
@@ -330,13 +327,4 @@
 };
 
-#if INTRA_BL
-static const UChar 
-INIT_INTRA_BL_PRED_FLAG[3][NUM_INTRA_BL_PRED_CTX] = 
-{
-  { 185,  185,  201, }, 
-  { 197,  197,  185, }, 
-  { 197,  197,  185, }, 
-};
-#endif
 static const UChar
 INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = 
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 345)
@@ -1643,48 +1643,10 @@
   pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
   
-#if INTRA_BL
-  iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#else
   iLeftIntraDir  = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#endif
   
   // Get intra direction of above PU
   pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, true );
   
-#if INTRA_BL
-  iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) && ( !pcTempCU->isIntraBL( uiTempPartIdx ) ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#else
   iAboveIntraDir = pcTempCU ? ( pcTempCU->isIntra( uiTempPartIdx ) ? pcTempCU->getLumaIntraDir( uiTempPartIdx ) : DC_IDX ) : DC_IDX;
-#endif 
-  
-#if SVC_BL_CAND_INTRA
-  if(m_layerId > 0)
-  {
-    UInt uiCUAddrBase, uiAbsPartAddrBase;
-    pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
-
-    if(pcTempCU->getPredictionMode( uiAbsPartAddrBase ) == MODE_INTRA )
-    {
-      Int iColBaseDir = pcTempCU->getLumaIntraDir( uiAbsPartAddrBase );
-      if( iColBaseDir != iAboveIntraDir && iColBaseDir != iLeftIntraDir && iAboveIntraDir != iLeftIntraDir)
-      {
-        uiIntraDirPred[0] = iColBaseDir;
-        uiIntraDirPred[1] = iLeftIntraDir;
-        uiIntraDirPred[2] = iAboveIntraDir;
-        if( piMode )
-        {
-          *piMode = 2;
-        }
-        uiPredNum = 3;
-        return uiPredNum;
-      }
-      else 
-      {
-        iAboveIntraDir = (iColBaseDir == iLeftIntraDir) ? iAboveIntraDir : iLeftIntraDir;
-        iLeftIntraDir  = iColBaseDir;
-      }
-    }
-  }
-#endif
   
   uiPredNum = 3;
@@ -1828,9 +1790,5 @@
   UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2;
   PartSize  partSize  = getPartitionSize( absPartIdx );
-#if INTRA_BL
-  UInt quadtreeTUMaxDepth = isIntra( absPartIdx ) ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); 
-#else
   UInt quadtreeTUMaxDepth = getPredictionMode( absPartIdx ) == MODE_INTRA ? m_pcSlice->getSPS()->getQuadtreeTUMaxDepthIntra() : m_pcSlice->getSPS()->getQuadtreeTUMaxDepthInter(); 
-#endif
   Int intraSplitFlag = ( getPredictionMode( absPartIdx ) == MODE_INTRA && partSize == SIZE_NxN ) ? 1 : 0;
   Int interSplitFlag = ((quadtreeTUMaxDepth == 1) && (getPredictionMode( absPartIdx ) == MODE_INTER) && (partSize != SIZE_2Nx2N) );
@@ -1854,39 +1812,4 @@
   return log2MinTUSizeInCU;
 }
-
-#if INTRA_BL
-UInt TComDataCU::getCtxIntraBLFlag( UInt uiAbsPartIdx )
-{
-#if INTRA_BL_CTX_CHANGE
-  Int cuDepth = getDepth(uiAbsPartIdx);
-  Int maxCuDepth = g_uiMaxCUDepth - g_uiAddCUDepth;
-  UInt uiCtx = (maxCuDepth==3 && cuDepth > 0) ? (cuDepth - 1) : cuDepth;
-  return uiCtx;
-#else
-  TComDataCU* pcTempCU;
-  UInt        uiTempPartIdx;
-  UInt        uiCtx = 0;
-  
-  // Get BCBP of left PU
-#if DEPENDENT_SLICES
-  Bool bDepSliceRestriction = ( !m_pcSlice->getPPS()->getDependentSliceEnabledFlag());
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction );
-#else
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
-#endif  
-  uiCtx    = ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0;
-  
-  // Get BCBP of above PU
-#if DEPENDENT_SLICES
-  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, bDepSliceRestriction );
-#else
-  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
-#endif  
-  uiCtx   += ( pcTempCU ) ? pcTempCU->isIntraBL( uiTempPartIdx ) : 0;
-  
-  return uiCtx;
-#endif
-}
-#endif
 
 #if REF_IDX_ME_ZEROMV
@@ -2586,58 +2509,4 @@
   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
-#if SVC_MVP
-  // BL collocated
-  TComDataCU *pcColCU = NULL;
-  UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
-#if AVC_BASE
-  if( !this->getSlice()->getVPS()->getAvcBaseLayerFlag() || AVC_SYNTAX )
-#endif
-  {
-    TComMvField cMvFieldBaseColCU[2];
-    if(m_layerId)  
-    {
-      pcColCU = getBaseColCU( m_layerId - 1, xP + nPSW/2, yP + nPSH/2, uiCUAddrBase, uiAbsPartAddrBase );
-
-#if INTRA_BL
-      if( pcColCU && pcColCU->isIntraBL( uiAbsPartAddrBase ) )
-      {
-        pcColCU = NULL;
-      }
-#endif
-
-      if(pcColCU && !pcColCU->isIntra( uiAbsPartAddrBase ) )
-      {
-        abCandIsInter[iCount] = true;
-
-        // get interDir
-        puhInterDirNeighbours[iCount] = pcColCU->getInterDir( uiAbsPartAddrBase );
-
-        pcMvFieldNeighbours[(iCount << 1)].setMvField( TComMv(0,0), -1);
-        pcMvFieldNeighbours[(iCount << 1) + 1].setMvField( TComMv(0,0), -1);
-
-        if( puhInterDirNeighbours[iCount] & 1 )
-        {
-          pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_0, cMvFieldBaseColCU[0]);
-          scaleBaseMV( m_layerId - 1, pcMvFieldNeighbours[iCount<<1], cMvFieldBaseColCU[0] );
-        }
-
-        if ( getSlice()->isInterB() && puhInterDirNeighbours[iCount] & 2 )
-        {
-          pcColCU->getMvField( pcColCU, uiAbsPartAddrBase, REF_PIC_LIST_1, cMvFieldBaseColCU[1] );
-          scaleBaseMV( m_layerId - 1, pcMvFieldNeighbours[(iCount<<1)+1], cMvFieldBaseColCU[1] );
-        }
-
-        if( puhInterDirNeighbours[iCount] > 0 )
-        {
-          if ( mrgCandIdx == iCount )
-          {
-            return;
-          }
-          iCount ++;
-        }
-      }
-    }
-  }
-#endif
 
   //left
@@ -2645,15 +2514,7 @@
   TComDataCU* pcCULeft = 0;
   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
-#if INTRA_BL
-  if( pcCULeft && pcCULeft->isIntraBL( uiLeftPartIdx ) )
-  {
-    pcCULeft = NULL;
-  }
-#endif
+
   Bool isAvailableA1 = pcCULeft &&
   pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
-#if SVC_MVP
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeft->hasEqualMotion( uiLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) &&
-#endif
   !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
   !pcCULeft->isIntra( uiLeftPartIdx ) ;
@@ -2685,14 +2546,6 @@
   TComDataCU* pcCUAbove = 0;
   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
-#if INTRA_BL
-  if( pcCUAbove && pcCUAbove->isIntraBL( uiAbovePartIdx ) )
-  {
-    pcCUAbove = NULL;
-  }
-#endif
+
   Bool isAvailableB1 = pcCUAbove &&
-#if SVC_MVP
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
-#endif
   pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
   !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
@@ -2725,14 +2578,6 @@
   TComDataCU* pcCUAboveRight = 0;
   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
-#if INTRA_BL
-  if( pcCUAboveRight && pcCUAboveRight->isIntraBL( uiAboveRightPartIdx ) )
-  {
-    pcCUAboveRight = NULL;
-  }
-#endif
+
   Bool isAvailableB0 = pcCUAboveRight &&
-#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveRight->hasEqualMotion( uiAboveRightPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
-#endif
   pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
   !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
@@ -2761,22 +2606,10 @@
 
   //left bottom
-#if SVC_MVP
-  if( iCount < 4 )
-  {
-#endif
   UInt uiLeftBottomPartIdx = 0;
   TComDataCU* pcCULeftBottom = 0;
   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
-#if INTRA_BL
-  if( pcCULeftBottom && pcCULeftBottom->isIntraBL( uiLeftBottomPartIdx ) )
-  {
-    pcCULeftBottom = NULL;
-  }
-#endif
+
   Bool isAvailableA0 = pcCULeftBottom &&
   pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
-#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
-  ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCULeftBottom->hasEqualMotion( uiLeftBottomPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0])) &&
-#endif
   !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
@@ -2802,7 +2635,4 @@
     return;
   }
-#if SVC_MVP
-  }
-#endif
 
   // above left 
@@ -2812,15 +2642,7 @@
     TComDataCU* pcCUAboveLeft = 0;
     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
-#if INTRA_BL
-    if( pcCUAboveLeft && pcCUAboveLeft->isIntraBL( uiAboveLeftPartIdx ) )
-    {
-      pcCUAboveLeft = NULL;
-    }
-#endif
+
     Bool isAvailableB2 = pcCUAboveLeft &&
     pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
-#if SVC_MVP && !IL_MRG_SIMPLIFIED_PRUNING
-    ( !pcColCU || pcColCU->isIntra( uiAbsPartAddrBase ) || !pcCUAboveLeft->hasEqualMotion( uiAboveLeftPartIdx, puhInterDirNeighbours[0], &pcMvFieldNeighbours[0] )) &&
-#endif
     !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
@@ -3123,18 +2945,10 @@
   UInt idx;
   tmpCU = getPUBelowLeft(idx, uiPartIdxLB);
-#if INTRA_BL
-  bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx));
-#else
   bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA);
-#endif
 
   if (!bAddedSmvp)
   {
     tmpCU = getPULeft(idx, uiPartIdxLB);
-#if INTRA_BL
-    bAddedSmvp = (tmpCU != NULL) && (!tmpCU->isIntra(idx));
-#else
     bAddedSmvp = (tmpCU != NULL) && (tmpCU->getPredictionMode(idx) != MODE_INTRA);
-#endif
   }
 
@@ -3562,5 +3376,5 @@
 
   // use coldir.
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   TComPic *pColPic;
   if (m_layerId > 0 && getSlice()->getAltColIndicationFlag())
@@ -3699,11 +3513,6 @@
   if (scaleFactor > 0)
   {
-#if SVC_MVP
-    m_acCUMvField[0].compress(m_pePredMode, m_puhInterDir, scaleFactor);
-    m_acCUMvField[1].compress(m_pePredMode, m_puhInterDir, scaleFactor);    
-#else
     m_acCUMvField[0].compress(m_pePredMode, scaleFactor);
     m_acCUMvField[1].compress(m_pePredMode, scaleFactor);    
-#endif
   }
 }
@@ -4137,41 +3946,4 @@
 }
 
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED 
-Void TComDataCU::getBaseLumaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride )
-{
-  TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec();
-  UInt uiStrideBase = pcBaseRec->getStride();
-  Pel* piBase = pcBaseRec->getLumaAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
-  
-  for ( UInt y = 0; y < uiHeight; y ++ )
-  {
-    memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) );
-  }
-}
-
-Void TComDataCU::getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId )
-{
-  TComPicYuv* pcBaseRec = getSlice()->getFullPelBaseRec();
-
-  UInt uiStrideBase = pcBaseRec->getCStride();
-  Pel* piBase;
-  
-  if( uiChromaId == 0 )
-  {
-    piBase = pcBaseRec->getCbAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
-  }
-  else
-  {
-    piBase = pcBaseRec->getCrAddr( getAddr(), getZorderIdxInCU() + uiAbsPartIdx );
-  }
-  
-  for ( UInt y = 0; y < uiHeight; y ++ )
-  {
-    memcpy( piPred + y * uiStride, piBase + y * uiStrideBase, uiWidth * sizeof( Pel ) );
-  }
-}
-
-#endif
-
 #if SVC_COL_BLK
 TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
@@ -4273,4 +4045,9 @@
 #endif
 
+#if N0139_POSITION_ROUNDING_OFFSET
+  iBX += 4;
+  iBY += 4;
+#endif
+
 #if SCALED_REF_LAYER_OFFSETS
   if ( iBX >= cBaseColPic->getPicYuvRec()->getWidth() || iBY >= cBaseColPic->getPicYuvRec()->getHeight() ||
@@ -4334,28 +4111,3 @@
 }
 #endif
-
-#if SVC_MVP
-Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField  )
-{
-  if ( getInterDir( uiAbsPartIdx ) != uchInterDir )
-  {
-    return false;
-  }
-
-  for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
-  {
-    if ( getInterDir( uiAbsPartIdx ) & ( 1 << uiRefListIdx ) )
-    {
-      if ( getCUMvField( RefPicList( uiRefListIdx ) )->getMv( uiAbsPartIdx )  != pcMvField[uiRefListIdx].getMv() || 
-        getCUMvField( RefPicList( uiRefListIdx ) )->getRefIdx( uiAbsPartIdx ) != pcMvField[uiRefListIdx].getRefIdx() )
-      {
-        return false;
-      }
-    }
-  }
-
-  return true;
-}
-#endif
-
 //! \}
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 345)
@@ -485,22 +485,9 @@
   Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
   
-#if SVC_MVP
-  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, UChar uchInterDir, TComMvField* pcMvField  );
-#endif
-  
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for modes
   // -------------------------------------------------------------------------------------------------------------------
   
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED 
-  Void          getBaseLumaBlk   ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride );
-  Void          getBaseChromaBlk ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, Pel* piPred, UInt uiStride, UInt uiChromaId );
-#endif
-#if INTRA_BL
-  Bool          isIntraBL ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA_BL; }
-  Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA || m_pePredMode[ uiPartIdx ] == MODE_INTRA_BL; }
-#else
   Bool          isIntra   ( UInt uiPartIdx )  { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
-#endif 
   Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
   Bool          isBipredRestriction( UInt puIdx );
@@ -529,8 +516,5 @@
   UInt&         getTotalBins            ()                            { return m_uiTotalBins;                                                                                                  }
 
-#if INTRA_BL
-  UInt          getCtxIntraBLFlag               ( UInt   uiAbsPartIdx                                 );
-#endif  
-
+#if REF_IDX_FRAMEWORK
 #if FAST_INTRA_SHVC
   Int           reduceSetOfIntraModes              (  UInt   uiAbsPartIdx, Int* uiIntraDirPred, Int &fullSetOfModes );
@@ -540,4 +524,5 @@
   Bool xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
   Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
+#endif
 #endif
 
@@ -553,8 +538,10 @@
   UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
 
+#if REF_IDX_FRAMEWORK
 #if SVC_COL_BLK 
   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
   Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
+#endif
 #endif
 };
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 345)
@@ -328,9 +328,5 @@
  * \param scale      Factor by which to subsample motion information
  */
-#if SVC_MVP
-Void TComCUMvField::compress(Char* pePredMode, UChar* peInterDir, Int scale)
-#else
 Void TComCUMvField::compress(Char* pePredMode, Int scale)
-#endif
 {
   Int N = scale * scale;
@@ -351,7 +347,4 @@
       pePredMode[ uiPartIdx + i ] = predMode;
       m_piRefIdx[ uiPartIdx + i ] = iRefIdx;
-#if SVC_MVP
-      peInterDir[ uiPartIdx + i ] = peInterDir[ uiPartIdx ];
-#endif
     }
   }
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 345)
@@ -158,9 +158,5 @@
   }
   
-#if SVC_MVP
-  Void compress(Char* pePredMode, UChar* peInterDir, Int scale);
-#else
   Void compress(Char* pePredMode, Int scale); 
-#endif
 
 #if REF_IDX_MFM
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 345)
@@ -408,13 +408,4 @@
 }
 
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-Void TComPrediction::getBaseBlk( TComDataCU* pcCU, TComYuv* pcYuvPred, Int iPartAddr, Int iWidth, Int iHeight )
-{
-  pcCU->getBaseLumaBlk( iWidth, iHeight, iPartAddr, pcYuvPred->getLumaAddr( iPartAddr ), pcYuvPred->getStride() );
-  pcCU->getBaseChromaBlk( iWidth >> 1, iHeight >> 1, iPartAddr, pcYuvPred->getCbAddr( iPartAddr ), pcYuvPred->getCStride(), 0 );
-  pcCU->getBaseChromaBlk( iWidth >> 1, iHeight >> 1, iPartAddr, pcYuvPred->getCrAddr( iPartAddr ), pcYuvPred->getCStride(), 1 );
-}
-#endif
-
 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
 {
Index: trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 345)
@@ -101,8 +101,5 @@
   
   Void    initTempBuff();
-  
-#if INTRA_BL
-  Void getBaseBlk ( TComDataCU* pcCU, TComYuv* pcYuvPred, Int iPartAddr, Int iWidth, Int iHeight );
-#endif
+
   // inter
   Void motionCompensation         ( TComDataCU*  pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList = REF_PIC_LIST_X, Int iPartIdx = -1 );
@@ -121,4 +118,5 @@
   Int  getPredicBufHeight()       { return m_iYuvExtHeight; }
 
+#if REF_IDX_FRAMEWORK
 #if SVC_UPSAMPLING
 #if SCALED_REF_LAYER_OFFSETS
@@ -128,4 +126,5 @@
 #endif
 #endif
+#endif
 };
 
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 345)
@@ -124,5 +124,5 @@
   m_numILRRefIdx = 0;
 #endif 
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   m_altColIndicationFlag = false;
   m_colRefLayerIdx       = 0;
@@ -385,12 +385,5 @@
 
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
   if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) )
-#else
-  if ((getLayerId() == 0) || 
-      ((getSPS()->getLayerId()) &&  !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
-       (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) )
-     )
-#endif
   {
 #endif
@@ -458,15 +451,7 @@
 #if ILR_RESTR
     Int maxSubLayerForILPPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  ) 
-#else
-    if( m_layerId > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  )
-#endif
 #else //#if ILR_RESTR
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
-#else
-    if( m_layerId > 0 )
-#endif
 #endif //#if ILR_RESTR
     {
@@ -599,13 +584,5 @@
       rpsCurrList0[cIdx] = RefPicSetStCurr0[i];
     }
-    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
-    {
-      rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
-    }
-    for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
-    {
-      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
-    }    
-
+#if RPL_INIT_N0316_N0082
 #if REF_IDX_FRAMEWORK
     if( m_layerId > 0 )
@@ -619,4 +596,32 @@
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
 #if ILR_RESTR
+        Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
+#endif
+          rpsCurrList0[cIdx] = ilpPic[refLayerIdc];
+      }
+    }
+#endif
+#endif 
+    for ( i=0; i<NumPocStCurr1; i++, cIdx++)
+    {
+      rpsCurrList0[cIdx] = RefPicSetStCurr1[i];
+    }
+    for ( i=0; i<NumPocLtCurr;  i++, cIdx++)
+    {
+      rpsCurrList0[cIdx] = RefPicSetLtCurr[i];
+    }    
+#if !RPL_INIT_N0316_N0082
+#if REF_IDX_FRAMEWORK
+    if( m_layerId > 0 )
+    {
+#if JCTVC_M0458_INTERLAYER_RPS_SIG
+      for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)      
+#else
+      for( i = 0; i < m_numILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
+#endif 
+      {
+        Int refLayerIdc = m_interLayerPredLayerIdc[i];
+#if ILR_RESTR
          Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
@@ -625,4 +630,5 @@
       }
     }
+#endif
 #endif
   assert(cIdx == numPocTotalCurr);
@@ -707,4 +713,7 @@
   TComRefPicListModification* refPicListModification = &m_RefPicListModification;
   Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList();  // total number of ref pics in listTemp0 including inter-layer ref pics
+#if RPL_INIT_N0316_N0082
+  Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList();  // number of negative temporal ref pics 
+#endif
 
   assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 1);
@@ -712,5 +721,12 @@
 
   //set L0 inter-layer reference picture modification
+#if RPL_INIT_N0316_N0082
+  Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true;
+#else
   Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true;
+#endif
+#if FINAL_RPL_CHANGE_N0082
+  hasModification = false; //modification is not necessary
+#endif
   refPicListModification->setRefPicListModificationFlagL0(hasModification);
   if(hasModification)
@@ -736,5 +752,16 @@
 #endif 
       {
+#if RPL_INIT_N0316_N0082
+        if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0])
+          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
+        else
+        {
+          refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr);
+          for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++)
+            refPicListModification->setRefPicSetIdxL0(j, j + m_activeNumILRRefIdx);
+        }
+#else
         refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i);
+#endif
       }
     }
@@ -773,5 +800,24 @@
 }
 #endif
-
+#if RPL_INIT_N0316_N0082
+Int TComSlice::getNumNegativeRpsCurrTempList()
+{
+  if( m_eSliceType == I_SLICE ) 
+  {
+    return 0;
+  }
+
+  Int numPocBeforeCurr = 0;
+  for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ )
+  {
+    if(m_pcRPS->getUsed(i))
+    {
+      numPocBeforeCurr++;
+    }
+  }
+
+  return numPocBeforeCurr;
+}
+#endif
 Int TComSlice::getNumRpsCurrTempList()
 {
@@ -1616,4 +1662,7 @@
 #endif
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  m_maxTidIlRefPicsPlus1PresentFlag = true;
+#endif 
   for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
   {
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 345)
@@ -456,4 +456,7 @@
   UInt       m_layerIdInVps[MAX_VPS_LAYER_ID_PLUS1];            // Maps layer_id_in_nuh with the layer ID in the VPS
 #endif
+#if ILP_SSH_SIG
+  Bool       m_ilpSshSignalingEnabledFlag;
+#endif
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling related
@@ -491,4 +494,7 @@
   UInt       m_maxSublayerForIlpPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
 #endif
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  Bool       m_maxTidIlRefPicsPlus1PresentFlag;
+#endif 
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Bool       m_singleLayerForNonIrapFlag;
@@ -588,4 +594,8 @@
   UInt   getLayerIdInVps(Int id)                                { return m_layerIdInVps[id];       }
   Void   setLayerIdInVps(Int id, UInt x)                        { m_layerIdInVps[id] = x;          }
+#endif
+#if ILP_SSH_SIG
+    Bool   getIlpSshSignalingEnabledFlag()                      { return m_ilpSshSignalingEnabledFlag;}
+    Void   setIlpSshSignalingEnabledFlag(Bool x)                { m_ilpSshSignalingEnabledFlag = x;}
 #endif
 #if VPS_EXTN_PROFILE_INFO
@@ -653,4 +663,8 @@
   Void   setMaxSublayerForIlpPlus1(Int layerId, UInt maxSublayer)   { m_maxSublayerForIlpPlus1[layerId] = maxSublayer;            }
 #endif
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  Bool   getMaxTidIlRefPicsPlus1PresentFlag()                   { return m_maxTidIlRefPicsPlus1PresentFlag ;}
+  Void   setMaxTidIlRefPicsPlus1PresentFlag(Bool x)             { m_maxTidIlRefPicsPlus1PresentFlag = x;}
+#endif 
 #if M0040_ADAPTIVE_RESOLUTION_CHANGE
   Bool   getSingleLayerForNonIrapFlag()                             { return m_singleLayerForNonIrapFlag; }
@@ -1560,4 +1574,7 @@
   Bool      getMvdL1ZeroFlag ()                                  { return m_bLMvdL1Zero;    }
   Int       getNumRpsCurrTempList();
+#if RPL_INIT_N0316_N0082
+  Int       getNumNegativeRpsCurrTempList();
+#endif
   Int       getList1IdxToList0Idx ( Int list1Idx )               { return m_list1IdxToList0Idx[list1Idx]; }
   Void      setReferenced(Bool b)                               { m_bRefenced = b; }
@@ -1778,4 +1795,5 @@
   Void      setMFMEnabledFlag(Bool flag)                { m_bMFMEnabledFlag = flag; }
   Bool      getMFMEnabledFlag()                         { return m_bMFMEnabledFlag; }
+#if !REMOVE_COL_PICTURE_SIGNALING
   Void      setColRefLayerIdx(Int i)                    { m_colRefLayerIdx = i;     }
   Int       getColRefLayerIdx()                         { return m_colRefLayerIdx;  }
@@ -1784,4 +1802,5 @@
   Void      setMotionPredIlp(TComPic *ilpPic)           { m_pcIlpPic = ilpPic; }
   TComPic*  getMotionPredIlp()                          { return m_pcIlpPic; }
+#endif
 #endif
 #endif
Index: trunk/source/Lib/TLibCommon/TComTrQuant.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComTrQuant.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComTrQuant.cpp	(revision 345)
@@ -1235,10 +1235,4 @@
     uiMode = pcCU->getLumaIntraDir( uiAbsPartIdx );
   }
-#if INTRA_BL_DST4x4
-  else if(eTType == TEXT_LUMA && pcCU->isIntraBL(uiAbsPartIdx) )
-  {
-    uiMode = DC_IDX; //Using DST
-  }
-#endif
   else
   {
@@ -1314,16 +1308,5 @@
     Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eTxt];
     assert(scalingListType < 6);
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if(pcCU->isIntraBL(uiAbsPartIdx) && eTxt == TEXT_LUMA)
-    {
-      invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, DC_IDX, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
-    }
-    else
-    {
-      invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
-    }
-#else
     invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eTxt, REG_DCT, pResi, uiStride, rpcCoeff, uiWidth, uiHeight, scalingListType, pcCU->getTransformSkip(uiAbsPartIdx, eTxt) );
-#endif
   }
   else
@@ -1809,9 +1792,5 @@
   Int     ui16CtxCbf          = 0;
   Int     iBestLastIdxP1      = 0;
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if( (!pcCU->isIntra( uiAbsPartIdx ) || pcCU->isIntraBL( uiAbsPartIdx )) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
-#else
   if( !pcCU->isIntra( uiAbsPartIdx ) && eTType == TEXT_LUMA && pcCU->getTransformIdx( uiAbsPartIdx ) == 0 )
-#endif
   {
     ui16CtxCbf   = 0;
Index: trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 345)
@@ -9,58 +9,82 @@
 {
   {  0,  0,  0, 64,  0,  0,  0,  0}, //
+#if ARBITRARY_SPATIAL_RATIO
+  {  0,  1, -3, 63,  4, -2,  1,  0},
+  { -1,  2, -5, 62,  8, -3,  1,  0},
+  { -1,  3, -8, 60, 13, -4,  1,  0},
+  { -1,  4,-10, 58, 17, -5,  1,  0},
+#else
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //
-  { -1, 4, -11, 52, 26,  -8, 3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5      
+#endif
+  { -1, 4, -11, 52, 26,  -8,  3, -1}, // <-> actual phase shift 1/3, used for spatial scalability x1.5      
+#if ARBITRARY_SPATIAL_RATIO
+  { -1, 3,  -9, 47, 31, -10,  4, -1},
+  { -1, 4, -11, 45, 34, -10,  4, -1},
+#else
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, //       
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
-  { -1, 4, -11, 40, 40, -11, 4, -1}, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
+#endif
+  { -1, 4, -11, 40, 40, -11,  4, -1}, // <-> actual phase shift 1/2, equal to HEVC MC, used for spatial scalability x2
+#if ARBITRARY_SPATIAL_RATIO
+  { -1,  4, -10, 34, 45, -11,  4, -1},
+  { -1,  4, -10, 31, 47,  -9,  3, -1},
+#else
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
+#endif
   { -1, 3,  -8, 26, 52, -11, 4, -1}, // <-> actual phase shift 2/3, used for spatial scalability x1.5
+#if ARBITRARY_SPATIAL_RATIO
+  { 0,  1,  -5, 17, 58, -10,  4, -1},
+  { 0,  1,  -4, 13, 60,  -8,  3, -1},
+  { 0,  1,  -3,  8, 62,  -5,  2, -1},
+  { 0,  1,  -2,  4, 63,  -3,  1,  0}
+#else
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}, // 
   {CNU,CNU,CNU,CNU,CNU,CNU,CNU,CNU}  // 
+#endif
 };
 
 const Int TComUpsampleFilter::m_chromaFixedFilter[16][NTAPS_US_CHROMA] =
 {
-#if CHROMA_UPSAMPLING
   {  0, 64,  0,  0},//
+#if ARBITRARY_SPATIAL_RATIO
+  { -2, 62,  4,  0},
+  { -2, 58, 10, -2},
+  { -4, 56, 14, -2},
+#else
   {CNU,CNU,CNU,CNU},//
   {CNU,CNU,CNU,CNU},//
   {CNU,CNU,CNU,CNU},// 
+#endif
   { -4, 54, 16, -2},// <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
   { -6, 52, 20, -2},// <-> actual phase shift 1/3, used for spatial scalability x1.5   
   { -6, 46, 28, -4},// <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)      
+#if ARBITRARY_SPATIAL_RATIO
+  { -4, 42, 30, -4},
+#else
   {CNU,CNU,CNU,CNU},// 
+#endif
   { -4, 36, 36, -4},// <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
   { -4, 30, 42, -4},// <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
+#if ARBITRARY_SPATIAL_RATIO
+  { -4, 28, 46, -6},
+#else
   {CNU,CNU,CNU,CNU},// 
+#endif
   { -2, 20, 52, -6},// <-> actual phase shift 2/3, used for spatial scalability x1.5
+#if ARBITRARY_SPATIAL_RATIO
+  {-2, 16, 54, -4},
+  {-2, 14, 56, -4},
+#else
   {CNU,CNU,CNU,CNU},// 
   {CNU,CNU,CNU,CNU},// 
+#endif
   { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)  
   {  0,  4, 62, -2} // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-#else
-  {  0, 64,  0,  0},//
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},//
-  {CNU,CNU,CNU,CNU},// 
-  { -4, 54, 16, -2},// <-> actual phase shift 1/4,equal to HEVC MC, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-  { -5, 50, 22, -3},// <-> actual phase shift 1/3, used for spatial scalability x1.5   
-  { -6, 46, 28, -4},// <-> actual phase shift 3/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)      
-  {CNU,CNU,CNU,CNU},// 
-  { -4, 36, 36, -4},// <-> actual phase shift 1/2,equal to HEVC MC, used for spatial scalability x2
-  { -4, 30, 43, -5},// <-> actual phase shift 7/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-  {CNU,CNU,CNU,CNU},// 
-  { -3, 22, 50, -5},// <-> actual phase shift 2/3, used for spatial scalability x1.5
-  {CNU,CNU,CNU,CNU},// 
-  {CNU,CNU,CNU,CNU},// 
-  { -2, 10, 58, -2},// <-> actual phase shift 7/8,equal to HEVC MC, used for spatial scalability x2 (only for accurate Chroma alignement)  
-  { -1,  5, 62, -2} // <-> actual phase shift 11/12, used for spatial scalability x1.5 (only for accurate Chroma alignement)
-#endif
 };
 
@@ -183,6 +207,11 @@
     }
 
+#if ARBITRARY_SPATIAL_RATIO 
+    assert ( widthEL >= widthBL );
+    assert ( heightEL >= heightBL );
+#else
     assert ( widthEL == widthBL || widthEL == 2*widthBL || 2*widthEL == 3*widthBL );
     assert ( heightEL == heightBL || heightEL == 2*heightBL || 2*heightEL == 3*heightBL );
+#endif
 
     pcBasePic->setBorderExtension(false);
@@ -195,6 +224,11 @@
     Int   phaseY = 0;
 
+#if ROUNDING_OFFSET
+    Int   addX = ( ( phaseX * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
+    Int   addY = ( ( phaseY * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
+#else
     Int   addX       = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
     Int   addY       = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
+#endif
 
     Int   deltaX     = 4 * phaseX;
@@ -216,4 +250,11 @@
     Int topStartL  = scalEL.getWindowTopOffset();
     Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
+#if BUGFIX_RESAMPLE
+    Int leftOffset = leftStartL > 0 ? leftStartL : 0;
+#endif
+#endif
+
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    Int shift1 = g_bitDepthY - 8;
 #endif
 
@@ -236,5 +277,9 @@
       for( j = 0; j < heightBL ; j++ )
       {
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+        *piDstY = sumLumaHor(piSrcY, coeff) >> shift1;
+#else
         *piDstY = sumLumaHor(piSrcY, coeff);
+#endif
         piSrcY += strideBL;
         piDstY += strideEL;
@@ -248,5 +293,9 @@
     pcTempPic->setHeight(heightEL);
 
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    Int nShift = US_FILTER_PREC*2 - shift1;
+#else
     const Int nShift = US_FILTER_PREC*2;
+#endif
     Int iOffset = 1 << (nShift - 1); 
 
@@ -269,4 +318,29 @@
       piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
 #if SCALED_REF_LAYER_OFFSETS
+#if BUGFIX_RESAMPLE
+      Pel* piDstY0 = piDstBufY + j * strideEL;            
+      piDstY = piDstY0 + leftOffset;
+      piSrcY += leftOffset;
+
+      for( i = min<Int>(rightEndL, pcTempPic->getWidth()) - max<Int>(0, leftStartL); i > 0; i-- )
+      {
+        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
+        piSrcY++;
+        piDstY++;
+      }
+
+      for( i = rightEndL; i < pcTempPic->getWidth(); i++ )
+      {
+        *piDstY = piDstY0[rightEndL-1];
+        piDstY++;
+      }
+
+      piDstY = piDstY0;
+      for( i = 0; i < leftStartL; i++ )
+      {
+        *piDstY = piDstY0[leftStartL];
+        piDstY++;
+      }
+#else
 #if 1 // it should provide identical result
       Pel* piDstY0 = piDstBufY + j * strideEL;            
@@ -308,4 +382,5 @@
       }
 #endif
+#endif
 #else
       piDstY = piDstBufY + j * strideEL;
@@ -351,4 +426,7 @@
     Int topStartC  = scalEL.getWindowTopOffset() >> 1;
     Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
+#if BUGFIX_RESAMPLE
+    leftOffset = leftStartC > 0 ? leftStartC : 0;
+#endif
 #endif
 
@@ -359,6 +437,11 @@
     phaseY = 1;
 
+#if ROUNDING_OFFSET
+    addX       = ( ( phaseX * scaleX + 2 ) >> 2 ) + ( 1 << ( shiftX - 5 ) );
+    addY       = ( ( phaseY * scaleY + 2 ) >> 2 ) + ( 1 << ( shiftY - 5 ) );
+#else
     addX       = ( ( ( widthBL * phaseX ) << ( shiftX - 2 ) ) + ( widthEL >> 1 ) ) / widthEL + ( 1 << ( shiftX - 5 ) );
     addY       = ( ( ( heightBL * phaseY ) << ( shiftY - 2 ) ) + ( heightEL >> 1 ) ) / heightEL+ ( 1 << ( shiftY - 5 ) );
+#endif
 
     deltaX     = 4 * phaseX;
@@ -379,4 +462,8 @@
     widthBL   = pcBasePic->getWidth () >> 1;
     heightBL  = min<Int>( pcBasePic->getHeight() >> 1, heightEL );
+#endif
+
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    shift1 = g_bitDepthC - 8;
 #endif
 
@@ -401,6 +488,11 @@
       for( j = 0; j < heightBL ; j++ )
       {
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+        *piDstU = sumChromaHor(piSrcU, coeff) >> shift1;
+        *piDstV = sumChromaHor(piSrcV, coeff) >> shift1;
+#else
         *piDstU = sumChromaHor(piSrcU, coeff);
         *piDstV = sumChromaHor(piSrcV, coeff);
+#endif
 
         piSrcU += strideBL;
@@ -416,4 +508,9 @@
     pcTempPic->extendPicBorder   (); // extend the border.
     pcTempPic->setHeight(heightEL << 1);
+
+#if  N0214_INTERMEDIATE_BUFFER_16BITS
+    nShift = US_FILTER_PREC*2 - shift1;
+    iOffset = 1 << (nShift - 1); 
+#endif
 
 #if SCALED_REF_LAYER_OFFSETS
@@ -436,4 +533,40 @@
       piSrcV = piTempBufV  + (refPos -((NTAPS_US_CHROMA>>1) - 1))*strideEL;
 #if SCALED_REF_LAYER_OFFSETS
+#if BUGFIX_RESAMPLE
+      Pel* piDstU0 = piDstBufU + j*strideEL;
+      Pel* piDstV0 = piDstBufV + j*strideEL;
+      piDstU = piDstU0 + leftOffset;
+      piDstV = piDstV0 + leftOffset;
+      piSrcU += leftOffset;
+      piSrcV += leftOffset;
+
+      for( i = min<Int>(rightEndC, pcTempPic->getWidth() >> 1) - max<Int>(0, leftStartC); i > 0; i-- )
+      {
+        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
+        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
+        piSrcU++;
+        piSrcV++;
+        piDstU++;
+        piDstV++;
+      }
+
+      for( i = rightEndC; i < pcTempPic->getWidth() >> 1; i++ )
+      {
+        *piDstU = piDstU0[rightEndC-1];
+        *piDstV = piDstV0[rightEndC-1];
+        piDstU++;
+        piDstV++;
+      }
+
+      piDstU = piDstU0;
+      piDstV = piDstV0;
+      for( i = 0; i < leftStartC; i++ )
+      {
+        *piDstU = piDstU0[leftStartC];
+        *piDstV = piDstV0[leftStartC];
+        piDstU++;
+        piDstV++;
+      }
+#else
 #if 1 // it should provide identical result
       Pel* piDstU0 = piDstBufU + j*strideEL;
@@ -490,4 +623,5 @@
       }
 #endif
+#endif
 #else
       piDstU = piDstBufU + j*strideEL;
Index: trunk/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComYuv.cpp	(revision 345)
@@ -184,57 +184,4 @@
 }
 
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-Void TComYuv::copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight )
-{
-  Int  y;
-
-  Pel* pDst     = getLumaAddr(uiAbsZorderIdx);
-  Pel* pSrc     = pcPicYuvSrc->getLumaAddr ( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
-
-  UInt  iDstStride  = getStride();
-  UInt  iSrcStride  = pcPicYuvSrc->getStride();
-  for ( y = uiHeight; y != 0; y-- )
-  {
-    ::memcpy( pDst, pSrc, sizeof(Pel)*uiWidth);
-    pDst += iDstStride;
-    pSrc += iSrcStride;
-  }
-}
-
-Void TComYuv::copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  )
-{
-  Int  y;
-
-  if (!uiChromaId)
-  {
-    Pel* pDstU      = getCbAddr(uiAbsZorderIdx); 
-    Pel* pSrcU      = pcPicYuvSrc->getCbAddr( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
-
-    UInt  iDstStride = getCStride();
-    UInt  iSrcStride = pcPicYuvSrc->getCStride();
-    for ( y = uiCHeight; y != 0; y-- )
-    {
-      ::memcpy( pDstU, pSrcU, sizeof(Pel)*(uiCWidth) );
-      pSrcU += iSrcStride;
-      pDstU += iDstStride;
-    }
-  }
-  else
-  {
-    Pel* pDstV      = getCrAddr(uiAbsZorderIdx);
-    Pel* pSrcV      = pcPicYuvSrc->getCrAddr( iCuAddr, uiZorderIdxInCU + uiAbsZorderIdx );
-
-    UInt  iDstStride = getCStride();
-    UInt  iSrcStride = pcPicYuvSrc->getCStride();
-    for ( y = uiCHeight; y != 0; y-- )
-    {
-      ::memcpy( pDstV, pSrcV, sizeof(Pel)*(uiCWidth) );
-      pSrcV += iSrcStride;
-      pDstV += iDstStride;
-    }
-  }
-}
-#endif
-
 Void TComYuv::copyToPartYuv( TComYuv* pcYuvDst, UInt uiDstPartIdx )
 {
Index: trunk/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComYuv.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/TComYuv.h	(revision 345)
@@ -115,8 +115,4 @@
   Void    copyFromPicLuma      ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
   Void    copyFromPicChroma    ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiAbsZorderIdx );
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  Void    copyFromPicLuma  ( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiWidth, UInt uiHeight );
-  Void    copyFromPicChroma( TComPicYuv* pcPicYuvSrc, UInt iCuAddr, UInt uiZorderIdxInCU, UInt uiAbsZorderIdx, UInt uiCWidth, UInt uiCHeight, UInt uiChromaId  );
-#endif
   
   //  Copy Small YUV buffer to the part of other Big YUV buffer
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 314)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 345)
@@ -41,9 +41,12 @@
 #define SVC_EXTENSION                    1
 
+#define N0139_POSITION_ROUNDING_OFFSET   1
+
 #define SYNTAX_BYTES                     10      ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
 
 #if SVC_EXTENSION
 #define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
-
+#define RPL_INIT_N0316_N0082             1      ///< N0316, N0082: initial reference picture list construction 
+#define FINAL_RPL_CHANGE_N0082           1      ///< N0082: final ref picture list change (encoder)
 #define M0464_TILE_BOUNDARY_ALIGNED_FLAG 1      ///< VUI flag to indicate tile boundary alignment
 #define M0463_VUI_EXT_ILP_REF            1      ///< VUI extension inter-layer dependency offset signalling
@@ -51,4 +54,8 @@
 #define SCALED_REF_LAYER_OFFSET_FLAG     0      ///< M0309: Signal scaled reference layer offsets in SPS
 #define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
+
+#define ILP_SSH_SIG                      1      ///< JCTVC-N0195 proposal 2, JCTVC-N0118: add presence flag in VPS ext to condition inter-layer prediction signaling in slice segment header
+#define SPL_FLG_CHK                      1      ///< JCTVC-N0195 proposal 5, JCTVC-N0085: constrain sum of lengths to be less than or equal to 6
+#define ILP_NUM_REF_CHK                  1      ///< JCTVC-N0195 proposal 1, JCTVC-N0081, JCTVC-N0154, JCTVC-N0217: a condition on signaling inter_layer_pred_layer_idc[ i ], to avoid sending when NumDirectRefLayers equals NumActiveRefLayerPics, and instead infer values
 
 #define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
@@ -74,5 +81,8 @@
 #define SVC_COL_BLK                      1      ///< get co-located block
 #define SVC_UPSAMPLING                   1      ///< upsampling filters
-#define CHROMA_UPSAMPLING                1      ///< L0335: Chroma upsampling with 5 bits coefficients
+#define ROUNDING_OFFSET                  1      ///< JCTVC-N0111: upsampling rounding offset using scalling factors
+#define N0214_INTERMEDIATE_BUFFER_16BITS 1      ///< JCTVC-N0214 support base layer input more than 8 bits
+#define ARBITRARY_SPATIAL_RATIO          0      ///< JCTVC-N0219, JCTVC-N0273: Support arbitrary spatial ratio
+#define BUGFIX_RESAMPLE                  1      ///< JCTVC-N0055: resampling bug fix for positive left scalled offset
 
 #define SIMPLIFIED_MV_POS_SCALING        1      ///< M0133/M0449: inter-layer MV scaling and pixel mapping position calculation
@@ -97,36 +107,20 @@
 #define JCTVC_M0458_INTERLAYER_RPS_SIG   1      ///< implementation of JCTVC-L0178
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
-#define ZERO_NUM_DIRECT_LAYERS           1      ///< support of zero direct reference layers
 #define MAX_ONE_RESAMPLING_DIRECT_LAYERS 1      ///< Allow maximum of one resampling process for direct reference layers
 #endif
 #define JCTVC_M0203_INTERLAYER_PRED_IDC  1      ///< implementation of JCTVC-M0203 Inter-layer Prediction Indication
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
-#define ILR_RESTR                        1     ///< JCTVC-M0209 Inter-layer RPS and RPL
+#define ILR_RESTR                        1      ///< JCTVC-M0209 Inter-layer RPS and RPL
+#define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120 max_tid_ref_pics_plus1_present_flag
 #endif
 #if REF_IDX_MFM
+#define REMOVE_COL_PICTURE_SIGNALING     1      ///< JCTVC-N0107 remove alternative collocated picture signalling
 #define M0457_COL_PICTURE_SIGNALING      1
 #endif
 
 #if !VPS_EXTN_DIRECT_REF_LAYERS || !M0457_PREDICTION_INDICATIONS || !JCTVC_M0458_INTERLAYER_RPS_SIG
-#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0
+#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0      ///< shall be 0, JCTVC-N0107
 #else
-#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0
-#endif
-
-#else
-#define INTRA_BL                         1      ///< inter-layer texture prediction
-
-#if INTRA_BL
-#define INTRA_BL_DST4x4                  1      ///< L0067/L0204: DST4x4 for Intra BL
-#define NO_RESIDUAL_FLAG_FOR_BLPRED      1      ///< L0437: Root cbf for Intra_BL
-#define IL_MRG_SIMPLIFIED_PRUNING        1      ///< M0124: simplified pruning, Only the left and above candidates are checked with BL-C candidate for redundancy removal 
-#define INTRA_BL_CTX_CHANGE              1      ///< M0075: spatial dependency removal for IntraBL flag context derivation
-
-// Hooks
-#define SVC_MVP                          1      ///< motion hook for merge mode as an example
-#if !AVC_BASE && !AVC_SYNTAX
-#define SVC_BL_CAND_INTRA                0      ///< Intra Base Mode Prediction hook as an example 
-#endif
-
+#define M0457_IL_SAMPLE_PRED_ONLY_FLAG   0      ///< shall be 0, JCTVC-N0107
 #endif
 #endif
@@ -134,8 +128,8 @@
 #define FAST_INTRA_SHVC                  1      ///< M0115: reduction number of intra modes in the EL (encoder only)
 #if FAST_INTRA_SHVC
-  #define NB_REMAIN_MODES                2      ///< nb of remaining modes (M0115)
-#endif
-
-#define RC_SHVC_HARMONIZATION            1  ///< JCTVC-M0037, rate control for SHVC
+#define NB_REMAIN_MODES                  2      ///< nb of remaining modes (M0115)
+#endif
+
+#define RC_SHVC_HARMONIZATION            1      ///< JCTVC-M0037, rate control for SHVC
 
 #else
@@ -472,7 +466,4 @@
   MODE_INTER,           ///< inter-prediction mode
   MODE_INTRA,           ///< intra-prediction mode
-#if INTRA_BL
-  MODE_INTRA_BL,        ///< inter-layer intra-prediction mode
-#endif
   MODE_NONE = 15
 };
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 345)
@@ -951,4 +951,22 @@
 #endif
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+  READ_FLAG( uiCode, "max_tid_il_ref_pics_plus1_present_flag"); vps->setMaxTidIlRefPicsPlus1PresentFlag(uiCode ? true : false);
+  if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
+  {
+    for(i = 0; i < vps->getMaxLayers() - 1; i++)
+    {
+      READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode);
+      assert( uiCode <= vps->getMaxTLayers() );
+    }
+  }
+  else 
+  {
+    for(i = 0; i < vps->getMaxLayers() - 1; i++)
+    {
+      vps->setMaxSublayerForIlpPlus1(i, 7);
+    }
+  }
+#else
   for(i = 0; i < vps->getMaxLayers() - 1; i++)
   {
@@ -956,4 +974,8 @@
     assert( uiCode <= vps->getMaxTLayers() );
   }
+#endif
+#endif
+#if ILP_SSH_SIG
+    READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false);
 #endif
 #if VPS_EXTN_PROFILE_INFO
@@ -1382,5 +1404,9 @@
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
     rpcSlice->setActiveNumILRRefIdx(0);
+#if ILP_SSH_SIG
+    if((sps->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) )
+#else
     if((sps->getLayerId() > 0)  &&  (rpcSlice->getNumILRRefIdx() > 0) )
+#endif
     {
       READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
@@ -1404,4 +1430,15 @@
             rpcSlice->setActiveNumILRRefIdx(1);
           }
+#if ILP_NUM_REF_CHK
+          if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() )
+          {
+            for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
+            {
+              rpcSlice->setInterLayerPredLayerIdc(i,i);
+            }
+          }
+          else
+          {
+#endif
           for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
           {
@@ -1409,4 +1446,7 @@
             rpcSlice->setInterLayerPredLayerIdc(uiCode,i);
           }
+#if ILP_NUM_REF_CHK
+          }
+#endif
         }
         else
@@ -1417,4 +1457,15 @@
       }
     }
+#if ILP_SSH_SIG
+    else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false )
+    {
+      rpcSlice->setInterLayerPredEnabledFlag(true);
+      rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx());
+      for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
+      {
+        rpcSlice->setInterLayerPredLayerIdc(i,i);
+      }
+    }
+#endif
 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG
     rpcSlice->setInterLayerSamplePredOnlyFlag( false );
@@ -1574,4 +1625,7 @@
     {
 #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
+#if REMOVE_COL_PICTURE_SIGNALING
+      rpcSlice->setMFMEnabledFlag( rpcSlice->getNumMotionPredRefLayers() > 0 ? true : false );
+#else
       rpcSlice->setMFMEnabledFlag( false );
       rpcSlice->setColRefLayerIdx( 0 );
@@ -1590,4 +1644,5 @@
       else
       {
+#endif //REMOVE_COL_PICTURE_SIGNALING
 #endif
       if ( rpcSlice->getSliceType() == B_SLICE )
@@ -1612,5 +1667,5 @@
         rpcSlice->setColRefIdx(0);
       }
-#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
+#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
       }
 #endif
@@ -2215,12 +2270,4 @@
   return (cnt>0);
 }
-
-#if INTRA_BL
-Void TDecCavlc::parseIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
-{
-  assert(0);
-}
-#endif
-
 //! \}
 
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 345)
@@ -118,8 +118,4 @@
   Void updateContextTables  ( SliceType /*eSliceType*/, Int /*iQp*/ ) { return; }
 
-#if INTRA_BL
-  Void parseIntraBLFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-#endif
-
   Void xParsePredWeightTable ( TComSlice* pcSlice );
   Void  parseScalingList               ( TComScalingList* scalingList );
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 345)
@@ -334,13 +334,4 @@
     return;
   }
-#if INTRA_BL
-  m_pcEntropyDecoder->decodeIntraBLFlag( pcCU, uiAbsPartIdx, 0, uiDepth );
-  if ( pcCU->isIntraBL( uiAbsPartIdx ) )
-  {
-    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); 
-  }
-  else
-  {
-#endif
 
   m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
@@ -357,17 +348,10 @@
     }
   }
-#if INTRA_BL
+
+  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
+  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
+  
   // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
-  }
-#endif
-
-  UInt uiCurrWidth      = pcCU->getWidth ( uiAbsPartIdx );
-  UInt uiCurrHeight     = pcCU->getHeight( uiAbsPartIdx );
-  
-#if !INTRA_BL
-  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
-  m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
-#endif
 
   // Coefficient decoding
@@ -440,13 +424,4 @@
       xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
       break;
-#if INTRA_BL
-    case MODE_INTRA_BL:
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-      xReconIntraBL( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
-#else
-      xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
-#endif
-      break;
-#endif
     default:
       assert(0);
@@ -516,11 +491,4 @@
   
   //===== get prediction signal =====
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
-  {
-    pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride );
-  }
-  else
-#endif
   m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
   
@@ -607,18 +575,9 @@
   
   //===== get prediction signal =====
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
-  {
-    pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId );
-  }
-  else
-#endif
-  {
-    if( uiChromaPredMode == DM_CHROMA_IDX )
-    {
-      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
-    }
-    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );  
-  }
+  if( uiChromaPredMode == DM_CHROMA_IDX )
+  {
+    uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
+  }
+  m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );  
 
   //===== inverse transform =====
@@ -930,27 +889,3 @@
 
 }
-
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-Void
-TDecCu::xReconIntraBL( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  m_ppcYuvReco[uiDepth]->copyFromPicLuma  ( pcCU->getSlice()->getFullPelBaseRec(m_layerId - 1),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, pcCU->getWidth(0), pcCU->getHeight(0));
-  m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(m_layerId - 1),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 0);
-  m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(m_layerId - 1),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 1);
-
-  // inter recon
-  xDecodeInterTexture( pcCU, 0, uiDepth );
-
-  // clip for only non-zero cbp case
-  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
-  {
-    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
-  }
-  else
-  {
-    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
-  }
-}
-#endif
-
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.h	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecCu.h	(revision 345)
@@ -77,8 +77,4 @@
 #endif
   
-#if INTRA_BL
-  TComPicYuv*         m_pcPicYuvRecBase;       ///< reconstructed base layer
-#endif 
-  
 public:
   TDecCu();
@@ -106,7 +102,4 @@
 #if SVC_EXTENSION
   TDecTop*   getLayerDec        ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; }
-#if INTRA_BL
-  Void  setBaseRecPic           ( TComPicYuv* p ) { m_pcPicYuvRecBase = p; }
-#endif 
 #endif
 protected:
@@ -122,7 +115,4 @@
   Void  xIntraRecLumaBlk        ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );
   Void  xIntraRecChromaBlk      ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, UInt uiChromaId );
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  Void  xReconIntraBL           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
-#endif
   
   Void  xReconPCM               ( TComDataCU* pcCU, UInt uiDepth );
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 345)
@@ -58,11 +58,4 @@
 }
 
-#if INTRA_BL
-Void TDecEntropy::decodeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
-{
-  m_pcEntropyDecoderIf->parseIntraBLFlag( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth );
-}
-#endif
-
 /** decode merge flag
  * \param pcSubCU
@@ -111,10 +104,4 @@
 Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
 {
-#if INTRA_BL
-  if( pcCU->isIntraBL( uiAbsPartIdx ) )                                 // Do nothing for Intra BL mode.
-  {
-    return;
-  }
-#endif
   if( pcCU->isIntra( uiAbsPartIdx ) )                                 // If it is Intra mode, encode intra prediction mode.
   {
@@ -450,13 +437,5 @@
     
     pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
-#if INTRA_BL
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if( ( !pcCU->isIntra(uiAbsPartIdx) || pcCU->isIntraBL(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#else
-    if( ( !pcCU->isIntra(uiAbsPartIdx) ) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#endif
-#else
     if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#endif 
     {
       pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
@@ -556,9 +535,5 @@
   UInt uiChromaOffset = uiLumaOffset>>2;
   
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if( pcCU->isIntra(uiAbsPartIdx) && !pcCU->isIntraBL(uiAbsPartIdx) )
-#else
   if( pcCU->isIntra(uiAbsPartIdx) )
-#endif
   {
   }
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 345)
@@ -107,8 +107,4 @@
   virtual Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) = 0;
 
-#if INTRA_BL
-  virtual Void parseIntraBLFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) = 0;
-#endif
-
   virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0;
   
@@ -170,8 +166,4 @@
   Void updateContextTables    ( SliceType eSliceType, Int iQp ) { m_pcEntropyDecoderIf->updateContextTables( eSliceType, iQp ); }
   
-#if INTRA_BL
-  Void decodeIntraBLFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-#endif
-  
 private:
   Void xDecodeTransform        ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP );
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 345)
@@ -77,7 +77,4 @@
 , m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
 , m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
-#if INTRA_BL
-, m_cIntraBLPredFlagSCModel   (1,              1,               NUM_INTRA_BL_PRED_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -138,7 +135,4 @@
 
   m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
-#if INTRA_BL
-  m_cIntraBLPredFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
   m_cTransformSkipSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
   m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
@@ -186,7 +180,4 @@
   m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
   m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
-#if INTRA_BL
-  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
   m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
   m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
@@ -438,32 +429,4 @@
 }
 
-#if INTRA_BL
-Void TDecSbac::parseIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
-{
-  if( pcCU->getLayerId() == 0 )
-  {
-    return;
-  }
-
-  UInt uiSymbol = 0;
-
-  UInt uiCtxIntraBL = pcCU->getCtxIntraBLFlag( uiAbsPartIdx ) ;
-  m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraBLPredFlagSCModel.get( 0, 0, uiCtxIntraBL )); 
-  DTRACE_CABAC_VL( g_nSymbolCounter++ );
-  DTRACE_CABAC_T( "\tIntrBLFlag" );
-  DTRACE_CABAC_T( "\tuiSymbol: ");
-  DTRACE_CABAC_V( uiSymbol );
-  DTRACE_CABAC_T( "\n");
-
-  if ( uiSymbol )
-  {
-    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
-    pcCU->setPredModeSubParts( MODE_INTRA_BL, uiAbsPartIdx, uiDepth );
-    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
-    pcCU->setLumaIntraDirSubParts ( DC_IDX, uiAbsPartIdx, uiDepth );   
-  }
-}
-#endif
-
 /** parse merge flag
  * \param pcCU
@@ -555,11 +518,5 @@
   UInt uiSymbol, uiMode = 0;
   PartSize eMode;
-  
-#if INTRA_BL
-  if ( pcCU->isIntraBL( uiAbsPartIdx ) )
-  {
-    assert( 0 );
-  }
-#endif
+
   if ( pcCU->isIntra( uiAbsPartIdx ) )
   {
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 345)
@@ -135,7 +135,4 @@
   Void  parseScalingList ( TComScalingList* /*scalingList*/ ) {}
 
-#if INTRA_BL
-  Void parseIntraBLFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-#endif
 private:
   UInt m_uiLastDQpNonZero;
@@ -174,7 +171,4 @@
   ContextModel3DBuffer m_cTransformSkipSCModel;
   ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
-#if INTRA_BL
-  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
-#endif
 };
 
Index: trunk/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 345)
@@ -197,7 +197,5 @@
   UInt uiTileLCUX;
   Int iNumSubstreamsPerTile = 1; // if independent.
-#if INTRA_BL
-  m_pcCuDecoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec(rpcPic->getLayerId()-1) : NULL);
-#endif
+
   Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
   uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 345)
@@ -242,4 +242,9 @@
 
   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+
+#if SVC_EXTENSION
+  m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used
+#endif
+
   if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
   {
@@ -812,10 +817,4 @@
 #if REF_IDX_FRAMEWORK
     if (m_layerId == 0)
-#elif INTRA_BL
-    if( m_layerId > 0 )
-    {
-      pcSlice->setRefPicList( m_cListPic );
-    }
-    else
 #endif
 #if FIX1071
@@ -913,9 +912,5 @@
 
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
-#else
-    if(m_layerId > 0)
-#endif
     {
       setILRPic(pcPic);
@@ -928,5 +923,5 @@
       {
         pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
         pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice));
 #endif
@@ -1321,9 +1316,5 @@
   if( vps->getNumDirectRefLayers( m_layerId ) <= 0 )
   {
-#if ZERO_NUM_DIRECT_LAYERS
     return (TDecTop *)getLayerDec( 0 );
-#else
-    return NULL;
-#endif
   }
   
@@ -1386,5 +1377,5 @@
 #endif
 
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
 TComPic* TDecTop::getMotionPredIlp(TComSlice* pcSlice)
 {
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 314)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 345)
@@ -230,5 +230,5 @@
   Void      xDecodePPS();
   Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   TComPic*  getMotionPredIlp(TComSlice* pcSlice);
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 345)
@@ -708,4 +708,16 @@
   }
 
+#if SPL_FLG_CHK
+  if(vps->getSplittingFlag())
+  {
+    UInt splDimSum=0;
+    for(j = 0; j < vps->getNumScalabilityTypes(); j++)
+    {
+      splDimSum+=(vps->getDimensionIdLen(j));
+    }
+    assert(splDimSum<=6);
+  }
+#endif
+
   WRITE_FLAG( vps->getNuhLayerIdPresentFlag(),         "vps_nuh_layer_id_present_flag" );
   for(i = 1; i < vps->getMaxLayers(); i++)
@@ -737,8 +749,22 @@
 #endif
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if N0120_MAX_TID_REF_PRESENT_FLAG
+   WRITE_FLAG( vps->getMaxTidIlRefPicsPlus1PresentFlag(), "max_tid_il_ref_pics_plus1_present_flag");
+   if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
+   {
+     for( i = 0; i < vps->getMaxLayers() - 1; i++)
+     {
+       WRITE_CODE(vps->getMaxSublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );
+     }
+   }
+#else
   for( i = 0; i < vps->getMaxLayers() - 1; i++)
   {
     WRITE_CODE(vps->getMaxSublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );
   }
+#endif
+#endif
+#if ILP_SSH_SIG
+    WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
 #endif
 #if VPS_EXTN_PROFILE_INFO
@@ -1052,6 +1078,10 @@
     }
 
-#if JCTVC_M0458_INTERLAYER_RPS_SIG    
-    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) ) 
+#if JCTVC_M0458_INTERLAYER_RPS_SIG
+#if ILP_SSH_SIG
+    if((pcSlice->getSPS()->getLayerId() > 0) && pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (pcSlice->getNumILRRefIdx() > 0) )
+#else
+    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) )
+#endif
     {
       WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
@@ -1069,8 +1099,15 @@
             WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");
           }       
+#if ILP_NUM_REF_CHK
+          if( pcSlice->getNumILRRefIdx() != pcSlice->getActiveNumILRRefIdx() )
+          {
+#endif
           for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
           {
             WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
           }
+#if ILP_NUM_REF_CHK
+          }
+#endif
         }
       }
@@ -1187,5 +1224,5 @@
     if ( pcSlice->getEnableTMVPFlag() )
     {
-#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
+#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
       if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 )
       {
@@ -1210,5 +1247,5 @@
         WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" );
       }
-#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING
+#if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
       }
 #endif
@@ -1726,11 +1763,3 @@
   return true;
 }
-
-#if INTRA_BL
-Void TEncCavlc::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
-{
-  assert(0);
-}
-
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 345)
@@ -112,7 +112,4 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if INTRA_BL
-  Void codeIntraBLFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#endif
  
   Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode );
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 345)
@@ -763,11 +763,4 @@
           }
         }
-#if INTRA_BL
-      if(m_pcPicYuvRecBase)
-      {
-        xCheckRDCostIntraBL( rpcBestCU, rpcTempCU );
-        rpcTempCU->initEstData( uiDepth, iQP );
-      }
-#endif
 #if (ENCODER_FAST_MODE)
       if(pcPic->getLayerId() > 0)
@@ -1215,9 +1208,4 @@
     return;
   }
-#if INTRA_BL
-  m_pcEntropyCoder->encodeIntraBLFlag( pcCU, uiAbsPartIdx );
-  if ( !pcCU->isIntraBL( uiAbsPartIdx ) )
-  {
-#endif
   m_pcEntropyCoder->encodePredMode( pcCU, uiAbsPartIdx );
   
@@ -1238,7 +1226,4 @@
   // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
-#if INTRA_BL
-  }
-#endif
   
   // Encode Coefficients
@@ -1568,7 +1553,5 @@
   
   m_pcEntropyCoder->resetBits();
-#if INTRA_BL
-  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
-#endif
+
   if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
   {
@@ -1624,7 +1607,5 @@
 
   m_pcEntropyCoder->resetBits();
-#if INTRA_BL
-  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
-#endif
+
   if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
   {
@@ -1879,54 +1860,4 @@
 #endif
 
-#if INTRA_BL
-Void TEncCu::xCheckRDCostIntraBL( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU )
-{
-  UInt uiDepth = rpcTempCU->getDepth( 0 );
-  rpcTempCU->setSkipFlagSubParts( false, 0, uiDepth ); 
-  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
-  rpcTempCU->setPredModeSubParts( MODE_INTRA_BL, 0, uiDepth );  
-  rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uiDepth );
-
-  m_pcPredSearch->setBaseRecPic( m_pcPicYuvRecBase ); 
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  rpcTempCU->setDepthSubParts( uiDepth, 0 );
-  //   rpcTempCU->setLumaIntraDirSubParts( DC_IDX, 0, uiDepth );
-  //   rpcTempCU->setChromIntraDirSubParts( DC_IDX, 0, uiDepth );
-  m_ppcPredYuvTemp[uiDepth]->copyFromPicLuma  ( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, rpcTempCU->getWidth(0), rpcTempCU->getHeight(0));
-  m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 0);
-  m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1),  rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 1);
-  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcResiYuvBest[uiDepth], m_ppcRecoYuvTemp[uiDepth], false );
-  rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-#else
-
-  m_pcPredSearch->estIntraBLPredQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth] );
-
-  m_pcEntropyCoder->resetBits();
-  m_pcEntropyCoder->encodeIntraBLFlag ( rpcTempCU, 0,       true );
-  m_pcEntropyCoder->encodeSkipFlag( rpcTempCU, 0,       true );
-  if ( rpcTempCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
-  {
-    m_pcEntropyCoder->encodeCUTransquantBypassFlag( rpcTempCU, 0,          true );
-  }
-
-  // Encode Coefficients
-  Bool bCodeDQP = getdQPFlag();
-  m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP );
-  setdQPFlag( bCodeDQP );
-  
-  if( m_bUseSBACRD ) m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[uiDepth][CI_TEMP_BEST]);
-  
-  rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
-  if(m_pcEncCfg->getUseSBACRD())
-  {
-    rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
-  }
-  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-#endif
-  
-  xCheckDQP( rpcTempCU );
-  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
-}
-#endif
 #if (ENCODER_FAST_MODE)
 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId)
Index: trunk/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncCu.h	(revision 345)
@@ -84,7 +84,4 @@
   //  Access channel
   TEncCfg*                m_pcEncCfg;
-#if INTRA_BL
-  TComPicYuv*             m_pcPicYuvRecBase;       ///< reconstructed base layer
-#endif 
   TEncSearch*             m_pcPredSearch;
   TComTrQuant*            m_pcTrQuant;
@@ -134,7 +131,5 @@
   Int   updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height );
 #endif
-#if INTRA_BL 
-  Void  setBaseRecPic       ( TComPicYuv* p ) { m_pcPicYuvRecBase = p; }   
-#endif
+
 protected:
   Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
@@ -157,7 +152,4 @@
 #endif
   Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
-#if INTRA_BL
-  Void  xCheckRDCostIntraBL ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU  );
-#endif
 #if ENCODER_FAST_MODE
   Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 345)
@@ -166,11 +166,4 @@
   }
 
-#if INTRA_BL
-  if( pcCU->isIntraBL( uiAbsPartIdx ) )
-  {
-    return;
-  }
-#endif
-
   m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx );
 }
@@ -251,10 +244,6 @@
     }
   }
-#if INTRA_BL
-    if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
-#else
   
   if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) )
-#endif
   {
     assert( uiSubdiv );
@@ -342,13 +331,5 @@
     }
     
-#if INTRA_BL
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if( ( !pcCU->isIntra( uiAbsPartIdx ) || pcCU->isIntraBL(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#else
-    if( ( !pcCU->isIntra( uiAbsPartIdx ) ) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#endif
-#else
     if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) )
-#endif
     {
       assert( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, 0 ) );
@@ -431,7 +412,4 @@
 Void TEncEntropy::encodePredInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
-#if INTRA_BL
-  assert ( !pcCU->isIntraBL( uiAbsPartIdx ) );
-#endif
   if( bRD )
   {
@@ -607,9 +585,5 @@
   UInt uiChromaOffset = uiLumaOffset>>2;
     
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if( pcCU->isIntra(uiAbsPartIdx) && !pcCU->isIntraBL(uiAbsPartIdx) )
-#else
   if( pcCU->isIntra(uiAbsPartIdx) )
-#endif
   {
     DTRACE_CABAC_VL( g_nSymbolCounter++ )
@@ -759,18 +733,3 @@
 }
 
-#if INTRA_BL
-Void TEncEntropy::encodeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
-{
-  if( pcCU->getLayerId() == 0 )
-  {
-    return;
-  }
-
-  if( bRD )
-  {
-    uiAbsPartIdx = 0;
-  }
-  m_pcEntropyCoderIf->codeIntraBLFlag( pcCU, uiAbsPartIdx );
-}
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 345)
@@ -85,8 +85,5 @@
   virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
-  
-#if INTRA_BL
-  virtual Void codeIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
-#endif
+
   virtual Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
   virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
@@ -164,7 +161,4 @@
   Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#if INTRA_BL
-  Void encodeIntraBLFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#endif
   Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
   Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 345)
@@ -511,5 +511,7 @@
 #if M0457_COL_PICTURE_SIGNALING
       pcSlice->setMFMEnabledFlag(false);
+#if !REMOVE_COL_PICTURE_SIGNALING
       pcSlice->setAltColIndicationFlag(false);
+#endif
 #endif
     }
@@ -645,12 +647,10 @@
       pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
     }
-#if ZERO_NUM_DIRECT_LAYERS
+
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     {
       pcSlice->setSliceType(I_SLICE);
     }
-    else
-#endif
-    if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
+    else if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() )
     {
       if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
@@ -760,9 +760,5 @@
 
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
-#else
-    if(m_layerId > 0)
-#endif
     {
 #if RESTR_CHK
@@ -820,9 +816,5 @@
     //  Set reference list
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if(m_layerId ==  0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) )
-#else
-    if(m_layerId ==  0)
-#endif
     {
       pcSlice->setRefPicList( rcListPic);
@@ -832,9 +824,5 @@
 #endif
 #if REF_IDX_FRAMEWORK
-#if ZERO_NUM_DIRECT_LAYERS
     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
-#else
-    if(m_layerId > 0)
-#endif
     {
       m_pcEncTop->setILRPic(pcPic);
@@ -848,5 +836,5 @@
       {
         pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic());
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
         pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice));
 #endif
@@ -858,5 +846,9 @@
 #if REF_IDX_MFM
 #if M0457_COL_PICTURE_SIGNALING
+#if REMOVE_COL_PICTURE_SIGNALING
+      if( pcSlice->getMFMEnabledFlag() && pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0 )
+#else
       if( pcSlice->getMFMEnabledFlag() && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) )
+#endif
 #else
       if( pcSlice->getSPS()->getMFMEnabledFlag() )
@@ -3005,5 +2997,5 @@
 }
 
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
 TComPic* TEncGOP::getMotionPredIlp(TComSlice* pcSlice)
 {
Index: trunk/source/Lib/TLibEncoder/TEncGOP.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.h	(revision 345)
@@ -198,5 +198,5 @@
   }
   Void dblMetric( TComPic* pcPic, UInt uiNumSlices );
-#if M0457_COL_PICTURE_SIGNALING
+#if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING
   TComPic* getMotionPredIlp(TComSlice* pcSlice);
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 345)
@@ -83,7 +83,4 @@
 , m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
 , m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
-#if INTRA_BL
-, m_cIntraBLPredFlagSCModel   (1,              1,               NUM_INTRA_BL_PRED_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -134,7 +131,4 @@
   m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
   m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
-#if INTRA_BL
-  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
   m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
   m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
@@ -169,7 +163,4 @@
       curCost  = m_cCUSplitFlagSCModel.calcCost       ( curSliceType, qp, (UChar*)INIT_SPLIT_FLAG );
       curCost += m_cCUSkipFlagSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_SKIP_FLAG );
-#if INTRA_BL
-      curCost += m_cIntraBLPredFlagSCModel.calcCost   ( curSliceType, qp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
       curCost += m_cCUMergeFlagExtSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
       curCost += m_cCUMergeIdxExtSCModel.calcCost     ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
@@ -243,7 +234,4 @@
   m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
   m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
-#if INTRA_BL
-  m_cIntraBLPredFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_BL_PRED_FLAG );
-#endif
   m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
   m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
@@ -428,7 +416,5 @@
 {
   PartSize eSize         = pcCU->getPartitionSize( uiAbsPartIdx );
-#if INTRA_BL
-  assert( !pcCU->isIntraBL( uiAbsPartIdx ) );
-#endif
+
   if ( pcCU->isIntra( uiAbsPartIdx ) )
   {
@@ -1600,23 +1586,3 @@
 }
 
-#if INTRA_BL
-/** code intra_bl flag
- * \param pcCU
- * \param uiAbsPartIdx 
- * \returns Void
- */
-Void TEncSbac::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
-{
-  // get context function is here
-  UInt uiSymbol = pcCU->isIntraBL( uiAbsPartIdx ) ? 1 : 0;
-
-  UInt uiCtxIntraBL = pcCU->getCtxIntraBLFlag( uiAbsPartIdx ) ;
-  m_pcBinIf->encodeBin(uiSymbol, m_cIntraBLPredFlagSCModel.get( 0, 0, uiCtxIntraBL )); 
-
-  DTRACE_CABAC_VL( g_nSymbolCounter++ );
-  DTRACE_CABAC_T( "\tuiSymbol: ");
-  DTRACE_CABAC_V( uiSymbol );
-  DTRACE_CABAC_T( "\n");
-}
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 345)
@@ -132,8 +132,5 @@
   Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
-  
-#if INTRA_BL
-  Void codeIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#endif
+
   Void codePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
@@ -206,7 +203,4 @@
   ContextModel3DBuffer m_cTransformSkipSCModel;
   ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
-#if INTRA_BL
-  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
-#endif
 };
 
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 345)
@@ -906,11 +906,5 @@
         m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
       }
-#if INTRA_BL
-      m_pcEntropyCoder->encodeIntraBLFlag ( pcCU, 0, true );
-      if( pcCU->isIntraBL( 0 ) )
-      {
-        return;
-      }
-#endif      
+    
       m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
 
@@ -950,10 +944,5 @@
     }
   }
-#if INTRA_BL
-  if( pcCU->isIntraBL( 0 ) )
-  {
-    return;
-  }
-#endif
+
   if( bChroma )
   {
@@ -1055,11 +1044,4 @@
     pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
     //===== get prediction signal =====
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-    if(pcCU->isIntraBL ( uiAbsPartIdx ) )
-    {
-      pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride );
-    }
-    else
-#endif
     predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
     // save prediction 
@@ -1247,14 +1229,6 @@
 
     //===== get prediction signal =====
-#if INTRA_BL && !NO_RESIDUAL_FLAG_FOR_BLPRED
-  if(pcCU->isIntraBL ( uiAbsPartIdx ) )
-  {
-    pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId );
-  }
-  else
-#endif
-    {
-      predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
-    }
+    predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+
     // save prediction 
     if( default0Save1Load2 == 1 )
@@ -4567,9 +4541,5 @@
 Void TEncSearch::encodeResAndCalcRdInterCU( TComDataCU* pcCU, TComYuv* pcYuvOrg, TComYuv* pcYuvPred, TComYuv*& rpcYuvResi, TComYuv*& rpcYuvResiBest, TComYuv*& rpcYuvRec, Bool bSkipRes )
 {
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-  if ( pcCU->isIntra(0) && !pcCU->isIntraBL(0))
-#else
   if ( pcCU->isIntra(0) )
-#endif
   {
     return;
@@ -4682,18 +4652,4 @@
       pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) );
     }
-#if NO_RESIDUAL_FLAG_FOR_BLPRED 
-    else if(pcCU->getLayerId() > 0 && pcCU->isIntraBL(0) && uiZeroDistortion == uiDistortion) // all zeros
-    {
-      const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (pcCU->getDepth(0) << 1);
-      ::memset( pcCU->getTransformIdx()      , 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCbf( TEXT_LUMA )    , 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCbf( TEXT_CHROMA_U ), 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCbf( TEXT_CHROMA_V ), 0, uiQPartNum * sizeof(UChar) );
-      ::memset( pcCU->getCoeffY()            , 0, uiWidth * uiHeight * sizeof( TCoeff )      );
-      ::memset( pcCU->getCoeffCb()           , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 );
-      ::memset( pcCU->getCoeffCr()           , 0, uiWidth * uiHeight * sizeof( TCoeff ) >> 2 );
-      pcCU->setTransformSkipSubParts ( 0, 0, 0, 0, pcCU->getDepth(0) );
-    }
-#endif
     else
     {
@@ -4994,17 +4950,5 @@
       Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA];
       assert(scalingListType < 6);     
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-      if(pcCU->isIntraBL(uiAbsPartIdx) )
-      {
-        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
-      }
-      else
-      {
-        m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
-      }
-#else
       m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType );//this is for inter mode only
-#endif
-      
       const UInt uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
       pcResi->getLumaAddr( absTUPartIdx ), pcResi->getStride(), trWidth,trHeight );
@@ -5275,16 +5219,5 @@
         assert(scalingListType < 6);     
 
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-        if(pcCU->isIntraBL(uiAbsPartIdx) )
-        {
-          m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,DC_IDX, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
-        }
-        else
-        {
-          m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
-        }
-#else
         m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA,REG_DCT, pcResiCurrY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),  pcCoeffCurrY, trWidth, trHeight, scalingListType, true );
-#endif
 
         uiNonzeroDistY = m_pcRdCost->getDistPart(g_bitDepthY, m_pcQTTempTComYuv[uiQTTempAccessLayer].getLumaAddr( absTUPartIdx ), m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(),
@@ -5617,13 +5550,5 @@
 
   {
-#if INTRA_BL
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    assert( !pcCU->isIntra(uiAbsPartIdx) || pcCU->isIntraBL(uiAbsPartIdx));
-#else
-    assert( !pcCU->isIntra(uiAbsPartIdx) );
-#endif
-#else
     assert( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA );
-#endif
     if( bSubdivAndCbf )
     {
@@ -5859,23 +5784,8 @@
     }
     m_pcEntropyCoder->encodeSkipFlag ( pcCU, 0, true );
-#if INTRA_BL
-    if(m_pcEncCfg->getLayerId())
-    {
-      m_pcEntropyCoder->encodeIntraBLFlag(pcCU, 0, true);
-#if !NO_RESIDUAL_FLAG_FOR_BLPRED
-      assert( pcCU->isIntraBL( 0 ) == false );
-#endif
-    }
-#endif
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    if( !pcCU->isIntraBL(0))
-    {
-#endif
     m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
     m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
     m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
-#if NO_RESIDUAL_FLAG_FOR_BLPRED
-    }
-#endif
+
     Bool bDummy = false;
     m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
@@ -6295,58 +6205,3 @@
 #endif
 
-#if INTRA_BL
-Void 
-TEncSearch::estIntraBLPredQT( TComDataCU* pcCU, 
-                           TComYuv*    pcOrgYuv, 
-                           TComYuv*    pcPredYuv, 
-                           TComYuv*    pcResiYuv,
-                           TComYuv*    pcRecoYuv )
-{
-  UInt    uiDepth        = pcCU->getDepth(0);
-  UInt    uiOverallDistY = 0;
-  UInt    uiOverallDistC = 0;
-  
-  //===== set QP and clear Cbf =====
-  if ( pcCU->getSlice()->getPPS()->getUseDQP() == true)
-  {
-    pcCU->setQPSubParts( pcCU->getQP(0), 0, uiDepth );
-  }
-  else
-  {
-    pcCU->setQPSubParts( pcCU->getSlice()->getSliceQp(), 0, uiDepth );
-  }
-  
-  //===== init pattern for luma prediction =====
-  Bool bAboveAvail = false;
-  Bool bLeftAvail  = false;
-  pcCU->getPattern()->initPattern   ( pcCU, 0, 0 );
-  pcCU->getPattern()->initAdiPattern( pcCU, 0, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
-  
-  pcCU->setLumaIntraDirSubParts ( DC_IDX, 0, uiDepth );
-  
-  // set context models
-  if( m_bUseSBACRD )
-  {
-    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
-  }
-  
-  // determine residual for partition
-  Double dPUCost   = 0.0;
-  xRecurIntraCodingQT( pcCU, 0, 0, false, pcOrgYuv, pcPredYuv, pcResiYuv, uiOverallDistY, uiOverallDistC, false, dPUCost );
-  xSetIntraResultQT( pcCU, 0, 0, false, pcRecoYuv );
-  
-  //=== update PU data ====
-  pcCU->copyToPic( uiDepth, 0, 0 );
-   
-  //===== reset context models =====
-  if(m_bUseSBACRD)
-  {
-    m_pcRDGoOnSbacCoder->load(m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST]);
-  }
-
-  //===== set distortion (rate and r-d costs are determined later) =====
-  pcCU->getTotalDistortion() = uiOverallDistY + uiOverallDistC;
-}
-
-#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 345)
@@ -99,7 +99,4 @@
 #if SVC_EXTENSION
   TEncTop**       m_ppcTEncTop;
-#if INTRA_BL
-  TComPicYuv*     m_pcPicYuvRecBase;       ///< reconstructed base layer
-#endif
 #endif
   
@@ -192,14 +189,4 @@
                                   TComYuv*    pcRecoYuv,
                                   UInt        uiPreCalcDistC );
-  
-#if INTRA_BL
-  Void setBaseRecPic            ( TComPicYuv* pcPicYuvRecBase ) { m_pcPicYuvRecBase = pcPicYuvRecBase; }  
-  TComPicYuv* getBaseRecPic     ()                              { return m_pcPicYuvRecBase; }
-  Void  estIntraBLPredQT        ( TComDataCU* pcCU, 
-                                  TComYuv*    pcOrgYuv, 
-                                  TComYuv*    pcPredYuv, 
-                                  TComYuv*    pcResiYuv, 
-                                  TComYuv*    pcRecoYuv );
-#endif
   
   /// encoder estimation - inter prediction (non-skip)
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 345)
@@ -345,5 +345,5 @@
 
 #if JCTVC_M0259_LAMBDAREFINEMENT
-  if( rpcSlice->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
+  if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
   {
     Int nCurLayer = rpcSlice->getLayerId();
@@ -373,5 +373,5 @@
   weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
 #if JCTVC_M0259_LAMBDAREFINEMENT
-  if( rpcSlice->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
+  if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
   {
     dLambda *= 1.1;
@@ -503,5 +503,7 @@
 #if M0457_COL_PICTURE_SIGNALING
     rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
+#if !REMOVE_COL_PICTURE_SIGNALING
     rpcSlice->setAltColIndicationFlag(rpcSlice->getMFMEnabledFlag());
+#endif
 #endif
   }
@@ -979,8 +981,4 @@
   UInt uiTileStartLCU = 0;
   UInt uiTileLCUX     = 0;
-
-#if INTRA_BL
-  m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec(rpcPic->getLayerId()-1) : NULL);
-#endif
 
   Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 314)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 345)
@@ -886,5 +886,9 @@
   for( Int i = 0; i < getGOPSize()+m_extraRPSs; i++) 
   {
+#if FINAL_RPL_CHANGE_N0082
+    GOPEntry ge = m_ppcTEncTop[m_cSPS.getLayerId()]->getGOPEntry(i);
+#else
     GOPEntry ge = getGOPEntry(i);
+#endif
     rps = rpsList->getReferencePictureSet(i);
     rps->setNumberOfPictures(ge.m_numRefPics);
@@ -1204,9 +1208,5 @@
   if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 )
   {
-#if ZERO_NUM_DIRECT_LAYERS
     return (TEncTop *)getLayerEnc( 0 );
-#else
-    return NULL;
-#endif
   }
 
