1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 17:42:17 +00:00

vd_lavc: Set AV_HWACCEL_FLAG_UNSAFE_OUTPUT flag

This new hwaccel flag was added to allow us to request that an hwaccel
decode not implicitly copy output frames before passing them out. The
only hwaccel that would implicitly copy frames is nvdec due to how it
has a small output pool that cannot be grown very much. However, we
already copy frames as soon as we get our hands on them (in our hwdec)
so we're already safe from pool exhaustion, and the extra copy doesn't
help us.
This commit is contained in:
Philip Langdale 2022-12-12 10:05:24 -08:00
parent cf349d68e3
commit eeefa8aec0

View File

@ -663,6 +663,17 @@ static void init_avctx(struct mp_filter *vd)
if (!lavc_param->check_hw_profile)
avctx->hwaccel_flags |= AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH;
#ifdef AV_HWACCEL_FLAG_UNSAFE_OUTPUT
/*
* This flag primarily exists for nvdec which has a very limited
* output frame pool, which can get exhausted if consumers don't
* release frames quickly. However, as an implementation
* requirement, we have to copy the frames anyway, so we don't
* need this extra implicit copy.
*/
avctx->hwaccel_flags |= AV_HWACCEL_FLAG_UNSAFE_OUTPUT;
#endif
if (ctx->hwdec.use_hw_device) {
if (ctx->hwdec_dev)
avctx->hw_device_ctx = av_buffer_ref(ctx->hwdec_dev);