From patchwork Mon Oct 7 12:29:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 52091 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp1888177vqg; Mon, 7 Oct 2024 05:30:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXNe1oOkCNWP/F9Q52fVXVr9QDhATq4b87GV6U54mgwfYXhuluTQqNIA1JE4iQVfxPjaF0sricu2spSz6VQcyoM@gmail.com X-Google-Smtp-Source: AGHT+IEYmcVn44pc3F40sxAz9N8gZYAf/OZUNvW4n7SJ4Gr8h/VvsArJdfUIC4BvAJ3FkDyzqaZV X-Received: by 2002:a05:6512:b96:b0:539:9527:3d59 with SMTP id 2adb3069b0e04-539ab9f0f7dmr5773314e87.52.1728304230463; Mon, 07 Oct 2024 05:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728304230; cv=none; d=google.com; s=arc-20240605; b=YTHRUvyoLb/A+15o4g2jcLbdIfzPGap7Qi2vYoADR90IQMnT6wDZdLjDMMlBcBc4LP cM03c7iuWMVwMArb89oxE+P1vntZTDtiPgMSsAPOyB2wrHdiVskBTMLN7kQr00Tj/hJK aFQIkARVBUCkZqr8LP2Js+VvOoJabVyZPxDKXjM4AjVijEUC3+BqPv3bdNshpk3+SaMo YoOcKvYt17rZkg5uEq7cnxBqyZBUr6b/QwiZIdCYndhEbfg0mFUoZ3YoiClie1fxUZ28 MXzFrpbG4AXZ4mhkKO9RHsiRQQJoNaz1B9LGhSsseVIZUgyTtkJF/c/2EUZa4AC+idrh 4tqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=EZiInfjGVEmRfMTQ5f7FHNnVDMjWHzDJPwfUE8VbA/4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=IexaVSVWlV8LlsIHRDBw8OirplUI+ZW5JW9YUvfeV6oEIpVeV9vNp39xQU1j9s9gps OKD25K77Eq0MXUMtl7lhzqSg2lZge0nQeImxHIspN/UWAadoTQEq+lyXt72N7ghDJzT8 /1ZgJqIPs23PTCOL2l2PIKvTgKFjJqOYFRxvFqneT5a4O2d2OB4/sONH3c+40d5xT2+R nYbWma2MCUiynH6iIJQPvmOn8nJ0iUh9z4N7RUKK0DxQsd0u/C3q5mKoCELkKv5zrdSR VcK3CM42PyhKHExgkE5eP5PPrRfWkNhala7ifLOCZbWA7L0BsClu6gBSdhwey6oUycPy 7vfQ==; 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="MnaCi7/q"; 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 2adb3069b0e04-539afec2eb1si1881887e87.106.2024.10.07.05.30.28; Mon, 07 Oct 2024 05:30:30 -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="MnaCi7/q"; 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 7BC6D68D786; Mon, 7 Oct 2024 15:30:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2049068CB23 for ; Mon, 7 Oct 2024 15:30:17 +0300 (EEST) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-71de9e1f431so2109033b3a.3 for ; Mon, 07 Oct 2024 05:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728304214; x=1728909014; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=12VaKCQsXoUO9BdQfUfjdddYbN79xbFXM9RYWCQV7ic=; b=MnaCi7/q+djT2ObhWno/68abHfFU+FOPPwGZP8f/A8edcD2x7mbwJ1x2Lu9XW6x2a7 fVCrcvp1lnKf9XpAjUApWz9Rfb9otw3Ml2t4e0QGZcFmYV0pCEmnWi9W0LctOQnCYGdg HPc0MPt0FaRhfyCrQEmmjqCyK0fYECsRTtJAh07nOAyFKB5WGwaaefq0nHeVrmx4F6dQ 315LCLn9eKGv6hY6HftVN7AvjTL+nZxl0YUc/YDJUmg1lZnxwfmYRvO77yWVmHiYNX2n 853BgjuuZdzsUUx6BSnGoXa0AiQ2WYGKwURS/Bih80Qfd+kxgYVlazQwwZUwCIglLo9p Fs6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304214; x=1728909014; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=12VaKCQsXoUO9BdQfUfjdddYbN79xbFXM9RYWCQV7ic=; b=X4Ktwn7qYhDPHQ0UDjCiIXPnXca5fjDlrqqL77LVul+nl8r8ENi+zx98lR6Sn1fvCO BDL3S3WG88nbICbS7Fp/1hXXC1uU4nfizEJEcJUfTf+lOmrL9wfvSecspoCPO5Qufd0R YIZ9rpMLXvKEqTqXrE/FEEDy+Jn3MeTdoQhK9MGFPKEOT5AAzkcTgBci9y4Aqhhj0ZOO TXNWgF7iQl5rGlHJUY18A9HI2flEZXm2GGNcH11ItpOzaz3ZVF/qlkv5LqK2d8eJYkUd KchohRY2B1TF0+4W0pmd9mVcri7FJtlBGd324vsKMEaDViVLu5yqPClTZpfW3w3wkc+B 7afA== X-Gm-Message-State: AOJu0YxijaXmF+ay2DJbFAnK3oTDuotozHYJTvFFpNbSpsyl+YDPa0lz tccup10lFhIDw9PfPNfCAPTGZ9slsgCzDuOwIa+6fAHYFMt9a1eshLypyQ== X-Received: by 2002:a05:6a20:6f07:b0:1d2:f0e2:4ad6 with SMTP id adf61e73a8af0-1d6dfa3b314mr15716104637.18.1728304214074; Mon, 07 Oct 2024 05:30:14 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0cbd8ecsm4267869b3a.25.2024.10.07.05.30.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:30:13 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Oct 2024 09:29:36 -0300 Message-ID: <20241007122955.309-1-jamrial@gmail.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/20] swscale/output: add missing yuv2packed1 and yuv2packed2 support for VUY{X, A} 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: vc2ShGw4G+Nl Signed-off-by: James Almer --- FATE tests don't seem to trigger this. libswscale/output.c | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/libswscale/output.c b/libswscale/output.c index 31921a3cce..e5d555f76f 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2668,6 +2668,110 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter, } } +static void +yuv2vuyX_1_c(SwsContext *c, const int16_t *buf0, + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf0, uint8_t *dest, int dstW, + int uvalpha, int y) +{ + int hasAlpha = !!abuf0; + int i; + + if (uvalpha < 2048) { + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] + 64) >> 7; + int U = (ubuf[0][i] + 64) >> 7; + int V = (vbuf[0][i] + 64) >> 7; + int A = 255; + + if (Y & 0x100) + Y = av_clip_uint8(Y); + if (U & 0x100) + U = av_clip_uint8(U); + if (V & 0x100) + V = av_clip_uint8(V); + + if (hasAlpha) { + A = (abuf0[i] + 64) >> 7; + if (A & 0x100) + A = av_clip_uint8(A); + } + + dest[i * 2 ] = Y; + dest[i * 2 + 1] = A; + } + } else { + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] + 64) >> 7; + int U = (ubuf[0][i] + ubuf[1][i] + 128) >> 8; + int V = (vbuf[0][i] + vbuf[1][i] + 128) >> 8; + int A = 255; + + if (Y & 0x100) + Y = av_clip_uint8(Y); + if (U & 0x100) + U = av_clip_uint8(U); + if (V & 0x100) + V = av_clip_uint8(V); + + if (hasAlpha) { + A = (abuf0[i] + 64) >> 7; + if (A & 0x100) + A = av_clip_uint8(A); + } + + dest[4 * i ] = V; + dest[4 * i + 1] = U; + dest[4 * i + 2] = Y; + dest[4 * i + 3] = A; + } + } +} + +static void +yuv2vuyX_2_c(SwsContext *c, const int16_t *buf[2], + const int16_t *ubuf[2], const int16_t *vbuf[2], + const int16_t *abuf[2], uint8_t *dest, int dstW, + int yalpha, int uvalpha, int y) +{ + int hasAlpha = abuf && abuf[0] && abuf[1]; + const int16_t *buf0 = buf[0], *buf1 = buf[1], + *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], + *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], + *abuf0 = hasAlpha ? abuf[0] : NULL, + *abuf1 = hasAlpha ? abuf[1] : NULL; + int yalpha1 = 4096 - yalpha; + int uvalpha1 = 4096 - uvalpha; + int i; + + av_assert2(yalpha <= 4096U); + av_assert2(uvalpha <= 4096U); + + for (i = 0; i < dstW; i++) { + int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19; + int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19; + int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19; + int A = 255; + + if (Y & 0x100) + Y = av_clip_uint8(Y); + if (U & 0x100) + U = av_clip_uint8(U); + if (V & 0x100) + V = av_clip_uint8(V); + + if (hasAlpha) { + A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 19; + A = av_clip_uint8(A); + } + + dest[4 * i ] = V; + dest[4 * i + 1] = U; + dest[4 * i + 2] = Y; + dest[4 * i + 3] = A; + } +} + static void yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, @@ -3275,6 +3379,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, break; case AV_PIX_FMT_VUYA: case AV_PIX_FMT_VUYX: + *yuv2packed1 = yuv2vuyX_1_c; + *yuv2packed2 = yuv2vuyX_2_c; *yuv2packedX = yuv2vuyX_X_c; break; case AV_PIX_FMT_XV30LE: