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

File onevpl-legacy-fix-6.1.1.patch, 10.7 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 7563625627..6bd37f98b6 100644
    static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs)  
    487487}
    488488#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
    489489
     490static int qsv_create_mfx_session_legacy(AVCodecContext *avctx,
     491                                         mfxIMPL implementation,
     492                                         mfxVersion *pver,
     493                                         int gpu_copy,
     494                                         mfxSession *psession)
     495{
     496    mfxInitParam init_par = {MFX_IMPL_AUTO_ANY};
     497    mfxSession session = NULL;
     498    mfxStatus sts;
     499
     500    av_log(avctx, AV_LOG_VERBOSE,
     501           "Use Intel(R) Media SDK to create MFX session, the required "
     502           "implementation version is %d.%d\n",
     503           pver->Major, pver->Minor);
     504
     505    *psession = NULL;
     506
     507    init_par.GPUCopy = gpu_copy;
     508    init_par.Implementation = implementation;
     509    init_par.Version = *pver;
     510    sts = MFXInitEx(init_par, &session);
     511    if (sts < 0)
     512        return ff_qsv_print_error(avctx, sts,
     513                                  "Error initializing a MFX session");
     514    else if (sts > 0)
     515    {
     516        ff_qsv_print_warning(avctx, sts,
     517                             "Warning in MFX initialization");
     518        return AVERROR_UNKNOWN;
     519    }
     520
     521    *psession = session;
     522
     523    return 0;
     524}
     525
    490526#if QSV_ONEVPL
    491527static int qsv_new_mfx_loader(AVCodecContext *avctx,
    492528                              mfxIMPL implementation,
    … … static int qsv_create_mfx_session(AVCodecContext *avctx,  
    618654        loader = *ploader;
    619655    }
    620656
    621     if (qsv_create_mfx_session_from_loader(avctx, loader, psession))
     657    if (qsv_create_mfx_session_from_loader(avctx, loader, psession) &&
     658        qsv_create_mfx_session_legacy(avctx, implementation, pver, gpu_copy, psession))
    622659        goto fail;
    623660
    624661    if (!*ploader)
    … … static int qsv_create_mfx_session(AVCodecContext *avctx,  
    642679                                  mfxSession *psession,
    643680                                  void **ploader)
    644681{
    645     mfxInitParam init_par = { MFX_IMPL_AUTO_ANY };
    646     mfxSession session = NULL;
    647     mfxStatus sts;
    648 
    649     av_log(avctx, AV_LOG_VERBOSE,
    650            "Use Intel(R) Media SDK to create MFX session, the required "
    651            "implementation version is %d.%d\n",
    652            pver->Major, pver->Minor);
    653 
    654     *psession = NULL;
    655682    *ploader = NULL;
    656 
    657     init_par.GPUCopy = gpu_copy;
    658     init_par.Implementation = implementation;
    659     init_par.Version = *pver;
    660     sts = MFXInitEx(init_par, &session);
    661     if (sts < 0)
    662         return ff_qsv_print_error(avctx, sts,
    663                                   "Error initializing a MFX session");
    664     else if (sts > 0) {
    665         ff_qsv_print_warning(avctx, sts,
    666                              "Warning in MFX initialization");
    667         return AVERROR_UNKNOWN;
    668     }
    669 
    670     *psession = session;
    671 
    672     return 0;
     683    return qsv_create_mfx_session_legacy(avctx, implementation, pver, gpu_copy, psession);
    673684}
    674685
    675686#endif
  • sources/libavfilter/qsvvpp.c

     libavfilter/qsvvpp.c | 55 ++++++++++++++++++++++++++++++++--------------------
     1 file changed, 34 insertions(+), 21 deletions(-)
    
    diff --git sources/libavfilter/qsvvpp.c sources/libavfilter/qsvvpp.c
    index 5cdba7d54a..8fef2b8414 100644
    int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr  
    10531053    return 0;
    10541054}
    10551055
     1056static int ff_qsvvpp_create_mfx_session_legacy(void *ctx,
     1057                                               void *loader,
     1058                                               mfxIMPL implementation,
     1059                                               mfxVersion *pver,
     1060                                               mfxSession *psession)
     1061{
     1062    mfxSession session = NULL;
     1063    mfxStatus sts;
     1064
     1065    av_log(ctx, AV_LOG_VERBOSE,
     1066           "Use Intel(R) Media SDK to create MFX session, API version is "
     1067           "%d.%d, the required implementation version is %d.%d\n",
     1068           MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
     1069
     1070    *psession = NULL;
     1071    sts = MFXInit(implementation, pver, &session);
     1072    if (sts < 0)
     1073        return ff_qsvvpp_print_error(ctx, sts,
     1074                                     "Error initializing an MFX session");
     1075    else if (sts > 0)
     1076    {
     1077        ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session initialization");
     1078        return AVERROR_UNKNOWN;
     1079    }
     1080
     1081    *psession = session;
     1082
     1083    return 0;
     1084}
     1085
    10561086#if QSV_ONEVPL
    10571087
    10581088int ff_qsvvpp_create_mfx_session(void *ctx,
    … … int ff_qsvvpp_create_mfx_session(void *ctx,  
    10961126        impl_idx++;
    10971127    }
    10981128
     1129    if (sts && !ff_qsvvpp_create_mfx_session_legacy(ctx, loader, implementation, pver, psession))
     1130        return 0;
     1131
    10991132    if (sts < 0)
    11001133        return ff_qsvvpp_print_error(ctx, sts,
    11011134                                     "Error creating a MFX session");
    … … int ff_qsvvpp_create_mfx_session(void *ctx,  
    11181151                                 mfxVersion *pver,
    11191152                                 mfxSession *psession)
    11201153{
    1121     mfxSession session = NULL;
    1122     mfxStatus sts;
    1123 
    1124     av_log(ctx, AV_LOG_VERBOSE,
    1125            "Use Intel(R) Media SDK to create MFX session, API version is "
    1126            "%d.%d, the required implementation version is %d.%d\n",
    1127            MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
    1128 
    1129     *psession = NULL;
    1130     sts = MFXInit(implementation, pver, &session);
    1131     if (sts < 0)
    1132         return ff_qsvvpp_print_error(ctx, sts,
    1133                                      "Error initializing an MFX session");
    1134     else if (sts > 0) {
    1135         ff_qsvvpp_print_warning(ctx, sts, "Warning in MFX session initialization");
    1136         return AVERROR_UNKNOWN;
    1137     }
    1138 
    1139     *psession = session;
    1140 
    1141     return 0;
     1154    return ff_qsvvpp_create_mfx_session_legacy(ctx, loader, implementation, pver, psession);
    11421155}
    11431156
    11441157#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 1bfda9e69b..ff71690d9d 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,  
    10281090    } else
    10291091        loader = *ploader;      // Use the input mfxLoader to create mfx session
    10301092
    1031     if (qsv_create_mfx_session_from_loader(ctx, loader, psession))
     1093    if (qsv_create_mfx_session_from_loader(ctx, loader, psession) &&
     1094        qsv_create_mfx_session_legacy(ctx, handle, handle_type, implementation, pver, psession))
    10321095        goto fail;
    10331096
    10341097    if (!*ploader)
    … … static int qsv_create_mfx_session(void *ctx,  
    10531116                                  mfxSession *psession,
    10541117                                  void **ploader)
    10551118{
    1056     mfxVersion ver;
    1057     mfxStatus sts;
    1058     mfxSession session = NULL;
    1059 
    1060     av_log(ctx, AV_LOG_VERBOSE,
    1061            "Use Intel(R) Media SDK to create MFX session, API version is "
    1062            "%d.%d, the required implementation version is %d.%d\n",
    1063            MFX_VERSION_MAJOR, MFX_VERSION_MINOR, pver->Major, pver->Minor);
    1064 
    10651119    *ploader = NULL;
    1066     *psession = NULL;
    1067     ver = *pver;
    1068     sts = MFXInit(implementation, &ver, &session);
    1069     if (sts != MFX_ERR_NONE) {
    1070         av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
    1071                "%d.\n", sts);
    1072         goto fail;
    1073     }
    1074 
    1075     sts = MFXQueryVersion(session, &ver);
    1076     if (sts != MFX_ERR_NONE) {
    1077         av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: "
    1078                "%d.\n", sts);
    1079         goto fail;
    1080     }
    1081 
    1082     av_log(ctx, AV_LOG_VERBOSE, "Initialize MFX session: implementation "
    1083            "version is %d.%d\n", ver.Major, ver.Minor);
    1084 
    1085     MFXClose(session);
    1086 
    1087     sts = MFXInit(implementation, &ver, &session);
    1088     if (sts != MFX_ERR_NONE) {
    1089         av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
    1090                "%d.\n", sts);
    1091         goto fail;
    1092     }
    1093 
    1094     *psession = session;
    1095 
    1096     return 0;
    1097 
    1098 fail:
    1099     if (session)
    1100         MFXClose(session);
    1101 
    1102     return AVERROR_UNKNOWN;
     1120    return qsv_create_mfx_session_legacy(ctx, handle, handle_type, implementation, pver, psession);
    11031121}
    11041122
    11051123#endif