Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp @ 5363:3c8286e5d07b multiple-jpeg-decoders
wip: try to add a jpeg decoder without colorspace conversion: not working now
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 11 Jul 2023 10:25:58 +0200 |
parents | 138e9d0c08c1 |
children |
comparison
equal
deleted
inserted
replaced
5360:165b67c02927 | 5363:3c8286e5d07b |
---|---|
98 # endif | 98 # endif |
99 #endif | 99 #endif |
100 | 100 |
101 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 | 101 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
102 # include <dcmtk/dcmjpeg/djdecode.h> | 102 # include <dcmtk/dcmjpeg/djdecode.h> |
103 # include <dcmtk/dcmjpeg/djcparam.h> | |
104 # include <dcmtk/dcmjpeg/djdecbas.h> | |
103 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 | 105 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
104 # include <dcmtk/dcmjpeg/djencode.h> | 106 # include <dcmtk/dcmjpeg/djencode.h> |
105 # endif | 107 # endif |
108 | |
106 #endif | 109 #endif |
107 | 110 |
108 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 | 111 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
109 # include <dcmtk/dcmjpls/djdecode.h> | 112 # include <dcmtk/dcmjpls/djdecode.h> |
110 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 | 113 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
123 static bool hasExternalDictionaries_ = false; | 126 static bool hasExternalDictionaries_ = false; |
124 | 127 |
125 | 128 |
126 namespace Orthanc | 129 namespace Orthanc |
127 { | 130 { |
131 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 | |
132 /** representation parameter for JPEG compression without colorspace conversion. | |
133 */ | |
134 class DcmJpegNoConversionRepresentationParameter: public DcmRepresentationParameter | |
135 { | |
136 public: | |
137 | |
138 DcmJpegNoConversionRepresentationParameter() | |
139 {} | |
140 | |
141 DcmJpegNoConversionRepresentationParameter(const DcmJpegNoConversionRepresentationParameter& arg) | |
142 {} | |
143 | |
144 virtual ~DcmJpegNoConversionRepresentationParameter() | |
145 {} | |
146 | |
147 virtual DcmRepresentationParameter *clone() const | |
148 { | |
149 return new DcmJpegNoConversionRepresentationParameter(); | |
150 } | |
151 | |
152 virtual const char *className() const | |
153 { | |
154 return "DcmJpegNoConversion"; | |
155 } | |
156 | |
157 virtual OFBool operator==(const DcmRepresentationParameter &arg) const | |
158 { | |
159 return arg.className() == className(); | |
160 } | |
161 | |
162 }; | |
163 #endif | |
164 | |
165 | |
128 static bool IsBinaryTag(const DcmTag& key) | 166 static bool IsBinaryTag(const DcmTag& key) |
129 { | 167 { |
130 return (key.isUnknownVR() || | 168 return (key.isUnknownVR() || |
131 key.getEVR() == EVR_OB || | 169 key.getEVR() == EVR_OB || |
132 key.getEVR() == EVR_OW || | 170 key.getEVR() == EVR_OW || |
1651 } | 1689 } |
1652 | 1690 |
1653 | 1691 |
1654 bool FromDcmtkBridge::Transcode(DcmFileFormat& dicom, | 1692 bool FromDcmtkBridge::Transcode(DcmFileFormat& dicom, |
1655 DicomTransferSyntax syntax, | 1693 DicomTransferSyntax syntax, |
1656 const DcmRepresentationParameter* representation) | 1694 const DcmRepresentationParameter* representation, |
1695 bool enableColorMapConversion) | |
1657 { | 1696 { |
1658 E_TransferSyntax xfer; | 1697 E_TransferSyntax xfer; |
1659 if (!LookupDcmtkTransferSyntax(xfer, syntax)) | 1698 if (!LookupDcmtkTransferSyntax(xfer, syntax)) |
1660 { | 1699 { |
1661 throw OrthancException(ErrorCode_InternalError); | 1700 throw OrthancException(ErrorCode_InternalError); |
1663 else | 1702 else |
1664 { | 1703 { |
1665 DicomTransferSyntax sourceSyntax; | 1704 DicomTransferSyntax sourceSyntax; |
1666 bool known = LookupOrthancTransferSyntax(sourceSyntax, dicom); | 1705 bool known = LookupOrthancTransferSyntax(sourceSyntax, dicom); |
1667 | 1706 |
1707 if (enableColorMapConversion && representation == NULL) | |
1708 { | |
1709 DcmJpegNoConversionRepresentationParameter param; | |
1710 return Transcode(dicom, syntax, ¶m, enableColorMapConversion); | |
1711 } | |
1712 | |
1713 // DJCodecParameter* cp = new DJCodecParameter( | |
1714 // ECC_lossyYCbCr, // ignored, compression only | |
1715 // EDC_never, | |
1716 // EUC_default, | |
1717 // EPC_default, | |
1718 // OFFalse, | |
1719 // OFFalse, | |
1720 // OFFalse); | |
1721 | |
1722 // // baseline JPEG | |
1723 // DJDecoderBaseline* decbas = new DJDecoderBaseline(); | |
1724 // if (decbas) DcmCodecList::registerCodec(decbas, NULL, cp); | |
1725 | |
1726 | |
1727 | |
1668 if (!dicom.chooseRepresentation(xfer, representation).good() || | 1728 if (!dicom.chooseRepresentation(xfer, representation).good() || |
1669 !dicom.canWriteXfer(xfer) || | 1729 !dicom.canWriteXfer(xfer) || |
1670 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good()) | 1730 !dicom.validateMetaInfo(xfer, EWM_updateMeta).good()) |
1671 { | 1731 { |
1672 return false; | 1732 return false; |
2466 #endif | 2526 #endif |
2467 | 2527 |
2468 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 | 2528 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
2469 CLOG(INFO, DICOM) << "Registering JPEG codecs in DCMTK"; | 2529 CLOG(INFO, DICOM) << "Registering JPEG codecs in DCMTK"; |
2470 DJDecoderRegistration::registerCodecs(); | 2530 DJDecoderRegistration::registerCodecs(); |
2531 | |
2532 // register a "no colorspace conversion" codec (this is a copy of part of DJDecoderRegistration::registerCodecs()) | |
2533 TODO: this does not work -> ask DCMTK forum | |
2534 DJCodecParameter* cp = new DJCodecParameter( | |
2535 ECC_lossyYCbCr, // ignored, compression only | |
2536 EDC_never, | |
2537 EUC_default, | |
2538 EPC_default, | |
2539 OFFalse, | |
2540 OFFalse, | |
2541 OFFalse); | |
2542 | |
2543 // // baseline JPEG | |
2544 DJDecoderBaseline* decbas = new DJDecoderBaseline(); | |
2545 if (decbas) | |
2546 { | |
2547 DcmCodecList::registerCodec(decbas, new DcmJpegNoConversionRepresentationParameter(), cp); | |
2548 } | |
2549 | |
2471 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 | 2550 # if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 |
2472 DJEncoderRegistration::registerCodecs(); | 2551 DJEncoderRegistration::registerCodecs(); |
2473 # endif | 2552 # endif |
2474 #endif | 2553 #endif |
2475 | 2554 |