Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-ffmpeg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ jobs:
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/02-idr-on-amf.patch
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/03-amfenc-disable-buffering.patch
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/04-mfenc-lowlatency.patch
git apply -v --ignore-whitespace ../../ffmpeg_patches/ffmpeg/05-qsv-session-leak.patch

- name: Setup cross compilation
id: cross
Expand Down
54 changes: 54 additions & 0 deletions ffmpeg_patches/ffmpeg/05-qsv-session-leak.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From a9ec49b4e728009c4bb4a2af7cb80a3c1ce6016c Mon Sep 17 00:00:00 2001
From: Cameron Gutman <aicommander@gmail.com>
Date: Thu, 12 Jan 2023 17:49:29 -0600
Subject: [PATCH] lavu/hwcontext_qsv: fix MFX session leak in hwdevice

There was no device_uninit() implementation to handle freeing
the resources allocated in qsv_device_derive_from_child().
---
libavutil/hwcontext_qsv.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 56dffa1f25..504d4f8a45 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -220,6 +220,14 @@ static int qsv_fill_border(AVFrame *dst, const AVFrame *src)
return 0;
}

+static void qsv_device_uninit(AVHWDeviceContext *ctx)
+{
+ AVQSVDeviceContext *hwctx = ctx->hwctx;
+
+ if (hwctx->session)
+ MFXClose(hwctx->session);
+}
+
static int qsv_device_init(AVHWDeviceContext *ctx)
{
AVQSVDeviceContext *hwctx = ctx->hwctx;
@@ -1424,11 +1432,7 @@ static int qsv_frames_get_constraints(AVHWDeviceContext *ctx,

static void qsv_device_free(AVHWDeviceContext *ctx)
{
- AVQSVDeviceContext *hwctx = ctx->hwctx;
- QSVDevicePriv *priv = ctx->user_opaque;
-
- if (hwctx->session)
- MFXClose(hwctx->session);
+ QSVDevicePriv *priv = ctx->user_opaque;

av_buffer_unref(&priv->child_device_ctx);
av_freep(&priv);
@@ -1674,6 +1678,7 @@ const HWContextType ff_hwcontext_type_qsv = {
.device_create = qsv_device_create,
.device_derive = qsv_device_derive,
.device_init = qsv_device_init,
+ .device_uninit = qsv_device_uninit,
.frames_get_constraints = qsv_frames_get_constraints,
.frames_init = qsv_frames_init,
.frames_uninit = qsv_frames_uninit,
--
2.39.0.windows.2