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 D8FB042B56 for ; Mon, 25 Jul 2022 11:19:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6AF5B68B7B2; Mon, 25 Jul 2022 14:19:10 +0300 (EEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C67EB68B698 for ; Mon, 25 Jul 2022 14:19:03 +0300 (EEST) Received: by mail-lf1-f50.google.com with SMTP id d17so15423330lfa.12 for ; Mon, 25 Jul 2022 04:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KDy4XSk5On4FIlh2PjkE285PhYBtmzHesqCGCtOUyjs=; b=YJmFgshId/Cu3EjLjMJd7w/S+2P0/zVIo4QZCa3ujA0qfJgL8ovBJUiXE8XW8Z3fNh OwuGr5Nj1tSONtyrnLoanxNwa9s72X4Do3Ppt3xRm91aVep4fJq9ZCGKSqarH2/N/PC4 qFY3GiNsOwyjDUBMNPjQQsDbS6x13b83OyhEE+Zgu5cZpkCf3jrHX2TBnCp8MNmujsp+ 066aYSBM4Sfa7KhDKJtrCMvl+HITl65i6vcVnLsAm/UvohRmiy7+svf+hLx/uomE6Dk8 LXBWgG2YlB5kb72xK4sgaY0Eyz9euCAd66zv982JR5+ZI/dkBYahb9Z9PmJwtyvia2aB 5vmg== 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=KDy4XSk5On4FIlh2PjkE285PhYBtmzHesqCGCtOUyjs=; b=b62jIDztylK+6nB/85dOgk4KO8t+eUeUJy2CPiD9ze9/0rpkRIAjbKlTbDnwTL4qUs imQKPHNAIqCk3IvQzXgLofbXcJraQ0spZ5meHzfJWbmEfRqjr+wt9peJXqTzkO2q3uBP gXoaSjNoj+x+qKUart2zm+NeSytqVJMBrmyF8jJFQ/Z+Qfblfy0+WtBeMfa9l6TAWcNq VY7UQ/5EOOy1KplfPlRRuhjSO63r0PzzhLBmobm8AWWUnJIjYYc9FXnfYyFaTkhJF1P0 CXLq8pYs5mKANtnddo5qBUmTuH+NXO+4316f4qTbceryWktNK51F7uWvWHTJbHvsCEmh nEZQ== X-Gm-Message-State: AJIora8/b2VUeN8I+pblWSd2xt3dwM3PKU24qfSiGqgpd91Ke57cZcb6 0afqJa2ur5k07Fpuy3YWpPJQrPhEyGcb6Q== X-Google-Smtp-Source: AGRyM1vW7Af/s50gkeQzPu04wVWPBp7rQxeA8/5CLnoKkEcdglLvbrpEpUxCbD/pEoOUOyhaYXZy/A== X-Received: by 2002:ac2:5b87:0:b0:48a:7b2a:3c8f with SMTP id o7-20020ac25b87000000b0048a7b2a3c8fmr4145276lfn.444.1658747942866; Mon, 25 Jul 2022 04:19:02 -0700 (PDT) Received: from hum-HP-ProBook-440-G7.wifi.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id w15-20020a2e9bcf000000b0025d520648d1sm2695915ljj.43.2022.07.25.04.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 04:19:02 -0700 (PDT) From: Hubert Mazur To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 13:18:56 +0200 Message-Id: <20220725111856.45459-1-hum@semihalf.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220715080228.686736-5-hum@semihalf.com> References: <20220715080228.686736-5-hum@semihalf.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/aarch64: Add neon implementation for sse8 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: gjb@semihalf.com, upstream@semihalf.com, jswinney@amazon.com, Hubert Mazur , martin@martin.st, mw@semihalf.com, spop@amazon.com 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: Provide optimized implementation of sse8 function for arm64. Performance comparison tests are shown below. - sse_1_c: 133.0 - sse_1_neon: 36.7 Benchmarks and tests run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur --- libavcodec/aarch64/me_cmp_init_aarch64.c | 3 + libavcodec/aarch64/me_cmp_neon.S | 72 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index 07d62cc1e5..89c817990c 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -34,6 +34,8 @@ int ff_pix_abs16_y2_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, int sse16_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); +int sse8_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, + ptrdiff_t stride, int h); int sse4_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); @@ -49,6 +51,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->sad[0] = ff_pix_abs16_neon; c->sse[0] = sse16_neon; + c->sse[1] = sse8_neon; c->sse[2] = sse4_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 6e392e9066..dcaffc9b73 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -353,6 +353,78 @@ function sse16_neon, export=1 endfunc +function sse8_neon, export=1 + // x0 - unused + // x1 - pix1 + // x2 - pix2 + // x3 - stride + // w4 - h + + movi d18, #0 + cmp w4, #4 + b.le 2f + +// make 4 iterations at once +1: + + // res = abs(pix1[0] - pix2[0]) + // res * res + + ld1 {v0.8b}, [x1], x3 // Load pix1 for first iteration + ld1 {v1.8b}, [x2], x3 // Load pix2 for second iteration + uabdl v30.8h, v0.8b, v1.8b // Absolute difference, first iteration + umull v21.4s, v30.4h, v30.4h // Multiply lower half, first iteration + ld1 {v2.8b}, [x1], x3 // Load pix1 for second iteration + umull2 v20.4s, v30.8h, v30.8h // Multiply upper half, second iteration + ld1 {v3.8b}, [x2], x3 // Load pix2 for second iteration + uabdl v29.8h, v2.8b, v3.8b // Absolute difference, second iteration + ld1 {v4.8b}, [x1], x3 // Load pix1 for third iteration + umlal v21.4s, v29.4h, v29.4h // Multiply lower half, second iteration + ld1 {v5.8b}, [x2], x3 // Load pix2 for third iteration + umlal2 v20.4s, v29.8h, v29.8h // Multiply upper half, second iteration + uabdl v28.8h, v4.8b, v5.8b // Absolute difference, third iteration + ld1 {v6.8b}, [x1], x3 // Load pix1 for fourth iteration + umlal v21.4s, v28.4h, v28.4h // Multiply lower half, third iteration + ld1 {v7.8b}, [x2], x3 // Load pix2 for fourth iteration + umlal2 v20.4s, v28.8h, v28.8h // Multiply upper half, third iteration + uabdl v27.8h, v6.8b, v7.8b // Absolute difference, fourth iteration + umlal v21.4s, v27.4h, v27.4h // Multiply lower half, fourth iteration + umlal2 v20.4s, v27.8h, v27.8h // Multiply upper ha;f, fourth iteration + + add v21.4s, v21.4s, v20.4s // Add accumulator vectors together + sub w4, w4, #4 // h -= 4 + uaddlv d17, v21.4s // Add up vector + add d18, d18, d17 + cmp w4, #4 + b.ge 1b + + cbnz w4, 2f + fmov w0, s18 + + ret + +// iterate by one +2: + ld1 {v0.8b}, [x1], x3 // Load pix1 + ld1 {v1.8b}, [x2], x3 // Load pix2 + + uabdl v30.8h, v0.8b, v1.8b + umull v21.4s, v30.4h, v30.4h + umull2 v20.4s, v30.8h, v30.8h + + subs w4, w4, #1 + + uaddlv d17, v21.4s + add d18, d18, d17 + uaddlv d17, v20.4S + add d18, d18, d17 + + b.ne 2b + fmov w0, s18 + + ret +endfunc + function sse4_neon, export=1 // x0 - unused // x1 - pix1 -- 2.34.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".