Index: soft/giet_vm/applications/mjpeg/vld.c
===================================================================
--- soft/giet_vm/applications/mjpeg/vld.c	(revision 723)
+++ soft/giet_vm/applications/mjpeg/vld.c	(revision 736)
@@ -193,6 +193,7 @@
 }
 
-////////////////////////////////////////////
-void huff_tables_load( huff_tables_t*  huff,
+/////////////////////////////////////////////
+void huff_tables_load( uint32_t        index,
+                       huff_tables_t*  huff,
                        mwmr_bufio_t*   bufio )
 {
@@ -253,5 +254,6 @@
     mwmr_bufio_align( bufio );
     
-#if (DEBUG_VLD > 2) 
+#if (DEBUG_VLD > 3) 
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
 huff_tables_dump( huff , is_ac );
 #endif
@@ -312,8 +314,11 @@
 // unpack a 8*8 pixels block with 2 bytes per pixel
 //////////////////////////////////////////////////////////
-static int16_t vld_unpack_block( bitreader_t*      stream, 
-                                 mwmr_channel_t*   mwmr_out, 
-                                 huff_tables_t*    huff,
-                                 int16_t           prev_dc )
+static int16_t vld_unpack_block( uint32_t          index,     // cluster index
+                                 uint32_t          image,     // image index
+                                 uint32_t          block,     // block index
+                                 bitreader_t*      stream,    // input bit stream
+                                 mwmr_channel_t*   mwmr_out,  // output channel
+                                 huff_tables_t*    huff,      // Huffman Tables
+                                 int16_t           prev_dc )  // previous DC coef
 {
     uint32_t temp;
@@ -335,6 +340,8 @@
     buf[0]   = value + prev_dc;
 
-#if (DEBUG_VLD > 1)
-PRINTF("\nDC[0] = %d / reformat( %x , %d ) = %d\n", buf[0], temp , symbol , value )
+#if (DEBUG_VLD > 2)
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] : DC[0] = %d / reformat( %x , %d ) = %d\n",
+         index , buf[0], temp , symbol , value ) }
 #endif
 
@@ -348,6 +355,7 @@
         {
 
-#if (DEBUG_VLD > 1)
-PRINTF("EOB found at i = %d\n", i );
+#if (DEBUG_VLD > 2)
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] : EOB found at i = %d\n", index , i ) }
 #endif 
             break;
@@ -370,5 +378,7 @@
 
 #if (DEBUG_VLD > 2)
-PRINTF("AC[%d] = %d / reformat( %x , %d ) = %d\n", i , buf[i] , temp , cat , value )
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] : AC[%d] = %d / reformat( %x , %d ) = %d\n",
+         index , i , buf[i] , temp , cat , value ) }
 #endif
 
@@ -379,20 +389,23 @@
 
 #if (DEBUG_VLD > 1 )
-PRINTF("  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n"
-       "  %d  %d  %d  %d  %d  %d  %d  %d\n",
-       buf[0] , buf[1] , buf[2] , buf[3] , buf[4] , buf[5] , buf[6] , buf[7] ,
-       buf[8] , buf[9] , buf[10], buf[11], buf[12], buf[13], buf[14], buf[15],
-       buf[16], buf[17], buf[18], buf[19], buf[20], buf[21], buf[22], buf[23],
-       buf[24], buf[25], buf[26], buf[27], buf[28], buf[29], buf[30], buf[31],
-       buf[32], buf[33], buf[34], buf[35], buf[36], buf[37], buf[38], buf[39],
-       buf[40], buf[41], buf[42], buf[43], buf[44], buf[45], buf[46], buf[47],
-       buf[48], buf[49], buf[50], buf[51], buf[52], buf[53], buf[54], buf[55],
-       buf[56], buf[57], buf[58], buf[59], buf[60], buf[61], buf[62], buf[63])
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] completes block %d/%d in image %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n"
+         "  %d  %d  %d  %d  %d  %d  %d  %d\n",
+         index , block , nblocks_w*nblocks_h , image ,
+         buf[0] , buf[1] , buf[2] , buf[3] , buf[4] , buf[5] , buf[6] , buf[7] ,
+         buf[8] , buf[9] , buf[10], buf[11], buf[12], buf[13], buf[14], buf[15],
+         buf[16], buf[17], buf[18], buf[19], buf[20], buf[21], buf[22], buf[23],
+         buf[24], buf[25], buf[26], buf[27], buf[28], buf[29], buf[30], buf[31],
+         buf[32], buf[33], buf[34], buf[35], buf[36], buf[37], buf[38], buf[39],
+         buf[40], buf[41], buf[42], buf[43], buf[44], buf[45], buf[46], buf[47],
+         buf[48], buf[49], buf[50], buf[51], buf[52], buf[53], buf[54], buf[55],
+         buf[56], buf[57], buf[58], buf[59], buf[60], buf[61], buf[62], buf[63]) }
 #endif
 
@@ -428,5 +441,7 @@
     // giet_tty_alloc( 0 );
 
-    PRINTF("\n[MJPEG] thread VLD[%d] starts on P[%d,%d,%d]\n" , index, x, y ,p )
+    PRINTF("\n[MJPEG] thread VLD[%d] starts on P[%d,%d,%d] / trdid = %x\n",
+           index , x , y , p, (uint32_t)trdid_vld[index] )
+
 
     // initialise BUFIO for MWMR channel <in_data>
@@ -436,6 +451,7 @@
 
 #if (DEBUG_VLD > 1)
-PRINTF("\nVLD[%d] <in_data> : &mwmr = %x / &bufio = %x\n",
-       index , mwmr_in_data , &bufio_in_data )
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] <in_data> : &mwmr = %x / &bufio = %x\n",
+         index , mwmr_in_data , &bufio_in_data ) }
 #endif
 
@@ -446,6 +462,7 @@
 
 #if (DEBUG_VLD > 1)
-PRINTF("\nVLD[%d] <in_huff> : &mwmr = %x / &bufio = %x\n",
-       index , mwmr_in_huff , &bufio_in_huff )
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] <in_huff> : &mwmr = %x / &bufio = %x\n",
+         index , mwmr_in_huff , &bufio_in_huff ) }
 #endif
 
@@ -459,11 +476,12 @@
     {
         // load first Huffman Table from bufio_in_huff
-        huff_tables_load( &huff , &bufio_in_huff );
+        huff_tables_load( index, &huff , &bufio_in_huff );
 
         // load second Huffman Table from bufio_in_huff
-        huff_tables_load( &huff , &bufio_in_huff );
+        huff_tables_load( index, &huff , &bufio_in_huff );
 
 #if (DEBUG_VLD > 1)
-PRINTF("\nVLD[%d] load Huffman tables for image %d\n", index , image )
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] load Huffman tables for image %d\n", index , image ) }
 #endif
 
@@ -482,11 +500,19 @@
 
 #if (DEBUG_VLD > 1) 
-PRINTF("\nVLD[%d] uncompress block %d/%d in image %d\n", index, block, nblocks, image )
-#endif
-            prev_dc = vld_unpack_block( &stream , mwmr_out, &huff , prev_dc );
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] uncompress block %d/%d in image %d\n", index, block, nblocks, image ) }
+#endif
+            prev_dc = vld_unpack_block( index,
+                                        image,
+                                        block,
+                                        &stream, 
+                                        mwmr_out, 
+                                        &huff, 
+                                        prev_dc );
         }  // end for blocks
 
 #if DEBUG_VLD 
-PRINTF("\nVLD[%d] completes image %d at cycle %d\n", index , image , giet_proctime() )
+if ( (index == DEBUG_CLUSTER_INDEX) || (DEBUG_CLUSTER_INDEX == 0XFFFFFFFF) )
+{ PRINTF("\nVLD[%d] completes image %d at cycle %d\n", index , image , giet_proctime() ) }
 #endif
         image = image + x_size*y_size;
@@ -494,5 +520,5 @@
     }  // end while on images
 
-    giet_pthread_exit( "vld completed" );
+    giet_pthread_exit( "VLD completed" );
 
 }  // end vld()
