vpk: convert to new channel layout API

Signed-off-by: James Almer <jamrial@gmail.com>
release/5.1
Anton Khirnov 6 years ago committed by James Almer
parent a3129027eb
commit 8eda3c7f91
  1. 14
      libavformat/vpk.c

@ -59,14 +59,14 @@ static int vpk_read_header(AVFormatContext *s)
st->codecpar->sample_rate = avio_rl32(s->pb); st->codecpar->sample_rate = avio_rl32(s->pb);
if (st->codecpar->sample_rate <= 0 || st->codecpar->block_align <= 0) if (st->codecpar->sample_rate <= 0 || st->codecpar->block_align <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
st->codecpar->channels = avio_rl32(s->pb); st->codecpar->ch_layout.nb_channels = avio_rl32(s->pb);
if (st->codecpar->channels <= 0) if (st->codecpar->ch_layout.nb_channels <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
samples_per_block = ((st->codecpar->block_align / st->codecpar->channels) * 28LL) / 16; samples_per_block = ((st->codecpar->block_align / st->codecpar->ch_layout.nb_channels) * 28LL) / 16;
if (samples_per_block <= 0) if (samples_per_block <= 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
vpk->block_count = (st->duration + (samples_per_block - 1)) / samples_per_block; vpk->block_count = (st->duration + (samples_per_block - 1)) / samples_per_block;
vpk->last_block_size = (st->duration % samples_per_block) * 16 * st->codecpar->channels / 28; vpk->last_block_size = (st->duration % samples_per_block) * 16 * st->codecpar->ch_layout.nb_channels / 28;
if (offset < avio_tell(s->pb)) if (offset < avio_tell(s->pb))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
@ -85,14 +85,14 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
vpk->current_block++; vpk->current_block++;
if (vpk->current_block == vpk->block_count) { if (vpk->current_block == vpk->block_count) {
unsigned size = vpk->last_block_size / par->channels; unsigned size = vpk->last_block_size / par->ch_layout.nb_channels;
unsigned skip = (par->block_align - vpk->last_block_size) / par->channels; unsigned skip = (par->block_align - vpk->last_block_size) / par->ch_layout.nb_channels;
uint64_t pos = avio_tell(s->pb); uint64_t pos = avio_tell(s->pb);
ret = av_new_packet(pkt, vpk->last_block_size); ret = av_new_packet(pkt, vpk->last_block_size);
if (ret < 0) if (ret < 0)
return ret; return ret;
for (i = 0; i < par->channels; i++) { for (i = 0; i < par->ch_layout.nb_channels; i++) {
ret = avio_read(s->pb, pkt->data + i * size, size); ret = avio_read(s->pb, pkt->data + i * size, size);
avio_skip(s->pb, skip); avio_skip(s->pb, skip);
if (ret != size) { if (ret != size) {

Loading…
Cancel
Save