aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-02-11 15:39:44 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-02-20 19:08:14 +0100
commit520c1b0a7c8fe92f1b3bd8a5864f4f0006757322 (patch)
tree96c5b51d3e197fb74a30d6210c10cb0b1d5ae769
parentcffadfe99a1c41866701bab6c7410c17737a1db1 (diff)
downloadffmpeg-520c1b0a7c8fe92f1b3bd8a5864f4f0006757322.tar.gz
avutil/hwcontext_vaapi: 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 VAAPIDeviceContext as one no longer has to go through AVHWDeviceInternal. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavutil/hwcontext_vaapi.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 29fc8bd648..7019769f24 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -75,6 +75,11 @@ typedef struct VAAPISurfaceFormat {
} VAAPISurfaceFormat;
typedef struct VAAPIDeviceContext {
+ /**
+ * The public AVVAAPIDeviceContext. See hwcontext_vaapi.h for it.
+ */
+ AVVAAPIDeviceContext p;
+
// Surface formats which can be used with this device.
VAAPISurfaceFormat *formats;
int nb_formats;
@@ -207,7 +212,7 @@ static int vaapi_get_image_format(AVHWDeviceContext *hwdev,
enum AVPixelFormat pix_fmt,
VAImageFormat **image_format)
{
- VAAPIDeviceContext *ctx = hwdev->internal->priv;
+ VAAPIDeviceContext *ctx = hwdev->hwctx;
int i;
for (i = 0; i < ctx->nb_formats; i++) {
@@ -224,9 +229,9 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev,
const void *hwconfig,
AVHWFramesConstraints *constraints)
{
- AVVAAPIDeviceContext *hwctx = hwdev->hwctx;
+ VAAPIDeviceContext *ctx = hwdev->hwctx;
+ AVVAAPIDeviceContext *hwctx = &ctx->p;
const AVVAAPIHWConfig *config = hwconfig;
- VAAPIDeviceContext *ctx = hwdev->internal->priv;
VASurfaceAttrib *attr_list = NULL;
VAStatus vas;
enum AVPixelFormat pix_fmt;
@@ -384,8 +389,8 @@ static const struct {
static int vaapi_device_init(AVHWDeviceContext *hwdev)
{
- VAAPIDeviceContext *ctx = hwdev->internal->priv;
- AVVAAPIDeviceContext *hwctx = hwdev->hwctx;
+ VAAPIDeviceContext *ctx = hwdev->hwctx;
+ AVVAAPIDeviceContext *hwctx = &ctx->p;
VAImageFormat *image_list = NULL;
VAStatus vas;
const char *vendor_string;
@@ -474,7 +479,7 @@ fail:
static void vaapi_device_uninit(AVHWDeviceContext *hwdev)
{
- VAAPIDeviceContext *ctx = hwdev->internal->priv;
+ VAAPIDeviceContext *ctx = hwdev->hwctx;
av_freep(&ctx->formats);
}
@@ -718,7 +723,7 @@ static int vaapi_transfer_get_formats(AVHWFramesContext *hwfc,
enum AVHWFrameTransferDirection dir,
enum AVPixelFormat **formats)
{
- VAAPIDeviceContext *ctx = hwfc->device_ctx->internal->priv;
+ VAAPIDeviceContext *ctx = hwfc->device_ctx->hwctx;
enum AVPixelFormat *pix_fmts;
int i, k, sw_format_available;
@@ -2007,8 +2012,7 @@ const HWContextType ff_hwcontext_type_vaapi = {
.type = AV_HWDEVICE_TYPE_VAAPI,
.name = "VAAPI",
- .device_hwctx_size = sizeof(AVVAAPIDeviceContext),
- .device_priv_size = sizeof(VAAPIDeviceContext),
+ .device_hwctx_size = sizeof(VAAPIDeviceContext),
.device_hwconfig_size = sizeof(AVVAAPIHWConfig),
.frames_hwctx_size = sizeof(AVVAAPIFramesContext),
.frames_priv_size = sizeof(VAAPIFramesContext),