fix(oiiotool): better type understanding with -i:ch= and other cleanup#5056
Open
lgritz wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
Open
fix(oiiotool): better type understanding with -i:ch= and other cleanup#5056lgritz wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
lgritz wants to merge 3 commits intoAcademySoftwareFoundation:mainfrom
Conversation
Background: oiiotool is pretty good at remembering the data type of the first file it reads in a command, and ensuring that the output preserves the same types, despite the fact that internally, it tends to keep everything in float. (As a further reminder: -d can override the heuristics that make this work.) But there was an exception: when `-i` was used with the optinal modifier `-i:ch=...` to select a subset of channels or reorder channels upon read, the underlying call to IBA::channels would cause it to not have that information in the "nativespec" at the right time that it was collected. This PR primarily ensures that the `-i:ch=...` preserves the information about which channels had which data types, despite the channel shuffle. Some other bits and pieces along the way: * A new `TypeDesc::basetype_merge()` variety that take a `cspan<TypeDesc>`. * A new utility `TypeDesc::all_types_equal(cspan<TypeDesc>)` * Cleanup in IBA::channels() to more correctly cmopute the common type of the channel subset that you actually specify. Signed-off-by: Larry Gritz <lg@larrygritz.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes oiiotool’s native type propagation when -i is combined with channel selection/reordering (-i:ch=...), ensuring the “first input’s” per-channel native types are preserved even after a channel shuffle.
Changes:
- Preserve/restore
nativespecchannel format information after applyingImageBufAlgo::channels()during-i:ch=.... - Add new
TypeDeschelpers:basetype_merge(cspan<TypeDesc>)andall_types_equal(cspan<TypeDesc>). - Update
ImageBufAlgo::channels()to compute the merged outputformatfrom the actually-selected channels and clearchannelformatswhen uniform; extend tests to cover the regression case.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| testsuite/oiiotool-copy/run.py | Adds a regression test exercising channel reordering/renaming without -d to validate correct type propagation. |
| testsuite/oiiotool-copy/ref/out.txt | Updates expected output to include info for the new regression output file. |
| src/python/py_typedesc.cpp | Exposes TypeDesc::all_types_equal to Python. |
| src/oiiotool/imagerec.cpp | After IBA::channels() channel shuffles, restores per-channel native types into nativespec and recomputes merged native format. |
| src/libOpenImageIO/imagebufalgo_channels.cpp | Computes newspec.format from selected channel formats and clears per-chan formats when all equal. |
| src/include/OpenImageIO/typedesc.h | Adds span-based basetype merging and uniform-type checking helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Collaborator
Author
|
2 weeks, no objections. Will merge by the end of the week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background: oiiotool is pretty good at remembering the data type of the first file it reads in a command, and ensuring that the output preserves the same types, despite the fact that internally, it tends to keep everything in float. (As a further reminder: -d can override the heuristics that make this work.)
But there was an exception: when
-iwas used with the optinal modifier-i:ch=...to select a subset of channels or reorder channels upon read, the underlying call to IBA::channels would cause it to not have that information in the "nativespec" at the right time that it was collected.This PR primarily ensures that the
-i:ch=...preserves the information about which channels had which data types, despite the channel shuffle.Some other bits and pieces along the way:
TypeDesc::basetype_merge()variety that take acspan<TypeDesc>.TypeDesc::all_types_equal(cspan<TypeDesc>)