From patchwork Tue Aug 6 10:51:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 50908 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp1955574vqb; Tue, 6 Aug 2024 03:51:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8ggIFFouo4PxpS4btMJOoiWSy8dSdXgOSDzNhORr6jXSqOlIIeyvhUWgFx7hM8r1YDtIDMOJvAPX5yUWLCh+ef8v8FW2KUxP0Og== X-Google-Smtp-Source: AGHT+IFwZ7J+/OgdWb56Qz/xrkLb798V4ZluqZL6NqQy8suzOuX/0pisfd8BeZ2zlNB8etVJvTHc X-Received: by 2002:a05:6512:110e:b0:52e:f907:1023 with SMTP id 2adb3069b0e04-530bb3c7ceemr8886858e87.49.1722941491335; Tue, 06 Aug 2024 03:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722941491; cv=none; d=google.com; s=arc-20160816; b=FhmWmbgW9Lpn1HSMQnRKOkc6IU8IHBC1JYyVbfD9bMjCrQnyPNVZFCtaaEFXeOhjJc 73g/HKK2xJHIRNR+7bW1UXrTEaEAgylRnf9y6XogLewZiE36iTQ64IsKDttEg2yzZT/B y7H5uvPFRxFAdwHsYxlg8uRlJKp7Jc7rkrVjOr+tZ80Xs1vL3B2oNrBylyO/s/q/Wnjt KAIqqkWlUwbAL6XX4BOtzH0bnIsBbNEi9Sqr3Qzbpz28cooX6IKXIZNLzPLiyI9MeGv6 +D7YrRvirrPFYwS7YQ0fciL1n4G3Ux9Iogg3Gob5LKtzU4mj/qYfWrJba4P3ts5Bhj0Q WgPQ== 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=dMJhdTPaKwB8i1Rg7kj6T2Us5EJAuT9YSg3PmujklWo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=nM0CiNp7zLfo3s0QwBi2F2Xm4OgUOhUnrrChPKiqMuceQV4RfvY4ipA/EBmzAUXyki mNwSur0AFAHZ6P/eHIi1gv6y/vuUco7w3Pyx7w83pb65K5u1pmqaxmFP/QPYmKCX1BVZ qNqIcF1xz+Ba6g+HQcCa9ZTY79Ef9PpfJSQgi7Xvm6vYfBlxHyem0uyJQKbdZ/PQuLmQ 3atffEwiXS+SIcRqdjau0/LNNrQU1yDxrXgmx79cdmIeEQ6oy3X8kTOpICSD616wAJbc 8pYwwHdzCctn0Bg80WCJkhph7tz8FEay02K4zNtK2oiNhmOmKSTdmPWzEUKL2O/+nXsf 2nUQ==; 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=C+W5Ecpr; 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-a7dc9efcb86si540417966b.745.2024.08.06.03.51.31; Tue, 06 Aug 2024 03:51:31 -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=C+W5Ecpr; 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 BA49B68D9B2; Tue, 6 Aug 2024 13:51:17 +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 5190C68D0D3 for ; Tue, 6 Aug 2024 13:51:10 +0300 (EEST) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-368663d7f80so326377f8f.3 for ; Tue, 06 Aug 2024 03:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722941469; x=1723546269; 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=xdPuu8F83kLhB95o0HYe1+wFj+hCb4kgpDrX3cC2bWo=; b=C+W5Ecprzv631SrAUnxKQNBI1aIKvMxBOCKIf+dn8v3e3XPVivS6yXDhbv2T1Gi4vI FUglQiQusCzqLf/372vJ+HE8SAFdnGKxcnjd/hBOCkFWI0fK34toUyR2p7aIUA5Z4Qsm IRXmRuUcrbmYgtvnx6dyG4njj9cr7HnPnUptsJ0e2B+TwSdYNvHQQY+vKz+i3H9JE5zO Ba1HeOlqBzVCjlbYrUzgdUWbi9UJxivGJwVUxBTOGgUuSKFFC4Dvzy/ytoFjdnpzjR1Q J5rpJfal4q9XurbRMPvi2SajEf4kk+A78VvSRUslAVxQ3RaHb+kHplpEAqlV6jrsiN62 5IDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722941469; x=1723546269; 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=xdPuu8F83kLhB95o0HYe1+wFj+hCb4kgpDrX3cC2bWo=; b=vcIT5PGuXlZ8NDTTn2ivKsE39RaKZiOBGE0Xv4plfeGCgeeX1ieA06gFTOnuVerAVF c39yToDx3s3vzjWPgrNAI5Oht4ASISdRv6vT7hiyByISQWDMk3grSuS46Axfch9sYPix m6wLHjxubyF5SwAoIuyu+PDLF+H+o+daZfH99uAVd5TIOMaDH51q/EVsu0rUXbhPKrbH DXGwzdo491k2GI0PLMXZ6jPe5fyY8b3oCY0nBy8z1I8eD3TnQVFooyEnYTC/EbjH6hrv /Bi1eMrcPPk8aCQY/gpYobTxghpdiP7kARJg7m/ZS9+YrCLD8mCXhNhLkhmRnxMIdL4a ho5w== X-Gm-Message-State: AOJu0Yw72oW9bnDMoSNZtNZ8dwucRg2nTtWn0RabISAq7oekpXMcrB2n VMftoz9xhTwi3EzYHwM99sGMypEsmbYv04bE5mNGSwhtJYu6WZDF9lrpZyQT X-Received: by 2002:a5d:5003:0:b0:368:3b1a:8350 with SMTP id ffacd0b85a97d-36bbc0c9a9amr10663791f8f.19.1722941468881; Tue, 06 Aug 2024 03:51:08 -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.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 03:51:08 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Aug 2024 12:51:02 +0200 Message-Id: <20240806105106.59866-2-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 1/5] swscale/yuv2rgb: prepare LOADCHROMA/PUTFUNC macros for multi-planar rgb 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: iLUMYSKURUpy This will be used in the upcoming yuv42{0,2}p -> gbrp unscaled colorspace converters. There is no difference in performance. --- libswscale/yuv2rgb.c | 402 +++++++++++++++++++++---------------------- 1 file changed, 201 insertions(+), 201 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index cfbc54abd0..d77660b3a3 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -65,64 +65,64 @@ const int *sws_getCoefficients(int colorspace) return ff_yuv2rgb_coeffs[colorspace]; } -#define LOADCHROMA(pu, pv, i) \ - U = pu[i]; \ - V = pv[i]; \ +#define LOADCHROMA(l, i) \ + U = pu_##l[i]; \ + V = pv_##l[i]; \ r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \ g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \ b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM]; -#define PUTRGB(dst, src, asrc, i, abase) \ - Y = src[2 * i]; \ - dst[2 * i] = r[Y] + g[Y] + b[Y]; \ - Y = src[2 * i + 1]; \ - dst[2 * i + 1] = r[Y] + g[Y] + b[Y]; - -#define PUTRGB24(dst, src, asrc, i, abase) \ - Y = src[2 * i]; \ - dst[6 * i + 0] = r[Y]; \ - dst[6 * i + 1] = g[Y]; \ - dst[6 * i + 2] = b[Y]; \ - Y = src[2 * i + 1]; \ - dst[6 * i + 3] = r[Y]; \ - dst[6 * i + 4] = g[Y]; \ - dst[6 * i + 5] = b[Y]; - -#define PUTBGR24(dst, src, asrc, i, abase) \ - Y = src[2 * i]; \ - dst[6 * i + 0] = b[Y]; \ - dst[6 * i + 1] = g[Y]; \ - dst[6 * i + 2] = r[Y]; \ - Y = src[2 * i + 1]; \ - dst[6 * i + 3] = b[Y]; \ - dst[6 * i + 4] = g[Y]; \ - dst[6 * i + 5] = r[Y]; - -#define PUTRGBA(dst, ysrc, asrc, i, abase) \ - Y = ysrc[2 * i]; \ - dst[2 * i] = r[Y] + g[Y] + b[Y] + ((uint32_t)(asrc[2 * i]) << abase); \ - Y = ysrc[2 * i + 1]; \ - dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + ((uint32_t)(asrc[2 * i + 1]) << abase); - -#define PUTRGB48(dst, src, asrc, i, abase) \ - Y = src[ 2 * i]; \ - dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \ - dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ - dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \ - Y = src[ 2 * i + 1]; \ - dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \ - dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ - dst[12 * i + 10] = dst[12 * i + 11] = b[Y]; - -#define PUTBGR48(dst, src, asrc, i, abase) \ - Y = src[2 * i]; \ - dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \ - dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ - dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \ - Y = src[2 * i + 1]; \ - dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \ - dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ - dst[12 * i + 10] = dst[12 * i + 11] = r[Y]; +#define PUTRGB(l, i, abase) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y] + g[Y] + b[Y]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y] + g[Y] + b[Y]; + +#define PUTRGB24(l, i, abase) \ + Y = py_##l[2 * i]; \ + dst_##l[6 * i + 0] = r[Y]; \ + dst_##l[6 * i + 1] = g[Y]; \ + dst_##l[6 * i + 2] = b[Y]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[6 * i + 3] = r[Y]; \ + dst_##l[6 * i + 4] = g[Y]; \ + dst_##l[6 * i + 5] = b[Y]; + +#define PUTBGR24(l, i, abase) \ + Y = py_##l[2 * i]; \ + dst_##l[6 * i + 0] = b[Y]; \ + dst_##l[6 * i + 1] = g[Y]; \ + dst_##l[6 * i + 2] = r[Y]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[6 * i + 3] = b[Y]; \ + dst_##l[6 * i + 4] = g[Y]; \ + dst_##l[6 * i + 5] = r[Y]; + +#define PUTRGBA(l, i, abase) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y] + g[Y] + b[Y] + ((uint32_t)(pa_##l[2 * i]) << abase); \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y] + g[Y] + b[Y] + ((uint32_t)(pa_##l[2 * i + 1]) << abase); + +#define PUTRGB48(l, i, abase) \ + Y = py_##l[ 2 * i]; \ + dst_##l[12 * i + 0] = dst_##l[12 * i + 1] = r[Y]; \ + dst_##l[12 * i + 2] = dst_##l[12 * i + 3] = g[Y]; \ + dst_##l[12 * i + 4] = dst_##l[12 * i + 5] = b[Y]; \ + Y = py_##l[ 2 * i + 1]; \ + dst_##l[12 * i + 6] = dst_##l[12 * i + 7] = r[Y]; \ + dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ + dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = b[Y]; + +#define PUTBGR48(l, i, abase) \ + Y = py_##l[2 * i]; \ + dst_##l[12 * i + 0] = dst_##l[12 * i + 1] = b[Y]; \ + dst_##l[12 * i + 2] = dst_##l[12 * i + 3] = g[Y]; \ + dst_##l[12 * i + 4] = dst_##l[12 * i + 5] = r[Y]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[12 * i + 6] = dst_##l[12 * i + 7] = b[Y]; \ + dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ + dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y]; #define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422) \ static int func_name(SwsContext *c, const uint8_t *src[], \ @@ -183,166 +183,166 @@ const int *sws_getCoefficients(int colorspace) #define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ YUV2RGBFUNC(func_name, dst_type, alpha, 0) \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ - PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, abase); \ + PUTFUNC(2, 0, abase); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ - PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + LOADCHROMA(1, 1); \ + PUTFUNC(2, 1, abase); \ + PUTFUNC(1, 1, abase); \ \ - LOADCHROMA(pu_1, pv_1, 2); \ - PUTFUNC(dst_1, py_1, pa_1, 2, abase); \ - PUTFUNC(dst_2, py_2, pa_2, 2, abase); \ + LOADCHROMA(1, 2); \ + PUTFUNC(1, 2, abase); \ + PUTFUNC(2, 2, abase); \ \ - LOADCHROMA(pu_1, pv_1, 3); \ - PUTFUNC(dst_2, py_2, pa_2, 3, abase); \ - PUTFUNC(dst_1, py_1, pa_1, 3, abase); \ + LOADCHROMA(1, 3); \ + PUTFUNC(2, 3, abase); \ + PUTFUNC(1, 3, abase); \ ENDYUV2RGBLINE(dst_delta, 0, alpha, 0) \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ - PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, abase); \ + PUTFUNC(2, 0, abase); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ - PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + LOADCHROMA(1, 1); \ + PUTFUNC(2, 1, abase); \ + PUTFUNC(1, 1, abase); \ ENDYUV2RGBLINE(dst_delta, 1, alpha, 0) \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ - PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, abase); \ + PUTFUNC(2, 0, abase); \ ENDYUV2RGBFUNC() #define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ YUV2RGBFUNC(func_name, dst_type, alpha, 1) \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, abase); \ \ - LOADCHROMA(pu_2, pv_2, 0); \ - PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + LOADCHROMA(2, 0); \ + PUTFUNC(2, 0, abase); \ \ - LOADCHROMA(pu_2, pv_2, 1); \ - PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ + LOADCHROMA(2, 1); \ + PUTFUNC(2, 1, abase); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + LOADCHROMA(1, 1); \ + PUTFUNC(1, 1, abase); \ \ - LOADCHROMA(pu_1, pv_1, 2); \ - PUTFUNC(dst_1, py_1, pa_1, 2, abase); \ + LOADCHROMA(1, 2); \ + PUTFUNC(1, 2, abase); \ \ - LOADCHROMA(pu_2, pv_2, 2); \ - PUTFUNC(dst_2, py_2, pa_2, 2, abase); \ + LOADCHROMA(2, 2); \ + PUTFUNC(2, 2, abase); \ \ - LOADCHROMA(pu_2, pv_2, 3); \ - PUTFUNC(dst_2, py_2, pa_2, 3, abase); \ + LOADCHROMA(2, 3); \ + PUTFUNC(2, 3, abase); \ \ - LOADCHROMA(pu_1, pv_1, 3); \ - PUTFUNC(dst_1, py_1, pa_1, 3, abase); \ + LOADCHROMA(1, 3); \ + PUTFUNC(1, 3, abase); \ ENDYUV2RGBLINE(dst_delta, 0, alpha, 1) \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, abase); \ \ - LOADCHROMA(pu_2, pv_2, 0); \ - PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + LOADCHROMA(2, 0); \ + PUTFUNC(2, 0, abase); \ \ - LOADCHROMA(pu_2, pv_2, 1); \ - PUTFUNC(dst_2, py_2, pa_2, 1, abase); \ + LOADCHROMA(2, 1); \ + PUTFUNC(2, 1, abase); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_1, py_1, pa_1, 1, abase); \ + LOADCHROMA(1, 1); \ + PUTFUNC(1, 1, abase); \ ENDYUV2RGBLINE(dst_delta, 1, alpha, 1) \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, pa_1, 0, abase); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, abase); \ \ - LOADCHROMA(pu_2, pv_2, 0); \ - PUTFUNC(dst_2, py_2, pa_2, 0, abase); \ + LOADCHROMA(2, 0); \ + PUTFUNC(2, 0, abase); \ ENDYUV2RGBFUNC() #define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ YUV2RGBFUNC(func_name, dst_type, 0, 0) \ LOADDITHER \ \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, 0, 0); \ - PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, 0); \ + PUTFUNC(2, 0, 0 + 8); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_2, py_2, 1, 2 + 8); \ - PUTFUNC(dst_1, py_1, 1, 2); \ + LOADCHROMA(1, 1); \ + PUTFUNC(2, 1, 2 + 8); \ + PUTFUNC(1, 1, 2); \ \ - LOADCHROMA(pu_1, pv_1, 2); \ - PUTFUNC(dst_1, py_1, 2, 4); \ - PUTFUNC(dst_2, py_2, 2, 4 + 8); \ + LOADCHROMA(1, 2); \ + PUTFUNC(1, 2, 4); \ + PUTFUNC(2, 2, 4 + 8); \ \ - LOADCHROMA(pu_1, pv_1, 3); \ - PUTFUNC(dst_2, py_2, 3, 6 + 8); \ - PUTFUNC(dst_1, py_1, 3, 6); \ + LOADCHROMA(1, 3); \ + PUTFUNC(2, 3, 6 + 8); \ + PUTFUNC(1, 3, 6); \ ENDYUV2RGBLINE(dst_delta, 0, 0, 0) \ LOADDITHER \ \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, 0, 0); \ - PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, 0); \ + PUTFUNC(2, 0, 0 + 8); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_2, py_2, 1, 2 + 8); \ - PUTFUNC(dst_1, py_1, 1, 2); \ + LOADCHROMA(1, 1); \ + PUTFUNC(2, 1, 2 + 8); \ + PUTFUNC(1, 1, 2); \ ENDYUV2RGBLINE(dst_delta, 1, 0, 0) \ LOADDITHER \ \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, 0, 0); \ - PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, 0); \ + PUTFUNC(2, 0, 0 + 8); \ ENDYUV2RGBFUNC() #define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ YUV2RGBFUNC(func_name, dst_type, 0, 1) \ LOADDITHER \ \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, 0, 0); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, 0); \ \ - LOADCHROMA(pu_2, pv_2, 0); \ - PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + LOADCHROMA(2, 0); \ + PUTFUNC(2, 0, 0 + 8); \ \ - LOADCHROMA(pu_2, pv_2, 1); \ - PUTFUNC(dst_2, py_2, 1, 2 + 8); \ + LOADCHROMA(2, 1); \ + PUTFUNC(2, 1, 2 + 8); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_1, py_1, 1, 2); \ + LOADCHROMA(1, 1); \ + PUTFUNC(1, 1, 2); \ \ - LOADCHROMA(pu_1, pv_1, 2); \ - PUTFUNC(dst_1, py_1, 2, 4); \ + LOADCHROMA(1, 2); \ + PUTFUNC(1, 2, 4); \ \ - LOADCHROMA(pu_2, pv_2, 2); \ - PUTFUNC(dst_2, py_2, 2, 4 + 8); \ + LOADCHROMA(2, 2); \ + PUTFUNC(2, 2, 4 + 8); \ \ - LOADCHROMA(pu_2, pv_2, 3); \ - PUTFUNC(dst_2, py_2, 3, 6 + 8); \ + LOADCHROMA(2, 3); \ + PUTFUNC(2, 3, 6 + 8); \ \ - LOADCHROMA(pu_1, pv_1, 3); \ - PUTFUNC(dst_1, py_1, 3, 6); \ + LOADCHROMA(1, 3); \ + PUTFUNC(1, 3, 6); \ ENDYUV2RGBLINE(dst_delta, 0, 0, 1) \ LOADDITHER \ \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, 0, 0); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, 0); \ \ - LOADCHROMA(pu_2, pv_2, 0); \ - PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + LOADCHROMA(2, 0); \ + PUTFUNC(2, 0, 0 + 8); \ \ - LOADCHROMA(pu_2, pv_2, 1); \ - PUTFUNC(dst_2, py_2, 1, 2 + 8); \ + LOADCHROMA(2, 1); \ + PUTFUNC(2, 1, 2 + 8); \ \ - LOADCHROMA(pu_1, pv_1, 1); \ - PUTFUNC(dst_1, py_1, 1, 2); \ + LOADCHROMA(1, 1); \ + PUTFUNC(1, 1, 2); \ ENDYUV2RGBLINE(dst_delta, 1, 0, 1) \ LOADDITHER \ \ - LOADCHROMA(pu_1, pv_1, 0); \ - PUTFUNC(dst_1, py_1, 0, 0); \ + LOADCHROMA(1, 0); \ + PUTFUNC(1, 0, 0); \ \ - LOADCHROMA(pu_2, pv_2, 0); \ - PUTFUNC(dst_2, py_2, 0, 0 + 8); \ + LOADCHROMA(2, 0); \ + PUTFUNC(2, 0, 0 + 8); \ ENDYUV2RGBFUNC() #define LOADDITHER16 \ @@ -350,86 +350,86 @@ const int *sws_getCoefficients(int colorspace) const uint8_t *e16 = ff_dither_2x2_4[y & 1]; \ const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; -#define PUTRGB16(dst, src, i, o) \ - Y = src[2 * i]; \ - dst[2 * i] = r[Y + d16[0 + o]] + \ - g[Y + e16[0 + o]] + \ - b[Y + f16[0 + o]]; \ - Y = src[2 * i + 1]; \ - dst[2 * i + 1] = r[Y + d16[1 + o]] + \ - g[Y + e16[1 + o]] + \ - b[Y + f16[1 + o]]; +#define PUTRGB16(l, i, o) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y + d16[0 + o]] + \ + g[Y + e16[0 + o]] + \ + b[Y + f16[0 + o]]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \ + g[Y + e16[1 + o]] + \ + b[Y + f16[1 + o]]; #define LOADDITHER15 \ const uint8_t *d16 = ff_dither_2x2_8[y & 1]; \ const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; -#define PUTRGB15(dst, src, i, o) \ - Y = src[2 * i]; \ - dst[2 * i] = r[Y + d16[0 + o]] + \ - g[Y + d16[1 + o]] + \ - b[Y + e16[0 + o]]; \ - Y = src[2 * i + 1]; \ - dst[2 * i + 1] = r[Y + d16[1 + o]] + \ - g[Y + d16[0 + o]] + \ - b[Y + e16[1 + o]]; +#define PUTRGB15(l, i, o) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y + d16[0 + o]] + \ + g[Y + d16[1 + o]] + \ + b[Y + e16[0 + o]]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \ + g[Y + d16[0 + o]] + \ + b[Y + e16[1 + o]]; #define LOADDITHER12 \ const uint8_t *d16 = ff_dither_4x4_16[y & 3]; -#define PUTRGB12(dst, src, i, o) \ - Y = src[2 * i]; \ - dst[2 * i] = r[Y + d16[0 + o]] + \ - g[Y + d16[0 + o]] + \ - b[Y + d16[0 + o]]; \ - Y = src[2 * i + 1]; \ - dst[2 * i + 1] = r[Y + d16[1 + o]] + \ - g[Y + d16[1 + o]] + \ - b[Y + d16[1 + o]]; +#define PUTRGB12(l, i, o) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y + d16[0 + o]] + \ + g[Y + d16[0 + o]] + \ + b[Y + d16[0 + o]]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y + d16[1 + o]] + \ + g[Y + d16[1 + o]] + \ + b[Y + d16[1 + o]]; #define LOADDITHER8 \ const uint8_t *d32 = ff_dither_8x8_32[yd & 7]; \ const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; -#define PUTRGB8(dst, src, i, o) \ - Y = src[2 * i]; \ - dst[2 * i] = r[Y + d32[0 + o]] + \ - g[Y + d32[0 + o]] + \ - b[Y + d64[0 + o]]; \ - Y = src[2 * i + 1]; \ - dst[2 * i + 1] = r[Y + d32[1 + o]] + \ - g[Y + d32[1 + o]] + \ - b[Y + d64[1 + o]]; +#define PUTRGB8(l, i, o) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y + d32[0 + o]] + \ + g[Y + d32[0 + o]] + \ + b[Y + d64[0 + o]]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y + d32[1 + o]] + \ + g[Y + d32[1 + o]] + \ + b[Y + d64[1 + o]]; #define LOADDITHER4D \ const uint8_t * d64 = ff_dither_8x8_73[yd & 7]; \ const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; \ int acc; -#define PUTRGB4D(dst, src, i, o) \ - Y = src[2 * i]; \ +#define PUTRGB4D(l, i, o) \ + Y = py_##l[2 * i]; \ acc = r[Y + d128[0 + o]] + \ g[Y + d64[0 + o]] + \ b[Y + d128[0 + o]]; \ - Y = src[2 * i + 1]; \ + Y = py_##l[2 * i + 1]; \ acc |= (r[Y + d128[1 + o]] + \ g[Y + d64[1 + o]] + \ b[Y + d128[1 + o]]) << 4; \ - dst[i] = acc; + dst_##l[i] = acc; #define LOADDITHER4DB \ const uint8_t *d64 = ff_dither_8x8_73[yd & 7]; \ const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; -#define PUTRGB4DB(dst, src, i, o) \ - Y = src[2 * i]; \ - dst[2 * i] = r[Y + d128[0 + o]] + \ - g[Y + d64[0 + o]] + \ - b[Y + d128[0 + o]]; \ - Y = src[2 * i + 1]; \ - dst[2 * i + 1] = r[Y + d128[1 + o]] + \ - g[Y + d64[1 + o]] + \ - b[Y + d128[1 + o]]; +#define PUTRGB4DB(l, i, o) \ + Y = py_##l[2 * i]; \ + dst_##l[2 * i] = r[Y + d128[0 + o]] + \ + g[Y + d64[0 + o]] + \ + b[Y + d128[0 + o]]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l[2 * i + 1] = r[Y + d128[1 + o]] + \ + g[Y + d64[1 + o]] + \ + b[Y + d128[1 + o]]; YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0) const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; From patchwork Tue Aug 6 10:51:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 50909 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp1955643vqb; Tue, 6 Aug 2024 03:51:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDzc8sbFISYYA/qjoT/jw5wDz/aI9WU+P58thVqviteEmf1cu5OFVlBfA4Pjj+qY8oev7N9xLLQFhlEm1p/zdkGqGDhN2sjgn+Kw== X-Google-Smtp-Source: AGHT+IHN1xLH7u4kfeUP5MQeWVpKALKpjUMFll1OS5OwoevPi9kMIy5cWKRjLxCNvQB4uV0XW6ST X-Received: by 2002:a05:6402:685:b0:5a7:48de:deb7 with SMTP id 4fb4d7f45d1cf-5b7f39e089cmr9914493a12.14.1722941501113; Tue, 06 Aug 2024 03:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722941501; cv=none; d=google.com; s=arc-20160816; b=Gqn6rjX4NZ253+5uZb4fHE+UOlJn4g4pOqHeQiYR87ItTIXPakShmOtYwWfA/W9MYi iKbpN6VLJti7052+7/9vfvSM1JS5I9zpaIhms2Ty3effFuMdJc3o+tqxjJim00OfhHdz UEUBR9MbIdbi0d7t7V5iQCpFntRT2cAdJvOENHs5kC7te0G6hpdx9rkFXxqlNRS8Vff3 1NTYUD880P8aOnBwKwUKgDprYcZJ0l615bQ4A2efJMlCE9oAXwx/oA20E63XFN0yXMzc 6jM5M5mk6LiS6UXIiqI9siqbOfZyelufTl03JdyKQFQ4z2SbqT2mKxl8mCFVwvMxE21R 6q4g== 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=tdPjZWIhluZDBKDUOSSIOg+ydwsOv4nhR5YfV4P6dnc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=HcXt7isivE1hg0k7WwshjbkDhnR36Ktk0GO2sIErnFiIks3XTur4DAhuXiCaeowt9U m/qOFPLbHFghCQn0MSeqaIv2/8C16sY8vy4Sm1u6foNLc9LrpXLTRtv++bZ0fJtFCggt HdURk4HRik4EJy1/iEaXo5pUZsOMWeJ2Ee5gGxOowkoBJ/sXP03uqYozdOa38qFKxR4g ZtUhElidr2tqC6lSfmxyGiJDIXVWSb0rxTxythrQUmpafFZ9jT1VWTZ+CQ1KBK14NFOs I8kyLS/Piht1fSbIisJQM/gzNl6shmtv4xzxz3xYELtDlOumEfkKB/8jPWPTGvn159t4 EvGQ==; 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=bQvdGiGY; 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 4fb4d7f45d1cf-5b839710cc9si5851929a12.6.2024.08.06.03.51.40; Tue, 06 Aug 2024 03:51:41 -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=bQvdGiGY; 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 CFB1468D9B6; Tue, 6 Aug 2024 13:51:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8719A68D9B6 for ; Tue, 6 Aug 2024 13:51:11 +0300 (EEST) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-428e0d18666so2744665e9.3 for ; Tue, 06 Aug 2024 03:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722941470; x=1723546270; 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=Mw4cBcvCc5RU8qZ+iJNvMdMFM1vtOMaVvneY2OpDxFw=; b=bQvdGiGYTDm9uR3l3aiCiTBf04gVpGDViDH/zL+dO6WWbty+qhHZTwbEad9XqrXOcg rrQLUdx9jlFnGgjzp6fbRLWG1WhrRtUcDTLbp4BczRDECbm+tqupJIV+TbMSHcAEoGqQ Oo6z3jY+eMP7/H3O9FoVuQLHsDbAeDr161CrsPf1SBu0Q40fWMx2/3RoOrHa+GmmspQp 2g+6qEu6rniYg7HwLMS9lM4mvunWZl2gZSxcpoYrnoWlmb0Gi678QvPA1aC6f1UQV/w3 nOo3dfACiscf5AE5fqCF7I6p7QlRv6inSGiHQyO/Qk/sI2FT81pHF3VBVsBYcgmEQEPc bUXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722941470; x=1723546270; 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=Mw4cBcvCc5RU8qZ+iJNvMdMFM1vtOMaVvneY2OpDxFw=; b=ZNP8F3ja8dLqfWSNPt/V3p+zVs9Z364UEzTIWXz2KHflVTAGzjEs0SMUPLO8V3qJTl MqZU6Zw3vqVYSzaU7EkVPVJ8PUv80vkyEmojbHlGNLp+cSeGXbwNfkKjGltZTtsHQm0m DTGx4IE6SOrkwU+mZn8fImCQ+OKao2/PtKbSjfQWwonmPvw4CdunYbsCKB45DUn0mbBm XKYna0pZwKSvaSwv1hBoD+seDhdgt8SiNH8lx+VqzBFvD9ThE3WeZ0exnWJ0Mh8BQIZH TJZbIcMxCaw0/sZjuw3ozT+DP2qb+N+n+sr1FNBIUiHgq+OEm60AhOKfFj0si6Sm1/IG RbiQ== X-Gm-Message-State: AOJu0YyR32U1dgH1tGi11aVfZhq3VdjWKU21AE4cmP/czN5kbfsDkGkx iqTP1IeHEiCHp9CqWtLxdN50yY8UTaoXGBAveN2pw8tncXhTkDWAZqIDU/Vy X-Received: by 2002:a5d:62c8:0:b0:366:ef25:de51 with SMTP id ffacd0b85a97d-36bbc1bd492mr10835038f8f.49.1722941469887; Tue, 06 Aug 2024 03:51:09 -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.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 03:51:09 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Aug 2024 12:51:03 +0200 Message-Id: <20240806105106.59866-3-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 2/5] swscale/yuv2rgb: prepare YUV2RGBFUNC macro for multi-planar rgb 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: L3H2JzB/Bp6A This will be used in the upcoming yuv42{0,2}p -> gbrp unscaled colorspace converters. There is no difference in performance. --- libswscale/yuv2rgb.c | 83 +++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index d77660b3a3..31d10235ef 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -124,7 +124,7 @@ const int *sws_getCoefficients(int colorspace) dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y]; -#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422) \ +#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \ static int func_name(SwsContext *c, const uint8_t *src[], \ int srcStride[], int srcSliceY, int srcSliceH, \ uint8_t *dst[], int dstStride[]) \ @@ -137,6 +137,7 @@ const int *sws_getCoefficients(int colorspace) (dst_type *)(dst[0] + (yd) * dstStride[0]); \ dst_type *dst_2 = \ (dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \ + dst_type av_unused *dst1_1, *dst1_2, *dst2_1, *dst2_2; \ dst_type av_unused *r, *g, *b; \ const uint8_t *py_1 = src[0] + y * srcStride[0]; \ const uint8_t *py_2 = py_1 + srcStride[0]; \ @@ -145,6 +146,12 @@ const int *sws_getCoefficients(int colorspace) const uint8_t av_unused *pu_2, *pv_2; \ const uint8_t av_unused *pa_1, *pa_2; \ unsigned int h_size = c->dstW >> 3; \ + if (nb_dst_planes > 1) { \ + dst1_1 = (dst_type *)(dst[1] + (yd) * dstStride[1]); \ + dst1_2 = (dst_type *)(dst[1] + (yd + 1) * dstStride[1]); \ + dst2_1 = (dst_type *)(dst[2] + (yd) * dstStride[2]); \ + dst2_2 = (dst_type *)(dst[2] + (yd + 1) * dstStride[2]); \ + } \ if (yuv422) { \ pu_2 = pu_1 + srcStride[1]; \ pv_2 = pv_1 + srcStride[2]; \ @@ -156,7 +163,7 @@ const int *sws_getCoefficients(int colorspace) while (h_size--) { \ int av_unused U, V, Y; \ -#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422) \ +#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422, nb_dst_planes) \ pu_1 += 4 >> ss; \ pv_1 += 4 >> ss; \ if (yuv422) { \ @@ -171,6 +178,12 @@ const int *sws_getCoefficients(int colorspace) } \ dst_1 += dst_delta >> ss; \ dst_2 += dst_delta >> ss; \ + if (nb_dst_planes > 1) { \ + dst1_1 += dst_delta >> ss; \ + dst1_2 += dst_delta >> ss; \ + dst2_1 += dst_delta >> ss; \ + dst2_2 += dst_delta >> ss; \ + } \ } \ if (c->dstW & (4 >> ss)) { \ int av_unused Y, U, V; \ @@ -181,8 +194,8 @@ const int *sws_getCoefficients(int colorspace) return srcSliceH; \ } -#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ - YUV2RGBFUNC(func_name, dst_type, alpha, 0) \ +#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \ + YUV2RGBFUNC(func_name, dst_type, alpha, 0, nb_dst_planes) \ LOADCHROMA(1, 0); \ PUTFUNC(1, 0, abase); \ PUTFUNC(2, 0, abase); \ @@ -198,7 +211,7 @@ const int *sws_getCoefficients(int colorspace) LOADCHROMA(1, 3); \ PUTFUNC(2, 3, abase); \ PUTFUNC(1, 3, abase); \ - ENDYUV2RGBLINE(dst_delta, 0, alpha, 0) \ + ENDYUV2RGBLINE(dst_delta, 0, alpha, 0, nb_dst_planes) \ LOADCHROMA(1, 0); \ PUTFUNC(1, 0, abase); \ PUTFUNC(2, 0, abase); \ @@ -206,14 +219,14 @@ const int *sws_getCoefficients(int colorspace) LOADCHROMA(1, 1); \ PUTFUNC(2, 1, abase); \ PUTFUNC(1, 1, abase); \ - ENDYUV2RGBLINE(dst_delta, 1, alpha, 0) \ + ENDYUV2RGBLINE(dst_delta, 1, alpha, 0, nb_dst_planes) \ LOADCHROMA(1, 0); \ PUTFUNC(1, 0, abase); \ PUTFUNC(2, 0, abase); \ ENDYUV2RGBFUNC() -#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ - YUV2RGBFUNC(func_name, dst_type, alpha, 1) \ +#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \ + YUV2RGBFUNC(func_name, dst_type, alpha, 1, nb_dst_planes) \ LOADCHROMA(1, 0); \ PUTFUNC(1, 0, abase); \ \ @@ -237,7 +250,7 @@ const int *sws_getCoefficients(int colorspace) \ LOADCHROMA(1, 3); \ PUTFUNC(1, 3, abase); \ - ENDYUV2RGBLINE(dst_delta, 0, alpha, 1) \ + ENDYUV2RGBLINE(dst_delta, 0, alpha, 1, nb_dst_planes) \ LOADCHROMA(1, 0); \ PUTFUNC(1, 0, abase); \ \ @@ -249,7 +262,7 @@ const int *sws_getCoefficients(int colorspace) \ LOADCHROMA(1, 1); \ PUTFUNC(1, 1, abase); \ - ENDYUV2RGBLINE(dst_delta, 1, alpha, 1) \ + ENDYUV2RGBLINE(dst_delta, 1, alpha, 1, nb_dst_planes) \ LOADCHROMA(1, 0); \ PUTFUNC(1, 0, abase); \ \ @@ -258,7 +271,7 @@ const int *sws_getCoefficients(int colorspace) ENDYUV2RGBFUNC() #define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ - YUV2RGBFUNC(func_name, dst_type, 0, 0) \ + YUV2RGBFUNC(func_name, dst_type, 0, 0, 1) \ LOADDITHER \ \ LOADCHROMA(1, 0); \ @@ -276,7 +289,7 @@ const int *sws_getCoefficients(int colorspace) LOADCHROMA(1, 3); \ PUTFUNC(2, 3, 6 + 8); \ PUTFUNC(1, 3, 6); \ - ENDYUV2RGBLINE(dst_delta, 0, 0, 0) \ + ENDYUV2RGBLINE(dst_delta, 0, 0, 0, 1) \ LOADDITHER \ \ LOADCHROMA(1, 0); \ @@ -286,7 +299,7 @@ const int *sws_getCoefficients(int colorspace) LOADCHROMA(1, 1); \ PUTFUNC(2, 1, 2 + 8); \ PUTFUNC(1, 1, 2); \ - ENDYUV2RGBLINE(dst_delta, 1, 0, 0) \ + ENDYUV2RGBLINE(dst_delta, 1, 0, 0, 1) \ LOADDITHER \ \ LOADCHROMA(1, 0); \ @@ -295,7 +308,7 @@ const int *sws_getCoefficients(int colorspace) ENDYUV2RGBFUNC() #define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \ - YUV2RGBFUNC(func_name, dst_type, 0, 1) \ + YUV2RGBFUNC(func_name, dst_type, 0, 1, 1) \ LOADDITHER \ \ LOADCHROMA(1, 0); \ @@ -321,7 +334,7 @@ const int *sws_getCoefficients(int colorspace) \ LOADCHROMA(1, 3); \ PUTFUNC(1, 3, 6); \ - ENDYUV2RGBLINE(dst_delta, 0, 0, 1) \ + ENDYUV2RGBLINE(dst_delta, 0, 0, 1, 1) \ LOADDITHER \ \ LOADCHROMA(1, 0); \ @@ -335,7 +348,7 @@ const int *sws_getCoefficients(int colorspace) \ LOADCHROMA(1, 1); \ PUTFUNC(1, 1, 2); \ - ENDYUV2RGBLINE(dst_delta, 1, 0, 1) \ + ENDYUV2RGBLINE(dst_delta, 1, 0, 1, 1) \ LOADDITHER \ \ LOADCHROMA(1, 0); \ @@ -431,7 +444,7 @@ const int *sws_getCoefficients(int colorspace) g[Y + d64[1 + o]] + \ b[Y + d128[1 + o]]; -YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0) +YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0, 1) const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; char out_1 = 0, out_2 = 0; g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]; @@ -494,18 +507,18 @@ YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0) ENDYUV2RGBFUNC() // YUV420 -YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48) -YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48) -YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8) +YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48, 1) +YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48, 1) +YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8, 1) #if HAVE_BIGENDIAN -YUV420FUNC(yuva2argb_c, uint32_t, 1, 24, PUTRGBA, 8) -YUV420FUNC(yuva2rgba_c, uint32_t, 1, 0, PUTRGBA, 8) +YUV420FUNC(yuva2argb_c, uint32_t, 1, 24, PUTRGBA, 8, 1) +YUV420FUNC(yuva2rgba_c, uint32_t, 1, 0, PUTRGBA, 8, 1) #else -YUV420FUNC(yuva2rgba_c, uint32_t, 1, 24, PUTRGBA, 8) -YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8) +YUV420FUNC(yuva2rgba_c, uint32_t, 1, 24, PUTRGBA, 8, 1) +YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) #endif -YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24) -YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24) +YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1) +YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1) YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8) YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8) YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8) @@ -514,18 +527,18 @@ YUV420FUNC_DITHER(yuv2rgb_c_4_ordered_dither, uint8_t, LOADDITHER4D, PUTRGB4D YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) // YUV422 -YUV422FUNC(yuv422p_rgb48_c, uint8_t, 0, 0, PUTRGB48, 48) -YUV422FUNC(yuv422p_bgr48_c, uint8_t, 0, 0, PUTBGR48, 48) -YUV422FUNC(yuv422p_rgb32_c, uint32_t, 0, 0, PUTRGB, 8) +YUV422FUNC(yuv422p_rgb48_c, uint8_t, 0, 0, PUTRGB48, 48, 1) +YUV422FUNC(yuv422p_bgr48_c, uint8_t, 0, 0, PUTBGR48, 48, 1) +YUV422FUNC(yuv422p_rgb32_c, uint32_t, 0, 0, PUTRGB, 8, 1) #if HAVE_BIGENDIAN -YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 24, PUTRGBA, 8) -YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 0, PUTRGBA, 8) +YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 24, PUTRGBA, 8, 1) +YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 0, PUTRGBA, 8, 1) #else -YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 24, PUTRGBA, 8) -YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8) +YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 24, PUTRGBA, 8, 1) +YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) #endif -YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24) -YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24) +YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1) +YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1) YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8) YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8) YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8) From patchwork Tue Aug 6 10:51:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 50910 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp1955688vqb; Tue, 6 Aug 2024 03:51:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVGmt2fyTgxdrvCjAVmDyJGdbo8Es1W/CLctnbdo5sM7AWfAifOyr6FzqJU+7HpOuMQwsyQNwXv9FLlCmwZycB4kWAwccwyP0tSOw== X-Google-Smtp-Source: AGHT+IFGpIFL5VUon4JPdxuvRHtdp7QDBeVSDoSbSAtv7aN5d8DoItgnB/nzkK6Q4tfmPOrPOMc6 X-Received: by 2002:a05:6512:3d20:b0:52c:d76f:4604 with SMTP id 2adb3069b0e04-530bb3b4664mr11756667e87.46.1722941509954; Tue, 06 Aug 2024 03:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722941509; cv=none; d=google.com; s=arc-20160816; b=yzC6pGJLrfc6/++Ks0HZagnLYFYI49gieUTODlPuplZyMUl7grGCZUPn5vhvo6HyP2 Z0QgTkl1dsFHZM3/8BJh+syUnvcZq8wta4jkhiVURySfe18EvFX5yNbgS5coKZzJaD6C wh2AO4g9W7Rt+Js4OwXTeHepuwrV4nIZoLPJf0jSzbhku/u+cr9phk3vG6fZU5i/kKzF 9vOUVN4ERfebBIGZ/CgsW59C+8v7y8iX3LlLMzItaTC0IqyWBlFxzkeMWX8fzyD9qWpK 45826A1ob4dZQ26igtlOZvvMSuEQj3lV4Aa3/eXK9d2VVjbHR2L80vYJnFwc+HI6et+r izQQ== 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=J5LZee5z/nQ8fe/LgMzjAmsyiC8OdFP52k6NZ9tpLEA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=rn5Gk1tpX8FwCwZl+YFFOHR8VfiAcTSJ2jIzv96stOrjYfnTEO7Ub9vneGqT++ubLg aPVwm2QhEQ01B5SpLLIJUIOybaAnaQ4oWOLG6aRn12zuO2W0I+5S6L9l7tIrix7WRWkM BtV/aL/Mlt7C90dgpPE8nUOaJvzA8GfznNM6pjUvbtSBANqaY1NnX6Gb0+F5NODTsDYP /jOFTUxDAwcs9fKeoRZvzGE1EgvndMOwm9EhzXLeM7u6Tu0HxJnHaZzI8uIKr2mAyn40 9PJuNNcXtoZSvCXmW1MWwuFcSyjmebOXRiVwlMM1Kg8eME65yJFtNLYU47L4yBbyqmWJ q65A==; 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=NG82UyRq; 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-a7dc9f6cb84si521834566b.989.2024.08.06.03.51.49; Tue, 06 Aug 2024 03:51: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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=NG82UyRq; 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 01A3068D9E4; Tue, 6 Aug 2024 13:51:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B3AF68D9D3 for ; Tue, 6 Aug 2024 13:51:12 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so4496395e9.2 for ; Tue, 06 Aug 2024 03:51:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722941471; x=1723546271; 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=UmqfdaSy/9lolnBdSI0B1jLrbtBYUb5uCPsh1Ale2Kc=; b=NG82UyRqDy0JheV9MTk2hoSPsc5rWqMNs4rb+dyVOTky0j2k3mO1AK3UuT6K6F+wpH vDE03UIOFlQsZ2KvtidhvZFdKUmxMpz+GwczyxifK3mrCc+9G6gfayLwP46r6+LMVve9 GsqjHnOAAjo5Wocu31Emw1cXd/91ja3tLw1egJdajzZAKvpkxmWVv9OtIZRkOp/+f2EG EHEv9oFosEKh6S7/vn1E9cFEVdj/y8Jx/xjxWn1vo00rUYj8ul7G1IbKqTMzQ3YZ9odH j8idnismO/JR0Vu0pd9eGgyvg/gMdXue1OHpGhyWwb10iUphtSY8VE41O5F05XGuC76G TrHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722941471; x=1723546271; 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=UmqfdaSy/9lolnBdSI0B1jLrbtBYUb5uCPsh1Ale2Kc=; b=Hsdpm7KacWZ/7t30lG2j+AWq8VHWJjc6WQIqCJGDmBvrPokwVjk1j0oWUZPBSh+K7a KCcGKHD9Ne2m4JyNwUCgB9+/fdXo+b9T/fi35KqGc1KP7NuBrg5zygj8T33i8nW8r1An zLdKPnvatrAZkOa37pwXGnmtVI90/24Glv7j40wrNVxcW/ETw5+fWvP4X08G6FPvENzj 9+56KS4Ndji9U8kag+QBr6eot+Q35GEO25F+YI3cMMx1lUNLHQkrud3DCrdKd2RoeeXZ bHRBIP+3XcZXFIYXyWirDwni8yDIIt0vewzHjPT4nBOqdRgklQgfHIyJI1ULJ2VVYm6v w8zg== X-Gm-Message-State: AOJu0Yz9DjUKoH08kx/TlnlccNN5Vu7LjvYpn3Q72V4Y2qPq+NMcGLed Zo+HUAfD54+5My7peMWR/sVdW6YfUc97dIXaDy+CrsMoyR7e5OJHSQwlpZBh X-Received: by 2002:a05:600c:3504:b0:427:f196:c549 with SMTP id 5b1f17b1804b1-428e6b7e954mr138384985e9.23.1722941470822; Tue, 06 Aug 2024 03:51:10 -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.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 03:51:10 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Aug 2024 12:51:04 +0200 Message-Id: <20240806105106.59866-4-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 3/5] swscale/yuv2rgb: add 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: 5ztzn701ti87 --- libswscale/yuv2rgb.c | 16 ++++++++++ tests/checkasm/sw_yuv2rgb.c | 60 +++++++++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 31d10235ef..52fe2093e7 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -124,6 +124,16 @@ const int *sws_getCoefficients(int colorspace) dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y]; +#define PUTGBRP(l, i, abase) \ + Y = py_##l[2 * i]; \ + dst_##l [2 * i + 0] = g[Y]; \ + dst1_##l[2 * i + 0] = b[Y]; \ + dst2_##l[2 * i + 0] = r[Y]; \ + Y = py_##l[2 * i + 1]; \ + dst_##l [2 * i + 1] = g[Y]; \ + dst1_##l[2 * i + 1] = b[Y]; \ + dst2_##l[2 * i + 1] = r[Y]; + #define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \ static int func_name(SwsContext *c, const uint8_t *src[], \ int srcStride[], int srcSliceY, int srcSliceH, \ @@ -519,6 +529,7 @@ YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) #endif YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1) YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1) +YUV420FUNC(yuv420p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3) YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8) YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8) YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8) @@ -539,6 +550,7 @@ YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) #endif YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1) YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1) +YUV422FUNC(yuv422p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3) YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8) YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8) YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8) @@ -604,6 +616,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) return yuv422p_bgr4_byte; case AV_PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither; + case AV_PIX_FMT_GBRP: + return yuv422p_gbrp_c; } } else { switch (c->dstFormat) { @@ -644,6 +658,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) return yuv2rgb_c_4b_ordered_dither; case AV_PIX_FMT_MONOBLACK: return yuv2rgb_c_1_ordered_dither; + case AV_PIX_FMT_GBRP: + return yuv420p_gbrp_c; } } return NULL; diff --git a/tests/checkasm/sw_yuv2rgb.c b/tests/checkasm/sw_yuv2rgb.c index 02ed9a74d5..5125f83968 100644 --- a/tests/checkasm/sw_yuv2rgb.c +++ b/tests/checkasm/sw_yuv2rgb.c @@ -58,6 +58,7 @@ static const int dst_fmts[] = { // AV_PIX_FMT_RGB4_BYTE, // AV_PIX_FMT_BGR4_BYTE, // AV_PIX_FMT_MONOBLACK, + AV_PIX_FMT_GBRP, }; static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) @@ -116,13 +117,25 @@ static void check_yuv2rgb(int src_pix_fmt) LOCAL_ALIGNED_8(uint8_t, src_a, [MAX_LINE_SIZE * 2]); const uint8_t *src[4] = { src_y, src_u, src_v, src_a }; - LOCAL_ALIGNED_8(uint8_t, dst0_, [2 * MAX_LINE_SIZE * 6]); - uint8_t *dst0[4] = { dst0_ }; - uint8_t *lines0[2] = { dst0_, dst0_ + MAX_LINE_SIZE * 6 }; - - LOCAL_ALIGNED_8(uint8_t, dst1_, [2 * MAX_LINE_SIZE * 6]); - uint8_t *dst1[4] = { dst1_ }; - uint8_t *lines1[2] = { dst1_, dst1_ + MAX_LINE_SIZE * 6 }; + LOCAL_ALIGNED_8(uint8_t, dst0_0, [2 * MAX_LINE_SIZE * 6]); + LOCAL_ALIGNED_8(uint8_t, dst0_1, [2 * MAX_LINE_SIZE]); + LOCAL_ALIGNED_8(uint8_t, dst0_2, [2 * MAX_LINE_SIZE]); + uint8_t *dst0[4] = { dst0_0, dst0_1, dst0_2 }; + uint8_t *lines0[4][2] = { + { dst0_0, dst0_0 + MAX_LINE_SIZE * 6 }, + { dst0_1, dst0_1 + MAX_LINE_SIZE }, + { dst0_2, dst0_2 + MAX_LINE_SIZE } + }; + + LOCAL_ALIGNED_8(uint8_t, dst1_0, [2 * MAX_LINE_SIZE * 6]); + LOCAL_ALIGNED_8(uint8_t, dst1_1, [2 * MAX_LINE_SIZE]); + LOCAL_ALIGNED_8(uint8_t, dst1_2, [2 * MAX_LINE_SIZE]); + uint8_t *dst1[4] = { dst1_0, dst1_1, dst1_2 }; + uint8_t *lines1[4][2] = { + { dst1_0, dst1_0 + MAX_LINE_SIZE * 6 }, + { dst1_1, dst1_1 + MAX_LINE_SIZE }, + { dst1_2, dst1_2 + MAX_LINE_SIZE } + }; randomize_buffers(src_y, MAX_LINE_SIZE * 2); randomize_buffers(src_u, MAX_LINE_SIZE); @@ -145,7 +158,11 @@ static void check_yuv2rgb(int src_pix_fmt) width >> src_desc->log2_chroma_w, width, }; - int dstStride[4] = { MAX_LINE_SIZE * 6 }; + int dstStride[4] = { + MAX_LINE_SIZE * 6, + MAX_LINE_SIZE, + MAX_LINE_SIZE, + }; // override log level to prevent spamming of the message // "No accelerated colorspace conversion found from %s to %s" @@ -159,8 +176,14 @@ static void check_yuv2rgb(int src_pix_fmt) fail(); if (check_func(ctx->convert_unscaled, "%s_%s_%d", src_desc->name, dst_desc->name, width)) { - memset(dst0_, 0xFF, 2 * MAX_LINE_SIZE * 6); - memset(dst1_, 0xFF, 2 * MAX_LINE_SIZE * 6); + memset(dst0_0, 0xFF, 2 * MAX_LINE_SIZE * 6); + memset(dst1_0, 0xFF, 2 * MAX_LINE_SIZE * 6); + if (dst_pix_fmt == AV_PIX_FMT_GBRP) { + memset(dst0_1, 0xFF, MAX_LINE_SIZE); + memset(dst0_2, 0xFF, MAX_LINE_SIZE); + memset(dst1_1, 0xFF, MAX_LINE_SIZE); + memset(dst1_2, 0xFF, MAX_LINE_SIZE); + } call_ref(ctx, src, srcStride, srcSliceY, srcSliceH, dst0, dstStride); @@ -173,19 +196,24 @@ static void check_yuv2rgb(int src_pix_fmt) dst_pix_fmt == AV_PIX_FMT_BGRA || dst_pix_fmt == AV_PIX_FMT_RGB24 || dst_pix_fmt == AV_PIX_FMT_BGR24) { - if (cmp_off_by_n(lines0[0], lines1[0], width * sample_size, 3) || - cmp_off_by_n(lines0[1], lines1[1], width * sample_size, 3)) + if (cmp_off_by_n(lines0[0][0], lines1[0][0], width * sample_size, 3) || + cmp_off_by_n(lines0[0][1], lines1[0][1], width * sample_size, 3)) fail(); } else if (dst_pix_fmt == AV_PIX_FMT_RGB565 || dst_pix_fmt == AV_PIX_FMT_BGR565) { - if (cmp_565_by_n(lines0[0], lines1[0], width, 2) || - cmp_565_by_n(lines0[1], lines1[1], width, 2)) + if (cmp_565_by_n(lines0[0][0], lines1[0][0], width, 2) || + cmp_565_by_n(lines0[0][1], lines1[0][1], width, 2)) fail(); } else if (dst_pix_fmt == AV_PIX_FMT_RGB555 || dst_pix_fmt == AV_PIX_FMT_BGR555) { - if (cmp_555_by_n(lines0[0], lines1[0], width, 2) || - cmp_555_by_n(lines0[1], lines1[1], width, 2)) + if (cmp_555_by_n(lines0[0][0], lines1[0][0], width, 2) || + cmp_555_by_n(lines0[0][1], lines1[0][1], width, 2)) fail(); + } else if (dst_pix_fmt == AV_PIX_FMT_GBRP) { + for (int p = 0; p < 3; p++) + for (int l = 0; l < 2; l++) + if (cmp_off_by_n(lines0[p][l], lines1[p][l], width, 3)) + fail(); } else { fail(); } 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