summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-02-09 18:12:44 +0000
committerScott <[email protected]>2019-02-11 14:02:17 +0000
commit30ae1c01c231ac07e798be2b1c0ccb8d5069f968 (patch)
treee507328c535f1c49e65398af7f6b55fd81a14ede
parent1728150b7e088eccc89f03ad03f9ea9dcb26cade (diff)
libhb: Add a hb_global_init_no_hardware that disables all the hardware encoder/decode init and check code. For users where drivers or other system issues prevent HandBrake from loading.
-rw-r--r--libhb/common.c66
-rw-r--r--libhb/common.h2
-rw-r--r--libhb/hb.c38
-rw-r--r--libhb/hb.h3
-rw-r--r--libhb/nvenc_common.c6
-rw-r--r--libhb/qsv_common.c5
-rw-r--r--libhb/vce_common.c10
7 files changed, 91 insertions, 39 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 4e96f72e9..26e7ff02a 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -270,44 +270,52 @@ hb_encoder_internal_t hb_video_encoders[] =
{ { "Theora", "theora", "Theora (libtheora)", HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_THEORA, },
};
int hb_video_encoders_count = sizeof(hb_video_encoders) / sizeof(hb_video_encoders[0]);
-static int hb_video_encoder_is_enabled(int encoder)
+static int hb_video_encoder_is_enabled(int encoder, int disable_hardware)
{
-#ifdef USE_QSV
- if (encoder & HB_VCODEC_QSV_MASK)
+ // Hardware Encoders
+ if (!disable_hardware)
{
- return hb_qsv_video_encoder_is_enabled(encoder);
- }
+#ifdef USE_QSV
+ if (encoder & HB_VCODEC_QSV_MASK)
+ {
+ return hb_qsv_video_encoder_is_enabled(encoder);
+ }
#endif
- switch (encoder)
- {
- // the following encoders are always enabled
- case HB_VCODEC_THEORA:
- case HB_VCODEC_FFMPEG_MPEG4:
- case HB_VCODEC_FFMPEG_MPEG2:
- case HB_VCODEC_FFMPEG_VP8:
- case HB_VCODEC_FFMPEG_VP9:
- return 1;
+ switch (encoder){
#ifdef USE_VCE
- case HB_VCODEC_FFMPEG_VCE_H264:
- return hb_vce_h264_available();
- case HB_VCODEC_FFMPEG_VCE_H265:
- return hb_vce_h265_available();
+ case HB_VCODEC_FFMPEG_VCE_H264:
+ return hb_vce_h264_available();
+ case HB_VCODEC_FFMPEG_VCE_H265:
+ return hb_vce_h265_available();
#endif
#ifdef USE_NVENC
- case HB_VCODEC_FFMPEG_NVENC_H264:
- return hb_nvenc_h264_available();
- case HB_VCODEC_FFMPEG_NVENC_H265:
- return hb_nvenc_h265_available();
+ case HB_VCODEC_FFMPEG_NVENC_H264:
+ return hb_nvenc_h264_available();
+ case HB_VCODEC_FFMPEG_NVENC_H265:
+ return hb_nvenc_h265_available();
#endif
#ifdef __APPLE__
- case HB_VCODEC_FFMPEG_VT_H264:
- return hb_vt_h264_is_available();
- case HB_VCODEC_FFMPEG_VT_H265:
- return hb_vt_h265_is_available();
+ case HB_VCODEC_FFMPEG_VT_H264:
+ return hb_vt_h264_is_available();
+ case HB_VCODEC_FFMPEG_VT_H265:
+ return hb_vt_h265_is_available();
#endif
+ }
+ }
+
+ // Software Encoders
+ switch (encoder)
+ {
+ // the following encoders are always enabled
+ case HB_VCODEC_THEORA:
+ case HB_VCODEC_FFMPEG_MPEG4:
+ case HB_VCODEC_FFMPEG_MPEG2:
+ case HB_VCODEC_FFMPEG_VP8:
+ case HB_VCODEC_FFMPEG_VP9:
+ return 1;
#ifdef USE_X265
case HB_VCODEC_X265_8BIT:
@@ -458,7 +466,7 @@ static int hb_container_is_enabled(int format)
}
}
-void hb_common_global_init()
+void hb_common_global_init(int disable_hardware)
{
static int common_init_done = 0;
if (common_init_done)
@@ -568,7 +576,7 @@ void hb_common_global_init()
{
// we still need to check
hb_video_encoders[i].enabled =
- hb_video_encoder_is_enabled(hb_video_encoders[i].item.codec);
+ hb_video_encoder_is_enabled(hb_video_encoders[i].item.codec, disable_hardware);
}
if (hb_video_encoders[i].enabled)
{
@@ -590,7 +598,7 @@ void hb_common_global_init()
if (!hb_video_encoders[i].enabled)
{
if ((hb_video_encoders[i].item.codec & HB_VCODEC_MASK) &&
- (hb_video_encoder_is_enabled(hb_video_encoders[i].item.codec)))
+ (hb_video_encoder_is_enabled(hb_video_encoders[i].item.codec, disable_hardware)))
{
// we have a specific fallback and it's enabled
continue;
diff --git a/libhb/common.h b/libhb/common.h
index 550c021cd..0e1da8794 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -334,7 +334,7 @@ struct hb_subtitle_config_s
*
*/
-void hb_common_global_init(void);
+void hb_common_global_init(int);
int hb_video_framerate_get_from_name(const char *name);
const char* hb_video_framerate_get_name(int framerate);
diff --git a/libhb/hb.c b/libhb/hb.c
index c8c4b1c5a..f91800497 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -68,6 +68,7 @@ struct hb_handle_s
hb_work_object_t * hb_objects = NULL;
int hb_instance_counter = 0;
+int disable_hardware = 0;
static void thread_func( void * );
@@ -414,8 +415,11 @@ void hb_scan( hb_handle_t * h, const char * path, int title_index,
hb_log(" - logical processor count: %d", hb_get_cpu_count());
#ifdef USE_QSV
- /* Print QSV info here so that it's in all scan and encode logs */
- hb_qsv_info_print();
+ if (!is_hardware_disabled())
+ {
+ /* Print QSV info here so that it's in all scan and encode logs */
+ hb_qsv_info_print();
+ }
#endif
hb_log( "hb_scan: path=%s, title_index=%d", path, title_index );
@@ -1638,6 +1642,12 @@ void hb_close( hb_handle_t ** _h )
*_h = NULL;
}
+int hb_global_init_no_hardware()
+{
+ disable_hardware = 1;
+ hb_global_init();
+}
+
int hb_global_init()
{
int result = 0;
@@ -1650,13 +1660,16 @@ int hb_global_init()
}
#ifdef USE_QSV
- result = hb_qsv_info_init();
- if (result < 0)
+ if (!disable_hardware)
{
- hb_error("hb_qsv_info_init failed!");
- return -1;
+ result = hb_qsv_info_init();
+ if (result < 0)
+ {
+ hb_error("hb_qsv_info_init failed!");
+ return -1;
+ }
+ hb_param_configure_qsv();
}
- hb_param_configure_qsv();
#endif
/* libavcodec */
@@ -1692,11 +1705,14 @@ int hb_global_init()
hb_register(&hb_encx265);
#endif
#ifdef USE_QSV
- hb_register(&hb_encqsv);
+ if (!disable_hardware)
+ {
+ hb_register(&hb_encqsv);
+ }
#endif
hb_x264_global_init();
- hb_common_global_init();
+ hb_common_global_init(disable_hardware);
/*
* Initialise buffer pool
@@ -1910,3 +1926,7 @@ hb_interjob_t * hb_interjob_get( hb_handle_t * h )
{
return h->interjob;
}
+
+int is_hardware_disabled(void){
+ return disable_hardware;
+}
diff --git a/libhb/hb.h b/libhb/hb.h
index aa9a039a6..c003c2a9c 100644
--- a/libhb/hb.h
+++ b/libhb/hb.h
@@ -134,6 +134,7 @@ void hb_close( hb_handle_t ** );
/* hb_global_init()
Performs process initialization. */
int hb_global_init(void);
+int hb_global_init_no_hardware();
/* hb_global_close()
Performs final cleanup for the process. */
void hb_global_close(void);
@@ -142,6 +143,8 @@ void hb_global_close(void);
Return the unique instance id of an libhb instance created by hb_init. */
int hb_get_instance_id( hb_handle_t * h );
+int is_hardware_disabled(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/libhb/nvenc_common.c b/libhb/nvenc_common.c
index 2c9822bb1..f731e7928 100644
--- a/libhb/nvenc_common.c
+++ b/libhb/nvenc_common.c
@@ -8,6 +8,7 @@
*/
#include "hbffmpeg.h"
+#include "hb.h"
#ifdef USE_NVENC
#include <ffnvcodec/nvEncodeAPI.h>
@@ -34,6 +35,11 @@ int hb_nvenc_h265_available()
int hb_check_nvenc_available()
{
+ if (is_hardware_disabled())
+ {
+ return 0;
+ }
+
#ifdef USE_NVENC
uint32_t nvenc_ver;
void *context;
diff --git a/libhb/qsv_common.c b/libhb/qsv_common.c
index 64c99ba0a..7376be4b9 100644
--- a/libhb/qsv_common.c
+++ b/libhb/qsv_common.c
@@ -147,6 +147,11 @@ static int qsv_implementation_is_hardware(mfxIMPL implementation)
int hb_qsv_available()
{
+ if (is_hardware_disabled())
+ {
+ return 0;
+ }
+
return ((hb_qsv_video_encoder_is_enabled(HB_VCODEC_QSV_H264) ? HB_VCODEC_QSV_H264 : 0) |
(hb_qsv_video_encoder_is_enabled(HB_VCODEC_QSV_H265) ? HB_VCODEC_QSV_H265 : 0) |
(hb_qsv_video_encoder_is_enabled(HB_VCODEC_QSV_H265_10BIT) ? HB_VCODEC_QSV_H265_10BIT : 0));
diff --git a/libhb/vce_common.c b/libhb/vce_common.c
index e5293705b..ab545eab0 100644
--- a/libhb/vce_common.c
+++ b/libhb/vce_common.c
@@ -98,11 +98,21 @@ clean:
int hb_vce_h264_available()
{
+ if (is_hardware_disabled())
+ {
+ return 0;
+ }
+
return (check_component_available(AMFVideoEncoderVCE_AVC) == AMF_OK) ? 1 : 0;
}
int hb_vce_h265_available()
{
+ if (is_hardware_disabled())
+ {
+ return 0;
+ }
+
return (check_component_available(AMFVideoEncoder_HEVC) == AMF_OK) ? 1 : 0;
}