[FFmpeg-devel] [PATCH 018/281] adxdec: convert to new channel layout API
James Almer
jamrial at gmail.com
Thu Jan 13 03:49:40 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/adxdec.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavformat/adxdec.c b/libavformat/adxdec.c
index d91d43d114..fa91080f41 100644
--- a/libavformat/adxdec.c
+++ b/libavformat/adxdec.c
@@ -56,12 +56,12 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
if (avio_feof(s->pb))
return AVERROR_EOF;
- if (par->channels <= 0) {
- av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
+ if (par->ch_layout.nb_channels <= 0) {
+ av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->ch_layout.nb_channels);
return AVERROR_INVALIDDATA;
}
- size = BLOCK_SIZE * par->channels;
+ size = BLOCK_SIZE * par->ch_layout.nb_channels;
pkt->pos = avio_tell(s->pb);
pkt->stream_index = 0;
@@ -79,8 +79,8 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
size = ret;
}
- pkt->duration = size / (BLOCK_SIZE * par->channels);
- pkt->pts = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->channels);
+ pkt->duration = size / (BLOCK_SIZE * par->ch_layout.nb_channels);
+ pkt->pts = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->ch_layout.nb_channels);
return 0;
}
@@ -90,6 +90,8 @@ static int adx_read_header(AVFormatContext *s)
ADXDemuxerContext *c = s->priv_data;
AVCodecParameters *par;
int ret;
+ int channels;
+
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
@@ -107,11 +109,11 @@ static int adx_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
return AVERROR_INVALIDDATA;
}
- par->channels = AV_RB8 (par->extradata + 7);
+ channels = AV_RB8 (par->extradata + 7);
par->sample_rate = AV_RB32(par->extradata + 8);
- if (par->channels <= 0) {
- av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
+ if (channels <= 0) {
+ av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", channels);
return AVERROR_INVALIDDATA;
}
@@ -120,9 +122,11 @@ static int adx_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
+ par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
+ par->ch_layout.nb_channels = channels;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->codec_id = s->iformat->raw_codec_id;
- par->bit_rate = (int64_t)par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
+ par->bit_rate = (int64_t)par->sample_rate * par->ch_layout.nb_channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
--
2.34.1
More information about the ffmpeg-devel
mailing list