From patchwork Tue May 15 19:44:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 8980 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: 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 ; Tue, 15 May 2018 22:44:42 +0300 (EEST) Received: by mail-wr0-f194.google.com with SMTP id o4-v6so1365145wrm.0 for ; 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: isasi@google.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- libavformat/mov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);