Leverage sws_is_noop for video reformat shortcuts#2327
Merged
Conversation
CarlosRDomin
commented
Jun 24, 2026
Comment on lines
264
to
265
| if frame.ptr.format < 0: | ||
| raise ValueError("Frame does not have format set.") |
Contributor
Author
There was a problem hiding this comment.
FYI not sure if this is needed anymore (I left it just in case, but maybe sws is robust to it already?)
71d4478 to
542b209
Compare
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.
Following up on #2323 (comment), this PR replaces the manual video reformat no-op checks with FFmpeg’s
sws_is_noop.Hardware frames are downloaded before the no-op check so the comparison is performed against the software frame that would actually be passed to swscale, so we only check for the no-op shortcut once. The destination frame is prepared as a lightweight descriptor for
sws_is_noop, and buffers are only allocated ifsws_scale_frameis needed.The change also simplifies color transfer/primaries handling by resolving
Noneto the source frame values before_reformat, removing the extraset_dst_color_*booleans while preserving explicitUNSPECIFIEDbehavior.