diff options
author | John Stebbins <[email protected]> | 2015-10-12 13:44:11 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2015-11-12 10:06:30 -0800 |
commit | 2c9d144740e0133cdf389ec814626439700b64f7 (patch) | |
tree | e6d847dd82bbaa02e618e34745b13b4eeeab7a83 | |
parent | 02585c6faf9163a1b1bab9ce537afb7044dc35f6 (diff) |
x265: add support for 10, 12, and 16 bit x265 libs
automatically pull in shared versions of these libs or allow statically
building against any one of them.
-rw-r--r-- | gtk/src/hb-backend.c | 5 | ||||
-rw-r--r-- | gtk/src/makedeps.py | 4 | ||||
-rw-r--r-- | libhb/common.c | 53 | ||||
-rw-r--r-- | libhb/common.h | 9 | ||||
-rw-r--r-- | libhb/encx265.c | 42 | ||||
-rw-r--r-- | libhb/h265_common.h | 5 | ||||
-rw-r--r-- | libhb/hb_dict.c | 2 | ||||
-rw-r--r-- | libhb/muxavformat.c | 5 | ||||
-rw-r--r-- | libhb/work.c | 23 |
9 files changed, 106 insertions, 42 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 9b26552d0..afae9d4da 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -999,7 +999,10 @@ ghb_vquality_default(signal_user_data_t *ud) switch (vcodec) { - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: return 20; diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index 8abc4cc9d..a0277e840 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -56,8 +56,8 @@ dep_map = ( DepEntry("VideoEncoder", "x264FastDecode", "x264|x264_10bit", False, True), DepEntry("VideoEncoder", "x264UseAdvancedOptions", "x264|x264_10bit", False, True), DepEntry("HideAdvancedVideoSettings", "x264UseAdvancedOptions", "1", True, True), - DepEntry("VideoEncoder", "VideoOptionExtraWindow", "x264|x264_10bit|x265|mpeg4|mpeg2|VP8", False, True), - DepEntry("VideoEncoder", "VideoOptionExtraLabel", "x264|x264_10bit|x265|mpeg4|mpeg2|VP8", False, True), + DepEntry("VideoEncoder", "VideoOptionExtraWindow", "x264|x264_10bit|x265|x265_10bit|x265_12bit|x265_16bit|mpeg4|mpeg2|VP8", False, True), + DepEntry("VideoEncoder", "VideoOptionExtraLabel", "x264|x264_10bit|x265|x265_10bit|x265_12bit|x265_16bit|mpeg4|mpeg2|VP8", False, True), DepEntry("x264UseAdvancedOptions", "VideoSettingsTable", "1", True, False), DepEntry("VideoEncoder", "x264_box", "x264|x264_10bit", False, True), DepEntry("x264UseAdvancedOptions", "x264_box", "0", True, False), diff --git a/libhb/common.c b/libhb/common.c index e4ea0c9ed..43c4d7601 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -227,7 +227,10 @@ hb_encoder_internal_t hb_video_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, }, { { "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, }, { { "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, }, - { { "H.265 (x265)", "x265", "H.265 (libx265)", HB_VCODEC_X265, HB_MUX_AV_MP4|HB_MUX_AV_MKV, }, NULL, 1, HB_GID_VCODEC_H265, }, + { { "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, }, + { { "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, }, + { { "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, }, + { { "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, }, { { "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, }, { { "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, }, @@ -250,10 +253,19 @@ static int hb_video_encoder_is_enabled(int encoder) case HB_VCODEC_FFMPEG_MPEG4: case HB_VCODEC_FFMPEG_MPEG2: case HB_VCODEC_FFMPEG_VP8: + return 1; + #ifdef USE_X265 - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: + { + const x265_api *api; + api = x265_api_get(hb_video_encoder_get_depth(encoder)); + return (api != NULL); + }; #endif - return 1; case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: @@ -1202,7 +1214,10 @@ void hb_video_quality_get_limits(uint32_t codec, float *low, float *high, case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: #ifdef USE_X265 - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: #endif *direction = 1; *granularity = 0.1; @@ -1249,7 +1264,10 @@ const char* hb_video_quality_get_name(uint32_t codec) case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: #ifdef USE_X265 - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: #endif return "RF"; @@ -1266,7 +1284,12 @@ int hb_video_encoder_get_depth(int encoder) switch (encoder) { case HB_VCODEC_X264_10BIT: + case HB_VCODEC_X265_10BIT: return 10; + case HB_VCODEC_X265_12BIT: + return 12; + case HB_VCODEC_X265_16BIT: + return 16; default: return 8; } @@ -1288,7 +1311,10 @@ const char* const* hb_video_encoder_get_presets(int encoder) return x264_preset_names; #ifdef USE_X265 - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: return x265_preset_names; #endif default: @@ -1305,7 +1331,10 @@ const char* const* hb_video_encoder_get_tunes(int encoder) return x264_tune_names; #ifdef USE_X265 - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: return x265_tune_names; #endif default: @@ -1329,8 +1358,14 @@ const char* const* hb_video_encoder_get_profiles(int encoder) case HB_VCODEC_X264_10BIT: return hb_h264_profile_names_10bit; - case HB_VCODEC_X265: - return hb_h265_profile_names; + case HB_VCODEC_X265_8BIT: + return hb_h265_profile_names_8bit; + case HB_VCODEC_X265_10BIT: + return hb_h265_profile_names_10bit; + case HB_VCODEC_X265_12BIT: + return hb_h265_profile_names_12bit; + case HB_VCODEC_X265_16BIT: + return hb_h265_profile_names_16bit; default: return NULL; diff --git a/libhb/common.h b/libhb/common.h index 5152cbc70..db87a9143 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -523,7 +523,6 @@ struct hb_job_s #define HB_VCODEC_MASK 0x00FFFFF #define HB_VCODEC_INVALID 0x0000000 #define HB_VCODEC_THEORA 0x0000002 -#define HB_VCODEC_X265 0x0000004 #define HB_VCODEC_FFMPEG_MPEG4 0x0000010 #define HB_VCODEC_FFMPEG_MPEG2 0x0000020 #define HB_VCODEC_FFMPEG_VP8 0x0000040 @@ -536,7 +535,13 @@ struct hb_job_s #define HB_VCODEC_X264_10BIT 0x0020000 #define HB_VCODEC_X264_MASK 0x0030000 #define HB_VCODEC_H264_MASK (HB_VCODEC_X264_MASK|HB_VCODEC_QSV_H264) -#define HB_VCODEC_H265_MASK (HB_VCODEC_X265|HB_VCODEC_QSV_H265) +#define HB_VCODEC_X265_8BIT 0x0001000 +#define HB_VCODEC_X265 HB_VCODEC_X265_8BIT +#define HB_VCODEC_X265_10BIT 0x0002000 +#define HB_VCODEC_X265_12BIT 0x0004000 +#define HB_VCODEC_X265_16BIT 0x0008000 +#define HB_VCODEC_X265_MASK 0x000F000 +#define HB_VCODEC_H265_MASK (HB_VCODEC_X265_MASK|HB_VCODEC_QSV_H265) int vcodec; double vquality; diff --git a/libhb/encx265.c b/libhb/encx265.c index 2da54ed71..4ce890f99 100644 --- a/libhb/encx265.c +++ b/libhb/encx265.c @@ -51,14 +51,13 @@ struct hb_work_private_s struct { - int64_t duration; + int64_t duration; } frame_info[FRAME_INFO_SIZE]; char csvfn[1024]; // Multiple bit-depth - int depth; const x265_api *api; }; @@ -95,22 +94,25 @@ static int param_parse(hb_work_private_t *pv, x265_param *param, **********************************************************************/ int encx265Init(hb_work_object_t *w, hb_job_t *job) { - hb_work_private_t *pv = calloc(1, sizeof(hb_work_private_t)); - pv->next_chapter_pts = AV_NOPTS_VALUE; - pv->delayed_chapters = hb_list_init(); - pv->job = job; - w->private_data = pv; - int ret; - hb_rational_t vrate; - x265_nal *nal; - uint32_t nnal; + hb_work_private_t *pv = calloc(1, sizeof(hb_work_private_t)); + int ret, depth; + hb_rational_t vrate; + x265_nal *nal; + uint32_t nnal; + const char * const *profile_names; + + pv->next_chapter_pts = AV_NOPTS_VALUE; + pv->delayed_chapters = hb_list_init(); + pv->job = job; + w->private_data = pv; + + depth = hb_video_encoder_get_depth(job->vcodec); + profile_names = hb_video_encoder_get_profiles(job->vcodec); + pv->api = x265_api_get(depth); - // TODO: add support for other bit depths - pv->depth = 8; - pv->api = x265_api_get(pv->depth); if (pv->api == NULL) { - hb_error("encx265: x265_api_get failed, bit depth %d.", pv->depth); + hb_error("encx265: x265_api_get failed, bit depth %d.", depth); goto fail; } @@ -292,9 +294,9 @@ int encx265Init(hb_work_object_t *w, hb_job_t *job) } /* Apply profile and level settings last. */ - if (job->encoder_profile != NULL && - strcasecmp(job->encoder_profile, hb_h265_profile_names[0]) != 0 && - pv->api->param_apply_profile(param, job->encoder_profile) < 0) + if (job->encoder_profile != NULL && + strcasecmp(job->encoder_profile, profile_names[0]) != 0 && + pv->api->param_apply_profile(param, job->encoder_profile) < 0) { goto fail; } @@ -558,8 +560,8 @@ int encx265Work(hb_work_object_t *w, hb_buffer_t **buf_in, hb_buffer_t **buf_out hb_buffer_list_clear(&list); // flush delayed frames - while ( - pv->api->encoder_encode(pv->x265, &nal, &nnal, NULL, &pic_out) > 0) + while (pv->api->encoder_encode(pv->x265, &nal, + &nnal, NULL, &pic_out) > 0) { hb_buffer_t *buf = nal_encode(w, &pic_out, nal, nnal); hb_buffer_list_append(&list, buf); diff --git a/libhb/h265_common.h b/libhb/h265_common.h index cc1b38708..724ea7d55 100644 --- a/libhb/h265_common.h +++ b/libhb/h265_common.h @@ -11,7 +11,10 @@ #define HB_H265_COMMON_H static const char * const hb_h265_tier_names[] = { "auto", "main", "high", NULL, }; -static const char * const hb_h265_profile_names[] = { "auto", "main", "mainstillpicture", NULL, }; +static const char * const hb_h265_profile_names_8bit[] = { "auto", "main", "mainstillpicture", NULL, }; +static const char * const hb_h265_profile_names_10bit[] = { "auto", "main10", "main10-intra", NULL, }; +static const char * const hb_h265_profile_names_12bit[] = { "auto", "main12", "main12-intra", NULL, }; +static const char * const hb_h265_profile_names_16bit[] = { "auto", "main16", "main16-intra", NULL, }; static const char * const hb_h265_level_names[] = { "auto", "1.0", "2.0", "2.1", "3.0", "3.1", "4.0", "4.1", "5.0", "5.1", "5.2", "6.0", "6.1", "6.2", NULL, }; static const int const hb_h265_level_values[] = { -1, 30, 60, 63, 90, 93, 120, 123, 150, 153, 156, 180, 183, 186, 0, }; diff --git a/libhb/hb_dict.c b/libhb/hb_dict.c index e634d8efd..268f5541a 100644 --- a/libhb/hb_dict.c +++ b/libhb/hb_dict.c @@ -595,7 +595,7 @@ hb_dict_t * hb_encopts_to_dict(const char * encopts, int encoder) name = hb_x264_encopt_name(name); #ifdef USE_X265 // x265 has multiple names for some options - if (encoder == HB_VCODEC_X265) + if (encoder & HB_VCODEC_X265_MASK) name = hb_x265_encopt_name(name); #endif if (name != NULL) diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c index 1bbece7be..aac09b764 100644 --- a/libhb/muxavformat.c +++ b/libhb/muxavformat.c @@ -324,7 +324,10 @@ static int avformatInit( hb_mux_object_t * m ) } } break; - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: case HB_VCODEC_QSV_H265: track->st->codec->codec_id = AV_CODEC_ID_HEVC; diff --git a/libhb/work.c b/libhb/work.c index bb122f479..931512999 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -228,7 +228,10 @@ hb_work_object_t* hb_video_encoder(hb_handle_t *h, int vcodec) w = hb_get_work(h, WORK_ENCTHEORA); break; #ifdef USE_X265 - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: w = hb_get_work(h, WORK_ENCX265); break; #endif @@ -415,7 +418,10 @@ void hb_display_job_info(hb_job_t *job) { case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: case HB_VCODEC_QSV_H264: case HB_VCODEC_QSV_H265: hb_log(" + preset: %s", job->encoder_preset); @@ -429,7 +435,10 @@ void hb_display_job_info(hb_job_t *job) { case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: hb_log(" + tune: %s", job->encoder_tune); default: break; @@ -446,7 +455,10 @@ void hb_display_job_info(hb_job_t *job) { case HB_VCODEC_X264_8BIT: case HB_VCODEC_X264_10BIT: - case HB_VCODEC_X265: + case HB_VCODEC_X265_8BIT: + case HB_VCODEC_X265_10BIT: + case HB_VCODEC_X265_12BIT: + case HB_VCODEC_X265_16BIT: case HB_VCODEC_QSV_H264: case HB_VCODEC_QSV_H265: hb_log(" + profile: %s", job->encoder_profile); @@ -477,7 +489,8 @@ void hb_display_job_info(hb_job_t *job) { hb_log( " + bitrate: %d kbps, pass: %d", job->vbitrate, job->pass_id ); if(job->pass_id == HB_PASS_ENCODE_1ST && job->fastfirstpass == 1 && - ((job->vcodec & HB_VCODEC_X264_MASK) || job->vcodec == HB_VCODEC_X265)) + ((job->vcodec & HB_VCODEC_X264_MASK) || + (job->vcodec & HB_VCODEC_X265_MASK))) { hb_log( " + fast first pass" ); if (job->vcodec & HB_VCODEC_X264_MASK) |