summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2022-12-12 10:05:24 -0800
committerPhilip Langdale <philipl@overt.org>2022-12-12 10:07:43 -0800
commiteeefa8aec0159f0fe08240cdc2902244f0827062 (patch)
treeee5a199972eb4bcdfe7bc66198bc3b1057dcd1ef /video/decode
parentcf349d68e3370d5f528de8a87950453fcaf39619 (diff)
downloadmpv-eeefa8aec0159f0fe08240cdc2902244f0827062.tar.bz2
mpv-eeefa8aec0159f0fe08240cdc2902244f0827062.tar.xz
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.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/vd_lavc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 5e8bf40a66..f70626916e 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -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);