diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2017-03-31 18:36:57 +0200 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:37 -0300 |
commit | 84aee1dc1eef0154e8adfdadf3735f78a63379e8 (patch) | |
tree | fac66f3f1199066a34b6d2bce1f68b36f83308a6 /libavformat | |
parent | a6b5153df5bd6181b5e99251a7077826222fb331 (diff) | |
download | ffmpeg-84aee1dc1eef0154e8adfdadf3735f78a63379e8.tar.gz |
sox: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/soxdec.c | 13 | ||||
-rw-r--r-- | libavformat/soxenc.c | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/libavformat/soxdec.c b/libavformat/soxdec.c index 83fb5e3758..10bea25232 100644 --- a/libavformat/soxdec.c +++ b/libavformat/soxdec.c @@ -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); diff --git a/libavformat/soxenc.c b/libavformat/soxenc.c index e24501bacd..ac01f97df5 100644 --- a/libavformat/soxenc.c +++ b/libavformat/soxenc.c @@ -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"); |