KSquare Utilities
ScannerFileZLib3BitEncoded.h
Go to the documentation of this file.
1 #if !defined(_SCANNERFILEZLIBENCODED_)
2 #define _SCANNERFILEZLIBENCODED_
3 
4 #include "ScannerFile.h"
5 
6 namespace KKLSC
7 {
8  /**
9  *@class ScannerFileZLib3BitEncoded
10  *@brief Implements Zlib compression on 3bit pixel data.
11  *@details Each frame of 3bit data will be compressed using the ZLIB library.
12  *@code
13  * Following the header fields at the beginning of the file there will be blocks of data
14  * where the first byte will contain a op-code that describes how to decode the following
15  * bytes.
16  * All data will be stored in two byte records with the exception of text.
17  * each 2 byte record will start with a 3 bit OpCode and a one bit eol flag.
18  * the rest of the 12 bits will be organized depending on the opcode field.
19  *
20  * Byte 1 : Op-Code
21  * Bytes 2 thru 1 + x: y = Length of rest of block. High order followed by low order.
22  * Bytes 2 + x thru 1 + x + y: Data, to decoded as specified by op-code will be y bytes long
23  *
24  * Op-Code:
25  * 1: Text block up to 255 bytes long, x = 1, will be followed by "1" byte specifying text block length.
26  * 2: Text block up to 65,535 bytes long, x = 2, will be followed by "2" bytes (High order, low order) specifying
27  * text block length.
28  *
29  * Op-Codes 5, 6, 7 assume that frame size recorded is the same as defined in the header.
30  * 5: Zlib compressed data up to 65,535 bytes, x = 2, will be followed by "2" bytes (High order, low order) specifying
31  * compressed data length.
32  * 6: ZLib compressed data up to 16,777,215, x = 3, Will be followed by "3" bytes that specify length of compressed data.
33  * 7: ZLib compressed data up to 4,294,967,295, x = 4, Will be followed by "4" bytes that specify length of compressed data.
34  *
35  *
36  *@endcode
37  */
39  {
40  public:
42 
43  /** Constructor for opening file for reading */
44  ScannerFileZLib3BitEncoded (const KKStr& _fileName,
45  RunLog& _log
46  );
47 
48  /** Constructor for opening file for Writing */
49  ScannerFileZLib3BitEncoded (const KKStr& _fileName,
50  kkuint32 _pixelsPerScanLine,
51  kkuint32 _frameHeight,
52  RunLog& _log
53  );
54 
55  virtual
57 
58 
59  virtual Format FileFormat () const {return Format::sfZlib3BitEncoded;}
60 
61  virtual
62  void ScanRate (float _scanRate);
63 
64  virtual
65  void WriteTextBlock (const uchar* txtBlock,
66  kkuint32 txtBlockLen
67  );
68 
69  private:
70  void AllocateBuffers ();
71 
72  void ExpandBuffer (uchar*& buffer,
73  kkuint32& bufferSize,
74  kkuint32 bufferNewSize
75  );
76 
77  void ExpandBufferNoCopy (uchar*& buffer,
78  kkuint32& bufferSize,
79  kkuint32 bufferNewSize
80  );
81 
82  virtual
83  kkint64 SkipToNextFrame ();
84 
85  virtual
86  kkuint32 ReadBufferFrame ();
87 
88  virtual
89  void WriteBufferFrame ();
90 
91 
92  typedef uchar uint8;
93 
94  struct OpCodeRec1;
95  struct OpCodeRec2;
96  struct OpCodeRec5;
97  struct OpCodeRec6;
98  struct OpCodeRec7;
99  struct TwoByteRec;
100  struct ThreeByteRec;
101  struct FourByteRec;
102 
103  uchar* compBuffer;
104  kkuint32 compBufferLen;
105  kkuint32 compBufferSize;
106 
107  }; /* ScannerFileZLib3BitEncoded */
108 }
109 
110 #endif
ScannerFileZLib3BitEncoded(const KKStr &_fileName, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
__int64 kkint64
Definition: KKBaseTypes.h:90
ScannerFileZLib3BitEncoded(const KKStr &_fileName, RunLog &_log)
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
Contains Classes that are specific to Cameras physical characteristics.
Used for logging messages.
Definition: RunLog.h:49
ScannerFileZLib3BitEncoded * ScannerFile3BitEncodedPtr
virtual void WriteTextBlock(const uchar *txtBlock, kkuint32 txtBlockLen)
Implements Zlib compression on 3bit pixel data.