From patchwork Mon Apr 2 17:36:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasi Inguva X-Patchwork-Id: 8288 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp2772659jad; Mon, 2 Apr 2018 10:42:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx48V1MWbrYIJ1rCrLwSWM1LTCv7QPyYAZB8O3M+3F1eivS1EoCdpxlU6V9DeqPAZ7xRfsufe X-Received: by 10.223.200.138 with SMTP id k10mr7758377wrh.282.1522690961926; Mon, 02 Apr 2018 10:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522690961; cv=none; d=google.com; s=arc-20160816; b=0kt38WC12bVA9Fs5MUVWYgwgc5CNqgtQYSGp0pygYRGIEMQSTTjimNRJ70NzhR0Lqs cpHhyCn1eabB/jH1oITECVf3FhZ99RiYF/lb6tYzMaCCxxEEMTyfcisNyUVxJssNa07X 6p4F7NXzPT8q0PQ9zm/G+EfxOESKxwW+mNj41NKgqw8NFaX+yHXysS+0qCpw4mpJ1lCN jMdfHwsGDJ4imte+5xu+x0bMwnpGi7ZqsJdalqAYVdTOnVmq/hCfmK7zC5ATAfWYGZLz EqI4QRpywQkt9y/q3AfqYvkPMS8mTk/tqxpJLSCrPg2cPpExR+CJp4qx1n+Iv7Q1D0tm O2iQ== 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=opLp0OlpnZH2N8sHcIlgnQg7ND13pKOdXwYABUwDcy9MSTHxhEpEonUBOFbd0uMhBs kgFlYztmRP1YAIFQkoGrsOIFgHf3WUmUFF8DzdXSmaxwsv5Db6ybOfigmQeJmn9G5ZBk tdKrCeSOEXZBTPbIfyNzSGD60QWp2cmDAbZNhX4zNTzm/RWRH0s4oXUJ3rk0C/irZjK7 1iqSMZgbM6uDUutrtkmgvvDqVqLCUcairveK7EBaCBtFIpK86K4XhAftDPpNvvqpOyjP r3LsmWMHSSMfrJfEh8qwPDzEPuq92rLaGZppLZrtFPHLBaeMWC3dPBoV33ZEtQpEbxS3 u50g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=llCg5vjN; 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 128si728252wmh.192.2018.04.02.10.42.39; Mon, 02 Apr 2018 10:42:41 -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=llCg5vjN; 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 D5E2C6807F8; Mon, 2 Apr 2018 20:42:17 +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 51FE26800A2 for ; Mon, 2 Apr 2018 20:42:11 +0300 (EEST) Received: by mail-pl0-f65.google.com with SMTP id bj1-v6so2588676plb.8 for ; Mon, 02 Apr 2018 10:42:31 -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=llCg5vjNKdQXnIWFpDIX9vCkpQaVeO/DSxRtFzt7wMyItzSuMdNpnuL+BY41Nlso8N AW5Xmg3/q+Z/eEza40/rGYZTyBqPk/LoS5Wo/yv2JsXcZHvNQeFVcO0TZE7441qpxKG6 Po3+zX/OrNeeKiDcjOWCrB+w86v0sxAsYhP+a41euLQbMIuzYBelzh44HMPgYsOKHmvj Lv+4CDfzHGYO+5BsVp4+RVpS8EMojnaGNWKrlm8VlgiAQ6RAbzkUFejZ4PJv2oP6nC1l trOO/DR27r79y3i7X8J2WeOhn5HUfj5vtsA5lPqRYxky6JhyXyX5qG6aalE1oI2DSPFG wb2Q== 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=ZdIaW45axbde8YxfKh5Bs6UMFTpuYzdugyCAARwcCyDSnsUdoIauLfqhwM/dyHJiXC C1UCqnOBibXbDhWRv+aUCycGmOFs5I2MQKIPMEl30FhxWLJPNERi3W+AkO2ur7Gd27DP FKkRCkd6AASLSwC0A2jYPWqCQI3l4dhD4tOs9O5wv+Exuk6z3nfXBaTGlFjcofO2CIjj 2ivDvtUeUjqimzXyuGDHFLeL+Wor2TjzxNXwGcssV8r5PIIGLzwSApq8AGY285OkLo0k wTwEoq1zgG8SIgBN+MUbhIcuEwKSSY0LKg44Oh/wsBXzzZRCZi1O5skvMJtm1EV6cZ1q gP4w== X-Gm-Message-State: AElRT7HW/lUADad4NYaTCdD+cB9qv42U26IIpi0sUxO1hxdMvgNBOQtz Ga2oBB9s/vPIWdlrWyOiytwjEvL8/9o= X-Received: by 2002:a17:902:a701:: with SMTP id w1-v6mr10587132plq.109.1522690616161; Mon, 02 Apr 2018 10:36:56 -0700 (PDT) Received: from isasi.mtv.corp.google.com ([2620:0:1000:4001:9a31:e971:b584:8af7]) by smtp.gmail.com with ESMTPSA id x3sm1325736pgv.86.2018.04.02.10.36.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 10:36:55 -0700 (PDT) From: Sasi Inguva X-Google-Original-From: Sasi Inguva To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Apr 2018 10:36:08 -0700 Message-Id: <20180402173608.232504-1-isasi@rodete-desktop-imager.corp.google.com> X-Mailer: git-send-email 2.17.0.rc1.321.gba9d0f2565-goog In-Reply-To: <20180331221657.GS20131@michaelspb> References: <20180331221657.GS20131@michaelspb> 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);