1 /*	$Id$ */
2 /*
3  * Copyright (c) 1994-1996 Sam Leffler
4  * Copyright (c) 1994-1996 Silicon Graphics, Inc.
5  * HylaFAX is a trademark of Silicon Graphics
6  *
7  * Permission to use, copy, modify, distribute, and sell this software and
8  * its documentation for any purpose is hereby granted without fee, provided
9  * that (i) the above copyright notices and this permission notice appear in
10  * all copies of the software and related documentation, and (ii) the names of
11  * Sam Leffler and Silicon Graphics may not be used in any advertising or
12  * publicity relating to the software without the specific, prior written
13  * permission of Sam Leffler and Silicon Graphics.
14  *
15  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  */
26 
27 #ifndef	_MemoryDecoder_
28 #define	_MemoryDecoder_
29 
30 #include "G3Decoder.h"
31 #include "Class2.h"
32 
33 class MemoryDecoder : public G3Decoder {
34 private:
35     u_char*	bp;
36     u_int	width;
37     u_int	byteWidth;
38     u_long	cc;
39     uint32	rows;
40     u_int	fillorder;
41     bool	is2D, isG4;
42     u_char*	endOfData;	// used by cutExtraRTC
43     u_int	nblanks;
44     tiff_runlen_t* runs;
45     u_char*	rowBuf;
46 
47     int		decodeNextByte();
48     void	invalidCode(const char* type, int x);
49     void	badPixelCount(const char* type, int got, int expected);
50     void	badDecodingState(const char* type, int x);
51 public:
52     MemoryDecoder(u_char* data, u_long cc);
53     MemoryDecoder(u_char* data, u_int wid, u_long n,
54                   u_int fillorder, bool twoDim, bool mmr);
55     ~MemoryDecoder();
current()56     u_char* current() { return bp; }
57     void fixFirstEOL();
58     u_char* cutExtraRTC();
59     u_char* cutExtraEOFB();
60     u_char* encodeTagLine (u_long* raster, u_int th, u_int slop);
61     u_char* convertDataFormat(const Class2Params& params);
62 
63     void scanPageForBlanks(u_int fillorder, const Class2Params& params);
getEndOfPage()64     const u_char* getEndOfPage()			{ return endOfData; }
getLastBlanks()65     u_int getLastBlanks()				{ return nblanks; }
getCC()66     u_long getCC()					{ return cc; }
getRows()67     uint32 getRows()					{ return rows; }
68 };
69 
70 #endif
71