diff options
author | Zhao Zhili <zhilizhao@tencent.com> | 2024-07-07 18:21:33 +0800 |
---|---|---|
committer | Zhao Zhili <zhilizhao@tencent.com> | 2024-07-16 19:53:53 +0800 |
commit | 2fca8e400ed8213fb44b4e2c0165d435fa98d9b6 (patch) | |
tree | 0ca866e99cd40994bdad1e7370b2900f949b0012 /libavcodec/vaapi_encode.c | |
parent | 0e338c4114578a5c68f931f5d6ecac6adba85f7c (diff) | |
download | ffmpeg-2fca8e400ed8213fb44b4e2c0165d435fa98d9b6.tar.gz |
avcodec/videotoolboxenc: Fix concurrent access to CVPixelBufferRef
For a frame comes from AV_HWDEVICE_TYPE_VIDEOTOOLBOX, it's
CVPixelBufferRef is maintained by a pool. CVPixelBufferRef returned
to the pool when frame buffer reference reached to zero. However,
VTCompressionSessionEncodeFrame also hold a reference to the
CVPixelBufferRef. So a new frame get from av_hwframe_get_buffer
may access a CVPixelBufferRef which still used by the encoder.
It's only after vtenc_output_callback that we can make sure
CVPixelBufferRef has been released by the encoder.
The issue can be tested with sample from trac #10884.
ffmpeg -hwaccel videotoolbox \
-hwaccel_output_format videotoolbox_vld \
-i input.mp4 \
-c:v hevc_videotoolbox \
-profile:v main \
-b:v 3M \
-vf scale_vt=w=iw/2:h=ih/2:color_matrix=bt709:color_primaries=bt709:color_transfer=bt709 \
-c:a copy \
-tag:v hvc1 \
output.mp4
Withtout the patch, there are some out of order images in output.mp4.
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavcodec/vaapi_encode.c')
0 files changed, 0 insertions, 0 deletions