diff --git a/libavfilter/vf_colorbalance.c b/libavfilter/vf_colorbalance.c index cc90dc08c78ef89b1883d264c7f026b6ff36f26d..6dc1b284831ee0d5c7ee1ce391d2d92a49808d27 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 f267da572e563dd6ed34b8f4b4f5a04549c98a26..15491fe6718d04636a6094144dc3feba400f15a7 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 a85dc388b0ed7b504f3781c7946ad44539c7c085..2d76c7d08d42a09db3d2ea1fe8675b03864617f1 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 d18fe5a466613444fab561cd860a66be1a958e31..2ab96ad70fa46e9d85f213bfa4235e73b7810cb4 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 254669ff88bac64e8ee35054f4af86c82bec2924..605860dee5a860c122ecb2845e7ef80ca187ec5d 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