Lines Matching defs:this
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
19 additional uses of the libraries contained in this release of SANE.
22 to produce an executable, this does not by itself cause the
33 those changes may be distributed with this exception intact.
36 whether to permit this exception to apply to your modifications.
37 If you do not wish that, delete this exception notice.
201 static TState ReadNextGrayLine(PTInstance this)
211 while (iWrite<this->state.cxMax) /* max 1 time in reality */
213 while (iWrite<this->state.cxMax &&
214 this->state.iBulkReadPos<this->state.cchBulk)
215 this->state.ppchLines[0][iWrite++] += /* add! */
216 this->state.pchBuf[this->state.iBulkReadPos++]<<4;
217 if (iWrite<this->state.cxMax) /* we need an additional chunk */
219 if (this->state.bLastBulk)
221 this->state.cchBulk=BulkReadBuffer(this,this->state.pchBuf,
224 this->state.cchBulk, this->state.iLine);
225 if (this->bWriteRaw)
226 fwrite(this->state.pchBuf,1,this->state.cchBulk,this->fhScan);
228 if (this->state.cchBulk!=USB_CHUNK_SIZE)
229 this->state.bLastBulk=true;
230 this->state.iBulkReadPos=0;
233 this->state.iLine++;
236 iRead<this->state.cxMax;
239 nInterpolator+=this->state.nFixAspect;
242 if (iWrite>=this->state.cchLineOut) continue;
244 if (this->mode==gray)
245 this->state.pchLineOut[iWrite++]=
246 this->state.ppchLines[0][iRead]>>4;
250 if (this->mode==line)
251 chBit=(this->state.ppchLines[0][iRead]<LINE_THRESHOLD);
254 short nError=this->state.ppchLines[0][iRead];
270 this->state.ppchLines[0][iRead+1]+=(nError>>2); /* 8/16 */
271 this->state.ppchLines[1][iRead+1]+=(nError>>1);
272 this->state.ppchLines[1][iRead] +=(nError>>2); /* 8/16 */
274 this->state.ppchLines[0][iRead+1]+=(nError*5)>>4;
275 this->state.ppchLines[1][iRead+1]+=(nError*8)>>4;
276 this->state.ppchLines[1][iRead] +=(nError*3)>>4;
281 if (iDot==8 && iWrite<this->state.cchLineOut)
283 this->state.pchLineOut[iWrite++]=chBits;
288 if (iDot && iWrite<this->state.cchLineOut)
289 this->state.pchLineOut[iWrite++]=chBits;
292 short *p=this->state.ppchLines[0];
293 this->state.ppchLines[0]=this->state.ppchLines[1];
294 this->state.ppchLines[1]=p;
295 memset(this->state.ppchLines[1],0,(this->state.cxMax+1)*sizeof(short));
307 TState StartScanGray(TInstance *this)
311 if (this->state.bScanning)
312 return SetError(this,SANE_STATUS_DEVICE_BUSY,"scan active");
313 memset(&(this->state),0,sizeof(TScanState));
314 this->state.ReadProc =ReadNextGrayLine;
316 switch (this->param.res)
324 GetAreaSize(this);
325 this->state.cyTotalPath = this->param.y/2;
326 DoJog(this,this->state.cyTotalPath);
328 this->state.cyTotalPath += this->param.cy/2; /* for jogging back */
335 RegWriteArray(this,R_ALL, NUM_SCANREGS, puchRegs); INST_ASSERT();
336 RegWrite(this,R_SPOS, 2,
337 this->param.x/2+this->calibration.xMargin); INST_ASSERT();
338 RegWrite(this,R_SLEN, 2, this->state.cyWindow); INST_ASSERT();
339 RegWrite(this,R_SWID, 2, this->state.cxWindow); INST_ASSERT();
340 RegWrite(this,R_STPS, 2, 0); INST_ASSERT();
343 RegWrite(this,0x41,1,0x01); /* gamma, gray */
344 RegWrite(this,0x40,1,0x20); /* FIFO at 0x08000 */
345 UploadGammaTable(this,0,this->agammaY); INST_ASSERT();
347 UploadGainCorrection(this, 0x2000);
351 this->state.pchBuf=malloc(USB_CHUNK_SIZE);
352 this->state.cBacklog=2;
353 this->state.ppchLines=calloc(this->state.cBacklog,sizeof(short *));
354 if (!this->state.pchBuf || !this->state.ppchLines)
355 return FreeState(this,SetError(this,
357 for (i=0; i<this->state.cBacklog; i++)
359 this->state.ppchLines[i]=calloc(this->state.cxMax+1,
361 if (!this->state.ppchLines[i])
362 return FreeState(this,SetError(this,
368 this->state.cchLineOut=(this->mode==gray)
369 ? this->state.cxPixel
370 : (this->state.cxPixel+7)/8;
372 this->state.pchLineOut = malloc(this->state.cchLineOut);
373 if (!this->state.pchLineOut)
374 return FreeState(this,SetError(this,
380 RegWrite(this,R_CTL, 1, 0x39); INST_ASSERT();
381 RegWrite(this,R_CTL, 1, 0x79); INST_ASSERT();
382 RegWrite(this,R_CTL, 1, 0xF9); INST_ASSERT();
384 this->state.bScanning = true;