Opened 22 months ago
Last modified 21 months ago
#9817 new defect
libavutil/eval.c "double" error comparison is equal to
Reported by: | 张文兵 | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avutil |
Version: | git-master | Keywords: | |
Cc: | 张文兵 | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
libavutil/eval.c
func eval_expr
case e_between: { double d = eval_expr(p, e->param[0]); return e->value * (d >= eval_expr(p, e->param[1]) && d <= eval_expr(p, e->param[2])); } ...... case e_eq: return e->value * (d == d2 ? 1.0 : 0.0); case e_gte: return e->value * (d >= d2 ? 1.0 : 0.0); case e_lte: return e->value * (d <= d2 ? 1.0 : 0.0);
Change History (4)
follow-up: 2 comment:1 by , 22 months ago
comment:2 by , 22 months ago
Replying to Gyan:
Can you elaborate what the bug is?
Two "doubles" cannot be used directly as equals, because the precision problem will cause two values that look the same to be unequal.
ffmpeg -i <input> -vf "fps=fps=25,settb=AVTB,setpts=PTS-STARTPTS,delogo=x=432:y=1:w=173:h=463:enable='between(t,2376.760000,2381.400000)'" -s 1920x1080 -y -pix_fmt yuv420p -c:v libx264 -preset ultrafast -r 25.000000 -acodec aac -strict -2 -ac 2 -ar 48000 <output>
"between(t,2376.760000,2381.400000)'" cannot correctly determine 2376.760000
Here is how to reproduce.
#include <inttypes.h> #include <math.h> #include <stdio.h> int main(void) { int64_t pts = 2376760000; double t = pts * (1 / (double)(1000000)); double myt = 2376.76; printf("t:%.32f myt:%.32f pts:%lld %d\n", t, myt, pts, myt == t); return 0; } // int main(void) { // int64_t pts = 59419; // double t = pts * (1 / (double)(25)); // double myt = 2376.76; // printf("t:%.32f myt:%.32f pts:%lld %d\n", // t, // myt, // pts, // myt == t); // return 0; // }
comment:4 by , 21 months ago
Priority: | important → normal |
---|
Note:
See TracTickets
for help on using tickets.
Can you elaborate what the bug is?