Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerContext.cpp @ 4265:f9eaf14d3d19
Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 30 Oct 2020 12:00:06 +0100 |
parents | 8e069a7e1c11 |
children | 0ae2ca210077 |
comparison
equal
deleted
inserted
replaced
4262:9a01e0f89b6d | 4265:f9eaf14d3d19 |
---|---|
1439 { | 1439 { |
1440 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) | 1440 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) |
1441 { | 1441 { |
1442 // Use Orthanc's built-in decoder, using the cache to speed-up | 1442 // Use Orthanc's built-in decoder, using the cache to speed-up |
1443 // things on multi-frame images | 1443 // things on multi-frame images |
1444 ServerContext::DicomCacheLocker locker(*this, publicId); | 1444 ServerContext::DicomCacheLocker locker(*this, publicId); |
1445 std::unique_ptr<ImageAccessor> decoded(locker.GetDicom().DecodeFrame(frameIndex)); | 1445 |
1446 std::unique_ptr<ImageAccessor> decoded; | |
1447 try | |
1448 { | |
1449 decoded.reset(locker.GetDicom().DecodeFrame(frameIndex)); | |
1450 } | |
1451 catch (OrthancException& e) | |
1452 { | |
1453 } | |
1454 | |
1446 if (decoded.get() != NULL) | 1455 if (decoded.get() != NULL) |
1447 { | 1456 { |
1448 return decoded.release(); | 1457 return decoded.release(); |
1449 } | 1458 } |
1450 } | 1459 } |
1454 GetPlugins().HasCustomImageDecoder()) | 1463 GetPlugins().HasCustomImageDecoder()) |
1455 { | 1464 { |
1456 // TODO: Store the raw buffer in the DicomCacheLocker | 1465 // TODO: Store the raw buffer in the DicomCacheLocker |
1457 std::string dicomContent; | 1466 std::string dicomContent; |
1458 ReadDicom(dicomContent, publicId); | 1467 ReadDicom(dicomContent, publicId); |
1459 std::unique_ptr<ImageAccessor> decoded( | 1468 |
1460 GetPlugins().Decode(dicomContent.c_str(), dicomContent.size(), frameIndex)); | 1469 std::unique_ptr<ImageAccessor> decoded; |
1470 try | |
1471 { | |
1472 decoded.reset(GetPlugins().Decode(dicomContent.c_str(), dicomContent.size(), frameIndex)); | |
1473 } | |
1474 catch (OrthancException& e) | |
1475 { | |
1476 } | |
1477 | |
1461 if (decoded.get() != NULL) | 1478 if (decoded.get() != NULL) |
1462 { | 1479 { |
1463 return decoded.release(); | 1480 return decoded.release(); |
1464 } | 1481 } |
1465 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) | 1482 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |
1485 ImageAccessor* ServerContext::DecodeDicomFrame(const DicomInstanceToStore& dicom, | 1502 ImageAccessor* ServerContext::DecodeDicomFrame(const DicomInstanceToStore& dicom, |
1486 unsigned int frameIndex) | 1503 unsigned int frameIndex) |
1487 { | 1504 { |
1488 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) | 1505 if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before) |
1489 { | 1506 { |
1490 std::unique_ptr<ImageAccessor> decoded(dicom.GetParsedDicomFile().DecodeFrame(frameIndex)); | 1507 std::unique_ptr<ImageAccessor> decoded; |
1508 try | |
1509 { | |
1510 decoded.reset(dicom.GetParsedDicomFile().DecodeFrame(frameIndex)); | |
1511 } | |
1512 catch (OrthancException& e) | |
1513 { | |
1514 } | |
1515 | |
1491 if (decoded.get() != NULL) | 1516 if (decoded.get() != NULL) |
1492 { | 1517 { |
1493 return decoded.release(); | 1518 return decoded.release(); |
1494 } | 1519 } |
1495 } | 1520 } |
1496 | 1521 |
1497 #if ORTHANC_ENABLE_PLUGINS == 1 | 1522 #if ORTHANC_ENABLE_PLUGINS == 1 |
1498 if (HasPlugins() && | 1523 if (HasPlugins() && |
1499 GetPlugins().HasCustomImageDecoder()) | 1524 GetPlugins().HasCustomImageDecoder()) |
1500 { | 1525 { |
1501 std::unique_ptr<ImageAccessor> decoded( | 1526 std::unique_ptr<ImageAccessor> decoded; |
1502 GetPlugins().Decode(dicom.GetBufferData(), dicom.GetBufferSize(), frameIndex)); | 1527 try |
1528 { | |
1529 decoded.reset(GetPlugins().Decode(dicom.GetBufferData(), dicom.GetBufferSize(), frameIndex)); | |
1530 } | |
1531 catch (OrthancException& e) | |
1532 { | |
1533 } | |
1534 | |
1503 if (decoded.get() != NULL) | 1535 if (decoded.get() != NULL) |
1504 { | 1536 { |
1505 return decoded.release(); | 1537 return decoded.release(); |
1506 } | 1538 } |
1507 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) | 1539 else if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_After) |