From patchwork Tue Sep 21 04:32:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 30394 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp2072146iob; Mon, 20 Sep 2021 21:32:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOKNQwHOmwqgpueFAw5Dfc5udxojWO3qvDz5KRKHnNQhw0lvkq0PEAVEDwe/7b1F5c5JfJ X-Received: by 2002:a17:906:8a41:: with SMTP id gx1mr34156838ejc.507.1632198760748; Mon, 20 Sep 2021 21:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632198760; cv=none; d=google.com; s=arc-20160816; b=iCy/h464RauU5eMCb7QO85+kYDzsJk8UkpiTdOlKfTzSV3qLR5tVzfiC0XDrYZXsVL vQNIjWt9IHmy/TmiIhn+rWO+w+clMaltHJDWPpNGYREZOEBfVTzreGydTxGMfw768PIm WwJAlEsUlBmknrFP21rmEMwdq/5Lijea/VCCo2xmBQwmPMDuCbY8fZudGVhvqdvP+7V6 oaH2evsAcTCPMV4AthUWQw7Zpoq8v2+wBEaSTDus43PT0loZYBfO3ThggY8zCLVzFebH LYn47pd5KGdLh+5AUNDVzZujBHY6mPO0GMB+aBgIpFgVmYKCvF8jMleIazTEfLN2LwZW pi7Q== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=+gNhCWg8hQzVHNOGDZF0RNaC0ZKzlE9oeDJXH9763yU=; b=R//KfqJHAXykcPgcCPj+uqKIukPq5VoaCHJAjis9O0kRXJsQVpzPV1qCmaXU3O2xA9 F0R2lr7CGxh7JB15r8Rmx/tFnDrrNQvkaNe2jklBCdfWjSECL4OhcmelsfzyNShFpi6e SH1sBS8ps+0Z1AgsNhTN7ZecZmq1VtSTsJRvuoneL8lLNw7lMdXPFsNnHGPgeZHULZXi XR2rg1FIBqRyZUcWOLcwzwZi15YadWUt6KXL7KOdw3vyWCJcKvGb74CUIYwTyLw7Yyd5 nFfj4Z0/TlQsYbCLLz/P9flRwzNSxHKYPJf330+0m9bLUid3O2whC6o5xoUwMf0UD+5t yioQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="VL/xpwVr"; 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 i8si11890283ejo.354.2021.09.20.21.32.40; Mon, 20 Sep 2021 21:32:40 -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=20210112 header.b="VL/xpwVr"; 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 9740C68AED8; Tue, 21 Sep 2021 07:32:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 110B968ABD7 for ; Tue, 21 Sep 2021 07:32:14 +0300 (EEST) Received: by mail-pl1-f178.google.com with SMTP id y1so5585564plk.10 for ; Mon, 20 Sep 2021 21:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fLbrnFwkf6rqnNypNa93NmldfsmUim8K5uTb+3UmWNs=; b=VL/xpwVrx7EBnHYGus7chfYrMXX58+qwv23TLfGV8WUFkkpVsIWkfn8kToVtWGK8Jz jvyRKbZHJ7gS3Th4BRFa6QA/shkC3xaHBTOQcfw4srSq/dpg4T6AG7x+2RyRgSWiDVIW oyOwBIX1AE22bb8aT4zqflvDh7CQPFisoMn1zFm3Dzz/425EfmE4hGnCYWBkshgZeVKm 6641/s2X/HOdT+3g9rmhMeA5ZDLvOAsL2f/FekHr8gue4kttNKEFVqis0f54uuvxzIt9 cpMt8XjZdM7gIDgoy3fF9pKJ1bAnH+VFmz5Pa7YRiWXyCJwxYh8mPh2obPifOT5qbz6P Z23g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fLbrnFwkf6rqnNypNa93NmldfsmUim8K5uTb+3UmWNs=; b=xyLTuPDY6LTqPOM12eYOOFYuHKMM2vH13uHj8JYUHkqUatH4onVjB5VJxKbp/ltBud Oh+Mznqveg7FqV0iM4KHfc9qhNKOiBuZrVig944UiftiPVcOapxRpsJmVtZ/zxqf0oyz ahdjBOpHxK9hO8XZxVPSwMGUtRU+tLQ67yGADDlL1m4PtG1ll/qOB8C0jxlU9SeSsgDb w70YKuh9te0r/MjTUF7p8PqBksPyTjr+FT9/F8C/0Aq9O/qMTOT0WPILVi2zhhFZ/Q+B gg0fcbdJwS+5ndtZhon7GqG3mTYNSiFCssKteXmO0GNgnlhx9pb0tEq+mmU8fdX3VCh2 jrNQ== X-Gm-Message-State: AOAM533LtQ/mJ7NpZHJsAlphs2DOjqUv6RAV10kmhEBOKtvCqA32YlVN mFJY87gNWP5WVy1+ImHr8MgQp8ZlAD4= X-Received: by 2002:a17:902:7b84:b0:13b:90a7:e270 with SMTP id w4-20020a1709027b8400b0013b90a7e270mr25696479pll.21.1632198732160; Mon, 20 Sep 2021 21:32:12 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id x24sm6670850pge.85.2021.09.20.21.32.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Sep 2021 21:32:11 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Sep 2021 12:32:03 +0800 Message-Id: <1632198725-19424-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1632198725-19424-1-git-send-email-lance.lmwang@gmail.com> References: <1632198725-19424-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/5] avfilter/vf_guided: Fix indention X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: T3v8c/5jesFF From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_guided.c | 77 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index f808ba1..066a00d 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -110,19 +110,19 @@ static int box_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) w = (radius << 1) + 1; numPix = w * w; for (int i = slice_start;i < slice_end;i++) { - for (int j = 0;j < width;j++) { - float temp = 0.0; - for (int row = -radius;row <= radius;row++) { - for (int col = -radius;col <= radius;col++) { - int x = i + row; - int y = j + col; - x = (x < 0) ? 0 : (x >= height ? height - 1 : x); - y = (y < 0) ? 0 : (y >= width ? width - 1 : y); - temp += src[x * src_stride + y]; - } + for (int j = 0;j < width;j++) { + float temp = 0.0; + for (int row = -radius;row <= radius;row++) { + for (int col = -radius;col <= radius;col++) { + int x = i + row; + int y = j + col; + x = (x < 0) ? 0 : (x >= height ? height - 1 : x); + y = (y < 0) ? 0 : (y >= width ? width - 1 : y); + temp += src[x * src_stride + y]; + } + } + dst[i * dst_stride + j] = temp / numPix; } - dst[i * dst_stride + j] = temp / numPix; - } } return 0; } @@ -161,8 +161,7 @@ static int config_input(AVFilterLink *inlink) if (s->mode == BASIC) { s->sub = 1; - } - else if (s->mode == FAST) { + } else if (s->mode == FAST) { if (s->radius >= s->sub) s->radius = s->radius / s->sub; else { @@ -235,13 +234,13 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s, goto end; \ } \ for (int i = 0;i < h;i++) { \ - for (int j = 0;j < w;j++) { \ - int x = i * w + j; \ - I[x] = src[(i * src_stride + j) * sub] / maxval; \ - II[x] = I[x] * I[x]; \ - P[x] = srcRef[(i * src_ref_stride + j) * sub] / maxval; \ - IP[x] = I[x] * P[x]; \ - } \ + for (int j = 0;j < w;j++) { \ + int x = i * w + j; \ + I[x] = src[(i * src_stride + j) * sub] / maxval; \ + II[x] = I[x] * I[x]; \ + P[x] = srcRef[(i * src_ref_stride + j) * sub] / maxval; \ + IP[x] = I[x] * P[x]; \ + } \ } \ \ t.width = w; \ @@ -262,13 +261,13 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s, ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads)); \ \ for (int i = 0;i < h;i++) { \ - for (int j = 0;j < w;j++) { \ - int x = i * w + j; \ - float varI = meanII[x] - (meanI[x] * meanI[x]); \ - float covIP = meanIP[x] - (meanI[x] * meanP[x]); \ - A[x] = covIP / (varI + eps); \ - B[x] = meanP[x] - A[x] * meanI[x]; \ - } \ + for (int j = 0;j < w;j++) { \ + int x = i * w + j; \ + float varI = meanII[x] - (meanI[x] * meanI[x]); \ + float covIP = meanIP[x] - (meanI[x] * meanP[x]); \ + A[x] = covIP / (varI + eps); \ + B[x] = meanP[x] - A[x] * meanI[x]; \ + } \ } \ \ t.src = A; \ @@ -279,11 +278,11 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s, ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads)); \ \ for (int i = 0;i < height;i++) { \ - for (int j = 0;j < width;j++) { \ - int x = i / sub * w + j / sub; \ - dst[i * dst_stride + j] = meanA[x] * src[i * src_stride + j] + \ - meanB[x] * maxval; \ - } \ + for (int j = 0;j < width;j++) { \ + int x = i / sub * w + j / sub; \ + dst[i * dst_stride + j] = meanA[x] * src[i * src_stride + j] + \ + meanB[x] * maxval; \ + } \ } \ end: \ av_freep(&I); \ @@ -321,13 +320,13 @@ static int filter_frame(AVFilterContext *ctx, AVFrame **out, AVFrame *in, AVFram continue; } if (s->depth <= 8) - guided_byte(ctx, s, in->data[plane], ref->data[plane], (*out)->data[plane], s->radius, s->eps, - s->planewidth[plane], s->planeheight[plane], - in->linesize[plane], ref->linesize[plane], (*out)->linesize[plane], (1 << s->depth) - 1.f); + guided_byte(ctx, s, in->data[plane], ref->data[plane], (*out)->data[plane], s->radius, s->eps, + s->planewidth[plane], s->planeheight[plane], + in->linesize[plane], ref->linesize[plane], (*out)->linesize[plane], (1 << s->depth) - 1.f); else - guided_word(ctx, s, in->data[plane], ref->data[plane], (*out)->data[plane], s->radius, s->eps, - s->planewidth[plane], s->planeheight[plane], - in->linesize[plane] / 2, ref->linesize[plane] / 2, (*out)->linesize[plane] / 2, (1 << s->depth) - 1.f); + guided_word(ctx, s, in->data[plane], ref->data[plane], (*out)->data[plane], s->radius, s->eps, + s->planewidth[plane], s->planeheight[plane], + in->linesize[plane] / 2, ref->linesize[plane] / 2, (*out)->linesize[plane] / 2, (1 << s->depth) - 1.f); } return 0;