diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-04-07 18:08:41 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:39 -0300 |
commit | 548aeb93834b8425c86d1ce60fddc1d41805724d (patch) | |
tree | 0e6f61649b3a70f407e225d247ba5ef0fe812a48 /libavformat/demux.c | |
parent | b6746b74621798d9b6697cd7369ee41625b375df (diff) | |
download | ffmpeg-548aeb93834b8425c86d1ce60fddc1d41805724d.tar.gz |
lavc: switch to the new channel layout API
Since the request_channel_layout is used only by a handful of codecs,
move the option to codec private contexts.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/demux.c')
-rw-r--r-- | libavformat/demux.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/libavformat/demux.c b/libavformat/demux.c index f7ebba2474..938af13831 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -1329,16 +1329,38 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) } got_packet = 1; } else if (st->discard < AVDISCARD_ALL) { +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + int orig_channels = sti->avctx->channels; + uint64_t orig_channel_layout = sti->avctx->channel_layout; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if ((ret = parse_packet(s, pkt, pkt->stream_index, 0)) < 0) return ret; st->codecpar->sample_rate = sti->avctx->sample_rate; st->codecpar->bit_rate = sti->avctx->bit_rate; #if FF_API_OLD_CHANNEL_LAYOUT FF_DISABLE_DEPRECATION_WARNINGS - st->codecpar->channels = sti->avctx->channels; - st->codecpar->channel_layout = sti->avctx->channel_layout; + /* parser setting the old-style fields */ + if (sti->avctx->channels != orig_channels || + sti->avctx->channel_layout != orig_channel_layout) { + av_channel_layout_uninit(&sti->avctx->ch_layout); + if (sti->avctx->channel_layout) { + av_channel_layout_from_mask(&sti->avctx->ch_layout, sti->avctx->channel_layout); + } else { + sti->avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + sti->avctx->ch_layout.nb_channels = sti->avctx->channels; + } + } + + st->codecpar->channels = sti->avctx->ch_layout.nb_channels; + st->codecpar->channel_layout = sti->avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + sti->avctx->ch_layout.u.mask : 0; FF_ENABLE_DEPRECATION_WARNINGS #endif + ret = av_channel_layout_copy(&st->codecpar->ch_layout, &sti->avctx->ch_layout); + if (ret < 0) + return ret; st->codecpar->codec_id = sti->avctx->codec_id; } else { /* free packet */ @@ -1948,7 +1970,7 @@ static int has_codec_parameters(const AVStream *st, const char **errmsg_ptr) FAIL("unspecified sample format"); if (!avctx->sample_rate) FAIL("unspecified sample rate"); - if (!avctx->channels) + if (!avctx->ch_layout.nb_channels) FAIL("unspecified number of channels"); if (sti->info->found_decoder >= 0 && !sti->nb_decoded_frames && avctx->codec_id == AV_CODEC_ID_DTS) FAIL("no decodable DTS frames"); |