summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filters/f_swresample.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/filters/f_swresample.c b/filters/f_swresample.c
index 8cb687def0..424a62bcf5 100644
--- a/filters/f_swresample.c
+++ b/filters/f_swresample.c
@@ -23,6 +23,7 @@
#include <libswresample/swresample.h>
#include "audio/aframe.h"
+#include "audio/chmap_avchannel.h"
#include "audio/fmt-conversion.h"
#include "audio/format.h"
#include "common/common.h"
@@ -269,14 +270,28 @@ static bool configure_lavrr(struct priv *p, bool verbose)
out_ch_layout = fudge_layout_conversion(p, in_ch_layout, out_ch_layout);
+#if HAVE_AV_CHANNEL_LAYOUT
// Real conversion; output is input to avrctx_out.
+ AVChannelLayout in_layout, out_layout;
+ mp_chmap_to_av_layout(&in_layout, &in_lavc);
+ mp_chmap_to_av_layout(&out_layout, &out_lavc);
+ av_opt_set_chlayout(p->avrctx, "in_chlayout", &in_layout, 0);
+ av_opt_set_chlayout(p->avrctx, "out_chlayout", &out_layout, 0);
+#else
av_opt_set_int(p->avrctx, "in_channel_layout", in_ch_layout, 0);
av_opt_set_int(p->avrctx, "out_channel_layout", out_ch_layout, 0);
+#endif
av_opt_set_int(p->avrctx, "in_sample_rate", p->in_rate, 0);
av_opt_set_int(p->avrctx, "out_sample_rate", p->out_rate, 0);
av_opt_set_int(p->avrctx, "in_sample_fmt", in_samplefmt, 0);
av_opt_set_int(p->avrctx, "out_sample_fmt", out_samplefmtp, 0);
+#if HAVE_AV_CHANNEL_LAYOUT
+ AVChannelLayout fake_layout;
+ av_channel_layout_default(&fake_layout, map_out.num);
+ av_opt_set_chlayout(p->avrctx_out, "in_chlayout", &fake_layout, 0);
+ av_opt_set_chlayout(p->avrctx_out, "out_chlayout", &fake_layout, 0);
+#else
// Just needs the correct number of channels for deplanarization.
struct mp_chmap fake_chmap;
mp_chmap_set_unknown(&fake_chmap, map_out.num);
@@ -285,6 +300,7 @@ static bool configure_lavrr(struct priv *p, bool verbose)
goto error;
av_opt_set_int(p->avrctx_out, "in_channel_layout", fake_out_ch_layout, 0);
av_opt_set_int(p->avrctx_out, "out_channel_layout", fake_out_ch_layout, 0);
+#endif
av_opt_set_int(p->avrctx_out, "in_sample_fmt", out_samplefmtp, 0);
av_opt_set_int(p->avrctx_out, "out_sample_fmt", out_samplefmt, 0);