Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.cpp @ 5666:aa231c18b9d2 find-refactoring
adding computed tags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Jul 2024 18:31:54 +0200 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
3893 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5480
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3893 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
12 * the License, or (at your option) any later version. |
3893 | 13 * |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * Lesser General Public License for more details. |
3893 | 18 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
3893 | 22 **/ |
23 | |
24 | |
25 #include "../PrecompiledHeaders.h" | |
26 #include "DcmtkTranscoder.h" | |
27 | |
28 | |
29 #if !defined(ORTHANC_ENABLE_DCMTK_JPEG) | |
30 # error Macro ORTHANC_ENABLE_DCMTK_JPEG must be defined | |
31 #endif | |
32 | |
33 #if !defined(ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS) | |
34 # error Macro ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS must be defined | |
35 #endif | |
36 | |
37 | |
38 #include "FromDcmtkBridge.h" | |
4304 | 39 #include "../Logging.h" |
3893 | 40 #include "../OrthancException.h" |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
41 #include "../Toolbox.h" |
3893 | 42 |
43 #include <dcmtk/dcmdata/dcdeftag.h> | |
44 #include <dcmtk/dcmjpeg/djrploss.h> // for DJ_RPLossy | |
45 #include <dcmtk/dcmjpeg/djrplol.h> // for DJ_RPLossless | |
46 #include <dcmtk/dcmjpls/djrparam.h> // for DJLSRepresentationParameter | |
47 | |
4304 | 48 #include <boost/lexical_cast.hpp> |
49 | |
3893 | 50 |
51 namespace Orthanc | |
52 { | |
4297 | 53 DcmtkTranscoder::DcmtkTranscoder() : |
54 lossyQuality_(90) | |
55 { | |
56 } | |
57 | |
58 | |
3938 | 59 static bool GetBitsStored(uint16_t& bitsStored, |
60 DcmDataset& dataset) | |
3893 | 61 { |
3938 | 62 return dataset.findAndGetUint16(DCM_BitsStored, bitsStored).good(); |
3893 | 63 } |
64 | |
65 | |
66 void DcmtkTranscoder::SetLossyQuality(unsigned int quality) | |
67 { | |
4200 | 68 if (quality == 0 || |
3893 | 69 quality > 100) |
70 { | |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
71 throw OrthancException( |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
72 ErrorCode_ParameterOutOfRange, |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
73 "The quality for lossy transcoding must be an integer between 1 and 100, received: " + |
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
74 boost::lexical_cast<std::string>(quality)); |
3893 | 75 } |
76 else | |
77 { | |
3939
c205f670098e
new configuration options: BuiltinDecoderTranscoderOrder and IngestTranscoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3938
diff
changeset
|
78 LOG(INFO) << "Quality for lossy transcoding using DCMTK is set to: " << quality; |
3893 | 79 lossyQuality_ = quality; |
80 } | |
81 } | |
82 | |
4297 | 83 unsigned int DcmtkTranscoder::GetLossyQuality() const |
84 { | |
85 return lossyQuality_; | |
86 } | |
87 | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
88 bool TryTranscode(std::vector<std::string>& failureReasons, /* out */ |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
89 DicomTransferSyntax& selectedSyntax, /* out*/ |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
90 DcmFileFormat& dicom, /* in/out */ |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
91 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
92 DicomTransferSyntax trySyntax) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
93 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
94 if (allowedSyntaxes.find(trySyntax) != allowedSyntaxes.end()) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
95 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
96 if (FromDcmtkBridge::Transcode(dicom, trySyntax, NULL)) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
97 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
98 selectedSyntax = trySyntax; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
99 return true; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
100 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
101 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
102 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(trySyntax)); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
103 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
104 return false; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
105 } |
4297 | 106 |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3946
diff
changeset
|
107 bool DcmtkTranscoder::InplaceTranscode(DicomTransferSyntax& selectedSyntax /* out */, |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
108 std::string& failureReason /* out */, |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
109 DcmFileFormat& dicom, /* in/out */ |
3893 | 110 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
111 bool allowNewSopInstanceUid) | |
112 { | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
113 std::vector<std::string> failureReasons; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
114 |
3893 | 115 if (dicom.getDataset() == NULL) |
116 { | |
117 throw OrthancException(ErrorCode_InternalError); | |
118 } | |
119 | |
120 DicomTransferSyntax syntax; | |
121 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(syntax, dicom)) | |
122 { | |
123 throw OrthancException(ErrorCode_BadFileFormat, | |
124 "Cannot determine the transfer syntax"); | |
125 } | |
126 | |
3938 | 127 uint16_t bitsStored; |
128 bool hasBitsStored = GetBitsStored(bitsStored, *dicom.getDataset()); | |
129 | |
3893 | 130 if (allowedSyntaxes.find(syntax) != allowedSyntaxes.end()) |
131 { | |
132 // No transcoding is needed | |
133 return true; | |
134 } | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
135 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
136 if (TryTranscode(failureReasons, selectedSyntax, dicom, allowedSyntaxes, DicomTransferSyntax_LittleEndianImplicit)) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
137 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
138 return true; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
139 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
140 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
141 if (TryTranscode(failureReasons, selectedSyntax, dicom, allowedSyntaxes, DicomTransferSyntax_LittleEndianExplicit)) |
3893 | 142 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
143 return true; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
144 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
145 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
146 if (TryTranscode(failureReasons, selectedSyntax, dicom, allowedSyntaxes, DicomTransferSyntax_BigEndianExplicit)) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
147 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
148 return true; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
149 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
150 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
151 if (TryTranscode(failureReasons, selectedSyntax, dicom, allowedSyntaxes, DicomTransferSyntax_DeflatedLittleEndianExplicit)) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
152 { |
3893 | 153 return true; |
154 } | |
155 | |
156 | |
157 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
158 if (allowedSyntaxes.find(DicomTransferSyntax_JPEGProcess1) != allowedSyntaxes.end()) |
3893 | 159 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
160 if (!allowNewSopInstanceUid) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
161 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
162 failureReasons.push_back(std::string("Can not transcode to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess1) + " without generating new SOPInstanceUID"); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
163 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
164 else if (hasBitsStored && bitsStored != 8) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
165 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
166 failureReasons.push_back(std::string("Can not transcode to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess1) + " if BitsStored != 8"); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
167 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
168 else |
3893 | 169 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
170 // Check out "dcmjpeg/apps/dcmcjpeg.cc" |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
171 DJ_RPLossy parameters(lossyQuality_); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
172 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
173 if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGProcess1, ¶meters)) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
174 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
175 selectedSyntax = DicomTransferSyntax_JPEGProcess1; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
176 return true; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
177 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
178 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess1)); |
3893 | 179 } |
180 } | |
181 #endif | |
182 | |
183 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
184 if (allowedSyntaxes.find(DicomTransferSyntax_JPEGProcess2_4) != allowedSyntaxes.end()) |
3893 | 185 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
186 if (!allowNewSopInstanceUid) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
187 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
188 failureReasons.push_back(std::string("Can not transcode to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess2_4) + " without generating new SOPInstanceUID"); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
189 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
190 else if (hasBitsStored && bitsStored > 12) |
3893 | 191 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
192 failureReasons.push_back(std::string("Can not transcode to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess2_4) + " if BitsStored != 8"); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
193 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
194 else |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
195 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
196 // Check out "dcmjpeg/apps/dcmcjpeg.cc" |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
197 DJ_RPLossy parameters(lossyQuality_); |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
198 if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGProcess2_4, ¶meters)) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
199 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
200 selectedSyntax = DicomTransferSyntax_JPEGProcess2_4; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
201 return true; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
202 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
203 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess2_4)); |
3893 | 204 } |
205 } | |
206 #endif | |
207 | |
208 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 | |
3902
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
209 if (allowedSyntaxes.find(DicomTransferSyntax_JPEGProcess14) != allowedSyntaxes.end()) |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
210 { |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
211 // Check out "dcmjpeg/apps/dcmcjpeg.cc" |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
212 DJ_RPLossless parameters(6 /* opt_selection_value */, |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
213 0 /* opt_point_transform */); |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
214 if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGProcess14, ¶meters)) |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
215 { |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
216 selectedSyntax = DicomTransferSyntax_JPEGProcess14; |
3902
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
217 return true; |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
218 } |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
219 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess14)); |
3902
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
220 } |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
221 #endif |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
222 |
7459fcb1bdf7
transcoding to 1.2.840.10008.1.2.4.57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
223 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
3893 | 224 if (allowedSyntaxes.find(DicomTransferSyntax_JPEGProcess14SV1) != allowedSyntaxes.end()) |
225 { | |
226 // Check out "dcmjpeg/apps/dcmcjpeg.cc" | |
227 DJ_RPLossless parameters(6 /* opt_selection_value */, | |
228 0 /* opt_point_transform */); | |
229 if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGProcess14SV1, ¶meters)) | |
230 { | |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
231 selectedSyntax = DicomTransferSyntax_JPEGProcess14SV1; |
3893 | 232 return true; |
233 } | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
234 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGProcess14SV1)); |
3893 | 235 } |
236 #endif | |
237 | |
238 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 | |
239 if (allowedSyntaxes.find(DicomTransferSyntax_JPEGLSLossless) != allowedSyntaxes.end()) | |
240 { | |
241 // Check out "dcmjpls/apps/dcmcjpls.cc" | |
242 DJLSRepresentationParameter parameters(2 /* opt_nearlossless_deviation */, | |
243 OFTrue /* opt_useLosslessProcess */); | |
244 | |
245 /** | |
246 * WARNING: This call results in a segmentation fault if using | |
247 * the DCMTK package 3.6.2 from Ubuntu 18.04. | |
248 **/ | |
249 if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGLSLossless, ¶meters)) | |
250 { | |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
251 selectedSyntax = DicomTransferSyntax_JPEGLSLossless; |
3893 | 252 return true; |
253 } | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
254 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGLSLossless)); |
3893 | 255 } |
256 #endif | |
257 | |
258 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 | |
259 if (allowNewSopInstanceUid && | |
260 allowedSyntaxes.find(DicomTransferSyntax_JPEGLSLossy) != allowedSyntaxes.end()) | |
261 { | |
262 // Check out "dcmjpls/apps/dcmcjpls.cc" | |
263 DJLSRepresentationParameter parameters(2 /* opt_nearlossless_deviation */, | |
264 OFFalse /* opt_useLosslessProcess */); | |
265 | |
266 /** | |
267 * WARNING: This call results in a segmentation fault if using | |
268 * the DCMTK package 3.6.2 from Ubuntu 18.04. | |
269 **/ | |
270 if (FromDcmtkBridge::Transcode(dicom, DicomTransferSyntax_JPEGLSLossy, ¶meters)) | |
271 { | |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
272 selectedSyntax = DicomTransferSyntax_JPEGLSLossy; |
3893 | 273 return true; |
274 } | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
275 failureReasons.push_back(std::string("Internal error while transcoding to ") + GetTransferSyntaxUid(DicomTransferSyntax_JPEGLSLossy)); |
3893 | 276 } |
277 #endif | |
278 | |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
279 Orthanc::Toolbox::JoinStrings(failureReason, failureReasons, ", "); |
3893 | 280 return false; |
281 } | |
282 | |
3904
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
283 bool DcmtkTranscoder::IsSupported(DicomTransferSyntax syntax) |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
284 { |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
285 if (syntax == DicomTransferSyntax_LittleEndianImplicit || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
286 syntax == DicomTransferSyntax_LittleEndianExplicit || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
287 syntax == DicomTransferSyntax_BigEndianExplicit || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
288 syntax == DicomTransferSyntax_DeflatedLittleEndianExplicit) |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
289 { |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
290 return true; |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
291 } |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
292 |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
293 #if ORTHANC_ENABLE_DCMTK_JPEG == 1 |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
294 if (syntax == DicomTransferSyntax_JPEGProcess1 || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
295 syntax == DicomTransferSyntax_JPEGProcess2_4 || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
296 syntax == DicomTransferSyntax_JPEGProcess14 || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
297 syntax == DicomTransferSyntax_JPEGProcess14SV1) |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
298 { |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
299 return true; |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
300 } |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
301 #endif |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
302 |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
303 #if ORTHANC_ENABLE_DCMTK_JPEG_LOSSLESS == 1 |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
304 if (syntax == DicomTransferSyntax_JPEGLSLossless || |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
305 syntax == DicomTransferSyntax_JPEGLSLossy) |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
306 { |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
307 return true; |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
308 } |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
309 #endif |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
310 |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
311 return false; |
c62f84c7eda9
fixing incorrect behavior in MemoryBufferTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3902
diff
changeset
|
312 } |
3906
f0dd5ded8927
refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3904
diff
changeset
|
313 |
f0dd5ded8927
refactoring using IDicomTranscoder::TranscodedDicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3904
diff
changeset
|
314 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
315 bool DcmtkTranscoder::Transcode(DicomImage& target, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
316 DicomImage& source /* in, "GetParsed()" possibly modified */, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
317 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
318 bool allowNewSopInstanceUid) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
319 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
320 target.Clear(); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
321 |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
322 DicomTransferSyntax sourceSyntax; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
323 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, source.GetParsed())) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
324 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
325 LOG(ERROR) << "Unsupport transfer syntax for transcoding"; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
326 return false; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
327 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
328 |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
329 std::string failureReason; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
330 std::string s; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
331 for (std::set<DicomTransferSyntax>::const_iterator |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
332 it = allowedSyntaxes.begin(); it != allowedSyntaxes.end(); ++it) |
3981
31252a887f0b
info log about dcmtk transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
333 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
334 if (!s.empty()) |
3981
31252a887f0b
info log about dcmtk transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
335 { |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
336 s += ", "; |
3981
31252a887f0b
info log about dcmtk transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
337 } |
31252a887f0b
info log about dcmtk transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
338 |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
339 s += GetTransferSyntaxUid(*it); |
3981
31252a887f0b
info log about dcmtk transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
340 } |
31252a887f0b
info log about dcmtk transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3951
diff
changeset
|
341 |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
342 if (s.empty()) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
343 { |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
344 s = "<none>"; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
345 } |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
346 |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
347 LOG(INFO) << "DCMTK transcoding from " << GetTransferSyntaxUid(sourceSyntax) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
348 << " to one of: " << s; |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
349 |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
350 #if !defined(NDEBUG) |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
351 const std::string sourceSopInstanceUid = GetSopInstanceUid(source.GetParsed()); |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
352 #endif |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
353 |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
354 DicomTransferSyntax targetSyntax; |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
355 if (allowedSyntaxes.find(sourceSyntax) != allowedSyntaxes.end()) |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
356 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
357 // No transcoding is needed |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
358 target.AcquireParsed(source); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
359 target.AcquireBuffer(source); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
360 return true; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
361 } |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
362 else if (InplaceTranscode(targetSyntax, failureReason, source.GetParsed(), |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
363 allowedSyntaxes, allowNewSopInstanceUid)) |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
364 { |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
365 // Sanity check |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
366 DicomTransferSyntax targetSyntax2; |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
367 if (FromDcmtkBridge::LookupOrthancTransferSyntax(targetSyntax2, source.GetParsed()) && |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
368 targetSyntax == targetSyntax2 && |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
369 allowedSyntaxes.find(targetSyntax2) != allowedSyntaxes.end()) |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
370 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
371 target.AcquireParsed(source); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
372 source.Clear(); |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
373 |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
374 #if !defined(NDEBUG) |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
375 // Only run the sanity check in debug mode |
3951
5fe8c6d3212e
removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3946
diff
changeset
|
376 CheckTranscoding(target, sourceSyntax, sourceSopInstanceUid, |
3946
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
377 allowedSyntaxes, allowNewSopInstanceUid); |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
378 #endif |
1f33ed7f82e6
automatic test of transcoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3945
diff
changeset
|
379 |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
380 return true; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
381 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
382 else |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
383 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
384 throw OrthancException(ErrorCode_InternalError); |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
385 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
386 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
387 else |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
388 { |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
389 // Cannot transcode |
5480
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
390 LOG(WARNING) << "DCMTK was unable to transcode from " << GetTransferSyntaxUid(sourceSyntax) |
58b91f5f4e79
more detailed log if InPlaceTranscode fails
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
391 << " to one of: " << s << " " << failureReason; |
3944
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
392 return false; |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
393 } |
aae045f802f4
preparing simplified interface for IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3939
diff
changeset
|
394 } |
3893 | 395 } |