Index: trunk/AddOn/TAcq/brproc.cc
===================================================================
--- trunk/AddOn/TAcq/brproc.cc	(revision 3635)
+++ trunk/AddOn/TAcq/brproc.cc	(revision 3640)
@@ -26,5 +26,6 @@
 //---------------------------------------------------------------
 
-BRProcARaw2C::BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax)
+BRProcARaw2C::BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, 
+                           uint_4 step, uint_4 nmax, bool fgnotrl)
   :  memgr(mem) 
 {
@@ -34,4 +35,5 @@
   stop_ = false;	
   path_ = path;	
+  fgnotrl_ = fgnotrl;
 }
 
@@ -50,6 +52,11 @@
   setRC(1);	
   try {
-    Timer tm("BRProcARaw2C");
+    Timer tm("BRProcARaw2C", false);
     TimeStamp ts; 
+    BRPaqChecker pcheck(~fgnotrl_);  // Verification/comptage des paquets 
+    
+    size_t totnbytesout = 0;
+    size_t totnbytesproc = 0;
+
     cout << " BRProcARaw2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ 
 	 << " NMean=" << nmean_ << " Step=" << step_ << endl;	
@@ -62,5 +69,5 @@
 
 // Initialisation pour calcul FFT 
-    TVector< complex<r_4> > cfour;  // composant TF
+    TVector< complex<r_4> > cfour1;  // composant TF
     uint_4 paqsz = memgr.PaqSize();
     uint_4 procpaqsz = memgr.ProcPaqSize();
@@ -69,12 +76,16 @@
     vx = (r_4)(0.);
     FFTPackServer ffts;
-    ffts.FFTForward(vx, cfour);
-    TVector<r_4> spectreV1, spectreV2;
-  
-    spectreV1.ReSize(cfour.Size());
-    spectreV2.ReSize(cfour.Size());
+    ffts.FFTForward(vx, cfour1);
+    TVector< complex<r_4> > cfour2(cfour1.Size());
     
-    TVector< complex<r_4> > visiV12( cfour.Size() );
+    TVector<r_4> spectreV1(cfour1.Size());
+    TVector<r_4> spectreV2(cfour1.Size());
+    TVector< complex<r_4> > visiV12( cfour1.Size() );
 
+
+    fftwf_plan plan1 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), 
+                          (fftwf_complex*)cfour1.Data(), FFTW_ESTIMATE); 
+    fftwf_plan plan2 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), 
+                          (fftwf_complex*)cfour2.Data(), FFTW_ESTIMATE); 
 
     uint_4 ifile = 0;  			        
@@ -85,46 +96,47 @@
       Byte* buff = memgr.GetMemZone(mid);
       if (buff == NULL) {
-  	cout << " BRProcARaw2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
-  	break;		
+         cout << " BRProcARaw2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
+  	     break;		
       }
       Byte* procbuff = memgr.GetProcMemZone(mid);
       if (procbuff == NULL) {
-  	cout << " BRProcARaw2C::run()/ERROR memgr.GetProcMemZone(" << mid << ") -> NULL" << endl;
-  	break;	
+  	    cout << " BRProcARaw2C::run()/ERROR memgr.GetProcMemZone(" << mid << ") -> NULL" << endl;
+        break;	
       }
-      BRPaquet paq0(NULL, buff, paqsz); 
+
       for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) {
-  	BRPaquet paq(NULL, buff+i*paqsz, paqsz); 
-  	Byte min = 255;
-  	Byte max = 0;
- 
+  	    BRPaquet paq(NULL, buff+i*paqsz, paqsz); 
+        if (!pcheck.Check(paq)) continue;   // on ne traite que les paquets OK
+
 // Traitement voie 1  	    
-  	for(sa_size_t j=0; j<vx.Size(); j++) 
-  	  vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
-        fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
-        fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), coeff1, FFTW_ESTIMATE); 
-  	fftwf_execute(plan); 
-        //   ffts_.FFTForward(vx, cfour_);
-        complex<r_4>* zp1 = (complex<r_4>*)(coeff1);
+  	    for(sa_size_t j=0; j<vx.Size(); j++) 
+  	      vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
+//        fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
+  	    fftwf_execute(plan1); 
+//        complex<r_4>* zp1 = (complex<r_4>*)(coeff1);
+//        ffts.FFTForward(vx, cfour1);
         for(sa_size_t j=0; j<spectreV1.Size(); j++) 
-          spectreV1(j) += Zmod2(zp1[j]);
- 
+          spectreV1(j) += Zmod2(cfour1(j));
+        memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size());
 // Traitement voie 2  	    
-   	for(sa_size_t j=0; j<vx.Size(); j++) 
- 	  vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
-        fftwf_complex* coeff2 = (fftwf_complex*)(procbuff+i*procpaqsz+procpaqsz/2);
-        plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), coeff2, FFTW_ESTIMATE); 
-  	fftwf_execute(plan); 
-        //    ffts_.FFTForward(vx, cfour_);
-        complex<r_4>* zp2 = (complex<r_4>*)(coeff2);
+   	    for(sa_size_t j=0; j<vx.Size(); j++) 
+ 	      vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
+
+  	    fftwf_execute(plan2); 
+
         for(sa_size_t j=0; j<spectreV2.Size(); j++) 
-          spectreV2(j) += Zmod2(zp2[j]); 
+          spectreV2(j) += Zmod2(cfour2(j));  // Zmod2(zp2[j]); 
+        memcpy(procbuff+i*procpaqsz+procpaqsz/2, cfour2.Data(), sizeof(complex<r_4>)*cfour2.Size());
 
 // Calcul correlation (visibilite V1 * V2)
-        for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j];
+        for(sa_size_t j=0; j<visiV12.Size(); j++) 
+          visiV12(j)+=cfour1(j)*conj(cfour2(j));
+//        for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j];
+        nzm++;   
+        totnbytesproc += paq.DataSize();
+        totnbytesout += (2*sizeof(complex<r_4>)*cfour1.Size());
 
-        nzm++;
-      }
-      if ((nzm >= nmean_) ||(kmz==(nmax_-1))) {
+      } // Fin de boucle sur les paquets d'une zone
+      if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
         spectreV1 /= (r_4)(nzm);
         spectreV2 /= (r_4)(nzm);
@@ -135,5 +147,5 @@
         spectreV2.Info()["NPaqMoy"] = nzm;
         visiV12.Info()["NPaqMoy"] = nzm;
-	{
+	    {
     	sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
         POutPersist po(fname);
@@ -141,5 +153,5 @@
         po << PPFNameTag("specV2") << spectreV2; 
         po << PPFNameTag("visiV12") << visiV12; 
-	}
+	    }
         spectreV1 = (r_4)(0.);
         spectreV2 = (r_4)(0.);
@@ -149,8 +161,19 @@
 //        filog << ts << " :  proc file  " << fname << endl;		       
         cout << " BRProcARaw2C::run() created file  " << fname << endl;
-      }
+      }   
       
       memgr.FreeMemZone(mid, MemZS_ProcA);
-    }
+    }  // Fin de boucle sur les zones a traiter 
+  cout << " ------------------  BRProcARaw2C::run() END ----------------- " << endl;
+  ts.SetNow();
+  tm.SplitQ();
+  cout << "  TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= " 
+       << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" 
+       << " ProcDataOut=" <<  totnbytesout/(1024*1024) << " MB" << endl;    
+  cout << pcheck;
+  cout << " BRProcARaw2C::run()/Timing: \n"; 
+  tm.Print();
+  cout << " ---------------------------------------------------------- " << endl;
+    
   }
   catch (PException& exc) {
