[FFmpeg-cvslog] lavf/concat: implement FFSEEK_SIZE.

Nicolas George git at videolan.org
Tue Aug 13 17:39:56 EEST 2019


ffmpeg | branch: master | Nicolas George <george at nsup.org> | Fri Jul 19 14:22:15 2019 +0200| [3add65e052cf3511b284d53e73f986a6768e5486] | committer: Nicolas George

lavf/concat: implement FFSEEK_SIZE.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3add65e052cf3511b284d53e73f986a6768e5486
---

 libavformat/concat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/concat.c b/libavformat/concat.c
index 19c83c309a..ea3bc1dfde 100644
--- a/libavformat/concat.c
+++ b/libavformat/concat.c
@@ -38,6 +38,7 @@ struct concat_data {
     struct concat_nodes *nodes;    ///< list of nodes to concat
     size_t               length;   ///< number of cat'ed nodes
     size_t               current;  ///< index of currently read node
+    uint64_t total_size;
 };
 
 static av_cold int concat_close(URLContext *h)
@@ -59,7 +60,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
 {
     char *node_uri = NULL;
     int err = 0;
-    int64_t size;
+    int64_t size, total_size = 0;
     size_t len, i;
     URLContext *uc;
     struct concat_data  *data = h->priv_data;
@@ -112,6 +113,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
         /* assembling */
         nodes[i].uc   = uc;
         nodes[i].size = size;
+        total_size += size;
     }
     av_free(node_uri);
     data->length = i;
@@ -123,6 +125,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags)
         err = AVERROR(ENOMEM);
     } else
         data->nodes = nodes;
+    data->total_size = total_size;
     return err;
 }
 
@@ -158,6 +161,8 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int whence)
     struct concat_nodes *nodes = data->nodes;
     size_t i;
 
+    if ((whence & AVSEEK_SIZE))
+        return data->total_size;
     switch (whence) {
     case SEEK_END:
         for (i = data->length - 1; i && pos < -nodes[i].size; i--)



More information about the ffmpeg-cvslog mailing list