summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2021-01-04 18:18:14 +0100
committerDamiano Galassi <[email protected]>2021-01-04 18:18:14 +0100
commit36f66956c3a391feec1b13cbf01f6e5c87b9bf94 (patch)
treec7495994e56de88741df1ceacf3210e8c7f82837
parente4d444553b85fa1d72addfa5b274ed7782f0b77b (diff)
libhb: properly set the 'PresetDisabled' presets property.
-rw-r--r--libhb/common.c85
-rw-r--r--libhb/handbrake/common.h1
-rw-r--r--libhb/preset.c67
3 files changed, 53 insertions, 100 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 076c3dbc4..f61a99936 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -245,6 +245,7 @@ typedef struct
{
hb_encoder_t item;
hb_encoder_t *next;
+ int deprecated;
int enabled;
int gid;
} hb_encoder_internal_t;
@@ -253,31 +254,31 @@ hb_encoder_t *hb_video_encoders_last_item = NULL;
hb_encoder_internal_t hb_video_encoders[] =
{
// legacy encoders, back to HB 0.9.4 whenever possible (disabled)
- { { "FFmpeg", "ffmpeg", NULL, HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4, },
- { { "MPEG-4 (FFmpeg)", "ffmpeg4", NULL, HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG4, },
- { { "MPEG-2 (FFmpeg)", "ffmpeg2", NULL, HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_MPEG2, },
- { { "VP3 (Theora)", "libtheora", NULL, HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_VCODEC_THEORA, },
+ { { "FFmpeg", "ffmpeg", NULL, HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, 0, HB_GID_VCODEC_MPEG4, },
+ { { "MPEG-4 (FFmpeg)", "ffmpeg4", NULL, HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, 0, HB_GID_VCODEC_MPEG4, },
+ { { "MPEG-2 (FFmpeg)", "ffmpeg2", NULL, HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, 0, HB_GID_VCODEC_MPEG2, },
+ { { "VP3 (Theora)", "libtheora", NULL, HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 1, 0, HB_GID_VCODEC_THEORA, },
// actual encoders
- { { "H.264 (x264)", "x264", "H.264 (libx264)", HB_VCODEC_X264_8BIT, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264_X264, },
- { { "H.264 10-bit (x264)", "x264_10bit", "H.264 10-bit (libx264)", HB_VCODEC_X264_10BIT, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264_X264, },
- { { "H.264 (Intel QSV)", "qsv_h264", "H.264 (Intel Media SDK)", HB_VCODEC_QSV_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264_QSV, },
- { { "H.264 (AMD VCE)", "vce_h264", "H.264 (AMD VCE)", HB_VCODEC_FFMPEG_VCE_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264_VCE, },
- { { "H.264 (NVEnc)", "nvenc_h264", "H.264 (NVEnc)", HB_VCODEC_FFMPEG_NVENC_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264_NVENC, },
- { { "H.264 (VideoToolbox)","vt_h264", "H.264 (libavcodec)", HB_VCODEC_FFMPEG_VT_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H264_VT, },
- { { "H.265 (x265)", "x265", "H.265 (libx265)", HB_VCODEC_X265_8BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 1, HB_GID_VCODEC_H265_X265, },
- { { "H.265 10-bit (x265)", "x265_10bit", "H.265 10-bit (libx265)", HB_VCODEC_X265_10BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 1, HB_GID_VCODEC_H265_X265, },
- { { "H.265 12-bit (x265)", "x265_12bit", "H.265 12-bit (libx265)", HB_VCODEC_X265_12BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 1, HB_GID_VCODEC_H265_X265, },
- { { "H.265 16-bit (x265)", "x265_16bit", "H.265 16-bit (libx265)", HB_VCODEC_X265_16BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 1, HB_GID_VCODEC_H265_X265, },
- { { "H.265 (Intel QSV)", "qsv_h265", "H.265 (Intel Media SDK)", HB_VCODEC_QSV_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265_QSV, },
- { { "H.265 10-bit (Intel QSV)","qsv_h265_10bit", "H.265 10-bit (Intel Media SDK)", HB_VCODEC_QSV_H265_10BIT, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265_QSV, },
- { { "H.265 (AMD VCE)", "vce_h265", "H.265 (AMD VCE)", HB_VCODEC_FFMPEG_VCE_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265_VCE, },
- { { "H.265 (NVEnc)", "nvenc_h265", "H.265 (NVEnc)", HB_VCODEC_FFMPEG_NVENC_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265_NVENC, },
- { { "H.265 (VideoToolbox)","vt_h265", "H.265 (libavcodec)", HB_VCODEC_FFMPEG_VT_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_H265_VT, },
- { { "MPEG-4", "mpeg4", "MPEG-4 (libavcodec)", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG4, },
- { { "MPEG-2", "mpeg2", "MPEG-2 (libavcodec)", HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_MPEG2, },
- { { "VP8", "VP8", "VP8 (libvpx)", HB_VCODEC_FFMPEG_VP8, HB_MUX_MASK_WEBM|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_VP8, },
- { { "VP9", "VP9", "VP9 (libvpx)", HB_VCODEC_FFMPEG_VP9, HB_MUX_MASK_WEBM|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_VP9, },
- { { "Theora", "theora", "Theora (libtheora)", HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_VCODEC_THEORA, },
+ { { "H.264 (x264)", "x264", "H.264 (libx264)", HB_VCODEC_X264_8BIT, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H264_X264, },
+ { { "H.264 10-bit (x264)", "x264_10bit", "H.264 10-bit (libx264)", HB_VCODEC_X264_10BIT, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H264_X264, },
+ { { "H.264 (Intel QSV)", "qsv_h264", "H.264 (Intel Media SDK)", HB_VCODEC_QSV_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H264_QSV, },
+ { { "H.264 (AMD VCE)", "vce_h264", "H.264 (AMD VCE)", HB_VCODEC_FFMPEG_VCE_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H264_VCE, },
+ { { "H.264 (NVEnc)", "nvenc_h264", "H.264 (NVEnc)", HB_VCODEC_FFMPEG_NVENC_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H264_NVENC, },
+ { { "H.264 (VideoToolbox)","vt_h264", "H.264 (libavcodec)", HB_VCODEC_FFMPEG_VT_H264, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H264_VT, },
+ { { "H.265 (x265)", "x265", "H.265 (libx265)", HB_VCODEC_X265_8BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_X265, },
+ { { "H.265 10-bit (x265)", "x265_10bit", "H.265 10-bit (libx265)", HB_VCODEC_X265_10BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_X265, },
+ { { "H.265 12-bit (x265)", "x265_12bit", "H.265 12-bit (libx265)", HB_VCODEC_X265_12BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_X265, },
+ { { "H.265 16-bit (x265)", "x265_16bit", "H.265 16-bit (libx265)", HB_VCODEC_X265_16BIT, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_X265, },
+ { { "H.265 (Intel QSV)", "qsv_h265", "H.265 (Intel Media SDK)", HB_VCODEC_QSV_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_QSV, },
+ { { "H.265 10-bit (Intel QSV)","qsv_h265_10bit", "H.265 10-bit (Intel Media SDK)", HB_VCODEC_QSV_H265_10BIT, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_QSV, },
+ { { "H.265 (AMD VCE)", "vce_h265", "H.265 (AMD VCE)", HB_VCODEC_FFMPEG_VCE_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_VCE, },
+ { { "H.265 (NVEnc)", "nvenc_h265", "H.265 (NVEnc)", HB_VCODEC_FFMPEG_NVENC_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_NVENC, },
+ { { "H.265 (VideoToolbox)","vt_h265", "H.265 (libavcodec)", HB_VCODEC_FFMPEG_VT_H265, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_H265_VT, },
+ { { "MPEG-4", "mpeg4", "MPEG-4 (libavcodec)", HB_VCODEC_FFMPEG_MPEG4, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_MPEG4, },
+ { { "MPEG-2", "mpeg2", "MPEG-2 (libavcodec)", HB_VCODEC_FFMPEG_MPEG2, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_MPEG2, },
+ { { "VP8", "VP8", "VP8 (libvpx)", HB_VCODEC_FFMPEG_VP8, HB_MUX_MASK_WEBM|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_VP8, },
+ { { "VP9", "VP9", "VP9 (libvpx)", HB_VCODEC_FFMPEG_VP9, HB_MUX_MASK_WEBM|HB_MUX_MASK_MKV, }, NULL, 0, 1, HB_GID_VCODEC_VP9, },
+ { { "Theora", "theora", "Theora (libtheora)", HB_VCODEC_THEORA, HB_MUX_MASK_MKV, }, NULL, 0, 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, int disable_hardware)
@@ -1469,6 +1470,18 @@ int hb_video_quality_is_supported(uint32_t codec)
}
}
+int hb_video_encoder_is_supported(int encoder)
+{
+ const hb_encoder_t *video_encoder = NULL;
+ while ((video_encoder = hb_video_encoder_get_next(video_encoder)) != NULL)
+ {
+ if (video_encoder->codec == encoder)
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
int hb_video_encoder_get_depth(int encoder)
{
@@ -2250,12 +2263,12 @@ const char* hb_video_encoder_get_name(int encoder)
if (!(encoder & HB_VCODEC_MASK))
goto fail;
- const hb_encoder_t *video_encoder = NULL;
- while ((video_encoder = hb_video_encoder_get_next(video_encoder)) != NULL)
+ int i;
+ for (i = 0; i < hb_video_encoders_count; i++)
{
- if (video_encoder->codec == encoder)
+ if (hb_video_encoders[i].item.codec == encoder && hb_video_encoders[i].deprecated == 0)
{
- return video_encoder->name;
+ return hb_video_encoders[i].item.name;
}
}
@@ -2268,12 +2281,12 @@ const char* hb_video_encoder_get_short_name(int encoder)
if (!(encoder & HB_VCODEC_MASK))
goto fail;
- const hb_encoder_t *video_encoder = NULL;
- while ((video_encoder = hb_video_encoder_get_next(video_encoder)) != NULL)
+ int i;
+ for (i = 0; i < hb_video_encoders_count; i++)
{
- if (video_encoder->codec == encoder)
+ if (hb_video_encoders[i].item.codec == encoder && hb_video_encoders[i].deprecated == 0)
{
- return video_encoder->short_name;
+ return hb_video_encoders[i].item.short_name;
}
}
@@ -2286,12 +2299,12 @@ const char* hb_video_encoder_get_long_name(int encoder)
if (!(encoder & HB_VCODEC_MASK))
goto fail;
- const hb_encoder_t *video_encoder = NULL;
- while ((video_encoder = hb_video_encoder_get_next(video_encoder)) != NULL)
+ int i;
+ for (i = 0; i < hb_video_encoders_count; i++)
{
- if (video_encoder->codec == encoder)
+ if (hb_video_encoders[i].item.codec == encoder && hb_video_encoders[i].deprecated == 0)
{
- return video_encoder->long_name;
+ return hb_video_encoders[i].item.long_name;
}
}
diff --git a/libhb/handbrake/common.h b/libhb/handbrake/common.h
index 7f945ca76..8a1faa37f 100644
--- a/libhb/handbrake/common.h
+++ b/libhb/handbrake/common.h
@@ -370,6 +370,7 @@ void hb_video_quality_get_limits(uint32_t codec, float *low, float *high,
const char* hb_video_quality_get_name(uint32_t codec);
int hb_video_quality_is_supported(uint32_t codec);
+int hb_video_encoder_is_supported(int encoder);
int hb_video_encoder_get_depth (int encoder);
const char* const* hb_video_encoder_get_presets (int encoder);
const char* const* hb_video_encoder_get_tunes (int encoder);
diff --git a/libhb/preset.c b/libhb/preset.c
index 969594f83..f7fdf2f2f 100644
--- a/libhb/preset.c
+++ b/libhb/preset.c
@@ -13,10 +13,6 @@
#include "handbrake/plist.h"
#include "handbrake/lang.h"
-#if HB_PROJECT_FEATURE_QSV
-#include "handbrake/qsv_common.h"
-#endif
-
#if defined(SYS_LINUX)
#define HB_PRESET_PLIST_FILE "ghb/presets"
#define HB_PRESET_JSON_FILE "ghb/presets.json"
@@ -84,11 +80,6 @@ typedef struct
int last_match_idx;
} preset_search_context_t;
-typedef struct
-{
- preset_do_context_t do_ctx;
-} preset_scrub_context_t;
-
typedef int (*preset_do_f)(hb_value_t *preset, preset_do_context_t *ctx);
static int preset_cmp_idx(hb_value_t *preset, int idx,
@@ -175,47 +166,6 @@ static int do_preset_search(hb_value_t *preset, preset_do_context_t *do_ctx)
return result;
}
-static int preset_hw_scrub(hb_value_t *preset)
-{
- int disabled = 0;
- hb_value_t *val = hb_dict_get(preset, "VideoEncoder");
- if (val != NULL)
- {
- const char *s;
- int vcodec;
- s = hb_value_get_string(val);
- vcodec = hb_video_encoder_get_from_name(s);
- if (vcodec != HB_VCODEC_INVALID)
- {
- if (vcodec & HB_VCODEC_QSV_MASK)
- {
- disabled = 1;
-#if HB_PROJECT_FEATURE_QSV
- if(hb_qsv_available())
- {
- // check the qsv codec is supported by hw
- disabled = hb_qsv_video_encoder_is_enabled(vcodec) ? 0 : 1;
- }
-#endif
- }
- // TODO: other hw codecs for non Intel platforms
- }
- }
-
- if(disabled)
- {
- hb_dict_set_int(preset, "PresetDisabled", disabled);
- }
- return 0;
-}
-
-static int do_preset_hw_scrub(hb_value_t *preset, preset_do_context_t *do_ctx)
-{
- preset_scrub_context_t *ctx = (preset_scrub_context_t*)do_ctx;
- preset_hw_scrub(preset);
- return PRESET_DO_NEXT;
-}
-
static int do_preset_import(hb_value_t *preset, preset_do_context_t *do_ctx)
{
preset_import_context_t *ctx = (preset_import_context_t*)do_ctx;
@@ -2276,6 +2226,9 @@ static void preset_clean(hb_value_t *preset, hb_value_t *template)
enc = hb_video_encoder_get_short_name(vcodec);
val = hb_value_string(enc);
hb_dict_set(preset, "VideoEncoder", val);
+
+ int disabled = hb_video_encoder_is_supported(vcodec) == 0;
+ hb_dict_set_bool(preset, "PresetDisabled", disabled);
}
val = hb_dict_get(preset, "VideoFramerate");
if (val != NULL)
@@ -2387,17 +2340,6 @@ void hb_presets_clean(hb_value_t *preset)
presets_clean(preset, hb_preset_template);
}
-static void presets_hw_scrub(hb_value_t *presets)
-{
- preset_scrub_context_t ctx;
- presets_do(do_preset_hw_scrub, presets, (preset_do_context_t*)&ctx);
-}
-
-void hb_presets_hw_scrub(hb_value_t *preset)
-{
- presets_hw_scrub(preset);
-}
-
static char * fix_name_collisions(hb_value_t * list, const char * name)
{
char * new_name = strdup(name);
@@ -3453,7 +3395,6 @@ int hb_presets_import(const hb_value_t *in, hb_value_t **out)
dup = hb_value_dup(in);
hb_presets_version(dup, &ctx.major, &ctx.minor, &ctx.micro);
presets_do(do_preset_import, dup, (preset_do_context_t*)&ctx);
- presets_do(do_preset_hw_scrub, dup, (preset_do_context_t*)&ctx);
if (cmpVersion(ctx.major, ctx.minor, ctx.micro, 29, 0, 0) <= 0)
{
hb_value_t * tmp;
@@ -3580,7 +3521,6 @@ void hb_presets_builtin_init(void)
hb_presets_builtin = hb_value_dup(hb_dict_get(dict, "PresetBuiltin"));
hb_presets_clean(hb_presets_builtin);
- hb_presets_hw_scrub(hb_presets_builtin);
hb_presets = hb_value_array_init();
hb_value_free(&dict);
@@ -3591,7 +3531,6 @@ int hb_presets_cli_default_init(void)
hb_value_t * dict = hb_value_json(hb_builtin_presets_json);
hb_presets_cli_default = hb_value_dup(hb_dict_get(dict, "PresetCLIDefault"));
hb_presets_clean(hb_presets_cli_default);
- hb_presets_hw_scrub(hb_presets_cli_default);
int result = hb_presets_add_internal(hb_presets_cli_default);
hb_value_free(&dict);