summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-05-14 18:49:07 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:29 -0300
commitc30e22c9fb1a3d1c3b62c6bc1ff9f8b6a0f41dcc (patch)
tree92e991a02bab2bd9492c1f2e5abbe8d496e13f5a /libavformat/mux.c
parent276c06726fbd2f784d51189870bd834e9284812f (diff)
lavf: add a temporary compat layer for the channel layout API change
Mediates between old-style (de)muxers and new-style callers. Will be removed once all the (de)muxers are converted to the new API. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 53eb56f0af..f1b5beea0a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -272,6 +272,16 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
ret = AVERROR(EINVAL);
goto fail;
}
+
+ /* if the new-style channel layout is set, convert it to old one
+ * for old-style muxers */
+ if (par->ch_layout.nb_channels &&
+ !par->channels) {
+ par->channels = par->ch_layout.nb_channels;
+ par->channel_layout = par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
+ par->ch_layout.u.mask : 0;
+ }
+
if (!par->block_align)
par->block_align = par->channels *
av_get_bits_per_sample(par->codec_id) >> 3;