[FFmpeg-trac] #9817(avutil:new): libavutil/eval.c "double" error comparison is equal to

FFmpeg trac at avcodec.org
Thu Jun 23 11:08:16 EEST 2022


#9817: libavutil/eval.c "double" error comparison is equal to
------------------------------------+----------------------------------
             Reporter:  张文兵      |                    Owner:  (none)
                 Type:  defect      |                   Status:  new
             Priority:  important   |                Component:  avutil
              Version:  git-master  |               Resolution:
             Keywords:              |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+----------------------------------
Comment (by 张文兵):

 Replying to [comment:1 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 "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;
 // }
 }}}
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9817#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list