summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/enc_qsv.c4
-rw-r--r--libhb/qsv_common.c76
-rw-r--r--libhb/qsv_common.h3
3 files changed, 60 insertions, 23 deletions
diff --git a/libhb/enc_qsv.c b/libhb/enc_qsv.c
index 11a3dace9..6e44bf740 100644
--- a/libhb/enc_qsv.c
+++ b/libhb/enc_qsv.c
@@ -668,8 +668,8 @@ int qsv_enc_init(hb_work_private_t *pv)
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);
+ hb_log("qsv_enc_init: using '%s %s' implementation, API: %"PRIu16".%"PRIu16"",
+ hb_qsv_impl_get_name(impl), hb_qsv_impl_get_via_name(impl), version.Major, version.Minor);
}
else
{
diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c
index 9cd54fb0b..cc95e6a2d 100644
--- a/libhb/qsv_common.c
+++ b/libhb/qsv_common.c
@@ -644,6 +644,11 @@ int hb_qsv_info_init()
*/
mfxSession session;
mfxVersion version = { .Major = 1, .Minor = 0, };
+#ifdef SYS_LINUX
+ mfxIMPL hw_preference = MFX_IMPL_VIA_ANY;
+#else
+ mfxIMPL hw_preference = MFX_IMPL_VIA_D3D11;
+#endif
// check for software fallback
if (MFXInit(MFX_IMPL_SOFTWARE, &version, &session) == MFX_ERR_NONE)
@@ -664,25 +669,41 @@ int hb_qsv_info_init()
}
// check for actual hardware support
- if (MFXInit(MFX_IMPL_HARDWARE_ANY, &version, &session) == MFX_ERR_NONE)
- {
- // Media SDK hardware found, but check that our minimum is supported
- //
- // Note: this-party hardware (QSV_G0) is unsupported for the time being
- MFXQueryVersion(session, &qsv_hardware_version);
- if (qsv_hardware_generation(hb_get_cpu_platform()) >= QSV_G1 &&
- HB_CHECK_MFX_VERSION(qsv_hardware_version,
- HB_QSV_MINVERSION_MAJOR,
- HB_QSV_MINVERSION_MINOR))
+ do{
+ if (MFXInit(MFX_IMPL_HARDWARE_ANY | hw_preference, &version, &session) == MFX_ERR_NONE)
+ {
+ // Media SDK hardware found, but check that our minimum is supported
+ //
+ // Note: this-party hardware (QSV_G0) is unsupported for the time being
+ MFXQueryVersion(session, &qsv_hardware_version);
+ if (qsv_hardware_generation(hb_get_cpu_platform()) >= QSV_G1 &&
+ HB_CHECK_MFX_VERSION(qsv_hardware_version,
+ HB_QSV_MINVERSION_MAJOR,
+ HB_QSV_MINVERSION_MINOR))
+ {
+ query_capabilities(session, qsv_hardware_version, &qsv_hardware_info_avc);
+ qsv_hardware_info_avc.implementation = MFX_IMPL_HARDWARE_ANY | hw_preference;
+ query_capabilities(session, qsv_hardware_version, &qsv_hardware_info_hevc);
+ qsv_hardware_info_hevc.implementation = MFX_IMPL_HARDWARE_ANY | hw_preference;
+ // now that we know which hardware encoders are
+ // available, we can set the preferred implementation
+ hb_qsv_impl_set_preferred("hardware");
+ }
+ MFXClose(session);
+ hw_preference = 0;
+ }
+ else
{
- query_capabilities(session, qsv_hardware_version, &qsv_hardware_info_avc);
- query_capabilities(session, qsv_hardware_version, &qsv_hardware_info_hevc);
- // now that we know which hardware encoders are
- // available, we can set the preferred implementation
- hb_qsv_impl_set_preferred("hardware");
+#ifndef SYS_LINUX
+ // Windows only: After D3D11 we will try D3D9
+ if (hw_preference == MFX_IMPL_VIA_D3D11)
+ hw_preference = MFX_IMPL_VIA_D3D9;
+ else
+#endif
+ hw_preference = 0;
}
- MFXClose(session);
}
+ while(hw_preference != 0);
// success
return 0;
@@ -796,8 +817,9 @@ void hb_qsv_info_print()
if (hb_qsv_info_avc != NULL && hb_qsv_info_avc->available)
{
hb_log(" - H.264 encoder: yes");
- hb_log(" - preferred implementation: %s",
- hb_qsv_impl_get_name(hb_qsv_info_avc->implementation));
+ hb_log(" - preferred implementation: %s %s",
+ hb_qsv_impl_get_name(hb_qsv_info_avc->implementation),
+ hb_qsv_impl_get_via_name(hb_qsv_info_avc->implementation));
if (qsv_hardware_info_avc.available)
{
log_capabilities(1, qsv_hardware_info_avc.capabilities,
@@ -816,8 +838,9 @@ void hb_qsv_info_print()
if (hb_qsv_info_hevc != NULL && hb_qsv_info_hevc->available)
{
hb_log(" - H.265 encoder: yes (8bit: yes, 10bit: %s)", (qsv_hardware_generation(hb_get_cpu_platform()) < QSV_G6) ? "no" : "yes" );
- hb_log(" - preferred implementation: %s",
- hb_qsv_impl_get_name(hb_qsv_info_hevc->implementation));
+ hb_log(" - preferred implementation: %s %s",
+ hb_qsv_impl_get_name(hb_qsv_info_hevc->implementation),
+ hb_qsv_impl_get_via_name(hb_qsv_info_hevc->implementation));
if (qsv_hardware_info_hevc.available)
{
log_capabilities(1, qsv_hardware_info_hevc.capabilities,
@@ -2159,6 +2182,19 @@ const char* hb_qsv_impl_get_name(int impl)
}
}
+const char* hb_qsv_impl_get_via_name(int impl)
+{
+ if (impl & MFX_IMPL_VIA_VAAPI)
+ return "via VAAPI";
+ else if (impl & MFX_IMPL_VIA_D3D11)
+ return "via D3D11";
+ else if (impl & MFX_IMPL_VIA_D3D9)
+ return "via D3D9";
+ else if (impl & MFX_IMPL_VIA_ANY)
+ return "via ANY";
+ else return NULL;
+}
+
void hb_qsv_force_workarounds()
{
#define FORCE_WORKAROUNDS ~(HB_QSV_CAP_OPTION2_BREFTYPE)
diff --git a/libhb/qsv_common.h b/libhb/qsv_common.h
index d59cdfd3c..e5964ca9d 100644
--- a/libhb/qsv_common.h
+++ b/libhb/qsv_common.h
@@ -35,7 +35,7 @@ typedef struct hb_qsv_info_s
{
// each info struct only corresponds to one CodecId and implementation combo
const mfxU32 codec_id;
- const mfxIMPL implementation;
+ mfxIMPL implementation;
// whether the encoder is available for this implementation
int available;
@@ -188,6 +188,7 @@ uint8_t hb_qsv_frametype_xlat(uint16_t qsv_frametype, uint16_t *out_flags);
int hb_qsv_impl_set_preferred(const char *name);
const char* hb_qsv_impl_get_name(int impl);
+const char* hb_qsv_impl_get_via_name(int impl);
void hb_qsv_force_workarounds(); // for developers only