[FFmpeg-cvslog] avio: Collect and print statistics of bytes read & seeks
Michael Niedermayer
git at videolan.org
Fri Jun 15 11:31:57 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jun 2 23:01:13 2012 +0200| [11153a9371a84d881809f43e60830d3ed8ae60b9] | committer: Michael Niedermayer
avio: Collect and print statistics of bytes read & seeks
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=11153a9371a84d881809f43e60830d3ed8ae60b9
---
libavformat/avio.h | 12 ++++++++++++
libavformat/aviobuf.c | 4 ++++
2 files changed, 16 insertions(+)
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 260bdd9..9e9a763 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -128,6 +128,18 @@ typedef struct {
* call the underlying seek function directly.
*/
int direct;
+
+ /**
+ * Bytes read statistic
+ * This field is internal to libavformat and access from outside is not allowed.
+ */
+ int64_t bytes_read;
+
+ /**
+ * seek statistic
+ * This field is internal to libavformat and access from outside is not allowed.
+ */
+ int seek_count;
} AVIOContext;
/* unbuffered I/O */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 45a8bad..d8451c5 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -237,6 +237,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
return AVERROR(EPIPE);
if ((res = s->seek(s->opaque, offset, SEEK_SET)) < 0)
return res;
+ s->seek_count ++;
if (!s->write_flag)
s->buf_end = s->buffer;
s->buf_ptr = s->buffer;
@@ -423,6 +424,7 @@ static void fill_buffer(AVIOContext *s)
s->pos += len;
s->buf_ptr = dst;
s->buf_end = dst + len;
+ s->bytes_read += len;
}
}
@@ -792,6 +794,8 @@ int avio_close(AVIOContext *s)
h = s->opaque;
av_free(s->buffer);
+ if (!s->write_flag)
+ av_log(s, AV_LOG_DEBUG, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count);
av_free(s);
return ffurl_close(h);
}
More information about the ffmpeg-cvslog
mailing list