History

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.

Limin Wang committed 6 years ago

Commit 49054fe1 parent c367d145 files · +24 −24Browse files

Showing the changes to libavfilter (1 of 5 files). Show all

Unified · Split

libavfilter/vf_colorbalance.c+12−12
@@ -188,9 +188,9 @@ static int color_balance8_p(AVFilterContext *ctx, void *arg, int jobnr, int nb_j · 187 unmodified lines
188188 if (s->preserve_lightness)
189189 preservel(&r, &g, &b, l);
190190
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));
194194 if (in != out && out->linesize[3])
195195 dsta[j] = srca[j];
196196 }
@@ -242,9 +242,9 @@ static int color_balance16_p(AVFilterContext *ctx, void *arg, int jobnr, int nb_ · 45 unmodified lines
242242 if (s->preserve_lightness)
243243 preservel(&r, &g, &b, l);
244244
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);
248248 if (in != out && out->linesize[3])
249249 dsta[j] = srca[j];
250250 }
@@ -299,9 +299,9 @@ static int color_balance8(AVFilterContext *ctx, void *arg, int jobnr, int nb_job · 48 unmodified lines
299299 if (s->preserve_lightness)
300300 preservel(&r, &g, &b, l);
301301
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));
305305 if (in != out && step == 4)
306306 dst[j + aoffset] = src[j + aoffset];
307307 }
@@ -351,9 +351,9 @@ static int color_balance16(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo · 43 unmodified lines
351351 if (s->preserve_lightness)
352352 preservel(&r, &g, &b, l);
353353
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);
357357 if (in != out && step == 4)
358358 dst[j + aoffset] = src[j + aoffset];
359359 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t