From patchwork Wed Oct 5 12:38:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 889 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp295073vsd; Wed, 5 Oct 2016 05:38:37 -0700 (PDT) X-Received: by 10.28.207.77 with SMTP id f74mr17035728wmg.35.1475671117182; Wed, 05 Oct 2016 05:38:37 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id tq8si10960982wjb.126.2016.10.05.05.38.36; Wed, 05 Oct 2016 05:38:37 -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; 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 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 83D9B689E45; Wed, 5 Oct 2016 15:38:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f67.google.com (mail-it0-f67.google.com [209.85.214.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 14C0F680D18 for ; Wed, 5 Oct 2016 15:38:13 +0300 (EEST) Received: by mail-it0-f67.google.com with SMTP id o19so10027885ito.3 for ; Wed, 05 Oct 2016 05:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=wsIAxgR35jfqW5Cf2mv0sBeg5c0T/YPK/+AroMu+XSk=; b=jnncm+SfaxAsQaMNeN+C5iPGq/yTgUtsCx0TelqtUGHVjjwi5EPEiW9036Zg/a+J7j Zb5dK2UgFEA9tQbWLdS0kanFYJStgWH8g77KzUwxN2/EjtEgc9AFaOxtSr3srgkeE2eh Hhtg/IvWS6eArbHbT72k+d9lP7OSCRXrm1oxR5DyloBQD1XmVEUegZaPlbmzWNep89dh D2axXdA3TtvuMR85UL+jTd+gwFIV1CRNN8udaFBKlWJFhJL5OWDHZV/+s/uHot0kucHO fo6YP4fEH7l6v0WJezd/nMEteJWILPnQifYZVMyh3spGDcESeG6leBugkCnEjIeGXicm HNag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=wsIAxgR35jfqW5Cf2mv0sBeg5c0T/YPK/+AroMu+XSk=; b=MV4bwZ/uxMdKuwKCSMz7Vre+oUfzjGyRAnFpWi1mpqrnRtOgWKltjQLIYvtQhvPRec 8XQSxxiYC7b7Tip3sGOcBKPAY/DsdJmNxFQVT0MUhP1lGrXAMviUPBPu8yEXuPRf43U+ DjNP0fIYCHfx4Swih+/rDZ+qIrjv7NZtGPs7n8br9UQYrhXHv+4KRU7FiweiCnlto2Qp 5WvJViCJ6JFi0PQoHerxzucpSnHBNn3U6bGDoT7Uqe91FofQx43Wo+UBuB+JntvDoXz7 C6sxEnGlrY9z9VlHjAg76aLl6iHPbpouZ7KHQ4hnWxS/aKXBtnTZrtQ7WmoP8seLP2TP gDoQ== X-Gm-Message-State: AA6/9RnAzMk6AZV3epM4iE88OsnkzRrx/xpi5MovfQHKp8zaVPF2Y082mJxTb87EcIyAoA== X-Received: by 10.36.6.130 with SMTP id 124mr9246160itv.94.1475671106468; Wed, 05 Oct 2016 05:38:26 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-209-137-129.hsd1.il.comcast.net. [73.209.137.129]) by smtp.gmail.com with ESMTPSA id u6sm11557844itb.3.2016.10.05.05.38.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Oct 2016 05:38:26 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Oct 2016 07:38:21 -0500 Message-Id: <20161005123822.91705-1-rodger.combs@gmail.com> X-Mailer: git-send-email 2.10.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavf/utils: ignore outlier subtitle and data stream end times as well 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 3acb260..d19cc5e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2524,7 +2524,7 @@ static int has_duration(AVFormatContext *ic) */ static void update_stream_timings(AVFormatContext *ic) { - int64_t start_time, start_time1, start_time_text, end_time, end_time1; + int64_t start_time, start_time1, start_time_text, end_time, end_time1, end_time_text; int64_t duration, duration1, filesize; int i; AVStream *st; @@ -2533,6 +2533,7 @@ static void update_stream_timings(AVFormatContext *ic) start_time = INT64_MAX; start_time_text = INT64_MAX; end_time = INT64_MIN; + end_time_text = INT64_MIN; duration = INT64_MIN; for (i = 0; i < ic->nb_streams; i++) { st = ic->streams[i]; @@ -2549,7 +2550,10 @@ static void update_stream_timings(AVFormatContext *ic) AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) { end_time1 += start_time1; - end_time = FFMAX(end_time, end_time1); + if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) + end_time_text = FFMAX(end_time_text, end_time1); + else + end_time = FFMAX(end_time, end_time1); } for (p = NULL; (p = av_find_program_from_stream(ic, p, i)); ) { if (p->start_time == AV_NOPTS_VALUE || p->start_time > start_time1) @@ -2569,6 +2573,12 @@ static void update_stream_timings(AVFormatContext *ic) else if (start_time > start_time_text) av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream starttime %f\n", start_time_text / (float)AV_TIME_BASE); + if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - end_time < AV_TIME_BASE)) { + end_time = end_time_text; + } else if (end_time < end_time_text) { + av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream endtime %f\n", end_time_text / (float)AV_TIME_BASE); + } + if (start_time != INT64_MAX) { ic->start_time = start_time; if (end_time != INT64_MIN) {