| Message ID | 1526413487-24657-1-git-send-email-derek.buitenhuis@gmail.com |
|---|---|
| State | New |
| Headers |
Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp1872324jad; Tue, 15 May 2018 12:45:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqSlpzpraOFd1tKmV9+J9MQ4qiisISwqAOhAlCHpUkjQhFOyfPjZPS81fXJ7vSXZ7qBksi+ X-Received: by 2002:a1c:e384:: with SMTP id a126-v6mr9879779wmh.93.1526413531285; Tue, 15 May 2018 12:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526413531; cv=none; d=google.com; s=arc-20160816; b=Jl5ceI6HMIGq7QQLLYBQ06xls9TVxGa99BIE1lZuYbGTTUcC3GqQx8TtsE8KnbDvWC wD+x0V9j3UBhSBJ/OCgK1hYcgg+O3y6er6+KUf7NBtov+SeYQBu5gMelka69OF+aOcW+ Ef/uNKbDkJckrqXXGM84iRJs1mZhqMCzX/omUrEu5D+jcQOR/d8jW944zT5xPkczYSXX 3jOigrbcOSzUZcshajtXif/wnLIN61EOx6rD68sCQGBsrB7WUqvjQRObx5zVf1xNMk4j lmbwYlbwsVf2BdZRJ55XazpLnD8En9kKcVHobjDwcNd3z/WRVZtFJFl9XQHyUxuCaWSd 7tqQ== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=lHWikfioTvlxso8BmuJxQ11DnYbhw1i0wkVTnFVNrQ8=; b=PqS00dLAf17aV+g+xWfpHy4rZb5l7WOEakluQCTFGqIIGYexfUM1V6/maxlo+BnRmJ cnLXUUcXM2l4SGWaoXiF1os3VzRrJJ5KYkzY6uVZPlkQ55iotEAtseOOY65bnxWNgqF8 ZwG9Me7Ip1MFHsn1PCORIbqY5EflGPtt2EbFrxhrC3IdQeMSlvJbBa6zMzcMev6fep/j T2H0Wz56SeES/ktKnLQEm0RBdZpHdWa8Xh21RCT1v+m8LCKzduWkffEcnnfHt03QAO/A NL53ql/oNEuxdQAYUNAZMCrCN9QFvoEd0S4homR6rbC5/Vv+8quM1152t3wD1pRklMch Lx3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=R6Tcw2fG; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j5-v6si633641wrm.199.2018.05.15.12.45.29; Tue, 15 May 2018 12:45:31 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=R6Tcw2fG; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89EF96802CF; Tue, 15 May 2018 22:44:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA97B6802CF for <ffmpeg-devel@ffmpeg.org>; Tue, 15 May 2018 22:44:42 +0300 (EEST) Received: by mail-wr0-f194.google.com with SMTP id o4-v6so1365145wrm.0 for <ffmpeg-devel@ffmpeg.org>; Tue, 15 May 2018 12:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=XaJfJziSE+qjpkhBpbxaaNtjXXQ2/xRAu8kJ8K/yquc=; b=R6Tcw2fG0sX9KDeterKrVQwTWaWPvt3SDYfGnEsKNjG+c5ud11jj675oJXkRvXirIG Yot5nCyBZFAlKXfNIXRwF+kLonKfloIgkDKPi97V0RKL5DdBUdtM8QksK5/4A8cazOi4 AcW5qBhtnbrPzusUKqHnKTA2AgCCjIHfj/jJLRsczkBnlchGW7pNAsCeOkzFOtbTcih1 mq7NZeJ1Sa6i7IexV4XQEw0nfgAtdjAjFav5/e9kigAgLG8n5bVs2A3KOSWd4j9BczqY 3M2+26LElcEgIgJHJVC4+yini9B5TMQAdnHl8OmM4679rz2HUt53RymRJ5U3pwpmedxt YFwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=XaJfJziSE+qjpkhBpbxaaNtjXXQ2/xRAu8kJ8K/yquc=; b=HljEj8/d8fDbxMlOLNIyESgVSrJsh5tyU43yJWxUZWDFc9aGgFgt/u4/ehsU979laJ aXrHLhyUpgKPHI7KrRSbm1GPoIs6DsFLHJzqNTZWf+CSTWui7WmZrMg1u8hC1LB3GRQi zy1l+ldxFhSGLLq75YmvWBN0xp8Owi2B6i7v7bhbU6S51kEBdCBePPS4wUNdG57voNSH yS1VJ+IZQOlHvC4vB/alsAy8gJePBZW+TCvtM8JLsncGDuD3WnGdAE/y+HSB2inPFCCt CIINzvAgLfaYeerQDcvBdCX6n7R9ZGrW+/F/rJIKqLd/l+Ru1oP405abmfZK+29/UVi7 Ralg== X-Gm-Message-State: ALKqPwfPoNOXFJqLyIsNyql44tCGkZWGvocCyji8ZSVdGK+AZT9SK8ZW 14sYoKi1LWd2W2ppVDiGObI66MUL X-Received: by 2002:adf:9b98:: with SMTP id d24-v6mr12629592wrc.240.1526413520313; Tue, 15 May 2018 12:45:20 -0700 (PDT) Received: from localhost.localdomain.localdomain ([81.2.155.129]) by smtp.gmail.com with ESMTPSA id f10-v6sm1366134wmc.0.2018.05.15.12.45.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 12:45:19 -0700 (PDT) From: Derek Buitenhuis <derek.buitenhuis@gmail.com> To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 May 2018 20:44:47 +0100 Message-Id: <1526413487-24657-1-git-send-email-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH] mov: Make sure PTS are both monotonically increasing, and unique X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <http://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <http://ffmpeg.org/pipermail/ffmpeg-devel/> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: isasi@google.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> |
Commit Message
Derek Buitenhuis
May 15, 2018, 7:44 p.m. UTC
We already did this for audio, but it should be done for video too.
If we don't, seeking back to the start of the file, for example, can
become quite broken, since the first N packets will have repeating
and nonmonotonic PTS, yet they need to be decoded even if they are
to be discarded.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
libavformat/mov.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
tis 2018-05-15 klockan 20:44 +0100 skrev Derek Buitenhuis: > We already did this for audio, but it should be done for video too. > If we don't, seeking back to the start of the file, for example, can > become quite broken, since the first N packets will have repeating > and nonmonotonic PTS, yet they need to be decoded even if they are > to be discarded. Why don't we do this for every format? /Tomas
On Tue, May 15, 2018 at 9:10 PM, Tomas Härdin <tjoppen@acc.umu.se> wrote:
> Why don't we do this for every format?
In this case, it is specific to MOV and MP4, since it's caused by the
way we apply edit lists at the packet level (reordering, marking them
as discard, changing timestamps, etc.). Previously we didn't much
care to set the discard-flagged packet timestamps properly, which is
what this fixes. It's not a high-level vsync sort of thing.
- Derek
tis 2018-05-15 klockan 21:21 +0100 skrev Derek Buitenhuis: > On Tue, May 15, 2018 at 9:10 PM, Tomas Härdin <tjoppen@acc.umu.se> > wrote: > > Why don't we do this for every format? > > In this case, it is specific to MOV and MP4, since it's caused by the > way we apply edit lists at the packet level (reordering, marking them > as discard, changing timestamps, etc.). Previously we didn't much > care to set the discard-flagged packet timestamps properly, which is > what this fixes. It's not a high-level vsync sort of thing. I see. Well, I don't remember too much about MOV these day so I'll leave this to someone else to actually comment on :o /Tomas
On Tue, May 15, 2018 at 8:44 PM, Derek Buitenhuis <derek.buitenhuis@gmail.com> wrote: > We already did this for audio, but it should be done for video too. > If we don't, seeking back to the start of the file, for example, can > become quite broken, since the first N packets will have repeating > and nonmonotonic PTS, yet they need to be decoded even if they are > to be discarded. > > Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> > --- > libavformat/mov.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Ping. Is nobody outside Sasi able to review code in this part of mov.c? That is slightly worrying to me. - Derek
Hi. sorry for the late reply. I sent a patch similar to this a while back
https://patchwork.ffmpeg.org/patch/8227/ but it got lost in the sea. You
also want to do,
@@ -3579,7 +3579,8 @@ static void mov_fix_index(MOVContext *mov, AVStream
*st)
frame_duration_buffer[num_discarded_begin - 1] =
frame_duration;
- if (first_non_zero_audio_edit > 0 &&
st->codecpar->codec_id != AV_CODEC_ID_VORBIS) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
&&
+ first_non_zero_audio_edit > 0 &&
st->codecpar->codec_id != AV_CODEC_ID_VORBIS) {
st->skip_samples += frame_duration;
}
so that we only increment skip samples for audio streams. Otherwise patch
looks good to me.
On Thu, May 17, 2018 at 7:03 AM Derek Buitenhuis <derek.buitenhuis@gmail.com>
wrote:
> On Tue, May 15, 2018 at 8:44 PM, Derek Buitenhuis
> <derek.buitenhuis@gmail.com> wrote:
> > We already did this for audio, but it should be done for video too.
> > If we don't, seeking back to the start of the file, for example, can
> > become quite broken, since the first N packets will have repeating
> > and nonmonotonic PTS, yet they need to be decoded even if they are
> > to be discarded.
> >
> > Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> > ---
> > libavformat/mov.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Ping.
>
> Is nobody outside Sasi able to review code in this part of
> mov.c? That is slightly worrying to me.
>
> - Derek
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Hi, On Tue, May 29, 2018 at 5:04 PM, Sasi Inguva <isasi-at-google.com@ffmpeg.org> wrote: > Hi. sorry for the late reply. I sent a patch similar to this a while back > https://patchwork.ffmpeg.org/patch/8227/ but it got lost in the sea. You > also want to do, Sorry I missed that! I'd prefer to use your patch over mine. I'll hold off on a push for a day or two until I figure out how to handle (or not handle) the midstream PTS. - Derek
On Tue, May 29, 2018 at 07:20:33PM +0100, Derek Buitenhuis wrote: > Hi, > > On Tue, May 29, 2018 at 5:04 PM, Sasi Inguva > <isasi-at-google.com@ffmpeg.org> wrote: > > Hi. sorry for the late reply. I sent a patch similar to this a while back > > https://patchwork.ffmpeg.org/patch/8227/ but it got lost in the sea. You > > also want to do, > > Sorry I missed that! I'd prefer to use your patch over mine. iam fine with sasis original patch too [...]
On 30/05/2018 00:48, Michael Niedermayer wrote: >> Sorry I missed that! I'd prefer to use your patch over mine. > > iam fine with sasis original patch too Pushed with the changes that were requested in that thread. - Derek
diff --git a/libavformat/mov.c b/libavformat/mov.c index 1975011..a74983f 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3579,7 +3579,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) flags |= AVINDEX_DISCARD_FRAME; av_log(mov->fc, AV_LOG_DEBUG, "drop a frame at curr_cts: %"PRId64" @ %"PRId64"\n", curr_cts, index); - if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && edit_list_start_encountered == 0) { + if (edit_list_start_encountered == 0) { num_discarded_begin++; frame_duration_buffer = av_realloc(frame_duration_buffer, num_discarded_begin * sizeof(int64_t)); @@ -3605,7 +3605,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) edit_list_start_encountered = 1; // Make timestamps strictly monotonically increasing for audio, by rewriting timestamps for // discarded packets. - if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && frame_duration_buffer) { + if (frame_duration_buffer) { fix_index_entry_timestamps(st, st->nb_index_entries, edit_list_dts_counter, frame_duration_buffer, num_discarded_begin); av_freep(&frame_duration_buffer);