adxdec: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
a4630dc046
commit
5e9dd31e2d
|
@ -56,12 +56,12 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||
if (avio_feof(s->pb))
|
||||
return AVERROR_EOF;
|
||||
|
||||
if (par->channels <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
|
||||
if (par->ch_layout.nb_channels <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->ch_layout.nb_channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
size = BLOCK_SIZE * par->channels;
|
||||
size = BLOCK_SIZE * par->ch_layout.nb_channels;
|
||||
|
||||
pkt->pos = avio_tell(s->pb);
|
||||
pkt->stream_index = 0;
|
||||
|
@ -79,8 +79,8 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||
size = ret;
|
||||
}
|
||||
|
||||
pkt->duration = size / (BLOCK_SIZE * par->channels);
|
||||
pkt->pts = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->channels);
|
||||
pkt->duration = size / (BLOCK_SIZE * par->ch_layout.nb_channels);
|
||||
pkt->pts = (pkt->pos - c->header_size) / (BLOCK_SIZE * par->ch_layout.nb_channels);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ static int adx_read_header(AVFormatContext *s)
|
|||
ADXDemuxerContext *c = s->priv_data;
|
||||
AVCodecParameters *par;
|
||||
int ret;
|
||||
int channels;
|
||||
|
||||
AVStream *st = avformat_new_stream(s, NULL);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
|
@ -107,11 +109,11 @@ static int adx_read_header(AVFormatContext *s)
|
|||
av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
par->channels = AV_RB8 (par->extradata + 7);
|
||||
channels = AV_RB8 (par->extradata + 7);
|
||||
par->sample_rate = AV_RB32(par->extradata + 8);
|
||||
|
||||
if (par->channels <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
|
||||
if (channels <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
@ -120,9 +122,10 @@ static int adx_read_header(AVFormatContext *s)
|
|||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
par->ch_layout.nb_channels = channels;
|
||||
par->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
par->codec_id = s->iformat->raw_codec_id;
|
||||
par->bit_rate = (int64_t)par->sample_rate * par->channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
|
||||
par->bit_rate = (int64_t)par->sample_rate * par->ch_layout.nb_channels * BLOCK_SIZE * 8LL / BLOCK_SAMPLES;
|
||||
|
||||
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user