Such fields can be seen as generally useful in cases where the API user is not implementing custom AVIO callbacks, but still would like to know if data is being read or written out, such as in case data is being read from input but no AVPacket has been received yet.
Unified · Split
| @@ -14,6 +14,9 @@ libavutil: 2021-04-27 · 13 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | API changes, most recent first: |
| 16 | 16 | |
| 17 | +2021-10-18 - xxxxxxxxxx - lavf 59.8.100 - avio.h | |
| 18 | + Introduce public bytes_{read,written} statistic fields to AVIOContext. | |
| 19 | + | |
| 17 | 20 | 2021-10-13 - xxxxxxxxxx - lavf 59.7.100 - avio.h |
| 18 | 21 | Deprecate AVIOContext.written. Originally added as a private entry in |
| 19 | 22 | commit 3f75e5116b900f1428aa13041fc7d6301bf1988a, its grouping with |
| @@ -292,7 +292,9 @@ typedef struct AVIOContext { · 291 unmodified lines | ||
| 292 | 292 | |
| 293 | 293 | #if FF_API_AVIOCONTEXT_WRITTEN |
| 294 | 294 | /** |
| 295 | − * @deprecated field utilized privately by libavformat. | |
| 295 | + * @deprecated field utilized privately by libavformat. For a public | |
| 296 | + * statistic of how many bytes were written out, see | |
| 297 | + * AVIOContext::bytes_written. | |
| 296 | 298 | */ |
| 297 | 299 | attribute_deprecated |
| 298 | 300 | int64_t written; |
| @@ -303,6 +305,16 @@ typedef struct AVIOContext { · 4 unmodified lines | ||
| 303 | 305 | * used keeping track of already written data for a later flush. |
| 304 | 306 | */ |
| 305 | 307 | unsigned char *buf_ptr_max; |
| 308 | + | |
| 309 | + /** | |
| 310 | + * Read-only statistic of bytes read for this AVIOContext. | |
| 311 | + */ | |
| 312 | + int64_t bytes_read; | |
| 313 | + | |
| 314 | + /** | |
| 315 | + * Read-only statistic of bytes written for this AVIOContext. | |
| 316 | + */ | |
| 317 | + int64_t bytes_written; | |
| 306 | 318 | } AVIOContext; |
| 307 | 319 | |
| 308 | 320 | /** |
| @@ -51,6 +51,11 @@ typedef struct FFIOContext { · 50 unmodified lines | ||
| 51 | 51 | */ |
| 52 | 52 | int64_t bytes_read; |
| 53 | 53 | |
| 54 | + /** | |
| 55 | + * Bytes written statistic | |
| 56 | + */ | |
| 57 | + int64_t bytes_written; | |
| 58 | + | |
| 54 | 59 | /** |
| 55 | 60 | * seek statistic |
| 56 | 61 | */ |
| @@ -169,6 +169,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) · 168 unmodified lines | ||
| 169 | 169 | if (ret < 0) { |
| 170 | 170 | s->error = ret; |
| 171 | 171 | } else { |
| 172 | + ctx->bytes_written += len; | |
| 173 | + s->bytes_written = ctx->bytes_written; | |
| 174 | + | |
| 172 | 175 | if (s->pos + len > ctx->written_output_size) { |
| 173 | 176 | ctx->written_output_size = s->pos + len; |
| 174 | 177 | #if FF_API_AVIOCONTEXT_WRITTEN |
| @@ -584,6 +587,7 @@ static void fill_buffer(AVIOContext *s) · 409 unmodified lines | ||
| 584 | 587 | s->buf_ptr = dst; |
| 585 | 588 | s->buf_end = dst + len; |
| 586 | 589 | ffiocontext(s)->bytes_read += len; |
| 590 | + s->bytes_read = ffiocontext(s)->bytes_read; | |
| 587 | 591 | } |
| 588 | 592 | } |
| 589 | 593 | |
| @@ -657,6 +661,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) · 67 unmodified lines | ||
| 657 | 661 | } else { |
| 658 | 662 | s->pos += len; |
| 659 | 663 | ffiocontext(s)->bytes_read += len; |
| 664 | + s->bytes_read = ffiocontext(s)->bytes_read; | |
| 660 | 665 | size -= len; |
| 661 | 666 | buf += len; |
| 662 | 667 | // reset the buffer |
| @@ -1236,8 +1241,9 @@ int avio_close(AVIOContext *s) · 573 unmodified lines | ||
| 1236 | 1241 | |
| 1237 | 1242 | av_freep(&s->buffer); |
| 1238 | 1243 | if (s->write_flag) |
| 1239 | − av_log(s, AV_LOG_VERBOSE, "Statistics: %d seeks, %d writeouts\n", | |
| 1240 | − ctx->seek_count, ctx->writeout_count); | |
| 1244 | + av_log(s, AV_LOG_VERBOSE, | |
| 1245 | + "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n", | |
| 1246 | + ctx->bytes_written, ctx->seek_count, ctx->writeout_count); | |
| 1241 | 1247 | else |
| 1242 | 1248 | av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n", |
| 1243 | 1249 | ctx->bytes_read, ctx->seek_count); |
| @@ -32,7 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) |
| 33 | 33 | // Also please add any ticket numbers that you believe might be affected here |
| 34 | 34 | #define LIBAVFORMAT_VERSION_MAJOR 59 |
| 35 | −#define LIBAVFORMAT_VERSION_MINOR 7 | |
| 35 | +#define LIBAVFORMAT_VERSION_MINOR 8 | |
| 36 | 36 | #define LIBAVFORMAT_VERSION_MICRO 100 |
| 37 | 37 | |
| 38 | 38 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |