From patchwork Thu May 31 23:23:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasi Inguva X-Patchwork-Id: 9218 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp211161jad; Thu, 31 May 2018 16:32:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLpo4INjDhAQNctafkR+JefJrp7SfrGTHVxG8W+wsyePP45EPkRbLTWwV4SdNIDNbPvD2vO X-Received: by 2002:adf:ab10:: with SMTP id q16-v6mr4388047wrc.239.1527809576890; Thu, 31 May 2018 16:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527809576; cv=none; d=google.com; s=arc-20160816; b=CTn0sO/w5D20EOWEnlEIrterOmz869XFZakcRhusrJlVtkk0eOwOTKN612oE+6T5Xk KqBiSLITo2LFnMzonk0Vl01+It3aIIzhUqG19qabDB0DTPQbQ7Mt9ca7gvxnAisoCuBZ Nhay4hMyj1BQe+hyF1e2M9qG/ssa9DJgVF6mHiPduAHMTF+pyr28PMQWlJsQJa8e9kDA GUDHWfKxbZPSJnDSAIArajJMDssMfaRxMwCWRDuUMHf2POVhb93uL4Z0PhUMExD3wugB 3FmRhM1ufPGLMKO1Y8Svm9kjKvUFIE6sywo1zMHI1YbXcELuHL5FG9fPdKPt5LSPOJtO Buow== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=QeRDpBwZbM8mblCxQVSEKsVd9AtA0jpnkVak26oKwOE=; b=COlbrVPu8ehjaFG2j8SWeA+AP8qW+59IMCGsvP/mT6TNvlFVoUcwpKbcd//yOhMaMe xdXI0CRSnTKCVRQDlb7TsWQ1riLLJ1yi/F61aFjCQ1EJxUevfJSQh5vYeC67uAtVOmnX 3QSbCPab5QOUTvw6Dgy6A65S6vYRyFrcmBkaBwBzqAh2yt+prE5mKJb/MJRCxzg2TiAU 99A47awIZPn5P6rXW87BLaCTEhgaD8Uhh8ZX5hi8czPxfAAo5UnRBuvSIWlXljQFGk3N wAiHkhlRKZ8KtuYwPvyTXdMZQkYR/iPCwXlwicFth5NVr4MHpUCVfHvhlDIje11IDIv7 Ihxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=nqmhOfTU; 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 y39-v6si412906wmh.88.2018.05.31.16.32.55; Thu, 31 May 2018 16:32:56 -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=@google.com header.s=20161025 header.b=nqmhOfTU; 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 8551768A451; Fri, 1 Jun 2018 02:32:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5550268A3E2 for ; Fri, 1 Jun 2018 02:32:02 +0300 (EEST) Received: by mail-pl0-f65.google.com with SMTP id t12-v6so14149505plo.7 for ; Thu, 31 May 2018 16:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UYd/txUirUBV3yrUFAwt9UO06Iv7N7MCkg0U5pk0UXQ=; b=nqmhOfTUyjX0iIFiSQZLHpcrewxF9HpxmOUFndoMy5kgNt+6ZMB5mnpoVja7+nE2E2 3jgnqBxHYa6fjde/Ecol7ZWBLt7qrDarNKYqW3+eC+55EYy4nR2grd184u87ujPkao4J aXX05OFb7llONLT1Sso7yrAfLGfhLVu7ordmsAw7qDxlce1nJUPhrdXyZfAgSX6DIQQL YP7FNPSyFO3H8dsFjk4cJsZVHwCDmtszp/ei2pgrogTZTll6W9WvyDTTIGt0su39CXe8 5hMkYQPw1kLLiRscHx1uhH9hKAH0biA6cq9WNm/eYG0/WLSDhHj5rNLF5M1VELyFfZ5c ejzA== 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:in-reply-to :references; bh=UYd/txUirUBV3yrUFAwt9UO06Iv7N7MCkg0U5pk0UXQ=; b=Oq3YuhPwypjryiEzQVjvxgIPauU+qIqLif66aEzWipJhHVRL/G1J1A/diKBceALcEo 8bMdUuZmWHlovHXnmyqtClOyCmsf8kwMKG26PG4sh8wWL+Y4natMJsS6B06VnsDWIVvV nigVGubTd6WXWlfA0CddFMzfodHc04u4mULvecR4Ruz03QnO5JxUqZfTZ4eCi7qE1iLi SvF8DHA6bEULf47tgQKizTbfUMncxtwkl1aM8CTY/Wj/3B7jQn8e4xvqnJgXRut3AxA9 VigDoNGnHjWl1S5nHSsU7w2rgEWD6Ob141vSQ7mC/xmBRRjV2F/IfY0mhz/aQlg8rko/ KMcQ== X-Gm-Message-State: ALKqPwdCbDacv8rZLOm+Zp3a3hS776Qnl5bHzvaKRZW6feZC7dcxTmbq StZ5fa30TBUtIIM/gCt3N1J8P53MleA= X-Received: by 2002:a17:902:7883:: with SMTP id q3-v6mr8852655pll.71.1527809082237; Thu, 31 May 2018 16:24:42 -0700 (PDT) Received: from isasi.mtv.corp.google.com ([2620:0:1000:4001:9a31:e971:b584:8af7]) by smtp.gmail.com with ESMTPSA id o88-v6sm104521976pfa.29.2018.05.31.16.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 16:24:41 -0700 (PDT) From: isasi-at-google.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 May 2018 16:23:19 -0700 Message-Id: <20180531232319.102393-1-isasi@google.com> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH] lavf/mov.c: Fix timestamps to be strictly monotonic for video also. 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: Sasi Inguva MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Sasi Inguva Using same timestamp for multiple packets confuses clients like Ffms2 while seeking to a packet with specific timestamp. Signed-off-by: Sasi Inguva --- libavformat/mov.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index cb6f3a45de..39d21e6e1c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3554,7 +3554,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) edit_list_dts_counter -= packet_skip_samples; if (edit_list_start_encountered == 0) { edit_list_start_encountered = 1; - // Make timestamps strictly monotonically increasing for audio, by rewriting timestamps for + // Make timestamps strictly monotonically increasing, by rewriting timestamps for // discarded packets. if (frame_duration_buffer) { fix_index_entry_timestamps(st, st->nb_index_entries, edit_list_dts_counter, @@ -3568,7 +3568,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)); @@ -3579,7 +3579,8 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) frame_duration_buffer[num_discarded_begin - 1] = frame_duration; // Increment skip_samples for the first non-zero audio edit list - 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; } } @@ -3594,7 +3595,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);