Repository navigation
Conversation
VideoPlane cached width, height and buffer_size when created, but read the frame's data pointer live. A plane made before apply_cropping() then paired the shifted pointer with the old size, so bytes(plane), memoryview(plane), update() and DLPack export read or wrote past the buffer. Recompute the geometry whenever the frame's dimensions, data pointer or linesize change. Also document that for hardware frames and 1-bit formats FFmpeg applies only the right and bottom crop, leaving crop_left and crop_top set.
Reject a crop when the two crops on an axis would leave no pixels, the same rule av_frame_apply_cropping() uses. Without this, nonsense values reached hardware filters such as scale_cuda, scale_vt and scale_vulkan, which read the crop fields without checking them. Zero is always allowed so the fields can be cleared.
av_frame_copy_props() copies crop_* onto the reformatted frame. They are in source pixels, so they still hold after a pixel format change but not after a resize, where they can exceed the new dimensions. Clear them when the size changes.
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.
Follow-up to #2496.
apply_cropping()paired the shifted pointer with the old size.bytes(plane),memoryview(plane),update()and DLPack export then read or wrote past the buffer (reproduced as SIGBUS with a guard page). The geometry is now recomputed whenever the frame's dimensions, data pointer or linesize change. Also documents that FFmpeg only applies the right and bottom crop for hardware frames and 1-bit formats.av_frame_apply_cropping()uses, so nonsense values can't reach hardware filters (scale_cuda,scale_vt,scale_vulkan,amf) that read the fields unchecked.reformat()resizes a frame.av_frame_copy_props()copies them onto the output; they still hold after a pixel format change but not after a resize, where they can exceed the new dimensions.