1 | #include "array.h"
|
---|
2 | #include <math.h>
|
---|
3 | #include "genwproc.h"
|
---|
4 | #include "toimanager.h"
|
---|
5 | #include "pexceptions.h"
|
---|
6 | #include "ctimer.h"
|
---|
7 |
|
---|
8 | // -------------------------------------------------------------
|
---|
9 | // Class GenWindowTOIProcessor : generic processor with window
|
---|
10 | // -------------------------------------------------------------
|
---|
11 |
|
---|
12 | ////////////////////////////////////////////////////////////////
|
---|
13 | GenWindowTOIProcessor::GenWindowTOIProcessor(int_4 nbinput,int_4 nboutput
|
---|
14 | ,int_4 wsz, int_4 wstep, int_4 wsztot)
|
---|
15 | {
|
---|
16 | if(nbinput<1) throw ParmError("GenWindowTOIProcessor::Creator nbinput<1 !");
|
---|
17 | if(nboutput<0) nboutput=0;
|
---|
18 | if(wsz<2) throw ParmError("GenWindowTOIProcessor::Creator wsz<2 !");
|
---|
19 | if(wsz%2==0) {if(wsztot==wsz) wsztot++; wsz++;}
|
---|
20 | if(wstep<1) wstep=1;
|
---|
21 | if(wsztot<wsz) wsztot = 2*wsz;
|
---|
22 | // cas sans intersection entre 2 samples successifs
|
---|
23 | if(wstep>=wsz) wsztot = wsz;
|
---|
24 |
|
---|
25 | NbInput = nbinput;
|
---|
26 | NbOutput = nboutput;
|
---|
27 | WSize = wsz;
|
---|
28 | WStep = wstep;
|
---|
29 | WSizeTot = wsztot;
|
---|
30 |
|
---|
31 | CurWtIndex = -1;
|
---|
32 | SNbegin = SNend = StartSample = LastFilledSn = -1;
|
---|
33 | TotNsCount = TotDecalCount = 0;
|
---|
34 |
|
---|
35 | SetDbgLevel();
|
---|
36 | SetWSizeLCR();
|
---|
37 | SetDefaultValue();
|
---|
38 |
|
---|
39 | TVector<r_8> vr8(1); // CMV+RZ supprimer taille(1) apres correction de
|
---|
40 | TVector<int_8> vi8(1); // constructeur copie de TArray (taille nulle)
|
---|
41 |
|
---|
42 | int_4 k;
|
---|
43 | for(k=0;k<NbInput;k++) {
|
---|
44 | WDataIn.push_back(vr8);
|
---|
45 | WFlagIn.push_back(vi8);
|
---|
46 | WInFlg.push_back(false);
|
---|
47 | }
|
---|
48 | if(NbOutput)
|
---|
49 | for(k=0;k<NbOutput;k++) {
|
---|
50 | WDataOut.push_back(vr8);
|
---|
51 | WFlagOut.push_back(vi8);
|
---|
52 | WOutFlg.push_back(false);
|
---|
53 | WPutOutFlg.push_back(false);
|
---|
54 | WPutOutOwnVector.push_back(false);
|
---|
55 | OutSample.push_back(0);
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | GenWindowTOIProcessor::~GenWindowTOIProcessor()
|
---|
60 | {
|
---|
61 | }
|
---|
62 |
|
---|
63 | ////////////////////////////////////////////////////////////////
|
---|
64 | void GenWindowTOIProcessor::PrintStatus(ostream & os)
|
---|
65 | {
|
---|
66 | os<<"\n ------------------------------------------------------ \n"
|
---|
67 | <<" GenWindowTOIProcessor::PrintStatus() - ["<<NbInput<<","<<NbOutput<<"]"<<endl
|
---|
68 | <<" WSizeTot="<<WSizeTot<<" WSize="<<GetWSize()<<" WStep= "<<GetWStep()<<endl;
|
---|
69 | os<<" WindowLCR: "
|
---|
70 | <<" L=("<<W0Left<<","<<GetWSize('l')<<")"
|
---|
71 | <<" C=("<<W0Center<<","<<GetWSize('c')<<")"
|
---|
72 | <<" R=("<<W0Right<<","<<GetWSize('r')<<")"
|
---|
73 | <<endl;
|
---|
74 |
|
---|
75 | TOIProcessor::PrintStatus(os);
|
---|
76 | os<<"ProcessedSampleCount="<<ProcessedSampleCount()<<" NbDecal="<<TotDecalCount<<endl;
|
---|
77 | os<<"------------------------------------------------------ "<<endl;
|
---|
78 | }
|
---|
79 |
|
---|
80 | ////////////////////////////////////////////////////////////////
|
---|
81 | TVector<r_8> GenWindowTOIProcessor::GetWData(int_4 numtoi)
|
---|
82 | {
|
---|
83 | if(numtoi<0 || numtoi>=NbInput)
|
---|
84 | throw RangeCheckError("GenWindowTOIProcessor::GetWData : toi out of range !");
|
---|
85 | if(!WInFlg[numtoi])
|
---|
86 | throw ParmError("GenWindowTOIProcessor::GetWData : toi not connected!");
|
---|
87 | return (WDataIn[numtoi])(Range(StartWtIndex(),0,WSize));
|
---|
88 | }
|
---|
89 |
|
---|
90 | TVector<uint_8> GenWindowTOIProcessor::GetWFlag(int_4 numtoi)
|
---|
91 | {
|
---|
92 | if(numtoi<0 || numtoi>=NbInput)
|
---|
93 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlag : toi out of range !");
|
---|
94 | if(!WInFlg[numtoi])
|
---|
95 | throw ParmError("GenWindowTOIProcessor::GetWFlag : toi not connected!");
|
---|
96 | return (WFlagIn[numtoi])(Range(StartWtIndex(),0,WSize));
|
---|
97 | }
|
---|
98 |
|
---|
99 | r_8 * GenWindowTOIProcessor::GetWDataPointer(int_4 numtoi)
|
---|
100 | {
|
---|
101 | if(numtoi<0 || numtoi>=NbInput)
|
---|
102 | throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointer : toi out of range !");
|
---|
103 | if(!WInFlg[numtoi])
|
---|
104 | throw ParmError("GenWindowTOIProcessor::GetWDataPointer : toi not connected!");
|
---|
105 | return (WDataIn[numtoi].Data()+StartWtIndex());
|
---|
106 |
|
---|
107 | }
|
---|
108 |
|
---|
109 | uint_8 * GenWindowTOIProcessor::GetWFlagPointer(int_4 numtoi)
|
---|
110 | {
|
---|
111 | if(numtoi<0 || numtoi>=NbInput)
|
---|
112 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer : toi out of range !");
|
---|
113 | if(!WInFlg[numtoi])
|
---|
114 | throw ParmError("GenWindowTOIProcessor::GetWFlagPointer : toi not connected!");
|
---|
115 | return (WFlagIn[numtoi].Data()+StartWtIndex());
|
---|
116 | }
|
---|
117 |
|
---|
118 | void GenWindowTOIProcessor::GetData(int_4 numtoi, int_8 numsample, r_8 & data, uint_8 & flag)
|
---|
119 | {
|
---|
120 | if(numtoi<0 || numtoi>=NbInput)
|
---|
121 | throw RangeCheckError("GenWindowTOIProcessor::GetData : toi out of range !");
|
---|
122 | if(!WInFlg[numtoi])
|
---|
123 | throw ParmError("GenWindowTOIProcessor::GetData : toi not connected!");
|
---|
124 | int_8 k = numsample-GetWStartSample();
|
---|
125 | if ((k<0) || (k >= GetWSize()))
|
---|
126 | throw RangeCheckError("GenWindowTOIProcessor::GetData : numsample out of window!");
|
---|
127 | k += StartWtIndex();
|
---|
128 | data = (WDataIn[numtoi])(k);
|
---|
129 | flag = (WFlagIn[numtoi])(k);
|
---|
130 | }
|
---|
131 |
|
---|
132 | ////////////////////////////////////////////////////////////////
|
---|
133 | void GenWindowTOIProcessor::PutWData(int numtoi,int_8 numsample
|
---|
134 | ,TVector<r_8>& data,TVector<uint_8>& flag)
|
---|
135 | {
|
---|
136 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
137 | throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
|
---|
138 | if(!WOutFlg[numtoi])
|
---|
139 | throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!");
|
---|
140 | if(data.Size()!=flag.Size())
|
---|
141 | throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()!=flag.Size()!");
|
---|
142 | if(data.Size() == 0)
|
---|
143 | throw ParmError("GenWindowTOIProcessor::PutWFlag : data.Size()==0 !");
|
---|
144 | WDataOut[numtoi].Share(data);
|
---|
145 | WFlagOut[numtoi].Share(flag);
|
---|
146 | OutSample[numtoi] = numsample;
|
---|
147 | WPutOutFlg[numtoi] = true;
|
---|
148 | WPutOutOwnVector[numtoi] = false;
|
---|
149 | }
|
---|
150 |
|
---|
151 | void GenWindowTOIProcessor::PutWData(int numtoi,int_8 numsample
|
---|
152 | , r_8 data, uint_8 flag)
|
---|
153 | {
|
---|
154 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
155 | throw RangeCheckError("GenWindowTOIProcessor::PutWFlag : toi out of range !");
|
---|
156 | if(!WOutFlg[numtoi])
|
---|
157 | throw ParmError("GenWindowTOIProcessor::PutWFlag : toi not connected!");
|
---|
158 | if (!WPutOutOwnVector[numtoi]) {
|
---|
159 | WDataOut[numtoi].Realloc(1,BaseArray::SameVectorType,true);
|
---|
160 | WFlagOut[numtoi].Realloc(1,BaseArray::SameVectorType,true);
|
---|
161 | WPutOutOwnVector[numtoi] = true;
|
---|
162 | }
|
---|
163 | (WDataOut[numtoi])(0) = data;
|
---|
164 | (WFlagOut[numtoi])(0) = flag;
|
---|
165 | OutSample[numtoi] = numsample;
|
---|
166 | WPutOutFlg[numtoi] = true;
|
---|
167 | }
|
---|
168 |
|
---|
169 | /******* cmv routines
|
---|
170 | void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
|
---|
171 | ,TVector<r_8>& data,TVector<uint_8>& flag)
|
---|
172 | {
|
---|
173 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
174 | throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
|
---|
175 | if(!WOutFlg[numtoi])
|
---|
176 | throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
|
---|
177 | if(data.Size()!=flag.Size())
|
---|
178 | throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()!=flag.Size()!");
|
---|
179 | if(data.Size() == 0)
|
---|
180 | throw ParmError("GenWindowTOIProcessor::PutWData : data.Size()==0 !");
|
---|
181 |
|
---|
182 | for(int_4 k=0;k<data.Size(); k++)
|
---|
183 | putData(numtoi,numsample+k,data(k),flag(k));
|
---|
184 | }
|
---|
185 |
|
---|
186 | void GenWindowTOIProcessor::PutWData(int_4 numtoi,int_8 numsample
|
---|
187 | ,r_8 data, uint_8 flag)
|
---|
188 | {
|
---|
189 | if(numtoi<0 || numtoi>=NbOutput || NbOutput<=0)
|
---|
190 | throw RangeCheckError("GenWindowTOIProcessor::PutWData : toi out of range !");
|
---|
191 | if(!WOutFlg[numtoi])
|
---|
192 | throw ParmError("GenWindowTOIProcessor::PutWData : toi not connected!");
|
---|
193 |
|
---|
194 | putData(numtoi,numsample,data,flag);
|
---|
195 | }
|
---|
196 | *********/
|
---|
197 |
|
---|
198 | ////////////////////////////////////////////////////////////////
|
---|
199 | void GenWindowTOIProcessor::SetWSizeLCR(int_4 wszl,int_4 wszc,int_4 wszr)
|
---|
200 | // Fenetre a gauche, au centre et a droite du pixel central
|
---|
201 | // Selon la logique:
|
---|
202 | //-----------------------------------------------
|
---|
203 | // | pixel central
|
---|
204 | // |
|
---|
205 | // |
|
---|
206 | // | wszl | wszc | wszr |
|
---|
207 | // |
|
---|
208 | // | WSize |
|
---|
209 | //-----------------------------------------------
|
---|
210 | // wszc toujours impair SVP.
|
---|
211 | // Default: 0,0,0 : WSize/2,1,WSize/2
|
---|
212 | {
|
---|
213 | int_4 wsz2 = WSize/2;
|
---|
214 | // Default
|
---|
215 | if(wszl<=0 && wszc<=0 && wszr<=0) {
|
---|
216 | WSizeLeft = WSizeRight = wsz2; WSizeCenter = 1;
|
---|
217 | W0Left = 0; W0Center = wsz2; W0Right = wsz2+1;
|
---|
218 | return;
|
---|
219 | }
|
---|
220 |
|
---|
221 | // Fenetre centrale
|
---|
222 | if(wszc<=0) wszc = 1;
|
---|
223 | if(wszc%2==0) wszc++;
|
---|
224 | if(wszc>WSize) wszc = WSize;
|
---|
225 | WSizeCenter = wszc;
|
---|
226 | W0Center = wsz2 - WSizeCenter/2;
|
---|
227 |
|
---|
228 | // Fenetre de gauche
|
---|
229 | if(wszl<=0) wszl = WSize;
|
---|
230 | W0Left = W0Center - wszl;
|
---|
231 | if(W0Left<0) W0Left = 0;
|
---|
232 | WSizeLeft = W0Center - W0Left;
|
---|
233 | if(WSizeLeft<=0) WSizeLeft = 1;
|
---|
234 |
|
---|
235 | // Fenetre de droite
|
---|
236 | if(wszr<=0) wszr = WSize;
|
---|
237 | W0Right = W0Center + WSizeCenter;
|
---|
238 | if(W0Right>=WSize) W0Right = WSize - 1;
|
---|
239 | int_4 dum = W0Right + wszr; if(dum>WSize) dum = WSize;
|
---|
240 | WSizeRight = dum - W0Right;
|
---|
241 | if(WSizeRight<=0) WSizeRight = 1;
|
---|
242 | }
|
---|
243 |
|
---|
244 | TVector<r_8> GenWindowTOIProcessor::GetWData(char cw,int_4 numtoi)
|
---|
245 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
246 | {
|
---|
247 | if(numtoi<0 || numtoi>=NbInput)
|
---|
248 | throw RangeCheckError("GenWindowTOIProcessor::GetWData(lcr) : toi out of range !");
|
---|
249 | if(!WInFlg[numtoi])
|
---|
250 | throw ParmError("GenWindowTOIProcessor::GetWData(lcr) : toi not connected!");
|
---|
251 | return (WDataIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
|
---|
252 | }
|
---|
253 |
|
---|
254 | TVector<uint_8> GenWindowTOIProcessor::GetWFlag(char cw,int_4 numtoi)
|
---|
255 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
256 | {
|
---|
257 | if(numtoi<0 || numtoi>=NbInput)
|
---|
258 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlag(lcr) : toi out of range !");
|
---|
259 | if(!WInFlg[numtoi])
|
---|
260 | throw ParmError("GenWindowTOIProcessor::GetWFlag(lcr) : toi not connected!");
|
---|
261 | return (WFlagIn[numtoi])(Range(StartWtIndex(cw),0,GetWSize(cw)));
|
---|
262 | }
|
---|
263 |
|
---|
264 | r_8 * GenWindowTOIProcessor::GetWDataPointer(char cw,int_4 numtoi,int_4& n)
|
---|
265 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
266 | {
|
---|
267 | if(numtoi<0 || numtoi>=NbInput)
|
---|
268 | throw RangeCheckError("GenWindowTOIProcessor::GetWDataPointe(lcr)r : toi out of range !");
|
---|
269 | if(!WInFlg[numtoi])
|
---|
270 | throw ParmError("GenWindowTOIProcessor::GetWDataPointer(lcr) : toi not connected!");
|
---|
271 | n = GetWSize(cw);
|
---|
272 | return (WDataIn[numtoi].Data()+StartWtIndex(cw));
|
---|
273 |
|
---|
274 | }
|
---|
275 |
|
---|
276 | uint_8 * GenWindowTOIProcessor::GetWFlagPointer(char cw,int_4 numtoi,int_4& n)
|
---|
277 | // cr='l' fenetre de gauche, 'c' du centre, 'r' de droite, autre = tout
|
---|
278 | {
|
---|
279 | if(numtoi<0 || numtoi>=NbInput)
|
---|
280 | throw RangeCheckError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi out of range !");
|
---|
281 | if(!WInFlg[numtoi])
|
---|
282 | throw ParmError("GenWindowTOIProcessor::GetWFlagPointer(lcr) : toi not connected!");
|
---|
283 | n = GetWSize(cw);
|
---|
284 | return (WFlagIn[numtoi].Data()+StartWtIndex(cw));
|
---|
285 | }
|
---|
286 |
|
---|
287 | ////////////////////////////////////////////////////////////////
|
---|
288 | void GenWindowTOIProcessor::UserInit(int_8 kstart)
|
---|
289 | {
|
---|
290 | cout<<"GenWindowTOIProcessor::UserInit() Default implementation does nothing"<<endl;
|
---|
291 | }
|
---|
292 |
|
---|
293 | void GenWindowTOIProcessor::UserProc(int_8 ks)
|
---|
294 | {
|
---|
295 | cout<<"GenWindowTOIProcessor:UserProc() Default implementation does nothing"<<endl;
|
---|
296 | }
|
---|
297 |
|
---|
298 | void GenWindowTOIProcessor::UserEnd(int_8 kend)
|
---|
299 | {
|
---|
300 | cout<<"GenWindowTOIProcessor::UserEnd() Default implementation does nothing"<<endl;
|
---|
301 | }
|
---|
302 |
|
---|
303 | ////////////////////////////////////////////////////////////////
|
---|
304 | void GenWindowTOIProcessor::init()
|
---|
305 | {
|
---|
306 | cout << "GenWindowTOIProcessor::init" << endl;
|
---|
307 | char buff[64];
|
---|
308 | int_4 k;
|
---|
309 | for(k=0; k<NbInput; k++) {
|
---|
310 | sprintf(buff,"in%d", k);
|
---|
311 | declareInput(buff);
|
---|
312 | }
|
---|
313 | if(NbOutput)
|
---|
314 | for(k=0; k<NbOutput; k++) {
|
---|
315 | sprintf(buff,"out%d",k);
|
---|
316 | declareOutput(buff);
|
---|
317 | }
|
---|
318 | name = "GenWindowTOIProcessor";
|
---|
319 | // upExtra = 1; $CHECK a quoi ca sert EA?
|
---|
320 | }
|
---|
321 |
|
---|
322 | void GenWindowTOIProcessor::run()
|
---|
323 | {
|
---|
324 | // TOIManager* mgr = TOIManager::getManager();
|
---|
325 | SNbegin = getMinIn();
|
---|
326 | SNend = getMaxIn();
|
---|
327 |
|
---|
328 | if(SNend-SNbegin<WSize)
|
---|
329 | throw ParmError("GenWindowTOIProcessor::run : sne-snb<WSize !");
|
---|
330 |
|
---|
331 | // Allocation des tailles pour les vecteurs
|
---|
332 | int_4 kc, nc=0;
|
---|
333 | for(kc=0;kc<NbInput;kc++) {
|
---|
334 | if( !(WInFlg[kc]=checkInputTOIIndex(kc)) ) continue;
|
---|
335 | WDataIn[kc].ReSize(WSizeTot);
|
---|
336 | WFlagIn[kc].ReSize(WSizeTot);
|
---|
337 | nc++;
|
---|
338 | }
|
---|
339 | if(nc==0) {
|
---|
340 | cerr<<" GenWindowTOIProcessor::run() - No input TOI connected!"<<endl;
|
---|
341 | throw ParmError("GenWindowTOIProcessor::run() No input TOI connected!");
|
---|
342 | }
|
---|
343 | if(NbOutput)
|
---|
344 | for(kc=0;kc<NbOutput;kc++) WOutFlg[kc] = checkOutputTOIIndex(kc);
|
---|
345 |
|
---|
346 | // Lecture des samples et remplissage des vecteurs
|
---|
347 | cout<<"GenWindowTOIProcessor::run() SNRange="<<SNbegin<<" - "<<SNend<<endl;
|
---|
348 | try {
|
---|
349 | Timer tm("GenWindowTOIProcessor::run()");
|
---|
350 | int_4 wsz2=WSize/2;
|
---|
351 | int_8 ksend = SNbegin;
|
---|
352 | for(int_8 ks=SNbegin; ks<=SNend; ks+=WStep) {
|
---|
353 |
|
---|
354 | Remplissage(ks);
|
---|
355 | if(DbgLevel) test_avec_print(ks);
|
---|
356 |
|
---|
357 | if(ks == SNbegin) {UserInit(ks); Ecriture();}
|
---|
358 |
|
---|
359 | UserProc(ks);
|
---|
360 | Ecriture();
|
---|
361 |
|
---|
362 | ksend = ks;
|
---|
363 | TotNsCount++;
|
---|
364 | }
|
---|
365 | UserEnd(ksend); Ecriture();
|
---|
366 | cout << " GenWindowTOIProcessor::run() - End of processing " << endl;
|
---|
367 |
|
---|
368 | } catch(PException & exc) {
|
---|
369 | cerr<<"GenWindowTOIProcessor::run Catched Exception "<<(string)typeid(exc).name()
|
---|
370 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
371 | }
|
---|
372 | }
|
---|
373 |
|
---|
374 | ////////////////////////////////////////////////////////////////
|
---|
375 | void GenWindowTOIProcessor::Remplissage(int_8 ks)
|
---|
376 | // INPUT:
|
---|
377 | // ks : numero du sample CENTRAL
|
---|
378 | // samples : sn-ws/2 sn sn+ws/2
|
---|
379 | // fenetre : 0 ws/2+1 ws-1
|
---|
380 | // Cette routine doit etre utilisee dans une boucle:
|
---|
381 | // for(int k=???; k<???; k+=WStep) .....
|
---|
382 | // Dans le grand buffer WSizeTot il doit y avoir WSize samples
|
---|
383 | // entre ks1=ks-wsz2 et ks2=ks-wsz2 (ks1<=k<=ks2)
|
---|
384 | // En ENTREE de cette routine :
|
---|
385 | // - CurWtIndex = c'est l'index du tableau WSizeTot qui doit etre rempli
|
---|
386 | // (le dernier index qui a ete rempli par l'appel precedent
|
---|
387 | // est donc CurWtIndex-1)
|
---|
388 | // - LastFilledSn = c'est le dernier numero de sample qui a ete rempli
|
---|
389 | // dans le tableau WSizeTot par l'appel precedent
|
---|
390 | {
|
---|
391 | int_4 wsz2=WSize/2;
|
---|
392 |
|
---|
393 | // Numero de sample du premier element du tableau WSize
|
---|
394 | // (peut etre < SNbegin au debut)
|
---|
395 | StartSample = ks - wsz2;
|
---|
396 |
|
---|
397 | // on doit avoir les samples [ks1,ks2] dans le buffer
|
---|
398 | // (mais selon le step, certain peuvent etre deja remplis)
|
---|
399 | int_8 ks1 = ks-wsz2, ks2 = ks+wsz2;
|
---|
400 |
|
---|
401 | if(DbgLevel>1)
|
---|
402 | cout<<"DBG-GenWindowTOIProcessor::Remplissage("<<ks
|
---|
403 | <<") ["<<ks1<<","<<ks2<<"]"
|
---|
404 | <<" CurWtIndex="<<CurWtIndex<<" LastFilledSn="<<LastFilledSn<<endl;
|
---|
405 |
|
---|
406 | //--------------------------------------------------------
|
---|
407 | // Premier remplissage ????
|
---|
408 | // Gestion de la borne inferieure pour le permier sample
|
---|
409 | //--------------------------------------------------------
|
---|
410 | if(CurWtIndex<0) {
|
---|
411 | if(DbgLevel>1)
|
---|
412 | cout<<"DBG-GenWindowTOIProcessor::Remplissage 1ere fois"<<endl;
|
---|
413 | for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
|
---|
414 | if(!WInFlg[ntoi]) continue;
|
---|
415 | for(int_8 k=ks1, j=0; k<=ks2; k++, j++) {
|
---|
416 | if(k>=SNbegin && k<=SNend) {
|
---|
417 | getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
|
---|
418 | } else {
|
---|
419 | (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
|
---|
420 | }
|
---|
421 | }
|
---|
422 | }
|
---|
423 | CurWtIndex = ks2 - ks1 + 1;
|
---|
424 | LastFilledSn = ks2;
|
---|
425 | return;
|
---|
426 | }
|
---|
427 |
|
---|
428 | //--------------------------------------------------------
|
---|
429 | // Faut-il decaler ????
|
---|
430 | //--------------------------------------------------------
|
---|
431 | if(WStep>=WSize) {
|
---|
432 | // On ne decale pas puisque entre 2 appels a la routine
|
---|
433 | // il faut TOUT recharger (aucun sample deja charge n'est utile)
|
---|
434 | CurWtIndex = 0;
|
---|
435 | } else {
|
---|
436 | // Certains samples deja charges sont utiles
|
---|
437 | int_8 ifin = ks2 - LastFilledSn + CurWtIndex-1;
|
---|
438 | if(ifin >= WSizeTot) { // On decale
|
---|
439 | int_8 ideb = CurWtIndex-1 - LastFilledSn + ks1;
|
---|
440 | if(DbgLevel>1)
|
---|
441 | cout<<"DBG-GenWindowTOIProcessor::Remplissage ... Decalage ideb="<<ideb
|
---|
442 | <<" ifin="<<ifin<< endl;
|
---|
443 | for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
|
---|
444 | if(!WInFlg[ntoi]) continue;
|
---|
445 | for(int_4 i=ideb, j=0; i<CurWtIndex; i++, j++) {
|
---|
446 | (WDataIn[ntoi])(j) = (WDataIn[ntoi])(i);
|
---|
447 | (WFlagIn[ntoi])(j) = (WFlagIn[ntoi])(i);
|
---|
448 | }
|
---|
449 | }
|
---|
450 | CurWtIndex = CurWtIndex-ideb;
|
---|
451 | TotDecalCount++;
|
---|
452 | }
|
---|
453 | }
|
---|
454 |
|
---|
455 | // Remplissage des samples utiles pour ks
|
---|
456 | if(ks1<=LastFilledSn) ks1 = LastFilledSn+1;
|
---|
457 | if(DbgLevel>1)
|
---|
458 | cout<<"DBG-GenWindowTOIProcessor::Normal fill de ["<<ks1<<","<<ks2<<"]"<<endl;
|
---|
459 | for(int_4 ntoi=0; ntoi<NbInput; ntoi++) {
|
---|
460 | if(!WInFlg[ntoi]) continue;
|
---|
461 | for(int_4 k=ks1, j=CurWtIndex; k<=ks2; k++, j++) {
|
---|
462 | if(k>=SNbegin && k<=SNend) {
|
---|
463 | getData(ntoi,k,(WDataIn[ntoi])(j),(WFlagIn[ntoi])(j));
|
---|
464 | } else {
|
---|
465 | (WDataIn[ntoi])(j) = R8DefVal; (WFlagIn[ntoi])(j) = I8DefVal;
|
---|
466 | }
|
---|
467 | }
|
---|
468 | }
|
---|
469 | CurWtIndex += ks2 - ks1 + 1;
|
---|
470 | LastFilledSn = ks2;
|
---|
471 |
|
---|
472 | return;
|
---|
473 | }
|
---|
474 |
|
---|
475 | void GenWindowTOIProcessor::Ecriture()
|
---|
476 | {
|
---|
477 | int_8 maxlenout = 0;
|
---|
478 | int kc;
|
---|
479 | for(kc=0; kc<NbOutput; kc++)
|
---|
480 | if(WOutFlg[kc] && WPutOutFlg[kc] && (WDataOut[kc].Size() > maxlenout) )
|
---|
481 | maxlenout = WDataOut[kc].Size();
|
---|
482 |
|
---|
483 | for(int_8 k=0; k<maxlenout; k++) {
|
---|
484 | for(int kc=0; kc<NbOutput; kc++) {
|
---|
485 | if(!WOutFlg[kc]) continue;
|
---|
486 | if(!WPutOutFlg[kc]) continue;
|
---|
487 | if(k>=WDataOut[kc].Size()) continue;
|
---|
488 | putData(kc, k+OutSample[kc], (WDataOut[kc])(k), (WFlagOut[kc])(k));
|
---|
489 | }
|
---|
490 | }
|
---|
491 | for(kc=0; kc<NbOutput; kc++) WPutOutFlg[kc] = false;
|
---|
492 | }
|
---|
493 |
|
---|
494 | ////////////////////////////////////////////////////////////////
|
---|
495 | void GenWindowTOIProcessor::test_avec_print(int_8 ks)
|
---|
496 | {
|
---|
497 | if(DbgLevel<=0) return;
|
---|
498 |
|
---|
499 | int i,ii=0;
|
---|
500 | r_8 * datatot = WDataIn[0].Data();
|
---|
501 | uint_8 * flagtot = WFlagIn[0].Data();
|
---|
502 | r_8 * data = GetWDataPointer();
|
---|
503 | uint_8 * flag = GetWFlagPointer();
|
---|
504 | int_4 nl,nc,nr;
|
---|
505 | r_8 * datal = GetWDataPointer('l',nl);
|
---|
506 | uint_8 * flagl = GetWFlagPointer('l',nl);
|
---|
507 | r_8 * datac = GetWDataPointer('c',nc);
|
---|
508 | uint_8 * flagc = GetWFlagPointer('c',nc);
|
---|
509 | r_8 * datar = GetWDataPointer('r',nr);
|
---|
510 | uint_8 * flagr = GetWFlagPointer('r',nr);
|
---|
511 |
|
---|
512 | cout<<"-------- ks = "<<ks<<endl;
|
---|
513 |
|
---|
514 | if(DbgLevel>2) {
|
---|
515 | cout<<"datatot = ";
|
---|
516 | for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<datatot[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
517 | if(ii==0) cout<<endl;
|
---|
518 | cout<<"flagtot = ";
|
---|
519 | for(i=0;i<WSizeTot;i++) {ii=0; cout<<" "<<flagtot[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
520 | if(ii==0) cout<<endl;
|
---|
521 | }
|
---|
522 |
|
---|
523 | cout<<"data = ";
|
---|
524 | for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<data[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
525 | if(ii==0) cout<<endl;
|
---|
526 | cout<<"flag = ";
|
---|
527 | for(i=0;i<GetWSize();i++) {ii=0; cout<<" "<<flag[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
528 | if(ii==0) cout<<endl;
|
---|
529 |
|
---|
530 | if(DbgLevel>2) {
|
---|
531 | cout<<"datal = ";
|
---|
532 | for(i=0;i<nl;i++) {ii=0; cout<<" "<<datal[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
533 | if(ii==0) cout<<endl;
|
---|
534 | cout<<"flagl = ";
|
---|
535 | for(i=0;i<nl;i++) {ii=0; cout<<" "<<flagl[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
536 | if(ii==0) cout<<endl;
|
---|
537 | cout<<"datac = ";
|
---|
538 | for(i=0;i<nc;i++) {ii=0; cout<<" "<<datac[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
539 | if(ii==0) cout<<endl;
|
---|
540 | cout<<"flagc = ";
|
---|
541 | for(i=0;i<nc;i++) {ii=0; cout<<" "<<flagc[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
542 | if(ii==0) cout<<endl;
|
---|
543 | cout<<"datar = ";
|
---|
544 | for(i=0;i<nr;i++) {ii=0; cout<<" "<<datar[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
545 | if(ii==0) cout<<endl;
|
---|
546 | cout<<"flagr = ";
|
---|
547 | for(i=0;i<nr;i++) {ii=0; cout<<" "<<flagr[i]; if(i%10==9) {cout<<endl; ii=1;}}
|
---|
548 | if(ii==0) cout<<endl;
|
---|
549 | }
|
---|
550 | }
|
---|