History

lavfi/qsvvpp: add set_frame_ext_params callback

This allows we add mfxExtBuffer per frame later.

Haihao Xiang committed 3 years ago

Commit 96b0b3f1 parent 044ab532 files · +61 −16Browse files

Unified · Split

2 files
  1. libavfilter/qsvvpp.c +51 −16
  2. libavfilter/qsvvpp.h +10 −0
libavfilter/qsvvpp.c+51−16
@@ -736,6 +736,11 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) · 735 unmodified lines
736736 return 0;
737737 }
738738
739+static int set_frame_ext_params_null(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp)
740+{
741+ return 0;
742+}
743+
739744 int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
740745 {
741746 int i;
@@ -747,6 +752,10 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 5 unmodified lines
747752 s->filter_frame = ff_filter_frame;
748753 s->out_sw_format = param->out_sw_format;
749754
755+ s->set_frame_ext_params = param->set_frame_ext_params;
756+ if (!s->set_frame_ext_params)
757+ s->set_frame_ext_params = set_frame_ext_params_null;
758+
750759 /* create the vpp session */
751760 ret = init_vpp_session(avctx, s);
752761 if (ret < 0)
@@ -873,27 +882,53 @@ failed: · 120 unmodified lines
873882 static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out)
874883 {
875884 int ret;
885+ mfxExtBuffer *ext_param[QSVVPP_MAX_FRAME_EXTBUFS];
886+ QSVVPPFrameParam fp = { 0, ext_param };
876887
877− if (s->vpp_initted)
878− return 0;
888+ ret = s->set_frame_ext_params(avctx, in->frame, out->frame, &fp);
889+ if (ret)
890+ return ret;
879891
880− s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
881− s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
892+ if (fp.num_ext_buf) {
893+ av_freep(&s->ext_buffers);
894+ s->nb_ext_buffers = s->nb_seq_buffers + fp.num_ext_buf;
882895
883− /* Query VPP params again, including params for frame */
884− ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
885− if (ret < 0)
886− return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params");
887− else if (ret > 0)
888− ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params");
896+ s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
897+ if (!s->ext_buffers)
898+ return AVERROR(ENOMEM);
889899
890− ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
891− if (ret < 0)
892− return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
893− else if (ret > 0)
894− ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
900+ memcpy(&s->ext_buffers[0], s->seq_buffers, s->nb_seq_buffers * sizeof(*s->seq_buffers));
901+ memcpy(&s->ext_buffers[s->nb_seq_buffers], fp.ext_buf, fp.num_ext_buf * sizeof(*fp.ext_buf));
902+ s->vpp_param.ExtParam = s->ext_buffers;
903+ s->vpp_param.NumExtParam = s->nb_ext_buffers;
904+ }
905+
906+ if (!s->vpp_initted) {
907+ s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
908+ s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
909+
910+ /* Query VPP params again, including params for frame */
911+ ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
912+ if (ret < 0)
913+ return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params");
914+ else if (ret > 0)
915+ ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params");
916+
917+ ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
918+ if (ret < 0)
919+ return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
920+ else if (ret > 0)
921+ ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
895922
896− s->vpp_initted = 1;
923+ s->vpp_initted = 1;
924+ } else if (fp.num_ext_buf) {
925+ ret = MFXVideoVPP_Reset(s->session, &s->vpp_param);
926+ if (ret < 0) {
927+ ret = ff_qsvvpp_print_error(avctx, ret, "Failed to reset session for qsvvpp");
928+ return ret;
929+ } else if (ret > 0)
930+ ff_qsvvpp_print_warning(avctx, ret, "Warning When resetting session for qsvvpp");
931+ }
897932
898933 return 0;
899934 }
libavfilter/qsvvpp.h+10−0
@@ -52,11 +52,20 @@ typedef struct QSVFrame { · 51 unmodified lines
5252 int queued;
5353 } QSVFrame;
5454
55+#define QSVVPP_MAX_FRAME_EXTBUFS 8
56+
57+typedef struct QSVVPPFrameParam {
58+ /* To fill with MFX enhanced filter configurations */
59+ int num_ext_buf;
60+ mfxExtBuffer **ext_buf;
61+} QSVVPPFrameParam;
62+
5563 typedef struct QSVVPPContext {
5664 const AVClass *class;
5765
5866 mfxSession session;
5967 int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
68+ int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
6069 enum AVPixelFormat out_sw_format; /**< Real output format */
6170 mfxVideoParam vpp_param;
6271 mfxFrameInfo *frame_infos; /**< frame info for each input */
@@ -101,6 +110,7 @@ typedef struct QSVVPPCrop { · 38 unmodified lines
101110 typedef struct QSVVPPParam {
102111 /* default is ff_filter_frame */
103112 int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
113+ int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
104114
105115 /* To fill with MFX enhanced filter configurations */
106116 int num_ext_buf;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t