diff --git a/libavformat/avio.h b/libavformat/avio.h index 6f4ed8440d..525eb7129e 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -327,6 +327,8 @@ typedef struct AVIOContext { * This is current internal only, do not use from outside. */ int (*short_seek_get)(void *opaque); + + int64_t written; } AVIOContext; /** 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); diff --git a/libavformat/version.h b/libavformat/version.h index 0920b48145..411fd6613d 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 57 #define LIBAVFORMAT_VERSION_MINOR 72 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \