From patchwork Tue Jul 23 12:46: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: 50709 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:a742:0:b0:482:c625:d099 with SMTP id f2csp2600746vqm; Tue, 23 Jul 2024 05:46:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVa8ZtJu58fDIUVUqLwqFd42zXX50aJgCYkgel3gJpexM3sc+saRvQ3ZVaNt3zTtCNoJtAwCDBISr2BKXCBweBLkhV7zJjO4aLlBg== X-Google-Smtp-Source: AGHT+IGSS1TI0+kCeIMH7jJhtyEN0Z8ISamwz4irkx0+MvbO3U5azbiptiql7vNOBCItndtsygbn X-Received: by 2002:a17:907:3ea1:b0:a77:dbf0:d22 with SMTP id a640c23a62f3a-a7a4c580e93mr718806866b.65.1721738791159; Tue, 23 Jul 2024 05:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721738791; cv=none; d=google.com; s=arc-20160816; b=MhYICltQ41ZOqXxvZN6S4/+IZA8VqkWcHAVubNWcCSJyyYy/HEtX/pd5WnvPaOT359 qNYAngmF6Nm7Us4TrnJyycNylIEoEVcURuYAm3oegdEz5wGCEAkHUsy5SnwTmxpAKSyl rJSbAkDn6xpA/4SMrB1veLlmuBrcW144kRULPvDzmepeKLn4/sQBsy40O2LThDvAvVce BO0KGbauSLhq24e2TgN4D2AxDUi4ounnVcIYneeHGbkq+5h4Y9oYOry9LV/8mDRj5iUA DingMlncxta8mKnXFTGGOVHtSZEDq1K+09ynCD5pC/c72WExnIeIfni7rETI6uWWqRUy ccEw== 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=34J8bftyIa9ct8ymiwhpfw5/JMllkBJ97RVszPsR8i0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=x2NL1GVgGr2IY5gRr4DKFGVjSikLOUhHK+a+ybCERmiEXsYRR4loE0zruvoSSD7GsI eNFpF9SKkBPe7ReJFBUsMXSD26CFbiUjjT/uVyZy4VeL0i3QdavMVvkbMZgNLm6QsuBW D8aV7L02ZEFUc01jW0bE1ItIqO6C7sHJl6I3IV8WNJ4b6EbSitbK4dVwQ9z9xzw2Ul93 x8AZ9lw4LBq7wfkuaWFNmm76CpgJ/ok332OPnjenUNgXiEEm/Yx+e48ZRWa/KvAj2J+9 Kph1+tTpEQeeas0AsIR8dA+uksHiE27oGT/M4M+hUWNoGyc3MHmR+VPw43s87KkLMYNd T6ow==; 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="P/vKTLhq"; 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-a7aa0472fd4si58128766b.742.2024.07.23.05.46.30; Tue, 23 Jul 2024 05:46: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="P/vKTLhq"; 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 B2A6168D559; Tue, 23 Jul 2024 15:46:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10C5E68D4AE for ; Tue, 23 Jul 2024 15:46:10 +0300 (EEST) Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so2115143f8f.3 for ; Tue, 23 Jul 2024 05:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721738769; x=1722343569; 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=nqicMMi2T8BVx56JvYLHaakJXMZCAREEenO6cMZojmY=; b=P/vKTLhqbUxXKqkBqSjSIWlEil+awlYjjK2P12aVtKzqjFu5pV+gZKUkMTnI8JAFYz 5uJKOJmgOFca7DqsnEUwQZTpWtzoeG/TETgmtkP3yEa6hZLavrdLiRrdaRTuOJ9CrcBO zF2qwsLv9NjNi0IZcd5IjkZccJRJODK2sLxHZcWxlSi6IqOR9//lwHFbxRbWlBSXtaWO ILzIiPO4EehbpRmza+vXMZ0kS6E85nbm2k5/VSsJpwVnLy3wNqz+0gq3i1EL9gB/jkei BOTbux0h4L8n3uwmVCM2pysN/AsaNvaCzhqi2uxOrpcjqHXTTu26NQB3H7xSxwYav/TY Sr5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721738769; x=1722343569; 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=nqicMMi2T8BVx56JvYLHaakJXMZCAREEenO6cMZojmY=; b=h6J7IFBirgxA7vM5YmKzqJnGwgrWYVXqgtX/BeoTyxgA3FMp45x9Lb4fqVsm/9O10m cajo50Of4zcVmlEKRbvqJKRG+jNlDwr3K7TKfQoVDsSULoGIZCIv3sU/IlVJzcPnOyN9 ErMJNRsWnRhF+Vn1Yk8vjM07Jtbwr3eyFfi/N1cobPGjquKCccmch3NK0Sp8KtraKC/X e/3vZsnv9lsH1AERggOQY3z/uYf89+pwoZ2Ej4yzIUxYNYGGFw7JEzsbQ2Y0QGVfZ89J rbEqRv5cqWCiINLhVEVXLI3haa5Rm5u/3nNL/S6MdOekTlEhDw/IfkB27fdbGS2mib3+ WQVA== X-Gm-Message-State: AOJu0Yx8x4jJk+vaB+E1GmzAqBNMUUwK3eKLFbf99De6sY8yfYcdy4xX Ft5cdEJMegjZNORC3o5ZLuFTuOt7nR0K9tQAkqdb06LscGpA/u6Tlx0/+lHs X-Received: by 2002:a5d:59a4:0:b0:368:785f:b790 with SMTP id ffacd0b85a97d-369bbbb2eddmr7956401f8f.1.1721738768899; Tue, 23 Jul 2024 05:46:08 -0700 (PDT) Received: from localhost.localdomain (232.39-67-87.adsl-dyn.isp.belgacom.be. [87.67.39.232]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787cee03sm11493779f8f.76.2024.07.23.05.46.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 05:46:08 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 Jul 2024 14:46:04 +0200 Message-Id: <20240723124606.107774-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240723124606.107774-1-ramiro.polla@gmail.com> References: <20240723124606.107774-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] 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: uDCCsSmmsd3E --- 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 c283d6d1bd..3a41c4eba6 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -124,6 +124,16 @@ const int *sws_getCoefficients(int colorspace) dst_p[0][l][12 * i + 8] = dst_p[0][l][12 * i + 9] = g[Y]; \ dst_p[0][l][12 * i + 10] = dst_p[0][l][12 * i + 11] = r[Y]; +#define PUTGBRP(l, src, asrc, i, abase) \ + Y = src[2 * i]; \ + dst_p[0][l][2 * i + 0] = g[Y]; \ + dst_p[1][l][2 * i + 0] = b[Y]; \ + dst_p[2][l][2 * i + 0] = r[Y]; \ + Y = src[2 * i + 1]; \ + dst_p[0][l][2 * i + 1] = g[Y]; \ + dst_p[1][l][2 * i + 1] = b[Y]; \ + dst_p[2][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, \ @@ -511,6 +521,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, 4) 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) @@ -531,6 +542,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, 4) 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) @@ -596,6 +608,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) { @@ -636,6 +650,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(); }