Skip to content

Preserve frame props after hardware downloads#2321

Merged
WyattBlue merged 1 commit into
PyAV-Org:mainfrom
CarlosRDomin:fix/preserve-hwframe-props
Jun 20, 2026
Merged

Preserve frame props after hardware downloads#2321
WyattBlue merged 1 commit into
PyAV-Org:mainfrom
CarlosRDomin:fix/preserve-hwframe-props

Conversation

@CarlosRDomin

Copy link
Copy Markdown
Contributor

This PR fixes hardware frame downloads losing AVFrame properties, as reported in #2231.

The regression test uses fate("hevc/hdr10_plus_h265_sample.hevc"), which carries non-default color metadata. Before this change, CPU decode preserved those frame properties, but hardware-download paths lost them:

  • is_hw_owned=False loses them in VideoCodecContext._transfer_hwframe()
  • is_hw_owned=True keeps them on the hardware frame, but loses them when VideoReformatter downloads the frame before swscale

The fix is to call _copy_internal_attributes(frame, data_layout=False) after av_hwframe_transfer_data(). That copies AVFrame metadata via av_frame_copy_props without overwriting the downloaded frame's actual format/width/height/data layout.

Note that I also removed the previous frame_sw._init_user_attributes() call from VideoReformatter. The downloaded frame_sw there is only a temporary source frame for swscale and is not returned to the user (the returned output frame is already initialized separately).

@CarlosRDomin CarlosRDomin force-pushed the fix/preserve-hwframe-props branch from 77a4649 to ed50af2 Compare June 20, 2026 05:23
@WyattBlue WyattBlue merged commit d1f701d into PyAV-Org:main Jun 20, 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