From patchwork Thu Apr 19 23:51:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 8517 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp42075jad; Thu, 19 Apr 2018 16:59:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Rq9E1JwoXyNyqgH5mdL8Aetj42s4c4b2oOxU1YtEVzA94P5p9xsgloLyP+zsls7JJq5YN X-Received: by 2002:adf:9607:: with SMTP id b7-v6mr5847234wra.129.1524182343733; Thu, 19 Apr 2018 16:59:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524182343; cv=none; d=google.com; s=arc-20160816; b=K6F2MgCfcAB6+/3Pfj3n4bXYZ7CIzO7JR4t+5WN/l2GTyaHf0UfS2LwutlFYNt8eYy v/a36ebxu+eFT/8jNCUfFDzIOhLOe8by8LoZKQMs3wKolH+ucO6CxaJ8F22VDuMku+jw zWuArY8MmGBRUlp5LXDllDE1eXP6vVHlVDoalYKDd+d+VJFOdCBTyEkG8EAVXmfm61Tw EQ4P0BfgGx14MLM62j95FwazCvhFqeo5T05QFs5HwIpcNtVbC/LmFg8qZ86X1X18Ycqt K2ffFkYvn3ifRdEs7Pir8aOK5+AGGTTSYN2glVtPMgMTjYkdhoyRN9SclHkCRc1OI35z WJXg== 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=M+k5kCaRa8wM+fUGFMsvD/ON/QF+LNIOQSF5cm0V2vQ=; b=PflntD5BFLwpOunpdXKfQNVrXR7MpfRCZg3G/8i78ZTeAnQDMr9aFaSa5e31E0HXbc mNuBF1rGpdSrGqpmh8EioU5c3HsYMxoov/dhmJKIzPd6JHA1QTZJ/AEKqHDkKcYQrfNC dxrvIoEC02UCFmO8tADIcugwTlPyhuFF5tOnleGGj72oiK1jnnCL9dwwBSUGHS7mAc2N SrNm0NLEQVjgEbjAB0ZAGN/7tyumfZhRJSt5q9f8UmewaM9eiik/xT7zNkvVPcLsIPfG p9GB7xs87gZUQVsvgAMNZimsaWHMlzmA6tQFYD7Jc8MYRABnwArSXLwvBPaB+VEkohoh fTeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=P3QD3Dy0; 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 e7si157536wme.78.2018.04.19.16.59.03; Thu, 19 Apr 2018 16:59:03 -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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=P3QD3Dy0; 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 E3C1368A088; Fri, 20 Apr 2018 02:58:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7D3F8689E35 for ; Fri, 20 Apr 2018 02:58:26 +0300 (EEST) Received: by mail-pg0-f65.google.com with SMTP id e9so3228913pgr.7 for ; Thu, 19 Apr 2018 16:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=69KAcQVkqL8bLzMqMsPSs8Pmw43o1c5cgU9fOqFFEMU=; b=P3QD3Dy0aS24hXBTWGohg5Id20aP183jo6mYzWFZusZIPUMf6GsoAGk8BYXjHlPASG i6a+ngr8UNBMtCHbP+huaxIQu2dtAkh8PYg1ruqI69QG36VhQjxtMCGYhbG/6vbM3/bl 8yMVUBvGl9OlS/ZOg/2oQ4KqMxWBToJW6p/Reglaj8k001E9wjQkzj/9lXzVlcaGWDw5 0JbgRxKgDsjBNZSyR9e6ZssfgW/EGW6NCyYs2Uyh5769H6+WY8jOpO5YsqXQpOtyfmMH EuS9/+EAkDXUEWLlvOMOig5IJZkpH3ktr8JWDuukq0x3b6daimdke0jikwR8BFhW7pq1 wTmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=69KAcQVkqL8bLzMqMsPSs8Pmw43o1c5cgU9fOqFFEMU=; b=MHEALcYJZ/rfhpuqppmCWj9n8vxn032sbyNmYRHt5lJswaygzCRK68NkeJ8tqKLcXp dhq/HFjXlCHtnzfQ1pVbZqUuGnLhdK1Yg1pbVpBl0sNQO1IxZrZXAcQYXvgDDCGQeZP5 cVHrMI/dCWEqfNqi84Qgzh25s5pmKHIpc/gN5US0BINOXkx+yOqfHUijT5aHiJTxxeH6 fmTbvtpoxDQhSC+lpTN/4RIelecWCk4WrRdhsCyHvv+qEMJdFH1uOfVxtYqYngHIOTV9 HCm+TAAZ1xHcJK8ErTOUrkh2G7Qp27fq+SfftDaxqRr895yxecJ8lW/Nv68/Nf/3+Z/F cpAA== X-Gm-Message-State: ALQs6tApW2EsNvVlwFrD0YjjsVWRzXwd0h1T/3nDOWxHFuB5+ayVYeM+ akE5C7JNJ241r6LBpLp8zAvh7Vk2 X-Received: by 10.101.96.141 with SMTP id t13mr6741437pgu.222.1524181898752; Thu, 19 Apr 2018 16:51:38 -0700 (PDT) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id 67sm10361101pfp.122.2018.04.19.16.51.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Apr 2018 16:51:38 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Apr 2018 16:51:34 -0700 Message-Id: <20180419235134.76459-2-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180419235134.76459-1-ffmpeg@tmm1.net> References: <20180419234318.GW20131@michaelspb> <20180419235134.76459-1-ffmpeg@tmm1.net> Subject: [FFmpeg-devel] [PATCH v2 2/2] avformat/utils: refactor upstream_stream_timings 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: michael@niedermayer.cc, Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta --- libavformat/utils.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 705b79031d..c25eab4d49 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2620,7 +2620,6 @@ static void update_stream_timings(AVFormatContext *ic) int64_t start_time, start_time1, start_time_text, end_time, end_time1, end_time_text; int64_t duration, duration1, duration_text, filesize; int i; - AVStream *st; AVProgram *p; start_time = INT64_MAX; @@ -2631,21 +2630,22 @@ static void update_stream_timings(AVFormatContext *ic) duration_text = INT64_MIN; for (i = 0; i < ic->nb_streams; i++) { - st = ic->streams[i]; + AVStream *st = ic->streams[i]; + int is_text = st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || + st->codecpar->codec_type == AVMEDIA_TYPE_DATA; if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) { start_time1 = av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q); - if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { - if (start_time1 < start_time_text) - start_time_text = start_time1; - } else + if (is_text) + start_time_text = FFMIN(start_time_text, start_time1); + else start_time = FFMIN(start_time, start_time1); end_time1 = av_rescale_q_rnd(st->duration, st->time_base, AV_TIME_BASE_Q, 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; - if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) + if (is_text) end_time_text = FFMAX(end_time_text, end_time1); else end_time = FFMAX(end_time, end_time1); @@ -2660,7 +2660,7 @@ static void update_stream_timings(AVFormatContext *ic) if (st->duration != AV_NOPTS_VALUE) { duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); - if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) + if (is_text) duration_text = FFMAX(duration_text, duration1); else duration = FFMAX(duration, duration1); @@ -2671,11 +2671,10 @@ 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 - (uint64_t)end_time < AV_TIME_BASE)) { + if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time < AV_TIME_BASE)) end_time = end_time_text; - } else if (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 (duration == INT64_MIN || (duration < duration_text && duration_text - duration < AV_TIME_BASE)) duration = duration_text;