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 
514  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 */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2