aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-02-11 16:50:56 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-03-04 16:26:41 +0100
commitf4df14b3545d9214a429cb14488550ca63f55aed (patch)
treea91dce60194879907842dc8cc014572bb63e007d /libavutil
parente2e2ee7711c6cf65302c2c420e60622da4e514e7 (diff)
downloadffmpeg-f4df14b3545d9214a429cb14488550ca63f55aed.tar.gz
avutil/hwcontext_vdpau: 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 VDPAUDeviceContext 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_vdpau.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/libavutil/hwcontext_vdpau.c b/libavutil/hwcontext_vdpau.c
index 5b78e95529..016300db1e 100644
--- a/libavutil/hwcontext_vdpau.c
+++ b/libavutil/hwcontext_vdpau.c
@@ -83,6 +83,11 @@ static const struct {
};
typedef struct VDPAUDeviceContext {
+ /**
+ * The public AVVDPAUDeviceContext. See hwcontext_vdpau.h for it.
+ */
+ AVVDPAUDeviceContext p;
+
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities *get_transfer_caps;
VdpVideoSurfaceGetBitsYCbCr *get_data;
VdpVideoSurfacePutBitsYCbCr *put_data;
@@ -115,8 +120,8 @@ static int count_pixfmts(const VDPAUPixFmtMap *map)
static int vdpau_init_pixmfts(AVHWDeviceContext *ctx)
{
- AVVDPAUDeviceContext *hwctx = ctx->hwctx;
- VDPAUDeviceContext *priv = ctx->internal->priv;
+ VDPAUDeviceContext *priv = ctx->hwctx;
+ AVVDPAUDeviceContext *hwctx = &priv->p;
int i;
for (i = 0; i < FF_ARRAY_ELEMS(priv->pix_fmts); i++) {
@@ -157,8 +162,8 @@ do {
static int vdpau_device_init(AVHWDeviceContext *ctx)
{
- AVVDPAUDeviceContext *hwctx = ctx->hwctx;
- VDPAUDeviceContext *priv = ctx->internal->priv;
+ VDPAUDeviceContext *priv = ctx->hwctx;
+ AVVDPAUDeviceContext *hwctx = &priv->p;
VdpStatus err;
int ret;
@@ -180,7 +185,7 @@ static int vdpau_device_init(AVHWDeviceContext *ctx)
static void vdpau_device_uninit(AVHWDeviceContext *ctx)
{
- VDPAUDeviceContext *priv = ctx->internal->priv;
+ VDPAUDeviceContext *priv = ctx->hwctx;
int i;
for (i = 0; i < FF_ARRAY_ELEMS(priv->pix_fmts); i++)
@@ -191,7 +196,7 @@ static int vdpau_frames_get_constraints(AVHWDeviceContext *ctx,
const void *hwconfig,
AVHWFramesConstraints *constraints)
{
- VDPAUDeviceContext *priv = ctx->internal->priv;
+ VDPAUDeviceContext *priv = ctx->hwctx;
int nb_sw_formats = 0;
int i;
@@ -219,7 +224,7 @@ static int vdpau_frames_get_constraints(AVHWDeviceContext *ctx,
static void vdpau_buffer_free(void *opaque, uint8_t *data)
{
AVHWFramesContext *ctx = opaque;
- VDPAUDeviceContext *device_priv = ctx->device_ctx->internal->priv;
+ VDPAUDeviceContext *device_priv = ctx->device_ctx->hwctx;
VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)data;
device_priv->surf_destroy(surf);
@@ -229,8 +234,8 @@ static AVBufferRef *vdpau_pool_alloc(void *opaque, size_t size)
{
AVHWFramesContext *ctx = opaque;
VDPAUFramesContext *priv = ctx->internal->priv;
- AVVDPAUDeviceContext *device_hwctx = ctx->device_ctx->hwctx;
- VDPAUDeviceContext *device_priv = ctx->device_ctx->internal->priv;
+ VDPAUDeviceContext *device_priv = ctx->device_ctx->hwctx;
+ AVVDPAUDeviceContext *device_hwctx = &device_priv->p;
AVBufferRef *ret;
VdpVideoSurface surf;
@@ -255,7 +260,7 @@ static AVBufferRef *vdpau_pool_alloc(void *opaque, size_t size)
static int vdpau_frames_init(AVHWFramesContext *ctx)
{
- VDPAUDeviceContext *device_priv = ctx->device_ctx->internal->priv;
+ VDPAUDeviceContext *device_priv = ctx->device_ctx->hwctx;
VDPAUFramesContext *priv = ctx->internal->priv;
int i;
@@ -508,8 +513,7 @@ const HWContextType ff_hwcontext_type_vdpau = {
.type = AV_HWDEVICE_TYPE_VDPAU,
.name = "VDPAU",
- .device_hwctx_size = sizeof(AVVDPAUDeviceContext),
- .device_priv_size = sizeof(VDPAUDeviceContext),
+ .device_hwctx_size = sizeof(VDPAUDeviceContext),
.frames_priv_size = sizeof(VDPAUFramesContext),
#if HAVE_VDPAU_X11