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 662DD4C92A for ; Fri, 9 Aug 2024 11:27:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0BE8868DA54; Fri, 9 Aug 2024 14:26:35 +0300 (EEST) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 858DA68D9DB for ; Fri, 9 Aug 2024 14:26:27 +0300 (EEST) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4281c164408so14009885e9.1 for ; Fri, 09 Aug 2024 04:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723202786; x=1723807586; 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=U8nWZy3K/p0Qq7PZ3WCy2SeN+5Xl8S8ujD1ncRhYPaQ=; b=Iw/6AALTYA0CgOUiSyImU2Hhzwq4XfDr+Cnk6koh/45bH8qmD3eKt3Q1h0MWZCyuAZ 0lrpXv6+FTI/hI++PfqZsNIGUDIEErxChZ9Zo+MkSkd0erLmcTRQEktlerTMrDpa3s0q YVzgmNUNzMtwT7ZHxiaTLQ2LtDo7gS8BemfUhf7X8AoJCWXd8YSPxVTEN9jecSEDoWxF MLr9i/kKNEFnShUx5qfMZKCXslkE4LqAq75h/KYXxRGD9oY7oIgk+iU2fHrP8DoIqzvb z/j4ZVd+0t9hLY9P6Yosmzc3pPhyFHbIzTNz62Nyief8w1KscCdbFzyc68rdC4pv/kOB iHWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723202786; x=1723807586; 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=U8nWZy3K/p0Qq7PZ3WCy2SeN+5Xl8S8ujD1ncRhYPaQ=; b=vWU1M8bKf+wH8O0R5hOepWhTF+dQ+0Rzy7sPgZx8JYeHIXo/WDOkt6q9mo53QELdY4 xsjKLuadtTWS3VIgQecgM+mdoG8gsETySAlfVrF9jjKgTWdyovY8sCSBcvq5AxaXvyld s4Pi7IZvcz7F1oJkyn179x/5H9qhz6bbtasL084ZWBVB9NTaP9cuqWgo6dUT/hS39iAt pQcnY8r7igauBGfPabeHtZ2o7TlfyQvIUqLW8gDc44uGGvM8LkM7hwZ8r70uhavvf+k/ YZypd8ZDSKvGI/41OYGCXR5BLjgR7FUx+nK0CjeCY/+OuNcy/vyNEScvoB3jCe36py9a WwCg== X-Gm-Message-State: AOJu0YziirK/Hwp8bhOXVH2UFPqp077Q4TX5O2Mb9hgMZe4n69jJNMwc vW85gW22PQ3TrJ/2FQzPpTBOdmypkb1bV46nsRRUPbTvB4kGa1/e0cpIKkVe X-Google-Smtp-Source: AGHT+IEk6TxJSMJMKDrWHs+0R/eZTYwWvj30m/kxHnxUfR8HNql/XmfqHeX0RN1x4U0emm1zwhWyxw== X-Received: by 2002:a05:600c:4fc4:b0:428:1663:2c2e with SMTP id 5b1f17b1804b1-429c3a286b3mr9434135e9.17.1723202786259; Fri, 09 Aug 2024 04:26:26 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:6610:8700:a59e:a164:e144:7458]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d6c8sm72385685e9.9.2024.08.09.04.26.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 04:26:25 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Aug 2024 13:26:12 +0200 Message-Id: <20240809112612.107000-4-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240809112612.107000-1-ramiro.polla@gmail.com> References: <20240809112612.107000-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] swscale/aarch64: add nv24/nv42 to yuv420p unscaled converter 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: nv24_yuv420p_128_c: 423.0 nv24_yuv420p_128_neon: 115.7 nv24_yuv420p_1920_c: 5939.5 nv24_yuv420p_1920_neon: 1339.7 nv42_yuv420p_128_c: 423.2 nv42_yuv420p_128_neon: 115.7 nv42_yuv420p_1920_c: 5907.5 nv42_yuv420p_1920_neon: 1342.5 --- libswscale/aarch64/Makefile | 1 + libswscale/aarch64/swscale_unscaled.c | 30 +++++++++ libswscale/aarch64/swscale_unscaled_neon.S | 75 ++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 libswscale/aarch64/swscale_unscaled_neon.S diff --git a/libswscale/aarch64/Makefile b/libswscale/aarch64/Makefile index 37ad960619..1de8c9c0d6 100644 --- a/libswscale/aarch64/Makefile +++ b/libswscale/aarch64/Makefile @@ -7,4 +7,5 @@ NEON-OBJS += aarch64/hscale.o \ aarch64/output.o \ aarch64/range_convert_neon.o \ aarch64/rgb2rgb_neon.o \ + aarch64/swscale_unscaled_neon.o \ aarch64/yuv2rgb_neon.o \ diff --git a/libswscale/aarch64/swscale_unscaled.c b/libswscale/aarch64/swscale_unscaled.c index b3093bbc9d..87bb011709 100644 --- a/libswscale/aarch64/swscale_unscaled.c +++ b/libswscale/aarch64/swscale_unscaled.c @@ -83,6 +83,31 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *src[], c->yuv2rgb_y_coeff); \ } \ +void ff_nv24_to_yuv420p_chroma_neon(uint8_t *dst1, int dstStride1, + uint8_t *dst2, int dstStride2, + const uint8_t *src, int srcStride, + int w, int h); + +static int nv24_to_yuv420p_neon_wrapper(SwsContext *c, const uint8_t *src[], + int srcStride[], int srcSliceY, int srcSliceH, + uint8_t *dst[], int dstStride[]) +{ + uint8_t *dst1 = dst[1] + dstStride[1] * srcSliceY / 2; + uint8_t *dst2 = dst[2] + dstStride[2] * srcSliceY / 2; + + ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW, + dst[0], dstStride[0]); + + if (c->srcFormat == AV_PIX_FMT_NV24) + ff_nv24_to_yuv420p_chroma_neon(dst1, dstStride[1], dst2, dstStride[2], + src[1], srcStride[1], c->srcW / 2, srcSliceH); + else + ff_nv24_to_yuv420p_chroma_neon(dst2, dstStride[2], dst1, dstStride[1], + src[1], srcStride[1], c->srcW / 2, srcSliceH); + + return srcSliceH; +} + #define DECLARE_FF_NVX_TO_ALL_RGBX_FUNCS(nvx) \ DECLARE_FF_NVX_TO_RGBX_FUNCS(nvx, argb) \ DECLARE_FF_NVX_TO_RGBX_FUNCS(nvx, rgba) \ @@ -119,6 +144,11 @@ static void get_unscaled_swscale_neon(SwsContext *c) { SET_FF_NVX_TO_ALL_RGBX_FUNC(nv21, NV21, accurate_rnd); SET_FF_NVX_TO_ALL_RGBX_FUNC(yuv420p, YUV420P, accurate_rnd); SET_FF_NVX_TO_ALL_RGBX_FUNC(yuv422p, YUV422P, accurate_rnd); + + if (c->dstFormat == AV_PIX_FMT_YUV420P && + (c->srcFormat == AV_PIX_FMT_NV24 || c->srcFormat == AV_PIX_FMT_NV42) && + !(c->srcH & 1) && !(c->srcW & 15) && !accurate_rnd) + c->convert_unscaled = nv24_to_yuv420p_neon_wrapper; } void ff_get_unscaled_swscale_aarch64(SwsContext *c) diff --git a/libswscale/aarch64/swscale_unscaled_neon.S b/libswscale/aarch64/swscale_unscaled_neon.S new file mode 100644 index 0000000000..a206fda41f --- /dev/null +++ b/libswscale/aarch64/swscale_unscaled_neon.S @@ -0,0 +1,75 @@ +/* + * 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_nv24_to_yuv420p_chroma_neon, export=1 +// x0 uint8_t *dst1 +// x1 int dstStride1 +// x2 uint8_t *dst2 +// x3 int dstStride2 +// x4 const uint8_t *src +// x5 int srcStride +// w6 int w +// w7 int h + + uxtw x1, w1 + uxtw x3, w3 + uxtw x5, w5 + + add x9, x4, x5 // x9 = src + srcStride + lsl w5, w5, #1 // srcStride *= 2 + +1: + mov w10, w6 // w10 = w + mov x11, x4 // x11 = src1 (line 1) + mov x12, x9 // x12 = src2 (line 2) + mov x13, x0 // x13 = dst1 (dstU) + mov x14, x2 // x14 = dst2 (dstV) + +2: + ld2 { v0.16b, v1.16b }, [x11], #32 // v0 = U1, v1 = V1 + ld2 { v2.16b, v3.16b }, [x12], #32 // v2 = U2, v3 = V2 + + uaddlp v0.8h, v0.16b // pairwise add U1 into v0 + uaddlp v1.8h, v1.16b // pairwise add V1 into v1 + uadalp v0.8h, v2.16b // pairwise add U2, accumulate into v0 + uadalp v1.8h, v3.16b // pairwise add V2, accumulate into v1 + + shrn v0.8b, v0.8h, #2 // divide by 4 + shrn v1.8b, v1.8h, #2 // divide by 4 + + st1 { v0.8b }, [x13], #8 // store U into dst1 + st1 { v1.8b }, [x14], #8 // store V into dst2 + + subs w10, w10, #8 + b.gt 2b + + // next row + add x4, x4, x5 // src1 += srcStride * 2 + add x9, x9, x5 // src2 += srcStride * 2 + add x0, x0, x1 // dst1 += dstStride1 + add x2, x2, x3 // dst2 += dstStride2 + + subs w7, w7, #2 + b.gt 1b + + ret +endfunc -- 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".