mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-16 20:07:04 +00:00
lavfi/qsv: create mfx session using oneVPL for qsv filters
Use the mfxLoader handle in qsv hwdevice to create mfx session for qsv filters. This is in preparation for oneVPL support
This commit is contained in:
parent
6900feef06
commit
54c4196d56
@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
#include "libavutil/common.h"
|
#include "libavutil/common.h"
|
||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
#include "libavutil/hwcontext.h"
|
|
||||||
#include "libavutil/hwcontext_qsv.h"
|
|
||||||
#include "libavutil/time.h"
|
#include "libavutil/time.h"
|
||||||
#include "libavutil/pixdesc.h"
|
#include "libavutil/pixdesc.h"
|
||||||
|
|
||||||
@ -32,6 +30,12 @@
|
|||||||
#include "qsvvpp.h"
|
#include "qsvvpp.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
|
|
||||||
|
#if QSV_ONEVPL
|
||||||
|
#include <mfxdispatcher.h>
|
||||||
|
#else
|
||||||
|
#define MFXUnload(a) do { } while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \
|
#define IS_VIDEO_MEMORY(mode) (mode & (MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET | \
|
||||||
MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
|
MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET))
|
||||||
#if QSV_HAVE_OPAQUE
|
#if QSV_HAVE_OPAQUE
|
||||||
@ -620,13 +624,10 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create a "slave" session with those same properties, to be used for vpp */
|
/* create a "slave" session with those same properties, to be used for vpp */
|
||||||
ret = MFXInit(impl, &ver, &s->session);
|
ret = ff_qsvvpp_create_mfx_session(avctx, device_hwctx->loader, impl, &ver,
|
||||||
if (ret < 0)
|
&s->session);
|
||||||
return ff_qsvvpp_print_error(avctx, ret, "Error initializing a session");
|
if (ret)
|
||||||
else if (ret > 0) {
|
return ret;
|
||||||
ff_qsvvpp_print_warning(avctx, ret, "Warning in session initialization");
|
|
||||||
return AVERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
|
ret = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
|
||||||
@ -912,3 +913,93 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QSV_ONEVPL
|
||||||
|
|
||||||
|
int ff_qsvvpp_create_mfx_session(void *ctx,
|
||||||
|
void *loader,
|
||||||
|
mfxIMPL implementation,
|
||||||
|
mfxVersion *pver,
|
||||||
|
mfxSession *psession)
|
||||||
|
{
|
||||||
|
mfxStatus sts;
|
||||||
|
mfxSession session = NULL;
|
||||||
|
uint32_t impl_idx = 0;
|
||||||
|
|
||||||
|
av_log(ctx, AV_LOG_VERBOSE,
|
||||||
|
"Use Intel(R) oneVPL to create MFX session with the specified MFX loader\n");
|
||||||
|
|
||||||
|
if (!loader) {
|
||||||
|
av_log(ctx, AV_LOG_ERROR, "Invalid MFX Loader handle\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
/* Enumerate all implementations */
|
||||||
|
mfxImplDescription *impl_desc;
|
||||||
|
|
||||||
|
sts = MFXEnumImplementations(loader, impl_idx,
|
||||||
|
MFX_IMPLCAPS_IMPLDESCSTRUCTURE,
|
||||||
|
(mfxHDL *)&impl_desc);
|
||||||
|
/* Failed to find an available implementation */
|
||||||
|
if (sts == MFX_ERR_NOT_FOUND)
|
||||||
|
break;
|
||||||
|
else if (sts != MFX_ERR_NONE) {
|
||||||
|
impl_idx++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sts = MFXCreateSession(loader, impl_idx, &session);
|
||||||
|
MFXDispReleaseImplDescription(loader, impl_desc);
|
||||||
|
if (sts == MFX_ERR_NONE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
impl_idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sts < 0)
|
||||||
|
return ff_qsvvpp_print_error(ctx, sts,
|
||||||
|
"Error creating a MFX session");
|
||||||
|
else if (sts > 0) {
|
||||||
|
ff_qsvvpp_print_warning(ctx, sts,
|
||||||
|
"Warning in MFX session creation");
|
||||||
|
return AVERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
*psession = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int ff_qsvvpp_create_mfx_session(void *ctx,
|
||||||
|
void *loader,
|
||||||
|
mfxIMPL implementation,
|
||||||
|
mfxVersion *pver,
|
||||||
|
mfxSession *psession)
|
||||||
|
{
|
||||||
|
mfxSession session = NULL;
|
||||||
|
mfxStatus sts;
|
||||||
|
|
||||||
|
av_log(ctx, AV_LOG_VERBOSE,
|
||||||
|
"Use Intel(R) Media SDK to create MFX session, API version is "
|
||||||
|
"%d.%d, the required implementation version is %d.%d\n",
|
||||||
|
MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
|
||||||
|
|
||||||
|
*psession = NULL;
|
||||||
|
sts = MFXInit(implementation, pver, &session);
|
||||||
|
if (sts < 0)
|
||||||
|
return ff_qsvvpp_print_error(ctx, sts,
|
||||||
|
"Error initializing an MFX session");
|
||||||
|
else if (sts > 0) {
|
||||||
|
ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session initialization");
|
||||||
|
return AVERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
*psession = session;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
#include "libavutil/fifo.h"
|
#include "libavutil/fifo.h"
|
||||||
|
#include "libavutil/hwcontext.h"
|
||||||
|
#include "libavutil/hwcontext_qsv.h"
|
||||||
|
|
||||||
#define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
|
#define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
|
||||||
#define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
|
#define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
|
||||||
@ -122,4 +124,7 @@ int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
|
|||||||
int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
|
int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
|
||||||
const char *warning_string);
|
const char *warning_string);
|
||||||
|
|
||||||
|
int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation,
|
||||||
|
mfxVersion *pver, mfxSession *psession);
|
||||||
|
|
||||||
#endif /* AVFILTER_QSVVPP_H */
|
#endif /* AVFILTER_QSVVPP_H */
|
||||||
|
@ -163,7 +163,7 @@ static int init_out_session(AVFilterContext *ctx)
|
|||||||
mfxIMPL impl;
|
mfxIMPL impl;
|
||||||
mfxVideoParam par;
|
mfxVideoParam par;
|
||||||
mfxStatus err;
|
mfxStatus err;
|
||||||
int i;
|
int i, ret;
|
||||||
|
|
||||||
#if QSV_HAVE_OPAQUE
|
#if QSV_HAVE_OPAQUE
|
||||||
opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
|
opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
|
||||||
@ -198,13 +198,10 @@ static int init_out_session(AVFilterContext *ctx)
|
|||||||
|
|
||||||
/* create a "slave" session with those same properties, to be used for
|
/* create a "slave" session with those same properties, to be used for
|
||||||
* actual deinterlacing */
|
* actual deinterlacing */
|
||||||
err = MFXInit(impl, &ver, &s->session);
|
ret = ff_qsvvpp_create_mfx_session(ctx, device_hwctx->loader, impl, &ver,
|
||||||
if (err < 0)
|
&s->session);
|
||||||
return ff_qsvvpp_print_error(ctx, err, "Error initializing a session for deinterlacing");
|
if (ret)
|
||||||
else if (err > 0) {
|
return ret;
|
||||||
ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization");
|
|
||||||
return AVERROR_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
err = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
|
err = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
|
||||||
|
@ -278,7 +278,7 @@ static int init_out_session(AVFilterContext *ctx)
|
|||||||
mfxIMPL impl;
|
mfxIMPL impl;
|
||||||
mfxVideoParam par;
|
mfxVideoParam par;
|
||||||
mfxStatus err;
|
mfxStatus err;
|
||||||
int i;
|
int i, ret;
|
||||||
|
|
||||||
#if QSV_HAVE_OPAQUE
|
#if QSV_HAVE_OPAQUE
|
||||||
opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
|
opaque = !!(in_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME);
|
||||||
@ -315,11 +315,10 @@ static int init_out_session(AVFilterContext *ctx)
|
|||||||
|
|
||||||
/* create a "slave" session with those same properties, to be used for
|
/* create a "slave" session with those same properties, to be used for
|
||||||
* actual scaling */
|
* actual scaling */
|
||||||
err = MFXInit(impl, &ver, &s->session);
|
ret = ff_qsvvpp_create_mfx_session(ctx, device_hwctx->loader, impl, &ver,
|
||||||
if (err != MFX_ERR_NONE) {
|
&s->session);
|
||||||
av_log(ctx, AV_LOG_ERROR, "Error initializing a session for scaling\n");
|
if (ret)
|
||||||
return AVERROR_UNKNOWN;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (handle) {
|
if (handle) {
|
||||||
err = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
|
err = MFXVideoCORE_SetHandle(s->session, handle_type, handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user