comparison Core/DicomParsing/MemoryBufferTranscoder.cpp @ 3946:1f33ed7f82e6 transcoding

automatic test of transcoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 May 2020 13:44:56 +0200
parents 0b3256c3ee14
children 5fe8c6d3212e
comparison
equal deleted inserted replaced
3945:0b3256c3ee14 3946:1f33ed7f82e6
72 const std::set<DicomTransferSyntax>& allowedSyntaxes, 72 const std::set<DicomTransferSyntax>& allowedSyntaxes,
73 bool allowNewSopInstanceUid) 73 bool allowNewSopInstanceUid)
74 { 74 {
75 target.Clear(); 75 target.Clear();
76 76
77 #if !defined(NDEBUG)
78 // Don't run this code in release mode, as it implies parsing the DICOM file
79 DicomTransferSyntax sourceSyntax;
80 if (!FromDcmtkBridge::LookupOrthancTransferSyntax(sourceSyntax, source.GetParsed()))
81 {
82 LOG(ERROR) << "Unsupport transfer syntax for transcoding";
83 return false;
84 }
85
86 const std::string sourceSopInstanceUid = GetSopInstanceUid(source.GetParsed());
87 #endif
88
77 std::string buffer; 89 std::string buffer;
78 if (TranscodeBuffer(buffer, hasSopInstanceUidChanged, source.GetBufferData(), 90 if (TranscodeBuffer(buffer, hasSopInstanceUidChanged, source.GetBufferData(),
79 source.GetBufferSize(), allowedSyntaxes, allowNewSopInstanceUid)) 91 source.GetBufferSize(), allowedSyntaxes, allowNewSopInstanceUid))
80 { 92 {
81 CheckTargetSyntax(buffer, allowedSyntaxes); // For debug only 93 CheckTargetSyntax(buffer, allowedSyntaxes); // For debug only
94
82 target.AcquireBuffer(buffer); 95 target.AcquireBuffer(buffer);
96
97 #if !defined(NDEBUG)
98 // Only run the sanity check in debug mode
99 CheckTranscoding(target, hasSopInstanceUidChanged, sourceSyntax, sourceSopInstanceUid,
100 allowedSyntaxes, allowNewSopInstanceUid);
101 #endif
102
83 return true; 103 return true;
84 } 104 }
85 else 105 else
86 { 106 {
87 return false; 107 return false;