From patchwork Wed Jun 5 16:36:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49585 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d792:0:b0:460:55fa:d5ed with SMTP id db18csp516224vqb; Wed, 5 Jun 2024 09:36:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVwAWgSUwVLCaq+6Ax/Vy4C6g6Q34xs/8fFRSkihKQ4oFyhhmWo3YlzADkETswwMdGR0IE9X5h2d68sqw1agIjqudj4qrKAymQpLQ== X-Google-Smtp-Source: AGHT+IF6l/jm9xgNT9zWyozlJXMcxGap7kM5PqnxWKOoovNTFE/rTH1JGZbhUqZX1Z3gCbDk7f03 X-Received: by 2002:a50:cc9c:0:b0:57a:1924:a9a1 with SMTP id 4fb4d7f45d1cf-57a8b6758bamr2055259a12.1.1717605409680; Wed, 05 Jun 2024 09:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717605409; cv=none; d=google.com; s=arc-20160816; b=OU0I8n8WWmu+7HO5TUduPKOoITv1Dh9aVLonNk/4G7pz5465jUCzTkQb55orE++Cmo xeA7TyDBOx63wdlfnx3oGkcgJ0pYApn4DT+dZ4TClXjVpdOJGPi6DLn1ZAblGRyTNa5y jA0v4N3mOa7FhSzzuqmR4vIWeVabq8dExeldrNJNQ4YtRAVpF2W6PaQ2LLCRW1pYjgcp KcncmaRFAm1qhfd2d4HmYW83AxP6LTFjbCSVc03n0fB4TEqDxn8bQYk1pVj8f4KMpMl3 l5pzgIg7LYrcxJaaiM0XxbqJqbRPmH9xst08sxBpYDNx3RHV3uqF6v4x5bNefm7URMI0 6k7A== 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 :delivered-to; bh=FKVi69i/EYEcXvM+RUg8lRVJvaNo3M5FiWLiXxddi0o=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BmXkjsptV6/3bDEzVuzx+eeipSjc6K5Ud4HmFu42RiGQCZRt2WDwKZwzWo7RsHcqJ5 NUgkfSvWW70s71JNV9zWFqxziCg8dT4aorg+dBKl73AkLIWg2roUhDkByoFpWOQDoa44 76dDTR5PBXy+0tp9qJxLkyYuA6/CACvQD3FMXfOFLiS85N6+ZzDzRLZB8hxzoeN5QIjV fGqmhWOKlnPwqguu/ioLo//BKwkzNewUAseqOP/uSGRb7pfkEPRw+igZ7G0Wmwb5Qi9X s4fh3jyhfYgd3Z3wVe0lMxHeTKXqHvtAvEL6sze3mXg/KUPvPU7dwNjBfIBGp+/azy0x G5gA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57a31c75710si6237545a12.347.2024.06.05.09.36.49; Wed, 05 Jun 2024 09:36:49 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C964168D6F0; Wed, 5 Jun 2024 19:36:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A1AEC68D612 for ; Wed, 5 Jun 2024 19:36:39 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 1EF63C0143 for ; Wed, 5 Jun 2024 19:36:39 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jun 2024 19:36:35 +0300 Message-ID: <20240605163638.10586-1-remi@remlab.net> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCHv3 1/3] sws/input: R-V V rgb24ToY & bgr24ToY 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: 9i9pS7oZHAzJ T-Head C908: rgb24_to_y_8_c: 2.0 rgb24_to_y_8_rvv_i32: 2.7 rgb24_to_y_128_c: 26.2 rgb24_to_y_128_rvv_i32: 9.2 rgb24_to_y_1080_c: 219.5 rgb24_to_y_1080_rvv_i32: 76.2 rgb24_to_y_1280_c: 276.2 rgb24_to_y_1280_rvv_i32: 89.7 rgb24_to_y_1920_c: 389.7 rgb24_to_y_1920_rvv_i32: 134.2 SpacemiT X60: rgb24_to_y_8_c: 1.7 rgb24_to_y_8_rvv_i32: 2.2 rgb24_to_y_128_c: 23.2 rgb24_to_y_128_rvv_i32: 4.2 rgb24_to_y_1080_c: 195.0 rgb24_to_y_1080_rvv_i32: 33.7 rgb24_to_y_1280_c: 231.0 rgb24_to_y_1280_rvv_i32: 40.0 rgb24_to_y_1920_c: 346.2 rgb24_to_y_1920_rvv_i32: 59.7 --- libswscale/riscv/Makefile | 6 ++-- libswscale/riscv/input.S | 55 +++++++++++++++++++++++++++++++++++ libswscale/riscv/swscale.c | 46 +++++++++++++++++++++++++++++ libswscale/swscale.c | 2 ++ libswscale/swscale_internal.h | 1 + 5 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 libswscale/riscv/input.S create mode 100644 libswscale/riscv/swscale.c diff --git a/libswscale/riscv/Makefile b/libswscale/riscv/Makefile index 48afaf62aa..d1b0eae367 100644 --- a/libswscale/riscv/Makefile +++ b/libswscale/riscv/Makefile @@ -1,3 +1,5 @@ -OBJS += riscv/rgb2rgb.o +OBJS += riscv/rgb2rgb.o \ + riscv/swscale.o RV-OBJS += riscv/rgb2rgb_rvb.o -RVV-OBJS += riscv/rgb2rgb_rvv.o +RVV-OBJS += riscv/input.o \ + riscv/rgb2rgb_rvv.o diff --git a/libswscale/riscv/input.S b/libswscale/riscv/input.S new file mode 100644 index 0000000000..323f650bc9 --- /dev/null +++ b/libswscale/riscv/input.S @@ -0,0 +1,55 @@ +/* + * Copyright © 2024 Rémi Denis-Courmont. + * + * 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/riscv/asm.S" + +func ff_bgr24ToY_rvv, zve32x + lw t1, 8(a5) # BY + lw t3, 0(a5) # RY + j 1f +endfunc + +func ff_rgb24ToY_rvv, zve32x + lw t1, 0(a5) # RY + lw t3, 8(a5) # BY +1: + lw t2, 4(a5) # GY + li t4, (32 << (15 - 1)) + (1 << (15 - 7)) +2: + vsetvli t0, a4, e32, m8, ta, ma + vlseg3e8.v v0, (a1) + sub a4, a4, t0 + vzext.vf4 v8, v0 + sh1add t5, t0, t0 # t1 = 3 * t0 + vzext.vf4 v16, v2 + vzext.vf4 v24, v4 + add a1, t5, a1 + vmul.vx v8, v8, t1 + vmacc.vx v8, t2, v16 + vmacc.vx v8, t3, v24 + vadd.vx v8, v8, t4 + vsetvli zero, zero, e16, m4, ta, ma + vnsra.wi v0, v8, 15 - 6 + vse16.v v0, (a0) + sh1add a0, t0, a0 + bnez a4, 2b + + ret +endfunc diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c new file mode 100644 index 0000000000..187b3fce58 --- /dev/null +++ b/libswscale/riscv/swscale.c @@ -0,0 +1,46 @@ +/* + * 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 "config.h" +#include "libavutil/attributes.h" +#include "libavutil/riscv/cpu.h" +#include "libswscale/swscale_internal.h" + +void ff_bgr24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, + const uint8_t *, int width, uint32_t *coeffs, void *); +void ff_rgb24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, + const uint8_t *, int width, uint32_t *coeffs, void *); + +av_cold void ff_sws_init_swscale_riscv(SwsContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) { + switch (c->srcFormat) { + case AV_PIX_FMT_BGR24: + c->lumToYV12 = ff_bgr24ToY_rvv; + break; + + case AV_PIX_FMT_RGB24: + c->lumToYV12 = ff_rgb24ToY_rvv; + break; + } + } +#endif +} diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2795429b6c..9736734881 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -602,6 +602,8 @@ void ff_sws_init_scale(SwsContext *c) ff_sws_init_swscale_arm(c); #elif ARCH_LOONGARCH64 ff_sws_init_swscale_loongarch(c); +#elif ARCH_RISCV + ff_sws_init_swscale_riscv(c); #endif } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index d4b0c3cee2..5007dd422f 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -988,6 +988,7 @@ void ff_sws_init_swscale_x86(SwsContext *c); void ff_sws_init_swscale_aarch64(SwsContext *c); void ff_sws_init_swscale_arm(SwsContext *c); void ff_sws_init_swscale_loongarch(SwsContext *c); +void ff_sws_init_swscale_riscv(SwsContext *c); void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth, const uint8_t *src, int srcW, int xInc); From patchwork Wed Jun 5 16:36:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49586 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d792:0:b0:460:55fa:d5ed with SMTP id db18csp516343vqb; Wed, 5 Jun 2024 09:37:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVikMTrzwos0OdjhNl8uw90jM81/kxbR9Q5qoUVgC0kuMyadtkrbPI9yW7RFNjEsoF3knY7OfNyWdJWm/VkCsRvrqI5Cc2HpmD1Bg== X-Google-Smtp-Source: AGHT+IFlQj+Sh96C8MgzHuKUyxn0RF023MHjeOSluW1dmI+172q9Tt81Fz3rsiADRXupM/rWnaMT X-Received: by 2002:a05:651c:b2b:b0:2e9:61c7:cad3 with SMTP id 38308e7fff4ca-2eac79c8aefmr28539671fa.25.1717605419810; Wed, 05 Jun 2024 09:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717605419; cv=none; d=google.com; s=arc-20160816; b=B2dZa12wWV/BmbzZIMvxDFNSKUe+RvJhrWp9q3Ukhix5HYaygte23uynCYD3w2pLq6 uhHZieNtLjbuMgZSx6bOwj5WAq7vX0HqV8uGA38IKfmKC/HQ0H7elVLshQdtOM/5zMmo ylbgJYhwU3TL3aPrIUpL6A6c9Hr6av12qqsM17b5zW0Jc9/oRGIqSZjiaBvnkOutkP6n /BWY4FDACWPol2p0/OC6UOd/c0kcUM7X0NLnAH+UhNxCH7FFjr4enD1N7FCHke3GxMA5 M9n9dYRdFfSdMv0G24C/xZIuUYB38Rs6iwfSdfm9Xe6y8+67itiC332DVLpkOq9RAhBA anKA== 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:delivered-to; bh=hE7Z9ZuGh+IKfx4FcSqIDkph1IZCpW9i8+RfMZ1J8fI=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=x0tlEWxbxr7uW+fL23lmO0PW+l7YUHukTLVV1GtjWlrBbxQ4/5X+PgctJQ8ZGpOMZI 70B23h5b66TPtcwE2epfD0vSrcPnU3ajtr0hRh4jsA31juPsBZ3G0fVRK7+tL2ZHZHO8 MOa17c2P3gr9DGHvx+yWbh8r4U2q4m+U1dVjAvBPOVlPJBMhD/xF9XokHhIpxJux92S5 vqF+llZ3btqz/521oBn0fIZzuR54PuUaPw/BTSswgFkpv9pZuK0NCS/MumSCZhtxf+se DEQDuKziA3jjn42UvRLDeXGTzj5OQdHwynYE6aOx0Z5rwH7FalBB9LnqGuGZl+4dXz8+ fQyw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2ea91d4d838si37593081fa.579.2024.06.05.09.36.59; Wed, 05 Jun 2024 09:36:59 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EFDFD68D6FF; Wed, 5 Jun 2024 19:36:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B4BA768D67D for ; Wed, 5 Jun 2024 19:36:39 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 527F2C02EF for ; Wed, 5 Jun 2024 19:36:39 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jun 2024 19:36:36 +0300 Message-ID: <20240605163638.10586-2-remi@remlab.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240605163638.10586-1-remi@remlab.net> References: <20240605163638.10586-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] sws/input: R-V V rgb24ToUV and bgr24ToUV 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: xsVN++OS4ouj T-Head C908: rgb24_to_uv_8_c: 2.7 rgb24_to_uv_8_rvv_i32: 3.2 rgb24_to_uv_128_c: 41.0 rgb24_to_uv_128_rvv_i32: 12.7 rgb24_to_uv_1080_c: 342.5 rgb24_to_uv_1080_rvv_i32: 105.7 rgb24_to_uv_1280_c: 406.0 rgb24_to_uv_1280_rvv_i32: 124.2 rgb24_to_uv_1920_c: 626.0 rgb24_to_uv_1920_rvv_i32: 186.0 SpacemiT X60: rgb24_to_uv_8_c: 2.5 rgb24_to_uv_8_rvv_i32: 3.0 rgb24_to_uv_128_c: 36.5 rgb24_to_uv_128_rvv_i32: 5.7 rgb24_to_uv_1080_c: 304.2 rgb24_to_uv_1080_rvv_i32: 49.0 rgb24_to_uv_1280_c: 360.5 rgb24_to_uv_1280_rvv_i32: 57.5 rgb24_to_uv_1920_c: 540.7 rgb24_to_uv_1920_rvv_i32: 86.2 --- libswscale/riscv/input.S | 46 ++++++++++++++++++++++++++++++++++++++ libswscale/riscv/swscale.c | 8 +++++++ 2 files changed, 54 insertions(+) diff --git a/libswscale/riscv/input.S b/libswscale/riscv/input.S index 323f650bc9..3392f189ca 100644 --- a/libswscale/riscv/input.S +++ b/libswscale/riscv/input.S @@ -53,3 +53,49 @@ func ff_rgb24ToY_rvv, zve32x ret endfunc + +func ff_bgr24ToUV_rvv, zve32x + lw t1, 20(a6) # BU + lw t4, 32(a6) # BV + lw t3, 12(a6) # RU + lw t6, 24(a6) # RV + j 1f +endfunc + +func ff_rgb24ToUV_rvv, zve32x + lw t1, 12(a6) # RU + lw t4, 24(a6) # RV + lw t3, 20(a6) # BU + lw t6, 32(a6) # BV +1: + lw t2, 16(a6) # GU + lw t5, 28(a6) # GV + li a7, (256 << (15 - 1)) + (1 << (15 - 7)) +2: + vsetvli t0, a5, e32, m8, ta, ma + vlseg3e8.v v0, (a3) + sub a5, a5, t0 + vzext.vf4 v16, v0 + sh1add a6, t0, t0 + vzext.vf4 v24, v2 + vmul.vx v8, v16, t1 + add a3, a6, a3 + vmul.vx v16, v16, t4 + vmacc.vx v8, t2, v24 + vmacc.vx v16, t5, v24 + vzext.vf4 v24, v4 + vadd.vx v8, v8, a7 + vadd.vx v16, v16, a7 + vmacc.vx v8, t3, v24 + vmacc.vx v16, t6, v24 + vsetvli zero, zero, e16, m4, ta, ma + vnsra.wi v0, v8, 15 - 6 + vnsra.wi v4, v16, 15 - 6 + vse16.v v0, (a0) + sh1add a0, t0, a0 + vse16.v v4, (a1) + sh1add a1, t0, a1 + bnez a5, 2b + + ret +endfunc diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c index 187b3fce58..b3552976c6 100644 --- a/libswscale/riscv/swscale.c +++ b/libswscale/riscv/swscale.c @@ -23,8 +23,12 @@ void ff_bgr24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, const uint8_t *, int width, uint32_t *coeffs, void *); +void ff_bgr24ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, const uint8_t *, + const uint8_t *, int width, uint32_t *coeffs, void *); void ff_rgb24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, const uint8_t *, int width, uint32_t *coeffs, void *); +void ff_rgb24ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, const uint8_t *, + const uint8_t *, int width, uint32_t *coeffs, void *); av_cold void ff_sws_init_swscale_riscv(SwsContext *c) { @@ -35,10 +39,14 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c) switch (c->srcFormat) { case AV_PIX_FMT_BGR24: c->lumToYV12 = ff_bgr24ToY_rvv; + if (!c->chrSrcHSubSample) + c->chrToYV12 = ff_bgr24ToUV_rvv; break; case AV_PIX_FMT_RGB24: c->lumToYV12 = ff_rgb24ToY_rvv; + if (!c->chrSrcHSubSample) + c->chrToYV12 = ff_rgb24ToUV_rvv; break; } } From patchwork Wed Jun 5 16:36:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49587 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d792:0:b0:460:55fa:d5ed with SMTP id db18csp516439vqb; Wed, 5 Jun 2024 09:37:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUTmAlLTHYRkVjC6m0cTNrS0hqvmemjzI8fTd2Ih+lvt4hy9G9YfC4K9O6mLUodevrr0EMBIfqcpZSVZdvRto85wfpD+RNOt1ODEg== X-Google-Smtp-Source: AGHT+IHarPZiw9pJfp05UF52YyVLsfAhXrNCbjU2zS1pYq5hN8PqY+2MLi3HmGqErAcw9AUVjCJv X-Received: by 2002:a50:9e6e:0:b0:57a:859e:4d81 with SMTP id 4fb4d7f45d1cf-57a8bca32b0mr1857757a12.28.1717605428226; Wed, 05 Jun 2024 09:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717605428; cv=none; d=google.com; s=arc-20160816; b=YFSkwO9oMdaKpp3AFkniGs5tiDNt6QSfW//BLDMRB7VKr7l81L2Wa8yxSDQ5XEFZfL Bi3LrG6jj+dr0yw/APdVD7P84VXSWOJNprNdKsPdyFnbPhJOhXMlofR8EeE/rvkaNJId nuFfSGX3aEaBZJEq1pTdo1TRvkBw6WQ+3T0sdLUfaCthsASoU4i7I1Bm2hFijXWyHHqo IeodN8UvFYDe+lFPJcWuRLUDKhwA8vLELdPDjiIWr0DJHng376NCtoLJBUmNLW2B2on/ d7+q5w4yevi6Xpfud4irp8mOtJlIObvnQEDBoKNP6AfhK5J45NVQBMJ+Wv6PmZmQUrIx sDbQ== 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:delivered-to; bh=/WatfdbsynV8IlSCEvEgK2EzlZLZzRNO1+3KyMrNvW0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PEoSlRbirOWnUY1+fjuz03dG6RZ3OzWCfBTfW7t8o9HjjQEJ8cT4+XJs8air+m3gyw 13xN2fZz53sHCpzXF0RgItuY/9uLKVRTclHh5DeTd2XWxb+R48pDW6BjYmLbgmicnsMY qopmdjneIRVQeFoLHaJXq3A1skVX1H2yUoySxVN5d1qmpFCwUQj+wPwFrf7ky6jJdI/q wzXyltnTZd3gMPPfkWDYzdFZ5LSR2aoAlvotxvwcIS6erneKqRJ/HTesYlI1YogAJsUx G7jLNnIhCOtzNvsIZ537HUBcWCCXV+25zP9u85hHzQ8olGSVaSAf8ia8ZxLFD8meUGkk no1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57a5fae69c1si3595486a12.617.2024.06.05.09.37.07; Wed, 05 Jun 2024 09:37:08 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03B7768D706; Wed, 5 Jun 2024 19:36:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 141E168D67D for ; Wed, 5 Jun 2024 19:36:40 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 82799C02F8 for ; Wed, 5 Jun 2024 19:36:39 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 5 Jun 2024 19:36:37 +0300 Message-ID: <20240605163638.10586-3-remi@remlab.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240605163638.10586-1-remi@remlab.net> References: <20240605163638.10586-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] sws/input: R-V V rgb24ToUV_half and bgr24ToUV_half 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: YMh+Lf60+DwU T-Head C908: rgb24_to_uv_half_4_c: 2.0 rgb24_to_uv_half_4_rvv_i32: 3.5 rgb24_to_uv_half_64_c: 27.0 rgb24_to_uv_half_64_rvv_i32: 12.5 rgb24_to_uv_half_540_c: 223.7 rgb24_to_uv_half_540_rvv_i32: 105.2 rgb24_to_uv_half_640_c: 265.5 rgb24_to_uv_half_640_rvv_i32: 123.7 rgb24_to_uv_half_960_c: 414.5 rgb24_to_uv_half_960_rvv_i32: 249.5 SpacemiT X60: rgb24_to_uv_half_4_c: 1.7 rgb24_to_uv_half_4_rvv_i32: 4.2 rgb24_to_uv_half_64_c: 24.0 rgb24_to_uv_half_64_rvv_i32: 8.7 rgb24_to_uv_half_540_c: 199.2 rgb24_to_uv_half_540_rvv_i32: 72.5 rgb24_to_uv_half_640_c: 235.7 rgb24_to_uv_half_640_rvv_i32: 85.2 rgb24_to_uv_half_960_c: 353.5 rgb24_to_uv_half_960_rvv_i32: 127.5 --- libswscale/riscv/input.S | 50 ++++++++++++++++++++++++++++++++++++++ libswscale/riscv/swscale.c | 14 +++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/libswscale/riscv/input.S b/libswscale/riscv/input.S index 3392f189ca..f84f79899b 100644 --- a/libswscale/riscv/input.S +++ b/libswscale/riscv/input.S @@ -99,3 +99,53 @@ func ff_rgb24ToUV_rvv, zve32x ret endfunc + +func ff_bgr24ToUV_half_rvv, zve32x + lw t1, 20(a6) # BU + lw t4, 32(a6) # BV + lw t3, 12(a6) # RU + lw t6, 24(a6) # RV + j 1f +endfunc + +func ff_rgb24ToUV_half_rvv, zve32x + lw t1, 12(a6) # RU + lw t4, 24(a6) # RV + lw t3, 20(a6) # BU + lw t6, 32(a6) # BV +1: + lw t2, 16(a6) # GU + lw t5, 28(a6) # GV + li a7, (256 << 15) + (1 << (15 - 6)) +2: + vsetvli t0, a5, e8, m1, ta, ma + vlseg6e8.v v0, (a3) + sh1add a6, t0, t0 + vwaddu.vv v8, v0, v3 + sub a5, a5, t0 + vwaddu.vv v10, v1, v4 + sh1add a3, a6, a3 + vwaddu.vv v12, v2, v5 + vsetvli zero, zero, e32, m4, ta, ma + vzext.vf2 v20, v8 + vzext.vf2 v24, v10 + vzext.vf2 v28, v12 + vmul.vx v0, v20, t1 + vmul.vx v4, v20, t4 + vmacc.vx v0, t2, v24 + vmacc.vx v4, t5, v24 + vmacc.vx v0, t3, v28 + vmacc.vx v4, t6, v28 + vadd.vx v0, v0, a7 + vadd.vx v4, v4, a7 + vsetvli zero, zero, e16, m2, ta, ma + vnsra.wi v0, v0, 15 - 5 + vnsra.wi v2, v4, 15 - 5 + vse16.v v0, (a0) + sh1add a0, t0, a0 + vse16.v v2, (a1) + sh1add a1, t0, a1 + bnez a5, 2b + + ret +endfunc diff --git a/libswscale/riscv/swscale.c b/libswscale/riscv/swscale.c index b3552976c6..bae626f64a 100644 --- a/libswscale/riscv/swscale.c +++ b/libswscale/riscv/swscale.c @@ -25,10 +25,16 @@ void ff_bgr24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, const uint8_t *, int width, uint32_t *coeffs, void *); void ff_bgr24ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int width, uint32_t *coeffs, void *); +void ff_bgr24ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *, + const uint8_t *, const uint8_t *, int width, + uint32_t *coeffs, void *); void ff_rgb24ToY_rvv(uint8_t *dst, const uint8_t *src, const uint8_t *, const uint8_t *, int width, uint32_t *coeffs, void *); void ff_rgb24ToUV_rvv(uint8_t *, uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int width, uint32_t *coeffs, void *); +void ff_rgb24ToUV_half_rvv(uint8_t *, uint8_t *, const uint8_t *, + const uint8_t *, const uint8_t *, int width, + uint32_t *coeffs, void *); av_cold void ff_sws_init_swscale_riscv(SwsContext *c) { @@ -39,13 +45,17 @@ av_cold void ff_sws_init_swscale_riscv(SwsContext *c) switch (c->srcFormat) { case AV_PIX_FMT_BGR24: c->lumToYV12 = ff_bgr24ToY_rvv; - if (!c->chrSrcHSubSample) + if (c->chrSrcHSubSample) + c->chrToYV12 = ff_bgr24ToUV_half_rvv; + else c->chrToYV12 = ff_bgr24ToUV_rvv; break; case AV_PIX_FMT_RGB24: c->lumToYV12 = ff_rgb24ToY_rvv; - if (!c->chrSrcHSubSample) + if (c->chrSrcHSubSample) + c->chrToYV12 = ff_rgb24ToUV_half_rvv; + else c->chrToYV12 = ff_rgb24ToUV_rvv; break; }