Converting to double before the multiplication rather than after avoids an integer overflow in some cases.
Unified · Split
| @@ -2409,7 +2409,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 2408 unmodified lines | |||
| 2409 | for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) { | 2409 | for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) { |
| 2410 | int framerate= get_std_framerate(i); | 2410 | int framerate= get_std_framerate(i); |
| 2411 | int ticks= lrintf(dur*framerate/(1001*12)); | 2411 | int ticks= lrintf(dur*framerate/(1001*12)); |
| 2412 | double error= dur - ticks*1001*12/(double)framerate; | 2412 | double error = dur - (double)ticks*1001*12 / framerate; |
| 2413 | st->info->duration_error[i] += error*error; | 2413 | st->info->duration_error[i] += error*error; |
| 2414 | } | 2414 | } |
| 2415 | st->info->duration_count++; | 2415 | st->info->duration_count++; |