mirror of https://git.ffmpeg.org/ffmpeg.git
alp: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
ffc4fd3cc2
commit
641761ac6e
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue