Commit 641761ac authored by James Almer's avatar James Almer

alp: convert to new channel layout API

Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent ffc4fd3c
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment