Repository navigation
BUG: Fix #1908 wrong-data items L73, L74, L77, L78 and L79 #1981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
d4584d0
14d2f8c
a6f6ebf
a233fb6
08fbb7d
b000702
13af744
4378457
c45cd20
2fa764d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,22 @@ namespace fs = std::filesystem; | |
|
|
||
| namespace | ||
| { | ||
| std::string DescribePageLayout(const IImageIO::PageMetadata& layout) | ||
| { | ||
| switch(layout.sampleFormat) | ||
| { | ||
| case IImageIO::SampleFormat::Unsigned: | ||
| return fmt::format("{}-component uint{}", layout.numComponents, layout.bitsPerSample); | ||
| case IImageIO::SampleFormat::Signed: | ||
| return fmt::format("{}-component int{}", layout.numComponents, layout.bitsPerSample); | ||
| case IImageIO::SampleFormat::Float: | ||
| return fmt::format("{}-component float{}", layout.numComponents, layout.bitsPerSample); | ||
| case IImageIO::SampleFormat::Unknown: | ||
| break; | ||
| } | ||
| return fmt::format("{}-component {}-bit samples of an unsupported type", layout.numComponents, layout.bitsPerSample); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Geometry of one raster read (2D raster or multi-page TIFF Z-stack). | ||
| * | ||
|
|
@@ -297,6 +313,12 @@ Result<> ReadRasterBackend(DataStructure& dataStructure, const ReadImageInputVal | |
| return MakeErrorResult(-2001, fmt::format("Crop window (start=[{},{},{}], size=[{},{},{}]) does not fit within the source image (size=[{},{},{}])", stream.xStart, stream.yStart, stream.zStart, | ||
| stream.dstWidth, stream.dstHeight, stream.dstDepth, stream.srcWidth, stream.srcHeight, metadata.numPages)); | ||
| } | ||
| // Only the decoded pages are validated. Page 0 sets the output layout, so each decoded page is compared with it. | ||
| auto layoutResult = ReadImage::ValidatePageLayouts(*imageIO, inputFilePath, stream.singlePageOnly ? usize{0} : stream.zStart, stream.dstDepth); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Minor] Execute repeats the preflight page-layout check, and a test calls the algorithm directly to reach it This breaks the KB entry Run a filter, not its algorithm. Fix (choose one): (a) Move the check to where |
||
| if(layoutResult.invalid()) | ||
| { | ||
| return layoutResult; | ||
| } | ||
|
|
||
| const DataType destType = imageArray.getDataType(); | ||
| const DataType srcType = metadata.dataType; | ||
|
|
@@ -468,3 +490,36 @@ Result<> ReadImage::operator()() | |
|
|
||
| return ReadRasterBackend(m_DataStructure, m_InputValues, m_MessageHandler, m_ShouldCancel); | ||
| } | ||
|
|
||
| // ----------------------------------------------------------------------------- | ||
| Result<> ReadImage::ValidatePageLayouts(const IImageIO& imageIO, const std::filesystem::path& filePath, usize firstPage, usize pageCount) | ||
| { | ||
| // Page 0 sets the output layout. A read of page 0 alone has nothing to compare. | ||
| if(pageCount == 0 || (firstPage == 0 && pageCount == 1)) | ||
| { | ||
| return {}; | ||
| } | ||
| auto result = imageIO.readPageLayouts(filePath); | ||
| if(result.invalid()) | ||
| { | ||
| return ConvertResult(std::move(result)); | ||
| } | ||
| const auto& layouts = result.value(); | ||
| if(layouts.empty()) | ||
| { | ||
| return {}; | ||
| } | ||
| const auto& first = layouts.front(); | ||
| const usize endPage = std::min(layouts.size(), firstPage + pageCount); | ||
| for(usize page = std::max(firstPage, usize{1}); page < endPage; ++page) | ||
| { | ||
| const auto& current = layouts[page]; | ||
| if(current.numComponents != first.numComponents || current.bitsPerSample != first.bitsPerSample || current.sampleFormat != first.sampleFormat) | ||
| { | ||
| return MakeErrorResult( | ||
| -50579, fmt::format("TIFF '{}': page {} is {}, page 0 is {}. Each page that is read must have the same component count and data type as page 0. Use a TIFF with matching page layouts.", | ||
| filePath.string(), page, DescribePageLayout(current), DescribePageLayout(first))); | ||
| } | ||
| } | ||
| return {}; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Nit] The knowledge base edit cites "the change" instead of the PR
The file's rules say to cite pull requests by number, and "items L73 to L79" suggests that L75 and L76 are included. Replace with: "
ComputeFeatureFaceMisorientationwas fixed in PR #1618 andFeatureFaceCurvaturein PR #1981."