1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

lavf: convert the generic layer to the new channel layout

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Anton Khirnov 2019-05-15 09:36:26 +02:00 committed by James Almer
parent c30e22c9fb
commit ac10e3c47c
3 changed files with 35 additions and 3 deletions

View File

@ -206,6 +206,18 @@ static int update_stream_avctx(AVFormatContext *s)
} }
} }
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
if (st->codecpar->ch_layout.nb_channels &&
!st->codecpar->channels) {
st->codecpar->channels = st->codecpar->ch_layout.nb_channels;
st->codecpar->channel_layout = st->codecpar->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ?
st->codecpar->ch_layout.u.mask : 0;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
/* update internal codec context, for the parser */ /* update internal codec context, for the parser */
ret = avcodec_parameters_to_context(sti->avctx, st->codecpar); ret = avcodec_parameters_to_context(sti->avctx, st->codecpar);
if (ret < 0) if (ret < 0)
@ -1333,8 +1345,12 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
return ret; return ret;
st->codecpar->sample_rate = sti->avctx->sample_rate; st->codecpar->sample_rate = sti->avctx->sample_rate;
st->codecpar->bit_rate = sti->avctx->bit_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->channels = sti->avctx->channels;
st->codecpar->channel_layout = sti->avctx->channel_layout; st->codecpar->channel_layout = sti->avctx->channel_layout;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
st->codecpar->codec_id = sti->avctx->codec_id; st->codecpar->codec_id = sti->avctx->codec_id;
} else { } else {
/* free packet */ /* free packet */

View File

@ -282,8 +282,24 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
par->ch_layout.u.mask : 0; par->ch_layout.u.mask : 0;
} }
#if FF_API_OLD_CHANNEL_LAYOUT
FF_DISABLE_DEPRECATION_WARNINGS
/* if the caller is using the deprecated channel layout API,
* convert it to the new style */
if (!par->ch_layout.nb_channels &&
par->channels) {
if (par->channel_layout) {
av_channel_layout_from_mask(&par->ch_layout, par->channel_layout);
} else {
par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
par->ch_layout.nb_channels = par->channels;
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (!par->block_align) if (!par->block_align)
par->block_align = par->channels * par->block_align = par->ch_layout.nb_channels *
av_get_bits_per_sample(par->codec_id) >> 3; av_get_bits_per_sample(par->codec_id) >> 3;
break; break;
case AVMEDIA_TYPE_VIDEO: case AVMEDIA_TYPE_VIDEO:

View File

@ -525,7 +525,7 @@ int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
continue; continue;
if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb) if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb)
continue; continue;
if (type == AVMEDIA_TYPE_AUDIO && !(par->channels && par->sample_rate)) if (type == AVMEDIA_TYPE_AUDIO && !(par->ch_layout.nb_channels && par->sample_rate))
continue; continue;
if (decoder_ret) { if (decoder_ret) {
decoder = ff_find_decoder(ic, st, par->codec_id); decoder = ff_find_decoder(ic, st, par->codec_id);
@ -1523,7 +1523,7 @@ static int match_stream_specifier(const AVFormatContext *s, const AVStream *st,
int val; int val;
switch (par->codec_type) { switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO: case AVMEDIA_TYPE_AUDIO:
val = par->sample_rate && par->channels; val = par->sample_rate && par->ch_layout.nb_channels;
if (par->format == AV_SAMPLE_FMT_NONE) if (par->format == AV_SAMPLE_FMT_NONE)
return 0; return 0;
break; break;