Merge commit '9200514ad8717c63f82101dc394f4378854325bf'

* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis
2016-04-10 20:58:15 +01:00
362 changed files with 6553 additions and 6077 deletions

View File

@@ -99,7 +99,7 @@ static int read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
@@ -197,15 +197,15 @@ static int read_header(AVFormatContext *s)
}
loop = avio_r8(s->pb); // loop flag
st->codec->codec_id = codec;
st->codec->channels = avio_r8(s->pb);
if (!st->codec->channels)
st->codecpar->codec_id = codec;
st->codecpar->channels = avio_r8(s->pb);
if (!st->codecpar->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1); // padding
st->codec->sample_rate = bfstm ? read32(s) : read16(s);
if (st->codec->sample_rate <= 0)
st->codecpar->sample_rate = bfstm ? read32(s) : read16(s);
if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
if (!bfstm)
@@ -214,7 +214,7 @@ static int read_header(AVFormatContext *s)
if (loop) {
if (av_dict_set_int(&s->metadata, "loop_start",
av_rescale(read32(s), AV_TIME_BASE,
st->codec->sample_rate),
st->codecpar->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
@@ -223,7 +223,7 @@ static int read_header(AVFormatContext *s)
st->start_time = 0;
st->duration = read32(s);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (!bfstm)
start = read32(s);
@@ -235,14 +235,14 @@ static int read_header(AVFormatContext *s)
}
b->block_size = read32(s);
if (b->block_size > UINT32_MAX / st->codec->channels)
if (b->block_size > UINT32_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(s);
b->last_block_used_bytes = read32(s);
b->last_block_samples = read32(s);
b->last_block_size = read32(s);
if (b->last_block_size > UINT32_MAX / st->codec->channels)
if (b->last_block_size > UINT32_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
@@ -255,16 +255,16 @@ static int read_header(AVFormatContext *s)
if (!bfstm)
toffset = read32(s) + 16LL;
else
toffset = toffset + read32(s) + st->codec->channels * 8 - 8;
toffset = toffset + read32(s) + st->codecpar->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
b->table = av_mallocz(32 * st->codec->channels);
b->table = av_mallocz(32 * st->codecpar->channels);
if (!b->table)
return AVERROR(ENOMEM);
for (ch = 0; ch < st->codec->channels; ch++) {
for (ch = 0; ch < st->codecpar->channels; ch++) {
if (avio_read(s->pb, b->table + ch * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
@@ -295,7 +295,7 @@ static int read_header(AVFormatContext *s)
codec != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
asize = b->block_count * st->codec->channels * 4;
asize = b->block_count * st->codecpar->channels * 4;
if (size < asize) {
ret = AVERROR_INVALIDDATA;
goto fail;
@@ -357,7 +357,7 @@ fail:
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
BRSTMDemuxContext *b = s->priv_data;
uint32_t samples, size, skip = 0;
int ret, i;
@@ -385,8 +385,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
}
if (codec->codec_id == AV_CODEC_ID_ADPCM_THP ||
codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
if (par->codec_id == AV_CODEC_ID_ADPCM_THP ||
par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
uint8_t *dst;
if (!b->adpc) {
@@ -394,30 +394,30 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_INVALIDDATA;
}
if (!b->table) {
b->table = av_mallocz(32 * codec->channels);
b->table = av_mallocz(32 * par->channels);
if (!b->table)
return AVERROR(ENOMEM);
}
if (size > (INT_MAX - 32 - 4) ||
(32 + 4 + size) > (INT_MAX / codec->channels) ||
(32 + 4 + size) * codec->channels > INT_MAX - 8)
(32 + 4 + size) > (INT_MAX / par->channels) ||
(32 + 4 + size) * par->channels > INT_MAX - 8)
return AVERROR_INVALIDDATA;
if (av_new_packet(pkt, 8 + (32 + 4 + size) * codec->channels) < 0)
if (av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels) < 0)
return AVERROR(ENOMEM);
dst = pkt->data;
if (codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
bytestream_put_le32(&dst, size * codec->channels);
if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
bytestream_put_le32(&dst, size * par->channels);
bytestream_put_le32(&dst, samples);
} else {
bytestream_put_be32(&dst, size * codec->channels);
bytestream_put_be32(&dst, size * par->channels);
bytestream_put_be32(&dst, samples);
}
bytestream_put_buffer(&dst, b->table, 32 * codec->channels);
bytestream_put_buffer(&dst, b->adpc + 4 * codec->channels *
(b->current_block - 1), 4 * codec->channels);
bytestream_put_buffer(&dst, b->table, 32 * par->channels);
bytestream_put_buffer(&dst, b->adpc + 4 * par->channels *
(b->current_block - 1), 4 * par->channels);
for (i = 0; i < codec->channels; i++) {
for (i = 0; i < par->channels; i++) {
ret = avio_read(s->pb, dst, size);
dst += size;
avio_skip(s->pb, skip);
@@ -428,7 +428,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
pkt->duration = samples;
} else {
size *= codec->channels;
size *= par->channels;
ret = av_get_packet(s->pb, pkt, size);
}
@@ -449,7 +449,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
timestamp /= b->samples_per_block;
ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size *
st->codec->channels, SEEK_SET);
st->codecpar->channels, SEEK_SET);
if (ret < 0)
return ret;