dcmdata/include/dcmtk/dcmdata/dccodec.h

00001 /*
00002  *
00003  *  Copyright (C) 1997-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:  dcmdata
00015  *
00016  *  Author:  Andreas Barth
00017  *
00018  *  Purpose: Interface of abstract class DcmCodec and the class DcmCodecStruct
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-10-14 13:15:40 $
00022  *  CVS/RCS Revision: $Revision: 1.24 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 #ifndef DCCODEC_H
00030 #define DCCODEC_H
00031 
00032 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00033 #include "dcmtk/ofstd/ofcond.h"
00034 #include "dcmtk/dcmdata/dctypes.h"
00035 #include "dcmtk/dcmdata/dcxfer.h"
00036 #include "dcmtk/ofstd/oflist.h"
00037 
00038 class DcmStack;
00039 class DcmRepresentationParameter;
00040 class DcmPixelSequence;
00041 class DcmPolymorphOBOW;
00042 class DcmItem;
00043 class DcmTagKey;
00044 
00049 class DcmCodecParameter
00050 {
00051 public:
00053     DcmCodecParameter() {}
00054 
00056     DcmCodecParameter(const DcmCodecParameter&) {}
00057 
00059     virtual ~DcmCodecParameter() {}
00060 
00065     virtual DcmCodecParameter *clone() const = 0;
00066 
00070     virtual const char *className() const = 0;
00071 
00072 };
00073 
00074 
00085 class DcmCodec
00086 {
00087 public:
00089   DcmCodec() {}
00090 
00092   virtual ~DcmCodec() {}
00093 
00104   virtual OFCondition decode(
00105     const DcmRepresentationParameter * fromRepParam,
00106     DcmPixelSequence * pixSeq,
00107     DcmPolymorphOBOW& uncompressedPixelData,
00108     const DcmCodecParameter * cp,
00109     const DcmStack& objStack) const = 0;
00110 
00136   virtual OFCondition decodeFrame(
00137     const DcmRepresentationParameter * fromParam,
00138     DcmPixelSequence * fromPixSeq,
00139     const DcmCodecParameter * cp,
00140     DcmItem *dataset,
00141     Uint32 frameNo,
00142     Uint32& startFragment,
00143     void *buffer,
00144     Uint32 bufSize,
00145     OFString& decompressedColorModel) const = 0;
00146 
00161   virtual OFCondition encode(
00162     const Uint16 * pixelData,
00163     const Uint32 length,
00164     const DcmRepresentationParameter * toRepParam,
00165     DcmPixelSequence * & pixSeq,
00166     const DcmCodecParameter *cp,
00167     DcmStack & objStack) const = 0;
00168 
00183   virtual OFCondition encode(
00184     const E_TransferSyntax fromRepType,
00185     const DcmRepresentationParameter * fromRepParam,
00186     DcmPixelSequence * fromPixSeq,
00187     const DcmRepresentationParameter * toRepParam,
00188     DcmPixelSequence * & toPixSeq,
00189     const DcmCodecParameter * cp,
00190     DcmStack & objStack) const = 0;
00191 
00199   virtual OFBool canChangeCoding(
00200     const E_TransferSyntax oldRepType,
00201     const E_TransferSyntax newRepType) const = 0;
00202 
00216   virtual OFCondition determineDecompressedColorModel(
00217     const DcmRepresentationParameter *fromParam,
00218     DcmPixelSequence *fromPixSeq,
00219     const DcmCodecParameter *cp,
00220     DcmItem *dataset,
00221     OFString &decompressedColorModel) const = 0;
00222 
00223   // static helper methods that have proven useful in codec classes derived from DcmCodec
00224 
00232   static OFCondition insertStringIfMissing(DcmItem *dataset, const DcmTagKey& tag, const char *val);
00233 
00242   static OFCondition convertToSecondaryCapture(DcmItem *dataset);
00243 
00252   static OFCondition newInstance(
00253     DcmItem *dataset,
00254     const char *purposeOfReferenceCodingScheme = NULL,
00255     const char *purposeOfReferenceCodeValue = NULL,
00256     const char *purposeOfReferenceCodeMeaning = NULL);
00257 
00262   static OFCondition updateImageType(DcmItem *dataset);
00263 
00272   static OFCondition insertCodeSequence(
00273     DcmItem *dataset,
00274     const DcmTagKey &tagKey,
00275     const char *codingSchemeDesignator,
00276     const char *codeValue,
00277     const char *codeMeaning);
00278 
00287   static OFCondition determineStartFragment(
00288     Uint32 frameNo,
00289     Sint32 numberOfFrames,
00290     DcmPixelSequence * fromPixSeq,
00291     Uint32& currentItem);
00292 };
00293 
00294 
00299 class DcmCodecList
00300 {
00301 
00302 public:
00303 
00305   virtual ~DcmCodecList();
00306 
00321   static OFCondition registerCodec(
00322     const DcmCodec *aCodec,
00323     const DcmRepresentationParameter *aDefaultRepParam,
00324     const DcmCodecParameter *aCodecParameter);
00325 
00331   static OFCondition deregisterCodec(const DcmCodec *aCodec);
00332 
00341   static OFCondition updateCodecParameter(
00342     const DcmCodec *aCodec,
00343     const DcmCodecParameter *aCodecParameter);
00344 
00357   static OFCondition decode(
00358     const DcmXfer & fromType,
00359     const DcmRepresentationParameter * fromParam,
00360     DcmPixelSequence * fromPixSeq,
00361     DcmPolymorphOBOW& uncompressedPixelData,
00362     DcmStack & pixelStack);
00363 
00390   static OFCondition decodeFrame(
00391     const DcmXfer & fromType,
00392     const DcmRepresentationParameter * fromParam,
00393     DcmPixelSequence * fromPixSeq,
00394     DcmItem *dataset,
00395     Uint32 frameNo,
00396     Uint32& startFragment,
00397     void *buffer,
00398     Uint32 bufSize,
00399     OFString& decompressedColorModel);
00400 
00417   static OFCondition encode(
00418     const E_TransferSyntax fromRepType,
00419     const Uint16 * pixelData,
00420     const Uint32 length,
00421     const E_TransferSyntax toRepType,
00422     const DcmRepresentationParameter * toRepParam,
00423     DcmPixelSequence * & pixSeq,
00424     DcmStack & pixelStack);
00425 
00443   static OFCondition encode(
00444     const E_TransferSyntax fromRepType,
00445     const DcmRepresentationParameter * fromParam,
00446     DcmPixelSequence * fromPixSeq,
00447     const E_TransferSyntax toRepType,
00448     const DcmRepresentationParameter * toRepParam,
00449     DcmPixelSequence * & toPixSeq,
00450     DcmStack & pixelStack);
00451 
00460   static OFBool canChangeCoding(
00461     const E_TransferSyntax fromRepType,
00462     const E_TransferSyntax toRepType);
00463 
00475   static OFCondition determineDecompressedColorModel(
00476     const DcmXfer &fromType,
00477     const DcmRepresentationParameter *fromParam,
00478     DcmPixelSequence *fromPixSeq,
00479     DcmItem *dataset,
00480     OFString &decompressedColorModel);
00481 
00482 private:
00483 
00489   DcmCodecList(
00490     const DcmCodec *aCodec,
00491     const DcmRepresentationParameter *aDefaultRepParam,
00492     const DcmCodecParameter *aCodecParameter);
00493 
00495   DcmCodecList(const DcmCodecList &);
00496 
00498   DcmCodecList &operator=(const DcmCodecList &);
00499 
00501   const DcmCodec * codec;
00502 
00504   const DcmRepresentationParameter * defaultRepParam;
00505 
00507   const DcmCodecParameter * codecParameter;
00508 
00510   static OFList<DcmCodecList *> registeredCodecs;
00511 
00512 #ifdef WITH_THREADS
00514   static OFReadWriteLock codecLock;
00515 #endif
00516 
00517   // dummy friend declaration to prevent gcc from complaining
00518   // that this class only defines private constructors and has no friends.
00519   friend class DcmCodecListDummyFriend;
00520 };
00521 
00522 
00523 #endif
00524 
00525 /*
00526 ** CVS/RCS Log:
00527 ** $Log: dccodec.h,v $
00528 ** Revision 1.24  2010-10-14 13:15:40  joergr
00529 ** Updated copyright header. Added reference to COPYRIGHT file.
00530 **
00531 ** Revision 1.23  2010-10-04 14:26:21  joergr
00532 ** Fixed issue with codec registry when compiled on Linux x86_64 with "configure
00533 ** --disable-threads" (replaced "#ifdef _REENTRANT" by "#ifdef WITH_THREADS").
00534 **
00535 ** Revision 1.22  2010-03-01 09:08:44  uli
00536 ** Removed some unnecessary include directives in the headers.
00537 **
00538 ** Revision 1.21  2009-11-17 16:36:51  joergr
00539 ** Added new method that allows for determining the color model of the
00540 ** decompressed image.
00541 **
00542 ** Revision 1.20  2009-11-04 09:58:07  uli
00543 ** Switched to logging mechanism provided by the "new" oflog module
00544 **
00545 ** Revision 1.19  2008-05-29 10:46:13  meichel
00546 ** Implemented new method DcmPixelData::getUncompressedFrame
00547 **   that permits frame-wise access to compressed and uncompressed
00548 **   objects without ever loading the complete object into main memory.
00549 **   For this new method to work with compressed images, all classes derived from
00550 **   DcmCodec need to implement a new method decodeFrame(). For now, only
00551 **   dummy implementations returning an error code have been defined.
00552 **
00553 ** Revision 1.18  2005/12/09 14:48:14  meichel
00554 ** Added missing virtual destructors
00555 **
00556 ** Revision 1.17  2005/12/08 16:28:01  meichel
00557 ** Changed include path schema for all DCMTK header files
00558 **
00559 ** Revision 1.16  2004/08/24 14:54:18  meichel
00560 **  Updated compression helper methods. Image type is not set to SECONDARY
00561 **   any more, support for the purpose of reference code sequence added.
00562 **
00563 ** Revision 1.15  2003/06/12 13:35:23  joergr
00564 ** Fixed inconsistent API documentation reported by Doxygen.
00565 **
00566 ** Revision 1.14  2002/05/24 14:51:41  meichel
00567 ** Moved helper methods that are useful for different compression techniques
00568 **   from module dcmjpeg to module dcmdata
00569 **
00570 ** Revision 1.13  2002/02/27 14:21:20  meichel
00571 ** Declare dcmdata read/write locks only when compiled in multi-thread mode
00572 **
00573 ** Revision 1.12  2001/11/12 16:29:51  meichel
00574 ** Added dummy friend class declaration to singleton class DcmCodecList
00575 **   to keep gcc from squawking.
00576 **
00577 ** Revision 1.11  2001/11/08 16:19:39  meichel
00578 ** Changed interface for codec registration. Now everything is thread-safe
00579 **   and multiple codecs can be registered for a single transfer syntax (e.g.
00580 **   one encoder and one decoder).
00581 **
00582 ** Revision 1.10  2001/09/25 17:19:07  meichel
00583 ** Updated abstract class DcmCodecParameter for use with dcmjpeg.
00584 **   Added new function deregisterGlobalCodec().
00585 **
00586 ** Revision 1.9  2001/06/01 15:48:34  meichel
00587 ** Updated copyright header
00588 **
00589 ** Revision 1.8  2001/05/25 09:53:51  meichel
00590 ** Modified DcmCodec::decode() interface, required for future dcmjpeg module.
00591 **
00592 ** Revision 1.7  2000/09/27 08:19:54  meichel
00593 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
00594 **
00595 ** Revision 1.6  2000/04/14 16:09:12  meichel
00596 ** Made function DcmCodec and related functions thread safe.
00597 **   registerGlobalCodec() should not be called anymore from the constructor
00598 **   of global objects.
00599 **
00600 ** Revision 1.5  2000/03/08 16:26:11  meichel
00601 ** Updated copyright header.
00602 **
00603 ** Revision 1.4  1999/03/31 09:24:31  meichel
00604 ** Updated copyright header in module dcmdata
00605 **
00606 ** Revision 1.3  1998/07/15 15:48:43  joergr
00607 ** Removed several compiler warnings reported by gcc 2.8.1 with
00608 ** additional options, e.g. missing copy constructors and assignment
00609 ** operators, initialization of member variables in the body of a
00610 ** constructor instead of the member initialization list, hiding of
00611 ** methods by use of identical names, uninitialized member variables,
00612 ** missing const declaration of char pointers. Replaced tabs by spaces.
00613 **
00614 ** Revision 1.2  1997/07/24 13:07:45  andreas
00615 ** - Make DcmCodec:canChangeCoding abstract
00616 **
00617 ** Revision 1.1  1997/07/21 07:54:57  andreas
00618 ** - New environment for encapsulated pixel representations. DcmPixelData
00619 **   can contain different representations and uses codecs to convert
00620 **   between them. Codecs are derived from the DcmCodec class. New error
00621 **   codes are introduced for handling of representations. New internal
00622 **   value representation (only for ident()) for PixelData
00623 **
00624 */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1