32 #include "dcmtk/config/osconfig.h"
33 #include "dcmtk/ofstd/oflist.h"
35 #define INCLUDE_CSTRING
36 #include "dcmtk/ofstd/ofstdinc.h"
38 #define DcmRLEEncoder_BLOCKSIZE 16384
52 virtual void write(
const unsigned char *buf,
size_t bufsize) =0;
104 inline void add(
unsigned char ch)
181 inline void add(
const unsigned char *buf,
size_t bufcount)
185 while (bufcount--)
add(*buf++);
259 if (
pad_ && (result & 1)) result++;
268 if (
fail_)
return OFTrue;
else return OFFalse;
275 inline void write(
void *target)
const
277 if ((!
fail_) && target)
279 unsigned char *current = NULL;
280 unsigned char *target8 = OFstatic_cast(
unsigned char *, target);
282 OFListConstIterator(
unsigned char *) last =
blockList_.
end();
283 while (first != last)
286 memcpy(target8, current, DcmRLEEncoder_BLOCKSIZE);
287 target8 += DcmRLEEncoder_BLOCKSIZE;
313 OFListConstIterator(
unsigned char *) last =
blockList_.
end();
314 while (first != last)
316 os.
write(*first, DcmRLEEncoder_BLOCKSIZE);
346 inline void move(
size_t numberOfBytes)
349 while (i < numberOfBytes)
351 if (
offset_ == DcmRLEEncoder_BLOCKSIZE)
void add(const unsigned char *buf, size_t bufcount)
this method adds a block of bytes to the byte stream to be compressed with the RLE compressor...
OFIterator< T > erase(OFIterator< T > position)
removes the element at the given position from the list.
size_t size() const
returns the size of compressed RLE stream in bytes.
unsigned char * currentBlock_
this member points to a block of size DcmRLEEncoder_BLOCKSIZE (unless fail_ is true).
DcmRLEEncoder(int doPad)
default constructor
void write(DcmEncoderOutputStream &os) const
copies the compressed RLE byte stream into an output stream
void move(size_t numberOfBytes)
this method moves the given number of bytes from buff_ to currentBlock_ and "flushes" currentBlock_ t...
OFIterator< T > end() const
returns an iterator which points to the past-to-end element of the list.
size_t size() const
returns number of elements in the list.
int RLE_pcount_
repeat counter, for RLE compressor may temporarily become negative, guaranteed to be >= 0 between met...
size_t offset_
contains the number of bytes already written the the memory block pointed to by currentBlock_.
void add(unsigned char ch)
this method adds one byte to the byte stream to be compressed with the RLE compressor.
this class implements an RLE compressor conforming to the DICOM standard.
abstract class that defines an interface through which encoder classes (such as DcmRLEEncoder) may ex...
~DcmRLEEncoder()
destructor
OFIterator< T > begin() const
returns an iterator referencing the first element in the list.
virtual ~DcmEncoderOutputStream()
Virtual Desctructor.
virtual void write(const unsigned char *buf, size_t bufsize)=0
write the given buffer into the output stream
DcmRLEEncoder & operator=(const DcmRLEEncoder &)
private undefined copy assignment operator
OFBool fail() const
returns true if the RLE compressor has run out of memory.
int RLE_prev_
value of the last byte fed to the RLE compressor.
int fail_
this flag indicates a failure of the RLE codec.
void flush()
this method finalizes the compressed RLE stream, i.e.
OFList< unsigned char * > blockList_
this member contains a list of memory blocks of size DcmRLEEncoder_BLOCKSIZE which already have been ...
unsigned int RLE_bindex_
index of next unused byte in RLE_buff_.
void write(void *target) const
copies the compressed RLE byte stream into a target array of at least size() bytes.
unsigned char * RLE_buff_
this member points to a buffer of 132 bytes that is used by the RLE encoding algorithm.
int pad_
this flag indicates whether the RLE codec must pad encoded data to an even number of bytes (as requir...
void push_back(const T &x)
inserts after the last element of the list.