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 2443C43E60 for ; Tue, 16 Aug 2022 12:21:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D16D68B89B; Tue, 16 Aug 2022 15:21:12 +0300 (EEST) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6782668B876 for ; Tue, 16 Aug 2022 15:21:04 +0300 (EEST) Received: by mail-lj1-f178.google.com with SMTP id y23so10316075ljh.12 for ; Tue, 16 Aug 2022 05:21:04 -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; bh=xs6JcHObQznf2rviOnBCgthrq/WUGqzD1ob6pzVidwk=; b=LQDjxbzU6Z58UC8ei+xNHL/2XAsR9Hqsyi8uySF4t3pF+1broAIZmhAVKgbnv4igS6 QGuWk67xCIkeqPIVUG5MVuEGnFLUZYXoJbpTQzOHz+JKvhpR37qy+ju0ZTRJPy1cnwMe d5oGkpy+f/nR2ZJ3ZO314Bx6dmeQjYTc8XR7gAwQzl4UMbv/rI31zMcQ2PDd+9PmXRpl yEAnaL5F1GID2R7Z7FBNbiJsXwoC6n75w2Y8vN2OMnrtAU8zvDCr1YoYMovUoQTOEML0 n27StODPH4M/mcbHO2Jya3UnmVkgyRRG2kZr5JRzBXVUCMmAihKKPFcbAC7E6hU1/PxI kvCg== 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; bh=xs6JcHObQznf2rviOnBCgthrq/WUGqzD1ob6pzVidwk=; b=0kajo1C+VLuypJHiJa4OEGf/LLId09mOSjcm0qc7DmuGIlcFCV8GsmS8ozrRbfh+jT Y10/lZ8QPl3ftZQypvkczCY7uQ2a1HTonh5qZ2hVnTYnjSKHRhL5g93K+gug0zAuR3P5 ZVF/i/x7UIWzRV53g3qL1DArmccgtO7Dx4gokdVkZXzSoPGUhUBjD13xkks+Y9vgoK+k QVj7IDhmE9lEoKqWqDvp/sJ0Qyz0e927kMZoeeGHE7vSyGEjYMwxm9uDMTvny8Did9Zd C+AFMorSGErWqQvYj4dfkNXPyyQM5Lf1pfkEWvreZMW3XA18dpB3ls66+6H6S5ZC5Fo+ pxTw== X-Gm-Message-State: ACgBeo0M2r+jU551umS06xGAcD/dhPYdccvmPgbCmLyvY0QKE0mjzYym LhV7J7aPDpc6A5jys9ZcBX9piNsSB7SqC9DX X-Google-Smtp-Source: AA6agR5H+DNOrHV5GUF7q+Lkti42Q5lnpBO9JEN+stqmc25SMWZtY1CtdfYZ3X/PTD6EosC6X5C9Vw== X-Received: by 2002:a05:651c:a04:b0:25e:753b:db42 with SMTP id k4-20020a05651c0a0400b0025e753bdb42mr6312060ljq.529.1660652463549; Tue, 16 Aug 2022 05:21:03 -0700 (PDT) Received: from hum-HP-ProBook-440-G7.office.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id p20-20020ac24ed4000000b0048b998be041sm1365707lfr.309.2022.08.16.05.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 05:21:03 -0700 (PDT) From: Hubert Mazur To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Aug 2022 14:20:16 +0200 Message-Id: <20220816122016.64929-6-hum@semihalf.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816122016.64929-1-hum@semihalf.com> References: <20220816122016.64929-1-hum@semihalf.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] lavc/aarch64: Add neon implementation for pix_abs8 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 pix_abs8 function for arm64. Performance comparison tests are shown below. - pix_abs_1_0_c: 101.2 - pix_abs_1_0_neon: 22.5 - sad_1_c: 101.2 - sad_1_neon: 22.5 Benchmarks and tests are run with checkasm tool on AWS Graviton 3. --- libavcodec/aarch64/me_cmp_init_aarch64.c | 4 ++ libavcodec/aarch64/me_cmp_neon.S | 49 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index 2f51f0497e..e7dbd4cbc5 100644 --- a/libavcodec/aarch64/me_cmp_init_aarch64.c +++ b/libavcodec/aarch64/me_cmp_init_aarch64.c @@ -31,6 +31,8 @@ int ff_pix_abs16_x2_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t * ptrdiff_t stride, int h); int ff_pix_abs16_y2_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h); +int ff_pix_abs8_neon(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2, + ptrdiff_t stride, int h); int sse16_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h); @@ -49,8 +51,10 @@ av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx) c->pix_abs[0][1] = ff_pix_abs16_x2_neon; c->pix_abs[0][2] = ff_pix_abs16_y2_neon; c->pix_abs[0][3] = ff_pix_abs16_xy2_neon; + c->pix_abs[1][0] = ff_pix_abs8_neon; c->sad[0] = ff_pix_abs16_neon; + c->sad[1] = ff_pix_abs8_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 3f4266d4d5..8c396cad21 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -72,6 +72,55 @@ function ff_pix_abs16_neon, export=1 ret endfunc +function ff_pix_abs8_neon, export=1 + // x0 unused + // x1 uint8_t *pix1 + // x2 uint8_t *pix2 + // x3 ptrdiff_t stride + // x4 int h + + movi d18, #0 + movi v30.8h, #0 + cmp w4, #4 + b.lt 2f + +// make 4 iterations at once +1: + ld1 {v0.8b}, [x1], x3 // Load pix1 for first iteration + ld1 {v1.8b}, [x2], x3 // Load pix2 for first iteration + ld1 {v2.8b}, [x1], x3 // Load pix1 for second iteration + uabal v30.8h, v0.8b, v1.8b // Absolute difference, first iteration + ld1 {v3.8b}, [x2], x3 // Load pix2 for second iteration + ld1 {v4.8b}, [x1], x3 // Load pix1 for third iteration + uabal v30.8h, v2.8b, v3.8b // Absolute difference, second iteration + ld1 {v5.8b}, [x2], x3 // Load pix2 for third iteration + sub w4, w4, #4 // h -= 4 + uabal v30.8h, v4.8b, v5.8b // Absolute difference, third iteration + ld1 {v6.8b}, [x1], x3 // Load pix1 for foruth iteration + ld1 {v7.8b}, [x2], x3 // Load pix2 for fourth iteration + cmp w4, #4 + uabal v30.8h, v6.8b, v7.8b // Absolute difference, foruth iteration + b.ge 1b + + cbz w4, 3f + +// iterate by one +2: + ld1 {v0.8b}, [x1], x3 // Load pix1 + ld1 {v1.8b}, [x2], x3 // Load pix2 + + subs w4, w4, #1 + uabal v30.8h, v0.8b, v1.8b + b.ne 2b + +3: + uaddlv s20, v30.8h // Add up vector + add d18, d18, d20 + fmov w0, s18 + + ret +endfunc + function ff_pix_abs16_xy2_neon, export=1 // x0 unused // x1 uint8_t *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".