Mercurial > hg > orthanc
comparison OrthancServer/ServerContext.cpp @ 3903:d1273d7cc200 transcoding
avoid unnecessary dicom serialization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 May 2020 16:43:08 +0200 |
parents | 8f7ad4989fec |
children | c62f84c7eda9 |
comparison
equal
deleted
inserted
replaced
3902:7459fcb1bdf7 | 3903:d1273d7cc200 |
---|---|
1153 } | 1153 } |
1154 } | 1154 } |
1155 } | 1155 } |
1156 | 1156 |
1157 | 1157 |
1158 bool ServerContext::TranscodeMemoryBuffer(std::string& target, | 1158 bool ServerContext::Transcode(std::string& target, |
1159 bool& hasSopInstanceUidChanged, | 1159 bool& hasSopInstanceUidChanged, |
1160 const std::string& source, | 1160 ParsedDicomFile& dicom, // Possibly modified |
1161 const std::set<DicomTransferSyntax>& allowedSyntaxes, | 1161 const std::set<DicomTransferSyntax>& allowedSyntaxes, |
1162 bool allowNewSopInstanceUid) | 1162 bool allowNewSopInstanceUid) |
1163 { | 1163 { |
1164 const char* data = source.empty() ? NULL : source.c_str(); | 1164 IDicomTranscoder* transcoder = dcmtkTranscoder_.get(); |
1165 | 1165 |
1166 #if ORTHANC_ENABLE_PLUGINS == 1 | 1166 #if ORTHANC_ENABLE_PLUGINS == 1 |
1167 if (HasPlugins()) | 1167 if (HasPlugins()) |
1168 { | 1168 { |
1169 return GetPlugins().TranscodeToBuffer( | 1169 transcoder = &GetPlugins(); |
1170 } | |
1171 #endif | |
1172 | |
1173 if (transcoder == NULL) | |
1174 { | |
1175 throw OrthancException(ErrorCode_InternalError); | |
1176 } | |
1177 else if (transcoder->HasInplaceTranscode()) | |
1178 { | |
1179 if (transcoder->InplaceTranscode(hasSopInstanceUidChanged, dicom.GetDcmtkObject(), | |
1180 allowedSyntaxes, allowNewSopInstanceUid)) | |
1181 { | |
1182 // In-place transcoding is supported and has succeeded | |
1183 dicom.SaveToMemoryBuffer(target); | |
1184 return true; | |
1185 } | |
1186 else | |
1187 { | |
1188 return false; | |
1189 } | |
1190 } | |
1191 else | |
1192 { | |
1193 std::string source; | |
1194 dicom.SaveToMemoryBuffer(source); | |
1195 | |
1196 const char* data = source.empty() ? NULL : source.c_str(); | |
1197 | |
1198 return transcoder->TranscodeToBuffer( | |
1170 target, hasSopInstanceUidChanged, data, source.size(), allowedSyntaxes, allowNewSopInstanceUid); | 1199 target, hasSopInstanceUidChanged, data, source.size(), allowedSyntaxes, allowNewSopInstanceUid); |
1171 } | 1200 } |
1172 #endif | |
1173 | |
1174 assert(dcmtkTranscoder_.get() != NULL); | |
1175 return dcmtkTranscoder_->TranscodeToBuffer( | |
1176 target, hasSopInstanceUidChanged, data, source.size(), allowedSyntaxes, allowNewSopInstanceUid); | |
1177 } | 1201 } |
1178 } | 1202 } |