aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/r3d.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/r3d.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/r3d.c')
-rw-r--r--libavformat/r3d.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 9db1d4bbfd..4b28379fc9 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -62,8 +62,8 @@ static int r3d_read_red1(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_id = AV_CODEC_ID_JPEG2000;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_id = AV_CODEC_ID_JPEG2000;
tmp = avio_r8(s->pb); // major version
tmp2 = avio_r8(s->pb); // minor version
@@ -80,8 +80,8 @@ static int r3d_read_red1(AVFormatContext *s)
avio_skip(s->pb, 32); // unknown
- st->codec->width = avio_rb32(s->pb);
- st->codec->height = avio_rb32(s->pb);
+ st->codecpar->width = avio_rb32(s->pb);
+ st->codecpar->height = avio_rb32(s->pb);
tmp = avio_rb16(s->pb); // unknown
av_log(s, AV_LOG_TRACE, "unknown2 %d\n", tmp);
@@ -100,7 +100,7 @@ static int r3d_read_red1(AVFormatContext *s)
av_dict_set(&st->metadata, "filename", filename, 0);
av_log(s, AV_LOG_TRACE, "filename %s\n", filename);
- av_log(s, AV_LOG_TRACE, "resolution %dx%d\n", st->codec->width, st->codec->height);
+ av_log(s, AV_LOG_TRACE, "resolution %dx%d\n", st->codecpar->width, st->codecpar->height);
av_log(s, AV_LOG_TRACE, "timescale %d\n", st->time_base.den);
av_log(s, AV_LOG_TRACE, "frame rate %d/%d\n",
framerate.num, framerate.den);
@@ -282,9 +282,9 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_id = AV_CODEC_ID_PCM_S32BE;
- st->codec->channels = r3d->audio_channels;
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
+ st->codecpar->channels = r3d->audio_channels;
avpriv_set_pts_info(st, 32, 1, s->streams[0]->time_base.den);
} else {
st = s->streams[1];
@@ -292,8 +292,8 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
dts = avio_rb32(s->pb);
- st->codec->sample_rate = avio_rb32(s->pb);
- if (st->codec->sample_rate <= 0) {
+ st->codecpar->sample_rate = avio_rb32(s->pb);
+ if (st->codecpar->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR, "Bad sample rate\n");
return AVERROR_INVALIDDATA;
}
@@ -324,9 +324,9 @@ static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
pkt->stream_index = 1;
pkt->dts = dts;
- pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
+ pkt->duration = av_rescale(samples, st->time_base.den, st->codecpar->sample_rate);
av_log(s, AV_LOG_TRACE, "pkt dts %"PRId64" duration %"PRId64" samples %d sample rate %d\n",
- pkt->dts, pkt->duration, samples, st->codec->sample_rate);
+ pkt->dts, pkt->duration, samples, st->codecpar->sample_rate);
return 0;
}