AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2010.05.11 16:59 "[Tiff] Combining multiple G4 images into a single output image", by Richard Nolde
2010.05.11 07:00 "[Tiff] Merging multiple Group4 compressed TIFF files", by Oliver Geisen
2010.05.11 15:22 "Re: [Tiff] Merging multiple Group4 compressed TIFF files", by Bob Friesenhahn
2010.05.11 17:33 "Re: [Tiff] Combining multiple G4 images into a single output image", by Oliver Geisen
2010.05.11 19:15 "Re: [Tiff] Combining multiple G4 images into a single output image", by Olivier Paquet
2010.05.12 16:47 "Re: [Tiff] Combining multiple G4 images into a single output image", by Bob Friesenhahn

2010.05.11 19:15 "Re: [Tiff] Combining multiple G4 images into a single output image", by Olivier Paquet

2010/5/11 Oliver Geisen <oliver.geisen@kreisbote.de>:

bit shifting. I'm not really shure what it means to do such massive shifting operations. It really depends on the size of the images to be

It really means nothing if you put a minimal amount of work into the implementation (ie. process more than one bit at a time). You are far more likely to be limited by file I/O and decompression/compression. For example, on a 2.2 GHz athlon 64 I can shift almost 1 GB/s in-place (a little less if copying) with this basic code:

    unsigned *buffer =...
    unsigned prev = 0;
    for( unsigned i = 0; i < n; ++i )
    {
        unsigned b = buffer[i];
        buffer[i] = prev | (b >> rshift);
        prev = b << (32 - rshift);
    }

which by the way does not work if rshift == 0 or rshift >= 32. You will need to do a little patching on the edges of the image but it won't matter in the overall run time. By the way, for those edges, you can generate a mask for the leftmost (or rightmost) n bits easily with:

unsigned rightmost = (1u << n) - 1u; /* for n 0 to 31 */ unsigned leftmost = INT_MIN >> (n - 1); /* for n 1 to 32 */

That will let you copy only some bits in a word easily. Note that all that code assumes a 32-bit unsigned type. You should use whatever typedef your environment provides to ensure you get that (eg. uint32_t or similar).

Olivier