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.
Showing the changes to libavfilter (1 of 5 files). Show all
Unified · Split
| @@ -188,9 +188,9 @@ static int color_balance8_p(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 187 unmodified lines | ||
| 188 | 188 | if (s->preserve_lightness) |
| 189 | 189 | preservel(&r, &g, &b, l); |
| 190 | 190 | |
| 191 | − dstr[j] = av_clip_uint8(r * max); | |
| 192 | − dstg[j] = av_clip_uint8(g * max); | |
| 193 | − dstb[j] = av_clip_uint8(b * max); | |
| 191 | + dstr[j] = av_clip_uint8(lrintf(r * max)); | |
| 192 | + dstg[j] = av_clip_uint8(lrintf(g * max)); | |
| 193 | + dstb[j] = av_clip_uint8(lrintf(b * max)); | |
| 194 | 194 | if (in != out && out->linesize[3]) |
| 195 | 195 | dsta[j] = srca[j]; |
| 196 | 196 | } |
| @@ -242,9 +242,9 @@ static int color_balance16_p(AVFilterContext *ctx, void *arg, int jobnr, int nb_ · 45 unmodified lines | ||
| 242 | 242 | if (s->preserve_lightness) |
| 243 | 243 | preservel(&r, &g, &b, l); |
| 244 | 244 | |
| 245 | − dstr[j] = av_clip_uintp2_c(r * max, depth); | |
| 246 | − dstg[j] = av_clip_uintp2_c(g * max, depth); | |
| 247 | − dstb[j] = av_clip_uintp2_c(b * max, depth); | |
| 245 | + dstr[j] = av_clip_uintp2_c(lrintf(r * max), depth); | |
| 246 | + dstg[j] = av_clip_uintp2_c(lrintf(g * max), depth); | |
| 247 | + dstb[j] = av_clip_uintp2_c(lrintf(b * max), depth); | |
| 248 | 248 | if (in != out && out->linesize[3]) |
| 249 | 249 | dsta[j] = srca[j]; |
| 250 | 250 | } |
| @@ -299,9 +299,9 @@ static int color_balance8(AVFilterContext *ctx, void *arg, int jobnr, int nb_job · 48 unmodified lines | ||
| 299 | 299 | if (s->preserve_lightness) |
| 300 | 300 | preservel(&r, &g, &b, l); |
| 301 | 301 | |
| 302 | − dst[j + roffset] = av_clip_uint8(r * max); | |
| 303 | − dst[j + goffset] = av_clip_uint8(g * max); | |
| 304 | − dst[j + boffset] = av_clip_uint8(b * max); | |
| 302 | + dst[j + roffset] = av_clip_uint8(lrintf(r * max)); | |
| 303 | + dst[j + goffset] = av_clip_uint8(lrintf(g * max)); | |
| 304 | + dst[j + boffset] = av_clip_uint8(lrintf(b * max)); | |
| 305 | 305 | if (in != out && step == 4) |
| 306 | 306 | dst[j + aoffset] = src[j + aoffset]; |
| 307 | 307 | } |
| @@ -351,9 +351,9 @@ static int color_balance16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo · 43 unmodified lines | ||
| 351 | 351 | if (s->preserve_lightness) |
| 352 | 352 | preservel(&r, &g, &b, l); |
| 353 | 353 | |
| 354 | − dst[j + roffset] = av_clip_uintp2_c(r * max, depth); | |
| 355 | − dst[j + goffset] = av_clip_uintp2_c(g * max, depth); | |
| 356 | − dst[j + boffset] = av_clip_uintp2_c(b * max, depth); | |
| 354 | + dst[j + roffset] = av_clip_uintp2_c(lrintf(r * max), depth); | |
| 355 | + dst[j + goffset] = av_clip_uintp2_c(lrintf(g * max), depth); | |
| 356 | + dst[j + boffset] = av_clip_uintp2_c(lrintf(b * max), depth); | |
| 357 | 357 | if (in != out && step == 4) |
| 358 | 358 | dst[j + aoffset] = src[j + aoffset]; |
| 359 | 359 | } |