diff options
author | Rodeo <[email protected]> | 2013-09-24 11:48:25 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2013-09-24 11:48:25 +0000 |
commit | 102c5428b559d967ea6531e9202b5931401679bd (patch) | |
tree | e46dca14718daa03a931bde313afcac22e21c2f3 | |
parent | c0d3a073e6309939a82b58d9aa693084b088644c (diff) |
QSV: re-use the encqsvInit MFX session when using the encode-only path.
This seems to work around a weird and obscure issue on some systems.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5801 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/enc_qsv.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c index b212b05f9..57a5063ff 100644 --- a/libhb/enc_qsv.c +++ b/libhb/enc_qsv.c @@ -74,6 +74,7 @@ struct hb_work_private_s // if encode-only, system memory used int is_sys_mem; + mfxSession mfx_session; struct SwsContext *sws_context_to_nv12; // whether to expect input from VPP or from QSV decode @@ -179,20 +180,10 @@ int qsv_enc_init(av_qsv_context *qsv, hb_work_private_t *pv) if (pv->is_sys_mem) { // no need to use additional sync as encode only -> single thread - // XXX: this zeroes the session handle, so call it before MFXInit av_qsv_add_context_usage(qsv, 0); - // initialize the session - qsv->ver.Major = AV_QSV_MSDK_VERSION_MAJOR; - qsv->ver.Minor = AV_QSV_MSDK_VERSION_MINOR; - qsv->impl = hb_qsv_impl_get_preferred(); - sts = MFXInit(qsv->impl, &qsv->ver, &qsv->mfx_session); - if (sts != MFX_ERR_NONE) - { - hb_error("qsv_enc_init: MFXInit failed (%d)", sts); - *job->die = 1; - return -1; - } + // re-use the session from encqsvInit + qsv->mfx_session = pv->mfx_session; } qsv->enc_space = qsv_encode = &pv->enc_space; } @@ -864,7 +855,6 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) } err = MFXVideoENCODE_GetVideoParam(session, &videoParam); MFXVideoENCODE_Close(session); - MFXClose(session); if (err == MFX_ERR_NONE) { // remove 32-bit NAL prefix (0x00 0x00 0x00 0x01) @@ -878,9 +868,20 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job) else { hb_error("encqsvInit: MFXVideoENCODE_GetVideoParam failed (%d)", err); + MFXClose(session); return -1; } + // when using system memory, we re-use this same session + if (pv->is_sys_mem) + { + pv->mfx_session = session; + } + else + { + MFXClose(session); + } + // check whether B-frames are used switch (videoParam.mfx.CodecProfile) { |