Skip to content

Commit

Permalink
utils: Make sure to copy all the things that mpegts can set in read_p…
Browse files Browse the repository at this point in the history
…acket

pls don't kill me nev

Fixes #3.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
  • Loading branch information
dwbuiten committed Apr 2, 2016
1 parent 4147215 commit d40f238
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libavformat/utils.c
Expand Up @@ -1422,6 +1422,16 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
if (s->ctx_flags & AVFMTCTX_NOHEADER) {
st->internal->avctx->codec_id = st->codecpar->codec_id;
st->internal->avctx->codec_type = st->codecpar->codec_type;
st->internal->avctx->codec_tag = st->codecpar->codec_tag;
if (!st->internal->avctx->extradata && st->codecpar->extradata_size != 0) {
st->internal->avctx->extradata_size = st->codecpar->extradata_size;
st->internal->avctx->extradata = av_malloc(st->codecpar->extradata_size);
if (!st->internal->avctx->extradata) {
st->internal->avctx->extradata_size = 0;
return AVERROR(ENOMEM);
}
memcpy(st->internal->avctx->extradata, st->codecpar->extradata, st->codecpar->extradata_size);
}
}

if (cur_pkt.pts != AV_NOPTS_VALUE &&
Expand Down

1 comment on commit d40f238

@Nevcairiel
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of piling more fields into this list, how about this idea:

Premises:

  • NOHEADER demuxers can sometimes change streams after their creation, unfortunately no way around that since we don't necessarily know when a stream is "done" (ie. mpegts infos can appear anytime)
  • After find_stream_info, no further updates should be allowed, or well, if they happen noone is going to read them anymore anyway, since AVCodecParameters is used once to init a decoder then.

So:
When a NOHEADER demuxer changes a field after the stream has already been created, it sets a field in AVStream->internal to inform find_stream_info (or read_frame_internal or wherever it makes the most sense, find_stream_info would be saner, imho, but have to see how that plays with parsers) to close any potential decoder for probing, recreate internal->avctx entirely from the codecpar, and go from there.

That way you don't have to pile a list of fields somewhere in here, but all fields can potentially change, and we have a clear condition when to update internal avctx, instead of doing it all the time.

Please sign in to comment.