summaryrefslogtreecommitdiff
path: root/libavformat/vqf.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-06-18 20:42:52 +0200
committerAnton Khirnov <anton@khirnov.net>2016-02-23 17:01:58 +0100
commit9200514ad8717c63f82101dc394f4378854325bf (patch)
tree566b8d48565a88303363198acc81de06363daa7a /libavformat/vqf.c
parenta8068346e48e123f8d3bdf4d64464d81e53e5fc7 (diff)
downloadffmpeg-9200514ad8717c63f82101dc394f4378854325bf.tar.gz
lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which is used by demuxers to export stream parameters to the caller and by muxers to receive stream parameters from the caller. It is also used internally as the codec context that is passed to parsers. In addition, it is also widely used by the callers as the decoding (when demuxer) or encoding (when muxing) context, though this has been officially discouraged since Libav 11. There are multiple important problems with this approach: - the fields in AVCodecContext are in general one of * stream parameters * codec options * codec state However, it's not clear which ones are which. It is consequently unclear which fields are a demuxer allowed to set or a muxer allowed to read. This leads to erratic behaviour depending on whether decoding or encoding is being performed or not (and whether it uses the AVStream embedded codec context). - various synchronization issues arising from the fact that the same context is used by several different APIs (muxers/demuxers, parsers, bitstream filters and encoders/decoders) simultaneously, with there being no clear rules for who can modify what and the different processes being typically delayed with respect to each other. - avformat_find_stream_info() making it necessary to support opening and closing a single codec context multiple times, thus complicating the semantics of freeing various allocated objects in the codec context. Those problems are resolved by replacing the AVStream embedded codec context with a newly added AVCodecParameters instance, which stores only the stream parameters exported by the demuxers or read by the muxers.
Diffstat (limited to 'libavformat/vqf.c')
-rw-r--r--libavformat/vqf.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/libavformat/vqf.c b/libavformat/vqf.c
index baff8fcb53..c3a6a97720 100644
--- a/libavformat/vqf.c
+++ b/libavformat/vqf.c
@@ -104,8 +104,8 @@ static int vqf_read_header(AVFormatContext *s)
header_size = avio_rb32(s->pb);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_TWINVQ;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_TWINVQ;
st->start_time = 0;
do {
@@ -127,12 +127,12 @@ static int vqf_read_header(AVFormatContext *s)
switch(chunk_tag){
case MKTAG('C','O','M','M'):
avio_read(s->pb, comm_chunk, 12);
- st->codec->channels = AV_RB32(comm_chunk ) + 1;
+ st->codecpar->channels = AV_RB32(comm_chunk ) + 1;
read_bitrate = AV_RB32(comm_chunk + 4);
rate_flag = AV_RB32(comm_chunk + 8);
avio_skip(s->pb, len-12);
- st->codec->bit_rate = read_bitrate*1000;
+ st->codecpar->bit_rate = read_bitrate * 1000;
break;
case MKTAG('D','S','I','Z'): // size of compressed data
{
@@ -165,32 +165,32 @@ static int vqf_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "COMM tag not found!\n");
return -1;
case 44:
- st->codec->sample_rate = 44100;
+ st->codecpar->sample_rate = 44100;
break;
case 22:
- st->codec->sample_rate = 22050;
+ st->codecpar->sample_rate = 22050;
break;
case 11:
- st->codec->sample_rate = 11025;
+ st->codecpar->sample_rate = 11025;
break;
default:
if (rate_flag < 8 || rate_flag > 44) {
av_log(s, AV_LOG_ERROR, "Invalid rate flag %d\n", rate_flag);
return AVERROR_INVALIDDATA;
}
- st->codec->sample_rate = rate_flag*1000;
+ st->codecpar->sample_rate = rate_flag*1000;
break;
}
- if (read_bitrate / st->codec->channels < 8 ||
- read_bitrate / st->codec->channels > 48) {
+ if (read_bitrate / st->codecpar->channels < 8 ||
+ read_bitrate / st->codecpar->channels > 48) {
av_log(s, AV_LOG_ERROR, "Invalid bitrate per channel %d\n",
- read_bitrate / st->codec->channels);
+ read_bitrate / st->codecpar->channels);
return AVERROR_INVALIDDATA;
}
- switch (((st->codec->sample_rate/1000) << 8) +
- read_bitrate/st->codec->channels) {
+ switch (((st->codecpar->sample_rate/1000) << 8) +
+ read_bitrate/st->codecpar->channels) {
case (11<<8) + 8 :
case (8 <<8) + 8 :
case (11<<8) + 10:
@@ -208,17 +208,17 @@ static int vqf_read_header(AVFormatContext *s)
break;
default:
av_log(s, AV_LOG_ERROR, "Mode not suported: %d Hz, %d kb/s.\n",
- st->codec->sample_rate, st->codec->bit_rate);
+ st->codecpar->sample_rate, st->codecpar->bit_rate);
return -1;
}
- c->frame_bit_len = st->codec->bit_rate*size/st->codec->sample_rate;
- avpriv_set_pts_info(st, 64, size, st->codec->sample_rate);
+ c->frame_bit_len = st->codecpar->bit_rate*size/st->codecpar->sample_rate;
+ avpriv_set_pts_info(st, 64, size, st->codecpar->sample_rate);
/* put first 12 bytes of COMM chunk in extradata */
- if (!(st->codec->extradata = av_malloc(12 + AV_INPUT_BUFFER_PADDING_SIZE)))
+ if (!(st->codecpar->extradata = av_malloc(12 + AV_INPUT_BUFFER_PADDING_SIZE)))
return AVERROR(ENOMEM);
- st->codec->extradata_size = 12;
- memcpy(st->codec->extradata, comm_chunk, 12);
+ st->codecpar->extradata_size = 12;
+ memcpy(st->codecpar->extradata, comm_chunk, 12);
ff_metadata_conv_ctx(s, NULL, vqf_metadata_conv);
@@ -262,7 +262,7 @@ static int vqf_read_seek(AVFormatContext *s,
int64_t pos;
st = s->streams[stream_index];
- pos = av_rescale_rnd(timestamp * st->codec->bit_rate,
+ pos = av_rescale_rnd(timestamp * st->codecpar->bit_rate,
st->time_base.num,
st->time_base.den * (int64_t)c->frame_bit_len,
(flags & AVSEEK_FLAG_BACKWARD) ?
@@ -270,7 +270,7 @@ static int vqf_read_seek(AVFormatContext *s,
pos *= c->frame_bit_len;
st->cur_dts = av_rescale(pos, st->time_base.den,
- st->codec->bit_rate * (int64_t)st->time_base.num);
+ st->codecpar->bit_rate * (int64_t)st->time_base.num);
if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0)
return ret;