summaryrefslogtreecommitdiff
path: root/libavfilter/vf_colorbalance.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2020-07-01 20:57:58 +0800
committerLimin Wang <lance.lmwang@gmail.com>2020-07-02 21:12:37 +0800
commit49054fe94c2f36881f63d15eca6e4bfb7f71b8ce (patch)
treef49b31de5afe49025ab3ab326732442192b270e1 /libavfilter/vf_colorbalance.c
parentc367d14d0a5d4ce1c007f636ba85681915fd5f79 (diff)
FATE: fix colorbalance fate test failed on x86_32
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. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavfilter/vf_colorbalance.c')
-rw-r--r--libavfilter/vf_colorbalance.c24
1 files changed, 12 insertions, 12 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];
}