From patchwork Thu Feb 8 19:07:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Connor Worley X-Patchwork-Id: 46115 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp480151pzc; Thu, 8 Feb 2024 11:07:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXJurPeI42ATsmw+UJbhL+dpr0BDTPAFIelJKsaFQBhzLksX6O8N9JftnWSGxLcLbbhzVFwJvuxzyrrRNIK3mSTJoar/dgBA2Ozeg== X-Google-Smtp-Source: AGHT+IHMAvE4lj6aHKzldizkieZZ0Vf18EbNsCb6N6qHM1UfF8mKZN5ES1ihO8NGW3nFwEZMvIUO X-Received: by 2002:a17:906:4910:b0:a38:2fba:f6d1 with SMTP id b16-20020a170906491000b00a382fbaf6d1mr181560ejq.18.1707419253928; Thu, 08 Feb 2024 11:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707419253; cv=none; d=google.com; s=arc-20160816; b=jxpV2mwRtHobMJAsOHQ8yY4tAGoRNVSq+KlRaAi9xXY6+aaWI8i8qo/Xj8/Gf0/D/R n7IxuExU0xSKK/oNYjphWenvzZsM3MbRg1B0AM1UiXJ0ijzdXYmdsN39/EG9zRPL1s2N FPUc0MzN3vmrAdSHPhgKfvpZHaNH0/NahEGsch1czVOtTGVqQy7x1btfWD6JORzaa1Lg TGGYJbLiAzM9U8PoQwHB+W2FIBAmJljssCsRWwbGLIey7OlrECSixdQ0z7uPmhUaC/Zn w/oIryBAuduH5iBcnveP1kyxKOVC1rYDFWndUwU3OEQW3S0V8L4zZqTftMiD+d7pS4HE odXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=jcheZ72RW7Mu1BzgmmmAcr2hmXZ0TB9+vGfIToxFRoY=; fh=TOwFuFP/bpvzKD6oEOhwkEFlgibVb7LMTMJTDLtDEI0=; b=jBHH7S6x3urFL0hXLHlBlUnTskC4QYGDvuaef79C7fcVhxwJzK1fHj3UNYbsuncw2D wf6VkGC4pQvRmvJpONICUuQ3jOnZ/k9KI4h0xpIcbyAbt+vDjug+lCzx9qtJn5FKgraZ 5/pF18P0C2yljzGTwlw4jbZrBUZEo+zVjJCyx9IBqpnsfCAxXpgY9IS0LfMYwmcT2Eo5 mlDM9uQh26NGBBb15pXdPnKUKkZ3HgVnfJ/Hc6j8cuPTmhOAa3TcIc5NeVGBdP2uUO+X R6AycjrSbQ2WlDyu3NfugrXS53Ewz52H9iyGj0GqP3nlMzFaeQ6JHGyRZI2z7qGTICdS uHGA==; 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=KZeW75CL; 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 X-Forwarded-Encrypted: i=1; AJvYcCWyv0tJTghEZ6Vng+0o59xhS34kukzSukThrGSezWnRee3+yCgYoAJJRlm8TGqQkdtBYcs9XzU9VohiU+FOFKipObva4+//3BPMpBwFCfErIiXITwe4MG6mqfJE0nuruLcJ6nqmHy7n88WMpcKbikhzK5YrAdbT+jUrRsupEW4ExAzJRKcvxxkzAC5qtXQQO2ASHX5oUYbFN9OPxoIn38O+2fwnSzTBnyoitVPbQedEZYNmm7xuB+C5A6m1N7FIGSoVHiMjCYpeW5TzILbIizQeqvIEeOTN0NqDrVQ7iUHZi94kg/E93OYy9XrkM52T73K3bHq3CHUIR/cFy+YhQ8MIXa/R1E74FvkIanyLmty+adqGHo2VhejX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bC/wW/RrIJaZKLviB1hVwv3HyyIL6KHwZOWGpYmKEU40sXuhyegY1VAlFB0HVDN3zfVte7LIF51j2AMPCWCsIIB9EIz02X9z39xJVCKyuyb4CEFMnVhRpZ3KWh16wT12fwsAheyd52tdcJbIePVdau5+buh1 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ci6-20020a170906c34600b00a37d4912630si305546ejb.1031.2024.02.08.11.07.33; Thu, 08 Feb 2024 11:07:33 -0800 (PST) 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=KZeW75CL; 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 A2F8468D169; Thu, 8 Feb 2024 21:07:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B54B68CA4C for ; Thu, 8 Feb 2024 21:07:24 +0200 (EET) Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1da0cd9c0e5so1547045ad.0 for ; Thu, 08 Feb 2024 11:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707419241; x=1708024041; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zHxe/mBEImWJqri+p9jKcsQv/sTpihCwgd2vLPldlfM=; b=KZeW75CLRtSpMkR3T0rPisBwzbe18o8cjrTrCzvOI+yWOMEfGJt4UhsNVEdhI5UCl7 XtBpecq4YyeTkLBZKOPGfCL5z8WNL69xhMqD12nDHbKUoUo3ttuA/47e60EbngDTb3ci 5QibMaEKyf/PrDHIefmu1+m2ch2W9Zd6FFUhaFdVvku9mGtwY0euuQoy5X2LiY5YoisG WrOW8n9IQtOzz/pBSEggKeMbEpGuR2Zy39BWNKdXeDUAXgV2qYnmXyrFmBiCIhRIFbGo 8c3UDrqt6z+ghsipTNWBHMOF8mBY8CVUKmnS1RbuaIcfxt1xbC+jxVslQjIsSkL15gW4 KTuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707419241; x=1708024041; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zHxe/mBEImWJqri+p9jKcsQv/sTpihCwgd2vLPldlfM=; b=LavSZCAiCDDi9uJjyG1koKgKZXMsl96Weau2mR9bdfvBEVJZwG6P+E0VetdoLzFrle jEaOarU8a2VYUsan+HbxVJZIMbnE3VqV4vK4dNpVq7hnIWY/UZo9D+LJVwyBSilySssv DEM3y0HrBhVP1xO2jBOPv9p5pI9G9UziZ/JG6f7br9kFH9DW8efFy5TQZW25VYj5blXv vwf0z2pGxMe9Yb2FHfkV2gZwwgnukHUxdG4ePTVUAioqIacc8w+OLxNLI4E8141weHOC qR4VzLWVhPX9qg1OQx7wMvMeTn9J9vcKbbCOxXXCPs/C+EsI68KyKZk12eiQPf1s/TxO 9Z8A== X-Gm-Message-State: AOJu0YzLPtVqtP2+ci752KFKpBaWqlZo7i7jH9o87VKUhihwvbBjQQSf opOqgEorrKIpe4w2q4Ku+CIlZ1pN+e8agV4N61pfRGrFwDeP86fi7tgTY+Sjyn8= X-Received: by 2002:a17:90a:77ca:b0:295:aaaa:74fe with SMTP id e10-20020a17090a77ca00b00295aaaa74femr745286pjs.14.1707419241239; Thu, 08 Feb 2024 11:07:21 -0800 (PST) Received: from localhost ([2601:647:4600:84e0:acc2:74e7:bab:f386]) by smtp.gmail.com with UTF8SMTPSA id ga3-20020a17090b038300b0028c89122f8asm126579pjb.6.2024.02.08.11.07.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Feb 2024 11:07:20 -0800 (PST) From: Connor Worley To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Feb 2024 11:07:08 -0800 Message-Id: <20240208190709.38110-1-connorbworley@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/2] lavc/texturedsp: fix premult2straight inversion 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 Cc: Connor Worley Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: hI19CPWEueeA This function should convert premultiplied alpha to straight, but does the opposite. Signed-off-by: Connor Worley --- libavcodec/texturedsp.c | 9 ++++++--- tests/ref/fate/dds-dxt2 | 2 +- tests/ref/fate/dds-dxt4 | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/texturedsp.c b/libavcodec/texturedsp.c index 5fb79937da..721bfc17f5 100644 --- a/libavcodec/texturedsp.c +++ b/libavcodec/texturedsp.c @@ -175,9 +175,12 @@ static av_always_inline void premult2straight(uint8_t *src) int b = src[2]; int a = src[3]; /* unchanged */ - src[0] = (uint8_t) r * a / 255; - src[1] = (uint8_t) g * a / 255; - src[2] = (uint8_t) b * a / 255; + if (a == 0) + return; + + src[0] = (uint8_t) FFMIN(r * 255 / a, 255); + src[1] = (uint8_t) FFMIN(g * 255 / a, 255); + src[2] = (uint8_t) FFMIN(b * 255 / a, 255); } /** diff --git a/tests/ref/fate/dds-dxt2 b/tests/ref/fate/dds-dxt2 index b5bdfbadc3..1744ef41f6 100644 --- a/tests/ref/fate/dds-dxt2 +++ b/tests/ref/fate/dds-dxt2 @@ -3,4 +3,4 @@ #codec_id 0: rawvideo #dimensions 0: 64x64 #sar 0: 0/1 -0, 0, 0, 1, 16384, 0x11cebeb0 +0, 0, 0, 1, 16384, 0xd7f7241b diff --git a/tests/ref/fate/dds-dxt4 b/tests/ref/fate/dds-dxt4 index 136dfd8006..f22878da56 100644 --- a/tests/ref/fate/dds-dxt4 +++ b/tests/ref/fate/dds-dxt4 @@ -3,4 +3,4 @@ #codec_id 0: rawvideo #dimensions 0: 64x64 #sar 0: 0/1 -0, 0, 0, 1, 16384, 0x31aaacd6 +0, 0, 0, 1, 16384, 0xf18d4216