summaryrefslogtreecommitdiff
path: root/libavformat/kvag.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-08-23 23:28:39 -0300
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:34 -0300
commit1c22a29e1a5b7c75ab79a3aedb370d8d95a90ab4 (patch)
tree8e89d20adf8e508e08ffccb2c2d9e2b45efc5ed0 /libavformat/kvag.c
parentef423132eb3a9b06ebf341377635e2b0020ca69a (diff)
kvag: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/kvag.c')
-rw-r--r--libavformat/kvag.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libavformat/kvag.c b/libavformat/kvag.c
index a277c28128..5cb856cf07 100644
--- a/libavformat/kvag.c
+++ b/libavformat/kvag.c
@@ -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;