On Wo, 2023-07-26 at 15:15 +0800, Xiang, Haihao wrote: > From: Haihao Xiang <haihao.xi...@intel.com> > > This allows we add mfxExtBuffer per frame later. > > Signed-off-by: Haihao Xiang <haihao.xi...@intel.com> > --- > libavfilter/qsvvpp.c | 67 +++++++++++++++++++++++++++++++++----------- > libavfilter/qsvvpp.h | 10 +++++++ > 2 files changed, 61 insertions(+), 16 deletions(-) > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c > index a03de05d9c..3c8dfea16a 100644 > --- a/libavfilter/qsvvpp.c > +++ b/libavfilter/qsvvpp.c > @@ -731,6 +731,11 @@ static int init_vpp_session(AVFilterContext *avctx, > QSVVPPContext *s) > 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 i; > @@ -742,6 +747,10 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam > *param) > s->filter_frame = ff_filter_frame; > 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 */ > ret = init_vpp_session(avctx, s); > if (ret < 0) > @@ -868,27 +877,53 @@ failed: > static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, > const QSVFrame *in, QSVFrame *out) > { > int ret; > + mfxExtBuffer *ext_param[QSVVPP_MAX_FRAME_EXTBUFS]; > + QSVVPPFrameParam fp = { 0, ext_param }; > > - if (s->vpp_initted) > - return 0; > + ret = s->set_frame_ext_params(avctx, in->frame, out->frame, &fp); > + if (ret) > + return ret; > > - s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct; > - s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct; > + if (fp.num_ext_buf) { > + 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 */ > - 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"); > + s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s- > >ext_buffers)); > + if (!s->ext_buffers) > + return AVERROR(ENOMEM); > > - 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"); > + memcpy(&s->ext_buffers[0], s->seq_buffers, s->nb_seq_buffers * > sizeof(*s->seq_buffers)); > + memcpy(&s->ext_buffers[s->nb_seq_buffers], fp.ext_buf, fp.num_ext_buf > * sizeof(*fp.ext_buf)); > + s->vpp_param.ExtParam = s->ext_buffers; > + s->vpp_param.NumExtParam = s->nb_ext_buffers; > + } > + > + 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; > + 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; > } > diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h > index fba5f037d4..4eea7a46c7 100644 > --- a/libavfilter/qsvvpp.h > +++ b/libavfilter/qsvvpp.h > @@ -52,11 +52,20 @@ typedef struct QSVFrame { > int queued; > } 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 { > const AVClass *class; > > mfxSession session; > 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 */ > mfxVideoParam vpp_param; > mfxFrameInfo *frame_infos; /**< frame info for each input */ > @@ -101,6 +110,7 @@ typedef struct QSVVPPCrop { > typedef struct QSVVPPParam { > /* default is ff_filter_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 */ > int num_ext_buf;
Will apply - Haihao _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".