Merge commit '3f75e5116b900f1428aa13041fc7d6301bf1988a'
authorJames Almer <jamrial@gmail.com>
Thu, 13 Apr 2017 22:49:20 +0000 (19:49 -0300)
committerJames Almer <jamrial@gmail.com>
Thu, 13 Apr 2017 22:49:20 +0000 (19:49 -0300)
* commit '3f75e5116b900f1428aa13041fc7d6301bf1988a':
  avio: Keep track of the amount of data written

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavformat/avio.h
libavformat/aviobuf.c
libavformat/version.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;
  
  /**
@@@ -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);
  
  #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, \