From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 3114E49389 for ; Thu, 8 Feb 2024 19:07:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 716FE68D164; Thu, 8 Feb 2024 21:07:30 +0200 (EET) 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-Google-Smtp-Source: AGHT+IEVMnmsr1OGqVA7p29QAtkrmo3Yd2cXPuUxsFWZFOHK6OoIWKpzl1wMg/27LBPqVLGp/7XnGg== 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".