From patchwork Sun Aug 18 20:13:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51071 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1569600vqj; Sun, 18 Aug 2024 13:13:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVglIabsiLVcKPIkQSfnIGrnvo/uX/KYaJ5uGJfI2kMsbKalv+9Hz5nJS1IfQcXbC0Tx6Oa3Rn81cGBgaTGipfT1T5QaE7NlD7gOg== X-Google-Smtp-Source: AGHT+IE1j6EbfTdwFTGUAGfACWDq6PFLn++GE/CsXP+KFAmwOACPadmhLMU+Pqpd/nZ/KE37cGSf X-Received: by 2002:a2e:bc16:0:b0:2ef:307d:17 with SMTP id 38308e7fff4ca-2f3be6e6debmr36399651fa.1.1724012023969; Sun, 18 Aug 2024 13:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724012023; cv=none; d=google.com; s=arc-20160816; b=z2eASrx5+rVYfKbmnYAvDIS43HCqXFIZ1SkEPKVEVo1OC5eDXYzNyBQIT+5ta2TkkQ 0D3AIqZo6XWBB2qXsQevkDRVBL2PFXsTDd20iRAycFBPXqVkneZOi3xI2ANcCKgqIlCU XkokYCEY56eF+Y+A3uiTm22oYlzIi28ynEbzoFVTiREgAy6SWrxWpgpF5SyIj++6302G QM5ZmxSazHnYLEGzDELHQOHCv/qKgXP1lZQkdHsk4ATSYYrCKN8mDngjGs+geUcuL5ZR ah3Ik6DhzJSNTr189YgRnXObvy3gjjWH2VwOd+Mifb6Br2800gD/NItiDoByj0Uf1chu wSFg== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=NaJ1JNb3LzJPfm0opNR9Um5PFEngBu87SGgETH8UsM8=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=j5y0NlVcAOlC+ia+Ay2b01U/vM4s+IyaGXZwr1JjHNJbZSsw/IOq/IEp+KgXchuVoG vaWCcroMwuHpcy7rxRjIe8wmDZoVLWbaavmeEiY2bhOzF1ltswDQ39590FwL476qN1ED 3yzgkiZF1t9QckBKo+4+W2ysJHFX/U82tktpxTk8boZ3mLEMV1Zz1hayIsYO8DkhHddz zONYp6HAOlCwZjPnXbaeI6K+Ey9jwoTZJ0uUhasic7u+IaUh30TAODJAMuQiJHoF94z4 J/x1z2k9GpBWFkt2lhSVCPm4mu0mqW8Acfi70+eYPgWql/Ote7lHbJRybeWeAmU5O/Xn ybTQ==; 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=XusVYilR; 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-5bebc0874e4si4645497a12.346.2024.08.18.13.13.42; Sun, 18 Aug 2024 13:13:43 -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=XusVYilR; 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 1E44768D992; Sun, 18 Aug 2024 23:13:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9BB8168D992 for ; Sun, 18 Aug 2024 23:13:31 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-37195f88a17so1685134f8f.3 for ; Sun, 18 Aug 2024 13:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012010; x=1724616810; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=LPavamlBEDPEr/T1vwLMpjMXGjR9VOuFw8bhaVpLCdU=; b=XusVYilR3ijJC5bul0/goNwyMiBEhmKDVjdEM/SZ5pA6Kiy6xGFjRKQIrTvBvFeO9Z nU5kCDVk+Xug3QsS+srLmnOWZzOFVohb2Aj3rOFHN8hRkDnaNjTaJq9ddCh7G0AADmi+ 7tWKKFxi9O/HtlOF+a8ByXl5CJENtRAP7qgVQO17LPAgX/hkVhdyLDuj1qPbSHr9DPn2 i+nH2bxRfMaPMhtrBCZwv7H6JBJJ22jaXupQpTv05QjVSgTjG+UfnnsZ3OUnyoMTNw4s l/jdpycBRA16ovUB3YR3kSqgGcXhKSDMVFjx6qqAn1UQQ5/CfHtHX7CTukjCsj9CCEIp R12g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012010; x=1724616810; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LPavamlBEDPEr/T1vwLMpjMXGjR9VOuFw8bhaVpLCdU=; b=o7WvHgp0SSPiG5+FcwyRmm4H0k+7ko0BtleEbWiE6qZismeyf0LpYyI8DVQB5TTcKf tcLLiDJqiVq6lim4newUzX+A8ntPNoS6NdnA6/C5sfb8Md3sVky1abfSxkoOeLn9g75w hWK3cY9GmJQY7GYD8NzAbn/LmUCdkKI36eNmE5+c4lbxoCQ74kuObbhFC++dkE+UuRw5 4StZMs2OTlAUHzqng37OCFUzv2MLi09U9nwa/nlmbHlHtzS4H5VGqbdTeUX8D6dypqBC M2Esqc3lsZ3swuF3MrEiutvizzH/BfyQClMJzXh+T5UV/UF+QmX+ogJH07Le2RL1sO/w JH+Q== X-Gm-Message-State: AOJu0YwGRoHCxDd3je2lMhA+LJGo9KRp8vSRPH8xJ45r6rJcQ+pnEbJ2 rFPn3Kjcb5J4ldJm0bghN1oVNn4BCt0rGua0YofTzFUzohcEco9qoacONovT X-Received: by 2002:adf:e841:0:b0:368:420e:b790 with SMTP id ffacd0b85a97d-371943289e7mr5404797f8f.14.1724012010004; Sun, 18 Aug 2024 13:13:30 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:29 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:20 +0200 Message-Id: <20240818201326.100492-1-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] checkasm/mpegvideoencdsp: add 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: SkMRLiTdRUHt --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/mpegvideoencdsp.c | 77 ++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 tests/checkasm/mpegvideoencdsp.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 3a7670e24b..7da58c14c4 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -18,6 +18,7 @@ AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o AVCODECOBJS-$(CONFIG_LLVIDENCDSP) += llviddspenc.o AVCODECOBJS-$(CONFIG_LPC) += lpc.o AVCODECOBJS-$(CONFIG_ME_CMP) += motion.o +AVCODECOBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideoencdsp.o AVCODECOBJS-$(CONFIG_VC1DSP) += vc1dsp.o AVCODECOBJS-$(CONFIG_VP8DSP) += vp8dsp.o AVCODECOBJS-$(CONFIG_VIDEODSP) += videodsp.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 58597d3888..0bba4fb295 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -170,6 +170,9 @@ static const struct { #if CONFIG_ME_CMP { "motion", checkasm_check_motion }, #endif + #if CONFIG_MPEGVIDEOENC + { "mpegvideoencdsp", checkasm_check_mpegvideoencdsp }, + #endif #if CONFIG_OPUS_DECODER { "opusdsp", checkasm_check_opusdsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 4d5f3e387e..ba7e8c1ea0 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -110,6 +110,7 @@ void checkasm_check_llviddsp(void); void checkasm_check_llviddspenc(void); void checkasm_check_lpc(void); void checkasm_check_motion(void); +void checkasm_check_mpegvideoencdsp(void); void checkasm_check_nlmeans(void); void checkasm_check_opusdsp(void); void checkasm_check_pixblockdsp(void); diff --git a/tests/checkasm/mpegvideoencdsp.c b/tests/checkasm/mpegvideoencdsp.c new file mode 100644 index 0000000000..00d21ba0ba --- /dev/null +++ b/tests/checkasm/mpegvideoencdsp.c @@ -0,0 +1,77 @@ +/* + * 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/mem.h" +#include "libavutil/mem_internal.h" + +#include "libavcodec/mpegvideoencdsp.h" + +#include "checkasm.h" + +static void check_pix_sum(MpegvideoEncDSPContext *c) +{ + LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); + + declare_func(int, const uint8_t *pix, int line_size); + + for (int i = 0; i < 16 * 16; i++) + src[i] = rnd(); + + if (check_func(c->pix_sum, "pix_sum")) { + int sum0, sum1; + sum0 = call_ref(src, 16); + sum1 = call_new(src, 16); + if (sum0 != sum1) + fail(); + bench_new(src, 16); + } +} + +static void check_pix_norm1(MpegvideoEncDSPContext *c) +{ + LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); + + declare_func(int, const uint8_t *pix, int line_size); + + for (int i = 0; i < 16 * 16; i++) + src[i] = rnd(); + + if (check_func(c->pix_norm1, "pix_norm1")) { + int sum0, sum1; + sum0 = call_ref(src, 16); + sum1 = call_new(src, 16); + if (sum0 != sum1) + fail(); + bench_new(src, 16); + } +} + +void checkasm_check_mpegvideoencdsp(void) +{ + AVCodecContext avctx = { + .bits_per_raw_sample = 8, + }; + MpegvideoEncDSPContext c = { 0 }; + + ff_mpegvideoencdsp_init(&c, &avctx); + + check_pix_sum(&c); + report("pix_sum"); + check_pix_norm1(&c); + report("pix_norm1"); +} From patchwork Sun Aug 18 20:13:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51072 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1569646vqj; Sun, 18 Aug 2024 13:13:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3oFD1hRg7rVHcDrzLUdS1dXuSdIix9ZsQENi/ws9sek2JL+KdsqnSCUIGo0owTdQ+KiTKlK9XYLXWHiHNK8Nmw2ta4JhS3E4+6w== X-Google-Smtp-Source: AGHT+IGWGY0+v4v9ka8iLWdU0PZRfDiip2tOAtE2ODFTOQkKlEZd5P8o6xPW0rpMsQudHC989yxJ X-Received: by 2002:a05:6512:b29:b0:52f:10b:666c with SMTP id 2adb3069b0e04-5331c6d031amr3294262e87.5.1724012034230; Sun, 18 Aug 2024 13:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724012034; cv=none; d=google.com; s=arc-20160816; b=ldEWP54zvvpAQfUx+PHej2wolrJJdMlqYBey3gW5v0JjYHo1wT7l0TbZWiujaZ9DVP 2T3fyIqWbujiRGk82Gzs5p+EwP88vCAdvAuKpP6FyueBAu8n88Wl5LVNO14Fx2zbiZjx 2A0SBgron1yW/tlS1njLTWrmTwqHi9QpcUTvFStYDFkudg1x5lK0fmIELr20BohCYuOA 1zC9IpoL6gDOLrxkxDIyBRwHKrXi1V3DNayo6zvGN+eVbTkhoIgyM02gPvfXa/0R2nrP +RBJFQLsDOcK6triNVslCROKiFH6QB2TiNODNRaqz1f70eGpa2deHkG01/9BugmDB3hX Y6gA== 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=JZqOgQSU9hVl2oT7xg1nJpHMzH3GHW2av8cMDYUwBsg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=vA2C9l6xGVLBgK1z34Tt4KTgHSq44K6E/pdm9zDLBcI3VPxqEGl/IsFhKzYMWSxL+w Zxo6Zxfbw7sWiYSZ9OlmjMBk+QvL5vthDNOhxTYiU4CsARlY3tZMyxleLJzoeMxSlvI1 YAagQum67sPDMsjCnBsJz3FUYaBj4XbZKXvBvSCgYfl/SuhJROL19Jp07i46EsacNIRZ nLHHvpJ0aA6R+XVBQ5mz3X6X4uijuzJeJlW5dUqpAvUl5FuMxM/TYM3iU2p5VagmnpH7 uX8gFHPzkNyh2Ga+D2eOCsfRF7oGWgqwVbuR1qbEypdVstes5qLj0HsHLwA0+bo3BwdQ 4kIA==; 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=BbFhBYXY; 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 a640c23a62f3a-a83838c7d72si474793866b.28.2024.08.18.13.13.53; Sun, 18 Aug 2024 13:13:54 -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=BbFhBYXY; 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 36AB068DDD2; Sun, 18 Aug 2024 23:13:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F1A0568DCA2 for ; Sun, 18 Aug 2024 23:13:32 +0300 (EEST) Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-428e3129851so29235925e9.3 for ; Sun, 18 Aug 2024 13:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012012; x=1724616812; 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=SzuborkmsgKimBm23reXR56+rSbCL9FA0yJboUrGE9s=; b=BbFhBYXYaLYYHaYJXVALPyeEHMVjkhMznZrYLuhD63ij/z7nvyeAM6VCpAXE9tLkiu T9xQfBaHwH5P1+KMVEwWfvOKVa4LcqTwxC/hO9A+9VHgX/t1PgaCN/OqiCUkt0YoPEk5 Mqe7dk4BPVbZWoC0H5s/JUHeeFZd1cmlhhTgMZM+x84pXZ9s83jVtBvaEiSqb2T/eaPl eVjY3o678hurDAQqJ57vIoHz0fLTIYlVn5sGuSOEKwxVqQUOgqaP9XpoV/vvLRhpb+MW b4FPrg1v26s3PU1+zs1rt3S5AFY3psj8RGhMa3te38rJS+nVunqLqa5ZF+ZtkTtw2Gtu zrlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012012; x=1724616812; 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=SzuborkmsgKimBm23reXR56+rSbCL9FA0yJboUrGE9s=; b=H5XAhlh1h9wUnCUCAMfqEn7GdiMyKjdzJAYN483e84kWOVrESvj9EQl8sLhognwyUV ojUlZu/NQ9dMVnO0XMqrwarfVDXxADZjNu+k+o1djRFJiulPCiL+t4eQMJzKIeS8cF2k cMbmss5dEVYWYGp5pHFQwj+ltAL6lx2pa3BpZGFIQ7806fXSE1kZSRUdUjaqdvfRSiEd TYRgbe4jfuxRqe1Ui5uVDAvDGPM/tjmFeLTzkO4pAG0mi6R11OTdzMDjtK41otdYaiyP UIJOsWIlGHACHm1j2z5Bsh57YBuONBCmBUDU6WxqS0vQxB+XN1bWj4mcx1fyebfI+8J4 3iQQ== X-Gm-Message-State: AOJu0YwQ3fpqSR5IDNhLh4IFniGD4TfIh6u5abLMQ3woblL/OJI7xD0r gS1/JJFXXE8X2MtrmxhSaSeHXkrS2DyCA+I6sfwpR7eaMzO2H/OoJ4mgM9/u X-Received: by 2002:a05:6000:183:b0:369:be6e:1596 with SMTP id ffacd0b85a97d-3719465351amr5174908f8f.33.1724012011496; Sun, 18 Aug 2024 13:13:31 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:30 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:21 +0200 Message-Id: <20240818201326.100492-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240818201326.100492-1-ramiro.polla@gmail.com> References: <20240818201326.100492-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/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: OQV+gJ/D0j1D A53 A76 pix_norm1_c: 519.2 231.5 pix_norm1_neon: 195.0 ( 2.66x) 44.2 ( 5.24x) pix_sum_c: 344.5 242.2 pix_sum_neon: 119.0 ( 2.89x) 41.7 ( 5.81x) --- libavcodec/aarch64/Makefile | 2 + libavcodec/aarch64/mpegvideoencdsp_init.c | 39 +++++++++++++ libavcodec/aarch64/mpegvideoencdsp_neon.S | 67 +++++++++++++++++++++++ libavcodec/mpegvideoencdsp.c | 4 +- libavcodec/mpegvideoencdsp.h | 2 + 5 files changed, 113 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..89e50e29b3 --- /dev/null +++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S @@ -0,0 +1,67 @@ +/* + * 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 + + sxtw x1, w1 + movi v0.16b, #0 + mov w2, #16 + +1: + ld1 { v1.16b }, [x0], x1 + subs w2, w2, #1 + uadalp v0.8h, v1.16b + b.ne 1b + + uaddlp v0.4s, v0.8h + uaddlv d0, v0.4s + 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 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, From patchwork Sun Aug 18 20:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51073 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1569689vqj; Sun, 18 Aug 2024 13:14:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/cmtAHO8ugq57VGc2OEdmjl2cDAYUHJOc1JKjs1T9bzt3vtrl6dR2SEARlN4I2+eyVgg87j+zgUjdqbQNQwOdBX3AKgJQe+gCKw== X-Google-Smtp-Source: AGHT+IFzOJT5qRbxLQOCm08qj9PbcD5mdjV7WIz/Zy9JAgpmwUuJN0ZXM9t7UeCj9CCiEwERUCWc X-Received: by 2002:a05:6512:3190:b0:533:6f3:9840 with SMTP id 2adb3069b0e04-5332df369c7mr3053058e87.11.1724012043625; Sun, 18 Aug 2024 13:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724012043; cv=none; d=google.com; s=arc-20160816; b=ieR1Q1fZPLmhAhBzsqieUfR+oT8paZOK62Wfa8wJTKfLb9/vsGY41c4BfqJF0lZa8Y ZVELOwaGY6SWga6qqWjZxtluNPevEPrLVz81H/k8jWsTeoD9Ix71KLJ6Qi2zAqLbPedL a8GfZdpucOfp47mJD/GqHoDbDlno5XlvhXJ8YPwkNxG4qBasbyjwGntt1F5/Z896AHuB lOh+LF0XBV4rTFqyE6s3CYCRpIyG2ZXmdZWYs4MCCY6VzaCGrQQJ2DLRIpgw6tukEElO wZPnJaasslnqykdpLNMLIFDmvBS/Lr6hUxnnUCHiWWU73fp06E/Gjc+2oQ/VdiupdsB0 Tlkg== 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=u/cGUxf7UAHbc9y1vz5oxNr4BBhWNhPA4iEJNyPQcQw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=il9NWg9yjvpx4Mshd8gvQhlAC4mr2IedvRRR/CqIUWH8iHgmLIzYxI28qj69g1CQxt ELsWVjMD7nsygZpfWT2CJRorJvXJL4lKBuohokUDJSAGq7YhAJqtRbvK7EnUpcbreZBm BR9vJ35Y8hJtE4usZTAEW0LfT6v1hIJyA6kUXgoRVxcFjDsCeTG2kGuD8pDShlzFbQIJ i25gYxNcD5fEfV7IAtBSvMLBpHU7KmGh3uv8gbnahNwjV4xEoEORKDFf6vYQ8CotI+k6 Why56q0nQwA8bC/bvCALj6vGNUZJaEPXsWNNcsB8W4ovEb6Orb429j3nmu6LXHKXdR3U vWjg==; 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=SiMgdqFC; 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 a640c23a62f3a-a83839390a2si496220966b.395.2024.08.18.13.14.03; Sun, 18 Aug 2024 13:14:03 -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=SiMgdqFC; 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 3A60768DDBC; Sun, 18 Aug 2024 23:13:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3B95868DD5B for ; Sun, 18 Aug 2024 23:13:34 +0300 (EEST) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-428ec6c190eso30386265e9.1 for ; Sun, 18 Aug 2024 13:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012013; x=1724616813; 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=de+o5hu0bFtjqwJ1ZrQ88QuTZb5DNhrsZY6npnXjtZ4=; b=SiMgdqFC05UYzzO6HnmcVMvND+ZE25aAcgUTInGC8I9WKD3CMl9opZUxzgvaCyLE19 ynXf4fxYv9ctSxD0gleGCHvHtvFdnycHKVjZ9rhyEAEL/p6h21C4yyobypPJQ2cWepKw yyi/sSxGga72S2/FHuPLW2NGuLmB1Auihbe8fkN0whhWXLQk4g5PF8IIMZ2ZfHtGlzEP LITNDfsRg4aCIF2p6VJb6eJvxNOf4tSbfI5bfNhD48PCZVEx0KH6AMCoGCYz+HeIb0vs 6MS6rg6g7BzMVlcXe1cQGxCGyKzD0wpliE0eoq9SpvRV6F3bq/4sTlMXM9C8bP5VNFp5 50vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012013; x=1724616813; 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=de+o5hu0bFtjqwJ1ZrQ88QuTZb5DNhrsZY6npnXjtZ4=; b=vawqmHNL0QFoGTEwgz753k9L4TDE4d5+AFNbrOndm47MxkdSXWfAJih/xxDrBx0lEQ CvnYiCsyciwe3WlM1YaTd6JVDfZ2pVgzFyrXFpGBsLVSueItadQhQx48Q6s7JyeF3UHt VauKdCwF1MpTNZlrGZ/viJjVmyR5HANSe9y/d14YgRr+0AwhLYm4JsenbH5IfdU8Zs/0 /OSVDLHRWLGVma2XN+e1tVla4OSID6g5plBBmWjvecuD5ABdmAKvB5qIzvu1YrXDw65e YqCO4rSPNhTNWJ6qsHCB1gpLDWuYV2mIy6HiUqUV5qqd+Cni4Y0HSDXC9wjNQX+Qab81 QTUw== X-Gm-Message-State: AOJu0YzJtWUeyzBQE4nmJAkd40ZAoNsrTFr/d6kBi7B6C7wX8SjmzKMu uhSz0Lsoz7jXsxs7UGHLdfZYve6+Zlm6DlapeJKH214D4xep2riM5W5FYEgL X-Received: by 2002:a05:6000:1a89:b0:371:8d08:6309 with SMTP id ffacd0b85a97d-371a7477af5mr4512573f8f.55.1724012012793; Sun, 18 Aug 2024 13:13:32 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:32 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:22 +0200 Message-Id: <20240818201326.100492-3-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240818201326.100492-1-ramiro.polla@gmail.com> References: <20240818201326.100492-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7] avcodec/aarch64/mpegvideoencdsp: add dotprod implementation for 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: Ut6TAPoxzqk5 A76 pix_norm1_c: 231.5 pix_norm1_neon: 44.2 ( 5.24x) pix_norm1_dotprod: 20.7 (11.18x) --- libavcodec/aarch64/mpegvideoencdsp_init.c | 10 ++++++++ libavcodec/aarch64/mpegvideoencdsp_neon.S | 28 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c index 7eb632ed1b..d0ce07e178 100644 --- a/libavcodec/aarch64/mpegvideoencdsp_init.c +++ b/libavcodec/aarch64/mpegvideoencdsp_init.c @@ -27,6 +27,10 @@ int ff_pix_sum16_neon(const uint8_t *pix, int line_size); int ff_pix_norm1_neon(const uint8_t *pix, int line_size); +#if HAVE_DOTPROD +int ff_pix_norm1_neon_dotprod(const uint8_t *pix, int line_size); +#endif + av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, AVCodecContext *avctx) { @@ -36,4 +40,10 @@ av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, c->pix_sum = ff_pix_sum16_neon; c->pix_norm1 = ff_pix_norm1_neon; } + +#if HAVE_DOTPROD + if (have_dotprod(cpu_flags)) { + c->pix_norm1 = ff_pix_norm1_neon_dotprod; + } +#endif } diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S index 89e50e29b3..eccbdd850f 100644 --- a/libavcodec/aarch64/mpegvideoencdsp_neon.S +++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S @@ -65,3 +65,31 @@ function ff_pix_norm1_neon, export=1 ret endfunc + +#if HAVE_DOTPROD +ENABLE_DOTPROD + +function ff_pix_norm1_neon_dotprod, export=1 +// x0 const uint8_t *pix +// x1 int line_size + + sxtw x1, w1 + movi v0.16b, #0 + mov w2, #16 + +1: + ld1 { v1.16b }, [x0], x1 + ld1 { v2.16b }, [x0], x1 + udot v0.4s, v1.16b, v1.16b + subs w2, w2, #2 + udot v0.4s, v2.16b, v2.16b + b.ne 1b + + uaddlv d0, v0.4s + fmov w0, s0 + + ret +endfunc + +DISABLE_DOTPROD +#endif From patchwork Sun Aug 18 20:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51074 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1569739vqj; Sun, 18 Aug 2024 13:14:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWTCO5yH5auW25cUiD3lbcIEP/OybD6zPTiPE4FMfgq4B0/1dTG+4f2g3XCYFrXc1mJ8Z+RsLjtTDVbCm3pwl4C@gmail.com X-Google-Smtp-Source: AGHT+IHKmQ/1j3Yi/mfOg0+xvw9tamiIvt7oG58unnTOht3sSuQCekW4tpm4FhoXVzxe0rVxqJ2z X-Received: by 2002:a5d:6da7:0:b0:367:9505:73ed with SMTP id ffacd0b85a97d-3719465f5cbmr3564257f8f.7.1724012052695; Sun, 18 Aug 2024 13:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724012052; cv=none; d=google.com; s=arc-20160816; b=EOLPbqHhgV3OvCw1w6WcJaqZfd5UnclwyYAqe1vNZvnGul1Gld19WZgCYSsegMwqwL cm03PKsqlFr47qDwrsFXvmT4+LRkHl9CW11/zS7iDVJaF/ByzUub8RIOPbpSDU23ybYf eNVQ0faKsNDK2dPNMh3aB5tyJhpl24JSiiCZXJPVB0xOQnehOuMI29Dpwt6tuMOAUcn+ RvVwyb1OXiJ7XUbb3rtXPObRatyXA8ZsN+OiInvpgdiZRSwm43ZnjjmhZUt2U84Igrsa ohW6lTiS9rSg8x0keEhtp5zshW0mvgB4gPH7ukLkbBjtCPtbEXHNpslaUeRpou6+hq4K zC9A== 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=8Ky7Gq1SesAd0Ko5PxPuN4NQtwivr+g9E8E8OyaSL4A=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VP/PJBQa8afu6i8bI+03bz8gM6pMP1YfR91Q24hZkYG5fLgWP3PhbMwoUkPyQN4HJB aKs5yHkkcs/Yk6X6cm6um+0tjxZ/0hm83WWz2oB2E6zNK64aEEKu62/Q/gtiWY9rFtS0 C1kBHbJxAq/gM0rcRnM8GtpjBLc/aYWVcnuJ6kDq4m3TdTELX0h8aVswXStGdBoKFi5L EulF4GDblONCcg3b2KXhMb3gILdARbGbW0l2NCkzhtII91Qg6b+3yVnmgYMWZaY2j46D N9txB0+EJsa5rNO+9+cjOmX0ChjZ4tTyJlSvktFrUDdAAR0/RGon1OCbQr202MV7aIYT XOxA==; 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=Ft7mr2Xz; 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 a640c23a62f3a-a83839716f0si450155966b.882.2024.08.18.13.14.12; Sun, 18 Aug 2024 13:14:12 -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=Ft7mr2Xz; 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 A064268DDBA; Sun, 18 Aug 2024 23:13:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 678C568DD1F for ; Sun, 18 Aug 2024 23:13:35 +0300 (EEST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4281ca54fd3so28437755e9.2 for ; Sun, 18 Aug 2024 13:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012014; x=1724616814; 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=7y8DlUCOPdiszj82BxbjshTzBQ9vidKSncCxNyWGUfc=; b=Ft7mr2XzIszuIttcYKiroJGjRqF7/aRjXip7IXqfD7mHLSyr1OI17at5Ojj4UMDH1q n+yGciryEriKLrFXogpRkmuK8IW2DewiSNnt9NPv5mTx64vZ+Y5BCBWjYSdj2Gi4goxP TQf4A0cyvnrMPmDzLmpugsT39PSdJ9BBzqo7/lYfYZMVv6MknB2/4dFhwr5yB2MvgQ49 TkTOiQeLsUpMPPiHmo8aqIMxOmEAb4B4JJl0KuAVNqiBBK24sE7Paz3Gi+Y6nzWlTVvH 1JZMTftc+rbFMwieyYn8bZ+vzag6z7aBNf3hduH47vkybhnFtXR3c3sYaS0V/3RkOEFy XeJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012014; x=1724616814; 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=7y8DlUCOPdiszj82BxbjshTzBQ9vidKSncCxNyWGUfc=; b=YCRE5VdDl+Q074um6iHV1wNHtn4T5LszBPf31jGoleOkfWtRwvnQqmWy7Bi+PAEe2y p+VFj7VtHSa1egao+7ocThip6HsxS5WAS1x2I6tHjP5UfVQIm0fe/U/96OoldxDZLHci ZeOf32fEOOculKlxHQcijFqUt5GZjVKzSYYNzJNVAkPWRSUZJujTvOpPkTWGVxYtSi6a PeN7x8ZPZOwOBGbEZM3yPv37HROtk+fb2deQSZuXKjdqY5oJCAKKH/ADTEywNcqsub42 Eo71EwDaCZMfTN97geIulyg4ouh5gAKNhvisiYO3d9s+2vWSWgOwzxvJ9TEtggrzdmsy 61tg== X-Gm-Message-State: AOJu0YynpQJribuB1pMhqOdI9ib7d1c8/2dL984qtX8VddNR9c/LAsrZ 8RHKsJaTBdiXOJYxH9XDImtzXYw6vMhM8uN6wb4KWHL/NCv9xXOtY6y8oLAi X-Received: by 2002:a05:600c:3c9e:b0:428:1e8c:ff75 with SMTP id 5b1f17b1804b1-429ed7e2306mr55930205e9.35.1724012014110; Sun, 18 Aug 2024 13:13:34 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:33 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:23 +0200 Message-Id: <20240818201326.100492-4-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240818201326.100492-1-ramiro.polla@gmail.com> References: <20240818201326.100492-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/7] checkasm/mpegvideoencdsp: add draw_edges 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: LkHKMH8CYnx1 --- tests/checkasm/mpegvideoencdsp.c | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/checkasm/mpegvideoencdsp.c b/tests/checkasm/mpegvideoencdsp.c index 00d21ba0ba..21954a4a65 100644 --- a/tests/checkasm/mpegvideoencdsp.c +++ b/tests/checkasm/mpegvideoencdsp.c @@ -23,6 +23,12 @@ #include "checkasm.h" +#define randomize_buffers(buf, size) \ + do { \ + for (int j = 0; j < size; j += 4) \ + AV_WN32(buf + j, rnd()); \ + } while (0) + static void check_pix_sum(MpegvideoEncDSPContext *c) { LOCAL_ALIGNED_16(uint8_t, src, [16 * 16]); @@ -61,6 +67,51 @@ static void check_pix_norm1(MpegvideoEncDSPContext *c) } } +#define NUM_LINES 4 +#define MAX_LINE_SIZE 1920 +#define EDGE_WIDTH 16 +#define LINESIZE (EDGE_WIDTH + MAX_LINE_SIZE + EDGE_WIDTH) +#define BUFSIZE ((EDGE_WIDTH + NUM_LINES + EDGE_WIDTH) * LINESIZE) + +static void check_draw_edges(MpegvideoEncDSPContext *c) +{ + static const int input_sizes[] = {8, 128, 1080, MAX_LINE_SIZE}; + LOCAL_ALIGNED_16(uint8_t, buf0, [BUFSIZE]); + LOCAL_ALIGNED_16(uint8_t, buf1, [BUFSIZE]); + + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *buf, int wrap, int width, int height, + int w, int h, int sides); + + for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { + int width = input_sizes[isi]; + int linesize = EDGE_WIDTH + width + EDGE_WIDTH; + /* calculate height based on specifed width to use the entire buffer. */ + int height = (BUFSIZE / linesize) - (2 * EDGE_WIDTH); + uint8_t *dst0 = buf0 + EDGE_WIDTH * linesize + EDGE_WIDTH; + uint8_t *dst1 = buf1 + EDGE_WIDTH * linesize + EDGE_WIDTH; + + for (int shift = 0; shift < 3; shift++) { + int edge = EDGE_WIDTH >> shift; + if (check_func(c->draw_edges, "draw_edges_%d_%d_%d", width, height, edge)) { + for (int i = 0; i < BUFSIZE; i++) { + uint8_t r = rnd(); + buf0[i] = r; + buf1[i] = r; + } + call_ref(dst0, linesize, width, height, edge, edge, EDGE_BOTTOM | EDGE_TOP); + call_new(dst1, linesize, width, height, edge, edge, EDGE_BOTTOM | EDGE_TOP); + if (memcmp(buf0, buf1, BUFSIZE)) + fail(); + bench_new(dst1, linesize, width, height, edge, edge, EDGE_BOTTOM | EDGE_TOP); + } + } + } +} + +#undef NUM_LINES +#undef MAX_LINE_SIZE +#undef EDGE_WIDTH + void checkasm_check_mpegvideoencdsp(void) { AVCodecContext avctx = { @@ -74,4 +125,6 @@ void checkasm_check_mpegvideoencdsp(void) report("pix_sum"); check_pix_norm1(&c); report("pix_norm1"); + check_draw_edges(&c); + report("draw_edges"); } From patchwork Sun Aug 18 20:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51077 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1575578vqj; Sun, 18 Aug 2024 13:36:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1CPRbti1sPkyyDA9zudZWQDpjPgDlZclBCRxVxYoenbr+p9Hsch29FQtC5gM9ZGovOSEHFhaFdoHoiMbhyZGVN7G0AeV/uA40wg== X-Google-Smtp-Source: AGHT+IE47mG6ofuuUGkdO4jYDqGqOLNVrhKeRn2FSZg1tKddml1ZjnK44oMxtBcDVD9C1bOdNFGs X-Received: by 2002:a2e:a585:0:b0:2ef:23af:f202 with SMTP id 38308e7fff4ca-2f3be5f0304mr86568331fa.46.1724013380237; Sun, 18 Aug 2024 13:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724013380; cv=none; d=google.com; s=arc-20160816; b=Efor1+aXSXRIdL0kyF67A8KfLhy9+1FKkPV9KTmlNbK7yc91aMVct9Bq4Te2PvNgGg dZrXbyNd38RUXqwx2Kha8+Yk2iFidve1SBjegAp1Z/gCaL8xaNrZ06M1mR6YaNMfhWAb JEmx3bLCA4G2vDDJLp7iYy3XM/0YInIJtT4EkoQhpKQb8LbBE4kgRUZ9GKbkbouwT0Il 1iFOtsV9Ry45lv9HA800c9qvY56MAOPuXToKmU0fGqh+OAvvhMnLuEhyJtes+7aR30bw DvntMs2CaaB28ruJFZ/wLysG6gP/FGAizunPvgfMDqV/OIbP33tvqsxaZwwR5Jnw2dz8 mtag== 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=j3TYXc6pGNN/EGYPmQH9pPxFiwSBUvnOm8W6tBloyfk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Kk1buCpYZcdI8qCuNyaB63QZWxxlNC+b3uqwdZOzpDBWCADTLNUMM/K4JCvPi+W1kB wWyAJuiNJn+tIA96XcQKkKAZY+MxsLXf8jKgVZ7+CO22KlN5VIZOLlmm4l91JQ5QF92c phRrxhzra2gmljjtFWDTDV5K0OeoN3gmMvsx6ktql6bS287ui1Nu2EqgqynOI7nfgRri pd7p4l3xT3oKwn6MNEH8lPyEVEXVTzRaB2cYH4TncQ1LttZoRxOISrsAf75f8ZX/Z0dJ 1W/IGBLKrVISkrUYte7WpjncaZb1lz76xJDQvgTmk3m1ytuiUK31pvGNtqzHMG4DLDbY c7PA==; 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=jhM0dzGB; 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 a640c23a62f3a-a838398d7e3si470192966b.1010.2024.08.18.13.36.19; Sun, 18 Aug 2024 13:36: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=jhM0dzGB; 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 E7C9F68DDE7; Sun, 18 Aug 2024 23:13:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 189FA68DDD0 for ; Sun, 18 Aug 2024 23:13:36 +0300 (EEST) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3718eaf4046so2177716f8f.3 for ; Sun, 18 Aug 2024 13:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012015; x=1724616815; 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=cdCRx34vUZuk65KNMd+COyACckFYXEgMwGcuSz2PpZo=; b=jhM0dzGBklucgV/vZLSnuKw3mN2/Km/vMLMr+1i3dLD8v86IUtpYwQ1lv1yqph3lre VvOV8vebXRr6J0ouD3hxbf+87N6qUNXKRHQLOIoweWNKYL2isSUDvrrtPSOz4ucjwo/M OFTSNbYtjmCAESNnt6z1bmV57rWNZ7n6PwUlCuH8iYX/2op6XMaXNBxwS8odPRWEE8v+ afyaTN5VbyfC8ZNjLWbp2BpZWuqTcJH1oQJS1KYtH8O6x8YCKNigNh+FhET4rKjKBy4z syJGstwqUstGX6qnEVo6+ZOb9FspuisWUVSQT7OYUQKmhsKH61JloYCOPxkV6J8moYPX 8dUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012015; x=1724616815; 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=cdCRx34vUZuk65KNMd+COyACckFYXEgMwGcuSz2PpZo=; b=IIiJ1LlzQDYz42bHlZ+V5VmSDOO7FWw35fUEyKWlB3Lp+JCCIVpDPcYhKze0YKfWBu +gf7YdkFkLhgtT6MrvIS06iYLBjZEMoX+WW51ObtczxlIFx+QgR/2rtdwh3aWTs12s76 n9eOu/uZJA6gmyzuIChB8N4O24ZyjPUycNBULDTAfCVR0XUmVlT7MOn951AVmGIVqacZ fWQ6yltSHQnXibmB1slnTgueRf0zwfXirTxBwN3c1aF0YhryqjnY88K5fplosZbYEBxe FF+Fg+WRNJVCPrTO9mbHT4KI8IbgIjaPSC4C/s0RvbOI5jfMk/2ULwAHKmGISKjKbAa2 h41A== X-Gm-Message-State: AOJu0YxsLMgPRVG1dI14xImOMrAn84P2TI3/4ZBLFf9oU5Uq069/yn1M woa/607WRaTkwRnYmVEKVPdD4ZYEjuD4WCvpZ9jJLeWGDWA38MpIcYnTDK+R X-Received: by 2002:adf:f843:0:b0:368:6564:751b with SMTP id ffacd0b85a97d-371946513fdmr6474108f8f.32.1724012014941; Sun, 18 Aug 2024 13:13:34 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:34 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:24 +0200 Message-Id: <20240818201326.100492-5-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240818201326.100492-1-ramiro.polla@gmail.com> References: <20240818201326.100492-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/7] avcodec/x86/mpegvideoencdsp: fix comment for draw_edges_mmx 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: yM2FbgwG1y3s Not only w == 8 and w == 16 are supported, but also w == 4. --- libavcodec/x86/mpegvideoencdsp_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c index ec174b15aa..503548e668 100644 --- a/libavcodec/x86/mpegvideoencdsp_init.c +++ b/libavcodec/x86/mpegvideoencdsp_init.c @@ -95,8 +95,7 @@ int ff_pix_norm1_sse2(const uint8_t *pix, int line_size); #undef PHADDD #endif /* HAVE_SSSE3_INLINE */ -/* Draw the edges of width 'w' of an image of size width, height - * this MMX version can only handle w == 8 || w == 16. */ +/* Draw the edges of width 'w' of an image of size width, height */ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides) { From patchwork Sun Aug 18 20:13:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51075 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1569831vqj; Sun, 18 Aug 2024 13:14:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXY/j0c2vrHwQdIdnN7zr2mVjxlFrFplWtuL9wx5dgSKoYooQdaVfxIgupLX0ilZe5X5To8HcfNu6bCj2ed+zCA@gmail.com X-Google-Smtp-Source: AGHT+IHHk6BCPRW4qYvBicGnY3ASvy7nSNSGapCFgJcvUIh3jkuMrthCwpPi1vGJ3QZOmIaECn7T X-Received: by 2002:a2e:be07:0:b0:2ef:307d:1f with SMTP id 38308e7fff4ca-2f3be4788ebmr37113921fa.1.1724012071310; Sun, 18 Aug 2024 13:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724012071; cv=none; d=google.com; s=arc-20160816; b=bZcisna3QFXUPkRdZ4POnAj+u0Ko1qjnJHVY6ynwqlBhIn49BVF3nBEEUAcfzv6Oo7 aOzyajzVJrqix4p2G2PmoNpIhJPweODcXAEZ0M/7ttXFcMEKUyjRqDrQTPNiR9A9hv59 GZihq09TZd0oK31tThz/hkuEqTOEg6k5vkSP7SFOFmFHLjYEBpJ50uj2nA269Cl6pi6F n0Z3/v2Ma5+MhofjnD44ga7+XqddNv2ZzwfdmA3NoQi1tQJWYPKzkNkXnlxnhOIejJFH 4yV2qELohN3oevubx4HjdXiDS+JBnRHCaNWvUy8OVJc253jrOKFeVyu6yF4mo1IhFcKw deqQ== 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=l/ecNPoSshc7Qz6TLx60VAHeja18HDfrFu+0vDvi0k4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Ae/nF45CiR1fg2TBOfg/qzPyidYjmJUqDAKkjAqtp6yxdCKAb6GH1goxgQUt8f8Q1f 4c2avSgXfdA/N1KJ7JCsHfvPQe1j9SNvlzMxGqU+HS6Kukt7K1nIsJHrCzcJSIJZsGsv GDLB/cj8Bn9cOT3GbC986ul63hqZT18ZnFgm4++R4C+N9QWzhQRt82suCblXs759bID5 McuNOW+RpG5jy521fPkUF5KHq6Uo4Mg4Ts+Tr+6kfougv3Tlm2v5JRziQPK1nczp32Ye DvKrL0zL0eTMfw5R2z7d4ZOH2CFTPeeW6ZannXQKtVvbJxElf9ykInM1GAcL/u/9jGFT SJwQ==; 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="T7fFMeq/"; 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 38308e7fff4ca-2f3b76eb0b3si21359881fa.295.2024.08.18.13.14.30; Sun, 18 Aug 2024 13:14:31 -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="T7fFMeq/"; 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 744F268DDEF; Sun, 18 Aug 2024 23:13:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 041D468DDD9 for ; Sun, 18 Aug 2024 23:13:37 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-371b97cfd6fso480327f8f.2 for ; Sun, 18 Aug 2024 13:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012016; x=1724616816; 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=TYiv5X76ggupCD0RSBLFPQyBLhv2Ai4JDKJoyC1abo0=; b=T7fFMeq/jMoQycpdCH8OkW0Un2hwRErJFAL8MuGKdQV3lLMuh8KxNh9UlJZ5LHbvoj euPW3JgDHkgZ0Q0TWV4G7+BOcQ1hP1sEx61cmeHRxBVz90rdKm1BfDZBPGSoNOq8KLhl BfoqBCFZWsRibVfgbGkUA2kzURFxmXFSVSZzelbD1lf2KWYvM4TtmMwAJzene5viDhxD IkmnjmREeopSrLmCNsRMgc4WSmrwQgYGHsVbYy4cFS6TFw70pWi1PKd4v00I5xLyQGgg BxK73bnAqkEFEfaQo0stXNPzdiSGq2tDzcbV6XKyKGGt1DBcrkr1Eb45FJ1lsFUucUEo OJJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012016; x=1724616816; 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=TYiv5X76ggupCD0RSBLFPQyBLhv2Ai4JDKJoyC1abo0=; b=KWqE+S4e23iSRreXq9mmA8LBe/6VaDEaQVf4tKjk842GqrIGPJDGrZjwRq82IPcgJf sZgrYwWUe1163Y5Z0+woIKcYOi9P57XdYHfXmL9cr34xpO1EUl0Nk4/tTinXWlviGCZp R85oL9FlwZNzAgLqSH7pxaf5G+S+XfCukMQyClfo8674LIk6o/RWE27sewtgXkmoD/Kd T18BgL3NlCvScXnE+ESWbei+qfrXwjfDPA7I4sEAvGLvebLMG8VbUvsqcRsV+jW3WqG9 6oqI1HdXBDOcWgxL+NdHjY7gaKrBP4eU49jcB9RYnGpNOzzZ/BCrfY7Xf/aau1L7ztC1 p0ug== X-Gm-Message-State: AOJu0YySxL2sv+QIRLv2TkjdcFNNLofJKuQciIL8mViL4ec5G/RHOtfs AYluF+SwDgWFiyzz+6ghkKXGI5LlfuVuuHx9kkdGPIQgAnx2HI2YmuW4s2ek X-Received: by 2002:a5d:54d1:0:b0:371:8bc9:1682 with SMTP id ffacd0b85a97d-3719465ff4cmr5099457f8f.33.1724012015935; Sun, 18 Aug 2024 13:13:35 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:35 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:25 +0200 Message-Id: <20240818201326.100492-6-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240818201326.100492-1-ramiro.polla@gmail.com> References: <20240818201326.100492-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] avcodec/x86/mpegvideoencdsp: speed up draw_edges_mmx by using memcpy() 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: 2Ds3plcAcenM The mmx memory copy code is not nearly as efficient as memcpy(), which would make draw_edges_mmx much slower than draw_edges_8_c. Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz: before after draw_edges_8_1724_4_mmx: 8697.2 8739.6 ( 1.00x) draw_edges_8_1724_8_mmx: 10439.0 10548.4 ( 0.99x) draw_edges_8_1724_16_mmx: 10687.5 10876.1 ( 0.98x) draw_edges_128_407_4_mmx: 4252.5 3562.4 ( 1.19x) draw_edges_128_407_8_mmx: 4561.7 3868.1 ( 1.18x) draw_edges_128_407_16_mmx: 5505.7 4533.4 ( 1.21x) draw_edges_1080_31_4_mmx: 1667.7 560.4 ( 2.98x) draw_edges_1080_31_8_mmx: 2804.5 1232.1 ( 2.28x) draw_edges_1080_31_16_mmx: 12478.5 3829.6 ( 3.26x) draw_edges_1920_4_4_mmx: 2596.2 812.4 ( 3.20x) draw_edges_1920_4_8_mmx: 8056.0 2964.4 ( 2.72x) draw_edges_1920_4_16_mmx: 24628.7 6387.9 ( 3.86x) --- libavcodec/x86/mpegvideoencdsp_init.c | 51 ++++++--------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c index 503548e668..c30fa91175 100644 --- a/libavcodec/x86/mpegvideoencdsp_init.c +++ b/libavcodec/x86/mpegvideoencdsp_init.c @@ -166,46 +166,17 @@ static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, "r" (ptr + wrap * height)); } - /* top and bottom (and hopefully also the corners) */ - if (sides & EDGE_TOP) { - for (i = 0; i < h; i += 4) { - ptr = buf - (i + 1) * wrap - w; - __asm__ volatile ( - "1: \n\t" - "movq (%1, %0), %%mm0 \n\t" - "movq %%mm0, (%0) \n\t" - "movq %%mm0, (%0, %2) \n\t" - "movq %%mm0, (%0, %2, 2) \n\t" - "movq %%mm0, (%0, %3) \n\t" - "add $8, %0 \n\t" - "cmp %4, %0 \n\t" - "jb 1b \n\t" - : "+r" (ptr) - : "r" ((x86_reg) buf - (x86_reg) ptr - w), - "r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3), - "r" (ptr + width + 2 * w)); - } - } - - if (sides & EDGE_BOTTOM) { - for (i = 0; i < h; i += 4) { - ptr = last_line + (i + 1) * wrap - w; - __asm__ volatile ( - "1: \n\t" - "movq (%1, %0), %%mm0 \n\t" - "movq %%mm0, (%0) \n\t" - "movq %%mm0, (%0, %2) \n\t" - "movq %%mm0, (%0, %2, 2) \n\t" - "movq %%mm0, (%0, %3) \n\t" - "add $8, %0 \n\t" - "cmp %4, %0 \n\t" - "jb 1b \n\t" - : "+r" (ptr) - : "r" ((x86_reg) last_line - (x86_reg) ptr - w), - "r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3), - "r" (ptr + width + 2 * w)); - } - } + /* top and bottom + corners */ + buf -= w; + last_line = buf + (height - 1) * wrap; + if (sides & EDGE_TOP) + for (i = 0; i < h; i++) + // top + memcpy(buf - (i + 1) * wrap, buf, width + w + w); + if (sides & EDGE_BOTTOM) + for (i = 0; i < h; i++) + // bottom + memcpy(last_line + (i + 1) * wrap, last_line, width + w + w); } #endif /* HAVE_INLINE_ASM */ From patchwork Sun Aug 18 20:13:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51076 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp1571746vqj; Sun, 18 Aug 2024 13:21:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX5PcX7OzOu72b4/5ehtLNuNvlE9PLaHhkSFOnCm1DkFd9Qf7aFHptOMRIRnTR8w4rhD6YB1pmusQmMbZWcAAPf@gmail.com X-Google-Smtp-Source: AGHT+IF9UqNuP/c4YYJDbNQvd9YnLJ8ZYxpMOl0TPlIcBELHhR4yhHIoDznePT9khk+NmYjQSijf X-Received: by 2002:a2e:be23:0:b0:2ef:2405:ff63 with SMTP id 38308e7fff4ca-2f3be5f8f47mr32492571fa.5.1724012480069; Sun, 18 Aug 2024 13:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724012480; cv=none; d=google.com; s=arc-20160816; b=U7oEI8XWL2TPgvXKX3WQRmMGSrLCtZk1cHeLnk1wAM10a3qDmKAg3LaHKK5SNBkSQE Pz9yh7Wp1xPBXLB7l/vuztlFXWZdYsR6CuQNQ3+dJEcDC1XQGjS/05Uc6aW3W0gugApy ZsxdFW9BPSwUonsTjsP/S8mBuRTgxo6yOzqN2fzWC7fAE+sSpNhUs2sxXQBZyaj+ekrK 45YAs0NFMyjgHXpJj7O9Pvd6cxCGNjzOoHaXmGrLseby8mATELve2/NAnW+64V56amce 5OKGQm/9Z0qzu39XWr870xSn7VNnw7HS8g11jQ5sM5QkTy3jYVbQ82qUwDJoyiz/wcrV 17Sg== 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=7mC924w6gCrph2sUntZLLxiHLFyH37a1TDbLdAVy+M0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=zrt8pHn6UJCttaKX4eR55t5AVF0CTNPewW2PmLyqPy3+SYhbKBQC1VzlZn704GUYLj UNXAeGL64A35ZXj43lIEnCVN0rHVci88JqSaO0sJr7YI2KSxSydkfMs8CkFFCGTnFyjI igU4JWgrZ0bhD6leg/ah8KWak6hqWixZJgeID4DJhHyNjgBtgHIeNOxAFb/kq5U4yWMX mNXpSD0OMitM2aGSuZzZOCTB+d1bQ0S8EWomtRO9blo7zJmB/JvypZHgdc4xGgSwkHVD VTlVCdHzIKFjTV1hrCU170dTuyvqnSQ9h5410xcYtfATQNsD3LN4i0hW4C2MbIZncDCB 6MjA==; 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="eziI/CpB"; 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-5bebc07e9besi4687330a12.327.2024.08.18.13.21.19; Sun, 18 Aug 2024 13:21: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="eziI/CpB"; 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 F169C68DDF1; Sun, 18 Aug 2024 23:13:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7EB2C68DD49 for ; Sun, 18 Aug 2024 23:13:38 +0300 (EEST) Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3718ca50fd7so2115881f8f.1 for ; Sun, 18 Aug 2024 13:13:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724012017; x=1724616817; 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=Y+GQ0nxGy8Ihca2+FNag42PssT3wDtn6wFSBlSVoWBs=; b=eziI/CpBJz9WLg+KodihgL5NnljSy9mo6KGJc+N2LJLWStIIl8nvj6eDHe0FDTCouO Nnn+nWjuj8hbDp70iZXN1b8O6CbgOuqfEXe3q3a2ePCi3duNt9D0r0iFeGB726eBHlh2 gcMhIXB64D683pAq7LBd0t0Y/752qpvVnYYrtek51kymC9f7QmAHrB93RTkDi+/Mg/4H OZ9GuRVHcubK25nbsHemlTlOPYktdw5W0y/8hdE/3yUigy6co4fj2qM7fLQ57QPgwc5m HEPbBYpTFa9rO8JCiyu51wkSBbyVVS9jzA1NXX2ARImxHjGOTCW8nZxv7FMC2zR5g5Yt Gy1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724012017; x=1724616817; 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=Y+GQ0nxGy8Ihca2+FNag42PssT3wDtn6wFSBlSVoWBs=; b=ra5m0WNatAV1SS83S9acONiXUbCSCybxlo684ORVft0cT3VsZ8vUZFqcTn2OSARorK peYV/4F8vHmQCuAfHVlDb9qbdnm25usVuTQxRVOhWAsuNQ1mFHt0ZWak07G3NKbn2C9g PhXDsWONt8BNofvPjKt+ZUoTxILCNKo9ZWQ8UNEi43xB0amY+lClLbaWAuDL+bA85Ort D6dx8SIYdIAMZ8dlLX1BkwPNnPvUqK//g0YrcQwK1ZOe+bFokYQXrqjoYoIvwAxum2fw sTtijopnvxEJASVg6Z34y4YhdW6BLNqHCJ4pdXA2Hf3IVaAS8qOaMT7sriPR5xY7RS65 M1kA== X-Gm-Message-State: AOJu0YwzQW45tIR+ScBFJ5nE2cdahu1RR7T7EGEaJ+z0m8GBpH5/AgO9 gw7Asb/iHEHUr++5V5MhMquC3EFKv4hpOhRcn8SQtr9upT+vFgqja4rHgLO2 X-Received: by 2002:a5d:4043:0:b0:371:8f26:67f1 with SMTP id ffacd0b85a97d-37194452a6dmr5132252f8f.33.1724012016975; Sun, 18 Aug 2024 13:13:36 -0700 (PDT) Received: from localhost.localdomain (205.66-130-109.adsl-dyn.isp.belgacom.be. [109.130.66.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c5bsm8739931f8f.80.2024.08.18.13.13.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 13:13:36 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2024 22:13:26 +0200 Message-Id: <20240818201326.100492-7-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240818201326.100492-1-ramiro.polla@gmail.com> References: <20240818201326.100492-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/7] avcodec/mpegvideoencdsp: speed up draw_edges_8_c by inlining it for all used edge widths 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: l62QMrKREWLg This commit also restricts w to 4, 8, or 16. Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz: before after draw_edges_8_1724_4_c: 45074.5 7144.7 ( 6.31x) draw_edges_8_1724_8_c: 41716.5 7216.0 ( 5.78x) draw_edges_8_1724_16_c: 45282.7 16026.2 ( 2.83x) draw_edges_128_407_4_c: 10863.2 4153.0 ( 2.62x) draw_edges_128_407_8_c: 10273.0 4392.7 ( 2.34x) draw_edges_128_407_16_c: 11606.0 4614.0 ( 2.52x) draw_edges_1080_31_4_c: 1238.5 971.7 ( 1.27x) draw_edges_1080_31_8_c: 1712.2 1035.2 ( 1.65x) draw_edges_1080_31_16_c: 4281.5 3774.7 ( 1.13x) draw_edges_1920_4_4_c: 920.5 731.0 ( 1.26x) draw_edges_1920_4_8_c: 2861.0 2749.5 ( 1.04x) draw_edges_1920_4_16_c: 6416.7 6334.5 ( 1.01x) --- libavcodec/mpegvideoencdsp.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c index a96f0b6436..89fde7edf0 100644 --- a/libavcodec/mpegvideoencdsp.c +++ b/libavcodec/mpegvideoencdsp.c @@ -114,19 +114,31 @@ static int pix_norm1_c(const uint8_t *pix, int line_size) return s; } +static av_always_inline void draw_edges_lr(uint8_t *ptr, int wrap, int width, int height, int w) +{ + for (int i = 0; i < height; i++) { + memset(ptr - w, ptr[0], w); + memset(ptr + width, ptr[width - 1], w); + ptr += wrap; + } +} + /* draw the edges of width 'w' of an image of size width, height */ // FIXME: Check that this is OK for MPEG-4 interlaced. static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides) { - uint8_t *ptr = buf, *last_line; + uint8_t *last_line; int i; /* left and right */ - for (i = 0; i < height; i++) { - memset(ptr - w, ptr[0], w); - memset(ptr + width, ptr[width - 1], w); - ptr += wrap; + if (w == 16) { + draw_edges_lr(buf, wrap, width, height, 16); + } else if (w == 8) { + draw_edges_lr(buf, wrap, width, height, 8); + } else { + av_assert1(w == 4); + draw_edges_lr(buf, wrap, width, height, 4); } /* top and bottom + corners */