Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1214)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1215)
@@ -2467,218 +2467,4 @@
 }
 
-#if CGS_3D_ASYMLUT
-Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
-{
-  UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum();
-  WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" );
-  for( UInt i = 0 ; i < uiNumRefLayers ; i++ )
-  {
-    WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" );
-  }
-
-  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
-  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
-  assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
-  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
-  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
-
-  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" );
-  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" );
-  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" );
-  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" );
-
-  assert( pc3DAsymLUT->getResQuantBit() < 4 );
-  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
-#if R0300_CGS_RES_COEFF_CODING
-  xFindDeltaBits( pc3DAsymLUT );
-  assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4);
-  WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" );
-#endif 
-
-  if( pc3DAsymLUT->getCurOctantDepth() == 1 )
-  {
-    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" );
-    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" );
-  }
-
-#if R0164_CGS_LUT_BUGFIX_CHECK
-  pc3DAsymLUT->xInitCuboids();
-#endif
-  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
-#if R0164_CGS_LUT_BUGFIX_CHECK
-  xCuboidsFilledCheck( false );
-  pc3DAsymLUT->display( false );
-#endif
-}
-
-Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
-{
-  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
-  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
-    WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
-  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
-  if( uiOctantSplit )
-  {
-    Int nHalfLength = nLength >> 1;
-    for( Int l = 0 ; l < 2 ; l++ )
-    {
-      for( Int m = 0 ; m < 2 ; m++ )
-      {
-        for( Int n = 0 ; n < 2 ; n++ )
-        {
-          xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
-        }
-      }
-    }
-  }
-  else
-  {
-#if R0300_CGS_RES_COEFF_CODING
-    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; 
-    nFLCbits = nFLCbits >= 0 ? nFLCbits : 0;
-#endif
-    for( Int l = 0 ; l < nYPartNum ; l++ )
-    {
-#if R0164_CGS_LUT_BUGFIX      
-      Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ;
-#endif
-      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
-      {
-#if R0164_CGS_LUT_BUGFIX 
-        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx );
-#else
-        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
-#endif
-        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
-        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
-        if( uiCodeVertex )
-        {
-#if R0300_CGS_RES_COEFF_CODING
-          xWriteParam( sRes.Y, nFLCbits );
-          xWriteParam( sRes.U, nFLCbits );
-          xWriteParam( sRes.V, nFLCbits );
-#else
-          xWriteParam( sRes.Y );
-          xWriteParam( sRes.U );
-          xWriteParam( sRes.V );
-#endif
-        }
-      }
-#if R0164_CGS_LUT_BUGFIX_CHECK
-      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
-#endif
-    }
-  }
-}
-
-#if R0300_CGS_RES_COEFF_CODING
-Void TEncCavlc::xWriteParam( Int param, UInt rParam)
-#else
-Void TEncCavlc::xWriteParam( Int param)
-#endif
-{
-#if !R0300_CGS_RES_COEFF_CODING
-  const UInt rParam = 7;
-#endif
-  Int codeNumber = abs(param);
-  WRITE_UVLC(codeNumber / (1 << rParam), "quotient");
-  WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder");
-  if (abs(param))
-    WRITE_FLAG( param <0, "sign");
-}
-
-#if R0300_CGS_RES_COEFF_CODING
-Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT )
-{
-  Int nDeltaBits; 
-  Int nBestDeltaBits = -1; 
-  Int nBestBits = MAX_INT; 
-  for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++)
-  {
-    Int nCurBits = 0;
-    xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits );
-    //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits); 
-    if(nCurBits < nBestBits)
-    {
-      nBestDeltaBits = nDeltaBits; 
-      nBestBits = nCurBits;
-    }
-  }
-
-  assert(nBestDeltaBits >=1 && nBestDeltaBits < 5);
-  pc3DAsymLUT->setDeltaBits(nBestDeltaBits); 
-}
-
-Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits )
-{
-  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
-  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
-    nCurBits ++; 
-  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
-  if( uiOctantSplit )
-  {
-    Int nHalfLength = nLength >> 1;
-    for( Int l = 0 ; l < 2 ; l++ )
-    {
-      for( Int m = 0 ; m < 2 ; m++ )
-      {
-        for( Int n = 0 ; n < 2 ; n++ )
-        {
-          xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits );
-        }
-      }
-    }
-  }
-  else
-  {
-    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ; 
-    nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
-    //printf("nFLCbits = %d\n", nFLCbits);
-
-    for( Int l = 0 ; l < nYPartNum ; l++ )
-    {
-      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
-      {
-        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
-
-        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
-        nCurBits++;
-        if( uiCodeVertex )
-        {
-          xCheckParamBits( sRes.Y, nFLCbits, nCurBits );
-          xCheckParamBits( sRes.U, nFLCbits, nCurBits );
-          xCheckParamBits( sRes.V, nFLCbits, nCurBits );
-        }
-      }
-    }
-  }
-}
-
-Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits)
-{
-  Int codeNumber = abs(param);
-  Int codeQuotient = codeNumber >> rParam;
-  Int qLen; 
-
-  UInt uiLength = 1;
-  UInt uiTemp = ++codeQuotient;
-    
-  while( 1 != uiTemp )
-  {
-    uiTemp >>= 1;
-    uiLength += 2;
-  }
-
-  qLen  = (uiLength >> 1);
-  qLen += ((uiLength+1) >> 1);
-
-  nBits += qLen; 
-  nBits += rParam; 
-  if (abs(param))
-    nBits++; 
-}
-#endif
-#endif
-
 Void TEncCavlc::codeVpsVuiBspHrdParams(TComVPS * const vps)
 {
@@ -2748,4 +2534,202 @@
 }
 
+
+#if CGS_3D_ASYMLUT
+Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
+{
+  UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum();
+  WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" );
+  for( UInt i = 0 ; i < uiNumRefLayers ; i++ )
+  {
+    WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" );
+  }
+
+  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
+  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
+  assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
+  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
+  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
+
+  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" );
+  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" );
+  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" );
+  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" );
+
+  assert( pc3DAsymLUT->getResQuantBit() < 4 );
+  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
+
+  xFindDeltaBits( pc3DAsymLUT );
+  assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4);
+  WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" );
+
+  if( pc3DAsymLUT->getCurOctantDepth() == 1 )
+  {
+    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" );
+    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" );
+  }
+
+#if R0164_CGS_LUT_BUGFIX_CHECK
+  pc3DAsymLUT->xInitCuboids();
+#endif
+  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
+#if R0164_CGS_LUT_BUGFIX_CHECK
+  xCuboidsFilledCheck( false );
+  pc3DAsymLUT->display( false );
+#endif
+}
+
+Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
+{
+  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
+  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
+    WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
+  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
+  if( uiOctantSplit )
+  {
+    Int nHalfLength = nLength >> 1;
+    for( Int l = 0 ; l < 2 ; l++ )
+    {
+      for( Int m = 0 ; m < 2 ; m++ )
+      {
+        for( Int n = 0 ; n < 2 ; n++ )
+        {
+          xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
+        }
+      }
+    }
+  }
+  else
+  {
+    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; 
+    nFLCbits = nFLCbits >= 0 ? nFLCbits : 0;
+
+    for( Int l = 0 ; l < nYPartNum ; l++ )
+    {
+#if R0164_CGS_LUT_BUGFIX      
+      Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ;
+#endif
+      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
+      {
+#if R0164_CGS_LUT_BUGFIX 
+        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx );
+#else
+        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
+#endif
+        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
+        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
+        if( uiCodeVertex )
+        {
+          xWriteParam( sRes.Y, nFLCbits );
+          xWriteParam( sRes.U, nFLCbits );
+          xWriteParam( sRes.V, nFLCbits );
+        }
+      }
+#if R0164_CGS_LUT_BUGFIX_CHECK
+      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
+#endif
+    }
+  }
+}
+
+Void TEncCavlc::xWriteParam( Int param, UInt rParam)
+{
+  Int codeNumber = abs(param);
+  WRITE_UVLC(codeNumber / (1 << rParam), "quotient");
+  WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder");
+  if (abs(param))
+    WRITE_FLAG( param <0, "sign");
+}
+
+Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT )
+{
+  Int nDeltaBits; 
+  Int nBestDeltaBits = -1; 
+  Int nBestBits = MAX_INT; 
+  for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++)
+  {
+    Int nCurBits = 0;
+    xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits );
+    //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits); 
+    if(nCurBits < nBestBits)
+    {
+      nBestDeltaBits = nDeltaBits; 
+      nBestBits = nCurBits;
+    }
+  }
+
+  assert(nBestDeltaBits >=1 && nBestDeltaBits < 5);
+  pc3DAsymLUT->setDeltaBits(nBestDeltaBits); 
+}
+
+Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits )
+{
+  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
+  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
+    nCurBits ++; 
+  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
+  if( uiOctantSplit )
+  {
+    Int nHalfLength = nLength >> 1;
+    for( Int l = 0 ; l < 2 ; l++ )
+    {
+      for( Int m = 0 ; m < 2 ; m++ )
+      {
+        for( Int n = 0 ; n < 2 ; n++ )
+        {
+          xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits );
+        }
+      }
+    }
+  }
+  else
+  {
+    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ; 
+    nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
+    //printf("nFLCbits = %d\n", nFLCbits);
+
+    for( Int l = 0 ; l < nYPartNum ; l++ )
+    {
+      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
+      {
+        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
+
+        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
+        nCurBits++;
+        if( uiCodeVertex )
+        {
+          xCheckParamBits( sRes.Y, nFLCbits, nCurBits );
+          xCheckParamBits( sRes.U, nFLCbits, nCurBits );
+          xCheckParamBits( sRes.V, nFLCbits, nCurBits );
+        }
+      }
+    }
+  }
+}
+
+Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits)
+{
+  Int codeNumber = abs(param);
+  Int codeQuotient = codeNumber >> rParam;
+  Int qLen; 
+
+  UInt uiLength = 1;
+  UInt uiTemp = ++codeQuotient;
+    
+  while( 1 != uiTemp )
+  {
+    uiTemp >>= 1;
+    uiLength += 2;
+  }
+
+  qLen  = (uiLength >> 1);
+  qLen += ((uiLength+1) >> 1);
+
+  nBits += qLen; 
+  nBits += rParam; 
+  if (abs(param))
+    nBits++; 
+}
+#endif //CGS_3D_ASYMLUT
+
 #endif //SVC_EXTENSION
 //! \}
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1214)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1215)
@@ -163,4 +163,5 @@
 #endif
   Void  codeVpsVuiBspHrdParams  (TComVPS * const);
+
 #if CGS_3D_ASYMLUT
 #if R0179_ENC_OPT_3DLUT_SIZE
@@ -174,13 +175,9 @@
   Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
 #endif
-#if R0300_CGS_RES_COEFF_CODING
   Void xWriteParam( Int param, UInt nFLCBits);
   Void xCheckParamBits( Int param, Int nFLCBits, Int & nCurBits);
   Void xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int &nCurBits); 
   Void xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT );
-#else
-  Void xWriteParam( Int param);
-#endif
-#endif
+#endif //CGS_3D_ASYMLUT
 #endif //SVC_EXTENSION
 
