From patchwork Wed Jul 11 00:17:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9672 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp4245104jad; Tue, 10 Jul 2018 17:18:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcgXo9RaFcle4rQDJbkRuijp48Vl/ytzn5gyRyKKvug4K5mZTg00iuRMokUX+t7gNmeKe6+ X-Received: by 2002:adf:9527:: with SMTP id 36-v6mr18027598wrs.99.1531268319523; Tue, 10 Jul 2018 17:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531268319; cv=none; d=google.com; s=arc-20160816; b=ooYGH2tpV33rQ1CzjKi5URl6EgiGQIk64GtVcqvLllweyjO0XGCisxS2ZyMoKxsvP/ /PS2EUonOhfCcm2wQLxZkYoIElRoFab1W4HqWQMFmX4DD+RH1FGhLxuF6HNvObMoetSZ th47JQcHNvqfzqWqsr8EghiNG8HIGsYDNLtwU635fR0zA98zgJw/pNUqL66JYtSTMd/I F2oqsFNU8KK31kZps+yoUGFZ31j6QaiBvGpyYktafWYg56KQc3KzTBBEMiebjco05wcW /LvApgaXWNTjDf/WeiD0dmKqPN/XxespHWVjH5sjrVP3vj6WM/R70jObLVCf9aIH6+sC 34aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=t/Uhp5kLFddNUnLSeROzAoKM5of12GsTL9CgNucMuO4=; b=zPwBlTNLkRDmbGwUbNkSuP328zq395kVvOMnRmgNJFtBYtKFEls1WldRWwMyiKWuPI fEECC1wU/1YA+0/zQv3mh5nBcp56cMYR9gLzBGXMW2GX5A/Upg4nO6jG+Ifyv5hXoRVQ c19YSY8FHkjCmiDWe1uH/cgORqQthOFiloxWQTGXUZTl/H5AMSv5w3LsG8kOSiKE7ZN8 8eKsmVE3a+XqUv67626HWzs14m4zwO4rEyxSnMf7dGILlp4u4U1xr2QLPVh+cp1nlnIr 47L8/JnktlzxXrZz6zCb9QKVC3z8akaJJm/Jtms7USFrIgprkoMIgOB9qpXgzOBppdKu MFvw== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 64-v6si410401wmp.229.2018.07.10.17.18.39; Tue, 10 Jul 2018 17:18:39 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E30068A576; Wed, 11 Jul 2018 03:18:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-3.mx.upcmail.net (vie01a-qmta-pe02-3.mx.upcmail.net [62.179.121.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F9CD68A536 for ; Wed, 11 Jul 2018 03:18:02 +0300 (EEST) Received: from [172.31.218.52] (helo=vie01a-dmta-pe08-1.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fd2pc-00081G-MZ for ffmpeg-devel@ffmpeg.org; Wed, 11 Jul 2018 02:18:08 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe08.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fd2pW-0006PD-UV for ffmpeg-devel@ffmpeg.org; Wed, 11 Jul 2018 02:18:02 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 9CJ01y01K0S5wYM01CJ12o; Wed, 11 Jul 2018 02:18:01 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 11 Jul 2018 02:17:55 +0200 Message-Id: <20180711001758.27132-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 Subject: [FFmpeg-devel] [PATCH 1/4] avformat/mov: remove modulo operations from mov_estimate_video_delay() 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 0.324 <-0.491 sec Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 1346ffe480..aabf06de12 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3310,13 +3310,16 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st) { for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) { if (buf_size == (MAX_REORDER_DELAY + 1)) { // If circular buffer is full, then move the first element forward. - buf_start = (buf_start + 1) % buf_size; + buf_start = (buf_start + 1); + if (buf_start == MAX_REORDER_DELAY + 1) + buf_start = 0; } else { ++buf_size; } // Point j to the last elem of the buffer and insert the current pts there. - j = (buf_start + buf_size - 1) % buf_size; + j = buf_start - 1; + if (j < 0) j = buf_size - 1; pts_buf[j] = st->index_entries[ind].timestamp + msc->ctts_data[ctts_ind].duration; // The timestamps that are already in the sorted buffer, and are greater than the @@ -3327,7 +3330,8 @@ static void mov_estimate_video_delay(MOVContext *c, AVStream* st) { // go through, to keep this buffer in sorted order. num_swaps = 0; while (j != buf_start) { - r = (j - 1 + buf_size) % buf_size; + r = j - 1; + if (r < 0) r = buf_size - 1; if (pts_buf[j] < pts_buf[r]) { FFSWAP(int64_t, pts_buf[j], pts_buf[r]); ++num_swaps;