[FFmpeg-devel] [PATCH] Making xmp data process faster

孟辰(阏逢) mengchen.mc at alibaba-inc.com
Tue Nov 8 08:15:04 EET 2016


---
 libavformat/mov.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f06de06..341d22d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4533,13 +4533,20 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         if (!buffer) {
             return AVERROR(ENOMEM);
         }
-        ret = avio_read(pb, buffer, len);
+
+        if (c->export_xmp) {
+            ret = avio_read(pb, buffer, len);
+            if (ret != len) {
+                av_free(buffer);
+                return AVERROR_INVALIDDATA;
+            }
+        } else {
+            // skip all uuid atoms, which makes it fast for long uuid-xmp file
+            ret = avio_seek(pb, len, SEEK_CUR);
+        }
         if (ret < 0) {
             av_free(buffer);
             return ret;
-        } else if (ret != len) {
-            av_free(buffer);
-            return AVERROR_INVALIDDATA;
         }
         if (c->export_xmp) {
             buffer[len] = '\0';
-- 
2.8.2



More information about the ffmpeg-devel mailing list