Mercurial > hg > orthanc
comparison Core/DicomParsing/MemoryBufferTranscoder.cpp @ 3908:89ebb37cee6a transcoding
removing leaky abstraction about inplace transcoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 08 May 2020 11:30:32 +0200 |
parents | 1555feda39e2 |
children | 6762a97deabc |
comparison
equal
deleted
inserted
replaced
3907:1555feda39e2 | 3908:89ebb37cee6a |
---|---|
85 return Transcode(target, sourceSyntax, targetSyntax, hasSopInstanceUidChanged, buffer, size, | 85 return Transcode(target, sourceSyntax, targetSyntax, hasSopInstanceUidChanged, buffer, size, |
86 allowedSyntaxes, allowNewSopInstanceUid); | 86 allowedSyntaxes, allowNewSopInstanceUid); |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 bool MemoryBufferTranscoder::HasInplaceTranscode( | |
91 DicomTransferSyntax inputSyntax, | |
92 const std::set<DicomTransferSyntax>& outputSyntaxes) const | |
93 { | |
94 /** | |
95 * Inplace transcoding is only possible if DCMTK is enabled, and | |
96 * if DCMTK supports all the requested transfer | |
97 * syntaxes. Otherwise, one has to call the "buffer-to-buffer" | |
98 * transcoder. | |
99 **/ | |
100 | |
101 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 | |
102 if (useDcmtk_) | |
103 { | |
104 if (!DcmtkTranscoder::IsSupported(inputSyntax)) | |
105 { | |
106 return false; | |
107 } | |
108 | |
109 for (std::set<DicomTransferSyntax>::const_iterator | |
110 it = outputSyntaxes.begin(); it != outputSyntaxes.end(); ++it) | |
111 { | |
112 if (!DcmtkTranscoder::IsSupported(*it)) | |
113 { | |
114 return false; | |
115 } | |
116 } | |
117 | |
118 return true; | |
119 } | |
120 else | |
121 #endif | |
122 { | |
123 return false; | |
124 } | |
125 } | |
126 | |
127 | |
128 bool MemoryBufferTranscoder::InplaceTranscode(bool& hasSopInstanceUidChanged, | |
129 DcmFileFormat& dicom, | |
130 const std::set<DicomTransferSyntax>& allowedSyntaxes, | |
131 bool allowNewSopInstanceUid) | |
132 { | |
133 #if ORTHANC_ENABLE_DCMTK_TRANSCODING == 1 | |
134 DicomTransferSyntax inputSyntax; | |
135 if (useDcmtk_ && | |
136 FromDcmtkBridge::LookupOrthancTransferSyntax(inputSyntax, dicom) && | |
137 HasInplaceTranscode(inputSyntax, allowedSyntaxes)) | |
138 { | |
139 return dcmtk_.InplaceTranscode(hasSopInstanceUidChanged, dicom, allowedSyntaxes, allowNewSopInstanceUid); | |
140 } | |
141 else | |
142 #endif | |
143 { | |
144 // "HasInplaceTranscode()" should have been called | |
145 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
146 } | |
147 } | |
148 | |
149 | |
150 | |
151 | |
152 bool MemoryBufferTranscoder::TranscodeParsedToBuffer( | 90 bool MemoryBufferTranscoder::TranscodeParsedToBuffer( |
153 std::string& target /* out */, | 91 std::string& target /* out */, |
154 DicomTransferSyntax& sourceSyntax /* out */, | 92 DicomTransferSyntax& sourceSyntax /* out */, |
155 DicomTransferSyntax& targetSyntax /* out */, | 93 DicomTransferSyntax& targetSyntax /* out */, |
156 bool& hasSopInstanceUidChanged /* out */, | 94 bool& hasSopInstanceUidChanged /* out */, |