From patchwork Fri Jun 14 16:48:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 13536 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 7AF47448B6E for ; Fri, 14 Jun 2019 20:13:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 54C9C68066A; Fri, 14 Jun 2019 20:13:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8374B68066A for ; Fri, 14 Jun 2019 20:13:24 +0300 (EEST) Received: by mail-pf1-f195.google.com with SMTP id x15so1849658pfq.0 for ; Fri, 14 Jun 2019 10:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k+sAYjkUUfOIfhy2OixbGGBoX4iuaQ7HOS8sXZokUZU=; b=cRMAfiKkTocHJiNtbkxj04R7qWWUiVulCIofFMdWKvdrJKBwRW6yogctaLMtSjb2S6 n3S1SBFqYopMFjRR7lfi8pH+Ig+69TObsXjsFK/FLcNO+vGUGh+MSS4VUjiBRgCSO9dY 97ZTAfu80z5QwSaqknTYl88jyyVUqprT2bYVrZBmHEsbQCDANwSWGMTYUvqDIJ6/mPRF 46IGP3OS3tWr8KJL7iBceEhBmekWwe3Y2wPzFoKupRT2lBkXqu6GdoxxkD+Tbkg/Cmvd TyrhixjgX6VuNrwYDC7FFvwKUS9A9OJHByZT3FHG9XALaRVS3vyi/niAROaCQaRepThM q77g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k+sAYjkUUfOIfhy2OixbGGBoX4iuaQ7HOS8sXZokUZU=; b=rlZvOa70mffiEnG3Ydt5/YeHme0jPmkgTjl3XSwunLXdW6GjYaVmw9Vd03FsVkJtf8 FoLRulMAEXLmKiW7ulbiBj6mwqA/UfWpdcnKDOxQFIRjj0yKlPQcYfi4ZJ9iCdnmC4j6 LQO4l16iQDBh5hohO+mYmRKk2mfTqyRFKsZDm2pYLLYVG45QHj3Ys5TTiAycRUM1/rR7 +2tOyfiHvkSypKregZ9A+LS95Fh93fCzP6zHvjy3Ij5GOpOHlRTXQM2DLWycBFql3rG+ /VsC6iJg2W3WT6iUu6Nnk3L3wYn18tj5OUkmw34ubC7lsH/BZRWUYRFaaqFwdwipRvEE X51g== X-Gm-Message-State: APjAAAXsQreQk/2RY03Albg9qv8rA3GAEtZWKOSwsmR0JV5WGAlObMLA vL6XX8BkHHytEnaM9CoQptgyyIERtIY= X-Google-Smtp-Source: APXvYqwnCxmGg0tHwoz1jZSRuAlATxLLHQk7VG8FB49edkEJgeLfYOIl+7sIdN2DY8rKS2hexmd98A== X-Received: by 2002:a63:6105:: with SMTP id v5mr36557898pgb.312.1560530924867; Fri, 14 Jun 2019 09:48:44 -0700 (PDT) Received: from localhost.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id y5sm3183161pgv.12.2019.06.14.09.48.43 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 14 Jun 2019 09:48:44 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jun 2019 00:48:25 +0800 Message-Id: <1560530906-60749-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1560530906-60749-1-git-send-email-lance.lmwang@gmail.com> References: <20190612105018.43545-1-lance.lmwang@gmail.com> <1560530906-60749-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v5 2/3] ibavfilter/vf_cover_rect.c: change the cover_rect function for support cover frame can be changed 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_cover_rect.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c index 898debf..b66c40b 100644 --- a/libavfilter/vf_cover_rect.c +++ b/libavfilter/vf_cover_rect.c @@ -71,24 +71,25 @@ static int config_input(AVFilterLink *inlink) return 0; } -static void cover_rect(CoverContext *cover, AVFrame *in, int offx, int offy) +static void cover_rect(AVFrame *cover_frame, AVFrame *in, int offx, int offy) { int x, y, p; for (p = 0; p < 3; p++) { uint8_t *data = in->data[p] + (offx>>!!p) + (offy>>!!p) * in->linesize[p]; - const uint8_t *src = cover->cover_frame->data[p]; - int w = AV_CEIL_RSHIFT(cover->cover_frame->width , !!p); - int h = AV_CEIL_RSHIFT(cover->cover_frame->height, !!p); + const uint8_t *src = cover_frame->data[p]; + int w = AV_CEIL_RSHIFT(cover_frame->width , !!p); + int h = AV_CEIL_RSHIFT(cover_frame->height, !!p); for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { data[x] = src[x]; } data += in->linesize[p]; - src += cover->cover_frame->linesize[p]; + src += cover_frame->linesize[p]; } } } + static void blur(CoverContext *cover, AVFrame *in, int offx, int offy) { int x, y, p; @@ -139,6 +140,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVDictionaryEntry *ex, *ey, *ew, *eh; int x = -1, y = -1, w = -1, h = -1; char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL; + AVFrame *cover_frame = NULL; ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE); ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, AV_DICT_MATCH_CASE); @@ -174,6 +176,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (cover->cover_frame) { if (w != cover->cover_frame->width || h != cover->cover_frame->height) return AVERROR(EINVAL); + cover_frame = cover->cover_frame; } cover->width = w; @@ -186,8 +189,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (cover->mode == MODE_BLUR) { blur (cover, in, x, y); - } else { - cover_rect(cover, in, x, y); + } else if (cover_frame) { + cover_rect(cover_frame, in, x, y); } return ff_filter_frame(ctx->outputs[0], in); }