summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodeo <[email protected]>2014-01-15 00:09:56 +0000
committerRodeo <[email protected]>2014-01-15 00:09:56 +0000
commitf8cacd9c5edbc626e41aaa2d1767a5277a7e290c (patch)
treefd57c0e06f219653f73f1b1c2e30affad2d42f82
parentc67470b02699badf203d62c044670e86e7fb2e01 (diff)
decavcodec: only allow in-decoder downmix if it matches the requested mix levels.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5973 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/decavcodec.c65
1 files changed, 46 insertions, 19 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 42aa7e3c3..ca33d4172 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -302,31 +302,58 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job )
hb_error("decavcodecaInit: hb_audio_resample_init() failed");
return 1;
}
- // some decoders can downmix using embedded coefficients,
- // or dedicated audio substreams for a specific channel layout
- switch (w->audio->config.out.mixdown)
+ /*
+ * Some audio decoders can downmix using embedded coefficients,
+ * or dedicated audio substreams for a specific channel layout.
+ *
+ * But some will e.g. use normalized mix coefficients unconditionally,
+ * so we need to make sure this matches what the user actually requested.
+ */
+ int avcodec_downmix = 0;
+ switch (w->codec_param)
{
- case HB_AMIXDOWN_MONO:
- if (w->codec_param == AV_CODEC_ID_TRUEHD)
- {
- // libavcodec can't decode TrueHD Mono (bug #356)
- // work around it by requesting Stereo and downmixing
- pv->context->request_channel_layout = AV_CH_LAYOUT_STEREO;
- break;
- }
- pv->context->request_channel_layout = AV_CH_LAYOUT_MONO;
+ case AV_CODEC_ID_AC3:
+ case AV_CODEC_ID_EAC3:
+ avcodec_downmix = w->audio->config.out.normalize_mix_level != 0;
+ break;
+ case AV_CODEC_ID_DTS:
+ avcodec_downmix = w->audio->config.out.normalize_mix_level == 0;
break;
- // request 5.1 before downmixing to dpl1/dpl2
- case HB_AMIXDOWN_DOLBY:
- case HB_AMIXDOWN_DOLBYPLII:
- pv->context->request_channel_layout = AV_CH_LAYOUT_5POINT1;
+ case AV_CODEC_ID_TRUEHD:
+ avcodec_downmix = (w->audio->config.out.normalize_mix_level == 0 ||
+ w->audio->config.out.mixdown == HB_AMIXDOWN_MONO ||
+ w->audio->config.out.mixdown == HB_AMIXDOWN_DOLBY ||
+ w->audio->config.out.mixdown == HB_AMIXDOWN_DOLBYPLII);
break;
- // request the layout corresponding to the selected mixdown
default:
- pv->context->request_channel_layout =
- hb_ff_mixdown_xlat(w->audio->config.out.mixdown, NULL);
break;
}
+ if (avcodec_downmix)
+ {
+ switch (w->audio->config.out.mixdown)
+ {
+ case HB_AMIXDOWN_MONO:
+ if (w->codec_param == AV_CODEC_ID_TRUEHD)
+ {
+ // libavcodec can't decode TrueHD Mono (bug #356)
+ // work around it by requesting Stereo and downmixing
+ pv->context->request_channel_layout = AV_CH_LAYOUT_STEREO;
+ break;
+ }
+ pv->context->request_channel_layout = AV_CH_LAYOUT_MONO;
+ break;
+ // request 5.1 before downmixing to dpl1/dpl2
+ case HB_AMIXDOWN_DOLBY:
+ case HB_AMIXDOWN_DOLBYPLII:
+ pv->context->request_channel_layout = AV_CH_LAYOUT_5POINT1;
+ break;
+ // request the layout corresponding to the selected mixdown
+ default:
+ pv->context->request_channel_layout =
+ hb_ff_mixdown_xlat(w->audio->config.out.mixdown, NULL);
+ break;
+ }
+ }
}
// Set decoder opts...