From patchwork Fri Feb 9 21:34:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?WGlhb2hhbiBXYW5nICjnjovmtojlr5Ip?= X-Patchwork-Id: 7539 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp1277116jai; Fri, 9 Feb 2018 13:41:04 -0800 (PST) X-Google-Smtp-Source: AH8x227WeVPxnNrpWkuz6rEY4dsDQGrBTXQKzfPwIxmxTkdI2oDVRQKLrif7xiFpUaLcmv6dDEC5 X-Received: by 10.28.63.65 with SMTP id m62mr3095937wma.29.1518212464656; Fri, 09 Feb 2018 13:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518212464; cv=none; d=google.com; s=arc-20160816; b=xPPSB6snFk9SBVmSTusdj0axaNb0tTsrK8F8MkmK9Ybw/9EtRF8pikeYvrg8IEq7T/ pa2fIkLfqVigsYnq92meBLR+9V/8g0wrm4h3+MZCwAxBmilkhAMLIslcgfvcqdJyQluj gIT7wkWlg+reJFAHYLNavqqwLSVxircKIxFyApHtPw4FuddfJ1iGsEjoJNQ2rkj/a/zq 3L2Fyl2RLl0IG+zPazRDuALZ4OtCOknZ7RRkVeBVOrr6kZolRSnLKx37b+vtzJ8z6kFa 6XvbVm95SJemvYQpqIctdWVXiSMQfWEi6dfz7BT6ueNmFl1ONyW9nZu6rRHw1+BCYQDo DF8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:dkim-signature:delivered-to :arc-authentication-results; bh=tM1YB+GpRsbK/A7b+igTyTogX5zxLAKsUTrBVHfUuVY=; b=JKNac4sdHg8Yr+rN7M4NVKicczoXEq/vkP492heB+rEzRhRbrcG7Cpfq9qzaGJYbgE 2/J98Ko+vPGMBQGO8pv00330kcX8NDnN5jvbuP4s5+BaaMylfoRDGZyX+aPUud94riMn rm768dinhvXBy78IwagEkeP47PEqiD7mgGBbIn0pWtjpBtRJlkyPdu7IIop2tqii8OYX BRJga3j9NbtYVFw1VLKWz99kTABLfs8sHvAsP7VQtzu8vwmmp4FUZ/oLV7L0TTk39M7P w4cVttpVja5gbaBt15QOYASJuROGr2BDis9SRw4e+AZwXuN5Ck9d2J/ZbkytjgABE7Wt Bh0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=pXOYyuP/; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=KIYU6JHN; 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 sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b6si1288757wra.462.2018.02.09.13.41.04; Fri, 09 Feb 2018 13:41:04 -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=@google.com header.s=20161025 header.b=pXOYyuP/; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=KIYU6JHN; 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 sp=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65048689757; Fri, 9 Feb 2018 23:40:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw0-f173.google.com (mail-yw0-f173.google.com [209.85.161.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6AB4F688292 for ; Fri, 9 Feb 2018 23:40:46 +0200 (EET) Received: by mail-yw0-f173.google.com with SMTP id l11so2928789ywh.2 for ; Fri, 09 Feb 2018 13:40:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=cy0o8DFD6YirBl5hBbo3Dqru4DkWUHFhfZAwtmdNV44=; b=pXOYyuP/IKRflTVySRzn5HHfIUx3GQqslW3H9vJVGGRpgY/1vIx2x5GPrJA4geOrYc bRGJfRC50Qo6kvwi3PGqUeIAtQ0jJ/XTtHXdG7RYC/Uq3Nu3NgzFbQ/zyFbWQyiMYsCK 1eioLNVzxmBkyGLWpcD8XYWVySHHGGJlTvY8/CIO2dByx4O+2r9xsNzfqxdk/p37BK6M 8UmalTv5ndy3AL8hDmcbvH9IeSTpbxtnde9+ij/i47mheyZPO99i+NIMiQtp/jI0/JAR DZs68w13Ms1Q41u1GEOWZAPanV67sOJHfw05+TNk8rTQJd+VP/H3TAlVtl8NsJE4mDtq vmiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=cy0o8DFD6YirBl5hBbo3Dqru4DkWUHFhfZAwtmdNV44=; b=KIYU6JHNaEHVShBinALyqVyFKn1pBdxfMjCYuKgxS8U0kSj1+lXR+fUutJAhmH+Fhs jg5F1PKjL76oHACVpMWfvgKni2QEIwg2UsASWGP9nR9kSXSWGksi/k38kQCI7d0Z8FeW 7bJc8YTcOgQGbiq9KP0NZZsqGbgKmZODHHAxA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=cy0o8DFD6YirBl5hBbo3Dqru4DkWUHFhfZAwtmdNV44=; b=hEo4USLT8i5GRieu6WHfmHd8u/WHeC/+GcDpwUhsC2DNr4qmTgQOmqru/WJWWg5UDn 4x5mTn0RYVNQWgWKvPRm6vWOkgCb/F7ywMjviFzuchDgxVPLUuvX5wrfSN4iHcpgiw3F TqcyA50Xb4jojSwN3kLpLwuVRUqUbpEbE4vgm6I2Zx1yKLVbxFPRUnYhozG37e4Oh4za b5xDyYZ/O6t8rkpsw9aZtfAv6DmXv6lT7pT3gwGbyY7QJI+aCbIVetx4IxHWj48DvIN0 YtN8d5p2EMFiN4/5lERBT4gZNG5Z96b88hRijsTY729Hmok9Fnl55vzUEvCc8qqKfqzs xICA== X-Gm-Message-State: APf1xPArih2/o1HI/eJJXQigc4Tyapdr4KLvYo3ZZs0nqvq4pQQrX8iT Rb+8rRbGtGEYWYwnUMjGiqppP0UVz/uPX/eu9ISyKoC0 X-Received: by 10.13.207.196 with SMTP id r187mr3027396ywd.251.1518212097740; Fri, 09 Feb 2018 13:34:57 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:844d:0:0:0:0:0 with HTTP; Fri, 9 Feb 2018 13:34:37 -0800 (PST) In-Reply-To: References: <20180203203607.GJ3063@michaelspb> From: =?UTF-8?B?WGlhb2hhbiBXYW5nICjnjovmtojlr5Ip?= Date: Fri, 9 Feb 2018 13:34:37 -0800 X-Google-Sender-Auth: I_RIenkgLPxMxu7QZ33AlldKeWY Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] Fix ctts_index calculation 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: Michael Niedermayer Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I uploaded a new patch. Is this what you meant? I am confused with the code though. In the case *ctts_index == ctts_count, this while loop will do nothing. Is this what we want? Also, the "wrong" |ctts_index| will be available outside of this function. How do we make sure it won't cause trouble later? On Fri, Feb 9, 2018 at 12:26 PM, Sasi Inguva wrote: > > > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index 5adba52e08..f0bd3e3623 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -3148,7 +3148,7 @@ static int find_prev_closest_index(AVStream *st, > > *ctts_index = 0; > > *ctts_sample = 0; > > for (index_ctts_count = 0; index_ctts_count < *index; > > index_ctts_count++) { > > - if (*ctts_index < ctts_count) { > > + if (*ctts_index < ctts_count - 1) { > > > If you do this, then we are skipping, looking at ctts_samples in the last > ctts entry where (*ctts_index == ctts_count -1), which is not desired. > > (*ctts_sample)++; > > if (ctts_data[*ctts_index].count == *ctts_sample) { > > (*ctts_index)++; > > > > Here *ctts_index == ctts_count only iff the *ctts_index is the last CTTS > entry, and we still didn't reach *index. That means that it's file with > CTTS truncated i.e. no corresponding CTTS entries for some STTS entries. > This issue can be fixed by checking for *ctts_index < ctts_count, in the > line after this loop. > while (*index > party/ffmpeg/next/libavformat/mov.c?l=3123&ct=xref_jump_to_ > def&gsn=index&rcl=184932376> > >= 0 && (*ctts_index > party/ffmpeg/next/libavformat/mov.c?l=3124&ct=xref_jump_to_ > def&gsn=ctts_index&rcl=184932376>) > >= 0) { > we already check for (*ctts_index) >=0 so we can check for the upper bound > too. > > On Sat, Feb 3, 2018 at 12:36 PM, Michael Niedermayer > > wrote: > > > On Fri, Feb 02, 2018 at 05:55:38PM -0800, Xiaohan Wang (王消寒) wrote: > > > > > > > > mov.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > 87157b4053de0e044e78db72ef13e8058075c235 > 0001-Fix-ctts_index-calculatio > > n.patch > > > From bb376fd2de5da5f9ecdef41621a579252b899d7d Mon Sep 17 00:00:00 2001 > > > From: Xiaohan Wang > > > Date: Fri, 2 Feb 2018 17:33:56 -0800 > > > Subject: [PATCH] Fix ctts_index calculation > > > > > > An index should never be equal to the count. Hence we must make sure > > > *ctts_index < ctts_count. > > > --- > > > libavformat/mov.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > should be reviewed by sasi idealy, he wrote this > > > > thx > > > > > > [...] > > > > -- > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > > > Democracy is the form of government in which you can choose your dictator > > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > From cedc04aec7703ce63a7e2b78ee394fcb0999b016 Mon Sep 17 00:00:00 2001 From: Xiaohan Wang Date: Fri, 2 Feb 2018 17:33:56 -0800 Subject: [PATCH] Fix ctts_index calculation An index should never be equal to the count. Hence we must make sure *ctts_index < ctts_count. --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 5adba52e08..c7f70f141e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3157,7 +3157,7 @@ static int find_prev_closest_index(AVStream *st, } } - while (*index >= 0 && (*ctts_index) >= 0) { + while (*index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < ctts_count) { // Find a "key frame" with PTS <= timestamp_pts (So that we can decode B-frames correctly). // No need to add dts_shift to the timestamp here becase timestamp_pts has already been // compensated by dts_shift above. -- 2.16.0.rc1.238.g530d649a79-goog