From patchwork Fri Aug 31 12:16:27 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: 10192 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp695750jap; Fri, 31 Aug 2018 05:23:36 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbasmL/5b55RSWbbtrcnhN6B5Xz1VqsTnGQH/QGLWZ5EZLAGQxmwAM64JJoNNcMYwp1bl6d X-Received: by 2002:a1c:48d:: with SMTP id 135-v6mr4378937wme.106.1535718216382; Fri, 31 Aug 2018 05:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535718216; cv=none; d=google.com; s=arc-20160816; b=gpjor0hxqswrt2DwbeDvY1LZsw0WaPupQz22RzWb3UY3n/NHDD9v4M+KOnSWWYNyma QQ5oWVwsWGTZfsL2LXoNbNUq6MyQbU0N+6x5sZD8V5nuMrwXlJphG3tzShpjVwWr797/ s0DoYWewvgnTMzFFsToAIC5FDafBfKQBc+E54KggZCqAsCLX2Hj9Yi7/TA1ZMgNuNYl7 VTLU2Hv5t98RUsVVimO5F0t6ZTu4Y88/3F295rLE0sRNQjbIVxbgn/BImhkcn289GMeP lmLcKHHmGSM9XwcC5CIejwSeDLzycHc4ZwGspi+9v0rNe1TS38LD4yP8Hnw8WdFBwnYs 6UGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:delivered-to :arc-authentication-results; bh=LMLnjY+6NUp3DR8CXG2JdErq5u9B+7uLmXfso4VWBkc=; b=J9j9aDymjKFTEml94LbmCWEaRWF2uxZzZzssbYLOxF13bOsAmHYwuIJlVt+BQ/rQp2 GFSDQgPYl/S414AB89e/1KdzP7YRVzWneIMTanSHmMClhcAAInRUtQMlNEncSwKzMjk7 yXFT3uQzHjSNUqROJVBjE/c9o9NO86uWttf80Yn/h5wYoEOPhvXirZLDqAK7CNxqLJnd yXOp/EFA4D+SfhqR0Zttaz26moOD6XccWIdo0eIGvBKwxtgKsZW76Tgxl7PPjYdRKzYB ms2iSn8vM/25ObyjSc2ud5vEK4ymsySL8ld7RO8lxSuUdcjgit1Ymkc0+Xw1GSvWRzto rRYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=DFoiR1JL; 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 s30-v6si9670761wrb.131.2018.08.31.05.23.36; Fri, 31 Aug 2018 05:23:36 -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=DFoiR1JL; 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 272D9689BA7; Fri, 31 Aug 2018 15:23:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFF16689BA7 for ; Fri, 31 Aug 2018 15:23:23 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id l15-v6so9928157lji.6 for ; Fri, 31 Aug 2018 05:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=bgFKkpsTt74zQtSKCa/krK7Cm35l2xv012sYYp2+3zg=; b=DFoiR1JL90psQXQRt55VYL/D7nvq+C2z3yfIfPB4tv2dFlr1HxHkgJtxv6mDf9QqVy hVd5roOnSSsLaqdkefUJFkeFA4jppnN6DkRlxPsF0ysrZ7E8/eHxvX5eMEcxQnVdyn21 qQbGYyXwwvYTZ1Jy2RWztvBXa0Yl/DyY9oMk033EauAdnr2vledJkRjV4lDZYpTnQnmI aeqQlA8UurgYJFDu7W3Cjv6waJEiC5fN5u23FjSX6M+ksx7MRyGoWzlr1Y6kXzgT1xzt hcsvSNMoc4aH41SBQgSWSSHHDrWFn4kS0UH9cB02YP8ZtWmjoVveQVMgUaB+SM01ElR1 w+gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=bgFKkpsTt74zQtSKCa/krK7Cm35l2xv012sYYp2+3zg=; b=NH7TFz4z1UeJ2uQwBtnq/SYwrH8DrWc1YG5QcjNXpvC1likJ2r7WkKP4aEqsp8Axdk 7O0NRMV39xJx4NYghSt6AVj/Qx/DxSYm43xMtB/clspW2vQJWMGtmec5tL4aQmP/Z5Sp X255Ah0217/kY+c3zNdiip6tgmjftDMPN8W8rmPbX9nXtfs+dbyrwZ7jtbPo6wmCFYqY CZSC5w9tr5nEraAhN3UCf5K7Yu/CfA6sNkaTpuivpn14rElw4Nyd9oXdF+7fS+VlpE6E 8oKn8cG1L5KLCcN4o6mdc0lQivj7bLirqdDCLurbDTtdMvv0J/P2kCE5haGoitnSHFbP AnmQ== X-Gm-Message-State: APzg51Al5IXBn5PHVEbs21x2xoRBpzNA71zSg4ZyZpKub7iXM0CiZlS2 PoRKIB+lr2TyCCZSw9EOzbE1zUNnFcCVa9DxRwIlkFT+ X-Received: by 2002:a2e:259:: with SMTP id 86-v6mr10678855ljc.107.1535717788654; Fri, 31 Aug 2018 05:16:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:9914:0:0:0:0:0 with HTTP; Fri, 31 Aug 2018 05:16:27 -0700 (PDT) From: =?UTF-8?B?SmFuIEVrc3Ryw7Zt?= Date: Fri, 31 Aug 2018 15:16:27 +0300 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH 2/2] ffmpeg_filter: keep sub2video size configuration if likely a re-init 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" This commit tries to keep the sub2video canvas size in case a filter chain re-initialization occurs. This issue could also be improved by having this size be checked as new frames are pushed into the overlay, or the overlay filter itself having an option to scale overlayed images to the primary image's size. From d896643576f4f03f0f2f4bc2b653895bb4c07df3 Mon Sep 17 00:00:00 2001 From: Nongji Chen Date: Thu, 26 Jul 2018 16:25:19 +0300 Subject: [PATCH 2/2] ffmpeg_filter: keep sub2video size configuration if likely a re-init This way the filter chain does not accidentally mis-configure itself in case a filter chain re-initialization happens during run-time. --- fftools/ffmpeg_filter.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 4cb81ea41f..ae86be1f1a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -698,11 +698,17 @@ void check_filter_outputs(void) static int sub2video_prepare(InputStream *ist, InputFilter *ifilter) { AVFormatContext *avf = input_files[ist->file_index]->ctx; - int i, w, h; + int i, w, h, keep_existing = 0; /* Compute the size of the canvas for the subtitles stream. - If the subtitles codecpar has set a size, use it. Otherwise use the - maximum dimensions of the video streams in the same file. */ + + If the ifilter->width|height are nonzero and match the sub2video.w|h, + keep the configuration as this is likely a re-initialization + of the filter chain. + + Otherwise if the subtitles codecpar has set a size, use it, and + utilize either the input filter's width|height or the maximum + dimensions of the video streams in the same file. */ w = ifilter->width; h = ifilter->height; if (!(w && h)) { @@ -717,12 +723,19 @@ static int sub2video_prepare(InputStream *ist, InputFilter *ifilter) h = FFMAX(h, 576); } av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h); + } else if (w == ist->sub2video.w && h == ist->sub2video.h) { + // This is most likely a re-configuration, so keep the currently + // configured values for width and height. + keep_existing = 1; } + ist->sub2video.w = ifilter->width = w; ist->sub2video.h = ifilter->height = h; - ifilter->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w; - ifilter->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h; + if (!keep_existing) { + ifilter->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w; + ifilter->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h; + } /* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the palettes for all rectangles are identical or compatible */ -- 2.17.1