From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 7EF4A4B3AE for ; Thu, 22 Jan 2026 10:18:28 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'stkHGZNtckOXEFFn+DACVPUF9uuLc+0HmGLSFOMdA0s=', expected b'wUC0s38tumETb/sB+/nh4vh6rjb/AJWmhHqRhcBHyio=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1769077098; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=stkHGZNtckOXEFFn+DACVPUF9uuLc+0HmGLSFOMdA0s=; b=zCF6TxGRK5zZ99DxfYI3/o1W6foBl37MH3flJIaT4UBgiLLxU2wtQ57guLEPI5Jx0t7Ia 9LTF10NZm4qi7HgpRr0oji/bNxKXtSPtktsz30w0jALAi+j7hIipuilo7q6faAvXQ1DNnPl Il7U65sUUx3PEtXFxAr3eqY0jIq0Fc7fJkGUaDCZ58sIcrkAH+ZOvsNj0P8yJRigyYs6Z9L 6uxIxU0Z5Pt4VyZ8hOQnui4nmqeiCLsammzGiWHbsmz6ydVgSucmkmYwYWWn7UGiQK3aE3/ 3crzYezn29P2eDtiR9qgwsS6zyx2Og9qTADSxOl0kZvq8l+UaWZrUH3ZjdHg== Received: from [172.20.0.4] (unknown [172.20.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8D587690FC7; Thu, 22 Jan 2026 12:18:18 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1769077081; b=MtbJPXlYMFRGM/8iBaPEGEnTBE4VXYIWdyeRf89KiAyjVSLVTNpM0OGl/fTLBNDSNwUZr QnPYmiVth+ivziMIVnQD7qCNLsN3HRiYSffcrBne6454v2AgdtOGN6YlpifuabPZfkSZJlc BIgarlvEMusGWBLvIKqQHXCVWsR19Wqxt/HX60uHppic4RT7aP26shzffy+9hfcnbCs/yx6 WvkzndpYIdJ1bILB2zgch4D6ruyYJf0G8AmJPG5CsofU0torU8pl4RQxdEi2wklidJ5XgpF XakYwkKjLBFQBZlh7TT70BuvxiWZRSxlzSQcCwAao3LxvIKb4X2EPe+Pn23A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1769077081; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=YGdz0wMciE/KZ+7T08j1JAVeL+vsJ055DUEN0MAWfAw=; b=EKYXtU6QQcqIgyN0m+LdDG/r3gosfcrR0kH2RFOndGl0mc/aHaTiiwpOvCwqXFZxUR6yq 0B/xOedpju6s3o51IK4rct/LpFIi11MOCd6TExbQS9TjnGh7l01gyK1kCfU77PKaG8U7TXv RqoR4WVzCrMZvztDmQcJtPHwYBZREG2cfgDtr4+V5u1PnCOh11zfcTB8RFvGqGAVvQfg5hh JqXq/GbII9QdlVmfGLVwbMmg2unlrzjNiCVexPENjh/aFygGrpnV+ACu+0qFkchmwEusAEk GtO81sMWzvPksF1kaJz7TVjnBxHKqNh19tMA/SV6M0OCMtkGJJnWa5BGtlQg== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1769077072; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=wUC0s38tumETb/sB+/nh4vh6rjb/AJWmhHqRhcBHyio=; b=MYmPIBspuQnlPNkRSz4hD1u5gahCbMBrTNpF+YV8ZBTfQpfXdyw6ObKpv0a58mzQJR9XY eCqPDJ4MkroiuP7W+3Bd5G6CIfKazoHuOMh5zkZ0PeRV/ECxCSs8ibEu78BHRSbKWZgAgJn u1eeLzxb5jWwI5GhvTmqgfPnNtAp+qCAgk+7cqiCYLENSSygvbO0YteJrJcRDz7xuMm0KcR 8PbuJ1G/iM4fOWGXlNcPwYwS0SlaF6Yxvlt8IK1gjSD9q5OBYDHlb6fZqK7PyEkoL6Ld+57 cb169UoX9LKp4V8aQWJmdeK6UomSjTZ5ptarusjSkklAyNVcco0tnOpvDPpA== Received: from 69dab402ede7 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id AECD0690F9D for ; Thu, 22 Jan 2026 12:17:52 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Jan 2026 10:17:52 -0000 Message-ID: <176907707282.25.5047820092317262293@4457048688e7> Message-ID-Hash: ST3AXGA7C7I6GMUXTEHEQNZD6PUKWZ4Y X-Message-ID-Hash: ST3AXGA7C7I6GMUXTEHEQNZD6PUKWZ4Y X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avcodec/aarch64: add NEON optimization for draw_edges (PR #21545) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: chenmingbiao via ffmpeg-devel Cc: chenmingbiao Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21545 opened by chenmingbiao URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21545 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21545.patch Performance improvement for draw_edges function using NEON instructions. Optimized for edge widths 4, 8, and 16. Benchmark results (AArch64): draw_edges_8_1724_4_c: 851.4 draw_edges_8_1724_4_neon: 824.7 (1.03x) draw_edges_8_1724_16_c: 1620.9 draw_edges_8_1724_16_neon: 1049.9 (1.54x) draw_edges_1920_4_16_c: 849.0 draw_edges_1920_4_16_neon: 571.1 (1.49x) >>From cf54f4e51105d5b89f9c7782e3c457b26621d113 Mon Sep 17 00:00:00 2001 From: mbillchan Date: Wed, 21 Jan 2026 17:28:24 +0800 Subject: [PATCH] avcodec/aarch64: add NEON optimization for draw_edges Performance improvement for draw_edges function using NEON instructions. Optimized for edge widths 4, 8, and 16. Benchmark results (AArch64): draw_edges_8_1724_4_c: 851.4 draw_edges_8_1724_4_neon: 824.7 (1.03x) draw_edges_8_1724_16_c: 1620.9 draw_edges_8_1724_16_neon: 1049.9 (1.54x) draw_edges_1920_4_16_c: 849.0 draw_edges_1920_4_16_neon: 571.1 (1.49x) --- libavcodec/aarch64/mpegvideoencdsp_init.c | 3 + libavcodec/aarch64/mpegvideoencdsp_neon.S | 157 ++++++++++++++++++++++ tests/checkasm/mpegvideoencdsp.c | 5 + 3 files changed, 165 insertions(+) diff --git a/libavcodec/aarch64/mpegvideoencdsp_init.c b/libavcodec/aarch64/mpegvideoencdsp_init.c index 0402ac9e82..8363b18f48 100644 --- a/libavcodec/aarch64/mpegvideoencdsp_init.c +++ b/libavcodec/aarch64/mpegvideoencdsp_init.c @@ -26,6 +26,8 @@ int ff_pix_sum16_neon(const uint8_t *pix, ptrdiff_t line_size); int ff_pix_norm1_neon(const uint8_t *pix, ptrdiff_t line_size); +void ff_draw_edges_neon(uint8_t *buf, ptrdiff_t wrap, int width, int height, + int w, int h, int sides); #if HAVE_DOTPROD int ff_pix_norm1_neon_dotprod(const uint8_t *pix, ptrdiff_t line_size); @@ -39,6 +41,7 @@ av_cold void ff_mpegvideoencdsp_init_aarch64(MpegvideoEncDSPContext *c, if (have_neon(cpu_flags)) { c->pix_sum = ff_pix_sum16_neon; c->pix_norm1 = ff_pix_norm1_neon; + c->draw_edges = ff_draw_edges_neon; } #if HAVE_DOTPROD diff --git a/libavcodec/aarch64/mpegvideoencdsp_neon.S b/libavcodec/aarch64/mpegvideoencdsp_neon.S index 8175d8975e..29a6104241 100644 --- a/libavcodec/aarch64/mpegvideoencdsp_neon.S +++ b/libavcodec/aarch64/mpegvideoencdsp_neon.S @@ -91,3 +91,160 @@ endfunc DISABLE_DOTPROD #endif + +function ff_draw_edges_neon, export=1 + mov x9, x0 + mov x10, x1 + uxtw x11, w2 + uxtw x12, w3 + uxtw x13, w4 + uxtw x14, w5 + uxtw x15, w6 + mov x0, x9 + mov x1, x12 + + cmp w13, #16 + b.eq 1f + cmp w13, #8 + b.eq 2f + b 3f + +1: + ldrb w2, [x0] + dup v0.16b, w2 + sub x3, x0, #16 + st1 {v0.16b}, [x3] + + add x3, x0, x11 + sub x4, x3, #1 + ldrb w2, [x4] + dup v1.16b, w2 + st1 {v1.16b}, [x3] + + add x0, x0, x10 + subs x1, x1, #1 + b.ne 1b + b 4f + +2: + ldrb w2, [x0] + dup v0.8b, w2 + sub x3, x0, #8 + st1 {v0.8b}, [x3] + + add x3, x0, x11 + sub x4, x3, #1 + ldrb w2, [x4] + dup v1.8b, w2 + st1 {v1.8b}, [x3] + + add x0, x0, x10 + subs x1, x1, #1 + b.ne 2b + b 4f + +3: + ldrb w2, [x0] + dup v0.8b, w2 + sub x3, x0, #4 + st1 {v0.s}[0], [x3] + + add x3, x0, x11 + sub x4, x3, #1 + ldrb w2, [x4] + dup v1.8b, w2 + st1 {v1.s}[0], [x3] + + add x0, x0, x10 + subs x1, x1, #1 + b.ne 3b + +4: + sub x9, x9, x13 + tbnz w15, #0, 5f + b 6f + +5: + add x2, x11, x13, lsl #1 + mov x3, x14 + mov x4, x9 + sub x5, x9, x10 + +7: + mov x6, x5 + mov x7, x4 + mov x8, x2 + +8: + cmp x8, #64 + b.lt 17f + ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x7], #64 + st1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x6], #64 + sub x8, x8, #64 + b 8b + +17: + cmp x8, #16 + b.lt 9f + ld1 {v0.16b}, [x7], #16 + st1 {v0.16b}, [x6], #16 + sub x8, x8, #16 + b 17b +9: + cbz x8, 10f + ldrb w16, [x7], #1 + strb w16, [x6], #1 + sub x8, x8, #1 + b 9b +10: + sub x5, x5, x10 + subs x3, x3, #1 + b.ne 7b + +6: + tbnz w15, #1, 11f + b 12f + +11: + sub x3, x12, #1 + mul x3, x3, x10 + add x4, x9, x3 + add x5, x4, x10 + + add x2, x11, x13, lsl #1 + mov x3, x14 + +13: + mov x6, x5 + mov x7, x4 + mov x8, x2 + +14: + cmp x8, #64 + b.lt 18f + ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x7], #64 + st1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x6], #64 + sub x8, x8, #64 + b 14b + +18: + cmp x8, #16 + b.lt 15f + ld1 {v0.16b}, [x7], #16 + st1 {v0.16b}, [x6], #16 + sub x8, x8, #16 + b 18b +15: + cbz x8, 16f + ldrb w16, [x7], #1 + strb w16, [x6], #1 + sub x8, x8, #1 + b 15b +16: + add x5, x5, x10 + subs x3, x3, #1 + b.ne 13b + +12: + ret +endfunc diff --git a/tests/checkasm/mpegvideoencdsp.c b/tests/checkasm/mpegvideoencdsp.c index 955cd9f5b7..fdaed08e86 100644 --- a/tests/checkasm/mpegvideoencdsp.c +++ b/tests/checkasm/mpegvideoencdsp.c @@ -147,8 +147,13 @@ static void check_draw_edges(MpegvideoEncDSPContext *c) LOCAL_ALIGNED_16(uint8_t, buf0, [BUFSIZE]); LOCAL_ALIGNED_16(uint8_t, buf1, [BUFSIZE]); +#if ARCH_X86 declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *buf, ptrdiff_t wrap, int width, int height, int w, int h, int sides); +#else + declare_func(void, uint8_t *buf, ptrdiff_t wrap, int width, int height, + int w, int h, int sides); +#endif for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { int input_size = input_sizes[isi]; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org