[FFmpeg-cvslog] avformat/avio: move short seek threshold to the context

Michael Niedermayer git at videolan.org
Thu Jun 11 16:08:13 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Jun  2 18:40:53 2015 +0200| [4e640f05605f19a377c2ae9cc27effb53f83cf4f] | committer: Michael Niedermayer

avformat/avio: move short seek threshold to the context

This allows us to adjust it internally.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4e640f05605f19a377c2ae9cc27effb53f83cf4f
---

 libavformat/avio.h    |    6 ++++++
 libavformat/aviobuf.c |    3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 5c5aa6d..28997f8 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -196,6 +196,12 @@ typedef struct AVIOContext {
      * This field is internal to libavformat and access from outside is not allowed.
      */
     int orig_buffer_size;
+
+    /**
+     * Threshold to favor readahead over seek.
+     * This is current internal only, do not use from outside.
+     */
+    int short_seek_threshold;
 } AVIOContext;
 
 /* unbuffered I/O */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 45400cd..dfefe62 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -97,6 +97,7 @@ int ffio_init_context(AVIOContext *s,
     s->seekable        = seek ? AVIO_SEEKABLE_NORMAL : 0;
     s->max_packet_size = 0;
     s->update_checksum = NULL;
+    s->short_seek_threshold = SHORT_SEEK_THRESHOLD;
 
     if (!read_packet && !write_flag) {
         s->pos     = buffer_size;
@@ -232,7 +233,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
         /* can do the seek inside the buffer */
         s->buf_ptr = s->buffer + offset1;
     } else if ((!s->seekable ||
-               offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
+               offset1 <= s->buf_end + s->short_seek_threshold - s->buffer) &&
                !s->write_flag && offset1 >= 0 &&
                (!s->direct || !s->seek) &&
               (whence != SEEK_END || force)) {



More information about the ffmpeg-cvslog mailing list