So there is a chance to update vpp parameters per frame
Showing the changes to libavfilter (2 of 2 files). Show all
Unified · Split
| @@ -835,6 +835,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) · 834 unmodified lines | |||
| 835 | /* Print output memory mode */ | 835 | /* Print output memory mode */ |
| 836 | ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP"); | 836 | ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP"); |
| 837 | 837 | ||
| 838 | /* Validate VPP params, but don't initial VPP session here */ | ||
| 838 | ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param); | 839 | ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param); |
| 839 | if (ret < 0) { | 840 | if (ret < 0) { |
| 840 | ret = ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params"); | 841 | 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 | |||
| 842 | } else if (ret > 0) | 843 | } else if (ret > 0) |
| 843 | ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params"); | 844 | ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params"); |
| 844 | 845 | ||
| 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 | |||
| 852 | return 0; | 846 | return 0; |
| 853 | 847 | ||
| 854 | failed: | 848 | failed: |
| @@ -857,6 +851,31 @@ failed: · 2 unmodified lines | |||
| 857 | return ret; | 851 | return ret; |
| 858 | } | 852 | } |
| 859 | 853 | ||
| 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 | |||
| 860 | int ff_qsvvpp_close(AVFilterContext *avctx) | 879 | int ff_qsvvpp_close(AVFilterContext *avctx) |
| 861 | { | 880 | { |
| 862 | QSVVPPContext *s = avctx->priv; | 881 | QSVVPPContext *s = avctx->priv; |
| @@ -865,6 +884,7 @@ int ff_qsvvpp_close(AVFilterContext *avctx) · 2 unmodified lines | |||
| 865 | MFXVideoVPP_Close(s->session); | 884 | MFXVideoVPP_Close(s->session); |
| 866 | MFXClose(s->session); | 885 | MFXClose(s->session); |
| 867 | s->session = NULL; | 886 | s->session = NULL; |
| 887 | s->vpp_initted = 0; | ||
| 868 | } | 888 | } |
| 869 | 889 | ||
| 870 | /* release all the resources */ | 890 | /* release all the resources */ |
| @@ -920,6 +940,10 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr · 49 unmodified lines | |||
| 920 | return AVERROR(ENOMEM); | 940 | return AVERROR(ENOMEM); |
| 921 | } | 941 | } |
| 922 | 942 | ||
| 943 | ret = qsvvpp_init_vpp_session(ctx, s); | ||
| 944 | if (ret) | ||
| 945 | return ret; | ||
| 946 | |||
| 923 | do { | 947 | do { |
| 924 | ret = MFXVideoVPP_RunFrameVPPAsync(s->session, &in_frame->surface, | 948 | ret = MFXVideoVPP_RunFrameVPPAsync(s->session, &in_frame->surface, |
| 925 | &out_frame->surface, NULL, &sync); | 949 | &out_frame->surface, NULL, &sync); |
| @@ -90,6 +90,7 @@ typedef struct QSVVPPContext { · 89 unmodified lines | |||
| 90 | AVFifo *async_fifo; | 90 | AVFifo *async_fifo; |
| 91 | 91 | ||
| 92 | mfxVersion ver; | 92 | mfxVersion ver; |
| 93 | int vpp_initted; | ||
| 93 | } QSVVPPContext; | 94 | } QSVVPPContext; |
| 94 | 95 | ||
| 95 | typedef struct QSVVPPCrop { | 96 | typedef struct QSVVPPCrop { |