[FFmpeg-devel] [PATCH] wtvenc: test avio_size() validity
pross at xvid.org
Mon Dec 23 11:04:45 CET 2013
On Sun, Dec 22, 2013 at 08:10:54AM +0100, Reimar Döffinger wrote:
> On 21.12.2013, at 09:42, Peter Ross <pross at xvid.org> wrote:
> > Previously the demuxer was testing against avio_tell, and this would generate
> > many false warnings.
> Do we support streaming (or otherwise non-seekable) wtv files?
Not currently. The filesystem-like nature of wtv means that (lots of) seeking is almost always
required. It is theorectically to craft a file that does require seeking.
> I suspect not, but to be correct for that case it would need to check that avio_size is valid first...
libavformat/wtvdec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 5069d48..21236fa 100644
@@ -153,6 +153,7 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
+ int64_t size;
if (seek_by_sector(s->pb, first_sector, 0) < 0)
@@ -205,7 +206,8 @@ static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, int
- if ((int64_t)wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > avio_size(s->pb))
+ size = avio_size(s->pb);
+ if (size >= 0 && (int64_t)wf->sectors[wf->nb_sectors - 1] << WTV_SECTOR_BITS > size)
av_log(s, AV_LOG_WARNING, "truncated file\n");
/* check length */
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel