Skip to content

Leverage sws_is_noop for video reformat shortcuts#2327

Merged
WyattBlue merged 1 commit into
PyAV-Org:mainfrom
CarlosRDomin:feat/leverage-sws-is-noop
Jun 24, 2026
Merged

Leverage sws_is_noop for video reformat shortcuts#2327
WyattBlue merged 1 commit into
PyAV-Org:mainfrom
CarlosRDomin:feat/leverage-sws-is-noop

Conversation

@CarlosRDomin

Copy link
Copy Markdown
Contributor

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 if sws_scale_frame is needed.

The change also simplifies color transfer/primaries handling by resolving None to the source frame values before _reformat, removing the extra set_dst_color_* booleans while preserving explicit UNSPECIFIED behavior.

Comment thread av/video/reformatter.py Outdated
Comment on lines 264 to 265
if frame.ptr.format < 0:
raise ValueError("Frame does not have format set.")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI not sure if this is needed anymore (I left it just in case, but maybe sws is robust to it already?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just remove it

@CarlosRDomin CarlosRDomin force-pushed the feat/leverage-sws-is-noop branch from 71d4478 to 542b209 Compare June 24, 2026 03:55
@WyattBlue WyattBlue merged commit 934717a into PyAV-Org:main Jun 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants