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
736 return 0;736 return 0;
737}737}
738 738
739static int set_frame_ext_params_null(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp)
740{
741 return 0;
742}
743
739int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)744int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
740{745{
741 int i;746 int i;
@@ -747,6 +752,10 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 5 unmodified lines
747 s->filter_frame = ff_filter_frame;752 s->filter_frame = ff_filter_frame;
748 s->out_sw_format = param->out_sw_format;753 s->out_sw_format = param->out_sw_format;
749 754
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
750 /* create the vpp session */759 /* create the vpp session */
751 ret = init_vpp_session(avctx, s);760 ret = init_vpp_session(avctx, s);
752 if (ret < 0)761 if (ret < 0)
@@ -873,27 +882,53 @@ failed: · 120 unmodified lines
873static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out)882static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out)
874{883{
875 int ret;884 int ret;
885 mfxExtBuffer *ext_param[QSVVPP_MAX_FRAME_EXTBUFS];
886 QSVVPPFrameParam fp = { 0, ext_param };
876 887
877 if (s->vpp_initted)888 ret = s->set_frame_ext_params(avctx, in->frame, out->frame, &fp);
878 return 0;889 if (ret)
890 return ret;
879 891
880 s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;892 if (fp.num_ext_buf) {
881 s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;893 av_freep(&s->ext_buffers);
894 s->nb_ext_buffers = s->nb_seq_buffers + fp.num_ext_buf;
882 895
883 /* Query VPP params again, including params for frame */896 s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers));
884 ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);897 if (!s->ext_buffers)
885 if (ret < 0)898 return AVERROR(ENOMEM);
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");
889 899
890 ret = MFXVideoVPP_Init(s->session, &s->vpp_param);900 memcpy(&s->ext_buffers[0], s->seq_buffers, s->nb_seq_buffers * sizeof(*s->seq_buffers));
891 if (ret < 0)901 memcpy(&s->ext_buffers[s->nb_seq_buffers], fp.ext_buf, fp.num_ext_buf * sizeof(*fp.ext_buf));
892 return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");902 s->vpp_param.ExtParam = s->ext_buffers;
893 else if (ret > 0)903 s->vpp_param.NumExtParam = s->nb_ext_buffers;
894 ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");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");
895 922
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 }
897 932
898 return 0;933 return 0;
899}934}
libavfilter/qsvvpp.h+10−0
@@ -52,11 +52,20 @@ typedef struct QSVFrame { · 51 unmodified lines
52 int queued;52 int queued;
53} QSVFrame;53} QSVFrame;
54 54
55#define QSVVPP_MAX_FRAME_EXTBUFS 8
56
57typedef struct QSVVPPFrameParam {
58 /* To fill with MFX enhanced filter configurations */
59 int num_ext_buf;
60 mfxExtBuffer **ext_buf;
61} QSVVPPFrameParam;
62
55typedef struct QSVVPPContext {63typedef struct QSVVPPContext {
56 const AVClass *class;64 const AVClass *class;
57 65
58 mfxSession session;66 mfxSession session;
59 int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */67 int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
68 int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
60 enum AVPixelFormat out_sw_format; /**< Real output format */69 enum AVPixelFormat out_sw_format; /**< Real output format */
61 mfxVideoParam vpp_param;70 mfxVideoParam vpp_param;
62 mfxFrameInfo *frame_infos; /**< frame info for each input */71 mfxFrameInfo *frame_infos; /**< frame info for each input */
@@ -101,6 +110,7 @@ typedef struct QSVVPPCrop { · 38 unmodified lines
101typedef struct QSVVPPParam {110typedef struct QSVVPPParam {
102 /* default is ff_filter_frame */111 /* default is ff_filter_frame */
103 int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);112 int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
113 int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
104 114
105 /* To fill with MFX enhanced filter configurations */115 /* To fill with MFX enhanced filter configurations */
106 int num_ext_buf;116 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