Message ID | ff626e47-f155-f013-07df-757d9f74ac8b@googlemail.com |
---|---|
State | Superseded |
Headers | show |
On Mon, Nov 07, 2016 at 11:49:52PM +0100, Andreas Cadhalpun wrote: > Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > --- > libavformat/mpegts.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > index fad10c6..77d63f2 100644 > --- a/libavformat/mpegts.c > +++ b/libavformat/mpegts.c > @@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s) > /* NOTE1: the bitrate is computed without the FEC */ > /* NOTE2: it is only the bitrate of the start of the stream */ > ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); > + if (ts->pcr_incr <= 0) { > + av_log(s, AV_LOG_ERROR, "invalid pcr increment %d\n", ts->pcr_incr); > + return AVERROR_INVALIDDATA; > + } if a pcr pair is bad i would suggest to run the loop by another iteration also i dont think the demuxer should fail hard and fatal from bad pcr (it would fail completely if it fails at header reading time) [...]
On Mon, 7 Nov 2016, Andreas Cadhalpun wrote: > Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > --- > libavformat/mpegts.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > index fad10c6..77d63f2 100644 > --- a/libavformat/mpegts.c > +++ b/libavformat/mpegts.c > @@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s) > /* NOTE1: the bitrate is computed without the FEC */ > /* NOTE2: it is only the bitrate of the start of the stream */ > ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); > + if (ts->pcr_incr <= 0) { As far as I see a negative pcr_incr can happen in valid streams in case of a PCR wraparound. Regards, Marton
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index fad10c6..77d63f2 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2692,6 +2692,10 @@ static int mpegts_read_header(AVFormatContext *s) /* NOTE1: the bitrate is computed without the FEC */ /* NOTE2: it is only the bitrate of the start of the stream */ ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); + if (ts->pcr_incr <= 0) { + av_log(s, AV_LOG_ERROR, "invalid pcr increment %d\n", ts->pcr_incr); + return AVERROR_INVALIDDATA; + } ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; s->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr; st->codecpar->bit_rate = s->bit_rate;
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> --- libavformat/mpegts.c | 4 ++++ 1 file changed, 4 insertions(+)