Ticket #10537: onevpl-legacy-fix-6.0.patch

File onevpl-legacy-fix-6.0.patch, 10.3 KB (added by Steve Browne, 3 years ago)
  • sources/libavcodec/qsv.c

     libavcodec/qsv.c | 67 +++++++++++++++++++++++++++++++++-----------------------
     1 file changed, 39 insertions(+), 28 deletions(-)
    
    diff --git sources/libavcodec/qsv.c sources/libavcodec/qsv.c
    index 7af154202c..3c99486af7 100644
    static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs)  
    491491}
    492492#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
    493493
     494static int qsv_create_mfx_session_legacy(AVCodecContext *avctx,
     495                                         mfxIMPL implementation,
     496                                         mfxVersion *pver,
     497                                         int gpu_copy,
     498                                         mfxSession *psession)
     499{
     500    mfxInitParam init_par = {MFX_IMPL_AUTO_ANY};
     501    mfxSession session = NULL;
     502    mfxStatus sts;
     503
     504    av_log(avctx, AV_LOG_VERBOSE,
     505           "Use Intel(R) Media SDK to create MFX session, the required "
     506           "implementation version is %d.%d\n",
     507           pver->Major, pver->Minor);
     508
     509    *psession = NULL;
     510
     511    init_par.GPUCopy = gpu_copy;
     512    init_par.Implementation = implementation;
     513    init_par.Version = *pver;
     514    sts = MFXInitEx(init_par, &session);
     515    if (sts < 0)
     516        return ff_qsv_print_error(avctx, sts,
     517                                  "Error initializing a MFX session");
     518    else if (sts > 0)
     519    {
     520        ff_qsv_print_warning(avctx, sts,
     521                             "Warning in MFX initialization");
     522        return AVERROR_UNKNOWN;
     523    }
     524
     525    *psession = session;
     526
     527    return 0;
     528}
     529
    494530#if QSV_ONEVPL
    495531static int qsv_new_mfx_loader(AVCodecContext *avctx,
    496532                              mfxIMPL implementation,
    static int qsv_create_mfx_session(AVCodecContext *avctx,  
    622658        loader = *ploader;
    623659    }
    624660
    625     if (qsv_create_mfx_session_from_loader(avctx, loader, psession))
     661    if (qsv_create_mfx_session_from_loader(avctx, loader, psession) &&
     662        qsv_create_mfx_session_legacy(avctx, implementation, pver, gpu_copy, psession))
    626663        goto fail;
    627664
    628665    if (!*ploader)
    static int qsv_create_mfx_session(AVCodecContext *avctx,  
    646683                                  mfxSession *psession,
    647684                                  void **ploader)
    648685{
    649     mfxInitParam init_par = { MFX_IMPL_AUTO_ANY };
    650     mfxSession session = NULL;
    651     mfxStatus sts;
    652 
    653     av_log(avctx, AV_LOG_VERBOSE,
    654            "Use Intel(R) Media SDK to create MFX session, the required "
    655            "implementation version is %d.%d\n",
    656            pver->Major, pver->Minor);
    657 
    658     *psession = NULL;
    659686    *ploader = NULL;
    660 
    661     init_par.GPUCopy = gpu_copy;
    662     init_par.Implementation = implementation;
    663     init_par.Version = *pver;
    664     sts = MFXInitEx(init_par, &session);
    665     if (sts < 0)
    666         return ff_qsv_print_error(avctx, sts,
    667                                   "Error initializing a MFX session");
    668     else if (sts > 0) {
    669         ff_qsv_print_warning(avctx, sts,
    670                              "Warning in MFX initialization");
    671         return AVERROR_UNKNOWN;
    672     }
    673 
    674     *psession = session;
    675 
    676     return 0;
     687    return qsv_create_mfx_session_legacy(avctx, implementation, pver, gpu_copy, psession);
    677688}
    678689
    679690#endif
  • sources/libavfilter/qsvvpp.c

     libavfilter/qsvvpp.c | 54 ++++++++++++++++++++++++++++++++--------------------
     1 file changed, 33 insertions(+), 21 deletions(-)
    
    diff --git sources/libavfilter/qsvvpp.c sources/libavfilter/qsvvpp.c
    index 54e7284234..b1090f8f08 100644
    int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr  
    936936    return 0;
    937937}
    938938
     939static int ff_qsvvpp_create_mfx_session_legacy(void *ctx,
     940                                               mfxIMPL implementation,
     941                                               mfxVersion *pver,
     942                                               mfxSession *psession)
     943{
     944    mfxSession session = NULL;
     945    mfxStatus sts;
     946
     947    av_log(ctx, AV_LOG_VERBOSE,
     948           "Use Intel(R) Media SDK to create MFX session, API version is "
     949           "%d.%d, the required implementation version is %d.%d\n",
     950           MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
     951
     952    *psession = NULL;
     953    sts = MFXInit(implementation, pver, &session);
     954    if (sts < 0)
     955        return ff_qsvvpp_print_error(ctx, sts,
     956                                     "Error initializing an MFX session");
     957    else if (sts > 0)
     958    {
     959        ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session initialization");
     960        return AVERROR_UNKNOWN;
     961    }
     962
     963    *psession = session;
     964
     965    return 0;
     966}
     967
    939968#if QSV_ONEVPL
    940969
    941970int ff_qsvvpp_create_mfx_session(void *ctx,
    int ff_qsvvpp_create_mfx_session(void *ctx,  
    9791008        impl_idx++;
    9801009    }
    9811010
     1011    if (sts && !ff_qsvvpp_create_mfx_session_legacy(ctx, implementation, pver, psession))
     1012        return 0;
     1013
    9821014    if (sts < 0)
    9831015        return ff_qsvvpp_print_error(ctx, sts,
    9841016                                     "Error creating a MFX session");
    int ff_qsvvpp_create_mfx_session(void *ctx,  
    10011033                                 mfxVersion *pver,
    10021034                                 mfxSession *psession)
    10031035{
    1004     mfxSession session = NULL;
    1005     mfxStatus sts;
    1006 
    1007     av_log(ctx, AV_LOG_VERBOSE,
    1008            "Use Intel(R) Media SDK to create MFX session, API version is "
    1009            "%d.%d, the required implementation version is %d.%d\n",
    1010            MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
    1011 
    1012     *psession = NULL;
    1013     sts = MFXInit(implementation, pver, &session);
    1014     if (sts < 0)
    1015         return ff_qsvvpp_print_error(ctx, sts,
    1016                                      "Error initializing an MFX session");
    1017     else if (sts > 0) {
    1018         ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session initialization");
    1019         return AVERROR_UNKNOWN;
    1020     }
    1021 
    1022     *psession = session;
    1023 
    1024     return 0;
     1036    return ff_qsvvpp_create_mfx_session_legacy(ctx, implementation, pver, psession);
    10251037}
    10261038
    10271039#endif
  • sources/libavutil/hwcontext_qsv.c

     libavutil/hwcontext_qsv.c | 112 +++++++++++++++++++++++++++-------------------
     1 file changed, 65 insertions(+), 47 deletions(-)
    
    diff --git sources/libavutil/hwcontext_qsv.c sources/libavutil/hwcontext_qsv.c
    index 42851d4fd5..8ec1c35e0f 100644
    static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl)  
    661661    return MFX_ERR_NONE;
    662662}
    663663
     664static int qsv_create_mfx_session_legacy(void *ctx,
     665                                         mfxHDL handle,
     666                                         mfxHandleType handle_type,
     667                                         mfxIMPL implementation,
     668                                         mfxVersion *pver,
     669                                         mfxSession *psession)
     670{
     671    mfxVersion ver;
     672    mfxStatus sts;
     673    mfxSession session = NULL;
     674
     675    av_log(ctx, AV_LOG_VERBOSE,
     676           "Use Intel(R) Media SDK to create MFX session, API version is "
     677           "%d.%d, the required implementation version is %d.%d\n",
     678           MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
     679
     680    *psession = NULL;
     681    ver = *pver;
     682    sts = MFXInit(implementation, &ver, &session);
     683    if (sts != MFX_ERR_NONE)
     684    {
     685        av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
     686                                  "%d.\n",
     687               sts);
     688        goto fail;
     689    }
     690
     691    sts = MFXQueryVersion(session, &ver);
     692    if (sts != MFX_ERR_NONE)
     693    {
     694        av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: "
     695                                  "%d.\n",
     696               sts);
     697        goto fail;
     698    }
     699
     700    av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation "
     701                                "version is %d.%d\n",
     702           ver.Major, ver.Minor);
     703
     704    MFXClose(session);
     705
     706    sts = MFXInit(implementation, &ver, &session);
     707    if (sts != MFX_ERR_NONE)
     708    {
     709        av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
     710                                  "%d.\n",
     711               sts);
     712        goto fail;
     713    }
     714
     715    *psession = session;
     716
     717    return 0;
     718
     719fail:
     720    if (session)
     721        MFXClose(session);
     722
     723    return AVERROR_UNKNOWN;
     724}
     725
    664726#if QSV_ONEVPL
    665727
    666728static int qsv_d3d11_update_config(void *ctx, mfxHDL handle, mfxConfig cfg)
    static int qsv_create_mfx_session(void *ctx,  
    10161078    } else
    10171079        loader = *ploader;      // Use the input mfxLoader to create mfx session
    10181080
    1019     if (qsv_create_mfx_session_from_loader(ctx, loader, psession))
     1081    if (qsv_create_mfx_session_from_loader(ctx, loader, psession) &&
     1082        qsv_create_mfx_session_legacy(ctx, handle, handle_type, implementation, pver, psession))
    10201083        goto fail;
    10211084
    10221085    if (!*ploader)
    static int qsv_create_mfx_session(void *ctx,  
    10411104                                  mfxSession *psession,
    10421105                                  void **ploader)
    10431106{
    1044     mfxVersion ver;
    1045     mfxStatus sts;
    1046     mfxSession session = NULL;
    1047 
    1048     av_log(ctx, AV_LOG_VERBOSE,
    1049            "Use Intel(R) Media SDK to create MFX session, API version is "
    1050            "%d.%d, the required implementation version is %d.%d\n",
    1051            MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
    1052 
    10531107    *ploader = NULL;
    1054     *psession = NULL;
    1055     ver = *pver;
    1056     sts = MFXInit(implementation, &ver, &session);
    1057     if (sts != MFX_ERR_NONE) {
    1058         av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
    1059                "%d.\n", sts);
    1060         goto fail;
    1061     }
    1062 
    1063     sts = MFXQueryVersion(session, &ver);
    1064     if (sts != MFX_ERR_NONE) {
    1065         av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: "
    1066                "%d.\n", sts);
    1067         goto fail;
    1068     }
    1069 
    1070     av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation "
    1071            "version is %d.%d\n", ver.Major, ver.Minor);
    1072 
    1073     MFXClose(session);
    1074 
    1075     sts = MFXInit(implementation, &ver, &session);
    1076     if (sts != MFX_ERR_NONE) {
    1077         av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
    1078                "%d.\n", sts);
    1079         goto fail;
    1080     }
    1081 
    1082     *psession = session;
    1083 
    1084     return 0;
    1085 
    1086 fail:
    1087     if (session)
    1088         MFXClose(session);
    1089 
    1090     return AVERROR_UNKNOWN;
     1108    return qsv_create_mfx_session_legacy(ctx, handle, handle_type, implementation, pver, psession);
    10911109}
    10921110
    10931111#endif