mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
fsb: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
9543161800
commit
07cdec42d1
@ -68,30 +68,30 @@ static int fsb_read_header(AVFormatContext *s)
|
||||
if (par->sample_rate <= 0)
|
||||
return AVERROR_INVALIDDATA;
|
||||
avio_skip(pb, 6);
|
||||
par->channels = avio_rl16(pb);
|
||||
if (!par->channels)
|
||||
par->ch_layout.nb_channels = avio_rl16(pb);
|
||||
if (!par->ch_layout.nb_channels)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
if (format & 0x00000100) {
|
||||
par->codec_id = AV_CODEC_ID_PCM_S16LE;
|
||||
par->block_align = 4096 * par->channels;
|
||||
par->block_align = 4096 * par->ch_layout.nb_channels;
|
||||
} else if (format & 0x00400000) {
|
||||
par->bits_per_coded_sample = 4;
|
||||
par->codec_id = AV_CODEC_ID_ADPCM_IMA_WAV;
|
||||
par->block_align = 36 * par->channels;
|
||||
par->block_align = 36 * par->ch_layout.nb_channels;
|
||||
} else if (format & 0x00800000) {
|
||||
par->codec_id = AV_CODEC_ID_ADPCM_PSX;
|
||||
par->block_align = 16 * par->channels;
|
||||
par->block_align = 16 * par->ch_layout.nb_channels;
|
||||
} else if (format & 0x02000000) {
|
||||
par->codec_id = AV_CODEC_ID_ADPCM_THP;
|
||||
par->block_align = 8 * par->channels;
|
||||
if (par->channels > INT_MAX / 32)
|
||||
par->block_align = 8 * par->ch_layout.nb_channels;
|
||||
if (par->ch_layout.nb_channels > INT_MAX / 32)
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = ff_alloc_extradata(par, 32 * par->channels);
|
||||
ret = ff_alloc_extradata(par, 32 * par->ch_layout.nb_channels);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
avio_seek(pb, 0x68, SEEK_SET);
|
||||
for (c = 0; c < par->channels; c++) {
|
||||
for (c = 0; c < par->ch_layout.nb_channels; c++) {
|
||||
avio_read(pb, par->extradata + 32 * c, 32);
|
||||
avio_skip(pb, 14);
|
||||
}
|
||||
@ -125,8 +125,8 @@ static int fsb_read_header(AVFormatContext *s)
|
||||
return AVERROR_INVALIDDATA;
|
||||
avio_skip(pb, 6);
|
||||
|
||||
par->channels = avio_rl16(pb);
|
||||
if (!par->channels)
|
||||
par->ch_layout.nb_channels = avio_rl16(pb);
|
||||
if (!par->ch_layout.nb_channels)
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
switch (par->codec_id) {
|
||||
@ -138,17 +138,17 @@ static int fsb_read_header(AVFormatContext *s)
|
||||
par->block_align = 2048;
|
||||
break;
|
||||
case AV_CODEC_ID_ADPCM_THP:
|
||||
if (par->channels > INT_MAX / 32)
|
||||
if (par->ch_layout.nb_channels > INT_MAX / 32)
|
||||
return AVERROR_INVALIDDATA;
|
||||
ret = ff_alloc_extradata(par, 32 * par->channels);
|
||||
ret = ff_alloc_extradata(par, 32 * par->ch_layout.nb_channels);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
avio_seek(pb, 0x80, SEEK_SET);
|
||||
for (c = 0; c < par->channels; c++) {
|
||||
for (c = 0; c < par->ch_layout.nb_channels; c++) {
|
||||
avio_read(pb, par->extradata + 32 * c, 32);
|
||||
avio_skip(pb, 14);
|
||||
}
|
||||
par->block_align = 8 * par->channels;
|
||||
par->block_align = 8 * par->ch_layout.nb_channels;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -174,14 +174,14 @@ static int fsb_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
|
||||
pos = avio_tell(s->pb);
|
||||
if (par->codec_id == AV_CODEC_ID_ADPCM_THP &&
|
||||
par->channels > 1) {
|
||||
par->ch_layout.nb_channels > 1) {
|
||||
int i, ch;
|
||||
|
||||
ret = av_new_packet(pkt, par->block_align);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (ch = 0; ch < par->channels; ch++) {
|
||||
for (ch = 0; ch < par->ch_layout.nb_channels; ch++) {
|
||||
pkt->data[ch * 8 + i * 2 + 0] = avio_r8(s->pb);
|
||||
pkt->data[ch * 8 + i * 2 + 1] = avio_r8(s->pb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user