[FFmpeg-devel] [PATCH 120/281] pcm: convert to new channel layout API
James Almer
jamrial at gmail.com
Thu Jan 13 03:57:37 EET 2022
From: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Anton Khirnov <anton at khirnov.net>
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/pcm.c | 2 +-
libavformat/pcmdec.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavformat/pcm.c b/libavformat/pcm.c
index e91117ce5a..9741f73667 100644
--- a/libavformat/pcm.c
+++ b/libavformat/pcm.c
@@ -63,7 +63,7 @@ int ff_pcm_read_seek(AVFormatContext *s,
st = s->streams[0];
block_align = st->codecpar->block_align ? st->codecpar->block_align :
- (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3;
+ (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->ch_layout.nb_channels) >> 3;
byte_rate = st->codecpar->bit_rate ? st->codecpar->bit_rate >> 3 :
block_align * st->codecpar->sample_rate;
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 63539a47c0..34e60da1df 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -48,7 +48,8 @@ static int pcm_read_header(AVFormatContext *s)
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->codec_id = s->iformat->raw_codec_id;
par->sample_rate = s1->sample_rate;
- par->channels = s1->channels;
+ par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+ par->ch_layout.nb_channels = s1->channels;
av_opt_get(s->pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type);
if (mime_type && s->iformat->mime_type) {
@@ -77,7 +78,7 @@ static int pcm_read_header(AVFormatContext *s)
}
par->sample_rate = rate;
if (channels > 0)
- par->channels = channels;
+ par->ch_layout.nb_channels = channels;
if (little_endian)
par->codec_id = AV_CODEC_ID_PCM_S16LE;
}
@@ -88,7 +89,7 @@ static int pcm_read_header(AVFormatContext *s)
av_assert0(par->bits_per_coded_sample > 0);
- par->block_align = par->bits_per_coded_sample * par->channels / 8;
+ par->block_align = par->bits_per_coded_sample * par->ch_layout.nb_channels / 8;
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
return 0;
--
2.34.1
More information about the ffmpeg-devel
mailing list