summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-02-11 16:45:08 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-03-05 09:33:16 +0100
commit028907b08ad9f327cbb405cff2df2b19d0e358e5 (patch)
treefaeb8e85fc6d5bf039253a119b4f904734cc95ad /libavutil
parent32fd27df2fc47099ca21c99a1a8b4595ca9249ab (diff)
avutil/hwcontext_qsv: Allocate public and priv device hwctx together
This is possible because the lifetime of both coincide. Besides reducing the number of allocations this also simplifies access to QSVDeviceContext as one no longer has to go through AVHWDeviceInternal. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/hwcontext_qsv.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index a67552b5ac..99d974f25f 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -70,6 +70,11 @@ typedef struct QSVDevicePriv {
} QSVDevicePriv;
typedef struct QSVDeviceContext {
+ /**
+ * The public AVQSVDeviceContext. See hwcontext_qsv.h for it.
+ */
+ AVQSVDeviceContext p;
+
mfxHDL handle;
mfxHandleType handle_type;
mfxVersion ver;
@@ -268,8 +273,8 @@ static int qsv_fill_border(AVFrame *dst, const AVFrame *src)
static int qsv_device_init(AVHWDeviceContext *ctx)
{
- AVQSVDeviceContext *hwctx = ctx->hwctx;
- QSVDeviceContext *s = ctx->internal->priv;
+ QSVDeviceContext *s = ctx->hwctx;
+ AVQSVDeviceContext *hwctx = &s->p;
int hw_handle_supported = 0;
mfxHandleType handle_type;
enum AVHWDeviceType device_type;
@@ -378,7 +383,7 @@ static int qsv_init_child_ctx(AVHWFramesContext *ctx)
{
AVQSVFramesContext *hwctx = ctx->hwctx;
QSVFramesContext *s = ctx->internal->priv;
- QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv;
+ QSVDeviceContext *device_priv = ctx->device_ctx->hwctx;
AVBufferRef *child_device_ref = NULL;
AVBufferRef *child_frames_ref = NULL;
@@ -1108,7 +1113,8 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx,
mfxSession *session, int upload)
{
AVQSVFramesContext *frames_hwctx = ctx->hwctx;
- QSVDeviceContext *device_priv = ctx->device_ctx->internal->priv;
+ QSVDeviceContext *device_priv = ctx->device_ctx->hwctx;
+ AVQSVDeviceContext *hwctx = &device_priv->p;
int opaque = 0;
mfxFrameAllocator frame_allocator = {
@@ -1123,7 +1129,6 @@ static int qsv_init_internal_session(AVHWFramesContext *ctx,
mfxVideoParam par;
mfxStatus err;
int ret = AVERROR_UNKNOWN;
- AVQSVDeviceContext *hwctx = ctx->device_ctx->hwctx;
/* hwctx->loader is non-NULL for oneVPL user and NULL for non-oneVPL user */
void **loader = &hwctx->loader;
@@ -2246,8 +2251,7 @@ const HWContextType ff_hwcontext_type_qsv = {
.type = AV_HWDEVICE_TYPE_QSV,
.name = "QSV",
- .device_hwctx_size = sizeof(AVQSVDeviceContext),
- .device_priv_size = sizeof(QSVDeviceContext),
+ .device_hwctx_size = sizeof(QSVDeviceContext),
.frames_hwctx_size = sizeof(AVQSVFramesContext),
.frames_priv_size = sizeof(QSVFramesContext),