summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2022-06-14 22:19:45 +0300
committerJan Ekström <jeebjp@gmail.com>2022-06-14 22:19:45 +0300
commit42b58c5698d109d33166c3fbdbe2b38eedd642bd (patch)
treed3c1bc350d484cce9cb1bc556235d247d7661d49
parent7a3f9af67fbd07a7e2dd10fb015d9563c0d15481 (diff)
downloadmpv-42b58c5698d109d33166c3fbdbe2b38eedd642bd.tar.bz2
mpv-42b58c5698d109d33166c3fbdbe2b38eedd642bd.tar.xz
af_lavcac3enc: refactor chmap adding into its own function
This simplifies ifdeffery with AVChannelLayouts.
-rw-r--r--audio/filter/af_lavcac3enc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c
index 45ebfa12a2..ac2ba0463c 100644
--- a/audio/filter/af_lavcac3enc.c
+++ b/audio/filter/af_lavcac3enc.c
@@ -270,6 +270,18 @@ static const struct mp_filter_info af_lavcac3enc_filter = {
.destroy = destroy,
};
+static void add_chmaps_to_autoconv(struct mp_autoconvert *conv,
+ const struct AVCodec *codec)
+{
+ const uint64_t *lch = codec->channel_layouts;
+ for (int n = 0; lch && lch[n]; n++) {
+ struct mp_chmap chmap = {0};
+ mp_chmap_from_lavc(&chmap, lch[n]);
+ if (mp_chmap_is_valid(&chmap))
+ mp_autoconvert_add_chmap(conv, &chmap);
+ }
+}
+
static struct mp_filter *af_lavcac3enc_create(struct mp_filter *parent,
void *options)
{
@@ -342,13 +354,7 @@ static struct mp_filter *af_lavcac3enc_create(struct mp_filter *parent,
mp_autoconvert_add_afmt(conv, mpfmt);
}
- const uint64_t *lch = s->lavc_acodec->channel_layouts;
- for (int n = 0; lch && lch[n]; n++) {
- struct mp_chmap chmap = {0};
- mp_chmap_from_lavc(&chmap, lch[n]);
- if (mp_chmap_is_valid(&chmap))
- mp_autoconvert_add_chmap(conv, &chmap);
- }
+ add_chmaps_to_autoconv(conv, s->lavc_acodec);
// At least currently, the AC3 encoder doesn't export sample rates.
mp_autoconvert_add_srate(conv, 48000);