5 #ifndef CHARLS_ENCODERSTRATEGY
6 #define CHARLS_ENCODERSTRATEGY
8 #include "dcmtk/ofstd/ofaptr.h"
36 void OnLineBegin(LONG cpixel,
void* ptypeBuffer, LONG pixelStride)
38 _processLine->NewLineRequested(ptypeBuffer, cpixel, pixelStride);
41 void OnLineEnd(LONG ,
void* , LONG ) { }
45 virtual size_t EncodeScan(
const void* pvoid,
void* pvoidOut,
size_t byteCount,
void* pvoidCompare) = 0;
49 void Init(BYTE* compressedBytes,
size_t byteCount)
53 _position = compressedBytes;
54 _compressedLength = byteCount;
58 void AppendToBitStream(LONG value, LONG length)
60 ASSERT(length < 32 && length >= 0);
62 ASSERT((_qdecoder.
get() == NULL) || (length == 0 && value == 0) ||( _qdecoder->ReadLongValue(length) == value));
67 int mask = (1 << (length)) - 1;
68 ASSERT((value | mask) == mask);
75 valcurrent = valcurrent | (value << bitpos);
78 valcurrent |= value >> -bitpos;
83 valcurrent |= value << bitpos;
93 AppendToBitStream(0, (bitpos - 1) % 8);
95 AppendToBitStream(0, bitpos % 8);
98 ASSERT(bitpos == 0x20);
103 for (LONG i = 0; i < 4; ++i)
111 *_position = BYTE(valcurrent >> 25);
112 valcurrent = valcurrent << 7;
114 _isFFWritten =
false;
118 *_position = BYTE(valcurrent >> 24);
119 valcurrent = valcurrent << 8;
121 _isFFWritten = *_position == 0xFF;
134 return _bytesWritten - (bitpos -32)/8;
138 inlinehint
void AppendOnesToBitStream(LONG length)
140 AppendToBitStream((1 << length) - 1, length);
151 unsigned int valcurrent;
153 size_t _compressedLength;
158 size_t _bytesWritten;