From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id F378F43656 for ; Thu, 21 Jul 2022 02:26:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 59FB768B5B3; Thu, 21 Jul 2022 05:25:53 +0300 (EEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D135C68818E for ; Thu, 21 Jul 2022 05:25:44 +0300 (EEST) Received: by mail-pf1-f176.google.com with SMTP id b9so460177pfp.10 for ; Wed, 20 Jul 2022 19:25:44 -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 :mime-version:content-transfer-encoding; bh=c4xeuuzjgkCyJeehhi155/UaxzBBbcPC2HabThBId/I=; b=IAwFasTQS73tdZ5BYyPHvB03WyreTogzaIrASTOmaJdQHYiBRqOOBVczhjdOLkp0iY oSfrrlLSiAJjsJ+SQ8tE6ALqdLfYDRWfq6A/FmSatGkNvQbfEc7+L+G31lGWvGff0KNw 4XQF4b5ySck/j6A6EWrn0g0DGMrvahca25jxjOKXa9efSffqpSABkKXulpmYBcAHvVdJ rUT3W3RUaVGjL3QLr/YRjwGGcQV0RBXlP+GBhJ39nZDsrehNjwxhSHO0Zo/Hjcd6o/UO FFZJNRLwpX+S4SgLEeMpLrCHxu0aMgB1rdvN654cvy5I4w2lg9wfcsxrjF7YvWLASLl8 dYKQ== 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:mime-version:content-transfer-encoding; bh=c4xeuuzjgkCyJeehhi155/UaxzBBbcPC2HabThBId/I=; b=kScwrKsN3A2opHRRc4FMLtVKekquO03VLJm5f73W4HvwbAUrLVAOLADihTsjR6fOm5 4i5nBgjVijEbxcpSJ+TNAbiZtMYBQ2vyt/OTL+gtmDWtdPA3RPp1ocaYNsxb+HmjBABq U5jV2jQxHFoAsFFHgxS+1rmHXaI66fakiHm15z2xEewpA2pjmRcuuU9nDHOJRYdlBHuH kx+V36PM3BZBxfcOIeO8VS1Y7zZmQqj7wHRAsmyHiImmv6+KZ5IDQH2U0lml8e9ho3Ou TgSkh/a8dF7R0/08UDVzyKOgj3n1xJouV/SoDeB1u42A2fRfh0ECQvkwMb6tloqkE6G+ Tlrw== X-Gm-Message-State: AJIora9rKTbGh9szIT3wu489IKTiNpGXJYhJVujy3k7/vbfxhYNOgLc7 1jflFN6XhWqu0NBs+JZ8icUe9Isor/XCnw== X-Google-Smtp-Source: AGRyM1takiO4ONK3d0P09O9sqEqDGxs3kH0MLghsGafTPYfuuMCc0UKwQyaqUpc8RMbuRYEsln1U1Q== X-Received: by 2002:a63:79c8:0:b0:41a:7b78:9ed2 with SMTP id u191-20020a6379c8000000b0041a7b789ed2mr2104061pgc.306.1658370342838; Wed, 20 Jul 2022 19:25:42 -0700 (PDT) Received: from localhost.localdomain (23-121-159-29.lightspeed.sntcca.sbcglobal.net. [23.121.159.29]) by smtp.googlemail.com with ESMTPSA id j3-20020a62c503000000b005251c6fbd0csm340079pfg.29.2022.07.20.19.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 19:25:42 -0700 (PDT) From: Chris Phlipot To: ffmpeg-devel@ffmpeg.org Date: Wed, 20 Jul 2022 19:25:13 -0700 Message-Id: <20220721022514.1466331-4-cphlipot0@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220721022514.1466331-1-cphlipot0@gmail.com> References: <20220721022514.1466331-1-cphlipot0@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/5] avfilter/vf_yadif: Process more pixels using filter_line 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: Chris Phlipot Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: filter_line is generally vectorized, wheras filter_edge is implemented in C. Currently we rely on filter_edge to process non-edges in cases where the width doesn't match the alignment. This causes us to process non-edge pixels with the slow C implementation vs the faster SSE implementation. It is generally faster to process 8 pixels with the slowest SSE2 vectorized implementation than it is to process 2 pixels with the C implementation. Therefore, if filter_edge needs to process 2 or more non-edge pixels, it would be faster to process these non-edge pixels with filter_line instead even if it processes more pixels than necessary. To address this, we use filter_line so long as we know that at least 2 pixels will be used in the final output even if the rest of the computed pixels are invalid. Any incorrect output pixels generated by filter_line will be overwritten by the following call to filter_edge. In addtion we avoid running filter_line if it would read or write pixels outside the current slice. Signed-off-by: Chris Phlipot --- libavfilter/vf_yadif.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 54109566be..394c04a985 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -201,6 +201,8 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) int slice_end = (td->h * (jobnr+1)) / nb_jobs; int y; int edge = 3 + s->req_align / df - 1; + int filter_width_target = td->w - 3; + int filter_width_rounded_up = (filter_width_target & ~(s->req_align-1)) + s->req_align; /* filtering reads 3 pixels to the left/right; to avoid invalid reads, * we need to call the c variant which avoids this for border pixels @@ -215,11 +217,28 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) int mrefs = y ? -refs : refs; int parity = td->parity ^ td->tff; int mode = y == 1 || y + 2 == td->h ? 2 : s->mode; + + /* Adjust width and alignment to process extra pixels in filter_line + * using potentially vectorized code so long as it doesn't cause + * reads or writes outside of the current slice. filter_edge will + * correct any incorrect pixels written by filter_line in this + * scenario. + */ + int filter_width; + int edge_alignment; + if (filter_width_rounded_up - filter_width_target >= 2 + && y*refs + filter_width_rounded_up < slice_end * refs + refs - 3) { + filter_width = filter_width_rounded_up; + edge_alignment = 1; + } else { + filter_width = td->w - edge; + edge_alignment = s->req_align; + } s->filter_line(dst + pix_3, prev + pix_3, cur + pix_3, - next + pix_3, td->w - edge, + next + pix_3, filter_width, prefs, mrefs, parity, mode); s->filter_edges(dst, prev, cur, next, td->w, - prefs, mrefs, parity, mode, s->req_align); + prefs, mrefs, parity, mode, edge_alignment); } else { memcpy(&td->frame->data[td->plane][y * td->frame->linesize[td->plane]], &s->cur->data[td->plane][y * refs], td->w * df); -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".