Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1902:8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Jan 2016 13:26:51 +0100 |
parents | b1291df2f780 |
children | d7c1cb559431 |
comparison
equal
deleted
inserted
replaced
1901:50234539a0dd | 1902:8b0ee8d5e6d0 |
---|---|
56 #include "../../Core/Images/PngReader.h" | 56 #include "../../Core/Images/PngReader.h" |
57 #include "../../Core/Images/PngWriter.h" | 57 #include "../../Core/Images/PngWriter.h" |
58 #include "../../Core/Images/JpegReader.h" | 58 #include "../../Core/Images/JpegReader.h" |
59 #include "../../Core/Images/JpegWriter.h" | 59 #include "../../Core/Images/JpegWriter.h" |
60 #include "../../Core/Images/ImageProcessing.h" | 60 #include "../../Core/Images/ImageProcessing.h" |
61 #include "../../OrthancServer/DefaultDicomImageDecoder.h" | |
61 #include "PluginsEnumerations.h" | 62 #include "PluginsEnumerations.h" |
62 | 63 |
63 #include <boost/regex.hpp> | 64 #include <boost/regex.hpp> |
64 #include <dcmtk/dcmdata/dcdict.h> | 65 #include <dcmtk/dcmdata/dcdict.h> |
65 #include <dcmtk/dcmdata/dcdicent.h> | 66 #include <dcmtk/dcmdata/dcdicent.h> |
1307 break; | 1308 break; |
1308 } | 1309 } |
1309 | 1310 |
1310 case OrthancPluginImageFormat_Dicom: | 1311 case OrthancPluginImageFormat_Dicom: |
1311 { | 1312 { |
1312 ParsedDicomFile dicom(p.data, p.size); | 1313 image.reset(Decode(p.data, p.size, 0)); |
1313 image.reset(Decode(dicom, 0)); | |
1314 break; | 1314 break; |
1315 } | 1315 } |
1316 | 1316 |
1317 default: | 1317 default: |
1318 throw OrthancException(ErrorCode_ParameterOutOfRange); | 1318 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1561 result->AssignWritable(Plugins::Convert(p.format), p.width, p.height, p.pitch, p.buffer); | 1561 result->AssignWritable(Plugins::Convert(p.format), p.width, p.height, p.pitch, p.buffer); |
1562 break; | 1562 break; |
1563 | 1563 |
1564 case _OrthancPluginService_DecodeDicomImage: | 1564 case _OrthancPluginService_DecodeDicomImage: |
1565 { | 1565 { |
1566 ParsedDicomFile dicom(p.constBuffer, p.bufferSize); | 1566 result.reset(Decode(p.constBuffer, p.bufferSize, p.frameIndex)); |
1567 result.reset(Decode(dicom, p.frameIndex)); | |
1568 break; | 1567 break; |
1569 } | 1568 } |
1570 | 1569 |
1571 default: | 1570 default: |
1572 throw OrthancException(ErrorCode_InternalError); | 1571 throw OrthancException(ErrorCode_InternalError); |
2374 boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); | 2373 boost::mutex::scoped_lock lock(pimpl_->worklistCallbackMutex_); |
2375 return pimpl_->worklistCallback_ != NULL; | 2374 return pimpl_->worklistCallback_ != NULL; |
2376 } | 2375 } |
2377 | 2376 |
2378 | 2377 |
2379 ImageAccessor* OrthancPlugins::Decode(ParsedDicomFile& dicom, | 2378 ImageAccessor* OrthancPlugins::Decode(const void* dicom, |
2379 size_t size, | |
2380 unsigned int frame) | 2380 unsigned int frame) |
2381 { | 2381 { |
2382 { | 2382 { |
2383 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_); | 2383 boost::mutex::scoped_lock lock(pimpl_->decodeImageCallbackMutex_); |
2384 if (pimpl_->decodeImageCallback_ != NULL) | 2384 if (pimpl_->decodeImageCallback_ != NULL) |
2385 { | 2385 { |
2386 std::string s; | |
2387 dicom.SaveToMemoryBuffer(s); | |
2388 | |
2389 OrthancPluginImage* pluginImage = NULL; | 2386 OrthancPluginImage* pluginImage = NULL; |
2390 if (pimpl_->decodeImageCallback_(&pluginImage, s.c_str(), s.size(), frame) == OrthancPluginErrorCode_Success && | 2387 if (pimpl_->decodeImageCallback_(&pluginImage, dicom, size, frame) == OrthancPluginErrorCode_Success && |
2391 pluginImage != NULL) | 2388 pluginImage != NULL) |
2392 { | 2389 { |
2393 return reinterpret_cast<ImageAccessor*>(pluginImage); | 2390 return reinterpret_cast<ImageAccessor*>(pluginImage); |
2394 } | 2391 } |
2395 | 2392 |
2396 LOG(WARNING) << "The custom image decoder cannot handle an image, fallback to the built-in decoder"; | 2393 LOG(WARNING) << "The custom image decoder cannot handle an image, fallback to the built-in decoder"; |
2397 } | 2394 } |
2398 } | 2395 } |
2399 | 2396 |
2400 DicomImageDecoder defaultDecoder; | 2397 DefaultDicomImageDecoder defaultDecoder; |
2401 return defaultDecoder.Decode(dicom, frame); | 2398 return defaultDecoder.Decode(dicom, size, frame); |
2402 } | 2399 } |
2403 } | 2400 } |