diff options
-rw-r--r-- | libhb/common.c | 65 | ||||
-rw-r--r-- | libhb/work.c | 11 | ||||
-rw-r--r-- | test/test.c | 8 |
3 files changed, 66 insertions, 18 deletions
diff --git a/libhb/common.c b/libhb/common.c index 6ba81f762..0bb2eafd5 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -2001,7 +2001,6 @@ void hb_autopassthru_apply_settings(hb_job_t *job) hb_audio_close(&audio); continue; } - audio->config.out.samplerate = audio->config.in.samplerate; if (!(audio->config.out.codec & HB_ACODEC_PASS_FLAG)) { if (audio->config.out.codec == job->acodec_fallback) @@ -2014,15 +2013,65 @@ void hb_autopassthru_apply_settings(hb_job_t *job) hb_log("Auto Passthru: passthru and fallback not possible for track %d, using default encoder", audio->config.out.track); } - audio->config.out.mixdown = - hb_mixdown_get_default(audio->config.out.codec, - audio->config.in.channel_layout); - audio->config.out.bitrate = - hb_audio_bitrate_get_default(audio->config.out.codec, + if (audio->config.out.mixdown <= 0) + { + audio->config.out.mixdown = + hb_mixdown_get_default(audio->config.out.codec, + audio->config.in.channel_layout); + } + else + { + audio->config.out.mixdown = + hb_mixdown_get_best(audio->config.out.codec, + audio->config.in.channel_layout, + audio->config.out.mixdown); + } + if (audio->config.out.samplerate <= 0) + audio->config.out.samplerate = audio->config.in.samplerate; + audio->config.out.samplerate = + hb_audio_samplerate_get_best(audio->config.out.codec, + audio->config.out.samplerate, + NULL); + int quality_not_allowed = + hb_audio_quality_get_default(audio->config.out.codec) + == HB_INVALID_AUDIO_QUALITY; + if (audio->config.out.bitrate > 0) + { + // Use best bitrate + audio->config.out.bitrate = + hb_audio_bitrate_get_best(audio->config.out.codec, + audio->config.out.bitrate, + audio->config.out.samplerate, + audio->config.out.mixdown); + } + else if (quality_not_allowed || + audio->config.out.quality != HB_INVALID_AUDIO_QUALITY) + { + // Use default bitrate + audio->config.out.bitrate = + hb_audio_bitrate_get_default(audio->config.out.codec, audio->config.out.samplerate, audio->config.out.mixdown); - audio->config.out.compression_level = - hb_audio_compression_get_default(audio->config.out.codec); + } + else + { + // Use best quality + audio->config.out.quality = + hb_audio_quality_get_best(audio->config.out.codec, + audio->config.out.quality); + } + if (audio->config.out.compression_level < 0) + { + audio->config.out.compression_level = + hb_audio_compression_get_default( + audio->config.out.codec); + } + else + { + audio->config.out.compression_level = + hb_audio_compression_get_best(audio->config.out.codec, + audio->config.out.compression_level); + } } else { diff --git a/libhb/work.c b/libhb/work.c index 5c8c38bed..240ccbb92 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -1002,16 +1002,23 @@ static void do_job(hb_job_t *job) audio->priv.fifo_out = hb_fifo_init(FIFO_LARGE, FIFO_LARGE_WAKE); audio->priv.fifo_in = hb_fifo_init(FIFO_LARGE, FIFO_LARGE_WAKE); - /* Passthru audio, nothing to sanitize here */ + /* Passthru audio */ if (audio->config.out.codec & HB_ACODEC_PASS_FLAG) + { + // Muxer needs these to be set correctly in order to + // set audio track MP4 time base. + audio->config.out.samples_per_frame = + audio->config.in.samples_per_frame; + audio->config.out.samplerate = audio->config.in.samplerate; continue; + } /* Vorbis language information */ if (audio->config.out.codec == HB_ACODEC_VORBIS) audio->priv.config.vorbis.language = audio->config.lang.simple; /* sense-check the requested samplerate */ - if (audio->config.out.samplerate < 0) + if (audio->config.out.samplerate <= 0) { // if not specified, set to same as input audio->config.out.samplerate = audio->config.in.samplerate; diff --git a/test/test.c b/test/test.c index 085abcde0..b0c5b6010 100644 --- a/test/test.c +++ b/test/test.c @@ -2528,14 +2528,6 @@ static int HandleEvents( hb_handle_t * h ) "%s requested and input codec is not compatible for track %d, using %s encoder\n", hb_audio_encoder_get_name(requested_passthru), audio->out.track, hb_audio_encoder_get_name(audio->out.codec)); - // we didn't drop the track, set the mixdown and bitrate from libhb defaults - audio->out.mixdown = - hb_mixdown_get_default(audio->out.codec, - audio->in.channel_layout); - audio->out.bitrate = - hb_audio_bitrate_get_default(audio->out.codec, - audio->out.samplerate, - audio->out.mixdown); } // we didn't drop the track i++; |