From patchwork Wed Nov 9 09:30:57 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: 1359 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp190301vsb; Wed, 9 Nov 2016 01:31:55 -0800 (PST) X-Received: by 10.194.108.10 with SMTP id hg10mr17626284wjb.58.1478683915120; Wed, 09 Nov 2016 01:31:55 -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 qp4si749592wjb.30.2016.11.09.01.31.54; Wed, 09 Nov 2016 01:31:55 -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 60A2A689E00; Wed, 9 Nov 2016 11:31:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out0-138.mail.aliyun.com (out0-138.mail.aliyun.com [140.205.0.138]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1ACBB689DE9 for ; Wed, 9 Nov 2016 11:31:30 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1478683884; h=From:To:Subject:Date:Message-Id; bh=Qv4D1vXQlJFjjqfbI7rVpRczSPuK7LuMflWOPqtO9mQ=; b=Yx93MHmqHpBu0eqpGUHdmnNH12uj/uMS8gWlM3LDx5JhWpJ7kgzcEQaGF3VLGw+3BhQXq2oSzcXazvQVTycNiHfZfMPuLW9NPwzq75hsJFf+jqp3gh3Y0wHj3AgSD2q2LMy/aNpEFSLpaJQsaBwBeIA3yK0L38O0LMZy3Ov5vHg= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R521e4; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e02c03299; MF=mengchen.mc@alibaba-inc.com; NM=1; PH=DS; RN=2; SR=0; TI=SMTPD_---.79RJ7rq_1478683871; Received: from localhost(mailfrom:mengchen.mc@alibaba-inc.com ip:121.0.29.67) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Nov 2016 17:31:12 +0800 From: "Chen Meng" To: ffmpeg-devel@ffmpeg.org Date: Wed, 09 Nov 2016 17:30:57 +0800 Message-Id: <20161109093057.84186-1-mengchen.mc@alibaba-inc.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161109090938.GB4602@nb4> References: <20161109090938.GB4602@nb4> Subject: [FFmpeg-devel] [PATCH] Make the process for uuid-xmp data 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 | 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; }