diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 47 | ||||
-rw-r--r-- | libhb/common.h | 3 | ||||
-rw-r--r-- | libhb/preset.c | 13 |
3 files changed, 34 insertions, 29 deletions
diff --git a/libhb/common.c b/libhb/common.c index ebe51c6e5..08bf0f08d 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -309,6 +309,7 @@ hb_encoder_internal_t hb_audio_encoders[] = { { "AAC", "aac", NULL, 0, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_AAC, }, { { "HE-AAC", "haac", NULL, 0, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 0, HB_GID_ACODEC_AAC_HE, }, // actual encoders + { { "None", "none", "None", HB_ACODEC_NONE, 0, }, NULL, 1, HB_GID_NONE, }, { { "AAC (CoreAudio)", "ca_aac", "AAC (Apple AudioToolbox)", HB_ACODEC_CA_AAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, { { "HE-AAC (CoreAudio)", "ca_haac", "HE-AAC (Apple AudioToolbox)", HB_ACODEC_CA_HAAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC_HE, }, { { "AAC (FDK)", "fdk_aac", "AAC (libfdk_aac)", HB_ACODEC_FDK_AAC, HB_MUX_MASK_MP4|HB_MUX_MASK_MKV, }, NULL, 1, HB_GID_ACODEC_AAC, }, @@ -372,6 +373,7 @@ static int hb_audio_encoder_is_enabled(int encoder) // the following encoders are always enabled case HB_ACODEC_LAME: case HB_ACODEC_VORBIS: + case HB_ACODEC_NONE: return 1; default: @@ -2186,7 +2188,7 @@ int hb_audio_encoder_get_fallback_for_passthru(int passthru) break; default: - gid = HB_GID_NONE; // will never match an enabled encoder + return HB_ACODEC_INVALID; break; } while ((audio_encoder = hb_audio_encoder_get_next(audio_encoder)) != NULL) @@ -2355,8 +2357,8 @@ void hb_autopassthru_apply_settings(hb_job_t *job) job->acodec_copy_mask, job->acodec_fallback, job->mux); - if (!(audio->config.out.codec & HB_ACODEC_PASS_FLAG) && - !(audio->config.out.codec & HB_ACODEC_MASK)) + if (audio->config.out.codec == HB_ACODEC_NONE || + audio->config.out.codec == HB_ACODEC_INVALID) { hb_log("Auto Passthru: passthru not possible and no valid fallback specified, dropping track %d", audio->config.out.track ); @@ -2366,16 +2368,8 @@ void hb_autopassthru_apply_settings(hb_job_t *job) } if (!(audio->config.out.codec & HB_ACODEC_PASS_FLAG)) { - if (audio->config.out.codec == job->acodec_fallback) - { - hb_log("Auto Passthru: passthru not possible for track %d, using fallback", - audio->config.out.track); - } - else - { - hb_log("Auto Passthru: passthru and fallback not possible for track %d, using default encoder", - audio->config.out.track); - } + hb_log("Auto Passthru: passthru not possible for track %d, using fallback", + audio->config.out.track); if (audio->config.out.mixdown <= 0) { audio->config.out.mixdown = @@ -2506,31 +2500,36 @@ void hb_autopassthru_print_settings(hb_job_t *job) int hb_autopassthru_get_encoder(int in_codec, int copy_mask, int fallback, int muxer) { - int i = 0; + int out_codec_result_set = 0; + int fallback_result_set = 0; + int out_codec_result = HB_ACODEC_INVALID; + int fallback_result = HB_ACODEC_INVALID; const hb_encoder_t *audio_encoder = NULL; int out_codec = (copy_mask & in_codec) | HB_ACODEC_PASS_FLAG; + // sanitize fallback encoder and selected passthru // note: invalid fallbacks are caught in hb_autopassthru_apply_settings while ((audio_encoder = hb_audio_encoder_get_next(audio_encoder)) != NULL) { - if (audio_encoder->codec == out_codec) + if (!out_codec_result_set && audio_encoder->codec == out_codec) { - i++; - if (!(audio_encoder->muxers & muxer)) - out_codec = 0; + out_codec_result_set = 1; + if (audio_encoder->muxers & muxer) + out_codec_result = out_codec; } - else if (audio_encoder->codec == fallback) + else if (!fallback_result_set && audio_encoder->codec == fallback) { - i++; - if (!(audio_encoder->muxers & muxer)) - fallback = hb_audio_encoder_get_default(muxer); + fallback_result_set = 1; + if ((audio_encoder->muxers & muxer) || fallback == HB_ACODEC_NONE) + fallback_result = fallback; } - if (i > 1) + if (out_codec_result_set && fallback_result_set) { break; } } - return (out_codec & HB_ACODEC_PASS_MASK) ? out_codec : fallback; + return (out_codec_result != HB_ACODEC_INVALID) ? out_codec_result : + fallback_result; } hb_container_t* hb_container_get_from_format(int format) diff --git a/libhb/common.h b/libhb/common.h index 2edbdc697..6aac0bacd 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -681,7 +681,8 @@ struct hb_job_s /* Audio starts here */ /* Audio Codecs: Update win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/NativeConstants.cs when changing these consts */ #define HB_ACODEC_INVALID 0x00000000 -#define HB_ACODEC_MASK 0x07FFFF00 +#define HB_ACODEC_NONE 0x00000001 +#define HB_ACODEC_MASK 0x07FFFF01 #define HB_ACODEC_LAME 0x00000200 #define HB_ACODEC_VORBIS 0x00000400 #define HB_ACODEC_AC3 0x00000800 diff --git a/libhb/preset.c b/libhb/preset.c index 37157e651..5ad3dbf76 100644 --- a/libhb/preset.c +++ b/libhb/preset.c @@ -492,7 +492,7 @@ static int sanitize_audio_codec(int in_codec, int out_codec, !(in_codec & out_codec & HB_ACODEC_PASS_MASK)) { codec = hb_audio_encoder_get_fallback_for_passthru(out_codec); - if (codec == 0) + if (codec == HB_ACODEC_INVALID) codec = fallback; } @@ -500,14 +500,14 @@ static int sanitize_audio_codec(int in_codec, int out_codec, const hb_encoder_t *encoder = NULL; while ((encoder = hb_audio_encoder_get_next(encoder)) != NULL) { - if (encoder->codec == codec && + if (encoder->codec == codec && codec != HB_ACODEC_NONE && !(encoder->muxers & mux)) { codec = hb_audio_encoder_get_default(mux); break; } } - if (codec == 0) + if (codec == HB_ACODEC_INVALID) codec = hb_audio_encoder_get_default(mux); return codec; } @@ -630,7 +630,6 @@ static void add_audio_for_lang(hb_value_array_t *list, const hb_dict_t *preset, hb_dict_t *used = source_audio_track_used(track_dict, ii); if (hb_value_get_bool(hb_dict_get(used, key))) continue; - hb_dict_set(used, key, hb_value_bool(1)); // Create new audio output track settings hb_dict_t *audio_dict = hb_dict_init(); @@ -657,6 +656,11 @@ static void add_audio_for_lang(hb_value_array_t *list, const hb_dict_t *preset, aconfig = hb_list_audio_config_item(title->list_audio, track); out_codec = sanitize_audio_codec(aconfig->in.codec, out_codec, copy_mask, fallback, mux); + if (out_codec == HB_ACODEC_NONE || HB_ACODEC_INVALID) + { + hb_value_free(&audio_dict); + continue; + } hb_dict_set(audio_dict, "Track", hb_value_int(track)); hb_dict_set(audio_dict, "Encoder", hb_value_string( hb_audio_encoder_get_short_name(out_codec))); @@ -730,6 +734,7 @@ static void add_audio_for_lang(hb_value_array_t *list, const hb_dict_t *preset, hb_sanitize_audio_settings(title, audio_dict); hb_value_array_append(list, audio_dict); + hb_dict_set(used, key, hb_value_bool(1)); } if (behavior == 2) track = find_audio_track(title, lang, track + 1, behavior); |