From c30e22c9fb1a3d1c3b62c6bc1ff9f8b6a0f41dcc Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 14 May 2019 18:49:07 +0200 Subject: 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 --- libavformat/demux.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libavformat/demux.c') 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) -- cgit v1.2.3