summaryrefslogtreecommitdiff
path: root/libavformat/smush.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/smush.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/smush.c')
-rw-r--r--libavformat/smush.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/libavformat/smush.c b/libavformat/smush.c
index 94ecb5cb17..262b941241 100644
--- a/libavformat/smush.c
+++ b/libavformat/smush.c
@@ -151,23 +151,23 @@ static int smush_read_header(AVFormatContext *ctx)
vst->duration =
vst->nb_frames = nframes;
vst->avg_frame_rate = av_inv_q(vst->time_base);
- vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- vst->codec->codec_id = AV_CODEC_ID_SANM;
- vst->codec->codec_tag = 0;
- vst->codec->width = width;
- vst->codec->height = height;
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ vst->codecpar->codec_id = AV_CODEC_ID_SANM;
+ vst->codecpar->codec_tag = 0;
+ vst->codecpar->width = width;
+ vst->codecpar->height = height;
if (!smush->version) {
- av_free(vst->codec->extradata);
- vst->codec->extradata_size = 1024 + 2;
- vst->codec->extradata = av_malloc(vst->codec->extradata_size +
- AV_INPUT_BUFFER_PADDING_SIZE);
- if (!vst->codec->extradata)
+ av_free(vst->codecpar->extradata);
+ vst->codecpar->extradata_size = 1024 + 2;
+ vst->codecpar->extradata = av_malloc(vst->codecpar->extradata_size +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!vst->codecpar->extradata)
return AVERROR(ENOMEM);
- AV_WL16(vst->codec->extradata, subversion);
+ AV_WL16(vst->codecpar->extradata, subversion);
for (i = 0; i < 256; i++)
- AV_WL32(vst->codec->extradata + 2 + i * 4, palette[i]);
+ AV_WL32(vst->codecpar->extradata + 2 + i * 4, palette[i]);
}
if (got_audio) {
@@ -178,13 +178,13 @@ static int smush_read_header(AVFormatContext *ctx)
smush->audio_stream_index = ast->index;
ast->start_time = 0;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_id = AV_CODEC_ID_ADPCM_VIMA;
- ast->codec->codec_tag = 0;
- ast->codec->sample_rate = sample_rate;
- ast->codec->channels = channels;
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_VIMA;
+ ast->codecpar->codec_tag = 0;
+ ast->codecpar->sample_rate = sample_rate;
+ ast->codecpar->channels = channels;
- avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
}
return 0;