32 #include "dcmtk/config/osconfig.h"
33 #include "dcmtk/dcmdata/dcerror.h"
78 inline OFCondition decompress(
void *compressedData,
size_t compressedSize)
81 if (compressedSize == 0)
return EC_Normal;
86 if (compressedData == NULL)
fail_ = 1;
93 unsigned char *cp = OFstatic_cast(
unsigned char *, compressedData);
99 nbytes = OFstatic_cast(
unsigned char, 257 -
suspendInfo_);
111 nbytes = OFstatic_cast(
unsigned char, (
suspendInfo_ & 0x7f) + 1);
113 if (compressedSize < nbytes)
116 suspendInfo_ = OFstatic_cast(
unsigned char, nbytes - compressedSize - 1);
117 nbytes = OFstatic_cast(
unsigned char, compressedSize);
118 result = EC_StreamNotifyClient;
122 compressedSize -= nbytes;
127 while (compressedSize && (!
fail_))
138 nbytes = OFstatic_cast(
unsigned char, 257 - ch);
147 result = EC_StreamNotifyClient;
153 nbytes = OFstatic_cast(
unsigned char, (ch & 0x7f) + 1);
154 if (compressedSize < nbytes)
157 suspendInfo_ = OFstatic_cast(
unsigned char, nbytes - compressedSize - 1);
158 nbytes = OFstatic_cast(
unsigned char, compressedSize);
159 result = EC_StreamNotifyClient;
163 compressedSize -= nbytes;
169 if (
fail_) result = EC_CorruptedData;
195 if (
fail_)
return OFTrue;
else return OFFalse;
211 inline void replicate(
unsigned char ch,
unsigned char nbytes)
228 inline void literal(
unsigned char *cp,
unsigned char nbytes)
DcmRLEDecoder(size_t outputBufferSize)
constructor
this class implements an RLE decompressor conforming to the DICOM standard.
void clear()
resets the decoder object to newly constructed state.
void literal(unsigned char *cp, unsigned char nbytes)
this method expands a literal run
DcmRLEDecoder & operator=(const DcmRLEDecoder &)
private undefined copy assignment operator
OFBool fail() const
returns true if the RLE compressor has failed (out of memory or output buffer too small)...
unsigned char suspendInfo_
contains suspension information.
int fail_
this flag indicates a failure of the RLE codec.
void * getOutputBuffer() const
returns pointer to the output buffer
size_t offset_
contains the number of bytes already written to outputBuffer_.
~DcmRLEDecoder()
destructor
unsigned char * outputBuffer_
this member points to a block of size outputBufferSize_ (unless fail_ is true).
size_t size() const
returns the number of bytes written to the output buffer
void replicate(unsigned char ch, unsigned char nbytes)
this method expands a replicate run
General purpose class for condition codes.
size_t outputBufferSize_
size of output buffer, in bytes