[FFmpeg-devel] [PATCH 1/2] lavc/videotoolbox: do not pass AVCodecContext to decoder output callback

Thilo Borgmann thilo.borgmann at mail.de
Thu Sep 15 22:22:23 EEST 2022


Am 15.09.22 um 15:56 schrieb Anton Khirnov:
> The opaque parameter for the callback is set in videotoolbox_start(),
> called when the hwaccel is initialized. When frame threading is used,
> avctx will be the context corresponding to the frame thread currently
> doing the decoding. Using this same codec context in all subsequent
> invocations of the decoder callback (even those triggered by a different
> frame thread) is unsafe, and broken after
> cc867f2c09d2b69cee8a0eccd62aff002cbbfe11, since each frame thread now
> cleans up its hwaccel state after decoding each frame.
> 
> Fix this by passing hwaccel_priv_data as the opaque parameter, which
> exists in a single instance forwarded between all frame threads.
> 
> The only other use of AVCodecContext in the decoder output callback is
> as a logging context. For this purpose, store a logging context in
> hwaccel_priv_data.
> ---
> Initial version of this patch tested by Marvin on IRC.
> Someone please test this final version, as I don't have the HW to do it
> myself.
> ---
>   libavcodec/videotoolbox.c | 10 ++++++----
>   libavcodec/vt_internal.h  |  2 ++
>   2 files changed, 8 insertions(+), 4 deletions(-)

Confirmed, fixes the crash for me as well!

Thx,
Thilo



More information about the ffmpeg-devel mailing list