Browse code

Merge commit '3f75e5116b900f1428aa13041fc7d6301bf1988a'

* commit '3f75e5116b900f1428aa13041fc7d6301bf1988a':
avio: Keep track of the amount of data written

Merged-by: James Almer <jamrial@gmail.com>

James Almer authored on 2017/04/14 07:49:20
Showing 3 changed files
... ...
@@ -327,6 +327,8 @@ typedef struct AVIOContext {
327 327
      * This is current internal only, do not use from outside.
328 328
      */
329 329
     int (*short_seek_get)(void *opaque);
330
+
331
+    int64_t written;
330 332
 } AVIOContext;
331 333
 
332 334
 /**
... ...
@@ -120,6 +120,7 @@ int ffio_init_context(AVIOContext *s,
120 120
     s->current_type          = AVIO_DATA_MARKER_UNKNOWN;
121 121
     s->last_time             = AV_NOPTS_VALUE;
122 122
     s->short_seek_get        = NULL;
123
+    s->written               = 0;
123 124
 
124 125
     return 0;
125 126
 }
... ...
@@ -154,6 +155,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len)
154 154
             ret = s->write_packet(s->opaque, (uint8_t *)data, len);
155 155
         if (ret < 0) {
156 156
             s->error = ret;
157
+        } else {
158
+            if (s->pos + len > s->written)
159
+                s->written = s->pos + len;
157 160
         }
158 161
     }
159 162
     if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT ||
... ...
@@ -323,6 +327,9 @@ int64_t avio_size(AVIOContext *s)
323 323
     if (!s)
324 324
         return AVERROR(EINVAL);
325 325
 
326
+    if (s->written)
327
+        return s->written;
328
+
326 329
     if (!s->seek)
327 330
         return AVERROR(ENOSYS);
328 331
     size = s->seek(s->opaque, 0, AVSEEK_SIZE);
... ...
@@ -33,7 +33,7 @@
33 33
 // Also please add any ticket numbers that you believe might be affected here
34 34
 #define LIBAVFORMAT_VERSION_MAJOR  57
35 35
 #define LIBAVFORMAT_VERSION_MINOR  72
36
-#define LIBAVFORMAT_VERSION_MICRO 100
36
+#define LIBAVFORMAT_VERSION_MICRO 101
37 37
 
38 38
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
39 39
                                                LIBAVFORMAT_VERSION_MINOR, \