mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-28 01:31:00 +00:00
kvag: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
ef423132eb
commit
1c22a29e1a
@ -71,18 +71,11 @@ static int kvag_read_header(AVFormatContext *s)
|
||||
par->codec_id = AV_CODEC_ID_ADPCM_IMA_SSI;
|
||||
par->format = AV_SAMPLE_FMT_S16;
|
||||
|
||||
if (hdr.stereo) {
|
||||
par->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||
par->channels = 2;
|
||||
} else {
|
||||
par->channel_layout = AV_CH_LAYOUT_MONO;
|
||||
par->channels = 1;
|
||||
}
|
||||
|
||||
av_channel_layout_default(&par->ch_layout, !!hdr.stereo + 1);
|
||||
par->sample_rate = hdr.sample_rate;
|
||||
par->bits_per_coded_sample = 4;
|
||||
par->block_align = 1;
|
||||
par->bit_rate = par->channels *
|
||||
par->bit_rate = par->ch_layout.nb_channels *
|
||||
(uint64_t)par->sample_rate *
|
||||
par->bits_per_coded_sample;
|
||||
|
||||
@ -90,7 +83,7 @@ static int kvag_read_header(AVFormatContext *s)
|
||||
st->start_time = 0;
|
||||
st->duration = hdr.data_size *
|
||||
(8 / par->bits_per_coded_sample) /
|
||||
par->channels;
|
||||
par->ch_layout.nb_channels;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -105,7 +98,7 @@ static int kvag_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||
pkt->stream_index = 0;
|
||||
pkt->duration = ret * (8 / par->bits_per_coded_sample) / par->channels;
|
||||
pkt->duration = ret * (8 / par->bits_per_coded_sample) / par->ch_layout.nb_channels;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -147,7 +140,7 @@ static int kvag_write_init(AVFormatContext *s)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
if (par->channels > 2) {
|
||||
if (par->ch_layout.nb_channels > 2) {
|
||||
av_log(s, AV_LOG_ERROR, "KVAG files only support up to 2 channels\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
@ -168,7 +161,7 @@ static int kvag_write_header(AVFormatContext *s)
|
||||
AV_WL32(buf + 0, KVAG_TAG);
|
||||
AV_WL32(buf + 4, 0); /* Data size, we fix this up later. */
|
||||
AV_WL32(buf + 8, par->sample_rate);
|
||||
AV_WL16(buf + 12, par->channels == 2);
|
||||
AV_WL16(buf + 12, par->ch_layout.nb_channels == 2);
|
||||
|
||||
avio_write(s->pb, buf, sizeof(buf));
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user