Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1525)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1526)
@@ -790,4 +790,10 @@
   Bool*   cfg_bUseSAO[MAX_LAYERS];
 
+#if PER_LAYER_LOSSLESS
+  Bool*     cfg_TransquantBypassEnableFlag[MAX_LAYERS];
+  Bool*     cfg_CUTransquantBypassFlagForce[MAX_LAYERS];
+  CostMode* cfg_costMode[MAX_LAYERS];  
+#endif
+
   for( UInt layer = 0; layer < m_numLayers; layer++ )
   {
@@ -890,4 +896,10 @@
 
     cfg_bUseSAO[layer]              = &m_apcLayerCfg[layer]->m_bUseSAO;
+
+#if PER_LAYER_LOSSLESS
+    cfg_TransquantBypassEnableFlag[layer]   = &m_apcLayerCfg[layer]->m_TransquantBypassEnableFlag;
+    cfg_CUTransquantBypassFlagForce[layer]  = &m_apcLayerCfg[layer]->m_CUTransquantBypassFlagForce;
+    cfg_costMode[layer]                     = &m_apcLayerCfg[layer]->m_costMode;  
+#endif
   }
 
@@ -1420,7 +1432,13 @@
 #endif
 
+#if PER_LAYER_LOSSLESS
+  ("TransquantBypassEnableFlag%d",                    cfg_TransquantBypassEnableFlag,        false, m_numLayers, "transquant_bypass_enable_flag indicator in PPS")
+  ("CUTransquantBypassFlagForce%d",                   cfg_CUTransquantBypassFlagForce,       false, m_numLayers, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
+  ("CostMode%d",                                      cfg_costMode,            COST_STANDARD_LOSSY, m_numLayers, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
+#else
   ("TransquantBypassEnableFlag",                      m_TransquantBypassEnableFlag,                     false, "transquant_bypass_enable_flag indicator in PPS")
   ("CUTransquantBypassFlagForce",                     m_CUTransquantBypassFlagForce,                    false, "Force transquant bypass mode, when transquant_bypass_enable_flag is enabled")
   ("CostMode",                                        m_costMode,                         COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).")
+#endif
   ("RecalculateQPAccordingToLambda",                  m_recalculateQPAccordingToLambda,                 false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
   ("StrongIntraSmoothing,-sis",                       m_useStrongIntraSmoothing,                         true, "Enable strong intra smoothing for 32x32 blocks")
@@ -3099,4 +3117,8 @@
   Int& m_extraRPSs                            = m_apcLayerCfg[layerIdx]->m_extraRPSs;
   GOPEntry* m_GOPList                         = m_apcLayerCfg[layerIdx]->m_GOPList;
+
+#if PER_LAYER_LOSSLESS
+  Bool& m_CUTransquantBypassFlagForce         = m_apcLayerCfg[layerIdx]->m_CUTransquantBypassFlagForce;
+#endif
 #else
 Void TAppEncCfg::xCheckParameter()
@@ -3947,6 +3969,10 @@
   }
 #endif
-
+  
+#if PER_LAYER_LOSSLESS
+  xConfirmPara(!m_apcLayerCfg[layerIdx]->m_TransquantBypassEnableFlag && m_apcLayerCfg[layerIdx]->m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
+#else
   xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce, "CUTransquantBypassFlagForce cannot be 1 when TransquantBypassEnableFlag is 0");
+#endif
 
   xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
@@ -4163,4 +4189,8 @@
     UInt& m_RCCpbSize                       = m_apcLayerCfg[layerIdx]->m_RCCpbSize;
     Double& m_RCInitialCpbFullness          = m_apcLayerCfg[layerIdx]->m_RCInitialCpbFullness;
+#endif
+
+#if PER_LAYER_LOSSLESS
+    CostMode& m_costMode                    = m_apcLayerCfg[layerIdx]->m_costMode;
 #endif
 
@@ -4449,4 +4479,14 @@
   printf("PCM:%d ", (m_usePCM && (1<<m_uiPCMLog2MinSize) <= m_uiMaxCUWidth)? 1 : 0);
 
+#if PER_LAYER_LOSSLESS
+  if (m_apcLayerCfg[layer]->m_TransquantBypassEnableFlag && m_apcLayerCfg[layer]->m_CUTransquantBypassFlagForce)
+  {
+    printf("TransQuantBypassEnabled: =1");
+  }
+  else
+  {
+    printf("TransQuantBypassEnabled:%d ", (m_apcLayerCfg[layer]->m_TransquantBypassEnableFlag)? 1:0 );
+  }
+#else
   if (m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagForce)
   {
@@ -4457,4 +4497,5 @@
     printf("TransQuantBypassEnabled:%d ", (m_TransquantBypassEnableFlag)? 1:0 );
   }
+#endif
 
   printf("WPP:%d ", (Int)m_useWeightedPred);
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1525)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 1526)
@@ -466,7 +466,9 @@
 #endif
 
+#if !PER_LAYER_LOSSLESS
   Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
   Bool      m_CUTransquantBypassFlagForce;                    ///< if transquant_bypass_enable_flag, then, if true, all CU transquant bypass flags will be set to true.
   CostMode  m_costMode;                                       ///< Cost mode to use
+#endif
 
   Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 1525)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 1526)
@@ -100,4 +100,10 @@
   Bool      m_bUseSAO;
 
+#if PER_LAYER_LOSSLESS
+  Bool      m_TransquantBypassEnableFlag;
+  Bool      m_CUTransquantBypassFlagForce;
+  CostMode  m_costMode;
+#endif
+
   ScalingListMode m_useScalingListId;                         ///< using quantization matrix
   std::string m_scalingListFileName;                          ///< quantization matrix file name
Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1525)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1526)
@@ -534,4 +534,9 @@
 
     string&        m_colourRemapSEIFileRoot                     = m_apcLayerCfg[layer]->m_colourRemapSEIFileRoot;
+#if PER_LAYER_LOSSLESS
+    Bool&          m_TransquantBypassEnableFlag                 = m_apcLayerCfg[layer]->m_TransquantBypassEnableFlag;
+    Bool&          m_CUTransquantBypassFlagForce                = m_apcLayerCfg[layer]->m_CUTransquantBypassFlagForce;
+    CostMode&      m_costMode                                   = m_apcLayerCfg[layer]->m_costMode;
+#endif
 #endif
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1525)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1526)
@@ -48,4 +48,5 @@
 
 #if SVC_EXTENSION
+#define PER_LAYER_LOSSLESS               1
 #define SCALABLE_REXT                    1      ///< enabling scalable RExt profiles, for bit-depth greater than 10 consider to enable RExt__HIGH_BIT_DEPTH_SUPPORT
 
