From 0ffaf653a21d0c767abfcf1094f9e57a6c9b5ba4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 26 Oct 2015 15:53:47 +0100 Subject: [PATCH] af_lavrresample: make planarization pass work with >8 channels av_get_default_channel_layout() fails with channel counts larger than 8. The channel layout doesn't need to make sense, so pick an arbitrary fallback. libswresample also has options for setting the channel counts directly, but better not introduce new concepts in the code. Also, libavresample doesn't have these options. --- audio/filter/af_lavrresample.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 11af645910..721bb30165 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -309,14 +309,15 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in, av_opt_set_int(s->avrctx, "in_sample_fmt", in_samplefmt, 0); av_opt_set_int(s->avrctx, "out_sample_fmt", out_samplefmtp, 0); - // Just needs the correct number of channels. - int fake_out_ch_layout = av_get_default_channel_layout(map_out.num); + // Just needs the correct number of channels for deplanarization. + struct mp_chmap fake_chmap; + mp_chmap_set_unknown(&fake_chmap, map_out.num); + uint64_t fake_out_ch_layout = mp_chmap_to_lavc_unchecked(&fake_chmap); if (!fake_out_ch_layout) goto error; - - // Deplanarize if needed. av_opt_set_int(s->avrctx_out, "in_channel_layout", fake_out_ch_layout, 0); av_opt_set_int(s->avrctx_out, "out_channel_layout", fake_out_ch_layout, 0); + av_opt_set_int(s->avrctx_out, "in_sample_fmt", out_samplefmtp, 0); av_opt_set_int(s->avrctx_out, "out_sample_fmt", out_samplefmt, 0); av_opt_set_int(s->avrctx_out, "in_sample_rate", s->out_rate, 0);