Message ID | 20201004171429.174812-1-andriy.gelman@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel] avformat/mpegts: ensure seekback for small probesize | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On Sun, 4 Oct 2020, Andriy Gelman wrote: > From: Andriy Gelman <andriy.gelman@gmail.com> > > get_packet_size() may read upto PROBE_PACKET_MAX_BUF bytes, which may be > larger than probesize. > > Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> > --- > > An alternative could be to make sure we don't read more than s->probesize bytes > in get_packet_size(), but because this function is also called during resync > (midstream) limiting the read bytes may not be the best option. > > libavformat/mpegts.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > index 50d4d5e9bc..019b627d51 100644 > --- a/libavformat/mpegts.c > +++ b/libavformat/mpegts.c > @@ -3054,7 +3054,7 @@ static int mpegts_read_header(AVFormatContext *s) > > s->internal->prefer_codec_framerate = 1; > > - if (ffio_ensure_seekback(pb, probesize) < 0) > + if (ffio_ensure_seekback(pb, FFMAX(probesize, PROBE_PACKET_MAX_BUF)) < 0) > av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); I posted a similar patch not long ago which is I think better because it also takes into account ts->resync_size. https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200929211021.25030-4-cus@passwd.hu/ Regards, Marton
On Mon, 05. Oct 10:31, Marton Balint wrote: > > > On Sun, 4 Oct 2020, Andriy Gelman wrote: > > > From: Andriy Gelman <andriy.gelman@gmail.com> > > > > get_packet_size() may read upto PROBE_PACKET_MAX_BUF bytes, which may be > > larger than probesize. > > > > Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> > > --- > > > > An alternative could be to make sure we don't read more than s->probesize bytes > > in get_packet_size(), but because this function is also called during resync > > (midstream) limiting the read bytes may not be the best option. > > > > libavformat/mpegts.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c > > index 50d4d5e9bc..019b627d51 100644 > > --- a/libavformat/mpegts.c > > +++ b/libavformat/mpegts.c > > @@ -3054,7 +3054,7 @@ static int mpegts_read_header(AVFormatContext *s) > > > > s->internal->prefer_codec_framerate = 1; > > > > - if (ffio_ensure_seekback(pb, probesize) < 0) > > + if (ffio_ensure_seekback(pb, FFMAX(probesize, PROBE_PACKET_MAX_BUF)) < 0) > > av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); > > I posted a similar patch not long ago which is I think better because it > also takes into account ts->resync_size. > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/20200929211021.25030-4-cus@passwd.hu/ Thanks, I missed in your patch in the set. -- Andriy
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 50d4d5e9bc..019b627d51 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -3054,7 +3054,7 @@ static int mpegts_read_header(AVFormatContext *s) s->internal->prefer_codec_framerate = 1; - if (ffio_ensure_seekback(pb, probesize) < 0) + if (ffio_ensure_seekback(pb, FFMAX(probesize, PROBE_PACKET_MAX_BUF)) < 0) av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); pos = avio_tell(pb);