From patchwork Thu Jul 2 01:20:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 20772 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9A8D544B1F8 for ; Thu, 2 Jul 2020 04:42:59 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 69628688060; Thu, 2 Jul 2020 04:42:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0309B688060 for ; Thu, 2 Jul 2020 04:42:52 +0300 (EEST) Received: by mail-oi1-f193.google.com with SMTP id t4so4518617oij.9 for ; Wed, 01 Jul 2020 18:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lWG0A3cP1zkR22R7KcpRw+iIKXTLn5NVI3ekYlBF9hw=; b=q+NiIRpfQLuDkAr/xH2lqKwLiwGOxKf+kNuT4u8PY2AMZptxIHnrkrauvPZHiZizpG nGjjFjXQSxugsrSvL+aX1yyJMvtk0xB5ZSVSP++rlvm5Yao4/MLIeNkd45bOVP8m5osV 6k/58sqApQz/9rDN3WvwFK/RzVW4i831s+6EjJKfWWPPfpV6zzLh0FN4QUWcYL0RJiiD Zcs0VVo0E8MOwf/N++VbOROFLbVmNa0fEXkEEK3bpamZ1NED0qg2QzidrspJgjoqcPyW nu4N4/YDMxZ+DzviJ0G4NUVhYRG6ULyvyLK+dxYVYjiuqY6NgH4+bX4uZi0S3Jl/X4Xp p+BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lWG0A3cP1zkR22R7KcpRw+iIKXTLn5NVI3ekYlBF9hw=; b=IgrFae1w0PATpNIEGAt4U0O9Mc4EzfF4bzwHUnJQYfrjF9YRhuhU+We5AaMD2hCje1 JyT1V8OVof8m3tyRwTniAbTJ8OXMDfLOmPkekxwL+TO0chEacofZe2mNbn8+OIvZ8geA Wrbd/V2F0KQupR/3iY9rkRKV94ODY+K3VQk/Wy6iJ8vzFXWzFAoQtp2MVfEyBElnn3zq 5Yy7ZQQyNOrYvJBIgwc04o5bOFR83mZaRek0rZgf8f9Y551t3kkpOcooMKyWtn2rTqZA zD1JC/L0sfk9KGhSC0//gfGSypivNlUg+xUxPkxvpJmcPw7TaX7tf/1J2RAk93QA5VsS 3FkQ== X-Gm-Message-State: AOAM532D1oQ5GNtNUCLqFmJJosv9f15dW6pl8VqZgCPp/gBe0UGbk5F2 22ZHVoftxk7iWqdVE5n8osbWpg0m X-Google-Smtp-Source: ABdhPJwGrFP0yFEt44UUotNv46PMJEGpE57l2U/Sb2540eeU8VB+bJ3qCOI9xMZ1W2tx1bgmLg3cqA== X-Received: by 2002:a17:90a:ad02:: with SMTP id r2mr2501212pjq.74.1593652818751; Wed, 01 Jul 2020 18:20:18 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id x69sm7126887pfc.144.2020.07.01.18.20.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2020 18:20:17 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Jul 2020 09:20:12 +0800 Message-Id: <1593652812-9277-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH] FATE: fix colorbalance fate test failed on x86_32 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang floating point precision will cause rgb*max generate different value on x86_32 and x86_64. have pass fate test on x86_32 and x86_64 by using lrintf to get the nearest integral value for rgb * max before av_clip. Signed-off-by: Limin Wang --- libavfilter/vf_colorbalance.c | 24 ++++++++++----------- tests/ref/fate/filter-colorbalance | 6 +++--- tests/ref/fate/filter-colorbalance-gbrap | 6 +++--- tests/ref/fate/filter-colorbalance-gbrap-16 | 6 +++--- tests/ref/fate/filter-colorbalance-rgba64 | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libavfilter/vf_colorbalance.c b/libavfilter/vf_colorbalance.c index cc90dc08c7..6dc1b28483 100644 --- a/libavfilter/vf_colorbalance.c +++ b/libavfilter/vf_colorbalance.c @@ -188,9 +188,9 @@ static int color_balance8_p(AVFilterContext *ctx, void *arg, int jobnr, int nb_j if (s->preserve_lightness) preservel(&r, &g, &b, l); - dstr[j] = av_clip_uint8(r * max); - dstg[j] = av_clip_uint8(g * max); - dstb[j] = av_clip_uint8(b * max); + dstr[j] = av_clip_uint8(lrintf(r * max)); + dstg[j] = av_clip_uint8(lrintf(g * max)); + dstb[j] = av_clip_uint8(lrintf(b * max)); if (in != out && out->linesize[3]) dsta[j] = srca[j]; } @@ -242,9 +242,9 @@ static int color_balance16_p(AVFilterContext *ctx, void *arg, int jobnr, int nb_ if (s->preserve_lightness) preservel(&r, &g, &b, l); - dstr[j] = av_clip_uintp2_c(r * max, depth); - dstg[j] = av_clip_uintp2_c(g * max, depth); - dstb[j] = av_clip_uintp2_c(b * max, depth); + dstr[j] = av_clip_uintp2_c(lrintf(r * max), depth); + dstg[j] = av_clip_uintp2_c(lrintf(g * max), depth); + dstb[j] = av_clip_uintp2_c(lrintf(b * max), depth); if (in != out && out->linesize[3]) dsta[j] = srca[j]; } @@ -299,9 +299,9 @@ static int color_balance8(AVFilterContext *ctx, void *arg, int jobnr, int nb_job if (s->preserve_lightness) preservel(&r, &g, &b, l); - dst[j + roffset] = av_clip_uint8(r * max); - dst[j + goffset] = av_clip_uint8(g * max); - dst[j + boffset] = av_clip_uint8(b * max); + dst[j + roffset] = av_clip_uint8(lrintf(r * max)); + dst[j + goffset] = av_clip_uint8(lrintf(g * max)); + dst[j + boffset] = av_clip_uint8(lrintf(b * max)); if (in != out && step == 4) dst[j + aoffset] = src[j + aoffset]; } @@ -351,9 +351,9 @@ static int color_balance16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo if (s->preserve_lightness) preservel(&r, &g, &b, l); - dst[j + roffset] = av_clip_uintp2_c(r * max, depth); - dst[j + goffset] = av_clip_uintp2_c(g * max, depth); - dst[j + boffset] = av_clip_uintp2_c(b * max, depth); + dst[j + roffset] = av_clip_uintp2_c(lrintf(r * max), depth); + dst[j + goffset] = av_clip_uintp2_c(lrintf(g * max), depth); + dst[j + boffset] = av_clip_uintp2_c(lrintf(b * max), depth); if (in != out && step == 4) dst[j + aoffset] = src[j + aoffset]; } diff --git a/tests/ref/fate/filter-colorbalance b/tests/ref/fate/filter-colorbalance index f267da572e..15491fe671 100644 --- a/tests/ref/fate/filter-colorbalance +++ b/tests/ref/fate/filter-colorbalance @@ -3,6 +3,6 @@ #codec_id 0: rawvideo #dimensions 0: 352x288 #sar 0: 0/1 -0, 0, 0, 1, 304128, 0xd50c9fea -0, 1, 1, 1, 304128, 0xdf9e1f79 -0, 2, 2, 1, 304128, 0x9b84087e +0, 0, 0, 1, 304128, 0xf68fadfd +0, 1, 1, 1, 304128, 0xa6302d9a +0, 2, 2, 1, 304128, 0x758d165a diff --git a/tests/ref/fate/filter-colorbalance-gbrap b/tests/ref/fate/filter-colorbalance-gbrap index a85dc388b0..2d76c7d08d 100644 --- a/tests/ref/fate/filter-colorbalance-gbrap +++ b/tests/ref/fate/filter-colorbalance-gbrap @@ -3,6 +3,6 @@ #codec_id 0: rawvideo #dimensions 0: 352x288 #sar 0: 0/1 -0, 0, 0, 1, 405504, 0xd33217e5 -0, 1, 1, 1, 405504, 0x08f161af -0, 2, 2, 1, 405504, 0x27508654 +0, 0, 0, 1, 405504, 0xdcc71df0 +0, 1, 1, 1, 405504, 0x48d56675 +0, 2, 2, 1, 405504, 0x68058bf0 diff --git a/tests/ref/fate/filter-colorbalance-gbrap-16 b/tests/ref/fate/filter-colorbalance-gbrap-16 index d18fe5a466..2ab96ad70f 100644 --- a/tests/ref/fate/filter-colorbalance-gbrap-16 +++ b/tests/ref/fate/filter-colorbalance-gbrap-16 @@ -3,6 +3,6 @@ #codec_id 0: rawvideo #dimensions 0: 352x288 #sar 0: 0/1 -0, 0, 0, 1, 405504, 0x2e44c4b0 -0, 1, 1, 1, 405504, 0xf47244e0 -0, 2, 2, 1, 405504, 0x040769dd +0, 0, 0, 1, 405504, 0xa497ca1b +0, 1, 1, 1, 405504, 0x92c24b0e +0, 2, 2, 1, 405504, 0x965270bd diff --git a/tests/ref/fate/filter-colorbalance-rgba64 b/tests/ref/fate/filter-colorbalance-rgba64 index 254669ff88..605860dee5 100644 --- a/tests/ref/fate/filter-colorbalance-rgba64 +++ b/tests/ref/fate/filter-colorbalance-rgba64 @@ -3,6 +3,6 @@ #codec_id 0: rawvideo #dimensions 0: 352x288 #sar 0: 0/1 -0, 0, 0, 1, 811008, 0x42e5db8b -0, 1, 1, 1, 811008, 0x31be5974 -0, 2, 2, 1, 811008, 0xdef21287 +0, 0, 0, 1, 811008, 0xc5f7e6ba +0, 1, 1, 1, 811008, 0x266955bf +0, 2, 2, 1, 811008, 0x55360c6e