ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Thu Apr 13 19:49:20 2017 -0300| [34d7f337c1608c72be8c36355018dc894f0560ce] | committer: James Almer
Merge commit '3f75e5116b900f1428aa13041fc7d6301bf1988a' * commit '3f75e5116b900f1428aa13041fc7d6301bf1988a': avio: Keep track of the amount of data written Merged-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34d7f337c1608c72be8c36355018dc894f0560ce --- libavformat/avio.h | 2 ++ libavformat/aviobuf.c | 7 +++++++ libavformat/version.h | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) 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, \ ====================================================================== diff --cc libavformat/avio.h index 6f4ed8440d,7bf7985c5e..525eb7129e --- a/libavformat/avio.h +++ b/libavformat/avio.h @@@ -321,12 -176,7 +321,14 @@@ typedef struct AVIOContext */ enum AVIODataMarkerType current_type; int64_t last_time; + + /** + * A callback that is used instead of short_seek_threshold. + * This is current internal only, do not use from outside. + */ + int (*short_seek_get)(void *opaque); ++ + int64_t written; } AVIOContext; /** diff --cc libavformat/aviobuf.c index ef6a0d4e9b,6d83a9661b..0a7c39eacd --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@@ -119,7 -144,6 +119,8 @@@ int ffio_init_context(AVIOContext *s s->ignore_boundary_point = 0; s->current_type = AVIO_DATA_MARKER_UNKNOWN; s->last_time = AV_NOPTS_VALUE; + s->short_seek_get = NULL; ++ s->written = 0; return 0; } @@@ -141,34 -165,32 +142,37 @@@ AVIOContext *avio_alloc_context return s; } -static void flush_buffer(AVIOContext *s) +static void writeout(AVIOContext *s, const uint8_t *data, int len) { - if (s->buf_ptr > s->buffer) { - int size = s->buf_ptr - s->buffer; - if (!s->error) { - int ret = 0; - if (s->write_data_type) - ret = s->write_data_type(s->opaque, s->buffer, - size, - s->current_type, - s->last_time); - else if (s->write_packet) - ret = s->write_packet(s->opaque, s->buffer, - size); - if (ret < 0) { - s->error = ret; - } else { - if (s->pos + size > s->written) - s->written = s->pos + size; - } - } - if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT || - s->current_type == AVIO_DATA_MARKER_BOUNDARY_POINT) { - s->current_type = AVIO_DATA_MARKER_UNKNOWN; + if (!s->error) { + int ret = 0; + if (s->write_data_type) + ret = s->write_data_type(s->opaque, (uint8_t *)data, + len, + s->current_type, + s->last_time); + else if (s->write_packet) + 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; } - s->last_time = AV_NOPTS_VALUE; + } + if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT || + s->current_type == AVIO_DATA_MARKER_BOUNDARY_POINT) { + s->current_type = AVIO_DATA_MARKER_UNKNOWN; + } + s->last_time = AV_NOPTS_VALUE; + s->writeout_count ++; + s->pos += len; +} + +static void flush_buffer(AVIOContext *s) +{ + if (s->write_flag && s->buf_ptr > s->buffer) { + writeout(s, s->buffer, s->buf_ptr - s->buffer); if (s->update_checksum) { s->checksum = s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr); diff --cc libavformat/version.h index 0920b48145,3fa2c4443b..411fd6613d --- a/libavformat/version.h +++ b/libavformat/version.h @@@ -29,11 -29,9 +29,11 @@@ #include "libavutil/version.h" -#define LIBAVFORMAT_VERSION_MAJOR 57 -#define LIBAVFORMAT_VERSION_MINOR 10 -#define LIBAVFORMAT_VERSION_MICRO 2 +// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) +// 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, \ _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog