Skip to content

Store a UniqueAVFrame in the blocks frame handle - #1596

Closed
NicolasHug wants to merge 1 commit into
borrowed_av_framesfrom
blocks_frame_handle
Closed

Store a UniqueAVFrame in the blocks frame handle#1596
NicolasHug wants to merge 1 commit into
borrowed_av_framesfrom
blocks_frame_handle

Conversation

@NicolasHug

Copy link
Copy Markdown
Contributor

The frame handle held a raw AVFrame*, so _blocks_convert_frame() had to
build a UniqueAVFrame around a pointer the handle already owned and then
release() it again to undo the fabricated second owner. It only worked
because nothing downstream acted on that ownership.

Hold a UniqueAVFrame instead. It's an ordinary C++ object whose destructor
calls av_frame_free, so the generic wrap_pointer_to_tensor handle used
by the other blocks types applies and the bespoke AVFrame wrapper goes
away. _blocks_convert_frame() then has a UniqueAVFrame to pass by
reference, with no temporary owner in sight.

Costs one small allocation per frame for the wrapper object.


Stack created with GitHub Stacks CLIGive Feedback 💬

@pytorch-bot

pytorch-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1596

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure

As of commit 7f264c8 with merge base 3f7692b (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 3, 2026
The frame handle held a raw AVFrame*, so _blocks_convert_frame() had to
build a UniqueAVFrame around a pointer the handle already owned and then
release() it again to undo the fabricated second owner. It only worked
because nothing downstream acted on that ownership.

Hold a UniqueAVFrame instead. It's an ordinary C++ object whose destructor
calls av_frame_free, so the generic wrap_pointer_to_tensor<T> handle used
by the other blocks types applies and the bespoke AVFrame wrapper goes
away. _blocks_convert_frame() then has a UniqueAVFrame to pass by
reference, with no temporary owner in sight.

Costs one small allocation per frame for the wrapper object.
@NicolasHug
NicolasHug force-pushed the blocks_frame_handle branch from 19d2c3d to 7f264c8 Compare August 3, 2026 21:33
@NicolasHug

Copy link
Copy Markdown
Contributor Author

Superseded by #1598

@NicolasHug NicolasHug closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant