00001 /* 00002 * 00003 * Copyright (C) 2007-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmjpls 00015 * 00016 * Author: Martin Willkomm, Marco Eichelberg 00017 * 00018 * Purpose: codec classes for JPEG-LS decoders. 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:17:19 $ 00022 * CVS/RCS Revision: $Revision: 1.6 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCMJPLS_DJCODECD_H 00030 #define DCMJPLS_DJCODECD_H 00031 00032 #include "dcmtk/config/osconfig.h" 00033 #include "dcmtk/dcmdata/dccodec.h" /* for class DcmCodec */ 00034 #include "dcmtk/ofstd/ofstring.h" 00035 00036 /* forward declaration */ 00037 class DJLSCodecParameter; 00038 00045 class DJLSDecoderBase: public DcmCodec 00046 { 00047 public: 00048 00050 DJLSDecoderBase(); 00051 00053 virtual ~DJLSDecoderBase(); 00054 00065 virtual OFCondition decode( 00066 const DcmRepresentationParameter * fromRepParam, 00067 DcmPixelSequence * pixSeq, 00068 DcmPolymorphOBOW& uncompressedPixelData, 00069 const DcmCodecParameter * cp, 00070 const DcmStack& objStack) const; 00071 00097 virtual OFCondition decodeFrame( 00098 const DcmRepresentationParameter * fromParam, 00099 DcmPixelSequence * fromPixSeq, 00100 const DcmCodecParameter * cp, 00101 DcmItem *dataset, 00102 Uint32 frameNo, 00103 Uint32& startFragment, 00104 void *buffer, 00105 Uint32 bufSize, 00106 OFString& decompressedColorModel) const; 00107 00122 virtual OFCondition encode( 00123 const Uint16 * pixelData, 00124 const Uint32 length, 00125 const DcmRepresentationParameter * toRepParam, 00126 DcmPixelSequence * & pixSeq, 00127 const DcmCodecParameter *cp, 00128 DcmStack & objStack) const; 00129 00144 virtual OFCondition encode( 00145 const E_TransferSyntax fromRepType, 00146 const DcmRepresentationParameter * fromRepParam, 00147 DcmPixelSequence * fromPixSeq, 00148 const DcmRepresentationParameter * toRepParam, 00149 DcmPixelSequence * & toPixSeq, 00150 const DcmCodecParameter * cp, 00151 DcmStack & objStack) const; 00152 00160 virtual OFBool canChangeCoding( 00161 const E_TransferSyntax oldRepType, 00162 const E_TransferSyntax newRepType) const; 00163 00177 virtual OFCondition determineDecompressedColorModel( 00178 const DcmRepresentationParameter *fromParam, 00179 DcmPixelSequence *fromPixSeq, 00180 const DcmCodecParameter *cp, 00181 DcmItem *dataset, 00182 OFString &decompressedColorModel) const; 00183 00184 private: 00185 00186 // static private helper methods 00187 00213 static OFCondition decodeFrame( 00214 DcmPixelSequence * fromPixSeq, 00215 const DJLSCodecParameter *cp, 00216 DcmItem *dataset, 00217 Uint32 frameNo, 00218 Uint32& startFragment, 00219 void *buffer, 00220 Uint32 bufSize, 00221 Sint32 imageFrames, 00222 Uint16 imageColumns, 00223 Uint16 imageRows, 00224 Uint16 imageSamplesPerPixel, 00225 Uint16 bytesPerSample); 00226 00235 static Uint16 determinePlanarConfiguration( 00236 const OFString& sopClassUID, 00237 const OFString& photometricInterpretation); 00238 00251 static Uint32 computeNumberOfFragments( 00252 Sint32 numberOfFrames, 00253 Uint32 currentFrame, 00254 Uint32 startItem, 00255 OFBool ignoreOffsetTable, 00256 DcmPixelSequence *pixSeq); 00257 00264 static OFBool isJPEGLSStartOfImage(Uint8 *fragmentData); 00265 00274 static OFCondition createPlanarConfiguration1Byte( 00275 Uint8 *imageFrame, 00276 Uint16 columns, 00277 Uint16 rows); 00278 00287 static OFCondition createPlanarConfiguration1Word( 00288 Uint16 *imageFrame, 00289 Uint16 columns, 00290 Uint16 rows); 00291 00300 static OFCondition createPlanarConfiguration0Byte( 00301 Uint8 *imageFrame, 00302 Uint16 columns, 00303 Uint16 rows); 00304 00313 static OFCondition createPlanarConfiguration0Word( 00314 Uint16 *imageFrame, 00315 Uint16 columns, 00316 Uint16 rows); 00317 }; 00318 00321 class DJLSLosslessDecoder : public DJLSDecoderBase 00322 { 00327 virtual E_TransferSyntax supportedTransferSyntax() const; 00328 }; 00329 00332 class DJLSNearLosslessDecoder : public DJLSDecoderBase 00333 { 00338 virtual E_TransferSyntax supportedTransferSyntax() const; 00339 }; 00340 00341 #endif 00342 00343 /* 00344 * CVS/RCS Log: 00345 * $Log: djcodecd.h,v $ 00346 * Revision 1.6 2010-10-14 13:17:19 joergr 00347 * Updated copyright header. Added reference to COPYRIGHT file. 00348 * 00349 * Revision 1.5 2010-10-12 12:32:22 uli 00350 * Avoid redundant findAndGet*() calls. 00351 * 00352 * Revision 1.4 2010-03-01 10:35:28 uli 00353 * Renamed include guards to avoid name clash with e.g. dcmjpeg. 00354 * 00355 * Revision 1.3 2009-11-17 16:57:14 joergr 00356 * Added new method that allows for determining the color model of the 00357 * decompressed image. 00358 * 00359 * Revision 1.2 2009-10-07 13:16:47 uli 00360 * Switched to logging mechanism provided by the "new" oflog module. 00361 * 00362 * Revision 1.1 2009-07-29 14:46:46 meichel 00363 * Initial release of module dcmjpls, a JPEG-LS codec for DCMTK based on CharLS 00364 * 00365 * Revision 1.2 2008-05-29 10:54:05 meichel 00366 * Implemented new method DcmPixelData::getUncompressedFrame 00367 * that permits frame-wise access to compressed and uncompressed 00368 * objects without ever loading the complete object into main memory. 00369 * For this new method to work with compressed images, all classes derived from 00370 * DcmCodec need to implement a new method decodeFrame(). For now, only 00371 * dummy implementations returning an error code have been defined. 00372 * 00373 * Revision 1.1 2007/06/15 14:35:45 meichel 00374 * Renamed CMake project and include directory from dcmjpgls to dcmjpls 00375 * 00376 * Revision 1.4 2007/06/15 10:39:15 meichel 00377 * Completed implementation of decoder, which now correctly processes all 00378 * of the NEMA JPEG-LS sample images, including fragmented frames. 00379 * 00380 * Revision 1.3 2007/06/14 12:36:14 meichel 00381 * Further code clean-up. Updated doxygen comments. 00382 * 00383 * Revision 1.2 2007/06/13 16:41:07 meichel 00384 * Code clean-up and removal of dead code 00385 * 00386 * 00387 */