summaryrefslogtreecommitdiff
path: root/libavfilter/vf_deinterlace_qsv.c
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2020-08-19 09:43:12 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2022-08-12 10:43:39 +0800
commitc77149bc37f5a200e635c60bf6eb4efc7b03af91 (patch)
tree18507a6a99e3624c4ad3a9e05df5e53b07db5fc7 /libavfilter/vf_deinterlace_qsv.c
parent63cda40930a228e490e107f4fc945688696cef2a (diff)
qsv: restrict OPAQUE memory to MFX_VERSION < 2.0
OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in preparation for oneVPL support [1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals [2] https://github.com/oneapi-src/oneVPL
Diffstat (limited to 'libavfilter/vf_deinterlace_qsv.c')
-rw-r--r--libavfilter/vf_deinterlace_qsv.c57
1 files changed, 32 insertions, 25 deletions
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index b8ff3e8339..50f9156d14 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -62,7 +62,9 @@ typedef struct QSVDeintContext {
mfxFrameSurface1 **surface_ptrs;
int nb_surface_ptrs;
+#if QSV_HAVE_OPAQUE
mfxExtOpaqueSurfaceAlloc opaque_alloc;
+#endif
mfxExtVPPDeinterlacing deint_conf;
mfxExtBuffer *ext_buffers[2];
int num_ext_buffers;
@@ -154,9 +156,7 @@ static int init_out_session(AVFilterContext *ctx)
AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)s->hw_frames_ctx->data;
AVQSVFramesContext *hw_frames_hwctx = hw_frames_ctx->hwctx;
AVQSVDeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx;
-
- int opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
-
+ int opaque = 0;
mfxHDL handle = NULL;
mfxHandleType handle_type;
mfxVersion ver;
@@ -165,6 +165,9 @@ static int init_out_session(AVFilterContext *ctx)
mfxStatus err;
int i;
+#if QSV_HAVE_OPAQUE
+ opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
+#endif
/* extract the properties of the "master" session given to us */
err = MFXQueryIMPL(device_hwctx->session, &impl);
if (err == MFX_ERR_NONE)
@@ -223,28 +226,7 @@ static int init_out_session(AVFilterContext *ctx)
s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf;
- if (opaque) {
- s->surface_ptrs = av_calloc(hw_frames_hwctx->nb_surfaces,
- sizeof(*s->surface_ptrs));
- if (!s->surface_ptrs)
- return AVERROR(ENOMEM);
- for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
- s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i;
- s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces;
-
- s->opaque_alloc.In.Surfaces = s->surface_ptrs;
- s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs;
- s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type;
-
- s->opaque_alloc.Out = s->opaque_alloc.In;
-
- s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
- s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
-
- s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc;
-
- par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
- } else {
+ if (!opaque) {
mfxFrameAllocator frame_allocator = {
.pthis = ctx,
.Alloc = frame_alloc,
@@ -268,6 +250,31 @@ static int init_out_session(AVFilterContext *ctx)
par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
}
+#if QSV_HAVE_OPAQUE
+ else {
+ s->surface_ptrs = av_calloc(hw_frames_hwctx->nb_surfaces,
+ sizeof(*s->surface_ptrs));
+
+ if (!s->surface_ptrs)
+ return AVERROR(ENOMEM);
+ for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++)
+ s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i;
+ s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces;
+
+ s->opaque_alloc.In.Surfaces = s->surface_ptrs;
+ s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs;
+ s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type;
+
+ s->opaque_alloc.Out = s->opaque_alloc.In;
+
+ s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
+ s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
+
+ s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc;
+
+ par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
+ }
+#endif
par.ExtParam = s->ext_buffers;
par.NumExtParam = s->num_ext_buffers;