From patchwork Sat Mar 31 17:09:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 8256 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp849445jad; Sat, 31 Mar 2018 10:09:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx498BrSkEadXMxki47JudV4gDUZVERdBsBvM8O99IqHr/WMCNxxq09MieSnLXsyF2NrakO3F X-Received: by 10.28.45.200 with SMTP id t191mr1449463wmt.7.1522516154505; Sat, 31 Mar 2018 10:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522516154; cv=none; d=google.com; s=arc-20160816; b=LEL6KcMymLXwt8W+4F1eHaFMZ4y6uv+rxnxw1rrN6tn9rB3xR/6j30yqXar1PPH3hH +CSq/cmIh9cd+R70gf1RBPu+zdIPXLxVtvrbeEr5FOtcCXwDTDHACIMNCdfRgAQ4VOmW b7ztkrzjV7gZahyfj6fhqFTpu//lwO+6hMS60d+A9bOCIG/Wc9rU/8CKi/YrfevWp7RE EtdGyEZHqLCNOINK/qf+8qT19tyvhmoNTL2peeIjAu4aYPgGSFIIbHKNbGOf6MGjlAW3 ydK9hCSDgDiyfwF0gr/oy+VVyWHqhaRJN5odNlSSlFlyxKbtyYcz09U3l0pw137ZC5J2 sgdw== 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:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=pr9IOM0FW9cwwG1nGop+A+xUh4ZM4yWrGWVqxAwUj7E=; b=TwgQynVWhh5zBEpmXtQtIHMOfQDi7b2vqDUKDvUkTpLqWIAHt20+etLE41vc4qWrCz vnahqNtDxU71fO3Y0+VqHfK/9PIiwY1PqcGiqG6s0+pkhzCpNdHSzrTZ00W9rXQVIj6Y 7fpCkKNazosGV4x2Je1JSSxdx3D+XKGfVCqV9ODYPHleD9pYmLV9yuRNUTC7h+MOIK/r JLDjZsTcBfHivkT8nm/Iki60GqS25x20cSTMMKMUtVRvOsgxJVpfqIh1olIUMjCq6V86 3GWrjgdHrXJF1xjpde0JF4dC/HaPlXM0ZSx0gpbSJ0I2lkQWNlxysEQ51Xh1vnv8KKA1 Uc0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=h8d/qMz7; 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 62si4566697wmz.108.2018.03.31.10.09.14; Sat, 31 Mar 2018 10:09:14 -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=h8d/qMz7; 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 7436C689CE0; Sat, 31 Mar 2018 20:08:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C22E1689CBE for ; Sat, 31 Mar 2018 20:08:47 +0300 (EEST) Received: by mail-lf0-f54.google.com with SMTP id a22-v6so15929165lfg.9 for ; Sat, 31 Mar 2018 10:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=oZq96WHE8IsY8ZeprkBKSu3lQbjYy6PAiGJGsSg3lpw=; b=h8d/qMz7a83ZUcr1V8/ReJ5DSLIdN30sON5Hgp0Yu/5bIvDUgbPMEb4/5vGxzJPKZc LUSd/unCJI3Ec3TWN9FuiyhpbgCIWECwGi2yaZqOXoU5+DC7gKKjwb5ADXdrFA+9B3aX OdJJjMAZHnr6xBDSNdKyMWJHpuN4Z4nU6QUbEQU9zGUP0nY/WEI3qAYKUd3OzxNC9Aib Ki6+QMqf16pnghyw9E72f7lnQQW9WL5lx736WNbpNlgxzxurVcnM07vjdM621iwcnPrV ZU99sOHD+X16npYyx4fv8nLXc9/bp+PBSxh2NROCpHJq81NwRaLWa91vSPPeDfYpFJNt +hcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=oZq96WHE8IsY8ZeprkBKSu3lQbjYy6PAiGJGsSg3lpw=; b=EdsZcb8N45xBTKPSC0e0DWwmczgzwb9s/01lZ0c1txJbqvhv8yo9tvIogEKO19RVes Anx7fGdd+F6dSQ1z5frSXmP8XT3U9ltobsKDnsRPe/0hMb2XamjQjS0wedyfC7VwIgKE 4psXXrEVKJnQTI+CLA2bfdjZDVyPs+tGq0UXiFdPcTFe2QG6bLH1IdM5uCoWV1gw+rWx HMXqPprs5QGfH0C+8Xr4WNJ8s7t8i68b8UCIkjWnfz8sqJ3BX59XlfxHa4+NIZ1y9dCQ g+F/pi8IrJUUkWoSmXp37/CZrKIDDH7gU/dMqAxbBMMLRSucSB+5jdhA3ETlBL+O01jd c8Kw== X-Gm-Message-State: AElRT7FLj8W+GW9tvaScLPpF7AwPz3HLGJNm8yiERSRFtFk+AVtY6Ia1 aLkEIZHZblaGrQXfWa5Vw+59Ltqo X-Received: by 10.46.64.26 with SMTP id n26mr2049448lja.50.1522516146488; Sat, 31 Mar 2018 10:09:06 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id d11-v6sm1318166lfa.48.2018.03.31.10.09.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 31 Mar 2018 10:09:05 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 31 Mar 2018 20:09:04 +0300 Message-Id: <20180331170904.21797-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.14.3 Subject: [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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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. --- Alternative patch to the first one, not really a v2 so not marking it as such. The initial patch tried to still pass on the updates but keeping the end_pts from becoming INT64_MAX (as it would get utilized as the pts for the next packet). This changed the sub2video FATE test's results as well as made the theoretical secondary stream not being possible to EOF with nullptr AVSubtitles. That said, I am not sure if the test's changes or the change in capability to do such EOF'ification were explicitly incorrect, but clearly my knowledge in this area was not perfect and the change in FATE test probably kept everyone away from the initial patch. For the record, the initial patch worked for way more than 48h without seeming problems with a CFR stream, so the previous patch was not as if not tested. Thus, this alternative patch instead opts to never send out new nullptr AVSubtitle updates if end_pts is already at INT64_MAX. The FATE test also is unchanged. --- 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);