diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-06-18 20:42:52 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-02-23 17:01:58 +0100 |
commit | 9200514ad8717c63f82101dc394f4378854325bf (patch) | |
tree | 566b8d48565a88303363198acc81de06363daa7a /libavformat/avisynth.c | |
parent | a8068346e48e123f8d3bdf4d64464d81e53e5fc7 (diff) | |
download | ffmpeg-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/avisynth.c')
-rw-r--r-- | libavformat/avisynth.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 1a6a73f53e..b00f9bc42e 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -233,10 +233,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) AviSynthContext *avs = s->priv_data; int planar = 0; // 0: packed, 1: YUV, 2: Y8 - st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - st->codec->codec_id = AV_CODEC_ID_RAWVIDEO; - st->codec->width = avs->vi->width; - st->codec->height = avs->vi->height; + st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; + st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + st->codecpar->width = avs->vi->width; + st->codecpar->height = avs->vi->height; st->time_base = (AVRational) { avs->vi->fps_denominator, avs->vi->fps_numerator }; @@ -249,38 +249,38 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) switch (avs->vi->pixel_type) { #ifdef USING_AVISYNTH case AVS_CS_YV24: - st->codec->pix_fmt = AV_PIX_FMT_YUV444P; - planar = 1; + st->codecpar->format = AV_PIX_FMT_YUV444P; + planar = 1; break; case AVS_CS_YV16: - st->codec->pix_fmt = AV_PIX_FMT_YUV422P; - planar = 1; + st->codecpar->format = AV_PIX_FMT_YUV422P; + planar = 1; break; case AVS_CS_YV411: - st->codec->pix_fmt = AV_PIX_FMT_YUV411P; - planar = 1; + st->codecpar->format = AV_PIX_FMT_YUV411P; + planar = 1; break; case AVS_CS_Y8: - st->codec->pix_fmt = AV_PIX_FMT_GRAY8; - planar = 2; + st->codecpar->format = AV_PIX_FMT_GRAY8; + planar = 2; break; #endif case AVS_CS_BGR24: - st->codec->pix_fmt = AV_PIX_FMT_BGR24; + st->codecpar->format = AV_PIX_FMT_BGR24; break; case AVS_CS_BGR32: - st->codec->pix_fmt = AV_PIX_FMT_RGB32; + st->codecpar->format = AV_PIX_FMT_RGB32; break; case AVS_CS_YUY2: - st->codec->pix_fmt = AV_PIX_FMT_YUYV422; + st->codecpar->format = AV_PIX_FMT_YUYV422; break; case AVS_CS_YV12: - st->codec->pix_fmt = AV_PIX_FMT_YUV420P; - planar = 1; + st->codecpar->format = AV_PIX_FMT_YUV420P; + planar = 1; break; case AVS_CS_I420: // Is this even used anywhere? - st->codec->pix_fmt = AV_PIX_FMT_YUV420P; - planar = 1; + st->codecpar->format = AV_PIX_FMT_YUV420P; + planar = 1; break; default: av_log(s, AV_LOG_ERROR, @@ -309,28 +309,28 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st) { AviSynthContext *avs = s->priv_data; - st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - st->codec->sample_rate = avs->vi->audio_samples_per_second; - st->codec->channels = avs->vi->nchannels; + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; + st->codecpar->sample_rate = avs->vi->audio_samples_per_second; + st->codecpar->channels = avs->vi->nchannels; st->time_base = (AVRational) { 1, avs->vi->audio_samples_per_second }; st->duration = avs->vi->num_audio_samples; switch (avs->vi->sample_type) { case AVS_SAMPLE_INT8: - st->codec->codec_id = AV_CODEC_ID_PCM_U8; + st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; break; case AVS_SAMPLE_INT16: - st->codec->codec_id = AV_CODEC_ID_PCM_S16LE; + st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; break; case AVS_SAMPLE_INT24: - st->codec->codec_id = AV_CODEC_ID_PCM_S24LE; + st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE; break; case AVS_SAMPLE_INT32: - st->codec->codec_id = AV_CODEC_ID_PCM_S32LE; + st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE; break; case AVS_SAMPLE_FLOAT: - st->codec->codec_id = AV_CODEC_ID_PCM_F32LE; + st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE; break; default: av_log(s, AV_LOG_ERROR, @@ -639,7 +639,7 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt) /* If either stream reaches EOF, try to read the other one before * giving up. */ avisynth_next_stream(s, &st, pkt, &discard); - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { ret = avisynth_read_packet_video(s, pkt, discard); if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) { avisynth_next_stream(s, &st, pkt, &discard); @@ -681,7 +681,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index, samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 }; st = s->streams[stream_index]; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { /* AviSynth frame counts are signed int. */ if ((timestamp >= avs->vi->num_frames) || (timestamp > INT_MAX) || |