Index: /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.cpp	(revision 851)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.cpp	(revision 852)
@@ -17,6 +17,7 @@
   m_pCuboid = NULL;
   m_nResQuanBit = 0;
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
   m_pCuboidExplicit = NULL;
+  m_pCuboidFilled = NULL;
 #endif
 }
@@ -60,6 +61,7 @@
   xAllocate3DArray( m_pCuboid , m_nYSize , m_nUSize , m_nVSize );
 
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
   xAllocate3DArray( m_pCuboidExplicit , m_nYSize , m_nUSize , m_nVSize );
+  xAllocate3DArray( m_pCuboidFilled   , m_nYSize , m_nUSize , m_nVSize );
 #endif
 }
@@ -68,6 +70,7 @@
 {
   xFree3DArray( m_pCuboid );
-#if R0164_CGS_LUT_BUGFIX
-  xFree3DArray( m_pCuboidExplicit  );
+#if R0164_CGS_LUT_BUGFIX_CHECK
+  xFree3DArray( m_pCuboidExplicit );
+  xFree3DArray( m_pCuboidFilled   );
 #endif
 }
@@ -345,5 +348,5 @@
 }
 
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
 Void TCom3DAsymLUT::xInitCuboids( )
 {
@@ -356,4 +359,5 @@
       { 
         m_pCuboidExplicit[yIdx][uIdx][vIdx] = false;
+        m_pCuboidFilled[yIdx][uIdx][vIdx]   = false;
       }
     }
@@ -361,20 +365,20 @@
 }
 
-Void TCom3DAsymLUT::xCuboidsExplicitCheck( Int yIdx , Int uIdx , Int vIdx )
-{
-  if ( m_pCuboidExplicit[yIdx][uIdx][vIdx] == false )
+Void TCom3DAsymLUT::xCuboidsFilledCheck( Int yIdx , Int uIdx , Int vIdx )
+{
+  if ( m_pCuboidFilled[yIdx][uIdx][vIdx] == false )
   {
     if( yIdx > 0) 
-      assert ( m_pCuboidExplicit[yIdx-1][uIdx][vIdx] );
+      assert ( m_pCuboidFilled[yIdx-1][uIdx][vIdx] );
 
     for ( Int nVertexIdx=0 ; nVertexIdx<4 ; nVertexIdx++ )
       m_pCuboid[yIdx][uIdx][vIdx].P[nVertexIdx] = yIdx == 0 ? xGetCuboidVertexPredA( yIdx , uIdx , vIdx , nVertexIdx ): xGetCuboidVertexPredAll( yIdx , uIdx , vIdx , nVertexIdx );
 
-    m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ;
-  }
-}
-
-
-Void TCom3DAsymLUT::xCuboidsExplicitCheck( Bool bDecode )
+    m_pCuboidFilled[yIdx][uIdx][vIdx] = true ;
+  }
+}
+
+
+Void TCom3DAsymLUT::xCuboidsFilledCheck( Bool bDecode )
 {
   Int ySize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
@@ -388,7 +392,7 @@
       { 
         if ( bDecode )
-          xCuboidsExplicitCheck( yIdx , uIdx , vIdx );
-
-        assert( m_pCuboidExplicit[yIdx][uIdx][vIdx] );
+          xCuboidsFilledCheck( yIdx , uIdx , vIdx );
+
+        assert( m_pCuboidFilled[yIdx][uIdx][vIdx] );
       }
     }
@@ -415,4 +419,52 @@
 #endif
 
-#endif
-
+#if R0164_CGS_LUT_BUGFIX_CHECK
+Void  TCom3DAsymLUT::display( Bool bFilled )
+{
+  Int ySize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
+  Int uSize = 1 << getCurOctantDepth();
+  Int vSize = 1 << getCurOctantDepth();
+  Int vIdx=0;
+
+  printf("\n");
+  printf("3DLut Explicit flag:\n");
+  for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
+  {
+    for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
+    {
+      printf("%d\t", m_pCuboidExplicit[yIdx][uIdx][vIdx] );
+    }
+    printf("\n");
+  }
+
+  printf("3DLut values (explicit):\n");
+  for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
+  {
+    for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
+    {
+      if ( m_pCuboidExplicit[yIdx][uIdx][vIdx] )  printf("%d\t", m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
+      else                                        printf("?\t", m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
+    }
+    printf("\n");
+  }
+
+  printf("3DLut values (all):\n");
+  for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
+  {
+    for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
+    {
+      if ( bFilled ) {
+        if ( m_pCuboidFilled[yIdx][uIdx][vIdx] )  printf("%d\t"  , m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
+        else                                      printf("unk\t" , m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
+      }
+      else
+        printf("%d\t"  , m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
+    }
+    printf("\n");
+  }
+
+}
+#endif
+
+#endif
+
Index: /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h	(revision 851)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h	(revision 852)
@@ -74,9 +74,11 @@
   SYUVP getCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx );
   Void  setCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx , Int deltaY , Int deltaU , Int deltaV );
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
   Void  xInitCuboids( );
-  Void  xCuboidsExplicitCheck( Int yIdx , Int uIdx , Int vIdx );
-  Void  xCuboidsExplicitCheck( Bool bDecode );
-  Void  xSetExplicit( Int yIdx , Int uIdx , Int vIdx )  { m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ;}
+  Void  xCuboidsFilledCheck( Int yIdx , Int uIdx , Int vIdx );
+  Void  xCuboidsFilledCheck( Bool bDecode );
+  Void  display( Bool bFilled=true );
+  Void  xSetExplicit( Int yIdx , Int uIdx , Int vIdx )  { m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ; xSetFilled(yIdx,uIdx,vIdx); }
+  Void  xSetFilled( Int yIdx , Int uIdx , Int vIdx )    { m_pCuboidFilled[yIdx][uIdx][vIdx] = true ; }
 #endif
 
@@ -114,6 +116,7 @@
   Int   m_nAdaptCThresholdV;
 #endif
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
   Bool  *** m_pCuboidExplicit;
+  Bool  *** m_pCuboidFilled;
 #endif
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 851)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 852)
@@ -103,4 +103,5 @@
 #define R0151_CGS_3D_ASYMLUT_IMPROVE     1      ///< JCTVC-R0151: Non-uniform chroma partitioning and improved LUT coefficient coding
 #define R0164_CGS_LUT_BUGFIX             1      ///< JCTVC-R0164: Bug fix with LUT syntax
+#define R0164_CGS_LUT_BUGFIX_CHECK       0      ///< JCTVC-R0164: Add traces explicitly/non-explicitly encoded vertices and check if 3DLUT is correctly filled
 #define R0179_CGS_SIZE_8x1x1             1      ///< JCTVC-R0179: allow CGS LUT size to be 8x1x1 as well 
 #define R0300_CGS_RES_COEFF_CODING       1      ///< JCTVC-R0300: improved residual coefficient coding for R0151
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 851)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 852)
@@ -4154,10 +4154,16 @@
   pc3DAsymLUT->setResQuantBit( uiResQaunBit );
 
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
   pc3DAsymLUT->xInitCuboids();
 #endif
   xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
 #if R0164_CGS_LUT_BUGFIX
-  pc3DAsymLUT->xCuboidsExplicitCheck( true );
+#if R0164_CGS_LUT_BUGFIX_CHECK
+  printf("============= Before 'xCuboidsFilledCheck()': ================\n");
+  pc3DAsymLUT->display();
+  pc3DAsymLUT->xCuboidsFilledCheck( false );
+  printf("============= After 'xCuboidsFilledCheck()': =================\n");
+  pc3DAsymLUT->display();
+#endif
 #endif
 }
@@ -4219,12 +4225,35 @@
 #if R0164_CGS_LUT_BUGFIX
         pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV );
+        for (Int m = 1; m < (1<<shift); m++) {
+          pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 );
+#if R0164_CGS_LUT_BUGFIX_CHECK
+          pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx );
+#endif
+        }
 #else
         pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV );
 #endif
       }
+#if R0164_CGS_LUT_BUGFIX_CHECK
+      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
+#endif
+    }
 #if R0164_CGS_LUT_BUGFIX
-      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
-#endif
-    }
+    for ( Int u=0 ; u<nLength ; u++ ) {
+      for ( Int v=0 ; v<nLength ; v++ ) {
+        if ( u!=0 || v!=0 ) {
+          for ( Int y=0 ; y<nLength*nYPartNum ; y++ ) {
+            for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
+            {
+              pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 );
+#if R0164_CGS_LUT_BUGFIX_CHECK
+              pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v );
+#endif
+            }
+          }
+        }
+      }
+    }
+#endif
   }
 }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 851)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 852)
@@ -2874,10 +2874,11 @@
 #endif
 
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
   pc3DAsymLUT->xInitCuboids();
 #endif
   xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
-#if R0164_CGS_LUT_BUGFIX
-  pc3DAsymLUT->xCuboidsExplicitCheck( false );
+#if R0164_CGS_LUT_BUGFIX_CHECK
+  xCuboidsFilledCheck( false );
+  pc3DAsymLUT->display( false );
 #endif
 }
@@ -2942,5 +2943,5 @@
         }
       }
-#if R0164_CGS_LUT_BUGFIX
+#if R0164_CGS_LUT_BUGFIX_CHECK
       pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
 #endif
