Mercurial > hg > orthanc
comparison OrthancServer/Internals/DicomFrameIndex.cpp @ 1950:533ff46e944b
return a single raw frame from DICOM videos
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Apr 2016 11:07:02 +0200 |
parents | cda5b0ab4ce5 |
children | 01de36d949c3 |
comparison
equal
deleted
inserted
replaced
1949:d90f737f2dde | 1950:533ff46e944b |
---|---|
35 | 35 |
36 #include "../../Core/OrthancException.h" | 36 #include "../../Core/OrthancException.h" |
37 #include "../../Core/DicomFormat/DicomImageInformation.h" | 37 #include "../../Core/DicomFormat/DicomImageInformation.h" |
38 #include "../FromDcmtkBridge.h" | 38 #include "../FromDcmtkBridge.h" |
39 #include "../OrthancInitialization.h" | 39 #include "../OrthancInitialization.h" |
40 #include "../../Core/Endianness.h" | |
40 #include "DicomImageDecoder.h" | 41 #include "DicomImageDecoder.h" |
41 | 42 |
42 #include <boost/lexical_cast.hpp> | 43 #include <boost/lexical_cast.hpp> |
43 | 44 |
44 #include <dcmtk/dcmdata/dcdeftag.h> | 45 #include <dcmtk/dcmdata/dcdeftag.h> |
45 #include <dcmtk/dcmdata/dcpxitem.h> | 46 #include <dcmtk/dcmdata/dcpxitem.h> |
46 #include <dcmtk/dcmdata/dcpixseq.h> | 47 #include <dcmtk/dcmdata/dcpixseq.h> |
47 | |
48 #if defined(_WIN32) // Windows machines are always little-endian | |
49 # define le32toh(x) x | |
50 #elif defined(__APPLE__) | |
51 # include <libkern/OSByteOrder.h> | |
52 # define le32toh(x) OSSwapLittleToHostInt32(x) | |
53 #else | |
54 # include <endian.h> | |
55 #endif | |
56 | |
57 | 48 |
58 namespace Orthanc | 49 namespace Orthanc |
59 { | 50 { |
60 class DicomFrameIndex::FragmentIndex : public DicomFrameIndex::IIndex | 51 class DicomFrameIndex::FragmentIndex : public DicomFrameIndex::IIndex |
61 { | 52 { |
326 } | 317 } |
327 }; | 318 }; |
328 | 319 |
329 | 320 |
330 | 321 |
322 bool DicomFrameIndex::IsVideo(const DcmDataset& dataset) | |
323 { | |
324 if (dataset.getOriginalXfer() == EXS_MPEG2MainProfileAtMainLevel || | |
325 dataset.getOriginalXfer() == EXS_MPEG2MainProfileAtHighLevel) | |
326 { | |
327 return true; | |
328 } | |
329 | |
330 #if DCMTK_VERSION_NUMBER > 360 | |
331 // New transfer syntaxes introduced in the DICOM standard after DCMTK 3.6.0 | |
332 if (dataset.getOriginalXfer() == EXS_MPEG4HighProfileLevel4 || | |
333 dataset.getOriginalXfer() == EXS_MPEG4BDcompatibleHighProfileLevel4 || | |
334 dataset.getOriginalXfer() == EXS_MPEG4HighProfileLevel4_2_For2DVideo || | |
335 dataset.getOriginalXfer() == EXS_MPEG4HighProfileLevel4_2_For3DVideo || | |
336 dataset.getOriginalXfer() == EXS_MPEG4StereoHighProfileLevel4_2) | |
337 { | |
338 return true; | |
339 } | |
340 #endif | |
341 | |
342 return false; | |
343 } | |
344 | |
331 | 345 |
332 unsigned int DicomFrameIndex::GetFramesCount(DcmDataset& dataset) | 346 unsigned int DicomFrameIndex::GetFramesCount(DcmDataset& dataset) |
333 { | 347 { |
348 // Assume 1 frame for video transfer syntaxes | |
349 if (IsVideo(dataset)) | |
350 { | |
351 return 1; | |
352 } | |
353 | |
334 const char* tmp = NULL; | 354 const char* tmp = NULL; |
335 if (!dataset.findAndGetString(DCM_NumberOfFrames, tmp).good() || | 355 if (!dataset.findAndGetString(DCM_NumberOfFrames, tmp).good() || |
336 tmp == NULL) | 356 tmp == NULL) |
337 { | 357 { |
338 return 1; | 358 return 1; |