diff options
author | Anton Khirnov <anton@khirnov.net> | 2019-05-14 18:49:07 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:29 -0300 |
commit | c30e22c9fb1a3d1c3b62c6bc1ff9f8b6a0f41dcc (patch) | |
tree | 92e991a02bab2bd9492c1f2e5abbe8d496e13f5a /libavformat/demux.c | |
parent | 276c06726fbd2f784d51189870bd834e9284812f (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/demux.c')
-rw-r--r-- | libavformat/demux.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/demux.c b/libavformat/demux.c index ec34b65288..0d99fdb508 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -194,6 +194,18 @@ static int update_stream_avctx(AVFormatContext *s) sti->parser = NULL; } + /* if the demuxer exports old channel layouts, convert it to new */ + if (!st->codecpar->ch_layout.nb_channels && + st->codecpar->channels) { + if (st->codecpar->channel_layout) { + av_channel_layout_from_mask(&st->codecpar->ch_layout, + st->codecpar->channel_layout); + } else { + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + st->codecpar->ch_layout.nb_channels = st->codecpar->channels; + } + } + /* update internal codec context, for the parser */ ret = avcodec_parameters_to_context(sti->avctx, st->codecpar); if (ret < 0) |