diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-01-13 11:55:18 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-01-13 15:24:08 +0100 |
commit | e38c62fe0c24ae4d138f4eff8b91db996a8b7e1d (patch) | |
tree | 00e53000555c5589d21eede192134a82b0eb770d | |
parent | 9aa22918c258bfe8ee0769fe158d41a344e3178a (diff) | |
download | ffmpeg-e38c62fe0c24ae4d138f4eff8b91db996a8b7e1d.tar.gz |
lavf: simplify handling of offset in av_probe_input_buffer()
(cherry picked from commit c1868e7ee7b07b40a0fe15f50df89fe499a01a50)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r-- | libavformat/utils.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index b0bfea224f..fb6606be9a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -357,7 +357,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { - AVProbeData pd = { filename ? filename : "", NULL, -offset }; + AVProbeData pd = { filename ? filename : "" }; unsigned char *buf = NULL; int ret = 0, probe_size; @@ -372,16 +372,14 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, if (offset >= max_probe_size) { return AVERROR(EINVAL); } + avio_skip(pb, offset); + max_probe_size -= offset; for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size && !*fmt; probe_size = FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))) { int score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX/4 : 0; int buf_offset = (probe_size == PROBE_BUF_MIN) ? 0 : probe_size>>1; - if (probe_size < offset) { - continue; - } - /* read probe data */ buf = av_realloc(buf, probe_size + AVPROBE_PADDING_SIZE); if ((ret = avio_read(pb, buf + buf_offset, probe_size - buf_offset)) < 0) { @@ -394,7 +392,7 @@ int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, ret = 0; /* error was end of file, nothing read */ } pd.buf_size += ret; - pd.buf = &buf[offset]; + pd.buf = buf; memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE); |