diff options
author | James Almer <jamrial@gmail.com> | 2017-04-13 19:49:20 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-04-13 19:49:20 -0300 |
commit | 34d7f337c1608c72be8c36355018dc894f0560ce (patch) | |
tree | d9546d39b216ab49903f3208d316837451411a9c /libavformat/aviobuf.c | |
parent | c5fd47fa8a300fc51489a47da94041609545803c (diff) | |
parent | 3f75e5116b900f1428aa13041fc7d6301bf1988a (diff) | |
download | ffmpeg-34d7f337c1608c72be8c36355018dc894f0560ce.tar.gz |
Merge commit '3f75e5116b900f1428aa13041fc7d6301bf1988a'
* commit '3f75e5116b900f1428aa13041fc7d6301bf1988a':
avio: Keep track of the amount of data written
Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index ef6a0d4e9b..0a7c39eacd 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -120,6 +120,7 @@ int ffio_init_context(AVIOContext *s, s->current_type = AVIO_DATA_MARKER_UNKNOWN; s->last_time = AV_NOPTS_VALUE; s->short_seek_get = NULL; + s->written = 0; return 0; } @@ -154,6 +155,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) ret = s->write_packet(s->opaque, (uint8_t *)data, len); if (ret < 0) { s->error = ret; + } else { + if (s->pos + len > s->written) + s->written = s->pos + len; } } if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT || @@ -323,6 +327,9 @@ int64_t avio_size(AVIOContext *s) if (!s) return AVERROR(EINVAL); + if (s->written) + return s->written; + if (!s->seek) return AVERROR(ENOSYS); size = s->seek(s->opaque, 0, AVSEEK_SIZE); |