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 AD01D46A4D for ; Sun, 2 Jul 2023 12:34:56 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D9A1968C3BB; Sun, 2 Jul 2023 15:33:24 +0300 (EEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4554568C348 for ; Sun, 2 Jul 2023 15:33:19 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3141c8a6f30so3582155f8f.1 for ; Sun, 02 Jul 2023 05:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kynesim-co-uk.20221208.gappssmtp.com; s=20221208; t=1688301199; x=1690893199; 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=HTO/nEdMAeOZCdntJlf0GIpaMNNokZ08Zkr1LLazdOu1Uj7FyhB57bYIlpuLD7evzz VqIRLoK6U+ueYZ4WCh8G4qYnuF4t/vU9NOt3gc5AtZ2h8XjK9SUhIr4uA7GqhMNP3U2c vWLK4ootK9xqRYLxUsDcGC2JCchoD/juXbLnkR+0Ybah1ViVDhPnzUatLLgOuXTdqEvE VOoTVocho7XlQAa70CUgkQakZ9F+F2z2Fg/iib4Dza63N8TyLm71kYbZl7U8rwf4y8Wt 1vefF1sks0MqGQ3ELm1bZjezkKjq97svwwfvwISKHH2Hu9QOPuUK0SGSCRVXjVMVe914 guiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688301199; x=1690893199; 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=hrKbBsOOgZ9ToZJW7UXdPc1fSRn3i8Z9aYJuwIvbnN0j7/ei/p/I2Bb8gi48SzgU66 Z6R+IbQpAUCGUavVjKOwW77tbXfaoaBCauXVTDWZMcd6GQy/X0ggONp3gxallN3Yf14x vrX60BretoIFEv8RW/CepzGCY9n7bkQbM7n6QM+IYZuFB2lIUYDPdwf5rUjowcRlAmUI vYNzl4FoOqEJubCp2SvUZ5MtYtamVveHGtBKQPqc1Qo3+m5cxZR3GD0FDfo4EaQ42Mwu LCfG+NWIlqo7VnJjEF/NjCG8vSM6V1IGhNVSB5OQlrI11kBkZLybd1EnAMh62/VF1Qe2 bbKg== X-Gm-Message-State: ABy/qLZqvasF+MGdj2jlYTRJwxx1MVL7eYsVesqW6vxCyjSkaUvnkUlh vvdtmFqShAlF+NzBsrwULMk3BvVhmC6UG81SZSo= X-Google-Smtp-Source: APBJJlEpTCLiz39V4wnYvxooEzswbciICYGMQl7Pxbh6jQAWCy5MY3NpMkcTKSocZru6WmJ6G6258A== X-Received: by 2002:a5d:49d1:0:b0:314:13e2:2f46 with SMTP id t17-20020a5d49d1000000b0031413e22f46mr5407715wrs.27.1688301199421; Sun, 02 Jul 2023 05:33:19 -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 f12-20020a7bc8cc000000b003fbbe41fd78sm8816167wml.10.2023.07.02.05.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 05:33:18 -0700 (PDT) From: John Cox To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Jul 2023 12:32:39 +0000 Message-Id: <20230702123242.232484-13-jc@kynesim.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230702123242.232484-1-jc@kynesim.co.uk> References: <20230702123242.232484-1-jc@kynesim.co.uk> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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 , martin@martin.st 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: 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; -- 2.39.2 _______________________________________________ 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".