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 BECFD4C931 for ; Fri, 9 Aug 2024 11:27:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7B2E968DAA4; Fri, 9 Aug 2024 14:27:48 +0300 (EEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E807368DA3E for ; Fri, 9 Aug 2024 14:27:40 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-428e0d18666so13938195e9.3 for ; Fri, 09 Aug 2024 04:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723202860; x=1723807660; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=poVmCwTC8KCz6raLeLJac6FOwS6m0beJf90lSNKl+8c=; b=HC/o8ebjOSODjcrSgV+3BUt4pxphfz3rIKcB11ngZFI0zgBGVgdUXITLc3U2p8LH8w gAbCGIn8q25jxvBx12KEulnW5mYjKipIHpC/9WLszXgsyUhXk4BcQxs1L+oC41KufcVk 7iTROCUw+xj+NgOUYR2hLsTnRP65WnD6hmWPI4j5j4+Lu6iuugTl1cm11i7FiLgZtLC5 wWdJgSVMkxjPhUlv5/w/+QvREdB2Z+GhQe42QXUWOdTCF7vs/rglKSRqriDUKFvvoDnh 6rgPeqihGort+Ca3jBEleWZBEwDoEaqX8qWh4cKWE0BA3BDLKzZ0MxZyxJ0izUSuSvfa 3MXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723202860; x=1723807660; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=poVmCwTC8KCz6raLeLJac6FOwS6m0beJf90lSNKl+8c=; b=m2aTS087g85TQ/7m+60rVo0s94L0ltflcS/gbhRC73TX6qdWldH/U3ovaaW4qwET3L AjcGB3qhqKGWt2Y06lmvLJ6Z2xGvISssMA8H5o5NIRO1Lk91dut0xdVysNujiHZd6x1O u/vjpx/7xtuwAWSNfsvUoPRpqM3EISRSvaMdEg+b0d9ID+EVAVG9/z0m6cQNpPYYW362 qhol5aSXHEIQjuLMwdWiqqNhegcZWTt4nap5g1O8pxP1I2WZzjUZ0SSbUTaslA7wqhfE s8KDVlXb7lDAD3X1j81oEPcLfW4PLRmSnQZ9V+hCyOmntuobMkweAjzHM9lNtG86hHXd iYPA== X-Gm-Message-State: AOJu0YzKfRxGFi/EfaqScSK9ckxW71DgIngXMkOIAB0Gr+MmvM1vj74I HmCs8yFBSLl2b+Uiufdv2ADIX6kBDXvUuByZhMmmZee9fFPhI1LUV1E+Tmnu X-Google-Smtp-Source: AGHT+IHTaGcko+tO96c0njVUjp5T5aCjbhfVdQPWfi8+rSpr8SHGlYEVsyea+ZEgymLjs+mc8k22UA== X-Received: by 2002:a05:600c:548b:b0:428:c0a:27ea with SMTP id 5b1f17b1804b1-429c3a1bc92mr7339405e9.12.1723202859506; Fri, 09 Aug 2024 04:27:39 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:6610:8700:a59e:a164:e144:7458]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d2718fb45sm5027927f8f.62.2024.08.09.04.27.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 04:27:39 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Aug 2024 13:27:27 +0200 Message-Id: <20240809112727.107159-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240809112727.107159-1-ramiro.polla@gmail.com> References: <20240809112727.107159-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/mpegvideoencdsp: add aarch64 pix_sum and pix_norm1 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 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: checkasm --bench for Raspberry Pi 5 Model B Rev 1.0: pix_norm1_c: 235.7 pix_norm1_neon: 40.7 pix_sum_c: 249.0 pix_sum_neon: 22.0 --- libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++ libavcodec/aarch64/mpegvideoencdsp_neon.S | 102 ++++++++++++++++++++++ libavcodec/mpegvideoencdsp.c | 4 +- libavcodec/mpegvideoencdsp.h | 2 + 5 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 libavcodec/aarch64/mpegvideoencdsp_init.c create mode 100644 libavcodec/aarch64/mpegvideoencdsp_neon.S diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index a3256bb1cc..de0653ebbc 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -10,6 +10,7 @@ OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_init_aarch64.o OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_init_aarch64.o OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_init_aarch64.o OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o +OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_init.o OBJS-$(CONFIG_NEON_CLOBBER_TEST) += aarch64/neontest.o OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_init_aarch64.o OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o @@ -51,6 +52,7 @@ NEON-OBJS-$(CONFIG_IDCTDSP) += aarch64/idctdsp_neon.o \ aarch64/simple_idct_neon.o NEON-OBJS-$(CONFIG_ME_CMP) += aarch64/me_cmp_neon.o NEON-OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_neon.o +NEON-OBJS-$(CONFIG_MPEGVIDEOENC) += aarch64/mpegvideoencdsp_neon.o NEON-OBJS-$(CONFIG_PIXBLOCKDSP) += aarch64/pixblockdsp_neon.o NEON-OBJS-$(CONFIG_VC1DSP) += aarch64/vc1dsp_neon.o NEON-OBJS-$(CONFIG_VP8DSP) += aarch64/vp8dsp_neon.o diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c new file mode 100644 index 0000000000..c014fac727 --- /dev/null +++ b/libavcodec/aarch64/mpegvideoencdsp_init.c @@ -0,0 +1,39 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "libavutil/attributes.h" +#include "libavutil/aarch64/cpu.h" +#include "libavcodec/mpegvideoencdsp.h" +#include "config.h" + +int ff_pix_sum_neon(const uint8_t *pix, int line_size); +int ff_pix_norm1_neon(const uint8_t *pix, int line_size); + +av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, + AVCodecContext *avctx) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { + c->pix_sum = ff_pix_sum_neon; + c->pix_norm1 = ff_pix_norm1_neon; + } +} diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S new file mode 100644 index 0000000000..eb45afe005 --- /dev/null +++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 Ramiro Polla + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/aarch64/asm.S" + +.macro sum_line add_insn, postinc +.ifb \postinc + ld1 { v1.16b }, [x0] +.else + ld1 { v1.16b }, [x0], \postinc +.endif + \add_insn v0.8h, v1.16b +.endm + +function ff_pix_sum_neon, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + uxtw x1, w1 + + sum_line uaddlp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp, x1 + sum_line uadalp + + uaddlp v0.4s, v0.8h + uaddlv d0, v0.4s + fmov w0, s0 + + ret +endfunc + +.macro norm1_line add_insn, postinc +.ifb \postinc + ld1 { v2.16b }, [x0] +.else + ld1 { v2.16b }, [x0], \postinc +.endif + umull v0.8h, v2.8b, v2.8b + umull2 v1.8h, v2.16b, v2.16b + \add_insn v3.4s, v0.8h + \add_insn v4.4s, v1.8h +.endm + +function ff_pix_norm1_neon, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + uxtw x1, w1 + + norm1_line uaddlp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp, x1 + norm1_line uadalp + + add v0.4s, v3.4s, v4.4s + uaddlv d0, v0.4s + fmov w0, s0 + + ret +endfunc diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c index 997d048663..a96f0b6436 100644 --- a/libavcodec/mpegvideoencdsp.c +++ b/libavcodec/mpegvideoencdsp.c @@ -245,7 +245,9 @@ av_cold void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, c->draw_edges = draw_edges_8_c; -#if ARCH_ARM +#if ARCH_AARCH64 + ff_mpegvideoencdsp_init_aarch64(c, avctx); +#elif ARCH_ARM ff_mpegvideoencdsp_init_arm(c, avctx); #elif ARCH_PPC ff_mpegvideoencdsp_init_ppc(c, avctx); diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h index 95084679d9..63dbd39603 100644 --- a/libavcodec/mpegvideoencdsp.h +++ b/libavcodec/mpegvideoencdsp.h @@ -46,6 +46,8 @@ typedef struct MpegvideoEncDSPContext { void ff_mpegvideoencdsp_init(MpegvideoEncDSPContext *c, AVCodecContext *avctx); +void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, + AVCodecContext *avctx); void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c, AVCodecContext *avctx); void ff_mpegvideoencdsp_init_ppc(MpegvideoEncDSPContext *c, -- 2.30.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".