From patchwork Tue Oct 4 01:10:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 865 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp1892271vsd; Mon, 3 Oct 2016 18:21:57 -0700 (PDT) X-Received: by 10.28.32.198 with SMTP id g189mr10284750wmg.130.1475544117663; Mon, 03 Oct 2016 18:21:57 -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 nf10si1371982wjb.60.2016.10.03.18.21.52; Mon, 03 Oct 2016 18:21:57 -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 D727C689C48; Tue, 4 Oct 2016 04:21:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f196.google.com (mail-io0-f196.google.com [209.85.223.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A8F2A689B5A for ; Tue, 4 Oct 2016 04:21:29 +0300 (EEST) Received: by mail-io0-f196.google.com with SMTP id p26so3908853ioo.2 for ; Mon, 03 Oct 2016 18:21:44 -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=AlLrNxu+yQOg+PCuBSfBZjvsoxU15sBE/TWWHXG6JSw=; b=urk48XqvE9rhxnvBIQdl91g6qrGZ5GqM4E27BldxCBggammA11Wpv7jZtm873zuaSE mh4jNNTKrPbtYsbR7AXtaukNOL2mdsYVpp0BmAKYWNzzzp1QcowuPO1HkbVAxHaVH/Rx ZHhGo882JshPgu3TFoKBqi+MdrtCfj+TSyy9C/fhiAEUNCeNwA3lvM6mLcO//v3St9t2 r4efuei/kX+HCSzekwAFTMJTQMiZlXVexP+HCQMh65PZEWH6R0GahSmSxBh5kz4yQw0B XXolqcJAuv4sZfpakflJnQ/zJLm/baGfNdjXNRtiU0jKCbw24o83iwyepLLJEnxDhVNe ETVw== 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=AlLrNxu+yQOg+PCuBSfBZjvsoxU15sBE/TWWHXG6JSw=; b=gV5CBixM9jd5OHEYfM3jHV9+vT/iTFzfCMa4XYhu3K04IloJk4f4TH31apLGiGOs0v Y5iFbNN+0Kk7lW2dtgfjXnlnEQPHHOQph74Ix1UiVfEy5eYS5gf8FqY5B8XGgc0+r6SN YnloDbkCB9KevphvEj6jUOEWQxCzSMmldVINMGsqU5kuJDgADA9pH7WKGXH2Uiiw5Y49 5+1FyWo1Tb1KbB8CEA2wjP3zLlp0COyJonlYzzl9NsGkDCB/mfYcW5U/NQndEDs9XGcb tfuvP2oVnW9ZT8wHaLhlJhOH1K+C43QlExBLmOK/Q3sYbYKn+rgmWxxGeESQeFAywlnz xOhQ== X-Gm-Message-State: AA6/9RnZeBuW29BmC3EPnCtl9NT3ydQ7cgm7+ktco8fEah1nCNddO+n4XLljg+YAPindBw== X-Received: by 10.107.144.138 with SMTP id s132mr1607507iod.146.1475543423899; Mon, 03 Oct 2016 18:10:23 -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 l15sm663394ioe.14.2016.10.03.18.10.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 03 Oct 2016 18:10:23 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Oct 2016 20:10:18 -0500 Message-Id: <20161004011018.7577-1-rodger.combs@gmail.com> X-Mailer: git-send-email 2.10.0 Subject: [FFmpeg-devel] [PATCH] libavformat/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 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 3acb260..ce68408 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,10 +2573,15 @@ 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) { - if (ic->nb_programs) { + if (ic->nb_programs > 1) { for (i = 0; i < ic->nb_programs; i++) { p = ic->programs[i]; if (p->start_time != AV_NOPTS_VALUE && p->end_time > p->start_time)