From patchwork Sun Jun 16 22:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 49957 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1596826vqg; Sun, 16 Jun 2024 15:29:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWdnorBxf1Ywmn5o4UdqduHKksGF8MCGGaIpTHwWdGO6CKywv6l6lrrd4s4Kol4kBw25VxBm3TJ4z8ypsRKvSeuQ+91Wpw7xP8KDw== X-Google-Smtp-Source: AGHT+IHowGsdVPIxfnt0n7S2rY6w1yC9bEhMB+GHrQpNh0e/QdNPy19V09qovNlvjW/egnJ3cPG9 X-Received: by 2002:a50:d759:0:b0:57c:5874:4f5c with SMTP id 4fb4d7f45d1cf-57cbd6c7561mr6610482a12.32.1718576993428; Sun, 16 Jun 2024 15:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718576993; cv=none; d=google.com; s=arc-20160816; b=POG1iXxxPvBjnBZsehEjziBws1dUJnAdv7sqnHseOyltOOb9imVXHFK9vk5WljQ24w ffaKjXIK69PtngeXgyka8rGqUrrrHb4+PYTb8IP7o0MNclEygiwAA7uXTaLypY3sTbYS gCP9zGmpnpG020QXCJkLvdr33MknQP5QGUyfJrthb5/SF9Kw/pvhMCgj7oa2sH2L194c myxp6Zhnr8F0YgMUphS6cFYFSN9vBeGDuGtB3B2E3ouFaYpTUYToMy1NHR0xZE/9Ls6j X5LuQOiHSjZHBlkYGfcQJifjYglGfUJ/b429F9/8JnlIlncHw/bPxgN5qx8HR5mzrKbx TPVQ== 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=OlkK9mYLvMNyWNfq0OvMap4iGVuTFDYwBHZEQVIo6cE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=yy86pCa/3aTwjevG4WKfzbZDlZfSMbb9w5WTcJyR3iptQArtvviIe8/q0iPxgMBZ3X k+knLJ/2Yfcvmb1A6f87Z4Y9R7dUMBjuy35ynUvDTkifa7lndhqmvJmCWKDPs3WzWKfm D+4xzxkSZFkIhU9fPpuV/LbS89t9o8+Nw3NnSMQHNRJfHPwZa6s34OgI8cnacRJWrb0s /wGGoeFh3AfwJy5O/ZP/HzjLmp9AoyB5K/wNjY1JBkWkOEyTSMuNfYTbq821e/qxmrAl zawOOoj/jFlJH+Vn331qX3Tbibpq2GBGfCHTCFUDamDSWmipj0x+FHYQ6y/UV76MXvTP ZtRA==; 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=Li4Ryfbv; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57cb72d60d3si3861834a12.100.2024.06.16.15.29.52; Sun, 16 Jun 2024 15:29:53 -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=Li4Ryfbv; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4035A68D767; Mon, 17 Jun 2024 01:29:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8CF9C68D742 for ; Mon, 17 Jun 2024 01:28:57 +0300 (EEST) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-35f22d3abf1so3471212f8f.1 for ; Sun, 16 Jun 2024 15:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718576936; x=1719181736; 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=uE1P5f0A7oGKEQ/3fewtVro4OXtTHymu9QEZzQ9e9cg=; b=Li4RyfbvbFU94ZkQD2jzs6n+n4VKzMdUju5gVFrGsNdTsnj2pNj84hbcxG9jFeMamQ M94C69Msyi8WdcFG4am5wi9wVsGlhv7zNrl8e9tZBWbVufKMgAIbab/43fEZPCyhNpu8 NQRVJlPB6EfXXdWyqYEohFKX+6LWFT+HV8CjOJZ98SBmFTP8t2UjL+hjBrz1SgnmlUdQ CUTjYIGFCIUrvH+CV2N+7fC08TimWxjGv/ZzfCrn8HjJARgR4f+DYIN13NLW0UrKNHUC XeS0H7qacUzfIvba42BhSqAwnUm94CEOIV1M54icZfYSFgXuxMEHZ4let8aplDJUef4m 1Ahg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718576936; x=1719181736; 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=uE1P5f0A7oGKEQ/3fewtVro4OXtTHymu9QEZzQ9e9cg=; b=KzwZB+OBKYUBNwtyt4fXhzniadQyXvwiTbhkhWhAotzxwM1cy7vZK/mLABraWlyEJO EOSlqLK+lSTngULX9stPQW2z2CNP94oyHFi2rVjYOtzg5C/EtgRSWgBrYAqbeuGWdpHa DsXXw6xuZXlNDzlZ0yrv8FzIVlSQFdtV2C3SgPR9HnDSLYNFvOrVb73MLVokpFKiHmrB XTIY85/CmWLcACnw2OCjAo8i616cSRfrh6D8P6mlXDs17WUkQ7CgkyyF7wtu976nWAfg Ftd4/JCSyDp3xISJASCyzDoynVEaJY/oHj9S23gyq5NGp7mGOta6LpHbU78BYhWHH4OB 7OdQ== X-Gm-Message-State: AOJu0Yw4FA5VHJdUuOOilXfVgEn/9jwXhgSYs5ggsngKZ+h/RNYZICEe M9hpXYu7V6bdLL+BQzCWSywQ568AI3/G/gpPMi04Y9kNIs8HvIvi33kbRA== X-Received: by 2002:adf:ed86:0:b0:360:79ed:6251 with SMTP id ffacd0b85a97d-3607a783347mr7194621f8f.52.1718576936361; Sun, 16 Jun 2024 15:28:56 -0700 (PDT) Received: from localhost.localdomain (247.111-201-80.adsl-dyn.isp.belgacom.be. [80.201.111.247]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-360750ad082sm10349146f8f.59.2024.06.16.15.28.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 15:28:55 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jun 2024 00:28:49 +0200 Message-Id: <20240616222849.420361-6-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240616222849.420361-1-ramiro.polla@gmail.com> References: <20240616222849.420361-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] swscale/yuv2rgb/x86: remove mmx/mmxext yuv2rgb functions 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: xGCpUiuvbXUH These functions are either slower or barely faster than the C LUT yuv2rgb code. --- libswscale/x86/yuv2rgb.c | 51 ----------------- libswscale/x86/yuv2rgb_template.c | 4 -- libswscale/x86/yuv_2_rgb.asm | 93 +------------------------------ 3 files changed, 3 insertions(+), 145 deletions(-) diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index 6754062245..41dfa80f33 100644 --- a/libswscale/x86/yuv2rgb.c +++ b/libswscale/x86/yuv2rgb.c @@ -41,25 +41,8 @@ #define DITHER1XBPP // only for MMX -//MMX versions -#if HAVE_MMX -#undef RENAME -#define COMPILE_TEMPLATE_MMX -#define RENAME(a) a ## _mmx -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMX -#endif /* HAVE_MMX */ - -// MMXEXT versions -#undef RENAME -#define COMPILE_TEMPLATE_MMXEXT -#define RENAME(a) a ## _mmxext -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMXEXT - //SSSE3 versions #undef RENAME -#define COMPILE_TEMPLATE_SSSE3 #define RENAME(a) a ## _ssse3 #include "yuv2rgb_template.c" @@ -99,40 +82,6 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) } } - if (EXTERNAL_MMXEXT(cpu_flags)) { - switch (c->dstFormat) { - case AV_PIX_FMT_RGB24: - return yuv420_rgb24_mmxext; - case AV_PIX_FMT_BGR24: - return yuv420_bgr24_mmxext; - } - } - - if (EXTERNAL_MMX(cpu_flags)) { - switch (c->dstFormat) { - case AV_PIX_FMT_RGB32: - if (c->srcFormat == AV_PIX_FMT_YUVA420P) { -#if CONFIG_SWSCALE_ALPHA - return yuva420_rgb32_mmx; -#endif - break; - } else - return yuv420_rgb32_mmx; - case AV_PIX_FMT_BGR32: - if (c->srcFormat == AV_PIX_FMT_YUVA420P) { -#if CONFIG_SWSCALE_ALPHA - return yuva420_bgr32_mmx; -#endif - break; - } else - return yuv420_bgr32_mmx; - case AV_PIX_FMT_RGB565: - return yuv420_rgb16_mmx; - case AV_PIX_FMT_RGB555: - return yuv420_rgb15_mmx; - } - } - #endif /* HAVE_X86ASM */ return NULL; } diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c index 596943bb73..a4741e6873 100644 --- a/libswscale/x86/yuv2rgb_template.c +++ b/libswscale/x86/yuv2rgb_template.c @@ -47,7 +47,6 @@ extern void RENAME(ff_yuv_420_bgr24)(x86_reg index, uint8_t *image, const uint8_ const uint8_t *pv_index, const uint64_t *pointer_c_dither, const uint8_t *py_2index); -#ifndef COMPILE_TEMPLATE_MMXEXT extern void RENAME(ff_yuv_420_rgb15)(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); @@ -163,9 +162,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[], } return srcSliceH; } -#endif -#if !defined(COMPILE_TEMPLATE_MMX) static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, @@ -193,4 +190,3 @@ static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[], } return srcSliceH; } -#endif diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm index a1f9134e08..b67ab162d2 100644 --- a/libswscale/x86/yuv_2_rgb.asm +++ b/libswscale/x86/yuv_2_rgb.asm @@ -38,12 +38,6 @@ pb_e0: times 16 db 224 pb_03: times 16 db 3 pb_07: times 16 db 7 -mask_1101: dw -1, -1, 0, -1 -mask_0010: dw 0, 0, -1, 0 -mask_0110: dw 0, -1, -1, 0 -mask_1001: dw -1, 0, 0, -1 -mask_0100: dw 0, -1, 0, 0 - SECTION .text ;----------------------------------------------------------------------------- @@ -55,14 +49,6 @@ SECTION .text ; ;----------------------------------------------------------------------------- -%macro MOV_H2L 1 -%if mmsize == 8 - psrlq %1, 32 -%else ; mmsize == 16 - psrldq %1, 8 -%endif -%endmacro - %macro yuv2rgb_fn 3 %if %3 == 32 @@ -91,18 +77,6 @@ SECTION .text %define m_blue m1 %endif -%if mmsize == 8 -%define time_num 1 -%define reg_num 8 -%define y_offset [pointer_c_ditherq + 8 * 8] -%define u_offset [pointer_c_ditherq + 9 * 8] -%define v_offset [pointer_c_ditherq + 10 * 8] -%define ug_coff [pointer_c_ditherq + 7 * 8] -%define vg_coff [pointer_c_ditherq + 6 * 8] -%define y_coff [pointer_c_ditherq + 3 * 8] -%define ub_coff [pointer_c_ditherq + 5 * 8] -%define vr_coff [pointer_c_ditherq + 4 * 8] -%elif mmsize == 16 %define time_num 2 %if ARCH_X86_32 %define reg_num 8 @@ -125,13 +99,11 @@ SECTION .text %define ub_coff m14 %define vr_coff m15 %endif ; ARCH_X86_32/64 -%endif ; coeff define mmsize == 8/16 cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters %if ARCH_X86_64 movsxd indexq, indexd -%if mmsize == 16 VBROADCASTSD y_offset, [pointer_c_ditherq + 8 * 8] VBROADCASTSD u_offset, [pointer_c_ditherq + 9 * 8] VBROADCASTSD v_offset, [pointer_c_ditherq + 10 * 8] @@ -141,7 +113,6 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters VBROADCASTSD ub_coff, [pointer_c_ditherq + 5 * 8] VBROADCASTSD vr_coff, [pointer_c_ditherq + 4 * 8] %endif -%endif .loop0: movu m_y, [py_2indexq + 2 * indexq] movh m_u, [pu_indexq + indexq] @@ -157,7 +128,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters psllw m1, 3 psllw m6, 3 psllw m7, 3 -%if (ARCH_X86_32 && mmsize == 16) +%if ARCH_X86_32 VBROADCASTSD m2, mu_offset VBROADCASTSD m3, mv_offset VBROADCASTSD m4, my_offset @@ -176,7 +147,7 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters pmulhw m0, m5 VBROADCASTSD m4, mvr_coff pmulhw m1, m4 -%else ; ARCH_X86_64 || mmsize == 8 +%else ; ARCH_X86_64 psubsw m0, u_offset ; U = U - 128 psubsw m1, v_offset ; V = V - 128 psubw m6, y_offset @@ -207,49 +178,10 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters packuswb m2, m7 ; G0 G2 G4 G6 ... G1 G3 G5 G7 ... mova m3, m_red mova m6, m_blue - MOV_H2L m_red + psrldq m_red, 8 punpcklbw m3, m2 ; R0 G0 R2 G2 R4 G4 R6 G6 R8 G8 ... punpcklbw m6, m_red ; B0 R1 B2 R3 B4 R5 B6 R7 B8 R9 ... - mova m5, m3 punpckhbw m2, m_blue ; G1 B1 G3 B3 G5 B5 G7 B7 G9 B9 ... -%if mmsize == 8 - punpcklwd m3 ,m6 ; R0 G0 B0 R1 R2 G2 B2 R3 - punpckhwd m5, m6 ; R4 G4 B4 R5 R6 G6 B6 R7 -%if cpuflag(mmxext) - pshufw m1, m2, 0xc6 - pshufw m6, m3, 0x84 - pshufw m7, m5, 0x38 - pand m6, [mask_1101] ; R0 G0 B0 R1 -- -- R2 G2 - movq m0, m1 - pand m7, [mask_0110] ; -- -- R6 G6 B6 R7 -- -- - movq m2, m1 - pand m1, [mask_0100] ; -- -- G3 B3 -- -- -- -- - psrlq m3, 48 ; B2 R3 -- -- -- -- -- -- - pand m0, [mask_0010] ; -- -- -- -- G1 B1 -- -- - psllq m5, 32 ; -- -- -- -- R4 G4 B4 R5 - pand m2, [mask_1001] ; G5 B5 -- -- -- -- G7 B7 - por m1, m3 - por m0, m6 - por m1, m5 - por m2, m7 - movntq [imageq], m0 - movntq [imageq + 8], m1 - movntq [imageq + 16], m2 -%else ; cpuflag(mmx) - movd [imageq], m3 ; R0 G0 R2 G2 - movd [imageq + 4], m2 ; G1 B1 - psrlq m3, 32 - psrlq m2, 16 - movd [imageq + 6], m3 ; R2 G2 B2 R3 - movd [imageq + 10], m2 ; G3 B3 - psrlq m2, 16 - movd [imageq + 12], m5 ; R4 G4 B4 R5 - movd [imageq + 16], m2 ; G5 B5 - psrlq m5, 32 - movd [imageq + 20], m2 ; -- -- G7 B7 - movd [imageq + 18], m5 ; R6 G6 B6 R7 -%endif ; cpuflag -%else ; mmsize == 16 pshufb m3, [rgb24_shuf1] ; r0 g0 r6 g6 r12 g12 r2 g2 r8 g8 r14 g14 r4 g4 r10 g10 pshufb m6, [rgb24_shuf2] ; b10 r11 b0 r1 b6 r7 b12 r13 b2 r3 b8 r9 b14 r15 b4 r5 pshufb m2, [rgb24_shuf3] ; g5 b5 g11 b11 g1 b1 g7 b7 g13 b13 g3 b3 g9 b9 g15 b15 @@ -274,7 +206,6 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters movu [imageq], m0 movu [imageq + 16], m1 movu [imageq + 32], m2 -%endif ; mmsize = 16 %else ; PACK RGB15/16/32 packuswb m0, m1 packuswb m3, m5 @@ -309,18 +240,12 @@ cglobal %1_420_%2%3, GPR_num, GPR_num, reg_num, parameters movu [imageq + 24 * time_num], m_alpha %else ; PACK RGB15/16 %define depth 2 -%if cpuflag(ssse3) %define red_dither m3 %define green_dither m4 %define blue_dither m5 VBROADCASTSD red_dither, [pointer_c_ditherq + 0 * 8] VBROADCASTSD green_dither, [pointer_c_ditherq + 1 * 8] VBROADCASTSD blue_dither, [pointer_c_ditherq + 2 * 8] -%else ; cpuflag(mmx/mmxext) -%define blue_dither [pointer_c_ditherq + 2 * 8] -%define green_dither [pointer_c_ditherq + 1 * 8] -%define red_dither [pointer_c_ditherq + 0 * 8] -%endif %if %3 == 15 %define gmask pb_03 %define isRGB15 1 @@ -358,18 +283,6 @@ RET %endmacro -INIT_MMX mmx -yuv2rgb_fn yuv, rgb, 32 -yuv2rgb_fn yuv, bgr, 32 -yuv2rgb_fn yuva, rgb, 32 -yuv2rgb_fn yuva, bgr, 32 -yuv2rgb_fn yuv, rgb, 15 -yuv2rgb_fn yuv, rgb, 16 - -INIT_MMX mmxext -yuv2rgb_fn yuv, rgb, 24 -yuv2rgb_fn yuv, bgr, 24 - INIT_XMM ssse3 yuv2rgb_fn yuv, rgb, 24 yuv2rgb_fn yuv, bgr, 24