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/rtpdec_h264.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/rtpdec_h264.c')
-rw-r--r-- | libavformat/rtpdec_h264.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c index e8543ee06d..d7b39ac895 100644 --- a/libavformat/rtpdec_h264.c +++ b/libavformat/rtpdec_h264.c @@ -146,7 +146,7 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s, PayloadContext *h264_data, const char *attr, const char *value) { - AVCodecContext *codec = stream->codec; + AVCodecParameters *par = stream->codecpar; if (!strcmp(attr, "packetization-mode")) { av_log(s, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value)); @@ -166,18 +166,18 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s, parse_profile_level_id(s, h264_data, value); } else if (!strcmp(attr, "sprop-parameter-sets")) { int ret; - codec->extradata_size = 0; - av_freep(&codec->extradata); - ret = ff_h264_parse_sprop_parameter_sets(s, &codec->extradata, - &codec->extradata_size, value); + par->extradata_size = 0; + av_freep(&par->extradata); + ret = ff_h264_parse_sprop_parameter_sets(s, &par->extradata, + &par->extradata_size, value); av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)\n", - codec->extradata, codec->extradata_size); + par->extradata, par->extradata_size); return ret; } return 0; } -void ff_h264_parse_framesize(AVCodecContext *codec, const char *p) +void ff_h264_parse_framesize(AVCodecParameters *par, const char *p) { char buf1[50]; char *dst = buf1; @@ -195,8 +195,8 @@ void ff_h264_parse_framesize(AVCodecContext *codec, const char *p) // a='framesize:96 320-240' // set our parameters - codec->width = atoi(buf1); - codec->height = atoi(p + 1); // skip the - + par->width = atoi(buf1); + par->height = atoi(p + 1); // skip the - } int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, AVPacket *pkt, @@ -396,7 +396,7 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index, stream = s->streams[st_index]; if (av_strstart(p, "framesize:", &p)) { - ff_h264_parse_framesize(stream->codec, p); + ff_h264_parse_framesize(stream->codecpar, p); } else if (av_strstart(p, "fmtp:", &p)) { return ff_parse_fmtp(s, stream, h264_data, p, sdp_parse_fmtp_config_h264); } else if (av_strstart(p, "cliprect:", &p)) { |