Skip to content

Commit

Permalink
qsv: fix incorrect hw implementation on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
galinart authored and sr55 committed May 1, 2021
1 parent 9b07759 commit bae2225
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libhb/handbrake/qsv_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ uint8_t hb_qsv_frametype_xlat(uint16_t qsv_frametype, uint16_t *out_flags);

const char* hb_qsv_impl_get_name(int impl);
const char* hb_qsv_impl_get_via_name(int impl);
mfxIMPL hb_qsv_dx_index_to_impl(int dx_index);

/* Full QSV pipeline helpers */
int hb_qsv_is_enabled(hb_job_t *job);
Expand All @@ -252,7 +253,6 @@ enum AVPixelFormat hb_qsv_get_format(AVCodecContext *s, const enum AVPixelFormat
int hb_qsv_preset_is_zero_copy_enabled(const hb_dict_t *job_dict);
void hb_qsv_uninit_dec(AVCodecContext *s);
void hb_qsv_uninit_enc(hb_job_t *job);
mfxIMPL hb_qsv_dx_index_to_impl(int dx_index);
int hb_qsv_parse_adapter_index(hb_job_t *job);
int hb_qsv_setup_job(hb_job_t *job);
int hb_qsv_decode_h264_is_supported(int adapter_index);
Expand Down
13 changes: 9 additions & 4 deletions libhb/qsv_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ hb_display_t * hb_qsv_display_init(void)
static int hb_qsv_query_adapters(mfxAdaptersInfo* adapters_info);
static int hb_qsv_make_adapters_list(const mfxAdaptersInfo* adapters_info, hb_list_t **qsv_adapters_list);
static int hb_qsv_make_adapters_details_list(const mfxAdaptersInfo* adapters_info, hb_list_t **hb_qsv_adapter_details_list);
#endif

mfxIMPL hb_qsv_dx_index_to_impl(int dx_index)
{
Expand Down Expand Up @@ -856,6 +855,7 @@ mfxIMPL hb_qsv_dx_index_to_impl(int dx_index)
}
return impl;
}
#endif

static int hb_qsv_collect_adapters_details(hb_list_t *qsv_adapters_list, hb_list_t *hb_qsv_adapter_details_list)
{
Expand Down Expand Up @@ -897,7 +897,12 @@ static int hb_qsv_collect_adapters_details(hb_list_t *qsv_adapters_list, hb_list
}
// check for actual hardware support
do{
if (MFXInit(hb_qsv_dx_index_to_impl(*dx_index) | hw_preference, &version, &session) == MFX_ERR_NONE)
#if defined(_WIN32) || defined(__MINGW32__)
mfxIMPL hw_impl = hb_qsv_dx_index_to_impl(details->index);
#else
mfxIMPL hw_impl = MFX_IMPL_HARDWARE_ANY;
#endif
if (MFXInit(hw_impl | hw_preference, &version, &session) == MFX_ERR_NONE)
{
// On linux, the handle to the VA display must be set.
// This code is essentiall a NOP other platforms.
Expand All @@ -918,9 +923,9 @@ static int hb_qsv_collect_adapters_details(hb_list_t *qsv_adapters_list, hb_list
HB_QSV_MINVERSION_MINOR))
{
query_capabilities(session, details->index, details->qsv_hardware_version, &details->qsv_hardware_info_avc);
details->qsv_hardware_info_avc.implementation = hb_qsv_dx_index_to_impl(*dx_index) | hw_preference;
details->qsv_hardware_info_avc.implementation = hw_impl | hw_preference;
query_capabilities(session, details->index, details->qsv_hardware_version, &details->qsv_hardware_info_hevc);
details->qsv_hardware_info_hevc.implementation = hb_qsv_dx_index_to_impl(*dx_index) | hw_preference;
details->qsv_hardware_info_hevc.implementation = hw_impl | hw_preference;
// now that we know which hardware encoders are
// available, we can set the preferred implementation
qsv_impl_set_preferred(details, "hardware");
Expand Down

0 comments on commit bae2225

Please sign in to comment.