summaryrefslogtreecommitdiff
path: root/libavformat/rsd.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-05-13 11:11:26 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:36 -0300
commit271a9b632cb09b076f36c4091c636db3a79e35af (patch)
treeb287917bc4399d62bdf63975e4a75f9d06d9db60 /libavformat/rsd.c
parent2a4a3f51765a88376a0e5c0bcfc8da63f6a6fe62 (diff)
rsd: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/rsd.c')
-rw-r--r--libavformat/rsd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/libavformat/rsd.c b/libavformat/rsd.c
index ba3b3429b9..65316f0219 100644
--- a/libavformat/rsd.c
+++ b/libavformat/rsd.c
@@ -81,9 +81,9 @@ static int rsd_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- par->channels = avio_rl32(pb);
- if (par->channels <= 0 || par->channels > INT_MAX / 36) {
- av_log(s, AV_LOG_ERROR, "Invalid number of channels: %d\n", par->channels);
+ par->ch_layout.nb_channels = avio_rl32(pb);
+ if (par->ch_layout.nb_channels <= 0 || par->ch_layout.nb_channels > INT_MAX / 36) {
+ av_log(s, AV_LOG_ERROR, "Invalid number of channels: %d\n", par->ch_layout.nb_channels);
return AVERROR_INVALIDDATA;
}
@@ -102,17 +102,17 @@ static int rsd_read_header(AVFormatContext *s)
memset(par->extradata, 0, 34);
break;
case AV_CODEC_ID_ADPCM_PSX:
- par->block_align = 16 * par->channels;
+ par->block_align = 16 * par->ch_layout.nb_channels;
break;
case AV_CODEC_ID_ADPCM_IMA_RAD:
- par->block_align = 20 * par->channels;
+ par->block_align = 20 * par->ch_layout.nb_channels;
break;
case AV_CODEC_ID_ADPCM_IMA_WAV:
if (version == 2)
start = avio_rl32(pb);
par->bits_per_coded_sample = 4;
- par->block_align = 36 * par->channels;
+ par->block_align = 36 * par->ch_layout.nb_channels;
break;
case AV_CODEC_ID_ADPCM_THP_LE:
/* RSD3GADP is mono, so only alloc enough memory
@@ -124,13 +124,13 @@ static int rsd_read_header(AVFormatContext *s)
return ret;
break;
case AV_CODEC_ID_ADPCM_THP:
- par->block_align = 8 * par->channels;
+ par->block_align = 8 * par->ch_layout.nb_channels;
avio_skip(s->pb, 0x1A4 - avio_tell(s->pb));
- if ((ret = ff_alloc_extradata(st->codecpar, 32 * par->channels)) < 0)
+ if ((ret = ff_alloc_extradata(st->codecpar, 32 * par->ch_layout.nb_channels)) < 0)
return ret;
- for (i = 0; i < par->channels; i++) {
+ for (i = 0; i < par->ch_layout.nb_channels; i++) {
if (avio_feof(pb))
return AVERROR_EOF;
avio_read(s->pb, st->codecpar->extradata + 32 * i, 32);
@@ -159,11 +159,11 @@ static int rsd_read_header(AVFormatContext *s)
st->duration = av_get_audio_frame_duration2(par, remaining - start);
break;
case AV_CODEC_ID_ADPCM_THP:
- st->duration = (remaining - start) / (8 * par->channels) * 14;
+ st->duration = (remaining - start) / (8 * par->ch_layout.nb_channels) * 14;
break;
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_S16BE:
- st->duration = (remaining - start) / 2 / par->channels;
+ st->duration = (remaining - start) / 2 / par->ch_layout.nb_channels;
}
}
@@ -194,14 +194,14 @@ static int rsd_read_packet(AVFormatContext *s, AVPacket *pkt)
par->codec_id == AV_CODEC_ID_XMA2) {
ret = av_get_packet(s->pb, pkt, par->block_align);
} else if (par->codec_tag == MKTAG('W','A','D','P') &&
- par->channels > 1) {
+ par->ch_layout.nb_channels > 1) {
int i, ch;
ret = av_new_packet(pkt, par->block_align);
if (ret < 0)
return ret;
for (i = 0; i < 4; i++) {
- for (ch = 0; ch < par->channels; ch++) {
+ for (ch = 0; ch < par->ch_layout.nb_channels; ch++) {
pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);
pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);
}