OFFIS DCMTK  Version 3.6.0
dccodec.h
1 /*
2  *
3  * Copyright (C) 1997-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Andreas Barth
17  *
18  * Purpose: Interface of abstract class DcmCodec and the class DcmCodecStruct
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:40 $
22  * CVS/RCS Revision: $Revision: 1.24 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCCODEC_H
30 #define DCCODEC_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 #include "dcmtk/ofstd/ofcond.h"
34 #include "dcmtk/dcmdata/dctypes.h"
35 #include "dcmtk/dcmdata/dcxfer.h"
36 #include "dcmtk/ofstd/oflist.h"
37 
38 class DcmStack;
40 class DcmPixelSequence;
41 class DcmPolymorphOBOW;
42 class DcmItem;
43 class DcmTagKey;
44 
50 {
51 public:
54 
57 
59  virtual ~DcmCodecParameter() {}
60 
65  virtual DcmCodecParameter *clone() const = 0;
66 
70  virtual const char *className() const = 0;
71 
72 };
73 
74 
85 class DcmCodec
86 {
87 public:
89  DcmCodec() {}
90 
92  virtual ~DcmCodec() {}
93 
104  virtual OFCondition decode(
105  const DcmRepresentationParameter * fromRepParam,
106  DcmPixelSequence * pixSeq,
107  DcmPolymorphOBOW& uncompressedPixelData,
108  const DcmCodecParameter * cp,
109  const DcmStack& objStack) const = 0;
110 
136  virtual OFCondition decodeFrame(
137  const DcmRepresentationParameter * fromParam,
138  DcmPixelSequence * fromPixSeq,
139  const DcmCodecParameter * cp,
140  DcmItem *dataset,
141  Uint32 frameNo,
142  Uint32& startFragment,
143  void *buffer,
144  Uint32 bufSize,
145  OFString& decompressedColorModel) const = 0;
146 
161  virtual OFCondition encode(
162  const Uint16 * pixelData,
163  const Uint32 length,
164  const DcmRepresentationParameter * toRepParam,
165  DcmPixelSequence * & pixSeq,
166  const DcmCodecParameter *cp,
167  DcmStack & objStack) const = 0;
168 
183  virtual OFCondition encode(
184  const E_TransferSyntax fromRepType,
185  const DcmRepresentationParameter * fromRepParam,
186  DcmPixelSequence * fromPixSeq,
187  const DcmRepresentationParameter * toRepParam,
188  DcmPixelSequence * & toPixSeq,
189  const DcmCodecParameter * cp,
190  DcmStack & objStack) const = 0;
191 
199  virtual OFBool canChangeCoding(
200  const E_TransferSyntax oldRepType,
201  const E_TransferSyntax newRepType) const = 0;
202 
217  const DcmRepresentationParameter *fromParam,
218  DcmPixelSequence *fromPixSeq,
219  const DcmCodecParameter *cp,
220  DcmItem *dataset,
221  OFString &decompressedColorModel) const = 0;
222 
223  // static helper methods that have proven useful in codec classes derived from DcmCodec
224 
232  static OFCondition insertStringIfMissing(DcmItem *dataset, const DcmTagKey& tag, const char *val);
233 
243 
252  static OFCondition newInstance(
253  DcmItem *dataset,
254  const char *purposeOfReferenceCodingScheme = NULL,
255  const char *purposeOfReferenceCodeValue = NULL,
256  const char *purposeOfReferenceCodeMeaning = NULL);
257 
262  static OFCondition updateImageType(DcmItem *dataset);
263 
273  DcmItem *dataset,
274  const DcmTagKey &tagKey,
275  const char *codingSchemeDesignator,
276  const char *codeValue,
277  const char *codeMeaning);
278 
288  Uint32 frameNo,
289  Sint32 numberOfFrames,
290  DcmPixelSequence * fromPixSeq,
291  Uint32& currentItem);
292 };
293 
294 
300 {
301 
302 public:
303 
305  virtual ~DcmCodecList();
306 
321  static OFCondition registerCodec(
322  const DcmCodec *aCodec,
323  const DcmRepresentationParameter *aDefaultRepParam,
324  const DcmCodecParameter *aCodecParameter);
325 
331  static OFCondition deregisterCodec(const DcmCodec *aCodec);
332 
342  const DcmCodec *aCodec,
343  const DcmCodecParameter *aCodecParameter);
344 
357  static OFCondition decode(
358  const DcmXfer & fromType,
359  const DcmRepresentationParameter * fromParam,
360  DcmPixelSequence * fromPixSeq,
361  DcmPolymorphOBOW& uncompressedPixelData,
362  DcmStack & pixelStack);
363 
390  static OFCondition decodeFrame(
391  const DcmXfer & fromType,
392  const DcmRepresentationParameter * fromParam,
393  DcmPixelSequence * fromPixSeq,
394  DcmItem *dataset,
395  Uint32 frameNo,
396  Uint32& startFragment,
397  void *buffer,
398  Uint32 bufSize,
399  OFString& decompressedColorModel);
400 
417  static OFCondition encode(
418  const E_TransferSyntax fromRepType,
419  const Uint16 * pixelData,
420  const Uint32 length,
421  const E_TransferSyntax toRepType,
422  const DcmRepresentationParameter * toRepParam,
423  DcmPixelSequence * & pixSeq,
424  DcmStack & pixelStack);
425 
443  static OFCondition encode(
444  const E_TransferSyntax fromRepType,
445  const DcmRepresentationParameter * fromParam,
446  DcmPixelSequence * fromPixSeq,
447  const E_TransferSyntax toRepType,
448  const DcmRepresentationParameter * toRepParam,
449  DcmPixelSequence * & toPixSeq,
450  DcmStack & pixelStack);
451 
460  static OFBool canChangeCoding(
461  const E_TransferSyntax fromRepType,
462  const E_TransferSyntax toRepType);
463 
476  const DcmXfer &fromType,
477  const DcmRepresentationParameter *fromParam,
478  DcmPixelSequence *fromPixSeq,
479  DcmItem *dataset,
480  OFString &decompressedColorModel);
481 
482 private:
483 
489  DcmCodecList(
490  const DcmCodec *aCodec,
491  const DcmRepresentationParameter *aDefaultRepParam,
492  const DcmCodecParameter *aCodecParameter);
493 
495  DcmCodecList(const DcmCodecList &);
496 
499 
501  const DcmCodec * codec;
502 
505 
508 
511 
512 #ifdef WITH_THREADS
513  static OFReadWriteLock codecLock;
515 #endif
516 
517  // dummy friend declaration to prevent gcc from complaining
518  // that this class only defines private constructors and has no friends.
519  friend class DcmCodecListDummyFriend;
520 };
521 
522 
523 #endif
524 
525 /*
526 ** CVS/RCS Log:
527 ** $Log: dccodec.h,v $
528 ** Revision 1.24 2010-10-14 13:15:40 joergr
529 ** Updated copyright header. Added reference to COPYRIGHT file.
530 **
531 ** Revision 1.23 2010-10-04 14:26:21 joergr
532 ** Fixed issue with codec registry when compiled on Linux x86_64 with "configure
533 ** --disable-threads" (replaced "#ifdef _REENTRANT" by "#ifdef WITH_THREADS").
534 **
535 ** Revision 1.22 2010-03-01 09:08:44 uli
536 ** Removed some unnecessary include directives in the headers.
537 **
538 ** Revision 1.21 2009-11-17 16:36:51 joergr
539 ** Added new method that allows for determining the color model of the
540 ** decompressed image.
541 **
542 ** Revision 1.20 2009-11-04 09:58:07 uli
543 ** Switched to logging mechanism provided by the "new" oflog module
544 **
545 ** Revision 1.19 2008-05-29 10:46:13 meichel
546 ** Implemented new method DcmPixelData::getUncompressedFrame
547 ** that permits frame-wise access to compressed and uncompressed
548 ** objects without ever loading the complete object into main memory.
549 ** For this new method to work with compressed images, all classes derived from
550 ** DcmCodec need to implement a new method decodeFrame(). For now, only
551 ** dummy implementations returning an error code have been defined.
552 **
553 ** Revision 1.18 2005/12/09 14:48:14 meichel
554 ** Added missing virtual destructors
555 **
556 ** Revision 1.17 2005/12/08 16:28:01 meichel
557 ** Changed include path schema for all DCMTK header files
558 **
559 ** Revision 1.16 2004/08/24 14:54:18 meichel
560 ** Updated compression helper methods. Image type is not set to SECONDARY
561 ** any more, support for the purpose of reference code sequence added.
562 **
563 ** Revision 1.15 2003/06/12 13:35:23 joergr
564 ** Fixed inconsistent API documentation reported by Doxygen.
565 **
566 ** Revision 1.14 2002/05/24 14:51:41 meichel
567 ** Moved helper methods that are useful for different compression techniques
568 ** from module dcmjpeg to module dcmdata
569 **
570 ** Revision 1.13 2002/02/27 14:21:20 meichel
571 ** Declare dcmdata read/write locks only when compiled in multi-thread mode
572 **
573 ** Revision 1.12 2001/11/12 16:29:51 meichel
574 ** Added dummy friend class declaration to singleton class DcmCodecList
575 ** to keep gcc from squawking.
576 **
577 ** Revision 1.11 2001/11/08 16:19:39 meichel
578 ** Changed interface for codec registration. Now everything is thread-safe
579 ** and multiple codecs can be registered for a single transfer syntax (e.g.
580 ** one encoder and one decoder).
581 **
582 ** Revision 1.10 2001/09/25 17:19:07 meichel
583 ** Updated abstract class DcmCodecParameter for use with dcmjpeg.
584 ** Added new function deregisterGlobalCodec().
585 **
586 ** Revision 1.9 2001/06/01 15:48:34 meichel
587 ** Updated copyright header
588 **
589 ** Revision 1.8 2001/05/25 09:53:51 meichel
590 ** Modified DcmCodec::decode() interface, required for future dcmjpeg module.
591 **
592 ** Revision 1.7 2000/09/27 08:19:54 meichel
593 ** Minor changes in DcmCodec interface, required for future dcmjpeg module.
594 **
595 ** Revision 1.6 2000/04/14 16:09:12 meichel
596 ** Made function DcmCodec and related functions thread safe.
597 ** registerGlobalCodec() should not be called anymore from the constructor
598 ** of global objects.
599 **
600 ** Revision 1.5 2000/03/08 16:26:11 meichel
601 ** Updated copyright header.
602 **
603 ** Revision 1.4 1999/03/31 09:24:31 meichel
604 ** Updated copyright header in module dcmdata
605 **
606 ** Revision 1.3 1998/07/15 15:48:43 joergr
607 ** Removed several compiler warnings reported by gcc 2.8.1 with
608 ** additional options, e.g. missing copy constructors and assignment
609 ** operators, initialization of member variables in the body of a
610 ** constructor instead of the member initialization list, hiding of
611 ** methods by use of identical names, uninitialized member variables,
612 ** missing const declaration of char pointers. Replaced tabs by spaces.
613 **
614 ** Revision 1.2 1997/07/24 13:07:45 andreas
615 ** - Make DcmCodec:canChangeCoding abstract
616 **
617 ** Revision 1.1 1997/07/21 07:54:57 andreas
618 ** - New environment for encapsulated pixel representations. DcmPixelData
619 ** can contain different representations and uses codecs to convert
620 ** between them. Codecs are derived from the DcmCodec class. New error
621 ** codes are introduced for handling of representations. New internal
622 ** value representation (only for ident()) for PixelData
623 **
624 */
static OFCondition insertCodeSequence(DcmItem *dataset, const DcmTagKey &tagKey, const char *codingSchemeDesignator, const char *codeValue, const char *codeMeaning)
insert code sequence into the given dataset
virtual ~DcmCodecList()
destructor
static OFCondition determineDecompressedColorModel(const DcmXfer &fromType, const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, DcmItem *dataset, OFString &decompressedColorModel)
determine color model of the decompressed image
a class representing a list of DICOM elements in which each element has a different tag and elements ...
Definition: dcitem.h:51
class maintaining a attribute tag (group and element number)
Definition: dctagkey.h:46
static OFCondition decodeFrame(const DcmXfer &fromType, const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, DcmItem *dataset, Uint32 frameNo, Uint32 &startFragment, void *buffer, Uint32 bufSize, OFString &decompressedColorModel)
looks for a codec that is able to decode from the given transfer syntax and calls the decodeFrame() m...
DcmCodecParameter(const DcmCodecParameter &)
copy constructor
Definition: dccodec.h:56
static OFCondition insertStringIfMissing(DcmItem *dataset, const DcmTagKey &tag, const char *val)
helper function that inserts a string attribute with a given value into a dataset if missing in the d...
const DcmRepresentationParameter * defaultRepParam
pointer to default representation parameter
Definition: dccodec.h:504
static OFCondition registerCodec(const DcmCodec *aCodec, const DcmRepresentationParameter *aDefaultRepParam, const DcmCodecParameter *aCodecParameter)
registers a codec object in the global list of codecs consulted by dcmdata whenever conversion to/fro...
virtual ~DcmCodec()
destructor
Definition: dccodec.h:92
static OFCondition updateCodecParameter(const DcmCodec *aCodec, const DcmCodecParameter *aCodecParameter)
updates the codec parameters object for a codec that has been registered before.
const DcmCodecParameter * codecParameter
pointer to codec parameter set
Definition: dccodec.h:507
virtual OFBool canChangeCoding(const E_TransferSyntax oldRepType, const E_TransferSyntax newRepType) const =0
checks if this codec is able to convert from the given current transfer syntax to the given new trans...
abstract base class for codec representation parameter sets.
Definition: dcpixel.h:50
const DcmCodec * codec
pointer to codec object
Definition: dccodec.h:501
virtual OFCondition encode(const Uint16 *pixelData, const Uint32 length, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, const DcmCodecParameter *cp, DcmStack &objStack) const =0
compresses the given uncompressed DICOM image and stores the result in the given pixSeq element...
static OFCondition deregisterCodec(const DcmCodec *aCodec)
deregisters a codec and it's parameter objects from the global list.
static OFList< DcmCodecList * > registeredCodecs
singleton list of registered codecs
Definition: dccodec.h:510
virtual DcmCodecParameter * clone() const =0
this methods creates a copy of type DcmCodecParameter * it must be overweritten in every subclass...
virtual const char * className() const =0
returns the class name as string.
static OFCondition updateImageType(DcmItem *dataset)
set first value of Image Type to DERIVED.
this class implements a sequence of pixel items, i.e.
Definition: dcpixseq.h:45
DcmCodecList(const DcmCodec *aCodec, const DcmRepresentationParameter *aDefaultRepParam, const DcmCodecParameter *aCodecParameter)
constructor
a class that allows for a lookup of Transfer Syntax properties and readable descriptions ...
Definition: dcxfer.h:161
static OFCondition convertToSecondaryCapture(DcmItem *dataset)
helper function that converts a dataset containing a DICOM image into a valid (standard extended) Sec...
static OFBool canChangeCoding(const E_TransferSyntax fromRepType, const E_TransferSyntax toRepType)
looks for a codec that claims to be able to convert between the given transfer syntaxes.
singleton that keeps list of registered codecs for dcmdata.
Definition: dccodec.h:299
virtual ~DcmCodecParameter()
destructor
Definition: dccodec.h:59
virtual OFCondition decodeFrame(const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, Uint32 frameNo, Uint32 &startFragment, void *buffer, Uint32 bufSize, OFString &decompressedColorModel) const =0
decompresses a single frame from the given pixel sequence and stores the result in the given buffer...
abstract base class for a codec parameter object that describes the settings (modes of operations) fo...
Definition: dccodec.h:49
this class manages a stack of pointers to DcmObject instances.
Definition: dcstack.h:77
DcmCodecParameter()
default constructor
Definition: dccodec.h:53
DcmCodecList & operator=(const DcmCodecList &)
private undefined copy assignment operator
static OFCondition determineStartFragment(Uint32 frameNo, Sint32 numberOfFrames, DcmPixelSequence *fromPixSeq, Uint32 &currentItem)
determine the index number (starting with zero) of the compressed pixel data fragment corresponding t...
DcmCodec()
default constructor
Definition: dccodec.h:89
static OFCondition encode(const E_TransferSyntax fromRepType, const Uint16 *pixelData, const Uint32 length, const E_TransferSyntax toRepType, const DcmRepresentationParameter *toRepParam, DcmPixelSequence *&pixSeq, DcmStack &pixelStack)
looks for a codec that is able to encode from the given transfer syntax and calls the encode() method...
static OFCondition newInstance(DcmItem *dataset, const char *purposeOfReferenceCodingScheme=NULL, const char *purposeOfReferenceCodeValue=NULL, const char *purposeOfReferenceCodeMeaning=NULL)
create new SOP instance UID and Source Image Sequence referencing the old SOP instance (if present) ...
abstract base class for a codec object that can be registered in dcmdata and performs transfer syntax...
Definition: dccodec.h:85
a simple string class that implements a subset of std::string.
Definition: ofstring.h:86
a class representing DICOM elements (such as uncompressed pixel data) that can be interpreted either ...
Definition: dcvrpobw.h:41
static OFCondition decode(const DcmXfer &fromType, const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, DcmPolymorphOBOW &uncompressedPixelData, DcmStack &pixelStack)
looks for a codec that is able to decode from the given transfer syntax and calls the decode() method...
virtual OFCondition decode(const DcmRepresentationParameter *fromRepParam, DcmPixelSequence *pixSeq, DcmPolymorphOBOW &uncompressedPixelData, const DcmCodecParameter *cp, const DcmStack &objStack) const =0
decompresses the given pixel sequence and stores the result in the given uncompressedPixelData elemen...
provides an operating system independent abstraction for read/write locks.
Definition: ofthread.h:427
virtual OFCondition determineDecompressedColorModel(const DcmRepresentationParameter *fromParam, DcmPixelSequence *fromPixSeq, const DcmCodecParameter *cp, DcmItem *dataset, OFString &decompressedColorModel) const =0
determine color model of the decompressed image
General purpose class for condition codes.
Definition: ofcond.h:305


Generated on Wed Jan 4 2017 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.6