Re: image buffering

David Mosberger-Tang (davidm@azstarnet.com)
Wed, 28 May 1997 09:24:54 -0700

Hi Mathias,

>>>>> On Wed, 28 May 1997 17:52:14 +0059 (MDT), "Mathias Weigt (Stud. 94)" <p5iba@medchem2.pharmazie.uni-halle.de> said:

Mathias> Servus! In the last postings the buffering of images was
Mathias> mentioned. I thought a little bit and like to know more
Mathias> about it. In scanimage.c must_buffer is set for handheld
Mathias> scanners (parm.lines<0) or for three pass scanning (either
Mathias> of the three frames). I think scanning a full size image
Mathias> (14 x 8.5 inch) at 600 dpi will cost 125 Mbyte of memory. I
Mathias> don`t have such an amount of memory (only if I double my
Mathias> swapspace) and I think not many people on Linux have.
Mathias> David mentioned that a temporary file wouldn`t be a nice
Mathias> solution. Here is my question: Why not ? Shouldn't it be
Mathias> possible to write three temporary files for the red, green
Mathias> and blue frame (of course not as image but the red bytes in
Mathias> a line...) so that each will consume 1/3 of the entire
Mathias> image in space? After the last pass the picture can be put
Mathias> together from those three files and send to stdout or file.

It's certainly possible. Michael suggested using mmap'ing to provide
backing store in the filesystem instead of the swap-space. Of the two
solutions, I think mmap is technically preferable when there is plenty
memory available. On the other hand, mmap is still quite a portability
nightmare, so using regular files might still be better, overall.

However, the real issue is: what if you have tons of memory/swap-space
but not much free diskspace? Don't say that doesn't happen. My
system has 64MB of RAM and much more swap-space, yet I'm hard-pressed
to find 256MB of free space on any of the filesystems... So, in that
case, using temporary files would prevent me from acquiring the images
(since you'd need 128MB of temporary space plus 128MB to store the
resulting image).

To me, it seems like we should use memory/swap-space when it looks
like the image might fit in the available memory/swap-space and use
temporary files otherwise. E.g., on Linux, we could base this
decision on MemTotal: as reported in /proc/meminfo.

--david

--
Source code, list archive, and docs: http://www.azstarnet.com/~axplinux/sane/
To unsubscribe: mail -s unsubscribe sane-devel-request@listserv.azstarnet.com