Message ID | 20211013211038.13391-3-jeebjp@gmail.com |
---|---|
State | New |
Headers | show |
Series | introduce public AVIOContext::bytes_{read, written} | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
On Thu, Oct 14, 2021 at 12:10:37AM +0300, Jan Ekström wrote: > 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. > --- > doc/APIchanges | 3 +++ > libavformat/avio.h | 10 ++++++++++ > libavformat/aviobuf.c | 4 +++- > libavformat/version.h | 2 +- > 4 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 7b267a79ac..806eaf4c83 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -14,6 +14,9 @@ libavutil: 2021-04-27 > > API changes, most recent first: > > +2021-09-26 - xxxxxxxxxx - lavf 59.7.100 - avio.h > + Introduce public bytes_{read,written} statistic fields to AVIOContext. > + > 2021-09-21 - xxxxxxxxxx - lavu 57.7.100 - pixfmt.h > Add AV_PIX_FMT_X2BGR10. > > diff --git a/libavformat/avio.h b/libavformat/avio.h > index a7b56ab667..0f9a0f909f 100644 > --- a/libavformat/avio.h > +++ b/libavformat/avio.h > @@ -297,6 +297,16 @@ typedef struct AVIOContext { > * used keeping track of already written data for a later flush. > */ > unsigned char *buf_ptr_max; > + > + /** > + * Read-only statistic of bytes read for this AVIOContext. > + */ > + int64_t bytes_read; > + > + /** > + * Read-only statistic of bytes written for this AVIOContext. > + */ > + int64_t bytes_written; > } AVIOContext; ok thx [...]
diff --git a/doc/APIchanges b/doc/APIchanges index 7b267a79ac..806eaf4c83 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-09-26 - xxxxxxxxxx - lavf 59.7.100 - avio.h + Introduce public bytes_{read,written} statistic fields to AVIOContext. + 2021-09-21 - xxxxxxxxxx - lavu 57.7.100 - pixfmt.h Add AV_PIX_FMT_X2BGR10. diff --git a/libavformat/avio.h b/libavformat/avio.h index a7b56ab667..0f9a0f909f 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -297,6 +297,16 @@ typedef struct AVIOContext { * used keeping track of already written data for a later flush. */ unsigned char *buf_ptr_max; + + /** + * Read-only statistic of bytes read for this AVIOContext. + */ + int64_t bytes_read; + + /** + * Read-only statistic of bytes written for this AVIOContext. + */ + int64_t bytes_written; } AVIOContext; /** diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 7afbff0266..436a264f83 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -165,7 +165,7 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) s->error = ret; } else { if (s->pos + len > ctx->bytes_written) { - ctx->bytes_written = s->pos + len; + s->bytes_written = ctx->bytes_written = s->pos + len; s->written = ctx->bytes_written; } } @@ -575,6 +575,7 @@ static void fill_buffer(AVIOContext *s) s->buf_ptr = dst; s->buf_end = dst + len; ffiocontext(s)->bytes_read += len; + s->bytes_read = ffiocontext(s)->bytes_read; } } @@ -648,6 +649,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) } else { s->pos += len; ffiocontext(s)->bytes_read += len; + s->bytes_read = ffiocontext(s)->bytes_read; size -= len; buf += len; // reset the buffer diff --git a/libavformat/version.h b/libavformat/version.h index d5dd22059b..474640bb78 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // 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 59 -#define LIBAVFORMAT_VERSION_MINOR 6 +#define LIBAVFORMAT_VERSION_MINOR 7 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \