Commit 84aee1dc authored by Vittorio Giovara's avatar Vittorio Giovara Committed by James Almer

sox: convert to new channel layout API

Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent a6b5153d
......@@ -49,6 +49,7 @@ static int sox_read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
unsigned header_size, comment_size;
double sample_rate, sample_rate_frac;
int channels;
AVStream *st;
st = avformat_new_stream(s, NULL);
......@@ -62,17 +63,19 @@ static int sox_read_header(AVFormatContext *s)
header_size = avio_rl32(pb);
avio_skip(pb, 8); /* sample count */
sample_rate = av_int2double(avio_rl64(pb));
st->codecpar->channels = avio_rl32(pb);
channels = avio_rl32(pb);
comment_size = avio_rl32(pb);
} else {
st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
header_size = avio_rb32(pb);
avio_skip(pb, 8); /* sample count */
sample_rate = av_int2double(avio_rb64(pb));
st->codecpar->channels = avio_rb32(pb);
channels = avio_rb32(pb);
comment_size = avio_rb32(pb);
}
st->codecpar->ch_layout.nb_channels = channels;
if (comment_size > 0xFFFFFFFFU - SOX_FIXED_HDR - 4U) {
av_log(s, AV_LOG_ERROR, "invalid comment size (%u)\n", comment_size);
return AVERROR_INVALIDDATA;
......@@ -90,7 +93,7 @@ static int sox_read_header(AVFormatContext *s)
sample_rate_frac);
if ((header_size + 4) & 7 || header_size < SOX_FIXED_HDR + comment_size
|| st->codecpar->channels > 65535 || st->codecpar->channels <= 0) /* Reserve top 16 bits */ {
|| channels > 65535 || channels <= 0) /* Reserve top 16 bits */ {
av_log(s, AV_LOG_ERROR, "invalid header\n");
return AVERROR_INVALIDDATA;
}
......@@ -115,9 +118,9 @@ static int sox_read_header(AVFormatContext *s)
st->codecpar->bits_per_coded_sample = 32;
st->codecpar->bit_rate = (int64_t)st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample *
st->codecpar->channels;
channels;
st->codecpar->block_align = st->codecpar->bits_per_coded_sample *
st->codecpar->channels / 8;
channels / 8;
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
......
......@@ -61,14 +61,14 @@ static int sox_write_header(AVFormatContext *s)
avio_wl32(pb, sox->header_size);
avio_wl64(pb, 0); /* number of samples */
avio_wl64(pb, av_double2int(par->sample_rate));
avio_wl32(pb, par->channels);
avio_wl32(pb, par->ch_layout.nb_channels);
avio_wl32(pb, comment_size);
} else if (par->codec_id == AV_CODEC_ID_PCM_S32BE) {
ffio_wfourcc(pb, "XoS.");
avio_wb32(pb, sox->header_size);
avio_wb64(pb, 0); /* number of samples */
avio_wb64(pb, av_double2int(par->sample_rate));
avio_wb32(pb, par->channels);
avio_wb32(pb, par->ch_layout.nb_channels);
avio_wb32(pb, comment_size);
} else {
av_log(s, AV_LOG_ERROR, "invalid codec; use pcm_s32le or pcm_s32be\n");
......
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