aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-08-23 23:01:06 -0300
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:30 -0300
commit641761ac6e05f1cdafbd1a52b76a90b124daccd0 (patch)
tree2a85c1968c06e7df19eaf25a27c7e18d34ce90e9
parentffc4fd3cc2ccb2cadb71f19849842b18ca1281c6 (diff)
downloadffmpeg-641761ac6e05f1cdafbd1a52b76a90b124daccd0.tar.gz
alp: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavformat/alp.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/libavformat/alp.c b/libavformat/alp.c
index f46bdb4511..444b55dd77 100644
--- a/libavformat/alp.c
+++ b/libavformat/alp.c
@@ -119,18 +119,14 @@ static int alp_read_header(AVFormatContext *s)
par->codec_id = AV_CODEC_ID_ADPCM_IMA_ALP;
par->format = AV_SAMPLE_FMT_S16;
par->sample_rate = hdr->sample_rate;
- par->channels = hdr->num_channels;
- if (hdr->num_channels == 1)
- par->channel_layout = AV_CH_LAYOUT_MONO;
- else if (hdr->num_channels == 2)
- par->channel_layout = AV_CH_LAYOUT_STEREO;
- else
+ if (hdr->num_channels > 2)
return AVERROR_INVALIDDATA;
+ av_channel_layout_default(&par->ch_layout, hdr->num_channels);
par->bits_per_coded_sample = 4;
par->block_align = 1;
- par->bit_rate = par->channels *
+ par->bit_rate = par->ch_layout.nb_channels *
par->sample_rate *
par->bits_per_coded_sample;
@@ -148,7 +144,7 @@ static int alp_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;
- pkt->duration = ret * 2 / par->channels;
+ pkt->duration = ret * 2 / par->ch_layout.nb_channels;
return 0;
}
@@ -202,7 +198,7 @@ static int alp_write_init(AVFormatContext *s)
return AVERROR(EINVAL);
}
- if (par->channels > 2) {
+ if (par->ch_layout.nb_channels > 2) {
av_log(s, AV_LOG_ERROR, "A maximum of 2 channels are supported\n");
return AVERROR(EINVAL);
}
@@ -228,7 +224,7 @@ static int alp_write_header(AVFormatContext *s)
avio_wl32(s->pb, alp->type == ALP_TYPE_PCM ? 12 : 8);
avio_write(s->pb, "ADPCM", 6);
avio_w8(s->pb, 0);
- avio_w8(s->pb, par->channels);
+ avio_w8(s->pb, par->ch_layout.nb_channels);
if (alp->type == ALP_TYPE_PCM)
avio_wl32(s->pb, par->sample_rate);