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 B3F7243D3A for ; Thu, 8 Sep 2022 09:26:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 06D5468BA75; Thu, 8 Sep 2022 12:25:44 +0300 (EEST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5528A68B32D for ; Thu, 8 Sep 2022 12:25:38 +0300 (EEST) Received: by mail-lf1-f41.google.com with SMTP id z25so26751035lfr.2 for ; Thu, 08 Sep 2022 02:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=swz+tkpbq2c/Yh3Tdn8cz73DgaAZj1zC/h5HAsE+xEg=; b=nvu4Q2G3pqSdKUUHxFUFlKGFmtfpiXbhMBUobmjnrExTv2IbJ5YLo0i3epUXW/IlLF IdpW59vqX5hye11QoqCKqQVUtK4p2z3Kled6AhcNNZsLQH6LlV2ljcK8sG7O1dxAf6b8 /TC1EXD5dhqYF8DbVEWrf+l3EKO97CEFbwBebL4rJ2ShuNW9ORW4zgaFDs6aPPaKOeuq IuzYv8hrzGjQXyHalJmdLw6z8hZK0bMHqGLqpClTZoLexQGut+hGM4d9ODjAy6auVtbm SPrFzs0pAzuxzPp0Q5Ic/ONnJnMu6kj52dHilYBRTDXKLBOgD1jm3O41yaSUf0cLM8g3 gEAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=swz+tkpbq2c/Yh3Tdn8cz73DgaAZj1zC/h5HAsE+xEg=; b=ayQwLt9oOyEvfwl7tUk6InwPoXUBNFg7EA4kG20XY0xfstT3m7Ldg1P6cMT0Yb3/C1 X30AhnCfU5v7vpSVmi9F4d/alXuHlp7owYbbtVV0wOHUmVUzxnSVZA2nEQkmb1AZPwZP 3rOxeqortEQ7TcsDeUSxNthKw+ra2Ji+VRLpbgi5epA1eCEnrqr4YphE+SxTXHi4xzKB FfOFekx7BaVhMt0ArRHRG1md1isblePEQG9TMTJvHyAKtGWiJ/0r+cyXCUhmN7y1fEbZ 9oK0uhyWfEWHVFFLj82MgDlaS2b8kYYPxZX3Jd3S1BGkE5pduLdQcig44OD9yB+eQ9Ha 9Lng== X-Gm-Message-State: ACgBeo3M9VLGeAUuY1THTR7JBHFSFFQt4vuOaVu+2EWC+LFCvw98BN8J YCt/LUBDhWJc9QRFd30u1z4Xf0OTH3zemg== X-Google-Smtp-Source: AA6agR4uMlV1VrswKf23DiLiVjSPPXtNwqB/caaeQv63fvodGBoQleA8JZGYfmdSdXKf1pZHh0hlsw== X-Received: by 2002:a05:6512:32c1:b0:48c:e9d8:7fd2 with SMTP id f1-20020a05651232c100b0048ce9d87fd2mr2272914lfg.331.1662629137186; Thu, 08 Sep 2022 02:25:37 -0700 (PDT) Received: from hum-HP-ProBook-440-G7.semihalf.net (apn-46-169-39-115.dynamic.gprs.plus.pl. [46.169.39.115]) by smtp.gmail.com with ESMTPSA id k20-20020a2ea274000000b00261e8e4e381sm3103998ljm.2.2022.09.08.02.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 02:25:36 -0700 (PDT) From: Hubert Mazur To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Sep 2022 11:25:04 +0200 Message-Id: <20220908092507.63319-3-hum@semihalf.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220908092507.63319-1-hum@semihalf.com> References: <20220908092507.63319-1-hum@semihalf.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] lavc/aarch64: Add neon implementation of vsse16 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 vsse16 for arm64. Performance comparison tests are shown below. - vsse_0_c: 257.7 - vsse_0_neon: 59.2 Benchmarks and tests are run with checkasm tool on AWS Graviton 3. Signed-off-by: Hubert Mazur --- libavcodec/aarch64/me_cmp_init_aarch64.c | 4 ++ libavcodec/aarch64/me_cmp_neon.S | 87 ++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index ddc5d05611..7b81e48d16 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -43,6 +43,8 @@ int sse4_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, int vsad16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h); +int vsse16_neon(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, + ptrdiff_t stride, int h); av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) { @@ -62,5 +64,7 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->sse[2] = sse4_neon; c->vsad[0] = vsad16_neon; + + c->vsse[0] = vsse16_neon; } } diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 1d0b166d69..b3f376aa60 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -649,3 +649,90 @@ function vsad16_neon, export=1 ret endfunc + +function vsse16_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // w4 int h + + ld1 {v0.16b}, [x1], x3 // Load pix1[0], first iteration + ld1 {v1.16b}, [x2], x3 // Load pix2[0], first iteration + + sub w4, w4, #1 // we need to make h-1 iterations + movi v16.4s, #0 + movi v17.4s, #0 + + cmp w4, #3 // check if we can make 3 iterations at once + usubl v31.8h, v0.8b, v1.8b // Signed difference of pix1[0] - pix2[0], first iteration + usubl2 v30.8h, v0.16b, v1.16b // Signed difference of pix1[0] - pix2[0], first iteration + b.le 2f + + +1: + // x = abs(pix1[0] - pix2[0] - pix1[0 + stride] + pix2[0 + stride]) + // res = (x) * (x) + ld1 {v0.16b}, [x1], x3 // Load pix1[0 + stride], first iteration + ld1 {v1.16b}, [x2], x3 // Load pix2[0 + stride], first iteration + ld1 {v2.16b}, [x1], x3 // Load pix1[0 + stride], second iteration + ld1 {v3.16b}, [x2], x3 // Load pix2[0 + stride], second iteration + usubl v29.8h, v0.8b, v1.8b + usubl2 v28.8h, v0.16b, v1.16b + ld1 {v4.16b}, [x1], x3 // Load pix1[0 + stride], third iteration + ld1 {v5.16b}, [x2], x3 // Load pix1[0 + stride], third iteration + sabd v31.8h, v31.8h, v29.8h + sabd v30.8h, v30.8h, v28.8h + usubl v27.8h, v2.8b, v3.8b + usubl2 v26.8h, v2.16b, v3.16b + usubl v25.8h, v4.8b, v5.8b + usubl2 v24.8h, v4.16b, v5.16b + sabd v29.8h, v29.8h, v27.8h + sabd v27.8h, v27.8h, v25.8h + umlal v16.4s, v31.4h, v31.4h + umlal2 v17.4s, v31.8h, v31.8h + sabd v28.8h, v28.8h, v26.8h + sabd v26.8h, v26.8h, v24.8h + umlal v16.4s, v30.4h, v30.4h + umlal2 v17.4s, v30.8h, v30.8h + mov v31.16b, v25.16b + umlal v16.4s, v29.4h, v29.4h + umlal2 v17.4s, v29.8h, v29.8h + mov v30.16b, v24.16b + umlal v16.4s, v28.4h, v28.4h + umlal2 v17.4s, v28.8h, v28.8h + sub w4, w4, #3 + umlal v16.4s, v27.4h, v27.4h + umlal2 v17.4s, v27.8h, v27.8h + cmp w4, #3 + umlal v16.4s, v26.4h, v26.4h + umlal2 v17.4s, v26.8h, v26.8h + + b.ge 1b + + cbz w4, 3f + +// iterate by once +2: + ld1 {v0.16b}, [x1], x3 + ld1 {v1.16b}, [x2], x3 + subs w4, w4, #1 + usubl v29.8h, v0.8b, v1.8b + usubl2 v28.8h, v0.16b, v1.16b + sabd v31.8h, v31.8h, v29.8h + sabd v30.8h, v30.8h, v28.8h + umlal v16.4s, v31.4h, v31.4h + umlal2 v17.4s, v31.8h, v31.8h + mov v31.16b, v29.16b + umlal v16.4s, v30.4h, v30.4h + umlal2 v17.4s, v30.8h, v30.8h + mov v30.16b, v28.16b + b.ne 2b + +3: + add v16.4s, v16.4s, v17.4s + uaddlv d17, v16.4s + fmov w0, s17 + + ret +endfunc -- 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".