summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodeo <[email protected]>2013-09-01 08:56:50 +0000
committerRodeo <[email protected]>2013-09-01 08:56:50 +0000
commit8270fcfeb84a2c6c051a24fcceea534b939eee58 (patch)
tree92b54f9247185704ccae7a92177412aa8a5fdeeb
parent4220853ed08a7dd6fb35421a422ff2e7c4bed2b7 (diff)
QSV: choose and re-use a "preferred" implementation instead of using MFX_IMPL_AUTO_ANY.
This fixes a rare issue where hardware support was detected as available and used in encqsvInit, but MFXInit silently fell back to software in qsv_enc_init (still don't know what that's all about though). git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5759 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/decavcodec.c2
-rw-r--r--libhb/enc_qsv.c43
-rw-r--r--libhb/qsv_common.c42
-rw-r--r--libhb/qsv_common.h3
4 files changed, 65 insertions, 25 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 4c1972fdf..d82dbd049 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -1187,8 +1187,8 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
if (hb_qsv_decode_is_enabled(job))
{
// setup the QSV configuration
- pv->qsv_config.impl_requested = MFX_IMPL_AUTO_ANY|MFX_IMPL_VIA_ANY;
pv->qsv_config.io_pattern = MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
+ pv->qsv_config.impl_requested = hb_qsv_impl_get_preferred();
pv->qsv_config.async_depth = job->qsv_async_depth;
pv->qsv_config.sync_need = 0;
pv->qsv_config.usage_threaded = 1;
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c
index e38a4b510..7ec9a8612 100644
--- a/libhb/enc_qsv.c
+++ b/libhb/enc_qsv.c
@@ -183,9 +183,9 @@ int qsv_enc_init(av_qsv_context *qsv, hb_work_private_t *pv)
av_qsv_add_context_usage(qsv, 0);
// initialize the session
- qsv->impl = MFX_IMPL_AUTO_ANY;
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)
{
@@ -332,6 +332,20 @@ int qsv_enc_init(av_qsv_context *qsv, hb_work_private_t *pv)
}
qsv_encode->is_init_done = 1;
+ mfxIMPL impl;
+ mfxVersion version;
+ // log actual implementation details now that we know them
+ if ((MFXQueryIMPL (qsv->mfx_session, &impl) == MFX_ERR_NONE) &&
+ (MFXQueryVersion(qsv->mfx_session, &version) == MFX_ERR_NONE))
+ {
+ hb_log("qsv_enc_init: using '%s' implementation, API: %"PRIu16".%"PRIu16"",
+ hb_qsv_impl_get_name(impl), version.Major, version.Minor);
+ }
+ else
+ {
+ hb_log("qsv_enc_init: MFXQueryIMPL/MFXQueryVersion failure");
+ }
+
pv->init_done = 1;
return 0;
}
@@ -708,7 +722,6 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
* this is fine since the actual encode will use the same
* values for all parameters relevant to the H.264 bitstream
*/
- mfxIMPL impl;
mfxStatus err;
mfxVersion version;
mfxVideoParam videoParam;
@@ -717,10 +730,9 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
mfxExtCodingOption option1_buf, *option1 = &option1_buf;
mfxExtCodingOption2 option2_buf, *option2 = &option2_buf;
mfxExtCodingOptionSPSPPS sps_pps_buf, *sps_pps = &sps_pps_buf;
- impl = MFX_IMPL_AUTO_ANY|MFX_IMPL_VIA_ANY;
version.Major = HB_QSV_MINVERSION_MAJOR;
version.Minor = HB_QSV_MINVERSION_MINOR;
- err = MFXInit(impl, &version, &session);
+ err = MFXInit(hb_qsv_impl_get_preferred(), &version, &session);
if (err != MFX_ERR_NONE)
{
hb_error("encqsvInit: MFXInit failed (%d)", err);
@@ -762,6 +774,8 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
videoParam.ExtParam[videoParam.NumExtParam++] = (mfxExtBuffer*)option2;
}
err = MFXVideoENCODE_GetVideoParam(session, &videoParam);
+ MFXVideoENCODE_Close(session);
+ MFXClose(session);
if (err == MFX_ERR_NONE)
{
// remove 32-bit NAL prefix (0x00 0x00 0x00 0x01)
@@ -775,27 +789,12 @@ int encqsvInit(hb_work_object_t *w, hb_job_t *job)
else
{
hb_error("encqsvInit: MFXVideoENCODE_GetVideoParam failed (%d)", err);
- MFXVideoENCODE_Close(session);
- MFXClose (session);
return -1;
}
- // log implementation details before closing this session
- if (pv->is_sys_mem)
- {
- hb_log("encqsvInit: using encode-only path");
- }
- if ((MFXQueryIMPL (session, &impl) == MFX_ERR_NONE) &&
- (MFXQueryVersion(session, &version) == MFX_ERR_NONE))
- {
- hb_log("encqsvInit: using %s implementation (%"PRIu16".%"PRIu16")",
- impl == MFX_IMPL_SOFTWARE ? "software" : "hardware",
- version.Major, version.Minor);
- }
- MFXVideoENCODE_Close(session);
- MFXClose (session);
-
- // log main output settings
+ // log code path and main output settings
+ hb_log("encqsvInit: using %s path",
+ pv->is_sys_mem ? "encode-only" : "full QSV");
hb_log("encqsvInit: TargetUsage %"PRIu16" AsyncDepth %"PRIu16"",
videoParam.mfx.TargetUsage, videoParam.AsyncDepth);
hb_log("encqsvInit: GopRefDist %"PRIu16" GopPicSize %"PRIu16" NumRefFrame %"PRIu16"",
diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c
index 99c1536e2..9d06ce3ec 100644
--- a/libhb/qsv_common.c
+++ b/libhb/qsv_common.c
@@ -25,6 +25,7 @@ extern void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx);
hb_qsv_info_t *hb_qsv_info = NULL;
// availability and versions
+static mfxIMPL preferred_implementation;
static mfxVersion qsv_hardware_version;
static mfxVersion qsv_software_version;
static mfxVersion qsv_minimum_version;
@@ -63,7 +64,8 @@ int hb_qsv_info_init()
if (MFXInit(MFX_IMPL_SOFTWARE,
&qsv_minimum_version, &session) == MFX_ERR_NONE)
{
- qsv_software_available = 1;
+ qsv_software_available = 1;
+ preferred_implementation = MFX_IMPL_SOFTWARE;
// our minimum is supported, but query the actual version
MFXQueryVersion(session, &qsv_software_version);
MFXClose(session);
@@ -73,7 +75,8 @@ int hb_qsv_info_init()
if (MFXInit(MFX_IMPL_HARDWARE_ANY|MFX_IMPL_VIA_ANY,
&qsv_minimum_version, &session) == MFX_ERR_NONE)
{
- qsv_hardware_available = 1;
+ qsv_hardware_available = 1;
+ preferred_implementation = MFX_IMPL_HARDWARE_ANY|MFX_IMPL_VIA_ANY;
// our minimum is supported, but query the actual version
MFXQueryVersion(session, &qsv_hardware_version);
MFXClose(session);
@@ -154,6 +157,8 @@ void hb_qsv_info_print()
qsv_minimum_version.Major,
qsv_minimum_version.Minor);
}
+ hb_log(" - Preferred implementation: %s",
+ hb_qsv_impl_get_name(preferred_implementation));
}
}
@@ -780,3 +785,36 @@ int hb_qsv_param_default(hb_qsv_param_t *param, mfxVideoParam *videoParam)
}
return 0;
}
+
+mfxIMPL hb_qsv_impl_get_preferred()
+{
+ return preferred_implementation;
+}
+
+const char* hb_qsv_impl_get_name(int impl)
+{
+ switch (MFX_IMPL_BASETYPE(impl))
+ {
+ case MFX_IMPL_SOFTWARE:
+ return "software";
+
+ case MFX_IMPL_HARDWARE:
+ return "hardware (1)";
+ case MFX_IMPL_HARDWARE2:
+ return "hardware (2)";
+ case MFX_IMPL_HARDWARE3:
+ return "hardware (3)";
+ case MFX_IMPL_HARDWARE4:
+ return "hardware (4)";
+ case MFX_IMPL_HARDWARE_ANY:
+ return "hardware (any)";
+
+ case MFX_IMPL_AUTO:
+ return "automatic";
+ case MFX_IMPL_AUTO_ANY:
+ return "automatic (any)";
+
+ default:
+ return NULL;
+ }
+}
diff --git a/libhb/qsv_common.h b/libhb/qsv_common.h
index cd85d33a2..9e9b58f30 100644
--- a/libhb/qsv_common.h
+++ b/libhb/qsv_common.h
@@ -116,4 +116,7 @@ float hb_qsv_atof (const char *str, int *err);
int hb_qsv_param_default(hb_qsv_param_t *param, mfxVideoParam *videoParam);
int hb_qsv_param_parse (hb_qsv_param_t *param, const char *key, const char *value, int vcodec);
+mfxIMPL hb_qsv_impl_get_preferred();
+const char* hb_qsv_impl_get_name(int impl);
+
#endif