From patchwork Fri Nov 11 02:36:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?GBK?B?w8+zvSjj1bfqKQ==?= X-Patchwork-Id: 1381 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1179256vsb; Thu, 10 Nov 2016 18:36:51 -0800 (PST) X-Received: by 10.28.161.129 with SMTP id k123mr57725wme.66.1478831810977; Thu, 10 Nov 2016 18:36:50 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w65si30900232wma.20.2016.11.10.18.36.50; Thu, 10 Nov 2016 18:36:50 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@alibaba-inc.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=alibaba-inc.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1CA45689F25; Fri, 11 Nov 2016 04:36:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out0-153.mail.aliyun.com (out0-153.mail.aliyun.com [140.205.0.153]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C1F0689F19 for ; Fri, 11 Nov 2016 04:36:35 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1478831792; h=From:To:Subject:Date:Message-Id; bh=K+zlw3i9fWpKqZUfkdaEeqVOct2VE8Kr0r5pcbwy9no=; b=moSsX2Kfv27uFVvHbGohpGiPHzQ7i9bJiTGIEzP9Fb466o2dUuzWPArpd1ZBvVv+aIo3PzWjpg1rthXmo0LglvolKWkW3IGxmus6HjHr9QOlzx1o/4RMNNElrIB82JHMSNf8aesQAfPXZj56OYxcPkSM4peaO2fcITLg6lipgyw= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R131e4; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e02c03309; MF=mengchen.mc@alibaba-inc.com; NM=1; PH=DS; RN=2; SR=0; TI=SMTPD_---.79q5Rpw_1478831786; Received: from localhost(mailfrom:mengchen.mc@alibaba-inc.com ip:121.0.29.67) by smtp.aliyun-inc.com(127.0.0.1); Fri, 11 Nov 2016 10:36:26 +0800 From: "Chen Meng" To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Nov 2016 10:36:16 +0800 Message-Id: <20161111023616.9417-1-mengchen.mc@alibaba-inc.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH] Make the process of uuid-xmp atom faster. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Chen Meng MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/mov.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 9ec7d03..436c234 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4549,24 +4549,28 @@ 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_skip(pb, len); + if (ret < 0) + return ret; } - av_free(buffer); } return 0; }