From patchwork Thu Jun 29 17:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Cox X-Patchwork-Id: 42325 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1e:b0:12b:9ae3:586d with SMTP id c30csp1946398pzh; Thu, 29 Jun 2023 11:00:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmLG+dMD+EfGfi2X+2WhaGB58WeKbREbZdvR5aLLsahmS81Cx05lD4UbsBJpObJfpLLO7Y X-Received: by 2002:a05:6512:368b:b0:4f7:6453:f3f1 with SMTP id d11-20020a056512368b00b004f76453f3f1mr483806lfs.15.1688061650410; Thu, 29 Jun 2023 11:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688061650; cv=none; d=google.com; s=arc-20160816; b=Tw5W0xo0J1dvVBwkP22axkM+g5edwFK/1IOFx3cKCFX+8mkDQ8UTReo80BldzE3SqS VaEkJVVVyLI/HCfqcz1XlYKY7T0lJGsVp7JbGhdHRtqVMdH1CgeE5qI6vScUMwuXYM+t jufo7fvR8Sd9iIVjAxXZVhEuNxQQRqIN2HNsPCegDKz8cNlSvexNUWr4S1DCUbOlyFzC ox9iFaS71GakEal8TYw5ZuJaK7uJ2qAEYSK6eXuX6kwbyA5aHx7G+MA0AZvDVUYcYcOp irHwnjUbbsHL+FCi3yjbwV+g1r6gKesBrOQ+om6JvSiNtzkCb70LkJTdvILoektAcGxC CUbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=TR7oBlHZynjQ7yxf3t50uQUhSuYvv8lm3do9+Mgxjv4=; fh=4TI4rjEBNZIiFzmH/zgNEtnT9CzHjNyw0MAPqTxWP34=; b=nCCjLIs9S9QNvrm3Rzdooo/QU8QyaPJBRJqFk7vyUTkY/14Ygq8JldC43lOy+wR6SQ EIQjzGFE6628Xh2fvz2M7q/t9W9B2oZjWStoHmojo+8lgT7k2ezv74bh4ludqDl8J8jN R9cK+k6xdGV1L/2QYaG71QseRLljpHl/jvmnk5mMes6qzJtgup15eVaBz+31kC7riqJd eNzFYg6lPDeK9W/C4hAhTU9MTn2l/GT6U5xAeF1z0H3d3UAjPCjPbtHFvwa5Aw5FB4jz Xfh+Wy7/hbqGT7X8tA6bou2TfyiwfJNPJhV/cYWGcQz1KV6CQiEyhjtkFHHkdHRcToNr JP2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kynesim-co-uk.20221208.gappssmtp.com header.s=20221208 header.b=kvZKWJay; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k20-20020a05640212d400b0051de4bfb8fesi535081edx.522.2023.06.29.11.00.49; Thu, 29 Jun 2023 11:00:50 -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=@kynesim-co-uk.20221208.gappssmtp.com header.s=20221208 header.b=kvZKWJay; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4467268C488; Thu, 29 Jun 2023 20:58:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5B5168C3BA for ; Thu, 29 Jun 2023 20:58:27 +0300 (EEST) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-3fbc0981733so6859325e9.3 for ; Thu, 29 Jun 2023 10:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kynesim-co-uk.20221208.gappssmtp.com; s=20221208; t=1688061507; x=1690653507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HBlsgRrEsc7jNsHDnUmnFXOpcKR+FHzpoMabGke73yE=; b=kvZKWJayS0OhgOh6tETliajxfRrCySWLOB1p1OBD/rKGMpuR38/8nnAYs56scX/AC7 NyTZknfSymNr3aL9Q3Lk7l6Uah5h+GjsBQBjKN2DjRYi9G64D65ZlMG5Q05dYuVyp1qx kH44ZTYD883ljD5H4a8qHm5h3cL3U40WtMhEpSwoZMdHpPiIBrzp+rnTbhekPp8FVE94 gHWd/inmENvHp6t6yEqqm7cTajNj53DEsziLXaBfu904IEF3k4IhJm3MRFB/H+LBxpMI 5mrmNPIg7EbXd1SXEwnnPX9LQXIp2vbS8A7+Wh5Lp89UNE1ajRKxGk5EWt7A6BRIUfW6 4ihw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688061507; x=1690653507; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HBlsgRrEsc7jNsHDnUmnFXOpcKR+FHzpoMabGke73yE=; b=G91jVoYUxLWZ/HNDG/sORaWJgOpQ8AxG/7Faq60N6+N3xa9IiyKFThphnI4/qHZFWv 4aIByk5Kh0ZwtrhpXmf74DcoxEzsCQFCDEakJzYqFqSL67XY9rDLb5QFsjbZyS0IiJrq oNdKHwjJEwtOuapPcxO8layABC8sRVQ9i90cvSb4qgKxwK99zuuRr+EsR7TyNcdZZAgy UT6jc/mJ4H10g1RHg47OaNZqv5w5auugHo4okuSlShrLttE5pQen0sIzZ0AgHvzVKKnG lqWZGcOxuqfIBtmiNL9zl7l9CydB6zkzpE5UqhgzVl0rl6yE9jTyftC2jDDneexDd7ZR d85g== X-Gm-Message-State: AC+VfDyWwSZgJqAmD2AiEU84p+KAYtXFRXtIKx2M0H+PDzr95J+kUXPY zS4ntiOLNzCZc4wMfHHP/sKbhHAMkYV88JSjTaA= X-Received: by 2002:a7b:c8d1:0:b0:3fa:9554:fb23 with SMTP id f17-20020a7bc8d1000000b003fa9554fb23mr69411wml.21.1688061507216; Thu, 29 Jun 2023 10:58:27 -0700 (PDT) Received: from sucnaath.outer.uphall.net (cpc1-cmbg20-2-0-cust759.5-4.cable.virginm.net. [86.21.218.248]) by smtp.gmail.com with ESMTPSA id f26-20020a7bcd1a000000b003fbba5f21b6sm2041541wmj.28.2023.06.29.10.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 10:58:27 -0700 (PDT) From: John Cox To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Jun 2023 17:57:26 +0000 Message-Id: <20230629175729.224383-13-jc@kynesim.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230629175729.224383-1-jc@kynesim.co.uk> References: <20230629175729.224383-1-jc@kynesim.co.uk> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/15] avfilter/vf_bwdif: Add a filter_line3 method for optimisation 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: thomas.mundt@hr.de, John Cox Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: w1qMMxgK3OOv Add an optional filter_line3 to the available optimisations. filter_line3 is equivalent to filter_line, memcpy, filter_line filter_line shares quite a number of loads and some calculations in common with its next iteration and testing shows that using aarch64 neon filter_line3s performance is 30% better than two filter_lines and a memcpy. Signed-off-by: John Cox --- libavfilter/bwdif.h | 7 +++++++ libavfilter/vf_bwdif.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/libavfilter/bwdif.h b/libavfilter/bwdif.h index cce99953f3..496cec72ef 100644 --- a/libavfilter/bwdif.h +++ b/libavfilter/bwdif.h @@ -35,6 +35,9 @@ typedef struct BWDIFContext { void (*filter_edge)(void *dst, void *prev, void *cur, void *next, int w, int prefs, int mrefs, int prefs2, int mrefs2, int parity, int clip_max, int spat); + void (*filter_line3)(void *dst, int dstride, + const void *prev, const void *cur, const void *next, int prefs, + int w, int parity, int clip_max); } BWDIFContext; void ff_bwdif_init_filter_line(BWDIFContext *bwdif, int bit_depth); @@ -53,4 +56,8 @@ void ff_bwdif_filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, int prefs3, int mrefs3, int prefs4, int mrefs4, int parity, int clip_max); +void ff_bwdif_filter_line3_c(void * dst1, int d_stride, + const void * prev1, const void * cur1, const void * next1, int s_stride, + int w, int parity, int clip_max); + #endif /* AVFILTER_BWDIF_H */ diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c index 26349da1fd..52bc676cf8 100644 --- a/libavfilter/vf_bwdif.c +++ b/libavfilter/vf_bwdif.c @@ -150,6 +150,31 @@ void ff_bwdif_filter_line_c(void *dst1, void *prev1, void *cur1, void *next1, FILTER2() } +#define NEXT_LINE()\ + dst += d_stride; \ + prev += prefs; \ + cur += prefs; \ + next += prefs; + +void ff_bwdif_filter_line3_c(void * dst1, int d_stride, + const void * prev1, const void * cur1, const void * next1, int s_stride, + int w, int parity, int clip_max) +{ + const int prefs = s_stride; + uint8_t * dst = dst1; + const uint8_t * prev = prev1; + const uint8_t * cur = cur1; + const uint8_t * next = next1; + + ff_bwdif_filter_line_c(dst, (void*)prev, (void*)cur, (void*)next, w, + prefs, -prefs, prefs * 2, - prefs * 2, prefs * 3, -prefs * 3, prefs * 4, -prefs * 4, parity, clip_max); + NEXT_LINE(); + memcpy(dst, cur, w); + NEXT_LINE(); + ff_bwdif_filter_line_c(dst, (void*)prev, (void*)cur, (void*)next, w, + prefs, -prefs, prefs * 2, - prefs * 2, prefs * 3, -prefs * 3, prefs * 4, -prefs * 4, parity, clip_max); +} + void ff_bwdif_filter_edge_c(void *dst1, void *prev1, void *cur1, void *next1, int w, int prefs, int mrefs, int prefs2, int mrefs2, int parity, int clip_max, int spat) @@ -244,6 +269,11 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) refs << 1, -(refs << 1), td->parity ^ td->tff, clip_max, (y < 2) || ((y + 3) > td->h) ? 0 : 1); + } else if (s->filter_line3 && y + 2 < slice_end && y + 6 < td->h) { + s->filter_line3(dst, td->frame->linesize[td->plane], + prev, cur, next, linesize, td->w, + td->parity ^ td->tff, clip_max); + y += 2; } else { s->filter_line(dst, prev, cur, next, td->w, refs, -refs, refs << 1, -(refs << 1), @@ -357,6 +387,7 @@ static int config_props(AVFilterLink *link) av_cold void ff_bwdif_init_filter_line(BWDIFContext *s, int bit_depth) { + s->filter_line3 = 0; if (bit_depth > 8) { s->filter_intra = filter_intra_16bit; s->filter_line = filter_line_c_16bit;