From patchwork Sat Mar 31 22:12:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 8259 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp1036571jad; Sat, 31 Mar 2018 15:12:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+T21arTABYnskO55L7bJlDiiLfRQWsG1FZEZ+5CoyHdVzI0D1s9Ote3SuT5GzmXc8S7rWc X-Received: by 10.223.171.26 with SMTP id q26mr2806025wrc.183.1522534361100; Sat, 31 Mar 2018 15:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522534361; cv=none; d=google.com; s=arc-20160816; b=i//kn6JWfNLrDVvUsbEN89SfYiQL0jSeAJbeplEoNHwjCcO4PZc5EMuXV3urLQ/goM nFjeBp8rkcw0kKdepyKfmO0pYQiKD/2YtYp4kkU2KJn/C+wgnZYLoK4FPV4YXVOACRU6 Ttg7lG3FWAcY6a/DGc6Dte3otFVhV7bwydXyQ+EMsq1APMe2RYK4UfRavm7RgW0Np94j 2VrWa2k1cwjJ4Dg5LGa5ch1pxvGCNS1Uif/vr9F69vk/vV208WaSvACBhetZxIQCoVN0 CnI+UrCOrsUj7iU7/bhQSHf35bSgV7Gx3feV4YSb3gTvtGZZWAREmiWDodQNKYCurPtS 94vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:message-id:date:from:references:in-reply-to :mime-version:dkim-signature:delivered-to:arc-authentication-results; bh=inTE5ilgmTLzN6LF6jTC9wmoVv/C1mVx+1zX9Z111II=; b=B20puO/iHvjj3jTyGtaVja4CyQVN6nn++XCE4KXk68t34ema+tESdRkCDtvUizeDME WwHQ6DMZueidpVwqQHObCqIvzzupH8WkWRD3Dx2O0F/6OKOOFKxO3r9NhA254MMzwM1P kVNaPVGWM9V0oSI3u00i82vwWi5W7Pdktc75FGZXuECUcqZ8EteJ6m24b4pA7deXNS31 LHgFnK/guBRKuI7cgA4Dn87l5n3q6JgfJNckrGxGKvF+2ACfjeKPp+9XEkqfFh6JZqow D4j2uem3DjUee/xpER5asjvQ8hX4XsrQegZggQQLwv0ZWp5SN1GBanLqqfNlBrVD4TSS eKjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=agIhLQ0A; 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 sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d21si8754536wrb.222.2018.03.31.15.12.39; Sat, 31 Mar 2018 15:12: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=@gmail.com header.s=20161025 header.b=agIhLQ0A; 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 sp=QUARANTINE 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 8AE4068042B; Sun, 1 Apr 2018 01:12:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F2AA680284 for ; Sun, 1 Apr 2018 01:12:11 +0300 (EEST) Received: by mail-lf0-f46.google.com with SMTP id g203-v6so16397722lfg.11 for ; Sat, 31 Mar 2018 15:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=TJ/9QdP6OFCiGiXrg8qhLVL81QTa3TOrqr7aVYn8eNs=; b=agIhLQ0AOlf7il6Th2VHVO7+EBi8eBpRNJSUvFUAn2BrtiLJMN1cLXX1fOQiTg8gPU U8GgrHJ6K4z4EyTf6zHQXkh4sfrHgQmyC4FLk+BEpsjpNw4vCkl4ORtSzXiGia7fkNyn Eoh2GO+yxLwJSooGncYsn64OizNvJsFY050xBj1TxS2mS3BrFdyXlFf7F7huXJbMkTtl Py5kdHmExsT7sKzvvMd65oGRKz+DvHXiNvSum45blFDgp9HvAEWTHnGgG9bTf6bjQC0V OK85wiP77pizcNG4cwiN0ZKi/HcUfuD1FV/Fgw8bpTJgXTLZb0+0Kn0N/L0EAMdydaqr bGLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=TJ/9QdP6OFCiGiXrg8qhLVL81QTa3TOrqr7aVYn8eNs=; b=lRiMGFzTW44ULZGoaGVRtP+tDt9T/Lk5az24l3+y3weKPcDf58zmElBoyp3aLXTxOz 4uZviBAKCE6tc9VXRTSfjTApAR4o5P8Q3LScJmnwlhFuUB5DttwsrqLcZ+sezxJejh9m eCiIZzEJmLMqOi62Zj8GFctltZlZz99nHzyGug6gGUwEp1AJlCM3CZvgDAua22LtnTgz Wr9Qt0SlzcVKKpYjGEM4787p8MlaVD18cXBEa1bz4lg4B+Ej5xVU/Cjl0PfuLcQt0Nmh ml8sGi2IKRI12g1oKg/wcpejW8KeH5SyfLp7YSXHcVj7qGkq4LSqBeqh2fUbgnO+uw3D odnQ== X-Gm-Message-State: ALQs6tACz6gkyVImrLlhJ1QMJvV0MCj5GsMMrWLsw//U3nw99d4G+JEm 3XLuUJAo8ujo8MH0zaEojhvBj42XSAsNRn+5WF1Mexhf X-Received: by 2002:a19:7708:: with SMTP id s8-v6mr2301311lfc.93.1522534350251; Sat, 31 Mar 2018 15:12:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.133.131 with HTTP; Sat, 31 Mar 2018 15:12:29 -0700 (PDT) In-Reply-To: <20180331170904.21797-1-jeebjp@gmail.com> References: <20180331170904.21797-1-jeebjp@gmail.com> From: =?UTF-8?B?SmFuIEVrc3Ryw7Zt?= Date: Sun, 1 Apr 2018 01:12:29 +0300 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] ffmpeg: prevent premature EOF in sub2video with nullptr AVSubtitles 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On Sat, Mar 31, 2018 at 8:09 PM, Jan Ekström wrote: > With certain types of input and the filter chain getting re-initialized > or re-configured, multiple nullptr AVSubtitles can get pushed into > sub2video_update() in a row from sub2video_heartbeat. > > This causes end_pts, and on the next round pts, to become INT64_MAX, > latter of which signals EOF in framesync, leading to complete loss of > subtitles from that point on. > > Thus, check that the sub2video.end_pts is smaller than INT64_MAX > in a similar fashion to sub2video_flush before sending out the > nullptr AVSubtitle. This keeps premature EOFs from happening in > framesync and the subtitle overlay is kept past the filter chain > re-initializations/configurations. > --- > fftools/ffmpeg.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c > index 4724f62fff..d3bc382dec 100644 > --- a/fftools/ffmpeg.c > +++ b/fftools/ffmpeg.c > @@ -285,7 +285,8 @@ static void sub2video_heartbeat(InputStream *ist, int64_t pts) > /* do not send the heartbeat frame if the subtitle is already ahead */ > if (pts2 <= ist2->sub2video.last_pts) > continue; > - if (pts2 >= ist2->sub2video.end_pts || !ist2->sub2video.frame->data[0]) > + if (pts2 >= ist2->sub2video.end_pts || > + (!ist2->sub2video.frame->data[0] && ist2->sub2video.end_pts < INT64_MAX)) > sub2video_update(ist2, NULL); > for (j = 0, nb_reqs = 0; j < ist2->nb_filters; j++) > nb_reqs += av_buffersrc_get_nb_failed_requests(ist2->filters[j]->filter); > -- > 2.14.3 > A diff which I utilized to help with testing this. I can share a sample to test this over on IRC. Jan --- if (sub2video_get_blank_frame(ist) < 0) { av_log(ist->dec_ctx, AV_LOG_ERROR, --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -247,10 +247,17 @@ void sub2video_update(InputStream *ist, AVSubtitle *sub) end_pts = av_rescale_q(sub->pts + sub->end_display_time * 1000LL, AV_TIME_BASE_Q, ist->st->time_base); num_rects = sub->num_rects; + av_log(ist->dec_ctx, AV_LOG_WARNING, + "normal AVSubtitle: utilized values: pts=%"PRId64", end_pts=%"PRId64", " + "num_rects=%d\n", + pts, end_pts, num_rects); } else { pts = ist->sub2video.end_pts; end_pts = INT64_MAX; num_rects = 0; + av_log(ist->dec_ctx, AV_LOG_WARNING, + "nullptr AVSubtitle: utilized values: pts=%"PRId64", end_pts=%"PRId64"\n", + pts, end_pts); }