From 6e24fb9c9d1d09b55ab1a69539fa65d3c648e740 Mon Sep 17 00:00:00 2001 From: Joerg Riesmeier Date: Sat, 25 May 2024 20:52:19 +0200 Subject: [PATCH] Replaced calls of DcmXfer::isEncapsulated(). Replaced calls of DcmXfer::isEncapsulated() and isNotEncapsulated() by the new methods such as hasEncapsulatedFormat(), hasNativeFormat() and isPixelDataCompressed(), because they are deprecated. This is another step towards supporting the Encapsulated Uncompressed Explicit VR Little Endian Transfer Syntax (see DCMTK Conformance #1000). --- dcmdata/apps/dcmcrle.cc | 4 +- dcmdata/apps/dump2dcm.cc | 4 +- dcmdata/apps/mdfdsman.cc | 6 +- dcmdata/apps/xml2dcm.cc | 4 +- dcmdata/libi2d/i2d.cc | 6 +- dcmdata/libsrc/dcdatset.cc | 16 ++-- dcmdata/libsrc/dcpixel.cc | 94 ++++++++++++----------- dcmdata/libsrc/dcpixseq.cc | 4 +- dcmdata/libsrc/dcrleccd.cc | 3 +- dcmdata/libsrc/dcrlecce.cc | 4 +- dcmdata/libsrc/dcvrobow.cc | 3 +- dcmect/libsrc/enhanced_ct.cc | 6 +- dcmimgle/include/dcmtk/dcmimgle/didocu.h | 2 +- dcmimgle/libsrc/didocu.cc | 12 +-- dcmiod/libsrc/iodutil.cc | 2 +- dcmjpeg/apps/dcmcjpeg.cc | 4 +- dcmjpeg/libsrc/djcodecd.cc | 3 +- dcmjpeg/libsrc/djcodece.cc | 3 +- dcmjpls/apps/dcmcjpls.cc | 4 +- dcmjpls/libsrc/djcodecd.cc | 2 +- dcmjpls/libsrc/djcodece.cc | 2 +- dcmnet/apps/getscu.cc | 2 +- dcmnet/apps/storescu.cc | 8 +- dcmpmap/libsrc/dpmparametricmapiod.cc | 9 ++- dcmseg/libsrc/segdoc.cc | 10 +-- dcmtract/libsrc/trctractographyresults.cc | 6 +- 26 files changed, 116 insertions(+), 107 deletions(-) diff --git a/dcmdata/apps/dcmcrle.cc b/dcmdata/apps/dcmcrle.cc index 0a58a100d8..c81fc3402d 100644 --- a/dcmdata/apps/dcmcrle.cc +++ b/dcmdata/apps/dcmcrle.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2002-2022, OFFIS e.V. + * Copyright (C) 2002-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -267,7 +267,7 @@ int main(int argc, char *argv[]) } DcmXfer original_xfer(dataset->getOriginalXfer()); - if (original_xfer.isEncapsulated()) + if (original_xfer.isPixelDataCompressed()) { OFLOG_INFO(dcmcrleLogger, "DICOM file is already compressed, converting to uncompressed transfer syntax first"); if (EC_Normal != dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL)) diff --git a/dcmdata/apps/dump2dcm.cc b/dcmdata/apps/dump2dcm.cc index 9cdc3e7118..f09fa159f3 100644 --- a/dcmdata/apps/dump2dcm.cc +++ b/dcmdata/apps/dump2dcm.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 1994-2023, OFFIS e.V. + * Copyright (C) 1994-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -1067,7 +1067,7 @@ int main(int argc, char *argv[]) if (fileformat.canWriteXfer(opt_xfer)) { /* check whether pixel data is compressed */ - if ((opt_writeMode == EWM_dataset) && DcmXfer(xfer).isEncapsulated()) + if ((opt_writeMode == EWM_dataset) && DcmXfer(xfer).usesEncapsulatedFormat()) { OFLOG_WARN(dump2dcmLogger, "encapsulated pixel data require file format, ignoring --write-dataset"); opt_writeMode = EWM_fileformat; diff --git a/dcmdata/apps/mdfdsman.cc b/dcmdata/apps/mdfdsman.cc index c89891f218..26d288f634 100644 --- a/dcmdata/apps/mdfdsman.cc +++ b/dcmdata/apps/mdfdsman.cc @@ -603,8 +603,8 @@ OFCondition MdfDatasetManager::saveFile(const char* file_name, /* check whether transfer syntax is possible */ if ((opt_xfer == EXS_Unknown) || (dfile->canWriteXfer(opt_xfer))) { - /* check whether pixel data is compressed */ - if (opt_dataset && DcmXfer(opt_xfer).isEncapsulated()) + /* check whether pixel data is encapsulated (e.g. compressed) */ + if (opt_dataset && DcmXfer(opt_xfer).usesEncapsulatedFormat()) { OFLOG_WARN(mdfdsmanLogger, "encapsulated pixel data requires file format, ignoring --write-dataset"); opt_dataset = OFFalse; @@ -714,7 +714,7 @@ OFCondition MdfDatasetManager::checkPixelDataInsertion(DcmElement* elem) const DcmRepresentationParameter* dontCare = NULL; pix->getCurrentRepresentationKey(ts, dontCare); DcmXfer xfer(ts); - if (xfer.isEncapsulated()) + if (xfer.usesEncapsulatedFormat()) { OFLOG_ERROR(mdfdsmanLogger, "Cannot replace encapsulated Pixel Data (not implemented)"); return EC_IllegalParameter; diff --git a/dcmdata/apps/xml2dcm.cc b/dcmdata/apps/xml2dcm.cc index c7529523db..4276cabcf2 100644 --- a/dcmdata/apps/xml2dcm.cc +++ b/dcmdata/apps/xml2dcm.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2003-2022, OFFIS e.V. + * Copyright (C) 2003-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -350,7 +350,7 @@ int main(int argc, char *argv[]) if (fileformat.canWriteXfer(opt_xfer)) { /* check whether pixel data is compressed */ - if ((opt_writeMode == EWM_dataset) && DcmXfer(xfer).isEncapsulated()) + if ((opt_writeMode == EWM_dataset) && DcmXfer(xfer).usesEncapsulatedFormat()) { OFLOG_WARN(xml2dcmLogger, "encapsulated pixel data require file format, ignoring --write-dataset"); opt_writeMode = EWM_fileformat; diff --git a/dcmdata/libi2d/i2d.cc b/dcmdata/libi2d/i2d.cc index c6eb7925f5..73897652fd 100644 --- a/dcmdata/libi2d/i2d.cc +++ b/dcmdata/libi2d/i2d.cc @@ -608,7 +608,7 @@ OFCondition Image2Dcm::readAndInsertPixelDataFirstFrame( if (m_frameLength > 0) compressionRatio = uncompressedSize / m_frameLength; DcmXfer transport(outputTS); - if (transport.isEncapsulated()) + if (transport.usesEncapsulatedFormat()) { m_offsetList.clear(); insertEncapsulatedPixelDataFirstFrame(dset, pixData, m_frameLength, outputTS); @@ -786,7 +786,7 @@ OFCondition Image2Dcm::readAndInsertPixelDataNextFrame( cond = makeOFCondition(OFM_dcmdata, 18, OF_error, "Image2Dcm: value of vertical PixelAspectRatio not equal for all frames of the multi-frame image"); return cond; } - if ((!transport.isEncapsulated()) && (next_frameLength != m_frameLength)) + if (transport.isPixelDataUncompressed() && (next_frameLength != m_frameLength)) { // in the case of uncompressed images, all frames must have exactly the same size. // for compressed images, where we store the compressed bitstream as a pixel item, this does not matter. @@ -804,7 +804,7 @@ OFCondition Image2Dcm::readAndInsertPixelDataNextFrame( // We will divide this by the number of frames later. m_compressionRatio += compressionRatio; - if (transport.isEncapsulated()) + if (transport.usesEncapsulatedFormat()) { cond = insertEncapsulatedPixelDataNextFrame(pixData, next_frameLength); delete[] pixData; diff --git a/dcmdata/libsrc/dcdatset.cc b/dcmdata/libsrc/dcdatset.cc index 0de01b45eb..b9c86f95bf 100644 --- a/dcmdata/libsrc/dcdatset.cc +++ b/dcmdata/libsrc/dcdatset.cc @@ -751,7 +751,7 @@ OFCondition DcmDataset::chooseRepresentation(const E_TransferSyntax repType, // check if we are attempting to compress but the image contains // floating point or double floating point pixel data, which our codecs don't support. if ((tagExists(DCM_FloatPixelData, OFTrue) || tagExists(DCM_DoubleFloatPixelData, OFTrue)) && - (fromrep.isEncapsulated() || torep.isEncapsulated())) + (fromrep.isPixelDataCompressed() || torep.isPixelDataCompressed())) { DCMDATA_ERROR("DcmDataset: Unable to compress/decompress floating point pixel data, cannot change representation"); l_error = EC_CannotChangeRepresentation; @@ -791,11 +791,11 @@ OFCondition DcmDataset::chooseRepresentation(const E_TransferSyntax repType, // If there are no pixel data elements in the dataset, issue a warning if (! pixelDataEncountered) { - if (torep.isEncapsulated() && ! fromrep.isEncapsulated()) + if (torep.isPixelDataCompressed() && fromrep.isPixelDataUncompressed()) { DCMDATA_WARN("DcmDataset: No pixel data present, nothing to compress"); } - if (! torep.isEncapsulated() && fromrep.isEncapsulated()) + if (torep.isPixelDataUncompressed() && fromrep.isPixelDataCompressed()) { DCMDATA_WARN("DcmDataset: No pixel data present, nothing to decompress"); } @@ -886,7 +886,7 @@ OFCondition DcmDataset::doPostReadChecks() if (findAndGetElement(DCM_PixelData, pixData).good()) { Uint32 valueLength = pixData->getLengthField(); - if (xf.isEncapsulated()) + if (xf.usesEncapsulatedFormat()) { if (valueLength != DCM_UndefinedLength) { @@ -897,8 +897,8 @@ OFCondition DcmDataset::doPostReadChecks() /* encapsulated pixel data (always encoded with undefined */ /* length). Print and return an error. */ DCMDATA_ERROR("Found explicit length Pixel Data in top level " - << "dataset with transfer syntax " << xf.getXferName() - << ": Only undefined length permitted"); + << "dataset with transfer syntax " << xf.getXferName() + << ": Only undefined length permitted"); result = EC_PixelDataExplLengthIllegal; } else @@ -907,8 +907,8 @@ OFCondition DcmDataset::doPostReadChecks() /* and behave like as we have the same case as for an */ /* icon image, which is always uncompressed (see above). */ DCMDATA_WARN("Found explicit length Pixel Data in top level " - << "dataset with transfer syntax " << xf.getXferName() - << ": Only undefined length permitted (ignored on explicit request)"); + << "dataset with transfer syntax " << xf.getXferName() + << ": Only undefined length permitted (ignored on explicit request)"); } } } diff --git a/dcmdata/libsrc/dcpixel.cc b/dcmdata/libsrc/dcpixel.cc index b5c682fb68..50451d60ba 100644 --- a/dcmdata/libsrc/dcpixel.cc +++ b/dcmdata/libsrc/dcpixel.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 1997-2023, OFFIS e.V. + * Copyright (C) 1997-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -186,7 +186,7 @@ DcmPixelData::calcElementLength( errorFlag = EC_Normal; Uint32 elementLength = 0; - if (xferSyn.isEncapsulated() && (! writeUnencapsulated(xfer))) + if (xferSyn.usesEncapsulatedFormat() && (! writeUnencapsulated(xfer))) { DcmRepresentationListIterator found; errorFlag = findConformingEncapsulatedRepresentation(xfer, NULL, found); @@ -194,7 +194,7 @@ DcmPixelData::calcElementLength( elementLength = (*found)->pixSeq->calcElementLength(xfer, enctype); } else if (existUnencapsulated) - elementLength = DcmPolymorphOBOW::calcElementLength(xfer, enctype); + elementLength = DcmPolymorphOBOW::calcElementLength(xfer, enctype); else errorFlag = EC_RepresentationNotFound; @@ -216,9 +216,9 @@ DcmPixelData::canChooseRepresentation( // 1. we have uncompressed data, and target is uncompressed (conversion between uncompressed always possible) // 2. we have uncompressed and want compressed, but we are forced to write uncompressed anyway // 3. we want to go to compressed, and already have the desired representation available - if ((!toType.isEncapsulated() && existUnencapsulated) || - (toType.isEncapsulated() && writeUnencapsulated(repType) && existUnencapsulated) || - (toType.isEncapsulated() && findRepresentationEntry(findEntry, resultIt) == EC_Normal)) + if ((toType.usesNativeFormat() && existUnencapsulated) || + (toType.usesEncapsulatedFormat() && writeUnencapsulated(repType) && existUnencapsulated) || + (toType.usesEncapsulatedFormat() && findRepresentationEntry(findEntry, resultIt) == EC_Normal)) { // representation found result = OFTrue; @@ -233,9 +233,9 @@ DcmPixelData::canChooseRepresentation( // we have uncompressed data, check whether we know how to go from uncompressed to desired compression result = DcmCodecList::canChangeCoding(EXS_LittleEndianExplicit, toType.getXfer()); } - else if (toType.isEncapsulated()) + else if (toType.usesEncapsulatedFormat()) { - // we have already compressed data, check whether we know how to transcode + // we have encapsulated data, check whether we know how to transcode result = DcmCodecList::canChangeCoding((*original)->repType, toType.getXfer()); if (!result) { @@ -260,9 +260,9 @@ DcmPixelData::canWriteXfer( { DcmXfer newXferSyn(newXfer); DcmRepresentationListIterator found; - OFBool result = existUnencapsulated && (!newXferSyn.isEncapsulated() || writeUnencapsulated(newXfer)); + OFBool result = existUnencapsulated && (newXferSyn.usesNativeFormat() || writeUnencapsulated(newXfer)); - if (!result && newXferSyn.isEncapsulated()) + if (!result && newXferSyn.usesEncapsulatedFormat()) result = (findConformingEncapsulatedRepresentation(newXferSyn, NULL, found) == EC_Normal); return result; } @@ -278,8 +278,8 @@ DcmPixelData::chooseRepresentation( const DcmRepresentationEntry findEntry(repType, repParam, NULL); DcmRepresentationListIterator result(repListEnd); - if ((!toType.isEncapsulated() && existUnencapsulated) || - (toType.isEncapsulated() && findRepresentationEntry(findEntry, result) == EC_Normal)) + if ((toType.usesNativeFormat() && existUnencapsulated) || + (toType.usesEncapsulatedFormat() && findRepresentationEntry(findEntry, result) == EC_Normal)) { // representation found current = result; @@ -291,14 +291,14 @@ DcmPixelData::chooseRepresentation( if (original == repListEnd) l_error = encode(EXS_LittleEndianExplicit, NULL, NULL, toType, repParam, pixelStack); - else if (toType.isEncapsulated()) + else if (toType.usesEncapsulatedFormat()) l_error = encode((*original)->repType, (*original)->repParam, (*original)->pixSeq, toType, repParam, pixelStack); else l_error = decode((*original)->repType, (*original)->repParam, (*original)->pixSeq, pixelStack); } - if (l_error.bad() && toType.isEncapsulated() && existUnencapsulated && writeUnencapsulated(repType)) + if (l_error.bad() && toType.usesEncapsulatedFormat() && existUnencapsulated && writeUnencapsulated(repType)) // Encoding failed so this will be written out unencapsulated l_error = EC_Normal; return l_error; @@ -478,11 +478,11 @@ DcmPixelData::encode( DcmStack & pixelStack) { OFCondition l_error = EC_CannotChangeRepresentation; - if (toType.isEncapsulated()) + if (toType.usesEncapsulatedFormat()) { DcmPixelSequence * toPixSeq = NULL; OFBool removeOldPixelRepresentation = OFFalse; - if (fromType.isEncapsulated()) + if (fromType.usesEncapsulatedFormat()) { l_error = DcmCodecList::encode(fromType.getXfer(), fromParam, fromPixSeq, toType.getXfer(), toParam, toPixSeq, pixelStack, removeOldPixelRepresentation); @@ -513,7 +513,7 @@ DcmPixelData::encode( // if it was possible to convert one encapsulated syntax into // another directly try it using decoding and encoding! - if (l_error.bad() && fromType.isEncapsulated()) + if (l_error.bad() && fromType.usesEncapsulatedFormat()) { l_error = decode(fromType, fromParam, fromPixSeq, pixelStack); if (l_error.good()) l_error = encode(EXS_LittleEndianExplicit, NULL, NULL, toType, toParam, pixelStack); @@ -559,7 +559,7 @@ DcmPixelData::findConformingEncapsulatedRepresentation( // of this pixel data element which meets both // the transfer syntax and (if given) the representation // parameter (i.e. quality factor for lossy JPEG). - if (repTypeSyn.isEncapsulated()) + if (repTypeSyn.usesEncapsulatedFormat()) { // first we check the current (active) representation if any. if ((current != repListEnd) && ((*current)->repType == repType) && @@ -617,9 +617,9 @@ DcmPixelData::hasRepresentation( { DcmXfer repTypeSyn(repType); DcmRepresentationListIterator found; - if (!repTypeSyn.isEncapsulated() && existUnencapsulated) + if (repTypeSyn.usesNativeFormat() && existUnencapsulated) return OFTrue; - else if (repTypeSyn.isEncapsulated()) + else if (repTypeSyn.usesEncapsulatedFormat()) return findConformingEncapsulatedRepresentation(repTypeSyn, repParam, found).good(); return OFFalse; } @@ -633,7 +633,7 @@ DcmPixelData::getLength(const E_TransferSyntax xfer, errorFlag = EC_Normal; Uint32 valueLength = 0; - if (xferSyn.isEncapsulated() && !writeUnencapsulated(xfer)) + if (xferSyn.usesEncapsulatedFormat() && !writeUnencapsulated(xfer)) { DcmRepresentationListIterator foundEntry; errorFlag = findConformingEncapsulatedRepresentation( @@ -819,15 +819,14 @@ DcmPixelData::read( /* create a DcmXfer object based on the transfer syntax which was passed */ DcmXfer ixferSyn(ixfer); - /* determine if the pixel data is captured in native (uncompressed) or encapsulated - * (compressed) format. We only derive this information from the length field - * which is set to undefined length for encapsulated data because even in - * compressed transfer syntaxes the Icon Image Sequence may contain an - * uncompressed image. + /* determine if the pixel data is captured in native or encapsulated format. + * We only derive this information from the length field which is set to + * undefined length for encapsulated data because even in compressed transfer + * syntaxes the Icon Image Sequence may contain an uncompressed image. */ if (getLengthField() == DCM_UndefinedLength) { - /* the pixel data is captured in encapsulated (compressed) format */ + /* the pixel data is captured in encapsulated (e.g. compressed) format */ /* if the transfer state is ERW_init, we need to prepare */ /* the reading of the pixel data from the stream. */ @@ -841,14 +840,15 @@ DcmPixelData::read( existUnencapsulated = OFFalse; setTransferState(ERW_inWork); - if (! ixferSyn.isEncapsulated()) + if (! ixferSyn.usesEncapsulatedFormat()) { - /* Special case: we have encountered a compressed image - * although we're decoding an uncompressed transfer syntax. - * This could be a compressed image stored without meta-header. - * For now, we just accept the data element; however, any attempt - * to write the dataset will fail because no suitable decoder - * is known. + /* Special case: we have encountered encapsulated format for + * the pixel data (undefined element length) although we're + * decoding a non-encapsulated transfer syntax. This could e.g. + * be a compressed image stored without meta-header. For now, + * we just accept the data element; however, any attempt to + * write the dataset will fail because no suitable decoder is + * known. */ } } @@ -875,11 +875,11 @@ DcmPixelData::read( recalcVR(); existUnencapsulated = OFTrue; - if (ixferSyn.isEncapsulated()) + if (ixferSyn.usesEncapsulatedFormat()) { - /* Special case: we have encountered an uncompressed image - * although we're decoding an encapsulated transfer syntax. - * This is probably an icon image. + /* Special case: we have encountered native format for the pixel + * data (explicit element length) although we're decoding an + * encapsulated transfer syntax. This is probably an icon image. */ alwaysUnencapsulated = OFTrue; } @@ -930,7 +930,8 @@ DcmPixelData::removeOriginalRepresentation( OFCondition l_error = EC_Normal; DcmXfer repTypeSyn(repType); - if (!repTypeSyn.isEncapsulated()) + /* native format or referenced pixel data */ + if (!repTypeSyn.usesEncapsulatedFormat()) { if (original != repListEnd) { @@ -947,6 +948,7 @@ DcmPixelData::removeOriginalRepresentation( } else { + /* encapsulated format */ DcmRepresentationListIterator result; DcmRepresentationEntry findEntry(repType, repParam, NULL); if (findRepresentationEntry(findEntry, result) == EC_Normal) @@ -984,7 +986,8 @@ DcmPixelData::removeRepresentation( OFCondition l_error = EC_Normal; DcmXfer repTypeSyn(repType); - if (!repTypeSyn.isEncapsulated()) + /* native format or referenced pixel data */ + if (!repTypeSyn.usesEncapsulatedFormat()) { if (original != repListEnd && existUnencapsulated) { @@ -996,6 +999,7 @@ DcmPixelData::removeRepresentation( } else { + /* encapsulated format */ DcmRepresentationListIterator result; DcmRepresentationEntry findEntry(repType, repParam, NULL); if (findRepresentationEntry(findEntry, result) == EC_Normal) @@ -1063,11 +1067,11 @@ OFCondition DcmPixelData::write( if (getTransferState() == ERW_notInitialized) errorFlag = EC_IllegalCall; else { - // check if the output transfer syntax is encapsulated - // and we are not requested to write an uncompressed dataset + // check if the output transfer syntax is encapsulated and + // we are not requested to write an uncompressed dataset, // for example because this is within an Icon Image Sequence DcmXfer xferSyn(oxfer); - if (xferSyn.isEncapsulated() && (! writeUnencapsulated(oxfer))) + if (xferSyn.usesEncapsulatedFormat() && (! writeUnencapsulated(oxfer))) { // write encapsulated representation (i.e., compressed image) if (getTransferState() == ERW_init) @@ -1129,7 +1133,7 @@ OFCondition DcmPixelData::writeSignatureFormat( else if (getTag().isSignable()) { DcmXfer xferSyn(oxfer); - if (xferSyn.isEncapsulated() && (! writeUnencapsulated(oxfer))) + if (xferSyn.usesEncapsulatedFormat() && (! writeUnencapsulated(oxfer))) { if (getTransferState() == ERW_init) { @@ -1273,7 +1277,7 @@ OFBool DcmPixelData::writeUnencapsulated(const E_TransferSyntax xfer) if (alwaysUnencapsulated) return OFTrue; - if (DcmXfer(xfer).isEncapsulated()) { + if (DcmXfer(xfer).usesEncapsulatedFormat()) { DcmRepresentationListIterator found; OFCondition cond = findConformingEncapsulatedRepresentation(xfer, NULL, found); if (cond.good()) { diff --git a/dcmdata/libsrc/dcpixseq.cc b/dcmdata/libsrc/dcpixseq.cc index 1af63add22..7d81fb6803 100644 --- a/dcmdata/libsrc/dcpixseq.cc +++ b/dcmdata/libsrc/dcpixseq.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 1994-2023, OFFIS e.V. + * Copyright (C) 1994-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -341,7 +341,7 @@ OFBool DcmPixelSequence::canWriteXfer(const E_TransferSyntax newXfer, { DcmXfer newXferSyn(newXfer); - return newXferSyn.isEncapsulated() && newXfer == oldXfer && oldXfer == Xfer; + return newXferSyn.usesEncapsulatedFormat() && newXfer == oldXfer && oldXfer == Xfer; } diff --git a/dcmdata/libsrc/dcrleccd.cc b/dcmdata/libsrc/dcrleccd.cc index 8c0421169e..86e62099a4 100644 --- a/dcmdata/libsrc/dcrleccd.cc +++ b/dcmdata/libsrc/dcrleccd.cc @@ -52,7 +52,8 @@ OFBool DcmRLECodecDecoder::canChangeCoding( { E_TransferSyntax myXfer = EXS_RLELossless; DcmXfer newRep(newRepType); - if (newRep.isNotEncapsulated() && (oldRepType == myXfer)) return OFTrue; // decompress requested + if (newRep.usesNativeFormat() && (oldRepType == myXfer)) + return OFTrue; // decompress requested // we don't support re-coding for now. return OFFalse; diff --git a/dcmdata/libsrc/dcrlecce.cc b/dcmdata/libsrc/dcrlecce.cc index 3c017354db..ef835f4edd 100644 --- a/dcmdata/libsrc/dcrlecce.cc +++ b/dcmdata/libsrc/dcrlecce.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2002-2021, OFFIS e.V. + * Copyright (C) 2002-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -55,7 +55,7 @@ OFBool DcmRLECodecEncoder::canChangeCoding( E_TransferSyntax myXfer = EXS_RLELossless; DcmXfer newRep(newRepType); DcmXfer oldRep(oldRepType); - if (oldRep.isNotEncapsulated() && (newRepType == myXfer)) return OFTrue; // compress requested + if (oldRep.usesNativeFormat() && (newRepType == myXfer)) return OFTrue; // compress requested // we don't support re-coding for now. return OFFalse; diff --git a/dcmdata/libsrc/dcvrobow.cc b/dcmdata/libsrc/dcvrobow.cc index 39d8a37923..3273998455 100644 --- a/dcmdata/libsrc/dcvrobow.cc +++ b/dcmdata/libsrc/dcvrobow.cc @@ -655,7 +655,8 @@ OFBool DcmOtherByteOtherWord::canWriteXfer(const E_TransferSyntax newXfer, const E_TransferSyntax /*oldXfer*/) { DcmXfer newXferSyn(newXfer); - return (getTag() != DCM_PixelData) || !newXferSyn.isEncapsulated(); + /* pixel data can only be written in native format */ + return (getTag() != DCM_PixelData) || newXferSyn.usesNativeFormat(); } diff --git a/dcmect/libsrc/enhanced_ct.cc b/dcmect/libsrc/enhanced_ct.cc index cffd610a86..f613850faa 100644 --- a/dcmect/libsrc/enhanced_ct.cc +++ b/dcmect/libsrc/enhanced_ct.cc @@ -1225,9 +1225,9 @@ OFCondition EctEnhancedCT::decompress(DcmDataset& dset) { DcmXfer xfer = dset.getOriginalXfer(); OFCondition result; - // If the original transfer is encapsulated and we do not already have an uncompressed version, decompress or reject - // the file - if (xfer.isEncapsulated()) + // If the original transfer syntax refers to compressed pixel data and we do not + // already have an uncompressed version, decompress or reject the file + if (xfer.isPixelDataCompressed()) { DCMECT_DEBUG("Enhanced CT object is compressed, converting to uncompressed transfer syntax first"); result = DcmIODUtil::decompress(dset); diff --git a/dcmimgle/include/dcmtk/dcmimgle/didocu.h b/dcmimgle/include/dcmtk/dcmimgle/didocu.h index 4aab11433b..8187949a12 100644 --- a/dcmimgle/include/dcmtk/dcmimgle/didocu.h +++ b/dcmimgle/include/dcmtk/dcmimgle/didocu.h @@ -179,7 +179,7 @@ class DCMTK_DCMIMGLE_EXPORT DiDocument */ inline OFBool isCompressed() const { - return DcmXfer(Xfer).isEncapsulated(); + return DcmXfer(Xfer).isPixelDataCompressed(); } /** search for given tag diff --git a/dcmimgle/libsrc/didocu.cc b/dcmimgle/libsrc/didocu.cc index efbbd69fbd..a0db6ec973 100644 --- a/dcmimgle/libsrc/didocu.cc +++ b/dcmimgle/libsrc/didocu.cc @@ -126,16 +126,16 @@ void DiDocument::convertPixelData() if (pobject->ident() == EVR_PixelData) { PixelData = OFstatic_cast(DcmPixelData *, pobject); - // check for a special (faulty) case where the original pixel data is uncompressed and - // the transfer syntax of the dataset refers to encapsulated format (i.e. compression) + // check for a special (faulty) case where the original pixel data is uncompressed in + // native format and the transfer syntax of the dataset refers to encapsulated format if (Object->ident() == EVR_dataset) { E_TransferSyntax repType = EXS_Unknown; const DcmRepresentationParameter *repParam = NULL; PixelData->getOriginalRepresentationKey(repType, repParam); - if (xfer.isEncapsulated() && !DcmXfer(repType).isEncapsulated()) + if (xfer.usesEncapsulatedFormat() && DcmXfer(repType).usesNativeFormat()) { - DCMIMGLE_WARN("pixel data is stored in uncompressed format, although " + DCMIMGLE_WARN("pixel data is stored in native format, although " << "the transfer syntax of the dataset refers to encapsulated format"); } } @@ -160,8 +160,8 @@ void DiDocument::convertPixelData() } if (status.good()) { - // set transfer syntax to unencapsulated/uncompressed - if (xfer.isEncapsulated()) + // set transfer syntax to native format (uncompressed pixel data) + if (xfer.usesEncapsulatedFormat()) { Xfer = EXS_LittleEndianExplicit; DCMIMGLE_DEBUG("decompressed complete pixel data in memory: " << PixelData->getLength(Xfer) << " bytes"); diff --git a/dcmiod/libsrc/iodutil.cc b/dcmiod/libsrc/iodutil.cc index 64c985cb50..0827d27e5e 100644 --- a/dcmiod/libsrc/iodutil.cc +++ b/dcmiod/libsrc/iodutil.cc @@ -643,7 +643,7 @@ const DcmTagKey DcmIODUtil::parseTagKey(const OFString& keyString) OFCondition DcmIODUtil::decompress(DcmDataset& dset) { DcmXfer xfer = dset.getOriginalXfer(); - if (xfer.isEncapsulated()) + if (xfer.isPixelDataCompressed()) { if (EC_Normal != dset.chooseRepresentation(EXS_LittleEndianExplicit, NULL)) { diff --git a/dcmjpeg/apps/dcmcjpeg.cc b/dcmjpeg/apps/dcmcjpeg.cc index 7c7cba15a2..cbb5eb4ca5 100644 --- a/dcmjpeg/apps/dcmcjpeg.cc +++ b/dcmjpeg/apps/dcmcjpeg.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2001-2022, OFFIS e.V. + * Copyright (C) 2001-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -679,7 +679,7 @@ int main(int argc, char *argv[]) DcmDataset *dataset = fileformat.getDataset(); DcmXfer original_xfer(dataset->getOriginalXfer()); - if (original_xfer.isEncapsulated()) + if (original_xfer.isPixelDataCompressed()) { OFLOG_INFO(dcmcjpegLogger, "DICOM file is already compressed, converting to uncompressed transfer syntax first"); if (EC_Normal != dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL)) diff --git a/dcmjpeg/libsrc/djcodecd.cc b/dcmjpeg/libsrc/djcodecd.cc index c06300f85a..5b0eeea213 100644 --- a/dcmjpeg/libsrc/djcodecd.cc +++ b/dcmjpeg/libsrc/djcodecd.cc @@ -54,7 +54,8 @@ OFBool DJCodecDecoder::canChangeCoding( { E_TransferSyntax myXfer = supportedTransferSyntax(); DcmXfer newRep(newRepType); - if (newRep.isNotEncapsulated() && (oldRepType == myXfer)) return OFTrue; // decompress requested + if (newRep.usesNativeFormat() && (oldRepType == myXfer)) + return OFTrue; // decompress requested // we don't support re-coding for now. return OFFalse; diff --git a/dcmjpeg/libsrc/djcodece.cc b/dcmjpeg/libsrc/djcodece.cc index d0371f6c2b..de973c5db3 100644 --- a/dcmjpeg/libsrc/djcodece.cc +++ b/dcmjpeg/libsrc/djcodece.cc @@ -67,7 +67,8 @@ OFBool DJCodecEncoder::canChangeCoding( E_TransferSyntax myXfer = supportedTransferSyntax(); DcmXfer newRep(newRepType); DcmXfer oldRep(oldRepType); - if (oldRep.isNotEncapsulated() && (newRepType == myXfer)) return OFTrue; // compress requested + if (oldRep.usesNativeFormat() && (newRepType == myXfer)) + return OFTrue; // compress requested // we don't support re-coding for now return OFFalse; diff --git a/dcmjpls/apps/dcmcjpls.cc b/dcmjpls/apps/dcmcjpls.cc index 6921f71dab..4c5cdf5aa1 100644 --- a/dcmjpls/apps/dcmcjpls.cc +++ b/dcmjpls/apps/dcmcjpls.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2007-2022, OFFIS e.V. + * Copyright (C) 2007-2024, OFFIS e.V. * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation were developed by @@ -437,7 +437,7 @@ LICENSE_FILE_EVALUATE_COMMAND_LINE_OPTIONS DcmDataset *dataset = fileformat.getDataset(); DcmXfer original_xfer(dataset->getOriginalXfer()); - if (original_xfer.isEncapsulated()) + if (original_xfer.isPixelDataCompressed()) { OFLOG_INFO(dcmcjplsLogger, "DICOM file is already compressed, converting to uncompressed transfer syntax first"); if (EC_Normal != dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL)) diff --git a/dcmjpls/libsrc/djcodecd.cc b/dcmjpls/libsrc/djcodecd.cc index e2a3ea4436..ca549afdb9 100644 --- a/dcmjpls/libsrc/djcodecd.cc +++ b/dcmjpls/libsrc/djcodecd.cc @@ -69,7 +69,7 @@ OFBool DJLSDecoderBase::canChangeCoding( // this codec only handles conversion from JPEG-LS to uncompressed. DcmXfer newRep(newRepType); - if (newRep.isNotEncapsulated() && (oldRepType == supportedTransferSyntax())) + if (newRep.usesNativeFormat() && (oldRepType == supportedTransferSyntax())) return OFTrue; return OFFalse; diff --git a/dcmjpls/libsrc/djcodece.cc b/dcmjpls/libsrc/djcodece.cc index eba1210c96..adf5dbb156 100644 --- a/dcmjpls/libsrc/djcodece.cc +++ b/dcmjpls/libsrc/djcodece.cc @@ -96,7 +96,7 @@ OFBool DJLSEncoderBase::canChangeCoding( { // this codec only handles conversion from uncompressed to JPEG-LS. DcmXfer oldRep(oldRepType); - return (oldRep.isNotEncapsulated() && (newRepType == supportedTransferSyntax())); + return (oldRep.usesNativeFormat() && (newRepType == supportedTransferSyntax())); } diff --git a/dcmnet/apps/getscu.cc b/dcmnet/apps/getscu.cc index f83e797b9c..e182adb1db 100644 --- a/dcmnet/apps/getscu.cc +++ b/dcmnet/apps/getscu.cc @@ -603,7 +603,7 @@ static void prepareTS(E_TransferSyntax ts, #endif default: DcmXfer xfer(ts); - if (xfer.isEncapsulated()) + if (xfer.usesEncapsulatedFormat()) { syntaxes.push_back(xfer.getXferID()); } diff --git a/dcmnet/apps/storescu.cc b/dcmnet/apps/storescu.cc index f90d445988..306b941905 100644 --- a/dcmnet/apps/storescu.cc +++ b/dcmnet/apps/storescu.cc @@ -1333,11 +1333,11 @@ storeSCU(T_ASC_Association *assoc, const char *fname) /* figure out which of the accepted presentation contexts should be used */ DcmXfer filexfer(dcmff.getDataset()->getOriginalXfer()); - /* special case: if the file uses an unencapsulated transfer syntax (uncompressed - * or deflated explicit VR) and we prefer deflated explicit VR, then try - * to find a presentation context for deflated explicit VR first. + /* special case: if the file uses a transfer syntax with native format + * (uncompressed or deflated explicit VR) and we prefer deflated explicit VR, + * then try to find a presentation context for deflated explicit VR first. */ - if (filexfer.isNotEncapsulated() && + if (filexfer.usesNativeFormat() && opt_networkTransferSyntax == EXS_DeflatedLittleEndianExplicit) { filexfer = EXS_DeflatedLittleEndianExplicit; diff --git a/dcmpmap/libsrc/dpmparametricmapiod.cc b/dcmpmap/libsrc/dpmparametricmapiod.cc index 857b50b745..9301e3faa7 100644 --- a/dcmpmap/libsrc/dpmparametricmapiod.cc +++ b/dcmpmap/libsrc/dpmparametricmapiod.cc @@ -993,15 +993,16 @@ OFCondition DPMParametricMapIOD::decompress(DcmDataset& dset) // If the original transfer syntax could have been lossy, print warning if (dset.hasRepresentation(EXS_LittleEndianExplicit, NULL)) { - if ( xfer.isEncapsulated() && (xfer != EXS_RLELossless) && (xfer != EXS_DeflatedLittleEndianExplicit) ) + if (xfer.isPixelDataCompressed() && (xfer != EXS_RLELossless)) { DCMPMAP_WARN("Dataset has been compressed using a (possibly) lossy compression scheme (ignored)"); } } - // If the original transfer is encapsulated and we do not already have an uncompressed version, decompress or reject the file - else if (xfer.isEncapsulated()) + // If the original transfer syntax refers to compressed pixel data and we do not + // already have an uncompressed version, decompress or reject the file + else if (xfer.isPixelDataCompressed()) { - // RLE compression is fine (truly lossless). Deflated is handled internally by DCMTK. + // RLE compression is fine (truly lossless) if (xfer == EXS_RLELossless) { DCMPMAP_DEBUG("DICOM file is RLE-compressed, converting to uncompressed transfer syntax first"); diff --git a/dcmseg/libsrc/segdoc.cc b/dcmseg/libsrc/segdoc.cc index a028349e17..89868fccf3 100644 --- a/dcmseg/libsrc/segdoc.cc +++ b/dcmseg/libsrc/segdoc.cc @@ -1403,16 +1403,16 @@ OFCondition DcmSegmentation::decompress(DcmDataset& dset) // If the original transfer syntax could have been lossy, print warning if (dset.hasRepresentation(EXS_LittleEndianExplicit, NULL)) { - if (xfer.isEncapsulated() && (xfer != EXS_RLELossless) && (xfer != EXS_DeflatedLittleEndianExplicit)) + if (xfer.isPixelDataCompressed() && (xfer != EXS_RLELossless)) { DCMSEG_WARN("Dataset has been compressed using a (possibly) lossy compression scheme (ignored)"); } } - // If the original transfer is encapsulated and we do not already have an uncompressed version, decompress or reject - // the file - else if (xfer.isEncapsulated()) + // If the original transfer syntax refers to compressed pixel data and we do not + // already have an uncompressed version, decompress or reject the file + else if (xfer.isPixelDataCompressed()) { - // RLE compression is fine (truly lossless). Deflated is handled internally by DCMTK. + // RLE compression is fine (truly lossless) if (xfer == EXS_RLELossless) { DCMSEG_DEBUG("DICOM file is RLE-compressed, converting to uncompressed transfer syntax first"); diff --git a/dcmtract/libsrc/trctractographyresults.cc b/dcmtract/libsrc/trctractographyresults.cc index 9c83e10269..17a8249fd1 100644 --- a/dcmtract/libsrc/trctractographyresults.cc +++ b/dcmtract/libsrc/trctractographyresults.cc @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2016-2018, Open Connections GmbH + * Copyright (C) 2016-2024, Open Connections GmbH * All rights reserved. See COPYRIGHT file for details. * * This software and supporting documentation are maintained by @@ -71,8 +71,8 @@ OFCondition TrcTractographyResults::loadDataset( TrcTractographyResults*& tract) { DcmXfer xfer = dataset.getOriginalXfer(); - // If the original transfer is encapsulated and we do not already have an uncompressed version, decompress or reject the file - if (xfer.isEncapsulated()) + // If the original transfer syntax refers to compressed pixel data reject the file + if (xfer.isPixelDataCompressed()) { DCMTRACT_ERROR("Cannot load dataset since it is compressed, transfer syntax: " << xfer.getXferName()); return IOD_EC_CannotDecompress;