From patchwork Tue Aug 6 10:51:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 50911 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp1955753vqb; Tue, 6 Aug 2024 03:51:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXxDDWZacS/RYsSRsDZRqZKbnZNjM1ejF2zh0HuxzQoo+/G9KzqC0HTXfKd9WoC4xwScYJSor9x7MNzO9r+tolNuN1zh28jyUJGCQ== X-Google-Smtp-Source: AGHT+IE/KBo+AvVD6I/rIGjD00RRMScmRpZO5CmqQiK8XCzVkKHSVNK9QpFwPREXGzXJ7Tat/2Rh X-Received: by 2002:a17:907:7d94:b0:a77:cd51:3b32 with SMTP id a640c23a62f3a-a7dc51600b4mr1030485666b.62.1722941518504; Tue, 06 Aug 2024 03:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722941518; cv=none; d=google.com; s=arc-20160816; b=tBnJabQ67zjanz2DgruVo4f2nWYdWknng46/Wsko1FTW6ezzhFKhjBl7xQ7O49Xdp1 ixLZbDzxdlxlum0sAV9epb9+5tzoFUOZrH122BStxHLFPI+Vx/8DTAuKVgsPzMFryM1+ 0rFMoqYovdGwvVp9TUhdjc+SIUOKi8AEBEL0PT+2y2iAXLVFurjzdPyTMXqUak4xBKzn I5HmpS1xCQuZBSHkZS2WCwD8Jziq0svHXoNoxTv8ZQLgB/xaAJZ5Dzje5R3VDUsesJmI V1J1sQbrUpaOCKGjQwBpAJFv7A/1necBUhE4bzZWDd82Lf9nGf3h6lLDBkvzAs/yiKqO 1ApQ== 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=TehwA7Gw6gnBrnV0iui/TzWLWScYDO307vQW27+OGvw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=b8k2B4Ld2znLvOZn/tPrmtRAF50kfbN2MH5/+T7vSyJZalqzlbN31ZSOK6MxLgBbEF qyw65sv4kYziDNSNSuvGyfLZHeaTHtt8d6bB2OPRAOBNdOh4sobUW7SPAe9xi9Grixov NHBHSy8iypIpHldGRD5T9Gi+/fn1/trNOFiPfYebnvxbC9gDHQobiZjSfcuLcZXYyJU3 J1980CHl+SVhKbGbehI8llLbPjhAPkG4OWZkrhbC/PqHkV/XOhkUioJEFbJGfPMFHtX8 7dE6m0DlVszlqlZJK5xP9cYEZRN1fO5zO2WKYyGnYma9ZeyX1FEMYlrTd8HxxtGkWI2E 1Mow==; 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=eugux4pJ; 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-a7dc9bcf08fsi555414066b.79.2024.08.06.03.51.57; Tue, 06 Aug 2024 03:51:58 -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=eugux4pJ; 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 2F85968D9D6; Tue, 6 Aug 2024 13:51:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7708368D9DD for ; Tue, 6 Aug 2024 13:51:13 +0300 (EEST) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-36844375001so348539f8f.0 for ; Tue, 06 Aug 2024 03:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722941472; x=1723546272; 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=x5x+sewRFi1RDEqk9ZBh5JjRrO9lnVyCxVb37z1iP+8=; b=eugux4pJWj+11cKaf6enY/S2N/lGCCxpJYCAKCgKPKLmj52/I3ycz1WP26wJmNx6qs JyeMiEUza9sNERRWc8XjOzIu020EBoNvDSWhaSITxze+4Hs99tfvExTNykacYJgzghLT HQgkEb9HnGCCbL0g5ePh7dt/v6wwji7rgI7tbihdCIS+hieoCc11AEpOVgMpRYm8Qc9v d1DIGbMQ3Hyy/QVPeVmmbsJFU9ilRpNd8qjEQuQSHHk6pkPKKCbXcwt67WOWMEeibgfN RMqcBWdPtGtY81Q/E91PDF/6P264qnNEpFqX8puqfSgYqRtDTaSwNoPWdBFNjruzDE9/ 7CCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722941472; x=1723546272; 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=x5x+sewRFi1RDEqk9ZBh5JjRrO9lnVyCxVb37z1iP+8=; b=Vjwyhlh+u8WKpUYOEsNUuHgFWdTQnr6Q0SGK/P8mPBQpYkjOSP6BCzE7Af5ykcFUuL rZMT4ZO1i9NeWUxQ2Q77VSDmSICJrCgSYEiVAsWB3PW/r85AV7iqEuV5kmQnenllJTCn 3xk42g6dSFYzNslmJlOnSxbd23hakBvHRnh+mLlK7+LtxMkoCh8rc2eDvBz8MV7Jj7MN O9mHMmcLbAnoc4HzilTXS9c3vdhmJbBzLFXErNrCwBPSP8TlWevBbOC5QI31bRYav/Fd SkUGfFwbVSux9ZWKwxl7BHZ3o+zjAa6yrINkoaocGP4+m9qTbbmvKfVbjykBwGa2rAMP 3xWQ== X-Gm-Message-State: AOJu0YzqLwB7/syukTP82OvObMwToaikjCA8o/apJTJfSaYNs3v4rOmS TxXq6egH4na7NwZkGD4QIZ3gXmhc9iQd5N4bet1gcKvZ0fI29EmNaKNs2y+q X-Received: by 2002:a5d:58ca:0:b0:366:e9fa:178 with SMTP id ffacd0b85a97d-36bbbff34f7mr9898547f8f.0.1722941472134; Tue, 06 Aug 2024 03:51:12 -0700 (PDT) Received: from localhost.localdomain (249.128-243-81.adsl-dyn.isp.belgacom.be. [81.243.128.249]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36bbd01efe5sm12674592f8f.46.2024.08.06.03.51.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 03:51:11 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Aug 2024 12:51:05 +0200 Message-Id: <20240806105106.59866-5-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240806105106.59866-1-ramiro.polla@gmail.com> References: <20240806105106.59866-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/5] swscale/x86/yuv2rgb: add ssse3 yuv42{0, 2}p -> gbrp unscaled colorspace converters 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: 3vfcT8QO2/pd Note: this implementation is limited to x86_64 due to general purpose register pressure. checkasm --bench on an Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz: yuv420p_gbrp_8_c: 118.5 yuv420p_gbrp_8_ssse3: 93.3 yuv420p_gbrp_128_c: 1068.3 yuv420p_gbrp_128_ssse3: 319.3 yuv420p_gbrp_1080_c: 8841.8 yuv420p_gbrp_1080_ssse3: 2211.8 yuv420p_gbrp_1920_c: 15903.8 yuv420p_gbrp_1920_ssse3: 3814.3 yuv422p_gbrp_8_c: 144.8 yuv422p_gbrp_8_ssse3: 93.8 yuv422p_gbrp_128_c: 1395.8 yuv422p_gbrp_128_ssse3: 313.0 yuv422p_gbrp_1080_c: 11551.5 yuv422p_gbrp_1080_ssse3: 2240.8 yuv422p_gbrp_1920_c: 20585.3 yuv422p_gbrp_1920_ssse3: 5249.5 yuva420p_gbrp_8_c: 117.5 yuva420p_gbrp_8_ssse3: 92.0 yuva420p_gbrp_128_c: 1593.0 yuva420p_gbrp_128_ssse3: 319.3 yuva420p_gbrp_1080_c: 8694.5 yuva420p_gbrp_1080_ssse3: 2186.0 yuva420p_gbrp_1920_c: 15946.5 yuva420p_gbrp_1920_ssse3: 3805.3 --- libswscale/x86/yuv2rgb.c | 39 ++++++++++++++++++++++++++++++++++++ libswscale/x86/yuv_2_rgb.asm | 24 +++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index 68e903c6ad..2a4505fa90 100644 --- a/libswscale/x86/yuv2rgb.c +++ b/libswscale/x86/yuv2rgb.c @@ -79,6 +79,12 @@ extern void ff_yuva_420_rgb32_ssse3(x86_reg index, uint8_t *image, const uint8_t extern void ff_yuva_420_bgr32_ssse3(x86_reg index, uint8_t *image, const uint8_t *pu_index, const uint8_t *pv_index, const uint64_t *pointer_c_dither, const uint8_t *py_2index, const uint8_t *pa_2index); +#if ARCH_X86_64 +extern void ff_yuv_420_gbrp24_ssse3(x86_reg index, uint8_t *image, uint8_t *dst_b, uint8_t *dst_r, + const uint8_t *pu_index, const uint8_t *pv_index, + const uint64_t *pointer_c_dither, + const uint8_t *py_2index); +#endif static inline int yuv420_rgb15_ssse3(SwsContext *c, const uint8_t *src[], int srcStride[], @@ -201,6 +207,35 @@ static inline int yuv420_bgr24_ssse3(SwsContext *c, const uint8_t *src[], return srcSliceH; } +#if ARCH_X86_64 +static inline int yuv420_gbrp_ssse3(SwsContext *c, const uint8_t *src[], + int srcStride[], + int srcSliceY, int srcSliceH, + uint8_t *dst[], int dstStride[]) +{ + int y, h_size, vshift; + + h_size = (c->dstW + 7) & ~7; + if (h_size * 3 > FFABS(dstStride[0])) + h_size -= 8; + + vshift = c->srcFormat != AV_PIX_FMT_YUV422P; + + for (y = 0; y < srcSliceH; y++) { + uint8_t *dst_g = dst[0] + (y + srcSliceY) * dstStride[0]; + uint8_t *dst_b = dst[1] + (y + srcSliceY) * dstStride[1]; + uint8_t *dst_r = dst[2] + (y + srcSliceY) * dstStride[2]; + const uint8_t *py = src[0] + y * srcStride[0]; + const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; + const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; + x86_reg index = -h_size / 2; + + ff_yuv_420_gbrp24_ssse3(index, dst_g, dst_b, dst_r, pu - index, pv - index, &(c->redDither), py - 2 * index); + } + return srcSliceH; +} +#endif + #endif /* HAVE_X86ASM */ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) @@ -234,6 +269,10 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) return yuv420_rgb16_ssse3; case AV_PIX_FMT_RGB555: return yuv420_rgb15_ssse3; +#if ARCH_X86_64 + case AV_PIX_FMT_GBRP: + return yuv420_gbrp_ssse3; +#endif } } diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm index b67ab162d2..eeb1d25942 100644 --- a/libswscale/x86/yuv_2_rgb.asm +++ b/libswscale/x86/yuv_2_rgb.asm @@ -32,6 +32,7 @@ mask_dw25 : db 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0 rgb24_shuf1: db 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5, 10, 11 rgb24_shuf2: db 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15, 4, 5 rgb24_shuf3: db 4, 5, 10, 11, 0, 1, 6, 7, 12, 13, 2, 3, 8, 9, 14, 15 +gbrp_shuf : db 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 pw_00ff: times 8 dw 255 pb_f8: times 16 db 248 pb_e0: times 16 db 224 @@ -60,8 +61,13 @@ SECTION .text %define GPR_num 6 %endif %else + %ifidn %2, gbrp + %define parameters index, image, dst_b, dst_r, pu_index, pv_index, pointer_c_dither, py_2index + %define GPR_num 8 + %else %define parameters index, image, pu_index, pv_index, pointer_c_dither, py_2index %define GPR_num 6 + %endif %endif %define m_green m2 @@ -172,10 +178,22 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters paddsw m2, m6 ; G0 G2 G4 G6 ... %if %3 == 24 ; PACK RGB24 -%define depth 3 packuswb m0, m3 ; B0 B2 B4 B6 ... B1 B3 B5 B7 ... packuswb m1, m5 ; R0 R2 R4 R6 ... R1 R3 R5 R7 ... packuswb m2, m7 ; G0 G2 G4 G6 ... G1 G3 G5 G7 ... +%ifidn %2, gbrp ; PLANAR GBRP +%define depth 1 + mova m4, [gbrp_shuf] + pshufb m0, m4 + pshufb m1, m4 + pshufb m2, m4 + movu [imageq], m2 + movu [dst_bq], m0 + movu [dst_rq], m1 + add dst_bq, 8 * depth * time_num + add dst_rq, 8 * depth * time_num +%else +%define depth 3 mova m3, m_red mova m6, m_blue psrldq m_red, 8 @@ -206,6 +224,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters movu [imageq], m0 movu [imageq + 16], m1 movu [imageq + 32], m2 +%endif ; PLANAR GBRP %else ; PACK RGB15/16/32 packuswb m0, m1 packuswb m3, m5 @@ -292,3 +311,6 @@ yuv2rgb_fn yuva, rgb, 32 yuv2rgb_fn yuva, bgr, 32 yuv2rgb_fn yuv, rgb, 15 yuv2rgb_fn yuv, rgb, 16 +%if ARCH_X86_64 +yuv2rgb_fn yuv, gbrp, 24 +%endif