History

avformat/avio{,buf}: introduce public AVIOContext::bytes_{read,written}

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.

Jan Ekström committed 5 years ago

Commit 682bafd1 parent a5622ed5 files · +30 −4Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavformat/avio.h +13 −1
  3. libavformat/avio_internal.h +5 −0
  4. libavformat/aviobuf.c +8 −2
  5. libavformat/version.h +1 −1
doc/APIchanges+3−0
@@ -14,6 +14,9 @@ libavutil: 2021-04-27 · 13 unmodified lines
14 14
15API changes, most recent first:15API changes, most recent first:
16 16
172021-10-18 - xxxxxxxxxx - lavf 59.8.100 - avio.h
18 Introduce public bytes_{read,written} statistic fields to AVIOContext.
19
172021-10-13 - xxxxxxxxxx - lavf 59.7.100 - avio.h202021-10-13 - xxxxxxxxxx - lavf 59.7.100 - avio.h
18 Deprecate AVIOContext.written. Originally added as a private entry in21 Deprecate AVIOContext.written. Originally added as a private entry in
19 commit 3f75e5116b900f1428aa13041fc7d6301bf1988a, its grouping with22 commit 3f75e5116b900f1428aa13041fc7d6301bf1988a, its grouping with
libavformat/avio.h+13−1
@@ -292,7 +292,9 @@ typedef struct AVIOContext { · 291 unmodified lines
292 292
293#if FF_API_AVIOCONTEXT_WRITTEN293#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 attribute_deprecated299 attribute_deprecated
298 int64_t written;300 int64_t written;
@@ -303,6 +305,16 @@ typedef struct AVIOContext { · 4 unmodified lines
303 * used keeping track of already written data for a later flush.305 * used keeping track of already written data for a later flush.
304 */306 */
305 unsigned char *buf_ptr_max;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} AVIOContext;318} AVIOContext;
307 319
308/**320/**
libavformat/avio_internal.h+5−0
@@ -51,6 +51,11 @@ typedef struct FFIOContext { · 50 unmodified lines
51 */51 */
52 int64_t bytes_read;52 int64_t bytes_read;
53 53
54 /**
55 * Bytes written statistic
56 */
57 int64_t bytes_written;
58
54 /**59 /**
55 * seek statistic60 * seek statistic
56 */61 */
libavformat/aviobuf.c+8−2
@@ -169,6 +169,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) · 168 unmodified lines
169 if (ret < 0) {169 if (ret < 0) {
170 s->error = ret;170 s->error = ret;
171 } else {171 } else {
172 ctx->bytes_written += len;
173 s->bytes_written = ctx->bytes_written;
174
172 if (s->pos + len > ctx->written_output_size) {175 if (s->pos + len > ctx->written_output_size) {
173 ctx->written_output_size = s->pos + len;176 ctx->written_output_size = s->pos + len;
174#if FF_API_AVIOCONTEXT_WRITTEN177#if FF_API_AVIOCONTEXT_WRITTEN
@@ -584,6 +587,7 @@ static void fill_buffer(AVIOContext *s) · 409 unmodified lines
584 s->buf_ptr = dst;587 s->buf_ptr = dst;
585 s->buf_end = dst + len;588 s->buf_end = dst + len;
586 ffiocontext(s)->bytes_read += len;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 } else {661 } else {
658 s->pos += len;662 s->pos += len;
659 ffiocontext(s)->bytes_read += len;663 ffiocontext(s)->bytes_read += len;
664 s->bytes_read = ffiocontext(s)->bytes_read;
660 size -= len;665 size -= len;
661 buf += len;666 buf += len;
662 // reset the buffer667 // reset the buffer
@@ -1236,8 +1241,9 @@ int avio_close(AVIOContext *s) · 573 unmodified lines
1236 1241
1237 av_freep(&s->buffer);1242 av_freep(&s->buffer);
1238 if (s->write_flag)1243 if (s->write_flag)
1239 av_log(s, AV_LOG_VERBOSE, "Statistics: %d seeks, %d writeouts\n",1244 av_log(s, AV_LOG_VERBOSE,
1240 ctx->seek_count, ctx->writeout_count);1245 "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n",
1246 ctx->bytes_written, ctx->seek_count, ctx->writeout_count);
1241 else1247 else
1242 av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",1248 av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",
1243 ctx->bytes_read, ctx->seek_count);1249 ctx->bytes_read, ctx->seek_count);
libavformat/version.h+1−1
@@ -32,7 +32,7 @@ · 31 unmodified lines
32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)32// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
33// Also please add any ticket numbers that you believe might be affected here33// Also please add any ticket numbers that you believe might be affected here
34#define LIBAVFORMAT_VERSION_MAJOR 5934#define LIBAVFORMAT_VERSION_MAJOR 59
35#define LIBAVFORMAT_VERSION_MINOR 735#define LIBAVFORMAT_VERSION_MINOR 8
36#define LIBAVFORMAT_VERSION_MICRO 10036#define LIBAVFORMAT_VERSION_MICRO 100
37 37
38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \38#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t