From patchwork Wed Jan 12 14:30:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 33277 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp4683766iog; Wed, 12 Jan 2022 06:31:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEiyQsp7IswpVr4uv4jZg46k7B2HCm6ppcynDsHbEwsJHuAzcYED3pjCUo35LbcU31pCmT X-Received: by 2002:a05:6402:3490:: with SMTP id v16mr9313956edc.398.1641997867579; Wed, 12 Jan 2022 06:31:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641997867; cv=none; d=google.com; s=arc-20160816; b=tuwSF0MN1riKGo4QBueyprXTLZC1fErLoqM928vXFF3PqDFyFVgIUEu9hFGF6asmzr +3eSyAjSWLzfH9dMYQYbpv0AfL+zfwD8JHgPhoyJlB/2mksS5kFwwEwUouXFNrzeYyou KtVOmmhLSMH2yfvurzUkAbo7tengj5pMe+eLL799jkAdeqPaCRsa2SQ15Q0Y89E/oVt0 D8QO/U8hULkCQTfaOUhiWGQwLhMiWyUNx6COrV5F1f44xDIxo1r3hA6MSOXzhOHmIhmj o/w5GXubYyTqlWsbZURmQ5eRgRJoT9iTEkz28UjrojRlQsA8PT3q6/axnKG60OQ8L1FQ lldA== 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=i68wB+Pc/5Ar7q77tduCWYZ/eFPsz+IBdf4p5C3JrbE=; b=AoFieQYufwmy5kqa4JrR+MoMjmxamFfIKphK2oDfeuZ989kdbqV5OboZE1A48ahGfc QRpUcwkzi27u4aiqm3LL0e3m2UkoGWWjp3mICgq89gC/+ZUN4KaChErwrZvMnyTBOARz J1J9/yjygUyzpBUHCz7DzdLdrUM/f9LwTq36nrbBGtv55wmP/BMyYE1FbHwmLCCCh1Bd 1bVLBIus+NAo0SHqBLOShrXXpssOeVWJRAcz4aQbfDF9lkdf8/e9GQVwPduRzSHcBk6T Pq01IeXG6dsNQMRPrAmC6D+H7NdCIvuMZIxF4zZJpggzJiO3a6NUjJ7hm7wB8axxVGKz iNmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=S09F4DyD; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g1si5544054ejt.939.2022.01.12.06.31.07; Wed, 12 Jan 2022 06:31:07 -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=20210112 header.b=S09F4DyD; 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 671C068AC54; Wed, 12 Jan 2022 16:31:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2A9C668A8E6 for ; Wed, 12 Jan 2022 16:30:58 +0200 (EET) Received: by mail-wm1-f42.google.com with SMTP id c66so1727450wma.5 for ; Wed, 12 Jan 2022 06:30:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9UlOMaj0gh9VZfkrZvP5b1Y40WeFEj+jqmyt4FnNHOg=; b=S09F4DyDNXv0DLbtVWLBESOSPoZ5BaliwaDdPT4bBeQBHBbbBuuYs6R7jqdTKjiJ1W sD32GpEoKqmZgYPg3eNiI8MEg5sTgp75rvPywC68FdyLYLKmo15qyYYC31Ys0daZsDD4 wcfRyUSBXRfYME8ZHscLPRfpm299p/Jpvfd7IFFWM/h5uh5CdchSRCKAcGbZr5HgC4bt P1XZmzjRV3BNXIPCxGZLikMbRJXni74qo1wIDvwn/4XCAGx/UhM5kVV6889SjftWcyUg DvoIkfzKtAFjdlGQHxrqaQysVQ9klrICAiZHZ/HapkvyM+HocCI0VUjceAADTWWNv1Je XTCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9UlOMaj0gh9VZfkrZvP5b1Y40WeFEj+jqmyt4FnNHOg=; b=yZif7AYvM36tYoPHkj/XFWHdDycJmXLiv3vbZ260v19USX82Snu9Amk22rjblodMGb rN07t008oY3pTk/lMH2ZMp1IzUHFY2MICLUGbFqiRu1PbmK4UL1b45XG7/dCBVpM7I/Y g0VWSdfB9JhUKZwKTxdR1SYoHzCyCUe0EI3nR21EHBGaofPsso+2uTgFNdYduOFt59O3 QrI6VQ0e1XTZ969ZJWh/qVO+b9zHrYSsc76rbq7PEKtGGo1CnCLAjl3WrVr//f4Dwfbc 1czJFBo9iAO2d6pqgdt8BPd/+EmZx1JNsayCylql5X4x1taOWr7ZW8n1uyGX+eMcl4VR ADaQ== X-Gm-Message-State: AOAM53306vauRPZwEyutWg3Lssr3WVU9wuUqYpCOMjXhG82EYBhwD3yG LUNS/iGmn8FFb9+EqGCJH0KnTMEPD9WyQw== X-Received: by 2002:a1c:7517:: with SMTP id o23mr7044172wmc.120.1641997857530; Wed, 12 Jan 2022 06:30:57 -0800 (PST) Received: from localhost.localdomain ([2001:b07:a11:213c:909b:111e:6742:9e0d]) by smtp.gmail.com with ESMTPSA id a2sm85380wri.17.2022.01.12.06.30.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jan 2022 06:30:57 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 15:30:55 +0100 Message-Id: <20220112143055.62347-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] vf_tonemap: Fix order of planes 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: v6UjEvBFYHy5 This resulted in a dimmed tonemapping due to bad resulting luma calculation. Found by: Derek Buitenhuis Signed-off-by: Vittorio Giovara --- libavfilter/vf_tonemap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c index 363df8034b..1285dbaa4d 100644 --- a/libavfilter/vf_tonemap.c +++ b/libavfilter/vf_tonemap.c @@ -119,18 +119,19 @@ static float mobius(float in, float j, double peak) static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in, const AVPixFmtDescriptor *desc, int x, int y, double peak) { - const float *r_in = (const float *)(in->data[0] + x * desc->comp[0].step + y * in->linesize[0]); - const float *b_in = (const float *)(in->data[1] + x * desc->comp[1].step + y * in->linesize[1]); - const float *g_in = (const float *)(in->data[2] + x * desc->comp[2].step + y * in->linesize[2]); - float *r_out = (float *)(out->data[0] + x * desc->comp[0].step + y * out->linesize[0]); - float *b_out = (float *)(out->data[1] + x * desc->comp[1].step + y * out->linesize[1]); - float *g_out = (float *)(out->data[2] + x * desc->comp[2].step + y * out->linesize[2]); + int map[3] = { desc->comp[0].plane, desc->comp[1].plane, desc->comp[2].plane }; + const float *r_in = (const float *)(in->data[map[0]] + x * desc->comp[map[0]].step + y * in->linesize[map[0]]); + const float *g_in = (const float *)(in->data[map[1]] + x * desc->comp[map[1]].step + y * in->linesize[map[1]]); + const float *b_in = (const float *)(in->data[map[2]] + x * desc->comp[map[2]].step + y * in->linesize[map[2]]); + float *r_out = (float *)(out->data[map[0]] + x * desc->comp[map[0]].step + y * out->linesize[map[0]]); + float *g_out = (float *)(out->data[map[1]] + x * desc->comp[map[1]].step + y * out->linesize[map[1]]); + float *b_out = (float *)(out->data[map[2]] + x * desc->comp[map[2]].step + y * out->linesize[map[2]]); float sig, sig_orig; /* load values */ *r_out = *r_in; - *b_out = *b_in; *g_out = *g_in; + *b_out = *b_in; /* desaturate to prevent unnatural colors */ if (s->desat > 0) {