diff options
author | wm4 <wm4@nowhere> | 2013-06-21 21:14:38 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-06-25 00:11:55 +0200 |
commit | e3c0fb1aee806758b1de8c148696afe5b0333701 (patch) | |
tree | 57effaf8ca17fa87b5fc2c12f9ce71df99d92dc9 /demux | |
parent | a40ae2de846d6f3e4fd6356c4914678c0588e083 (diff) | |
download | mpv-e3c0fb1aee806758b1de8c148696afe5b0333701.tar.bz2 mpv-e3c0fb1aee806758b1de8c148696afe5b0333701.tar.xz |
demux_lavf: use stream_peek() instead of read/unread
Simpler, reduces the amount of copying.
We still have to malloc+memcpy the probe buffer though, because padding
with FF_INPUT_BUFFER_PADDING_SIZE is required by libavformat.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_lavf.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index d8e8109c93..48e79e949b 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -267,12 +267,11 @@ static int lavf_check_file(demuxer_t *demuxer) while (avpd.buf_size < PROBE_BUF_SIZE) { int nsize = av_clip(avpd.buf_size * 2, INITIAL_PROBE_SIZE, PROBE_BUF_SIZE); - int read_size = stream_read(s, avpd.buf + avpd.buf_size, - nsize - avpd.buf_size); - if (read_size <= 0) + bstr buf = stream_peek(s, nsize); + if (buf.len <= avpd.buf_size) break; - - avpd.buf_size += read_size; + memcpy(avpd.buf, buf.start, buf.len); + avpd.buf_size = buf.len; int score = 0; priv->avif = av_probe_input_format2(&avpd, avpd.buf_size > 0, &score); @@ -294,7 +293,6 @@ static int lavf_check_file(demuxer_t *demuxer) priv->avif = NULL; } - stream_unread_buffer(s, avpd.buf, avpd.buf_size); av_free(avpd.buf); if (!priv->avif) { |