diff mbox

[FFmpeg-devel] Making process of uuid-xmp faster.

Message ID 20161108083413.57277-1-mengchen.mc@alibaba-inc.com
State Superseded
Headers show

Commit Message

=?GBK?B?w8+zvSjj1bfqKQ==?= Nov. 8, 2016, 8:34 a.m. UTC
---
 libavformat/mov.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Nov. 8, 2016, 12:09 p.m. UTC | #1
On Tue, Nov 08, 2016 at 04:34:13PM +0800, Chen Meng wrote:
> ---
>  libavformat/mov.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index f06de06..388cd1f 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;
> +            }

this looses the error code in ret

[...]
Michael Niedermayer Nov. 8, 2016, 5:59 p.m. UTC | #2
On Tue, Nov 08, 2016 at 11:04:35PM +0800, Chen Meng wrote:
> From baee22d71825128f74beb15122cd786f8d89f13f Mon Sep 17 00:00:00 2001
> From: Chen Meng <mengchen.mc@alibaba-inc.com>
> Date: Tue, 8 Nov 2016 22:58:44 +0800
> Subject: [PATCH] Take the error code in return.

git refuses to apply this

Applying: Making process of uuid-xmp faster.
fatal: unrecognized input
error: could not build fake ancestor
Patch failed at 0001 Making process of uuid-xmp faster.
The copy of the patch that failed is found in: .git/rebase-apply/patch


> 
> ---
>  libavformat/mov.c | 30 ++++++++++++++----------------
>  1 file changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 388cd1f..c86252c 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c

[...]
=?GBK?B?w8+zvSjj1bfqKQ==?= Nov. 9, 2016, 3:19 a.m. UTC | #3
Sorry for that, I've taken code back into up-date master branch again.---
 libavformat/mov.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index ca978c2..c358d17 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4530,24 +4530,30 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     } else if (!memcmp(uuid, uuid_xmp, sizeof(uuid))) {
         uint8_t *buffer;
         size_t len = atom.size - sizeof(uuid);
-
-        buffer = av_mallocz(len + 1);
-        if (!buffer) {
-            return AVERROR(ENOMEM);
-        }
-        ret = avio_read(pb, buffer, len);
-        if (ret < 0) {
-            av_free(buffer);
-            return ret;
-        } else if (ret != len) {
-            av_free(buffer);
-            return AVERROR_INVALIDDATA;
-        }
+        
         if (c->export_xmp) {
+            buffer = av_mallocz(len + 1);
+            if (!buffer) {
+                return AVERROR(ENOMEM);
+            }
+            ret = avio_read(pb, buffer, len);
+            if (ret < 0) {
+                av_free(buffer);
+                return ret;
+            } else if (ret != len) {
+                av_free(buffer);
+                return AVERROR_INVALIDDATA;
+            }
             buffer[len] = '\0';
             av_dict_set(&c->fc->metadata, "xmp", buffer, 0);
+            av_free(buffer);
+        } else {
+            // skip all uuid atom, which makes it fast for long uuid-xmp file
+
+            ret = avio_seek(pb, len, SEEK_CUR);
+            if (ret < 0)
+                return ret;
         }
-        av_free(buffer);
     }
     return 0;
 }
-- 
2.10.2
Michael Niedermayer Nov. 9, 2016, 9:09 a.m. UTC | #4
On Wed, Nov 09, 2016 at 11:19:10AM +0800, Chen Meng wrote:
> Sorry for that, I've taken code back into up-date master branch again.---
>  libavformat/mov.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)

the problem is not at the branch level, theres something wrong with the
mail
these dont apply either, and all the whitespaces in the mail look odd

Patch is empty. Was it split wrong?
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


[...]
=?GBK?B?w8+zvSjj1bfqKQ==?= Nov. 9, 2016, 9:17 a.m. UTC | #5
Guess it because of the web-based mail client not pretty well for git patch.I'll try to mail a new patch by git directly. 
------------------------------------------------------------------From:Michael Niedermayer <michael@niedermayer.cc>Time:2016 Nov 9 (Wed) 17:10To:FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>Subject:Re: [FFmpeg-devel] [PATCH] Making process of uuid-xmp faster.
On Wed, Nov 09, 2016 at 11:19:10AM +0800, Chen Meng wrote:
> Sorry for that, I've taken code back into up-date master branch again.---
>  libavformat/mov.c | 34 ++++++++++++++++++++--------------
>  1 file changed, 20 insertions(+), 14 deletions(-)

the problem is not at the branch level, theres something wrong with the
mail
these dont apply either, and all the whitespaces in the mail look odd

Patch is empty. Was it split wrong?
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f06de06..388cd1f 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 atom, 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';