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 0268143205 for ; Mon, 25 Jul 2022 11:21:38 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9BF6D68B7B2; Mon, 25 Jul 2022 14:21:36 +0300 (EEST) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 72B0E68B3D1 for ; Mon, 25 Jul 2022 14:21:29 +0300 (EEST) Received: by mail-lf1-f49.google.com with SMTP id d17so15432426lfa.12 for ; Mon, 25 Jul 2022 04:21:29 -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=Jhv1vmbJBFfo21Cxd0dfr+2R1awEoAiNCJL3jNAOOKo=; b=JaYm6+S69NXnPj81kehPqDpq88GLV3/fP/IoUA2GSA12ZeVOXujoz0ZouLtWTDh3/U CA/7UIs7jviv8ibD+A/8RjUoGi6SOmbs/PA6GgCMntP7w3PWa49KTwpA/3fqNGcQoiVV iT3I9s91RTWPknq8yJovPlWljRSiDYJNACgb2BnDLard+6g4tbZWP1ayMBF64iYmyRyM i/GKB3sre4Z+HM79p1Au/f0q82sguszHQyCFKlBFnRIjKHBOubdNAaj1Sd2RaVxxkY/4 jginy7D7rdOnsQ8/n2WfA0grLwrXOYm/8tQBTKmxMTRzTqSwxTTjPxLz8/wlIXU+xV6d WC1A== 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=Jhv1vmbJBFfo21Cxd0dfr+2R1awEoAiNCJL3jNAOOKo=; b=LE4IeowUHHJQNBujXIHt3wYks0TUhGfalci5NqphyA0mNXwpbuSLR2tc012TVr5Odv LugqWj52piAfcQNZmVUzCj/BDaJTH80CwyEIPPLGKfBYJBGz4rMwydjLy5NpyiTqh+lL Iw5HLx2JkKfkrVwvNDFXpvCFHaplJP65CCDS3SNynlsVyiK4eQfsECqdG9Vw7hSp0alG F66W0WsUq5FpTbwVbYIQKVv4RC+VxzRK4lO5Lo3r6br/hRixvdgruDbRQcTZFIZTuYAz dIRlfaWOcTCit9X5wiBkJ5vw3gX5KhxFqkC7NPEsI6uikahGJi1PNQU548XbRsyLzcfq Iveg== X-Gm-Message-State: AJIora+xyAgb1Dr6JpL73x5u4A76oOOVaBsCPhRsOwTWhTisBjHMuOEG gLrpx9HsZIq5kILPajXtEMtzCNUXLczkfQ== X-Google-Smtp-Source: AGRyM1tX3WxCEgz4sbtwpRNpuRf9mKjsEE+GqXeFrdTqVyCSutQaqd2KmdLSYEjV5AHYILGRoM7+3w== X-Received: by 2002:a19:9145:0:b0:48a:7ee4:5eac with SMTP id y5-20020a199145000000b0048a7ee45eacmr4106663lfj.641.1658748088516; Mon, 25 Jul 2022 04:21:28 -0700 (PDT) Received: from hum-HP-ProBook-440-G7.wifi.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id y18-20020a197512000000b0048a72f6037esm1051729lfe.170.2022.07.25.04.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 04:21:28 -0700 (PDT) From: Hubert Mazur To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Jul 2022 13:21:16 +0200 Message-Id: <20220725112116.46154-1-hum@semihalf.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220715080228.686736-6-hum@semihalf.com> References: <20220715080228.686736-6-hum@semihalf.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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: 105.2 - pix_abs_1_0_neon: 21.4 - sad_1_c: 107.2 - sad_1_neon: 20.9 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 | 53 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c index 89c817990c..7d7dc38754 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, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); int ff_pix_abs16_y2_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); +int ff_pix_abs8_neon(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2, + ptrdiff_t stride, int h); int sse16_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h); @@ -48,8 +50,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 dcaffc9b73..f2dd63ced1 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -72,6 +72,59 @@ 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 + 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 + uabdl v30.8h, v0.8b, v1.8b // Absolute difference, first iteration + ld1 {v2.8b}, [x1], x3 // Load pix1 for second iteration + ld1 {v3.8b}, [x2], x3 // Load pix2 for second iteration + uabal v30.8h, v2.8b, v3.8b // Absolute difference, second iteration + ld1 {v4.8b}, [x1], x3 // Load pix1 for third iteration + ld1 {v5.8b}, [x2], x3 // Load pix2 for third iteration + 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 + uabal v30.8h, v6.8b, v7.8b // Absolute difference, foruth iteration + + sub w4, w4, #4 // h -= 4 + uaddlv s20, v30.8h // Add up vector + cmp w4, #4 + add d18, d18, d20 + 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 v16.8h, v0.8b, v1.8b + + uaddlv s17, v16.8h + add d18, d18, d17 + subs w4, w4, #1 + b.ne 2b + 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".