mirror of https://git.ffmpeg.org/ffmpeg.git
lavfi/qsvvpp: add set_frame_ext_params callback
This allows we add mfxExtBuffer per frame later. Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
parent
044ab532fc
commit
96b0b3f67a
|
@ -736,6 +736,11 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int set_frame_ext_params_null(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
|
int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -747,6 +752,10 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
|
||||||
s->filter_frame = ff_filter_frame;
|
s->filter_frame = ff_filter_frame;
|
||||||
s->out_sw_format = param->out_sw_format;
|
s->out_sw_format = param->out_sw_format;
|
||||||
|
|
||||||
|
s->set_frame_ext_params = param->set_frame_ext_params;
|
||||||
|
if (!s->set_frame_ext_params)
|
||||||
|
s->set_frame_ext_params = set_frame_ext_params_null;
|
||||||
|
|
||||||
/* create the vpp session */
|
/* create the vpp session */
|
||||||
ret = init_vpp_session(avctx, s);
|
ret = init_vpp_session(avctx, s);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -873,27 +882,53 @@ failed:
|
||||||
static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out)
|
static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
mfxExtBuffer *ext_param[QSVVPP_MAX_FRAME_EXTBUFS];
|
||||||
|
QSVVPPFrameParam fp = { 0, ext_param };
|
||||||
|
|
||||||
if (s->vpp_initted)
|
ret = s->set_frame_ext_params(avctx, in->frame, out->frame, &fp);
|
||||||
return 0;
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
|
if (fp.num_ext_buf) {
|
||||||
s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
|
av_freep(&s->ext_buffers);
|
||||||
|
s->nb_ext_buffers = s->nb_seq_buffers + fp.num_ext_buf;
|
||||||
|
|
||||||
/* Query VPP params again, including params for frame */
|
s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
|
||||||
ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
|
if (!s->ext_buffers)
|
||||||
if (ret < 0)
|
return AVERROR(ENOMEM);
|
||||||
return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params");
|
|
||||||
else if (ret > 0)
|
|
||||||
ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params");
|
|
||||||
|
|
||||||
ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
|
memcpy(&s->ext_buffers[0], s->seq_buffers, s->nb_seq_buffers * sizeof(*s->seq_buffers));
|
||||||
if (ret < 0)
|
memcpy(&s->ext_buffers[s->nb_seq_buffers], fp.ext_buf, fp.num_ext_buf * sizeof(*fp.ext_buf));
|
||||||
return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
|
s->vpp_param.ExtParam = s->ext_buffers;
|
||||||
else if (ret > 0)
|
s->vpp_param.NumExtParam = s->nb_ext_buffers;
|
||||||
ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
|
}
|
||||||
|
|
||||||
s->vpp_initted = 1;
|
if (!s->vpp_initted) {
|
||||||
|
s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
|
||||||
|
s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
|
||||||
|
|
||||||
|
/* Query VPP params again, including params for frame */
|
||||||
|
ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
|
||||||
|
if (ret < 0)
|
||||||
|
return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params");
|
||||||
|
else if (ret > 0)
|
||||||
|
ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params");
|
||||||
|
|
||||||
|
ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
|
||||||
|
if (ret < 0)
|
||||||
|
return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
|
||||||
|
else if (ret > 0)
|
||||||
|
ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
|
||||||
|
|
||||||
|
s->vpp_initted = 1;
|
||||||
|
} else if (fp.num_ext_buf) {
|
||||||
|
ret = MFXVideoVPP_Reset(s->session, &s->vpp_param);
|
||||||
|
if (ret < 0) {
|
||||||
|
ret = ff_qsvvpp_print_error(avctx, ret, "Failed to reset session for qsvvpp");
|
||||||
|
return ret;
|
||||||
|
} else if (ret > 0)
|
||||||
|
ff_qsvvpp_print_warning(avctx, ret, "Warning When resetting session for qsvvpp");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,20 @@ typedef struct QSVFrame {
|
||||||
int queued;
|
int queued;
|
||||||
} QSVFrame;
|
} QSVFrame;
|
||||||
|
|
||||||
|
#define QSVVPP_MAX_FRAME_EXTBUFS 8
|
||||||
|
|
||||||
|
typedef struct QSVVPPFrameParam {
|
||||||
|
/* To fill with MFX enhanced filter configurations */
|
||||||
|
int num_ext_buf;
|
||||||
|
mfxExtBuffer **ext_buf;
|
||||||
|
} QSVVPPFrameParam;
|
||||||
|
|
||||||
typedef struct QSVVPPContext {
|
typedef struct QSVVPPContext {
|
||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
|
|
||||||
mfxSession session;
|
mfxSession session;
|
||||||
int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
|
int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
|
||||||
|
int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
|
||||||
enum AVPixelFormat out_sw_format; /**< Real output format */
|
enum AVPixelFormat out_sw_format; /**< Real output format */
|
||||||
mfxVideoParam vpp_param;
|
mfxVideoParam vpp_param;
|
||||||
mfxFrameInfo *frame_infos; /**< frame info for each input */
|
mfxFrameInfo *frame_infos; /**< frame info for each input */
|
||||||
|
@ -101,6 +110,7 @@ typedef struct QSVVPPCrop {
|
||||||
typedef struct QSVVPPParam {
|
typedef struct QSVVPPParam {
|
||||||
/* default is ff_filter_frame */
|
/* default is ff_filter_frame */
|
||||||
int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
|
int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
|
||||||
|
int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
|
||||||
|
|
||||||
/* To fill with MFX enhanced filter configurations */
|
/* To fill with MFX enhanced filter configurations */
|
||||||
int num_ext_buf;
|
int num_ext_buf;
|
||||||
|
|
Loading…
Reference in New Issue