Am 19.07.19 um 20:01 schrieb Nicolas George: > Ulf Zibis (12019-07-19): >> May be, but I believe single rounding over twice rounding is less fragile. > Yes. And two plastic bags will slow your fall more than one when you > jump from a plane. > >> Try this: >> printf("single rounding: %.40f\n", 130560LL * 1 / (double)12800); >> printf("twice rounding: %.40f\n", 130560LL * (double)(1 / >> (double)12800)); >> Result: >> single rounding: 10.1999999999999992894572642398998141288757 >> twice rounding: 10.2000000000000010658141036401502788066864 >> The 1st result is closer to 10.2 as the 2nd. > By a completely negligible difference. The wing beat of a butterfly can trigger a hurricane. > And that is assuming it would hold for other values of 10.2, which I am not > convinced. Then try this: #define TIME_BASE 12800 // typical time base for 25 fps video int false_single = 0, false_twice = 0; for (int t = 0; t < 100 * 100; t += 4) { char expr_str[16], end, *end_p = &end; sprintf(expr_str, "%6g", t/(float)100); // simulate string from command line double expr_parsed = strtod(expr_str, &end_p); // ... to parse int64_t pts = t * TIME_BASE / 100; double t_single = pts * 1 / (double)TIME_BASE; double t_twice = pts * (double)(1 / (double)TIME_BASE); int r_single = expr_parsed == t_single; int r_twice = expr_parsed == t_twice; /* printf("time:%6s, pts:%8ld, parsed:%22.18f, t_single:%22.18f=%s, t_twice:%22.18f=%s\n", expr_str, pts, expr_parsed, t_single, r_single ? "true " : "false", t_twice, r_twice ? "true " : "false"); */ false_single += !r_single; false_twice += !r_twice; }
printf("single rounding fails: %d, twice rounding fails: %d, in %d frames\n", false_single, false_twice, 100 * 100 / 4); Result: single rounding fails: 0, twice rounding fails: 327, in 2500 frames > You are wasting your time and making the code less readable for no > actual benefit. Finding out, why the select filter doesn't work as I expected, wasted enough time, so some time more doesn't matter ;-) -Ulf _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".