History

lavfi/qsvvpp: postpone vpp session initialization

So there is a chance to update vpp parameters per frame

Haihao Xiang committed 3 years ago

Commit bcdea211 parent cf21ca92 files · +32 −7Browse files

Showing the changes to libavfilter (2 of 2 files). Show all

Unified · Split

2 files
  1. libavfilter/qsvvpp.c +31 −7
  2. libavfilter/qsvvpp.h +1 −0
libavfilter/qsvvpp.c+31−7
@@ -835,6 +835,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 834 unmodified lines
835835 /* Print output memory mode */
836836 ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP");
837837
838+ /* Validate VPP params, but don't initial VPP session here */
838839 ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
839840 if (ret < 0) {
840841 ret = ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params");
@@ -842,13 +843,6 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 1 unmodified line
842843 } else if (ret > 0)
843844 ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params");
844845
845− ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
846− if (ret < 0) {
847− ret = ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
848− goto failed;
849− } else if (ret > 0)
850− ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
851−
852846 return 0;
853847
854848 failed:
@@ -857,6 +851,31 @@ failed: · 2 unmodified lines
857851 return ret;
858852 }
859853
854+static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
855+{
856+ int ret;
857+
858+ if (s->vpp_initted)
859+ return 0;
860+
861+ /* Query VPP params again, including params for frame */
862+ ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
863+ if (ret < 0)
864+ return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params");
865+ else if (ret > 0)
866+ ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params");
867+
868+ ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
869+ if (ret < 0)
870+ return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
871+ else if (ret > 0)
872+ ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
873+
874+ s->vpp_initted = 1;
875+
876+ return 0;
877+}
878+
860879 int ff_qsvvpp_close(AVFilterContext *avctx)
861880 {
862881 QSVVPPContext *s = avctx->priv;
@@ -865,6 +884,7 @@ int ff_qsvvpp_close(AVFilterContext *avctx) · 2 unmodified lines
865884 MFXVideoVPP_Close(s->session);
866885 MFXClose(s->session);
867886 s->session = NULL;
887+ s->vpp_initted = 0;
868888 }
869889
870890 /* release all the resources */
@@ -920,6 +940,10 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr · 49 unmodified lines
920940 return AVERROR(ENOMEM);
921941 }
922942
943+ ret = qsvvpp_init_vpp_session(ctx, s);
944+ if (ret)
945+ return ret;
946+
923947 do {
924948 ret = MFXVideoVPP_RunFrameVPPAsync(s->session, &in_frame->surface,
925949 &out_frame->surface, NULL, &sync);
libavfilter/qsvvpp.h+1−0
@@ -90,6 +90,7 @@ typedef struct QSVVPPContext { · 89 unmodified lines
9090 AVFifo *async_fifo;
9191
9292 mfxVersion ver;
93+ int vpp_initted;
9394 } QSVVPPContext;
9495
9596 typedef struct QSVVPPCrop {

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