From patchwork Tue Sep 3 11:54:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 14882 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B648C449947 for ; Tue, 3 Sep 2019 14:54:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C230688068; Tue, 3 Sep 2019 14:54:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C419A688068 for ; Tue, 3 Sep 2019 14:54:41 +0300 (EEST) X-QQ-mid: bizesmtp27t1567511674tgeej0oc Received: from localhost (unknown [49.7.64.202]) by esmtp10.qq.com (ESMTP) with id ; Tue, 03 Sep 2019 19:54:33 +0800 (CST) X-QQ-SSF: 01100000008000K0ZQF0000A0000000 X-QQ-FEAT: xVimSEZO+7cY8w1K91LBdBZjIzIgGX0YQSIl4VPxl082/7X89YZPJRJtJ+0tt SytI5JpkshfpqZcTP3RZ4JKmc1plq6FyhEcX1vvld39WnKKua9/ZNYzsmzA4VDqQnueWZk2 TzKd6KSA8d+bOvVo0NCZYWfehqtydM+zhcG3A4VtM1RPVVaSB04cvV7D6WSJ5Fpbp+mxnH4 HIrO1zyqeB+b0s/VH20VF2W9rT3h2SJPDTv8KWcyf4zDApA7VW8dRO+GpyL3+SoUhm8VIyk k+71+nfpbFuW6CYvBRjHPKB/rWywFStF/MFlOwAeiIe6YNj1x6qkWT27oOh2Z7TNdHXY85r DZO+RXl X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Sep 2019 19:54:26 +0800 Message-Id: <20190903115426.98164-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: <20190902215241.26732-1-lq@chinaffmpeg.org> References: <20190902215241.26732-1-lq@chinaffmpeg.org> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v2] avfilter/vf_delogo: avfilter/vf_delogo: add auto set the area inside of the frame 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: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" when the area outside of the frame, then use expr should give user warning message and auto set to the area inside of the frame. Signed-off-by: Steven Liu --- libavfilter/vf_delogo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 814575a36c..2d058021fb 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -327,6 +327,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->w = av_expr_eval(s->w_pexpr, s->var_values, s); s->h = av_expr_eval(s->h_pexpr, s->var_values, s); + if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w || + s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) { + av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame," + "auto set the area inside of the frame\n"); + } + + if (s->x + (s->band - 1) <= 0) + s->x = 1 + s->band; + if (s->y + (s->band - 1) <= 0) + s->y = 1 + s->band; + if (s->x + s->w - (s->band*2 - 2) > inlink->w) + s->w = inlink->w - s->x - (s->band*2 - 2); + if (s->y + s->h - (s->band*2 - 2) > inlink->h) + s->h = inlink->h - s->y - (s->band*2 - 2); + ret = config_input(inlink); if (ret < 0) { av_frame_free(&in);