From patchwork Wed Aug 21 14:55:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51103 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4062:b0:48e:c0f8:d0de with SMTP id kz34csp558541vqb; Wed, 21 Aug 2024 09:51:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXSS7FJEQHZSRydbKTa6lol8aJ4NlBcPMXNev3fiNKG0yH+EGqTieJeEW+K8IhsrXP6ewI7BOOCIDrk5ggzXPPs@gmail.com X-Google-Smtp-Source: AGHT+IEp3JjsQx+jgopwBwh+jruJacqpma4HXc+74bAYLqa/BBcEJS7eKhME2ZW5avYbu/hMU8vj X-Received: by 2002:a05:6402:354a:b0:5be:df28:f6e3 with SMTP id 4fb4d7f45d1cf-5bf1f0d675bmr1950574a12.13.1724259080978; Wed, 21 Aug 2024 09:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724259080; cv=none; d=google.com; s=arc-20160816; b=zDptwiPLoL30adp9ZHPGixlKnUOXpM4nCfq0q9KeN2EQwJUlalaxpNJSX12aSMvCC0 wyjueVxiPq5v835lD4+7ZG87RAjpYOKCTlUPT/6KZdh6uhOJ1Lae4IhBzO0a1mK8GQhf 0sNatXNKriOPeUo6Hjq0Z/HD5ZgxFz3O+PRiWA3MkFnYySb4d+F+Vdc/X3ydukpRyhv3 +0DBoGGf88r+aKc/Fks/jsDOEJN/o1BLf+TOt+jVTgVoVnfTBOCc+O+Ra6qnLZ6Qk2zH otX9Zmx1RWAGWaIutpNp/+R5CrnL2/FWVVUzlvymuQQ0EkfANWITsNGceQYisasVEfus lv2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=lTfkphaXje1pVm8LmWj4c5g5H2pSt7SEM0O5VhNzfdc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Sru9MIMehUnKFuex3P8Ks+suWz18CX0h00RMUEpJxZXJLlcFUhDQA/inyJGIvGJa/v 93KhJMEUzgdV8FycVZ91szf9qfZYZpY0vccFMMHr451zPFPRAHeWnKhZ+2bnaw0u0VKS B808dZ2/BXfToneGT5wXcabT+/1ieOZHGyXBFDU9xFrDY6eiaSHg8ABS172qDSY9fq0T HXWgiEMxf8IskDhPsuDiEGgoHsOGsjHzCOCMf39aWh4Yt78+NMa7N0wHoh2/i1SeSYBH kXE5xUkOSG+OiQQXToZAmvKwP/bjf5wldUehJj7d2PDZxIJWKmZjCj7jVUAcJ9aGz1qu ygaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=M8NXnq36; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5bebc0b6476si8627738a12.564.2024.08.21.09.51.20; Wed, 21 Aug 2024 09:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=M8NXnq36; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A1AF68D714; Wed, 21 Aug 2024 17:56:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D61768DC19 for ; Wed, 21 Aug 2024 17:56:02 +0300 (EEST) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3717de33d58so4341700f8f.1 for ; Wed, 21 Aug 2024 07:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724252161; x=1724856961; 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=+fW+omCYAb6Y90JIBkMoPN3DD8yuqsenOfAVrNoVDRo=; b=M8NXnq367+RmqsFYM5XInHG3+GDxYTIivwp7fWbjkeIYJ/IICWvkLDzUezk0OPjaa+ 9B9K5tgtKQhQ09Y8PjD9jJ6942s7VIwudBpv0nzMXsFFi9nxzYZpfFniVCng0px8eDhx ni42ZOfsztXx8jlDV53cuIa+sbjls979SBnIYi9FmThbM5knKCniERhxMoaFVGOcWiur AAjcvrFMc5RCW0xJ0evEgB9VhhvKcN5a7AXoOErjtkpOl51J7+ftcEpOha+G2OxChPY/ 91TKLWSsifGGeTDB4+2MBTHzdOBXdswhOB0l3qgw66HQuvbulmJzLXL31Bi/aVSoTaHo 8q8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724252161; x=1724856961; 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=+fW+omCYAb6Y90JIBkMoPN3DD8yuqsenOfAVrNoVDRo=; b=cX9wN6xYiaY40agyoKgCJGRLFpDOPdLIcpL23vawpkjHu+IGCkTxkrMcCyS4mVbuD+ 8LFuD8gE17k4SnXvGJDlSA1F4ovLhJN3ExPvJDdakSg3vAuB6Eb+640IP5VKD4fiPjLV 9x6kCOEEw4sbGy+jb6VR87IErSk5rOB7qPXRNN3tnezJhsQltQljR1wX/dlJbkLC+kXi ThIhK1jdXhuJEwROdnWiPw1DNWpPx2whEoDdm30xNaHLZVmXctS3SOS60vJt/n3zrXwr SLIidcukwytsRLqp7Qi8aq0a3vbwrHSPVYYAskyRchVG5U8o0WeOF/WxxnEbH1E4n7a/ hRqg== X-Gm-Message-State: AOJu0YxEB1jJfCNe3wqId9XuVeWph5KNLcMqsoZxF1d0wJJ0BS/XlgkJ Mtu7KizCPwtn3tiCbTibObQCzoiqF26TFKhUHjWdW20yiQVKE79vW5IDLq/G X-Received: by 2002:a5d:584d:0:b0:367:8847:5bf4 with SMTP id ffacd0b85a97d-372fd57fafdmr2049354f8f.10.1724252160883; Wed, 21 Aug 2024 07:56:00 -0700 (PDT) Received: from localhost.localdomain (196.105-180-91.adsl-dyn.isp.belgacom.be. [91.180.105.196]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c50sm15873554f8f.85.2024.08.21.07.55.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 07:56:00 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Aug 2024 16:55:51 +0200 Message-Id: <20240821145555.235323-4-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240821145555.235323-1-ramiro.polla@gmail.com> References: <20240821145555.235323-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/7] avcodec/aarch64/mpegvideoencdsp: add neon implementations for 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 16KDi+cWWYSu A55 A76 pix_norm1_c: 484.3 235.2 pix_norm1_neon: 193.8 ( 2.50x) 44.7 ( 5.26x) pix_sum_c: 302.8 243.7 pix_sum_neon: 81.6 ( 3.71x) 26.0 ( 9.37x) --- libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++++++ libavcodec/aarch64/mpegvideoencdsp_neon.S | 69 +++++++++++++++++++++++ libavcodec/mpegvideoencdsp.c | 4 +- libavcodec/mpegvideoencdsp.h | 2 + 5 files changed, 115 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..7eb632ed1b --- /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_sum16_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_sum16_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..6e7a9319ba --- /dev/null +++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S @@ -0,0 +1,69 @@ +/* + * 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" + +function ff_pix_sum16_neon, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + add x2, x0, w1, sxtw + sbfiz x1, x1, #1, #32 + movi v0.16b, #0 + mov w3, #16 + +1: + ld1 {v1.16b}, [x0], x1 + ld1 {v2.16b}, [x2], x1 + subs w3, w3, #2 + uadalp v0.8h, v1.16b + uadalp v0.8h, v2.16b + b.ne 1b + + uaddlv s0, v0.8h + fmov w0, s0 + + ret +endfunc + +function ff_pix_norm1_neon, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + sxtw x1, w1 + movi v4.16b, #0 + movi v5.16b, #0 + mov w2, #16 + +1: + ld1 {v1.16b}, [x0], x1 + subs w2, w2, #1 + umull v2.8h, v1.8b, v1.8b + umull2 v3.8h, v1.16b, v1.16b + uadalp v4.4s, v2.8h + uadalp v5.4s, v3.8h + b.ne 1b + + add v0.4s, v4.4s, v5.4s + uaddlv d0, v0.4s + fmov w0, s0 + + ret +endfunc diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c index 9ccf1c302e..1091c94574 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 3925d87dab..f437bc4e4e 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,